From d6be7a02d9cf817d3e3d19167d87e52260620ecd Mon Sep 17 00:00:00 2001 From: Chris Ruffin Date: Mon, 15 Sep 2014 00:38:00 +0100 Subject: staging: iio: accel: remove unnecessary syntax The else clause in the conditional of lis3l02dq_data_rdy_trig_poll() does not make consistent use of braces with the rest of the conditional. Fix this coding style problem by removing the unnecessary conditional altogether. Signed-off-by: Chris Ruffin Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/lis3l02dq_ring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 1d934ee3bb5f..9efc77b0ebdd 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -34,8 +34,9 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private) if (st->trigger_on) { iio_trigger_poll(st->trig); return IRQ_HANDLED; - } else - return IRQ_WAKE_THREAD; + } + + return IRQ_WAKE_THREAD; } static const u8 read_all_tx_array[] = { -- cgit v1.2.3-59-g8ed1b From 774623ca41280f74f499416fbbba3b1afbdd910e Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 19 Sep 2014 13:58:00 +0100 Subject: iio:adc:vf610-adc: Add temperature sensor support Vybrid ADC peripheral includes a temperature sensor which is connected to channel number 26. This patch adds support for the sensor. The raw value is read and the temperature calculated in milli degree Celsius, which is returned using IIO_CHAN_INFO_PROCESSED option. Signed-off-by: Sanchayan Maity Signed-off-by: Jonathan Cameron --- drivers/iio/adc/vf610_adc.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 4a10ae97dbf2..7ec21b5612ef 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -91,7 +91,7 @@ #define VF610_ADC_CAL 0x80 /* Other field define */ -#define VF610_ADC_ADCHC(x) ((x) & 0xF) +#define VF610_ADC_ADCHC(x) ((x) & 0x1F) #define VF610_ADC_AIEN (0x1 << 7) #define VF610_ADC_CONV_DISABLE 0x1F #define VF610_ADC_HS_COCO0 0x1 @@ -153,6 +153,12 @@ struct vf610_adc { BIT(IIO_CHAN_INFO_SAMP_FREQ), \ } +#define VF610_ADC_TEMPERATURE_CHAN(_idx, _chan_type) { \ + .type = (_chan_type), \ + .channel = (_idx), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \ +} + static const struct iio_chan_spec vf610_adc_iio_channels[] = { VF610_ADC_CHAN(0, IIO_VOLTAGE), VF610_ADC_CHAN(1, IIO_VOLTAGE), @@ -170,6 +176,7 @@ static const struct iio_chan_spec vf610_adc_iio_channels[] = { VF610_ADC_CHAN(13, IIO_VOLTAGE), VF610_ADC_CHAN(14, IIO_VOLTAGE), VF610_ADC_CHAN(15, IIO_VOLTAGE), + VF610_ADC_TEMPERATURE_CHAN(26, IIO_TEMP), /* sentinel */ }; @@ -451,6 +458,7 @@ static int vf610_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: + case IIO_CHAN_INFO_PROCESSED: mutex_lock(&indio_dev->mlock); reinit_completion(&info->completion); @@ -468,7 +476,23 @@ static int vf610_read_raw(struct iio_dev *indio_dev, return ret; } - *val = info->value; + switch (chan->type) { + case IIO_VOLTAGE: + *val = info->value; + break; + case IIO_TEMP: + /* + * Calculate in degree Celsius times 1000 + * Using sensor slope of 1.84 mV/°C and + * V at 25°C of 696 mV + */ + *val = 25000 - ((int)info->value - 864) * 1000000 / 1840; + break; + default: + mutex_unlock(&indio_dev->mlock); + return -EINVAL; + } + mutex_unlock(&indio_dev->mlock); return IIO_VAL_INT; -- cgit v1.2.3-59-g8ed1b From 4c21bbb475c16be9ec878e8753d5e8373f9b9d59 Mon Sep 17 00:00:00 2001 From: Heiko Stübner Date: Mon, 15 Sep 2014 22:47:00 +0100 Subject: iio: adc: rockchip_saradc: add support for rk3066-tsadc variant Older Rockchip SoCs, at least the rk3066, used a slightly modified saradc for temperature measurements. This so called tsadc does not contain any active parts like temperature interrupts and only supports polling the current temperature. The returned voltage can then be converted by a suitable thermal driver to and actual temperature and used for thermal handling. Signed-off-by: Heiko Stuebner Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/rockchip-saradc.txt | 2 +- drivers/iio/adc/rockchip_saradc.c | 64 +++++++++++++++++----- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt index 5d3ec1df226d..a9a5fe19ff2a 100644 --- a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt +++ b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt @@ -1,7 +1,7 @@ Rockchip Successive Approximation Register (SAR) A/D Converter bindings Required properties: -- compatible: Should be "rockchip,saradc" +- compatible: Should be "rockchip,saradc" or "rockchip,rk3066-tsadc" - reg: physical base address of the controller and length of memory mapped region. - interrupts: The interrupt number to the cpu. The interrupt specifier format diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index e074a0b03f28..b546bc1a9c30 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -18,13 +18,13 @@ #include #include #include +#include #include #include #include #include #define SARADC_DATA 0x00 -#define SARADC_DATA_MASK 0x3ff #define SARADC_STAS 0x04 #define SARADC_STAS_BUSY BIT(0) @@ -38,15 +38,22 @@ #define SARADC_DLY_PU_SOC 0x0c #define SARADC_DLY_PU_SOC_MASK 0x3f -#define SARADC_BITS 10 #define SARADC_TIMEOUT msecs_to_jiffies(100) +struct rockchip_saradc_data { + int num_bits; + const struct iio_chan_spec *channels; + int num_channels; + unsigned long clk_rate; +}; + struct rockchip_saradc { void __iomem *regs; struct clk *pclk; struct clk *clk; struct completion completion; struct regulator *vref; + const struct rockchip_saradc_data *data; u16 last_val; }; @@ -90,7 +97,7 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev, } *val = ret / 1000; - *val2 = SARADC_BITS; + *val2 = info->data->num_bits; return IIO_VAL_FRACTIONAL_LOG2; default: return -EINVAL; @@ -103,7 +110,7 @@ static irqreturn_t rockchip_saradc_isr(int irq, void *dev_id) /* Read value */ info->last_val = readl_relaxed(info->regs + SARADC_DATA); - info->last_val &= SARADC_DATA_MASK; + info->last_val &= GENMASK(info->data->num_bits - 1, 0); /* Clear irq & power down adc */ writel_relaxed(0, info->regs + SARADC_CTRL); @@ -133,12 +140,44 @@ static const struct iio_chan_spec rockchip_saradc_iio_channels[] = { ADC_CHANNEL(2, "adc2"), }; +static const struct rockchip_saradc_data saradc_data = { + .num_bits = 10, + .channels = rockchip_saradc_iio_channels, + .num_channels = ARRAY_SIZE(rockchip_saradc_iio_channels), + .clk_rate = 1000000, +}; + +static const struct iio_chan_spec rockchip_rk3066_tsadc_iio_channels[] = { + ADC_CHANNEL(0, "adc0"), + ADC_CHANNEL(1, "adc1"), +}; + +static const struct rockchip_saradc_data rk3066_tsadc_data = { + .num_bits = 12, + .channels = rockchip_rk3066_tsadc_iio_channels, + .num_channels = ARRAY_SIZE(rockchip_rk3066_tsadc_iio_channels), + .clk_rate = 50000, +}; + +static const struct of_device_id rockchip_saradc_match[] = { + { + .compatible = "rockchip,saradc", + .data = &saradc_data, + }, { + .compatible = "rockchip,rk3066-tsadc", + .data = &rk3066_tsadc_data, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_saradc_match); + static int rockchip_saradc_probe(struct platform_device *pdev) { struct rockchip_saradc *info = NULL; struct device_node *np = pdev->dev.of_node; struct iio_dev *indio_dev = NULL; struct resource *mem; + const struct of_device_id *match; int ret; int irq; @@ -152,6 +191,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev) } info = iio_priv(indio_dev); + match = of_match_device(rockchip_saradc_match, &pdev->dev); + info->data = match->data; + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); info->regs = devm_ioremap_resource(&pdev->dev, mem); if (IS_ERR(info->regs)) @@ -192,10 +234,10 @@ static int rockchip_saradc_probe(struct platform_device *pdev) } /* - * Use a default of 1MHz for the converter clock. + * Use a default value for the converter clock. * This may become user-configurable in the future. */ - ret = clk_set_rate(info->clk, 1000000); + ret = clk_set_rate(info->clk, info->data->clk_rate); if (ret < 0) { dev_err(&pdev->dev, "failed to set adc clk rate, %d\n", ret); return ret; @@ -227,8 +269,8 @@ static int rockchip_saradc_probe(struct platform_device *pdev) indio_dev->info = &rockchip_saradc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = rockchip_saradc_iio_channels; - indio_dev->num_channels = ARRAY_SIZE(rockchip_saradc_iio_channels); + indio_dev->channels = info->data->channels; + indio_dev->num_channels = info->data->num_channels; ret = iio_device_register(indio_dev); if (ret) @@ -296,12 +338,6 @@ static int rockchip_saradc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(rockchip_saradc_pm_ops, rockchip_saradc_suspend, rockchip_saradc_resume); -static const struct of_device_id rockchip_saradc_match[] = { - { .compatible = "rockchip,saradc" }, - {}, -}; -MODULE_DEVICE_TABLE(of, rockchip_saradc_match); - static struct platform_driver rockchip_saradc_driver = { .probe = rockchip_saradc_probe, .remove = rockchip_saradc_remove, -- cgit v1.2.3-59-g8ed1b From c20d4dffd537bee8d3db5ec28ca871ef73d44078 Mon Sep 17 00:00:00 2001 From: Jacob Pan Date: Wed, 17 Sep 2014 01:11:00 +0100 Subject: iio: add documentation for current attribute Add documentation for input current raw sysfs attribute. Signed-off-by: Jacob Pan Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index d760b0224ef7..1ac9ac20f530 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1028,3 +1028,12 @@ Contact: linux-iio@vger.kernel.org Description: Raw value of rotation from true/magnetic north measured with or without compensation from tilt sensors. + +What: /sys/bus/iio/devices/iio:deviceX/in_currentX_raw +KernelVersion: 3.18 +Contact: linux-iio@vger.kernel.org +Description: + Raw current measurement from channel X. Units are in milliamps + after application of scale and offset. If no offset or scale is + present, output should be considered as processed with the + unit in milliamps. -- cgit v1.2.3-59-g8ed1b From a7ee8839daf21c4a3ca439733e7bed25f32e7954 Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:35 +0200 Subject: iio:imu: changed structure name from st_sensors to st_sensor_settings This patch change structure name and related variables names. Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 13 +-- drivers/iio/common/st_sensors/st_sensors_core.c | 126 +++++++++++++----------- drivers/iio/gyro/st_gyro_core.c | 13 +-- drivers/iio/magnetometer/st_magn_core.c | 13 +-- drivers/iio/pressure/st_pressure_core.c | 20 ++-- include/linux/iio/common/st_sensors.h | 10 +- 6 files changed, 104 insertions(+), 91 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 087864854c61..7cbdfae03441 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -161,7 +161,7 @@ static const struct iio_chan_spec st_accel_16bit_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3) }; -static const struct st_sensors st_accel_sensors[] = { +static const struct st_sensor_settings st_accel_sensors_settings[] = { { .wai = ST_ACCEL_1_WAI_EXP, .sensors_supported = { @@ -470,18 +470,19 @@ int st_accel_common_probe(struct iio_dev *indio_dev, st_sensors_power_enable(indio_dev); err = st_sensors_check_device_support(indio_dev, - ARRAY_SIZE(st_accel_sensors), st_accel_sensors); + ARRAY_SIZE(st_accel_sensors_settings), + st_accel_sensors_settings); if (err < 0) return err; adata->num_data_channels = ST_ACCEL_NUMBER_DATA_CHANNELS; - adata->multiread_bit = adata->sensor->multi_read_bit; - indio_dev->channels = adata->sensor->ch; + adata->multiread_bit = adata->sensor_settings->multi_read_bit; + indio_dev->channels = adata->sensor_settings->ch; indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS; adata->current_fullscale = (struct st_sensor_fullscale_avl *) - &adata->sensor->fs.fs_avl[0]; - adata->odr = adata->sensor->odr.odr_avl[0].hz; + &adata->sensor_settings->fs.fs_avl[0]; + adata->odr = adata->sensor_settings->odr.odr_avl[0].hz; if (!plat_data) plat_data = diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 24cfe4e044f9..edd13d2b4121 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -44,18 +44,18 @@ st_sensors_write_data_with_mask_error: return err; } -static int st_sensors_match_odr(struct st_sensors *sensor, +static int st_sensors_match_odr(struct st_sensor_settings *sensor_settings, unsigned int odr, struct st_sensor_odr_avl *odr_out) { int i, ret = -EINVAL; for (i = 0; i < ST_SENSORS_ODR_LIST_MAX; i++) { - if (sensor->odr.odr_avl[i].hz == 0) + if (sensor_settings->odr.odr_avl[i].hz == 0) goto st_sensors_match_odr_error; - if (sensor->odr.odr_avl[i].hz == odr) { - odr_out->hz = sensor->odr.odr_avl[i].hz; - odr_out->value = sensor->odr.odr_avl[i].value; + if (sensor_settings->odr.odr_avl[i].hz == odr) { + odr_out->hz = sensor_settings->odr.odr_avl[i].hz; + odr_out->value = sensor_settings->odr.odr_avl[i].value; ret = 0; break; } @@ -71,23 +71,26 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr) struct st_sensor_odr_avl odr_out = {0, 0}; struct st_sensor_data *sdata = iio_priv(indio_dev); - err = st_sensors_match_odr(sdata->sensor, odr, &odr_out); + err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out); if (err < 0) goto st_sensors_match_odr_error; - if ((sdata->sensor->odr.addr == sdata->sensor->pw.addr) && - (sdata->sensor->odr.mask == sdata->sensor->pw.mask)) { + if ((sdata->sensor_settings->odr.addr == + sdata->sensor_settings->pw.addr) && + (sdata->sensor_settings->odr.mask == + sdata->sensor_settings->pw.mask)) { if (sdata->enabled == true) { err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->odr.addr, - sdata->sensor->odr.mask, + sdata->sensor_settings->odr.addr, + sdata->sensor_settings->odr.mask, odr_out.value); } else { err = 0; } } else { err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->odr.addr, sdata->sensor->odr.mask, + sdata->sensor_settings->odr.addr, + sdata->sensor_settings->odr.mask, odr_out.value); } if (err >= 0) @@ -98,16 +101,16 @@ st_sensors_match_odr_error: } EXPORT_SYMBOL(st_sensors_set_odr); -static int st_sensors_match_fs(struct st_sensors *sensor, +static int st_sensors_match_fs(struct st_sensor_settings *sensor_settings, unsigned int fs, int *index_fs_avl) { int i, ret = -EINVAL; for (i = 0; i < ST_SENSORS_FULLSCALE_AVL_MAX; i++) { - if (sensor->fs.fs_avl[i].num == 0) + if (sensor_settings->fs.fs_avl[i].num == 0) goto st_sensors_match_odr_error; - if (sensor->fs.fs_avl[i].num == fs) { + if (sensor_settings->fs.fs_avl[i].num == fs) { *index_fs_avl = i; ret = 0; break; @@ -118,25 +121,24 @@ st_sensors_match_odr_error: return ret; } -static int st_sensors_set_fullscale(struct iio_dev *indio_dev, - unsigned int fs) +static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs) { int err, i = 0; struct st_sensor_data *sdata = iio_priv(indio_dev); - err = st_sensors_match_fs(sdata->sensor, fs, &i); + err = st_sensors_match_fs(sdata->sensor_settings, fs, &i); if (err < 0) goto st_accel_set_fullscale_error; err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->fs.addr, - sdata->sensor->fs.mask, - sdata->sensor->fs.fs_avl[i].value); + sdata->sensor_settings->fs.addr, + sdata->sensor_settings->fs.mask, + sdata->sensor_settings->fs.fs_avl[i].value); if (err < 0) goto st_accel_set_fullscale_error; sdata->current_fullscale = (struct st_sensor_fullscale_avl *) - &sdata->sensor->fs.fs_avl[i]; + &sdata->sensor_settings->fs.fs_avl[i]; return err; st_accel_set_fullscale_error: @@ -153,10 +155,12 @@ int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable) struct st_sensor_data *sdata = iio_priv(indio_dev); if (enable) { - tmp_value = sdata->sensor->pw.value_on; - if ((sdata->sensor->odr.addr == sdata->sensor->pw.addr) && - (sdata->sensor->odr.mask == sdata->sensor->pw.mask)) { - err = st_sensors_match_odr(sdata->sensor, + tmp_value = sdata->sensor_settings->pw.value_on; + if ((sdata->sensor_settings->odr.addr == + sdata->sensor_settings->pw.addr) && + (sdata->sensor_settings->odr.mask == + sdata->sensor_settings->pw.mask)) { + err = st_sensors_match_odr(sdata->sensor_settings, sdata->odr, &odr_out); if (err < 0) goto set_enable_error; @@ -164,8 +168,8 @@ int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable) found = true; } err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->pw.addr, - sdata->sensor->pw.mask, tmp_value); + sdata->sensor_settings->pw.addr, + sdata->sensor_settings->pw.mask, tmp_value); if (err < 0) goto set_enable_error; @@ -175,9 +179,9 @@ int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable) sdata->odr = odr_out.hz; } else { err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->pw.addr, - sdata->sensor->pw.mask, - sdata->sensor->pw.value_off); + sdata->sensor_settings->pw.addr, + sdata->sensor_settings->pw.mask, + sdata->sensor_settings->pw.value_off); if (err < 0) goto set_enable_error; @@ -194,8 +198,9 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) struct st_sensor_data *sdata = iio_priv(indio_dev); return st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->enable_axis.addr, - sdata->sensor->enable_axis.mask, axis_enable); + sdata->sensor_settings->enable_axis.addr, + sdata->sensor_settings->enable_axis.mask, + axis_enable); } EXPORT_SYMBOL(st_sensors_set_axis_enable); @@ -236,13 +241,13 @@ void st_sensors_power_disable(struct iio_dev *indio_dev) EXPORT_SYMBOL(st_sensors_power_disable); static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata) + struct st_sensors_platform_data *pdata) { struct st_sensor_data *sdata = iio_priv(indio_dev); switch (pdata->drdy_int_pin) { case 1: - if (sdata->sensor->drdy_irq.mask_int1 == 0) { + if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) { dev_err(&indio_dev->dev, "DRDY on INT1 not available.\n"); return -EINVAL; @@ -250,7 +255,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, sdata->drdy_int_pin = 1; break; case 2: - if (sdata->sensor->drdy_irq.mask_int2 == 0) { + if (sdata->sensor_settings->drdy_irq.mask_int2 == 0) { dev_err(&indio_dev->dev, "DRDY on INT2 not available.\n"); return -EINVAL; @@ -318,7 +323,7 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, if (sdata->current_fullscale) { err = st_sensors_set_fullscale(indio_dev, - sdata->current_fullscale->num); + sdata->current_fullscale->num); if (err < 0) return err; } else @@ -330,7 +335,8 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, /* set BDU */ err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->bdu.addr, sdata->sensor->bdu.mask, true); + sdata->sensor_settings->bdu.addr, + sdata->sensor_settings->bdu.mask, true); if (err < 0) return err; @@ -346,26 +352,28 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) u8 drdy_mask; struct st_sensor_data *sdata = iio_priv(indio_dev); - if (!sdata->sensor->drdy_irq.addr) + if (!sdata->sensor_settings->drdy_irq.addr) return 0; /* Enable/Disable the interrupt generator 1. */ - if (sdata->sensor->drdy_irq.ig1.en_addr > 0) { + if (sdata->sensor_settings->drdy_irq.ig1.en_addr > 0) { err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->drdy_irq.ig1.en_addr, - sdata->sensor->drdy_irq.ig1.en_mask, (int)enable); + sdata->sensor_settings->drdy_irq.ig1.en_addr, + sdata->sensor_settings->drdy_irq.ig1.en_mask, + (int)enable); if (err < 0) goto st_accel_set_dataready_irq_error; } if (sdata->drdy_int_pin == 1) - drdy_mask = sdata->sensor->drdy_irq.mask_int1; + drdy_mask = sdata->sensor_settings->drdy_irq.mask_int1; else - drdy_mask = sdata->sensor->drdy_irq.mask_int2; + drdy_mask = sdata->sensor_settings->drdy_irq.mask_int2; /* Enable/Disable the interrupt generator for data ready. */ err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->drdy_irq.addr, drdy_mask, (int)enable); + sdata->sensor_settings->drdy_irq.addr, + drdy_mask, (int)enable); st_accel_set_dataready_irq_error: return err; @@ -378,8 +386,8 @@ int st_sensors_set_fullscale_by_gain(struct iio_dev *indio_dev, int scale) struct st_sensor_data *sdata = iio_priv(indio_dev); for (i = 0; i < ST_SENSORS_FULLSCALE_AVL_MAX; i++) { - if ((sdata->sensor->fs.fs_avl[i].gain == scale) && - (sdata->sensor->fs.fs_avl[i].gain != 0)) { + if ((sdata->sensor_settings->fs.fs_avl[i].gain == scale) && + (sdata->sensor_settings->fs.fs_avl[i].gain != 0)) { err = 0; break; } @@ -388,7 +396,7 @@ int st_sensors_set_fullscale_by_gain(struct iio_dev *indio_dev, int scale) goto st_sensors_match_scale_error; err = st_sensors_set_fullscale(indio_dev, - sdata->sensor->fs.fs_avl[i].num); + sdata->sensor_settings->fs.fs_avl[i].num); st_sensors_match_scale_error: return err; @@ -439,7 +447,7 @@ int st_sensors_read_info_raw(struct iio_dev *indio_dev, if (err < 0) goto out; - msleep((sdata->sensor->bootime * 1000) / sdata->odr); + msleep((sdata->sensor_settings->bootime * 1000) / sdata->odr); err = st_sensors_read_axis_data(indio_dev, ch, val); if (err < 0) goto out; @@ -456,7 +464,8 @@ out: EXPORT_SYMBOL(st_sensors_read_info_raw); int st_sensors_check_device_support(struct iio_dev *indio_dev, - int num_sensors_list, const struct st_sensors *sensors) + int num_sensors_list, + const struct st_sensor_settings *sensor_settings) { u8 wai; int i, n, err; @@ -470,23 +479,24 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev, } for (i = 0; i < num_sensors_list; i++) { - if (sensors[i].wai == wai) + if (sensor_settings[i].wai == wai) break; } if (i == num_sensors_list) goto device_not_supported; - for (n = 0; n < ARRAY_SIZE(sensors[i].sensors_supported); n++) { + for (n = 0; n < ARRAY_SIZE(sensor_settings[i].sensors_supported); n++) { if (strcmp(indio_dev->name, - &sensors[i].sensors_supported[n][0]) == 0) + &sensor_settings[i].sensors_supported[n][0]) == 0) break; } - if (n == ARRAY_SIZE(sensors[i].sensors_supported)) { + if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) { dev_err(&indio_dev->dev, "device name and WhoAmI mismatch.\n"); goto sensor_name_mismatch; } - sdata->sensor = (struct st_sensors *)&sensors[i]; + sdata->sensor_settings = + (struct st_sensor_settings *)&sensor_settings[i]; return i; @@ -508,11 +518,11 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev, mutex_lock(&indio_dev->mlock); for (i = 0; i < ST_SENSORS_ODR_LIST_MAX; i++) { - if (sdata->sensor->odr.odr_avl[i].hz == 0) + if (sdata->sensor_settings->odr.odr_avl[i].hz == 0) break; len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", - sdata->sensor->odr.odr_avl[i].hz); + sdata->sensor_settings->odr.odr_avl[i].hz); } mutex_unlock(&indio_dev->mlock); buf[len - 1] = '\n'; @@ -530,11 +540,11 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev, mutex_lock(&indio_dev->mlock); for (i = 0; i < ST_SENSORS_FULLSCALE_AVL_MAX; i++) { - if (sdata->sensor->fs.fs_avl[i].num == 0) + if (sdata->sensor_settings->fs.fs_avl[i].num == 0) break; len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", - sdata->sensor->fs.fs_avl[i].gain); + sdata->sensor_settings->fs.fs_avl[i].gain); } mutex_unlock(&indio_dev->mlock); buf[len - 1] = '\n'; diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index f156fc6c5c6c..9d41b68d24b2 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -103,7 +103,7 @@ static const struct iio_chan_spec st_gyro_16bit_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3) }; -static const struct st_sensors st_gyro_sensors[] = { +static const struct st_sensor_settings st_gyro_sensors_settings[] = { { .wai = ST_GYRO_1_WAI_EXP, .sensors_supported = { @@ -322,18 +322,19 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, st_sensors_power_enable(indio_dev); err = st_sensors_check_device_support(indio_dev, - ARRAY_SIZE(st_gyro_sensors), st_gyro_sensors); + ARRAY_SIZE(st_gyro_sensors_settings), + st_gyro_sensors_settings); if (err < 0) return err; gdata->num_data_channels = ST_GYRO_NUMBER_DATA_CHANNELS; - gdata->multiread_bit = gdata->sensor->multi_read_bit; - indio_dev->channels = gdata->sensor->ch; + gdata->multiread_bit = gdata->sensor_settings->multi_read_bit; + indio_dev->channels = gdata->sensor_settings->ch; indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS; gdata->current_fullscale = (struct st_sensor_fullscale_avl *) - &gdata->sensor->fs.fs_avl[0]; - gdata->odr = gdata->sensor->odr.odr_avl[0].hz; + &gdata->sensor_settings->fs.fs_avl[0]; + gdata->odr = gdata->sensor_settings->odr.odr_avl[0].hz; err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index a4b64130ac2f..b65405fada45 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -146,7 +146,7 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3) }; -static const struct st_sensors st_magn_sensors[] = { +static const struct st_sensor_settings st_magn_sensors_settings[] = { { .wai = ST_MAGN_1_WAI_EXP, .sensors_supported = { @@ -366,18 +366,19 @@ int st_magn_common_probe(struct iio_dev *indio_dev, st_sensors_power_enable(indio_dev); err = st_sensors_check_device_support(indio_dev, - ARRAY_SIZE(st_magn_sensors), st_magn_sensors); + ARRAY_SIZE(st_magn_sensors_settings), + st_magn_sensors_settings); if (err < 0) return err; mdata->num_data_channels = ST_MAGN_NUMBER_DATA_CHANNELS; - mdata->multiread_bit = mdata->sensor->multi_read_bit; - indio_dev->channels = mdata->sensor->ch; + mdata->multiread_bit = mdata->sensor_settings->multi_read_bit; + indio_dev->channels = mdata->sensor_settings->ch; indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS; mdata->current_fullscale = (struct st_sensor_fullscale_avl *) - &mdata->sensor->fs.fs_avl[0]; - mdata->odr = mdata->sensor->odr.odr_avl[0].hz; + &mdata->sensor_settings->fs.fs_avl[0]; + mdata->odr = mdata->sensor_settings->odr.odr_avl[0].hz; err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 473d914ef470..9563118c4d36 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -175,7 +175,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(1) }; -static const struct st_sensors st_press_sensors[] = { +static const struct st_sensor_settings st_press_sensors_settings[] = { { .wai = ST_PRESS_LPS331AP_WAI_EXP, .sensors_supported = { @@ -422,24 +422,24 @@ int st_press_common_probe(struct iio_dev *indio_dev, st_sensors_power_enable(indio_dev); err = st_sensors_check_device_support(indio_dev, - ARRAY_SIZE(st_press_sensors), - st_press_sensors); + ARRAY_SIZE(st_press_sensors_settings), + st_press_sensors_settings); if (err < 0) return err; pdata->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; - pdata->multiread_bit = pdata->sensor->multi_read_bit; - indio_dev->channels = pdata->sensor->ch; - indio_dev->num_channels = pdata->sensor->num_ch; + pdata->multiread_bit = pdata->sensor_settings->multi_read_bit; + indio_dev->channels = pdata->sensor_settings->ch; + indio_dev->num_channels = pdata->sensor_settings->num_ch; - if (pdata->sensor->fs.addr != 0) + if (pdata->sensor_settings->fs.addr != 0) pdata->current_fullscale = (struct st_sensor_fullscale_avl *) - &pdata->sensor->fs.fs_avl[0]; + &pdata->sensor_settings->fs.fs_avl[0]; - pdata->odr = pdata->sensor->odr.odr_avl[0].hz; + pdata->odr = pdata->sensor_settings->odr.odr_avl[0].hz; /* Some devices don't support a data ready pin. */ - if (!plat_data && pdata->sensor->drdy_irq.addr) + if (!plat_data && pdata->sensor_settings->drdy_irq.addr) plat_data = (struct st_sensors_platform_data *)&default_press_pdata; diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index d8257ab60bac..2c476acb87d9 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -164,7 +164,7 @@ struct st_sensor_transfer_function { }; /** - * struct st_sensors - ST sensors list + * struct st_sensor_settings - ST specific sensor settings * @wai: Contents of WhoAmI register. * @sensors_supported: List of supported sensors by struct itself. * @ch: IIO channels for the sensor. @@ -177,7 +177,7 @@ struct st_sensor_transfer_function { * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read. * @bootime: samples to discard when sensor passing from power-down to power-up. */ -struct st_sensors { +struct st_sensor_settings { u8 wai; char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME]; struct iio_chan_spec *ch; @@ -196,7 +196,7 @@ struct st_sensors { * struct st_sensor_data - ST sensor device status * @dev: Pointer to instance of struct device (I2C or SPI). * @trig: The trigger in use by the core driver. - * @sensor: Pointer to the current sensor struct in use. + * @sensor_settings: Pointer to the specific sensor settings in use. * @current_fullscale: Maximum range of measure by the sensor. * @vdd: Pointer to sensor's Vdd power supply * @vdd_io: Pointer to sensor's Vdd-IO power supply @@ -213,7 +213,7 @@ struct st_sensors { struct st_sensor_data { struct device *dev; struct iio_trigger *trig; - struct st_sensors *sensor; + struct st_sensor_settings *sensor_settings; struct st_sensor_fullscale_avl *current_fullscale; struct regulator *vdd; struct regulator *vdd_io; @@ -279,7 +279,7 @@ int st_sensors_read_info_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *ch, int *val); int st_sensors_check_device_support(struct iio_dev *indio_dev, - int num_sensors_list, const struct st_sensors *sensors); + int num_sensors_list, const struct st_sensor_settings *sensor_settings); ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev, struct device_attribute *attr, char *buf); -- cgit v1.2.3-59-g8ed1b From b6e6bda626972d895322474f41fb64a8a731cc0c Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:36 +0200 Subject: iio:accel: Removed unnecessary parameter on common_probe function Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel.h | 3 +-- drivers/iio/accel/st_accel_core.c | 9 ++++----- drivers/iio/accel/st_accel_i2c.c | 2 +- drivers/iio/accel/st_accel_spi.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index c3877630b2e4..fa9646034305 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -33,8 +33,7 @@ static const struct st_sensors_platform_data default_accel_pdata = { .drdy_int_pin = 1, }; -int st_accel_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata); +int st_accel_common_probe(struct iio_dev *indio_dev); void st_accel_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 7cbdfae03441..53f32629283a 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -457,8 +457,7 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { #define ST_ACCEL_TRIGGER_OPS NULL #endif -int st_accel_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *plat_data) +int st_accel_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *adata = iio_priv(indio_dev); int irq = adata->get_irq_data_ready(indio_dev); @@ -484,11 +483,11 @@ int st_accel_common_probe(struct iio_dev *indio_dev, &adata->sensor_settings->fs.fs_avl[0]; adata->odr = adata->sensor_settings->odr.odr_avl[0].hz; - if (!plat_data) - plat_data = + if (!adata->dev->platform_data) + adata->dev->platform_data = (struct st_sensors_platform_data *)&default_accel_pdata; - err = st_sensors_init_sensor(indio_dev, plat_data); + err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); if (err < 0) return err; diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 7164aeff3ab1..40adc7e88a39 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -84,7 +84,7 @@ static int st_accel_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, adata); - err = st_accel_common_probe(indio_dev, client->dev.platform_data); + err = st_accel_common_probe(indio_dev); if (err < 0) return err; diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 195639646e34..2090d80062d2 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -33,7 +33,7 @@ static int st_accel_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, adata); - err = st_accel_common_probe(indio_dev, spi->dev.platform_data); + err = st_accel_common_probe(indio_dev); if (err < 0) return err; -- cgit v1.2.3-59-g8ed1b From ef67b341477e54178245dcd7b349a209ec78d29d Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:37 +0200 Subject: iio:gyro: Removed unnecessary parameter on common_probe function Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/st_gyro.h | 3 +-- drivers/iio/gyro/st_gyro_core.c | 6 +++--- drivers/iio/gyro/st_gyro_i2c.c | 3 +-- drivers/iio/gyro/st_gyro_spi.c | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/iio/gyro/st_gyro.h b/drivers/iio/gyro/st_gyro.h index c197360c450b..5353d6328c54 100644 --- a/drivers/iio/gyro/st_gyro.h +++ b/drivers/iio/gyro/st_gyro.h @@ -30,8 +30,7 @@ static const struct st_sensors_platform_data gyro_pdata = { .drdy_int_pin = 2, }; -int st_gyro_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata); +int st_gyro_common_probe(struct iio_dev *indio_dev); void st_gyro_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index 9d41b68d24b2..f07a2336f7dc 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -309,8 +309,7 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = { #define ST_GYRO_TRIGGER_OPS NULL #endif -int st_gyro_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata) +int st_gyro_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *gdata = iio_priv(indio_dev); int irq = gdata->get_irq_data_ready(indio_dev); @@ -336,7 +335,8 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, &gdata->sensor_settings->fs.fs_avl[0]; gdata->odr = gdata->sensor_settings->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev, pdata); + err = st_sensors_init_sensor(indio_dev, + (struct st_sensors_platform_data *)&gyro_pdata); if (err < 0) return err; diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index 8fa0ad2ef4ef..94d01fba4a4c 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -72,8 +72,7 @@ static int st_gyro_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, gdata); - err = st_gyro_common_probe(indio_dev, - (struct st_sensors_platform_data *)&gyro_pdata); + err = st_gyro_common_probe(indio_dev); if (err < 0) return err; diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index b4ad3be26687..3e7a01af9b61 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -33,8 +33,7 @@ static int st_gyro_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, gdata); - err = st_gyro_common_probe(indio_dev, - (struct st_sensors_platform_data *)&gyro_pdata); + err = st_gyro_common_probe(indio_dev); if (err < 0) return err; -- cgit v1.2.3-59-g8ed1b From 2109eb4c0c7d21669ae2ad0cda90c438b5470bf3 Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:38 +0200 Subject: iio:magnetometer: Removed unnecessary parameter on common_probe function Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/st_magn.h | 3 +-- drivers/iio/magnetometer/st_magn_core.c | 5 ++--- drivers/iio/magnetometer/st_magn_i2c.c | 2 +- drivers/iio/magnetometer/st_magn_spi.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index 694e33e0fb72..7e81d00ef0c3 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -18,8 +18,7 @@ #define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn" #define LIS3MDL_MAGN_DEV_NAME "lis3mdl" -int st_magn_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata); +int st_magn_common_probe(struct iio_dev *indio_dev); void st_magn_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index b65405fada45..1f3c1b7be78f 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -353,8 +353,7 @@ static const struct iio_info magn_info = { .write_raw = &st_magn_write_raw, }; -int st_magn_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata) +int st_magn_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *mdata = iio_priv(indio_dev); int irq = mdata->get_irq_data_ready(indio_dev); @@ -380,7 +379,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev, &mdata->sensor_settings->fs.fs_avl[0]; mdata->odr = mdata->sensor_settings->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev, pdata); + err = st_sensors_init_sensor(indio_dev, NULL); if (err < 0) return err; diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index 689250058442..f8a682374239 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -56,7 +56,7 @@ static int st_magn_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, mdata); - err = st_magn_common_probe(indio_dev, NULL); + err = st_magn_common_probe(indio_dev); if (err < 0) return err; diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index a6143ea51dfc..f64214237cf6 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -33,7 +33,7 @@ static int st_magn_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, mdata); - err = st_magn_common_probe(indio_dev, NULL); + err = st_magn_common_probe(indio_dev); if (err < 0) return err; -- cgit v1.2.3-59-g8ed1b From 0baa3fc1b6c1e928260ca099cbdf551ced2cbfa3 Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:39 +0200 Subject: iio:pressure: Removed unnecessary parameter on common_probe function Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure.h | 3 +-- drivers/iio/pressure/st_pressure_core.c | 9 ++++----- drivers/iio/pressure/st_pressure_i2c.c | 2 +- drivers/iio/pressure/st_pressure_spi.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index 242943c0c4e4..f5f41490060b 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -26,8 +26,7 @@ static const struct st_sensors_platform_data default_press_pdata = { .drdy_int_pin = 1, }; -int st_press_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata); +int st_press_common_probe(struct iio_dev *indio_dev); void st_press_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 9563118c4d36..ee2ef7def097 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -409,8 +409,7 @@ static const struct iio_trigger_ops st_press_trigger_ops = { #define ST_PRESS_TRIGGER_OPS NULL #endif -int st_press_common_probe(struct iio_dev *indio_dev, - struct st_sensors_platform_data *plat_data) +int st_press_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *pdata = iio_priv(indio_dev); int irq = pdata->get_irq_data_ready(indio_dev); @@ -439,11 +438,11 @@ int st_press_common_probe(struct iio_dev *indio_dev, pdata->odr = pdata->sensor_settings->odr.odr_avl[0].hz; /* Some devices don't support a data ready pin. */ - if (!plat_data && pdata->sensor_settings->drdy_irq.addr) - plat_data = + if (!pdata->dev->platform_data && pdata->sensor_settings->drdy_irq.addr) + pdata->dev->platform_data = (struct st_sensors_platform_data *)&default_press_pdata; - err = st_sensors_init_sensor(indio_dev, plat_data); + err = st_sensors_init_sensor(indio_dev, pdata->dev->platform_data); if (err < 0) return err; diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index acaf165260bb..dd733513152d 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -56,7 +56,7 @@ static int st_press_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, pdata); - err = st_press_common_probe(indio_dev, client->dev.platform_data); + err = st_press_common_probe(indio_dev); if (err < 0) return err; diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index f45d430ec529..98c3e8e517ae 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -33,7 +33,7 @@ static int st_press_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, pdata); - err = st_press_common_probe(indio_dev, spi->dev.platform_data); + err = st_press_common_probe(indio_dev); if (err < 0) return err; -- cgit v1.2.3-59-g8ed1b From a1dcf42927a3eebe749b14178441889ef3887ceb Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:40 +0200 Subject: iio:pressure: Changed pressure data variable name to press_data This patch fix pressure data variable name. Usually pdata name it is used for platform data. Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_buffer.c | 12 +++++----- drivers/iio/pressure/st_pressure_core.c | 40 ++++++++++++++++--------------- drivers/iio/pressure/st_pressure_i2c.c | 10 ++++---- drivers/iio/pressure/st_pressure_spi.c | 10 ++++---- 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_buffer.c b/drivers/iio/pressure/st_pressure_buffer.c index b37b1c9ac932..2ff53f222352 100644 --- a/drivers/iio/pressure/st_pressure_buffer.c +++ b/drivers/iio/pressure/st_pressure_buffer.c @@ -38,10 +38,10 @@ static int st_press_buffer_preenable(struct iio_dev *indio_dev) static int st_press_buffer_postenable(struct iio_dev *indio_dev) { int err; - struct st_sensor_data *pdata = iio_priv(indio_dev); + struct st_sensor_data *press_data = iio_priv(indio_dev); - pdata->buffer_data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (pdata->buffer_data == NULL) { + press_data->buffer_data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); + if (press_data->buffer_data == NULL) { err = -ENOMEM; goto allocate_memory_error; } @@ -53,7 +53,7 @@ static int st_press_buffer_postenable(struct iio_dev *indio_dev) return err; st_press_buffer_postenable_error: - kfree(pdata->buffer_data); + kfree(press_data->buffer_data); allocate_memory_error: return err; } @@ -61,7 +61,7 @@ allocate_memory_error: static int st_press_buffer_predisable(struct iio_dev *indio_dev) { int err; - struct st_sensor_data *pdata = iio_priv(indio_dev); + struct st_sensor_data *press_data = iio_priv(indio_dev); err = iio_triggered_buffer_predisable(indio_dev); if (err < 0) @@ -70,7 +70,7 @@ static int st_press_buffer_predisable(struct iio_dev *indio_dev) err = st_sensors_set_enable(indio_dev, false); st_press_buffer_predisable_error: - kfree(pdata->buffer_data); + kfree(press_data->buffer_data); return err; } diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index ee2ef7def097..97baf40d424b 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -333,7 +333,7 @@ static int st_press_read_raw(struct iio_dev *indio_dev, int *val2, long mask) { int err; - struct st_sensor_data *pdata = iio_priv(indio_dev); + struct st_sensor_data *press_data = iio_priv(indio_dev); switch (mask) { case IIO_CHAN_INFO_RAW: @@ -347,10 +347,10 @@ static int st_press_read_raw(struct iio_dev *indio_dev, switch (ch->type) { case IIO_PRESSURE: - *val2 = pdata->current_fullscale->gain; + *val2 = press_data->current_fullscale->gain; break; case IIO_TEMP: - *val2 = pdata->current_fullscale->gain2; + *val2 = press_data->current_fullscale->gain2; break; default: err = -EINVAL; @@ -371,7 +371,7 @@ static int st_press_read_raw(struct iio_dev *indio_dev, return IIO_VAL_FRACTIONAL; case IIO_CHAN_INFO_SAMP_FREQ: - *val = pdata->odr; + *val = press_data->odr; return IIO_VAL_INT; default: return -EINVAL; @@ -411,8 +411,8 @@ static const struct iio_trigger_ops st_press_trigger_ops = { int st_press_common_probe(struct iio_dev *indio_dev) { - struct st_sensor_data *pdata = iio_priv(indio_dev); - int irq = pdata->get_irq_data_ready(indio_dev); + struct st_sensor_data *press_data = iio_priv(indio_dev); + int irq = press_data->get_irq_data_ready(indio_dev); int err; indio_dev->modes = INDIO_DIRECT_MODE; @@ -426,23 +426,25 @@ int st_press_common_probe(struct iio_dev *indio_dev) if (err < 0) return err; - pdata->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; - pdata->multiread_bit = pdata->sensor_settings->multi_read_bit; - indio_dev->channels = pdata->sensor_settings->ch; - indio_dev->num_channels = pdata->sensor_settings->num_ch; + press_data->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; + press_data->multiread_bit = press_data->sensor_settings->multi_read_bit; + indio_dev->channels = press_data->sensor_settings->ch; + indio_dev->num_channels = press_data->sensor_settings->num_ch; - if (pdata->sensor_settings->fs.addr != 0) - pdata->current_fullscale = (struct st_sensor_fullscale_avl *) - &pdata->sensor_settings->fs.fs_avl[0]; + if (press_data->sensor_settings->fs.addr != 0) + press_data->current_fullscale = + (struct st_sensor_fullscale_avl *) + &press_data->sensor_settings->fs.fs_avl[0]; - pdata->odr = pdata->sensor_settings->odr.odr_avl[0].hz; + press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; /* Some devices don't support a data ready pin. */ - if (!pdata->dev->platform_data && pdata->sensor_settings->drdy_irq.addr) - pdata->dev->platform_data = + if (!press_data->dev->platform_data && + press_data->sensor_settings->drdy_irq.addr) + press_data->dev->platform_data = (struct st_sensors_platform_data *)&default_press_pdata; - err = st_sensors_init_sensor(indio_dev, pdata->dev->platform_data); + err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); if (err < 0) return err; @@ -478,12 +480,12 @@ EXPORT_SYMBOL(st_press_common_probe); void st_press_common_remove(struct iio_dev *indio_dev) { - struct st_sensor_data *pdata = iio_priv(indio_dev); + struct st_sensor_data *press_data = iio_priv(indio_dev); st_sensors_power_disable(indio_dev); iio_device_unregister(indio_dev); - if (pdata->get_irq_data_ready(indio_dev) > 0) + if (press_data->get_irq_data_ready(indio_dev) > 0) st_sensors_deallocate_trigger(indio_dev); st_press_deallocate_ring(indio_dev); diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index dd733513152d..8859e93e6dc6 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -43,18 +43,18 @@ static int st_press_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct iio_dev *indio_dev; - struct st_sensor_data *pdata; + struct st_sensor_data *press_data; int err; - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pdata)); + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*press_data)); if (!indio_dev) return -ENOMEM; - pdata = iio_priv(indio_dev); - pdata->dev = &client->dev; + press_data = iio_priv(indio_dev); + press_data->dev = &client->dev; st_sensors_of_i2c_probe(client, st_press_of_match); - st_sensors_i2c_configure(indio_dev, client, pdata); + st_sensors_i2c_configure(indio_dev, client, press_data); err = st_press_common_probe(indio_dev); if (err < 0) diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 98c3e8e517ae..10c96245f12a 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -21,17 +21,17 @@ static int st_press_spi_probe(struct spi_device *spi) { struct iio_dev *indio_dev; - struct st_sensor_data *pdata; + struct st_sensor_data *press_data; int err; - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*pdata)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*press_data)); if (indio_dev == NULL) return -ENOMEM; - pdata = iio_priv(indio_dev); - pdata->dev = &spi->dev; + press_data = iio_priv(indio_dev); + press_data->dev = &spi->dev; - st_sensors_spi_configure(indio_dev, spi, pdata); + st_sensors_spi_configure(indio_dev, spi, press_data); err = st_press_common_probe(indio_dev); if (err < 0) -- cgit v1.2.3-59-g8ed1b From 7be178bb48bc3ed5af2f6cfdb69074dba4bd87b9 Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Fri, 3 Oct 2014 17:35:41 +0200 Subject: iio:common: Set the device pointer into ST common sensors library Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_i2c.c | 1 - drivers/iio/accel/st_accel_spi.c | 1 - drivers/iio/common/st_sensors/st_sensors_i2c.c | 1 + drivers/iio/common/st_sensors/st_sensors_spi.c | 1 + drivers/iio/gyro/st_gyro_i2c.c | 1 - drivers/iio/gyro/st_gyro_spi.c | 1 - drivers/iio/magnetometer/st_magn_i2c.c | 1 - drivers/iio/magnetometer/st_magn_spi.c | 1 - drivers/iio/pressure/st_pressure_i2c.c | 1 - drivers/iio/pressure/st_pressure_spi.c | 1 - 10 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 40adc7e88a39..c7246bdd30b9 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -79,7 +79,6 @@ static int st_accel_i2c_probe(struct i2c_client *client, return -ENOMEM; adata = iio_priv(indio_dev); - adata->dev = &client->dev; st_sensors_of_i2c_probe(client, st_accel_of_match); st_sensors_i2c_configure(indio_dev, client, adata); diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 2090d80062d2..12ec29389e4b 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -29,7 +29,6 @@ static int st_accel_spi_probe(struct spi_device *spi) return -ENOMEM; adata = iio_priv(indio_dev); - adata->dev = &spi->dev; st_sensors_spi_configure(indio_dev, spi, adata); diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index bb6f3085f57b..98cfee296d46 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c @@ -72,6 +72,7 @@ void st_sensors_i2c_configure(struct iio_dev *indio_dev, indio_dev->dev.parent = &client->dev; indio_dev->name = client->name; + sdata->dev = &client->dev; sdata->tf = &st_sensors_tf_i2c; sdata->get_irq_data_ready = st_sensors_i2c_get_irq; } diff --git a/drivers/iio/common/st_sensors/st_sensors_spi.c b/drivers/iio/common/st_sensors/st_sensors_spi.c index 251baf6abc25..78a6a1ab3ece 100644 --- a/drivers/iio/common/st_sensors/st_sensors_spi.c +++ b/drivers/iio/common/st_sensors/st_sensors_spi.c @@ -111,6 +111,7 @@ void st_sensors_spi_configure(struct iio_dev *indio_dev, indio_dev->dev.parent = &spi->dev; indio_dev->name = spi->modalias; + sdata->dev = &spi->dev; sdata->tf = &st_sensors_tf_spi; sdata->get_irq_data_ready = st_sensors_spi_get_irq; } diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index 94d01fba4a4c..64480b16c689 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -67,7 +67,6 @@ static int st_gyro_i2c_probe(struct i2c_client *client, return -ENOMEM; gdata = iio_priv(indio_dev); - gdata->dev = &client->dev; st_sensors_of_i2c_probe(client, st_gyro_of_match); st_sensors_i2c_configure(indio_dev, client, gdata); diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index 3e7a01af9b61..e59bead6bc3c 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -29,7 +29,6 @@ static int st_gyro_spi_probe(struct spi_device *spi) return -ENOMEM; gdata = iio_priv(indio_dev); - gdata->dev = &spi->dev; st_sensors_spi_configure(indio_dev, spi, gdata); diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index f8a682374239..92e5c15452a3 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -51,7 +51,6 @@ static int st_magn_i2c_probe(struct i2c_client *client, return -ENOMEM; mdata = iio_priv(indio_dev); - mdata->dev = &client->dev; st_sensors_of_i2c_probe(client, st_magn_of_match); st_sensors_i2c_configure(indio_dev, client, mdata); diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index f64214237cf6..7adacf160146 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -29,7 +29,6 @@ static int st_magn_spi_probe(struct spi_device *spi) return -ENOMEM; mdata = iio_priv(indio_dev); - mdata->dev = &spi->dev; st_sensors_spi_configure(indio_dev, spi, mdata); diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 8859e93e6dc6..137788bba4a3 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -51,7 +51,6 @@ static int st_press_i2c_probe(struct i2c_client *client, return -ENOMEM; press_data = iio_priv(indio_dev); - press_data->dev = &client->dev; st_sensors_of_i2c_probe(client, st_press_of_match); st_sensors_i2c_configure(indio_dev, client, press_data); diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 10c96245f12a..1ffa6d4d349c 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -29,7 +29,6 @@ static int st_press_spi_probe(struct spi_device *spi) return -ENOMEM; press_data = iio_priv(indio_dev); - press_data->dev = &spi->dev; st_sensors_spi_configure(indio_dev, spi, press_data); -- cgit v1.2.3-59-g8ed1b From 2e3d6675dc2f402d8b799b773324e60af3e2a325 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 2 Oct 2014 22:25:23 -0300 Subject: iio: adc: vf610: Return the error code directly There is no need to pass the error clock code to the variable 'ret'. Just return the error directly. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/vf610_adc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 7ec21b5612ef..ebb73f5d3c3a 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -610,8 +610,7 @@ static int vf610_adc_probe(struct platform_device *pdev) 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; + return PTR_ERR(info->clk); } info->vref = devm_regulator_get(&pdev->dev, "vref"); -- cgit v1.2.3-59-g8ed1b From 9da64c25ffefa60b969c64176098ae616219f759 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 2 Oct 2014 22:25:24 -0300 Subject: iio: adc: vf610: Disable the regulator on error If clk_prepare_enable() fails we should disable the regulator that was previously enabled. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/vf610_adc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index ebb73f5d3c3a..767e9b975f00 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -704,11 +704,15 @@ static int vf610_adc_resume(struct device *dev) ret = clk_prepare_enable(info->clk); if (ret) - return ret; + goto disable_reg; vf610_adc_hw_init(info); return 0; + +disable_reg: + regulator_disable(info->vref); + return ret; } #endif -- cgit v1.2.3-59-g8ed1b From ef0d5454930aa687ac2c2337107391f1389aa0f1 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 2 Oct 2014 22:25:25 -0300 Subject: iio: adc: vf610: SIMPLE_DEV_PM_OPS can fit on a single line No need to call the SIMPLE_DEV_PM_OPS() macro in several lines. It can fit into the 80-column range. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/vf610_adc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 767e9b975f00..d47fff003b78 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -716,9 +716,7 @@ disable_reg: } #endif -static SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, - vf610_adc_suspend, - vf610_adc_resume); +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, -- cgit v1.2.3-59-g8ed1b From 064a74637ccdee608eb898ea3e3847b142b261c6 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Mon, 29 Sep 2014 13:28:55 -0500 Subject: IIO: add si7020 driver This patch adds support to the Industrial IO subsystem for the Silicon Labs Si7013/20/21 Relative Humidity and Temperature Sensors. Website: http://www.silabs.com/products/sensors/humidity-sensors/Pages/si7013-20-21.aspx These are i2c devices which measure relative humidity and temperature and all use the same protocol. The Si7013 has an additional input with programmable linearization which is not supported because that's complicated and I didn't need it. Signed-off-by: David Barksdale -- Changes since v1: * Renamed to si7020 and replaced Si701x/2x with Si7013/20/21. * Removed unneeded mutex. * Pre-computed floating-point constant expressions. * Removed address_list and I2C_CLASS_HWMON. Changes since v2: * Return correct raw sensor values. * Rename dev variable to indio_dev. * Issue a software reset command during probe. * Un-broke string literal. Changes since v3: * enum changed to #define Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/Kconfig | 10 +++ drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/si7020.c | 163 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 drivers/iio/humidity/si7020.c diff --git a/drivers/iio/humidity/Kconfig b/drivers/iio/humidity/Kconfig index e116bd8dd0e4..4813b793b9f7 100644 --- a/drivers/iio/humidity/Kconfig +++ b/drivers/iio/humidity/Kconfig @@ -22,4 +22,14 @@ config SI7005 To compile this driver as a module, choose M here: the module will be called si7005. +config SI7020 + tristate "Si7013/20/21 Relative Humidity and Temperature Sensors" + depends on I2C + help + Say yes here to build support for the Silicon Labs Si7013/20/21 + Relative Humidity and Temperature Sensors. + + To compile this driver as a module, choose M here: the module + will be called si7020. + endmenu diff --git a/drivers/iio/humidity/Makefile b/drivers/iio/humidity/Makefile index e3f3d942e646..86e2d26e9f4d 100644 --- a/drivers/iio/humidity/Makefile +++ b/drivers/iio/humidity/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DHT11) += dht11.o obj-$(CONFIG_SI7005) += si7005.o +obj-$(CONFIG_SI7020) += si7020.o diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c new file mode 100644 index 000000000000..e336af713f20 --- /dev/null +++ b/drivers/iio/humidity/si7020.c @@ -0,0 +1,163 @@ +/* + * si7020.c - Silicon Labs Si7013/20/21 Relative Humidity and Temp Sensors + * Copyright (c) 2013,2014 Uplogix, Inc. + * David Barksdale + * + * 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 that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * The Silicon Labs Si7013/20/21 Relative Humidity and Temperature Sensors + * are i2c devices which have an identical programming interface for + * measuring relative humidity and temperature. The Si7013 has an additional + * temperature input which this driver does not support. + * + * Data Sheets: + * Si7013: http://www.silabs.com/Support%20Documents/TechnicalDocs/Si7013.pdf + * Si7020: http://www.silabs.com/Support%20Documents/TechnicalDocs/Si7020.pdf + * Si7021: http://www.silabs.com/Support%20Documents/TechnicalDocs/Si7021.pdf + */ + +#include +#include +#include +#include +#include + +#include +#include + +/* Measure Relative Humidity, Hold Master Mode */ +#define SI7020CMD_RH_HOLD 0xE5 +/* Measure Temperature, Hold Master Mode */ +#define SI7020CMD_TEMP_HOLD 0xE3 +/* Software Reset */ +#define SI7020CMD_RESET 0xFE + +static int si7020_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct i2c_client **client = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = i2c_smbus_read_word_data(*client, + chan->type == IIO_TEMP ? + SI7020CMD_TEMP_HOLD : + SI7020CMD_RH_HOLD); + if (ret < 0) + return ret; + if (chan->type == IIO_TEMP) + *val = ret >> 2; + else + *val = (ret & 0x3FFF) >> 2; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + if (chan->type == IIO_TEMP) + *val = 175720; /* = 175.72 * 1000 */ + else + *val = 125 * 1000; + *val2 = 65536 >> 2; + return IIO_VAL_FRACTIONAL; + case IIO_CHAN_INFO_OFFSET: + /* + * Since iio_convert_raw_to_processed_unlocked assumes offset + * is an integer we have to round these values and lose + * accuracy. + * Relative humidity will be 0.0032959% too high and + * temperature will be 0.00277344 degrees too high. + * This is no big deal because it's within the accuracy of the + * sensor. + */ + if (chan->type == IIO_TEMP) + *val = -4368; /* = -46.85 * (65536 >> 2) / 175.72 */ + else + *val = -786; /* = -6 * (65536 >> 2) / 125 */ + return IIO_VAL_INT; + default: + break; + } + + return -EINVAL; +} + +static const struct iio_chan_spec si7020_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 si7020_info = { + .read_raw = si7020_read_raw, + .driver_module = THIS_MODULE, +}; + +static int si7020_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct i2c_client **data; + int ret; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE | + I2C_FUNC_SMBUS_READ_WORD_DATA)) + return -ENODEV; + + /* Reset device, loads default settings. */ + ret = i2c_smbus_write_byte(client, SI7020CMD_RESET); + if (ret < 0) + return ret; + /* Wait the maximum power-up time after software reset. */ + msleep(15); + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + *data = client; + i2c_set_clientdata(client, indio_dev); + + indio_dev->dev.parent = &client->dev; + indio_dev->name = dev_name(&client->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &si7020_info; + indio_dev->channels = si7020_channels; + indio_dev->num_channels = ARRAY_SIZE(si7020_channels); + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id si7020_id[] = { + { "si7020", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, si7020_id); + +static struct i2c_driver si7020_driver = { + .driver.name = "si7020", + .probe = si7020_probe, + .id_table = si7020_id, +}; + +module_i2c_driver(si7020_driver); +MODULE_DESCRIPTION("Silicon Labs Si7013/20/21 Relative Humidity and Temperature Sensors"); +MODULE_AUTHOR("David Barksdale "); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From b12206e917ac34bec41b9ff93d37d8bd53a2b3bc Mon Sep 17 00:00:00 2001 From: Søren Andersen Date: Wed, 8 Oct 2014 20:42:00 +0200 Subject: iio: adc: mcp320x. Add support for more ADCs Signed-off-by: Soeren Andersen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mcp320x.c | 222 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 187 insertions(+), 35 deletions(-) diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index 28a086e48776..efbfd12a4bfd 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -1,9 +1,30 @@ /* * Copyright (C) 2013 Oskar Andero + * Copyright (C) 2014 Rose Technology + * Allan Bendorff Jensen + * Soren Andersen + * + * Driver for following ADC chips from Microchip Technology's: + * 10 Bit converter + * MCP3001 + * MCP3002 + * MCP3004 + * MCP3008 + * ------------ + * 12 bit converter + * MCP3201 + * MCP3202 + * MCP3204 + * MCP3208 + * ------------ * - * Driver for Microchip Technology's MCP3204 and MCP3208 ADC chips. * Datasheet can be found here: - * http://ww1.microchip.com/downloads/en/devicedoc/21298c.pdf + * http://ww1.microchip.com/downloads/en/DeviceDoc/21293C.pdf mcp3001 + * http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf mcp3002 + * http://ww1.microchip.com/downloads/en/DeviceDoc/21295d.pdf mcp3004/08 + * http://ww1.microchip.com/downloads/en/DeviceDoc/21290D.pdf mcp3201 + * http://ww1.microchip.com/downloads/en/DeviceDoc/21034D.pdf mcp3202 + * http://ww1.microchip.com/downloads/en/DeviceDoc/21298c.pdf mcp3204/08 * * 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 @@ -11,19 +32,29 @@ */ #include +#include #include #include #include #include -#define MCP_SINGLE_ENDED (1 << 3) -#define MCP_START_BIT (1 << 4) - enum { + mcp3001, + mcp3002, + mcp3004, + mcp3008, + mcp3201, + mcp3202, mcp3204, mcp3208, }; +struct mcp320x_chip_info { + const struct iio_chan_spec *channels; + unsigned int num_channels; + unsigned int resolution; +}; + struct mcp320x { struct spi_device *spi; struct spi_message msg; @@ -34,19 +65,69 @@ struct mcp320x { struct regulator *reg; struct mutex lock; + const struct mcp320x_chip_info *chip_info; }; -static int mcp320x_adc_conversion(struct mcp320x *adc, u8 msg) +static int mcp320x_channel_to_tx_data(int device_index, + const unsigned int channel, bool differential) +{ + int start_bit = 1; + + switch (device_index) { + case mcp3001: + case mcp3201: + return 0; + case mcp3002: + case mcp3202: + return ((start_bit << 4) | (!differential << 3) | + (channel << 2)); + case mcp3004: + case mcp3204: + case mcp3008: + case mcp3208: + return ((start_bit << 6) | (!differential << 5) | + (channel << 2)); + default: + return -EINVAL; + } +} + +static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel, + bool differential, int device_index) { int ret; - adc->tx_buf = msg; - ret = spi_sync(adc->spi, &adc->msg); - if (ret < 0) - return ret; + adc->rx_buf[0] = 0; + adc->rx_buf[1] = 0; + adc->tx_buf = mcp320x_channel_to_tx_data(device_index, + channel, differential); + + if (device_index != mcp3001 && device_index != mcp3201) { + ret = spi_sync(adc->spi, &adc->msg); + if (ret < 0) + return ret; + } else { + ret = spi_read(adc->spi, &adc->rx_buf, sizeof(adc->rx_buf)); + if (ret < 0) + return ret; + } - return ((adc->rx_buf[0] & 0x3f) << 6) | - (adc->rx_buf[1] >> 2); + switch (device_index) { + case mcp3001: + return (adc->rx_buf[0] << 5 | adc->rx_buf[1] >> 3); + case mcp3002: + case mcp3004: + case mcp3008: + return (adc->rx_buf[0] << 2 | adc->rx_buf[1] >> 6); + case mcp3201: + return (adc->rx_buf[0] << 7 | adc->rx_buf[1] >> 1); + case mcp3202: + case mcp3204: + case mcp3208: + return (adc->rx_buf[0] << 4 | adc->rx_buf[1] >> 4); + default: + return -EINVAL; + } } static int mcp320x_read_raw(struct iio_dev *indio_dev, @@ -55,18 +136,17 @@ static int mcp320x_read_raw(struct iio_dev *indio_dev, { struct mcp320x *adc = iio_priv(indio_dev); int ret = -EINVAL; + int device_index = 0; mutex_lock(&adc->lock); + device_index = spi_get_device_id(adc->spi)->driver_data; + switch (mask) { case IIO_CHAN_INFO_RAW: - if (channel->differential) - ret = mcp320x_adc_conversion(adc, - MCP_START_BIT | channel->address); - else - ret = mcp320x_adc_conversion(adc, - MCP_START_BIT | MCP_SINGLE_ENDED | - channel->address); + ret = mcp320x_adc_conversion(adc, channel->address, + channel->differential, device_index); + if (ret < 0) goto out; @@ -75,18 +155,15 @@ static int mcp320x_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_SCALE: - /* Digital output code = (4096 * Vin) / Vref */ ret = regulator_get_voltage(adc->reg); if (ret < 0) goto out; + /* convert regulator output voltage to mV */ *val = ret / 1000; - *val2 = 12; + *val2 = adc->chip_info->resolution; ret = IIO_VAL_FRACTIONAL_LOG2; break; - - default: - break; } out: @@ -117,6 +194,16 @@ out: .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \ } +static const struct iio_chan_spec mcp3201_channels[] = { + MCP320X_VOLTAGE_CHANNEL_DIFF(0), +}; + +static const struct iio_chan_spec mcp3202_channels[] = { + MCP320X_VOLTAGE_CHANNEL(0), + MCP320X_VOLTAGE_CHANNEL(1), + MCP320X_VOLTAGE_CHANNEL_DIFF(0), +}; + static const struct iio_chan_spec mcp3204_channels[] = { MCP320X_VOLTAGE_CHANNEL(0), MCP320X_VOLTAGE_CHANNEL(1), @@ -146,19 +233,46 @@ static const struct iio_info mcp320x_info = { .driver_module = THIS_MODULE, }; -struct mcp3208_chip_info { - const struct iio_chan_spec *channels; - unsigned int num_channels; -}; - -static const struct mcp3208_chip_info mcp3208_chip_infos[] = { +static const struct mcp320x_chip_info mcp320x_chip_infos[] = { + [mcp3001] = { + .channels = mcp3201_channels, + .num_channels = ARRAY_SIZE(mcp3201_channels), + .resolution = 10 + }, + [mcp3002] = { + .channels = mcp3202_channels, + .num_channels = ARRAY_SIZE(mcp3202_channels), + .resolution = 10 + }, + [mcp3004] = { + .channels = mcp3204_channels, + .num_channels = ARRAY_SIZE(mcp3204_channels), + .resolution = 10 + }, + [mcp3008] = { + .channels = mcp3208_channels, + .num_channels = ARRAY_SIZE(mcp3208_channels), + .resolution = 10 + }, + [mcp3201] = { + .channels = mcp3201_channels, + .num_channels = ARRAY_SIZE(mcp3201_channels), + .resolution = 12 + }, + [mcp3202] = { + .channels = mcp3202_channels, + .num_channels = ARRAY_SIZE(mcp3202_channels), + .resolution = 12 + }, [mcp3204] = { .channels = mcp3204_channels, - .num_channels = ARRAY_SIZE(mcp3204_channels) + .num_channels = ARRAY_SIZE(mcp3204_channels), + .resolution = 12 }, [mcp3208] = { .channels = mcp3208_channels, - .num_channels = ARRAY_SIZE(mcp3208_channels) + .num_channels = ARRAY_SIZE(mcp3208_channels), + .resolution = 12 }, }; @@ -166,7 +280,7 @@ static int mcp320x_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct mcp320x *adc; - const struct mcp3208_chip_info *chip_info; + const struct mcp320x_chip_info *chip_info; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); @@ -181,7 +295,7 @@ static int mcp320x_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mcp320x_info; - chip_info = &mcp3208_chip_infos[spi_get_device_id(spi)->driver_data]; + chip_info = &mcp320x_chip_infos[spi_get_device_id(spi)->driver_data]; indio_dev->channels = chip_info->channels; indio_dev->num_channels = chip_info->num_channels; @@ -226,7 +340,45 @@ static int mcp320x_remove(struct spi_device *spi) return 0; } +#if defined(CONFIG_OF) +static const struct of_device_id mcp320x_dt_ids[] = { + { + .compatible = "mcp3001", + .data = &mcp320x_chip_infos[mcp3001], + }, { + .compatible = "mcp3002", + .data = &mcp320x_chip_infos[mcp3002], + }, { + .compatible = "mcp3004", + .data = &mcp320x_chip_infos[mcp3004], + }, { + .compatible = "mcp3008", + .data = &mcp320x_chip_infos[mcp3008], + }, { + .compatible = "mcp3201", + .data = &mcp320x_chip_infos[mcp3201], + }, { + .compatible = "mcp3202", + .data = &mcp320x_chip_infos[mcp3202], + }, { + .compatible = "mcp3204", + .data = &mcp320x_chip_infos[mcp3204], + }, { + .compatible = "mcp3208", + .data = &mcp320x_chip_infos[mcp3208], + }, { + } +}; +MODULE_DEVICE_TABLE(of, mcp320x_dt_ids); +#endif + static const struct spi_device_id mcp320x_id[] = { + { "mcp3001", mcp3001 }, + { "mcp3002", mcp3002 }, + { "mcp3004", mcp3004 }, + { "mcp3008", mcp3008 }, + { "mcp3201", mcp3201 }, + { "mcp3202", mcp3202 }, { "mcp3204", mcp3204 }, { "mcp3208", mcp3208 }, { } @@ -245,5 +397,5 @@ static struct spi_driver mcp320x_driver = { module_spi_driver(mcp320x_driver); MODULE_AUTHOR("Oskar Andero "); -MODULE_DESCRIPTION("Microchip Technology MCP3204/08"); +MODULE_DESCRIPTION("Microchip Technology MCP3x01/02/04/08"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3-59-g8ed1b From 0f431ff7a38e8235b6c5c30e7aea84a426109f4f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:43 -0400 Subject: staging: unisys: clean up enums in uisqueue.h Get rid of typedefs in enums SWITCH_TYPE and IOPART_MSG_TYPE, and use the enum names directly instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 5178270b98d1..534c7d85a92c 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -34,7 +34,6 @@ #include "controlvmcompletionstatus.h" struct uisqueue_info { - CHANNEL_HEADER __iomem *chan; /* channel containing queues in which scsi commands & * responses are queued @@ -149,10 +148,10 @@ struct device_info { unsigned long long last_on_list_cnt; }; -typedef enum { +enum switch_type { RECOVERY_LAN = 1, IB_LAN = 2 -} SWITCH_TYPE; +}; struct bus_info { u32 busNo, deviceCount; @@ -199,7 +198,7 @@ struct network_policy { */ -typedef enum { +enum iopart_msg_type { IOPART_ADD_VNIC, IOPART_DEL_VNIC, IOPART_DEL_ALL_VNICS, @@ -219,7 +218,7 @@ typedef enum { IOPART_RESUME_VDISK, IOPART_ADD_DEVICE, /* add generic device */ IOPART_DEL_DEVICE, /* del generic device */ -} IOPART_MSG_TYPE; +}; struct add_virt_iopart { void *chanptr; /* pointer to data channel */ @@ -297,8 +296,7 @@ struct del_switch_iopart { /* destroy switch */ }; struct io_msgs { - - IOPART_MSG_TYPE msgtype; + enum iopart_msg_type msgtype; /* additional params needed by some messages */ union { @@ -394,7 +392,6 @@ struct init_chipset_guestpart { }; struct guest_msgs { - GUESTPART_MSG_TYPE msgtype; /* additional params needed by messages */ -- cgit v1.2.3-59-g8ed1b From bae4e2ad834db505d39b2d332e9a3593e1419591 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:44 -0400 Subject: staging: unisys: clean up GUESTPART_MSG_TYPE typedef Switch GUESTPART_MSG_TYPE over to enum guestpart_msg_type. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 534c7d85a92c..8a84c2474fc5 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -197,7 +197,6 @@ struct network_policy { * code that processes the ControlVm channel messages. */ - enum iopart_msg_type { IOPART_ADD_VNIC, IOPART_DEL_VNIC, @@ -327,7 +326,7 @@ struct io_msgs { * the ControlVm channel messages. */ -typedef enum { +enum guestpart_msg_type { GUEST_ADD_VBUS, GUEST_ADD_VHBA, GUEST_ADD_VNIC, @@ -342,7 +341,7 @@ typedef enum { GUEST_PAUSE_VNIC, GUEST_RESUME_VHBA, GUEST_RESUME_VNIC -} GUESTPART_MSG_TYPE; +}; struct add_vbus_guestpart { void __iomem *chanptr; /* pointer to data channel for bus - @@ -392,7 +391,7 @@ struct init_chipset_guestpart { }; struct guest_msgs { - GUESTPART_MSG_TYPE msgtype; + enum guestpart_msg_type msgtype; /* additional params needed by messages */ union { -- cgit v1.2.3-59-g8ed1b From 43ecb9fe08ee6adaf67710519099711fa1e6c2db Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:45 -0400 Subject: staging: unisys: Clean up CamelCase in struct bus_info Clean up CamelCase names: busNo => bus_no deviceCount => device_count guestHandle => guest_handle recvBusInterruptHandle => recv_bus_irq_handle busInstGuid => inst_uuid pBusChannel => bus_channel busChannelBytes => bus_channel_bytes partitionName => partition_name localVnic => local_vnic Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 14 +++--- drivers/staging/unisys/uislib/uislib.c | 80 +++++++++++++++---------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 8a84c2474fc5..60961f25346b 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -154,18 +154,18 @@ enum switch_type { }; struct bus_info { - u32 busNo, deviceCount; + u32 bus_no, device_count; struct device_info **device; - u64 guestHandle, recvBusInterruptHandle; - uuid_le busInstGuid; - ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *pBusChannel; - int busChannelBytes; + u64 guest_handle, recv_bus_irq_handle; + uuid_le bus_inst_uuid; + ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *bus_channel; + int bus_channel_bytes; struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/ */ struct proc_dir_entry *proc_info; /* proc/uislib/vbus//info */ char name[25]; - char partitionName[99]; + char partition_name[99]; struct bus_info *next; - u8 localVnic; /* 1 if local vnic created internally + u8 local_vnic; /* 1 if local vnic created internally * by IOVM; 0 otherwise... */ }; diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 706f1c0c2c6e..d31da1ca70d9 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -190,23 +190,23 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) */ if (msg->hdr.Flags.testMessage) { /* This implies we're the IOVM so set guest handle to 0... */ - bus->guestHandle = 0; - bus->busNo = busNo; - bus->localVnic = 1; + bus->guest_handle = 0; + bus->bus_no = busNo; + bus->local_vnic = 1; } else - bus->busNo = bus->guestHandle = busNo; - sprintf(bus->name, "%d", (int) bus->busNo); - bus->deviceCount = deviceCount; + bus->bus_no = bus->guest_handle = busNo; + sprintf(bus->name, "%d", (int) bus->bus_no); + bus->device_count = deviceCount; bus->device = (struct device_info **) ((char *) bus + sizeof(struct bus_info)); - bus->busInstGuid = msg->cmd.createBus.busInstGuid; - bus->busChannelBytes = 0; - bus->pBusChannel = NULL; + bus->bus_inst_uuid = msg->cmd.createBus.busInstGuid; + bus->bus_channel_bytes = 0; + bus->bus_channel = NULL; /* add bus to our bus list - but check for duplicates first */ read_lock(&BusListLock); for (tmp = BusListHead; tmp; tmp = tmp->next) { - if (tmp->busNo == bus->busNo) + if (tmp->bus_no == bus->bus_no) break; } read_unlock(&BusListLock); @@ -215,16 +215,16 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) * reject add */ LOGERR("CONTROLVM_BUS_CREATE Failed: bus %d already exists.\n", - bus->busNo); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo, + bus->bus_no); + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, POSTCODE_SEVERITY_ERR); kfree(bus); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } if ((msg->cmd.createBus.channelAddr != 0) && (msg->cmd.createBus.channelBytes != 0)) { - bus->busChannelBytes = msg->cmd.createBus.channelBytes; - bus->pBusChannel = + bus->bus_channel_bytes = msg->cmd.createBus.channelBytes; + bus->bus_channel = init_vbus_channel(msg->cmd.createBus.channelAddr, msg->cmd.createBus.channelBytes); } @@ -234,20 +234,20 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) cmd.msgtype = GUEST_ADD_VBUS; cmd.add_vbus.busNo = busNo; - cmd.add_vbus.chanptr = bus->pBusChannel; + cmd.add_vbus.chanptr = bus->bus_channel; cmd.add_vbus.deviceCount = deviceCount; cmd.add_vbus.busTypeGuid = msg->cmd.createBus.busDataTypeGuid; cmd.add_vbus.busInstGuid = msg->cmd.createBus.busInstGuid; if (!VirtControlChanFunc) { LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered."); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo, + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, POSTCODE_SEVERITY_ERR); kfree(bus); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } if (!VirtControlChanFunc(&cmd)) { LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci GUEST_ADD_VBUS returned error."); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo, + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, POSTCODE_SEVERITY_ERR); kfree(bus); return @@ -266,7 +266,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) BusListCount++; write_unlock(&BusListLock); - POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->busNo, + POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->bus_no, POSTCODE_SEVERITY_INFO); return CONTROLVM_RESP_SUCCESS; } @@ -285,7 +285,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) bus = BusListHead; while (bus) { - if (bus->busNo == busNo) + if (bus->bus_no == busNo) break; prev = bus; bus = bus->next; @@ -299,7 +299,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) } /* verify that this bus has no devices. */ - for (i = 0; i < bus->deviceCount; i++) { + for (i = 0; i < bus->device_count; i++) { if (bus->device[i] != NULL) { LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.", i, busNo); @@ -335,9 +335,9 @@ remove: BusListCount--; write_unlock(&BusListLock); - if (bus->pBusChannel) { - uislib_iounmap(bus->pBusChannel); - bus->pBusChannel = NULL; + if (bus->bus_channel) { + uislib_iounmap(bus->bus_channel); + bus->bus_channel = NULL; } kfree(bus); @@ -412,11 +412,11 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { - if (bus->busNo == busNo) { + if (bus->bus_no == busNo) { /* make sure the device number is valid */ - if (devNo >= bus->deviceCount) { + if (devNo >= bus->device_count) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: device (%d) >= deviceCount (%d).", - devNo, bus->deviceCount); + devNo, bus->device_count); result = CONTROLVM_RESP_ERROR_MAX_DEVICES; POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, @@ -555,11 +555,11 @@ pause_device(CONTROLVM_MESSAGE *msg) read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { - if (bus->busNo == busNo) { + if (bus->bus_no == busNo) { /* make sure the device number is valid */ - if (devNo >= bus->deviceCount) { + if (devNo >= bus->device_count) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device(%d) >= deviceCount(%d).", - devNo, bus->deviceCount); + devNo, bus->device_count); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { /* make sure this device exists */ @@ -623,11 +623,11 @@ resume_device(CONTROLVM_MESSAGE *msg) read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { - if (bus->busNo == busNo) { + if (bus->bus_no == busNo) { /* make sure the device number is valid */ - if (devNo >= bus->deviceCount) { + if (devNo >= bus->device_count) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device(%d) >= deviceCount(%d).", - devNo, bus->deviceCount); + devNo, bus->device_count); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { /* make sure this device exists */ @@ -693,11 +693,11 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) read_lock(&BusListLock); LOGINF("destroy_device called for busNo=%u, devNo=%u", busNo, devNo); for (bus = BusListHead; bus; bus = bus->next) { - if (bus->busNo == busNo) { + if (bus->bus_no == busNo) { /* make sure the device number is valid */ - if (devNo >= bus->deviceCount) { + if (devNo >= bus->device_count) { LOGERR("CONTROLVM_DEVICE_DESTORY Failed: device(%d) >= deviceCount(%d).", - devNo, bus->deviceCount); + devNo, bus->device_count); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID; } else { /* make sure this device exists */ @@ -1206,17 +1206,17 @@ info_debugfs_read_helper(char **buff, int *buff_len) for (bus = BusListHead; bus; bus = bus->next) { if (PLINE(" bus=0x%p, busNo=%d, deviceCount=%d\n", - bus, bus->busNo, bus->deviceCount) < 0) + bus, bus->bus_no, bus->device_count) < 0) goto err_done_unlock; if (PLINE(" Devices:\n") < 0) goto err_done_unlock; - for (i = 0; i < bus->deviceCount; i++) { + for (i = 0; i < bus->device_count; i++) { if (bus->device[i]) { if (PLINE(" busNo %d, device[%i]: 0x%p, chanptr=0x%p, swtch=0x%p\n", - bus->busNo, i, bus->device[i], + bus->bus_no, i, bus->device[i], bus->device[i]->chanptr, bus->device[i]->swtch) < 0) goto err_done_unlock; @@ -1294,9 +1294,9 @@ find_dev(u32 busNo, u32 devNo) read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { - if (bus->busNo == busNo) { + if (bus->bus_no == busNo) { /* make sure the device number is valid */ - if (devNo >= bus->deviceCount) { + if (devNo >= bus->device_count) { LOGERR("%s bad busNo, devNo=%d,%d", __func__, (int) (busNo), (int) (devNo)); -- cgit v1.2.3-59-g8ed1b From 34e6230b21dc397592c41ca9164a06adad0c86e6 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:46 -0400 Subject: staging: unisys: fix CamelCase in struct add_vbus_guestpart Clean up CamelCase names: busNo => bus_no deviceCount => dev_count busTypeGuid => bus_uuid busInstGuid => instance_guid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 8 ++++---- drivers/staging/unisys/uislib/uislib.c | 8 ++++---- drivers/staging/unisys/virtpci/virtpci.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 60961f25346b..04f51e66ebf0 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -346,10 +346,10 @@ enum guestpart_msg_type { struct add_vbus_guestpart { void __iomem *chanptr; /* pointer to data channel for bus - * NOT YET USED */ - u32 busNo; /* bus number to be created/deleted */ - u32 deviceCount; /* max num of devices on bus */ - uuid_le busTypeGuid; /* indicates type of bus */ - uuid_le busInstGuid; /* instance guid for device */ + u32 bus_no; /* bus number to be created/deleted */ + u32 dev_count; /* max num of devices on bus */ + uuid_le bus_uuid; /* indicates type of bus */ + uuid_le instance_uuid; /* instance guid for device */ }; struct del_vbus_guestpart { diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index d31da1ca70d9..f7f855538d80 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -233,11 +233,11 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) struct guest_msgs cmd; cmd.msgtype = GUEST_ADD_VBUS; - cmd.add_vbus.busNo = busNo; + cmd.add_vbus.bus_no = busNo; cmd.add_vbus.chanptr = bus->bus_channel; - cmd.add_vbus.deviceCount = deviceCount; - cmd.add_vbus.busTypeGuid = msg->cmd.createBus.busDataTypeGuid; - cmd.add_vbus.busInstGuid = msg->cmd.createBus.busInstGuid; + cmd.add_vbus.dev_count = deviceCount; + cmd.add_vbus.bus_uuid = msg->cmd.createBus.busDataTypeGuid; + cmd.add_vbus.instance_uuid = msg->cmd.createBus.busInstGuid; if (!VirtControlChanFunc) { LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered."); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index ee9f8260cd15..91f939570b38 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -262,7 +262,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams) if (!vbus) return 0; - dev_set_name(vbus, "vbus%d", addparams->busNo); + dev_set_name(vbus, "vbus%d", addparams->bus_no); vbus->release = virtpci_bus_release; vbus->parent = &virtpci_rootbus_device; /* root bus is parent */ vbus->bus = &virtpci_bus_type; /* bus type */ @@ -283,7 +283,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams) &Chipset_DriverInfo); write_vbus_busInfo(vbus->platform_data /* chanptr */ , &Bus_DriverInfo); LOGINF("Added vbus %d; device %s created successfully\n", - addparams->busNo, BUS_ID(vbus)); + addparams->bus_no, BUS_ID(vbus)); POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); return 1; } -- cgit v1.2.3-59-g8ed1b From 2df7cc6267035c2da2f5e92fe632356178735825 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:47 -0400 Subject: staging: unisys: Fix CamelCase function pointers in uisutils Fix CamelCase names: UisnicControlChanFunc => uisnic_control_chan_func UissdControlChanFunc => uissd_control_chan_func VirtControlChanFunc => virt_control_chan_func Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 6 +++--- drivers/staging/unisys/uislib/uislib.c | 30 +++++++++++++++--------------- drivers/staging/unisys/uislib/uisutils.c | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 74e7cf65502c..85d49e4860a6 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -43,9 +43,9 @@ /* global function pointers that act as callback functions into * uisnicmod, uissdmod, and virtpcimod */ -extern int (*UisnicControlChanFunc)(struct io_msgs *); -extern int (*UissdControlChanFunc)(struct io_msgs *); -extern int (*VirtControlChanFunc)(struct guest_msgs *); +extern int (*uisnic_control_chan_func)(struct io_msgs *); +extern int (*uissd_control_chan_func)(struct io_msgs *); +extern int (*virt_control_chan_func)(struct guest_msgs *); /* Return values of above callback functions: */ #define CCF_ERROR 0 /* completed and failed */ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index f7f855538d80..b48b962165ff 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -57,7 +57,7 @@ #define __MYFILE__ "uislib.c" /* global function pointers that act as callback functions into virtpcimod */ -int (*VirtControlChanFunc)(struct guest_msgs *); +int (*virt_control_chan_func)(struct guest_msgs *); static int ProcReadBufferValid; static char *ProcReadBuffer; /* Note this MUST be global, @@ -238,14 +238,14 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) cmd.add_vbus.dev_count = deviceCount; cmd.add_vbus.bus_uuid = msg->cmd.createBus.busDataTypeGuid; cmd.add_vbus.instance_uuid = msg->cmd.createBus.busInstGuid; - if (!VirtControlChanFunc) { + if (!virt_control_chan_func) { LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered."); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, POSTCODE_SEVERITY_ERR); kfree(bus); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } - if (!VirtControlChanFunc(&cmd)) { + if (!virt_control_chan_func(&cmd)) { LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci GUEST_ADD_VBUS returned error."); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, POSTCODE_SEVERITY_ERR); @@ -316,11 +316,11 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) with this bus. */ cmd.msgtype = GUEST_DEL_VBUS; cmd.del_vbus.bus_no = busNo; - if (!VirtControlChanFunc) { + if (!virt_control_chan_func) { LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci callback not registered."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } - if (!VirtControlChanFunc(&cmd)) { + if (!virt_control_chan_func(&cmd)) { LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci GUEST_DEL_VBUS returned error."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; } @@ -500,7 +500,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) goto Away; } - if (!VirtControlChanFunc) { + if (!virt_control_chan_func) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci callback not registered."); POSTCODE_LINUX_4 (DEVICE_CREATE_FAILURE_PC, devNo, @@ -509,7 +509,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) goto Away; } - if (!VirtControlChanFunc(&cmd)) { + if (!virt_control_chan_func(&cmd)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci GUEST_ADD_[VHBA||VNIC] returned error."); POSTCODE_LINUX_4 (DEVICE_CREATE_FAILURE_PC, devNo, @@ -596,11 +596,11 @@ pause_device(CONTROLVM_MESSAGE *msg) LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n"); return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; } - if (!VirtControlChanFunc) { + if (!virt_control_chan_func) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } - if (!VirtControlChanFunc(&cmd)) { + if (!virt_control_chan_func(&cmd)) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; @@ -665,11 +665,11 @@ resume_device(CONTROLVM_MESSAGE *msg) LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n"); return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; } - if (!VirtControlChanFunc) { + if (!virt_control_chan_func) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } - if (!VirtControlChanFunc(&cmd)) { + if (!virt_control_chan_func(&cmd)) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; @@ -736,12 +736,12 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; } - if (!VirtControlChanFunc) { + if (!virt_control_chan_func) { LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; } - if (!VirtControlChanFunc(&cmd)) { + if (!virt_control_chan_func(&cmd)) { LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error."); return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; @@ -783,7 +783,7 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf) * functions. */ if (!msg->hdr.Flags.testMessage) - WAIT_ON_CALLBACK(VirtControlChanFunc); + WAIT_ON_CALLBACK(virt_control_chan_func); chipset_inited = 1; POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -1574,7 +1574,7 @@ uislib_mod_init(void) BusListHead = NULL; BusListCount = MaxBusCount = 0; rwlock_init(&BusListLock); - VirtControlChanFunc = NULL; + virt_control_chan_func = NULL; /* Issue VMCALL_GET_CONTROLVM_ADDR to get CtrlChanPhysAddr and * then map this physical address to a virtual address. */ diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 8ff6d26ff00b..3001819aba96 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -82,13 +82,13 @@ uisctrl_register_req_handler(int type, void *fptr, switch (type) { case 2: if (fptr) { - if (!VirtControlChanFunc) + if (!virt_control_chan_func) atomic_inc(&UisUtils_Registered_Services); - VirtControlChanFunc = fptr; + virt_control_chan_func = fptr; } else { - if (VirtControlChanFunc) + if (virt_control_chan_func) atomic_dec(&UisUtils_Registered_Services); - VirtControlChanFunc = NULL; + virt_control_chan_func = NULL; } break; -- cgit v1.2.3-59-g8ed1b From e9b9262a24bd5fa2c7de074a4fcd95eb6c6928d7 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:48 -0400 Subject: staging: unisys: fix CamelCase name for registered services variable Fix CamelCase names: UisUtils_Registered_Services => uisutils_registered_services Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 2 +- drivers/staging/unisys/uislib/uisutils.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 85d49e4860a6..3c9aadb657d2 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -51,7 +51,7 @@ extern int (*virt_control_chan_func)(struct guest_msgs *); #define CCF_ERROR 0 /* completed and failed */ #define CCF_OK 1 /* completed successfully */ #define CCF_PENDING 2 /* operation still pending */ -extern atomic_t UisUtils_Registered_Services; +extern atomic_t uisutils_registered_services; typedef unsigned int MACARRAY[MAX_MACADDR_LEN]; typedef struct ReqHandlerInfo_struct { diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index b48b962165ff..b1c9d4942cd6 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1232,7 +1232,7 @@ info_debugfs_read_helper(char **buff, int *buff_len) read_unlock(&BusListLock); if (PLINE("UisUtils_Registered_Services: %d\n", - atomic_read(&UisUtils_Registered_Services)) < 0) + atomic_read(&uisutils_registered_services)) < 0) goto err_done; if (PLINE("cycles_before_wait %llu wait_cycles:%llu\n", cycles_before_wait, wait_cycles) < 0) diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 3001819aba96..82230f2c61ae 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -39,7 +39,7 @@ #define __MYFILE__ "uisutils.c" /* exports */ -atomic_t UisUtils_Registered_Services = ATOMIC_INIT(0); +atomic_t uisutils_registered_services = ATOMIC_INIT(0); /* num registrations via * uisctrl_register_req_handler() or * uisctrl_register_req_handler_ex() */ @@ -83,11 +83,11 @@ uisctrl_register_req_handler(int type, void *fptr, case 2: if (fptr) { if (!virt_control_chan_func) - atomic_inc(&UisUtils_Registered_Services); + atomic_inc(&uisutils_registered_services); virt_control_chan_func = fptr; } else { if (virt_control_chan_func) - atomic_dec(&UisUtils_Registered_Services); + atomic_dec(&uisutils_registered_services); virt_control_chan_func = NULL; } break; @@ -145,7 +145,7 @@ uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, goto Away; } - atomic_inc(&UisUtils_Registered_Services); + atomic_inc(&uisutils_registered_services); rc = 1; /* success */ Away: if (rc) { @@ -170,7 +170,7 @@ uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid) &switchTypeGuid); goto Away; } - atomic_dec(&UisUtils_Registered_Services); + atomic_dec(&uisutils_registered_services); rc = 1; /* success */ Away: if (!rc) -- cgit v1.2.3-59-g8ed1b From 9aee8f970dd9a82e468f625eee56f71bfaa7dd52 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:49 -0400 Subject: staging: unisys: get rid of MACARRAY typedef Remove the MACARRAY typedef entirely and switch over to u8*[ETH_ALEN], like everybody else seems to use. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 3c9aadb657d2..0dee798ad4e0 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "vmcallinterface.h" #include "channel.h" @@ -53,7 +54,6 @@ extern int (*virt_control_chan_func)(struct guest_msgs *); #define CCF_PENDING 2 /* operation still pending */ extern atomic_t uisutils_registered_services; -typedef unsigned int MACARRAY[MAX_MACADDR_LEN]; typedef struct ReqHandlerInfo_struct { uuid_le switchTypeGuid; int (*controlfunc)(struct io_msgs *); @@ -132,7 +132,7 @@ void util_unmap_virt(struct phys_info *sg); unsigned char *util_map_virt_atomic(struct phys_info *sg); void util_unmap_virt_atomic(void *buf); int uislib_server_inject_add_vnic(u32 switchNo, u32 BusNo, u32 numIntPorts, - u32 numExtPorts, MACARRAY pmac[], + u32 numExtPorts, u8 *pmac[ETH_ALEN], pCHANNEL_HEADER **chan); void uislib_server_inject_del_vnic(u32 switchNo, u32 busNo, u32 numIntPorts, u32 numExtPorts); -- cgit v1.2.3-59-g8ed1b From 38ab19b63373ef301a0ecee4800cb7cd938c3814 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:50 -0400 Subject: staging: unisys: remove typedef ReqHandlerInfo_t Convert all references to the typedef to struct req_handler_info. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 14 +++++++------- drivers/staging/unisys/uislib/uislib.c | 2 +- drivers/staging/unisys/uislib/uisutils.c | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 0dee798ad4e0..9bb95d597d5c 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -54,7 +54,7 @@ extern int (*virt_control_chan_func)(struct guest_msgs *); #define CCF_PENDING 2 /* operation still pending */ extern atomic_t uisutils_registered_services; -typedef struct ReqHandlerInfo_struct { +struct req_handler_info { uuid_le switchTypeGuid; int (*controlfunc)(struct io_msgs *); unsigned long min_channel_bytes; @@ -63,18 +63,18 @@ typedef struct ReqHandlerInfo_struct { (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes); char switch_type_name[99]; struct list_head list_link; /* links into ReqHandlerInfo_list */ -} ReqHandlerInfo_t; +}; -ReqHandlerInfo_t *ReqHandlerAdd(uuid_le switchTypeGuid, +struct req_handler_info *ReqHandlerAdd(uuid_le switchTypeGuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, int (*Server_Channel_Ok)(unsigned long channelBytes), - int (*Server_Channel_Init) - (void *x, unsigned char *clientStr, - u32 clientStrLen, u64 bytes)); -ReqHandlerInfo_t *ReqHandlerFind(uuid_le switchTypeGuid); + int (*Server_Channel_Init)(void *x, + unsigned char *clientStr, + u32 clientStrLen, u64 bytes)); +struct req_handler_info *ReqHandlerFind(uuid_le switchTypeGuid); int ReqHandlerDel(uuid_le switchTypeGuid); #define uislib_ioremap_cache(addr, size) \ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index b1c9d4942cd6..c438d8334e23 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -352,7 +352,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) u32 busNo, devNo; int result = CONTROLVM_RESP_SUCCESS; u64 minSize = MIN_IO_CHANNEL_SIZE; - ReqHandlerInfo_t *pReqHandler; + struct req_handler_info *pReqHandler; busNo = msg->cmd.createDevice.busNo; devNo = msg->cmd.createDevice.devNo; diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 82230f2c61ae..f3a23a62d6fe 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -116,7 +116,7 @@ uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, u32 clientStrLen, u64 bytes), ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo) { - ReqHandlerInfo_t *pReqHandlerInfo; + struct req_handler_info *pReqHandlerInfo; int rc = 0; /* assume failure */ LOGINF("type=%pUL, controlfunc=0x%p.\n", @@ -275,10 +275,10 @@ dolist: if (skb_shinfo(skb)->frag_list) { } EXPORT_SYMBOL_GPL(uisutil_copy_fragsinfo_from_skb); -static LIST_HEAD(ReqHandlerInfo_list); /* list of ReqHandlerInfo_t */ +static LIST_HEAD(ReqHandlerInfo_list); /* list of struct req_handler_info */ static DEFINE_SPINLOCK(ReqHandlerInfo_list_lock); -ReqHandlerInfo_t * +struct req_handler_info * ReqHandlerAdd(uuid_le switchTypeGuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), @@ -287,7 +287,7 @@ ReqHandlerAdd(uuid_le switchTypeGuid, int (*Server_Channel_Init) (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes)) { - ReqHandlerInfo_t *rc = NULL; + struct req_handler_info *rc = NULL; rc = kzalloc(sizeof(*rc), GFP_ATOMIC); if (!rc) @@ -307,15 +307,15 @@ ReqHandlerAdd(uuid_le switchTypeGuid, return rc; } -ReqHandlerInfo_t * +struct req_handler_info * ReqHandlerFind(uuid_le switchTypeGuid) { struct list_head *lelt, *tmp; - ReqHandlerInfo_t *entry = NULL; + struct req_handler_info *entry = NULL; spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { - entry = list_entry(lelt, ReqHandlerInfo_t, list_link); + entry = list_entry(lelt, struct req_handler_info, list_link); if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) { spin_unlock(&ReqHandlerInfo_list_lock); return entry; @@ -329,12 +329,12 @@ int ReqHandlerDel(uuid_le switchTypeGuid) { struct list_head *lelt, *tmp; - ReqHandlerInfo_t *entry = NULL; + struct req_handler_info *entry = NULL; int rc = -1; spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { - entry = list_entry(lelt, ReqHandlerInfo_t, list_link); + entry = list_entry(lelt, struct req_handler_info, list_link); if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) { list_del(lelt); kfree(entry); -- cgit v1.2.3-59-g8ed1b From 157764e776139ce7996190a3ef44e3b0ee582d82 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:51 -0400 Subject: staging: unisys: fix CamelCase in struct req_handler_info Fix CamelCase names: switchTypeGuid => switch_uuid Server_Channel_Ok => server_channel_ok channelBytes => channel_bytes Server_Channel_Init => server_channel_init clientStr => client_str clientStrLen => client_str_len Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 8 ++++---- drivers/staging/unisys/uislib/uisutils.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 9bb95d597d5c..992c8cdfb725 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -55,12 +55,12 @@ extern int (*virt_control_chan_func)(struct guest_msgs *); extern atomic_t uisutils_registered_services; struct req_handler_info { - uuid_le switchTypeGuid; + uuid_le switch_uuid; int (*controlfunc)(struct io_msgs *); unsigned long min_channel_bytes; - int (*Server_Channel_Ok)(unsigned long channelBytes); - int (*Server_Channel_Init) - (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes); + int (*server_channel_ok)(unsigned long channel_bytes); + int (*server_channel_init) + (void *x, unsigned char *client_str, u32 client_str_len, u64 bytes); char switch_type_name[99]; struct list_head list_link; /* links into ReqHandlerInfo_list */ }; diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index f3a23a62d6fe..7006c470d6ac 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -292,11 +292,11 @@ ReqHandlerAdd(uuid_le switchTypeGuid, rc = kzalloc(sizeof(*rc), GFP_ATOMIC); if (!rc) return NULL; - rc->switchTypeGuid = switchTypeGuid; + rc->switch_uuid = switchTypeGuid; rc->controlfunc = controlfunc; rc->min_channel_bytes = min_channel_bytes; - rc->Server_Channel_Ok = Server_Channel_Ok; - rc->Server_Channel_Init = Server_Channel_Init; + rc->server_channel_ok = Server_Channel_Ok; + rc->server_channel_init = Server_Channel_Init; if (switch_type_name) strncpy(rc->switch_type_name, switch_type_name, sizeof(rc->switch_type_name) - 1); @@ -316,7 +316,7 @@ ReqHandlerFind(uuid_le switchTypeGuid) spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, struct req_handler_info, list_link); - if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) { + if (uuid_le_cmp(entry->switch_uuid, switchTypeGuid) == 0) { spin_unlock(&ReqHandlerInfo_list_lock); return entry; } @@ -335,7 +335,7 @@ ReqHandlerDel(uuid_le switchTypeGuid) spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, struct req_handler_info, list_link); - if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) { + if (uuid_le_cmp(entry->switch_uuid, switchTypeGuid) == 0) { list_del(lelt); kfree(entry); rc++; -- cgit v1.2.3-59-g8ed1b From 3636c0da3d048a058c01e5be71cd601fbdbb1c7e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:52 -0400 Subject: staging: unisys: fix CamelCase names in ReqHandlerAdd() Fix CamelCase names: ReqHandlerAdd => req_handler_add Server_Channel_Ok => svr_channel_ok channelBytes => channel_bytes Server_Channel_Init => svr_channel_init clientStr => client_str ClientStrLen => client_str_len Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 16 ++++++++-------- drivers/staging/unisys/uislib/uisutils.c | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 992c8cdfb725..1455c73a5479 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -65,15 +65,15 @@ struct req_handler_info { struct list_head list_link; /* links into ReqHandlerInfo_list */ }; -struct req_handler_info *ReqHandlerAdd(uuid_le switchTypeGuid, +struct req_handler_info *req_handler_add(uuid_le switch_uuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, - int (*Server_Channel_Ok)(unsigned long - channelBytes), - int (*Server_Channel_Init)(void *x, - unsigned char *clientStr, - u32 clientStrLen, u64 bytes)); + int (*svr_channel_ok)(unsigned long + channel_bytes), + int (*svr_channel_init)(void *x, + unsigned char *client_str, + u32 client_str_len, u64 bytes)); struct req_handler_info *ReqHandlerFind(uuid_le switchTypeGuid); int ReqHandlerDel(uuid_le switchTypeGuid); @@ -119,9 +119,9 @@ int uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, const char *switch_type_name, int (*fptr)(struct io_msgs *), unsigned long min_channel_bytes, - int (*Server_Channel_Ok)(unsigned long + int (*svr_channel_ok)(unsigned long channelBytes), - int (*Server_Channel_Init) + int (*svr_channel_init) (void *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes), ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo); diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 7006c470d6ac..b336debe1d73 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -135,7 +135,7 @@ uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, &switchTypeGuid); goto Away; } - pReqHandlerInfo = ReqHandlerAdd(switchTypeGuid, + pReqHandlerInfo = req_handler_add(switchTypeGuid, switch_type_name, controlfunc, min_channel_bytes, @@ -279,7 +279,7 @@ static LIST_HEAD(ReqHandlerInfo_list); /* list of struct req_handler_info */ static DEFINE_SPINLOCK(ReqHandlerInfo_list_lock); struct req_handler_info * -ReqHandlerAdd(uuid_le switchTypeGuid, +req_handler_add(uuid_le switch_uuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, @@ -292,7 +292,7 @@ ReqHandlerAdd(uuid_le switchTypeGuid, rc = kzalloc(sizeof(*rc), GFP_ATOMIC); if (!rc) return NULL; - rc->switch_uuid = switchTypeGuid; + rc->switch_uuid = switch_uuid; rc->controlfunc = controlfunc; rc->min_channel_bytes = min_channel_bytes; rc->server_channel_ok = Server_Channel_Ok; -- cgit v1.2.3-59-g8ed1b From ea2cfd65315b479eeadd77df4ac311f7f5a1cb16 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:53 -0400 Subject: staging: unisys: fix CamelCase in ReqHandlerFind() Fix CamelCase names: ReqHandlerFind => req_handler_find switchTypeGuid => switch_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 2 +- drivers/staging/unisys/uislib/uisutils.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 1455c73a5479..65ded5eeab26 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -74,7 +74,7 @@ struct req_handler_info *req_handler_add(uuid_le switch_uuid, int (*svr_channel_init)(void *x, unsigned char *client_str, u32 client_str_len, u64 bytes)); -struct req_handler_info *ReqHandlerFind(uuid_le switchTypeGuid); +struct req_handler_info *req_handler_find(uuid_le switch_uuid); int ReqHandlerDel(uuid_le switchTypeGuid); #define uislib_ioremap_cache(addr, size) \ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index c438d8334e23..0ae008bfa199 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -379,7 +379,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) if (msg->hdr.Flags.testMessage) dev->chanptr = (void __iomem *)__va(dev->channel_addr); else { - pReqHandler = ReqHandlerFind(dev->channel_uuid); + pReqHandler = req_handler_find(dev->channel_uuid); if (pReqHandler) /* generic service handler registered for this * channel diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index b336debe1d73..b62b680f23c5 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -308,7 +308,7 @@ req_handler_add(uuid_le switch_uuid, } struct req_handler_info * -ReqHandlerFind(uuid_le switchTypeGuid) +req_handler_find(uuid_le switch_uuid) { struct list_head *lelt, *tmp; struct req_handler_info *entry = NULL; @@ -316,7 +316,7 @@ ReqHandlerFind(uuid_le switchTypeGuid) spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, struct req_handler_info, list_link); - if (uuid_le_cmp(entry->switch_uuid, switchTypeGuid) == 0) { + if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) { spin_unlock(&ReqHandlerInfo_list_lock); return entry; } -- cgit v1.2.3-59-g8ed1b From 7692544dcfab0a9ad1e68ed98b8637f39428bea4 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:54 -0400 Subject: staging: unisys: fix CamelCase in ReqHandlerDel Fix CamelCase names: ReqHandlerDel => req_handler_del switchTypeGuid => switch_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uisutils.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 65ded5eeab26..ba71a471ecdf 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -75,7 +75,7 @@ struct req_handler_info *req_handler_add(uuid_le switch_uuid, unsigned char *client_str, u32 client_str_len, u64 bytes)); struct req_handler_info *req_handler_find(uuid_le switch_uuid); -int ReqHandlerDel(uuid_le switchTypeGuid); +int req_handler_del(uuid_le switch_uuid); #define uislib_ioremap_cache(addr, size) \ dbg_ioremap_cache(addr, size, __FILE__, __LINE__) diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index b62b680f23c5..5231c19bb74a 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -165,7 +165,7 @@ uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid) int rc = 0; /* assume failure */ LOGINF("type=%pUL.\n", &switchTypeGuid); - if (ReqHandlerDel(switchTypeGuid) < 0) { + if (req_handler_del(switchTypeGuid) < 0) { LOGERR("failed to remove %pUL from server list\n", &switchTypeGuid); goto Away; @@ -326,7 +326,7 @@ req_handler_find(uuid_le switch_uuid) } int -ReqHandlerDel(uuid_le switchTypeGuid) +req_handler_del(uuid_le switch_uuid) { struct list_head *lelt, *tmp; struct req_handler_info *entry = NULL; @@ -335,7 +335,7 @@ ReqHandlerDel(uuid_le switchTypeGuid) spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, struct req_handler_info, list_link); - if (uuid_le_cmp(entry->switch_uuid, switchTypeGuid) == 0) { + if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) { list_del(lelt); kfree(entry); rc++; -- cgit v1.2.3-59-g8ed1b From f9dd5dda30cd700d38ed24196bfb2b1f5a690b0c Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:55 -0400 Subject: staging: unisys: fix indentation in req_handler_info Fix the indentation around server_channel_init, so the parameters line up nicely. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index ba71a471ecdf..3f481364ff5a 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -59,8 +59,8 @@ struct req_handler_info { int (*controlfunc)(struct io_msgs *); unsigned long min_channel_bytes; int (*server_channel_ok)(unsigned long channel_bytes); - int (*server_channel_init) - (void *x, unsigned char *client_str, u32 client_str_len, u64 bytes); + int (*server_channel_init)(void *x, unsigned char *client_str, + u32 client_str_len, u64 bytes); char switch_type_name[99]; struct list_head list_link; /* links into ReqHandlerInfo_list */ }; -- cgit v1.2.3-59-g8ed1b From 1032885d7299217995c134e5cd36dd0b333b3bdb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:56 -0400 Subject: staging: unisys: fix CamelCase in uisctrl_register_req_handler_ex Fix CamelCase names: switchTypeGuid => switch_uuid clientStr => client_str clientStrLent => client_str_len chipset_driverInfo => chipset_driver_info Server_Channel_Ok => server_channel_ok Server_Channel_Init => server_channel_init Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 13 ++++++----- drivers/staging/unisys/uislib/uisutils.c | 38 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 3f481364ff5a..9fb9aaa6f90a 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -115,16 +115,17 @@ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, int uisctrl_register_req_handler(int type, void *fptr, ULTRA_VBUS_DEVICEINFO *chipset_driver_info); -int uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, +int uisctrl_register_req_handler_ex(uuid_le switch_guid, const char *switch_type_name, int (*fptr)(struct io_msgs *), unsigned long min_channel_bytes, int (*svr_channel_ok)(unsigned long - channelBytes), - int (*svr_channel_init) - (void *x, unsigned char *clientStr, - u32 clientStrLen, u64 bytes), - ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo); + channel_bytes), + int (*svr_channel_init)(void *x, + unsigned char *client_str, + u32 client_str_len, + u64 bytes), + ULTRA_VBUS_DEVICEINFO *chipset_driver_info); int uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid); unsigned char *util_map_virt(struct phys_info *sg); diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 5231c19bb74a..6211ac1ada44 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -105,43 +105,43 @@ uisctrl_register_req_handler(int type, void *fptr, EXPORT_SYMBOL_GPL(uisctrl_register_req_handler); int -uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, +uisctrl_register_req_handler_ex(uuid_le switch_uuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, - int (*Server_Channel_Ok)(unsigned long - channelBytes), - int (*Server_Channel_Init) - (void *x, unsigned char *clientStr, - u32 clientStrLen, u64 bytes), - ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo) + int (*server_channel_ok)(unsigned long + channel_bytes), + int (*server_channel_init)(void *x, + unsigned char *client_str, + u32 client_str_len, u64 bytes), + ULTRA_VBUS_DEVICEINFO *chipset_driver_info) { struct req_handler_info *pReqHandlerInfo; int rc = 0; /* assume failure */ LOGINF("type=%pUL, controlfunc=0x%p.\n", - &switchTypeGuid, controlfunc); + &switch_uuid, controlfunc); if (!controlfunc) { - LOGERR("%pUL: controlfunc must be supplied\n", &switchTypeGuid); + LOGERR("%pUL: controlfunc must be supplied\n", &switch_uuid); goto Away; } - if (!Server_Channel_Ok) { + if (!server_channel_ok) { LOGERR("%pUL: Server_Channel_Ok must be supplied\n", - &switchTypeGuid); + &switch_uuid); goto Away; } - if (!Server_Channel_Init) { + if (!server_channel_init) { LOGERR("%pUL: Server_Channel_Init must be supplied\n", - &switchTypeGuid); + &switch_uuid); goto Away; } - pReqHandlerInfo = req_handler_add(switchTypeGuid, + pReqHandlerInfo = req_handler_add(switch_uuid, switch_type_name, controlfunc, min_channel_bytes, - Server_Channel_Ok, Server_Channel_Init); + server_channel_ok, server_channel_init); if (!pReqHandlerInfo) { - LOGERR("failed to add %pUL to server list\n", &switchTypeGuid); + LOGERR("failed to add %pUL to server list\n", &switch_uuid); goto Away; } @@ -149,11 +149,11 @@ uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, rc = 1; /* success */ Away: if (rc) { - if (chipset_DriverInfo) - bus_device_info_init(chipset_DriverInfo, "chipset", + if (chipset_driver_info) + bus_device_info_init(chipset_driver_info, "chipset", "uislib", VERSION, NULL); } else - LOGERR("failed to register type %pUL.\n", &switchTypeGuid); + LOGERR("failed to register type %pUL.\n", &switch_uuid); return rc; } -- cgit v1.2.3-59-g8ed1b From d44694af501ebeb16da450bfcfd286b0a18fa8cb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:57 -0400 Subject: staging: unisys: fix CamelCase in uisctrl_unregister_req_handler_ex Fix CamelCase names: switchTypeGuid => switch_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uisutils.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 9fb9aaa6f90a..ea8708b078ec 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -127,7 +127,7 @@ int uisctrl_register_req_handler_ex(uuid_le switch_guid, u64 bytes), ULTRA_VBUS_DEVICEINFO *chipset_driver_info); -int uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid); +int uisctrl_unregister_req_handler_ex(uuid_le switch_uuid); unsigned char *util_map_virt(struct phys_info *sg); void util_unmap_virt(struct phys_info *sg); unsigned char *util_map_virt_atomic(struct phys_info *sg); diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 6211ac1ada44..31f517aa141f 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -160,21 +160,21 @@ Away: EXPORT_SYMBOL_GPL(uisctrl_register_req_handler_ex); int -uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid) +uisctrl_unregister_req_handler_ex(uuid_le switch_uuid) { int rc = 0; /* assume failure */ - LOGINF("type=%pUL.\n", &switchTypeGuid); - if (req_handler_del(switchTypeGuid) < 0) { + LOGINF("type=%pUL.\n", &switch_uuid); + if (req_handler_del(switch_uuid) < 0) { LOGERR("failed to remove %pUL from server list\n", - &switchTypeGuid); + &switch_uuid); goto Away; } atomic_dec(&uisutils_registered_services); rc = 1; /* success */ Away: if (!rc) - LOGERR("failed to unregister type %pUL.\n", &switchTypeGuid); + LOGERR("failed to unregister type %pUL.\n", &switch_uuid); return rc; } EXPORT_SYMBOL_GPL(uisctrl_unregister_req_handler_ex); -- cgit v1.2.3-59-g8ed1b From 99c4c5ae69e01976a2541961a2200b570d153f28 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:58 -0400 Subject: staging: unisys: remove uislib_server_inject_add/del_vnic() prototypes These functions contain CamelCase names but are not used. Delete the prototypes from uisutils.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index ea8708b078ec..1520c8dcbf48 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -132,11 +132,6 @@ unsigned char *util_map_virt(struct phys_info *sg); void util_unmap_virt(struct phys_info *sg); unsigned char *util_map_virt_atomic(struct phys_info *sg); void util_unmap_virt_atomic(void *buf); -int uislib_server_inject_add_vnic(u32 switchNo, u32 BusNo, u32 numIntPorts, - u32 numExtPorts, u8 *pmac[ETH_ALEN], - pCHANNEL_HEADER **chan); -void uislib_server_inject_del_vnic(u32 switchNo, u32 busNo, u32 numIntPorts, - u32 numExtPorts); int uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid, u64 channelAddr, ulong nChannelBytes); int uislib_client_inject_del_bus(u32 busNo); -- cgit v1.2.3-59-g8ed1b From e1242538b1d049e97ee975da79a461bc297d9992 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:08:59 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_add_bus() Fix CamelCase names: busNo => bus_no instGuid => inst_uuid channelAddr => channel_addr nChannelBytes => n_channel_bytes Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 4 ++-- drivers/staging/unisys/uislib/uislib.c | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 1520c8dcbf48..1902244f662f 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -132,8 +132,8 @@ unsigned char *util_map_virt(struct phys_info *sg); void util_unmap_virt(struct phys_info *sg); unsigned char *util_map_virt_atomic(struct phys_info *sg); void util_unmap_virt_atomic(void *buf); -int uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid, - u64 channelAddr, ulong nChannelBytes); +int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, + u64 channel_addr, ulong n_channel_bytes); int uislib_client_inject_del_bus(u32 busNo); int uislib_client_inject_add_vhba(u32 busNo, u32 devNo, diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 0ae008bfa199..2a2e68bfc905 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -822,14 +822,14 @@ delete_device_glue(u32 busNo, u32 devNo) } int -uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid, - u64 channelAddr, ulong nChannelBytes) +uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, + u64 channel_addr, ulong n_channel_bytes) { CONTROLVM_MESSAGE msg; - LOGINF("enter busNo=0x%x\n", busNo); + LOGINF("enter busNo=0x%x\n", bus_no); /* step 0: init the chipset */ - POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); + POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO); if (!chipset_inited) { /* step: initialize the chipset */ @@ -848,24 +848,25 @@ uislib_client_inject_add_bus(u32 busNo, uuid_le instGuid, return 0; } LOGINF("chipset initialized\n"); - POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, busNo, + POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); } /* step 1: create a bus */ - POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_WARNING); + POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, + POSTCODE_SEVERITY_WARNING); init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); - msg.cmd.createBus.busNo = busNo; + msg.cmd.createBus.busNo = bus_no; msg.cmd.createBus.deviceCount = 23; /* devNo+1; */ - msg.cmd.createBus.channelAddr = channelAddr; - msg.cmd.createBus.channelBytes = nChannelBytes; + msg.cmd.createBus.channelAddr = channel_addr; + msg.cmd.createBus.channelBytes = n_channel_bytes; if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("create_bus failed.\n"); - POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, + POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR); return 0; } - POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); + POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO); return 1; } -- cgit v1.2.3-59-g8ed1b From ac15ba594e9b1344119130017287878410653231 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:00 -0400 Subject: staging: unisys: fix CamelCase in uislib_client_inject_del_bus() Fix CamelCase names: busNo => bus_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 1902244f662f..4610b4ffca29 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -134,7 +134,7 @@ unsigned char *util_map_virt_atomic(struct phys_info *sg); void util_unmap_virt_atomic(void *buf); int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, u64 channel_addr, ulong n_channel_bytes); -int uislib_client_inject_del_bus(u32 busNo); +int uislib_client_inject_del_bus(u32 bus_no); int uislib_client_inject_add_vhba(u32 busNo, u32 devNo, u64 phys_chan_addr, u32 chan_bytes, diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 2a2e68bfc905..4d85a327fb7c 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -874,9 +874,9 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_add_bus); int -uislib_client_inject_del_bus(u32 busNo) +uislib_client_inject_del_bus(u32 bus_no) { - return delete_bus_glue(busNo); + return delete_bus_glue(bus_no); } EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus); -- cgit v1.2.3-59-g8ed1b From 3d3b7154a38141886b945f8b93a3316ba414a0de Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:01 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_add_vhba() Clean up CamelCase names: busNo => bus_no devNo => dev_no instGuid => inst_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 4 ++-- drivers/staging/unisys/uislib/uislib.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 4610b4ffca29..8ed82c4bd6e7 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -136,9 +136,9 @@ int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, u64 channel_addr, ulong n_channel_bytes); int uislib_client_inject_del_bus(u32 bus_no); -int uislib_client_inject_add_vhba(u32 busNo, u32 devNo, +int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le instGuid, + int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr); int uislib_client_inject_pause_vhba(u32 busNo, u32 devNo); int uislib_client_inject_resume_vhba(u32 busNo, u32 devNo); diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 4d85a327fb7c..9f62462f9966 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -922,19 +922,19 @@ uislib_client_inject_resume_vhba(u32 busNo, u32 devNo) EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba); int -uislib_client_inject_add_vhba(u32 busNo, u32 devNo, +uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le instGuid, + int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr) { CONTROLVM_MESSAGE msg; - LOGINF(" enter busNo=0x%x devNo=0x%x\n", busNo, devNo); + LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no); /* chipset init'ed with bus bus has been previously created - * Verify it still exists step 2: create the VHBA device on the * bus */ - POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC, devNo, busNo, + POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); @@ -943,9 +943,9 @@ uislib_client_inject_add_vhba(u32 busNo, u32 devNo, * need to be ioremap()ed */ msg.hdr.Flags.testMessage = 1; - msg.cmd.createDevice.busNo = busNo; - msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.devInstGuid = instGuid; + msg.cmd.createDevice.busNo = bus_no; + msg.cmd.createDevice.devNo = dev_no; + msg.cmd.createDevice.devInstGuid = inst_uuid; if (intr) msg.cmd.createDevice.intr = *intr; else @@ -963,11 +963,11 @@ uislib_client_inject_add_vhba(u32 busNo, u32 devNo, msg.cmd.createDevice.dataTypeGuid = UltraVhbaChannelProtocolGuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA create_device failed.\n"); - POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, devNo, busNo, + POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); return 0; } - POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC, devNo, busNo, + POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); return 1; } -- cgit v1.2.3-59-g8ed1b From 062d312d81acd4e9ea5a8d3d7e3f6945b2b7ecd9 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:02 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_pause_vhba() Fix CamelCase names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 8ed82c4bd6e7..27dc876d0316 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -140,7 +140,7 @@ int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr); -int uislib_client_inject_pause_vhba(u32 busNo, u32 devNo); +int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vhba(u32 busNo, u32 devNo); int uislib_client_inject_del_vhba(u32 busNo, u32 devNo); int uislib_client_inject_add_vnic(u32 busNo, u32 devNo, diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 9f62462f9966..132126944acf 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -881,19 +881,19 @@ uislib_client_inject_del_bus(u32 bus_no) EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus); int -uislib_client_inject_pause_vhba(u32 busNo, u32 devNo) +uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no) { CONTROLVM_MESSAGE msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = busNo; - msg.cmd.deviceChangeState.devNo = devNo; + msg.cmd.deviceChangeState.busNo = bus_no; + msg.cmd.deviceChangeState.devNo = dev_no; msg.cmd.deviceChangeState.state = SegmentStateStandby; rc = pause_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA pause_device failed. busNo=0x%x devNo=0x%x\n", - busNo, devNo); + bus_no, dev_no); return rc; } return 0; -- cgit v1.2.3-59-g8ed1b From ae47a51bfba0a848a15d580aa68ec7eeda377ddf Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:03 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_resume_vhba() Fix CamelCase names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 27dc876d0316..408dca2d9d30 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -141,7 +141,7 @@ int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr); int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no); -int uislib_client_inject_resume_vhba(u32 busNo, u32 devNo); +int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_del_vhba(u32 busNo, u32 devNo); int uislib_client_inject_add_vnic(u32 busNo, u32 devNo, u64 phys_chan_addr, u32 chan_bytes, diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 132126944acf..96e38bfcc1f8 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -901,19 +901,19 @@ uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no) EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba); int -uislib_client_inject_resume_vhba(u32 busNo, u32 devNo) +uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no) { CONTROLVM_MESSAGE msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = busNo; - msg.cmd.deviceChangeState.devNo = devNo; + msg.cmd.deviceChangeState.busNo = bus_no; + msg.cmd.deviceChangeState.devNo = dev_no; msg.cmd.deviceChangeState.state = SegmentStateRunning; rc = resume_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA resume_device failed. busNo=0x%x devNo=0x%x\n", - busNo, devNo); + bus_no, dev_no); return rc; } return 0; -- cgit v1.2.3-59-g8ed1b From 6bc962ac9390c185496c9d60b45415b2dc7dc817 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:04 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_del_vhba() Fix CamelCase names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 408dca2d9d30..3a232bebed6b 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -142,7 +142,7 @@ int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, struct InterruptInfo *intr); int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no); -int uislib_client_inject_del_vhba(u32 busNo, u32 devNo); +int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_add_vnic(u32 busNo, u32 devNo, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le instGuid, diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 96e38bfcc1f8..5b897a9bb3e7 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -974,9 +974,9 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, EXPORT_SYMBOL_GPL(uislib_client_inject_add_vhba); int -uislib_client_inject_del_vhba(u32 busNo, u32 devNo) +uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no) { - return delete_device_glue(busNo, devNo); + return delete_device_glue(bus_no, dev_no); } EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba); -- cgit v1.2.3-59-g8ed1b From 94a887da6fe4cbe253493099895f939003c4c372 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:05 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_add_vnic() Fix CamelCase names: busNo => bus_no devNo => dev_no instGuid => inst_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 4 ++-- drivers/staging/unisys/uislib/uislib.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 3a232bebed6b..cbfbd9eac5a5 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -143,9 +143,9 @@ int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no); -int uislib_client_inject_add_vnic(u32 busNo, u32 devNo, +int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le instGuid, + int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr); int uislib_client_inject_pause_vnic(u32 busNo, u32 devNo); int uislib_client_inject_resume_vnic(u32 busNo, u32 devNo); diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 5b897a9bb3e7..368b366bb476 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -981,19 +981,19 @@ uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no) EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba); int -uislib_client_inject_add_vnic(u32 busNo, u32 devNo, +uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, - int is_test_addr, uuid_le instGuid, + int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr) { CONTROLVM_MESSAGE msg; - LOGINF(" enter busNo=0x%x devNo=0x%x\n", busNo, devNo); + LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no); /* chipset init'ed with bus bus has been previously created - * Verify it still exists step 2: create the VNIC device on the * bus */ - POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC, devNo, busNo, + POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); @@ -1002,9 +1002,9 @@ uislib_client_inject_add_vnic(u32 busNo, u32 devNo, * need to be ioremap()ed */ msg.hdr.Flags.testMessage = 1; - msg.cmd.createDevice.busNo = busNo; - msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.devInstGuid = instGuid; + msg.cmd.createDevice.busNo = bus_no; + msg.cmd.createDevice.devNo = dev_no; + msg.cmd.createDevice.devInstGuid = inst_uuid; if (intr) msg.cmd.createDevice.intr = *intr; else @@ -1022,12 +1022,12 @@ uislib_client_inject_add_vnic(u32 busNo, u32 devNo, msg.cmd.createDevice.dataTypeGuid = UltraVnicChannelProtocolGuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC create_device failed.\n"); - POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, devNo, busNo, + POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_SEVERITY_ERR); return 0; } - POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC, devNo, busNo, + POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC, dev_no, bus_no, POSTCODE_SEVERITY_INFO); return 1; } -- cgit v1.2.3-59-g8ed1b From 68a4b12c9293104a7c65167888125412b441fc8b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:06 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_pause_vnic() Fix CamelCase names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index cbfbd9eac5a5..f08d51f392b0 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -147,7 +147,7 @@ int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr); -int uislib_client_inject_pause_vnic(u32 busNo, u32 devNo); +int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vnic(u32 busNo, u32 devNo); int uislib_client_inject_del_vnic(u32 busNo, u32 devNo); #ifdef STORAGE_CHANNEL diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 368b366bb476..da1887d552f3 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1034,19 +1034,19 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, EXPORT_SYMBOL_GPL(uislib_client_inject_add_vnic); int -uislib_client_inject_pause_vnic(u32 busNo, u32 devNo) +uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no) { CONTROLVM_MESSAGE msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = busNo; - msg.cmd.deviceChangeState.devNo = devNo; + msg.cmd.deviceChangeState.busNo = bus_no; + msg.cmd.deviceChangeState.devNo = dev_no; msg.cmd.deviceChangeState.state = SegmentStateStandby; rc = pause_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC pause_device failed. busNo=0x%x devNo=0x%x\n", - busNo, devNo); + bus_no, dev_no); return -1; } return 0; -- cgit v1.2.3-59-g8ed1b From 3fe7cec47780878f5c44723097bb842b67d69dae Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:07 -0400 Subject: staging: unisys: Fix CamelCase in uislib_client_inject_resume_vnic() Fix CamelCase names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index f08d51f392b0..28e6f1f17615 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -148,7 +148,7 @@ int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, int is_test_addr, uuid_le inst_uuid, struct InterruptInfo *intr); int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no); -int uislib_client_inject_resume_vnic(u32 busNo, u32 devNo); +int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no); int uislib_client_inject_del_vnic(u32 busNo, u32 devNo); #ifdef STORAGE_CHANNEL u64 uislib_storage_channel(int client_id); diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index da1887d552f3..09c71637778f 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1054,19 +1054,19 @@ uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no) EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic); int -uislib_client_inject_resume_vnic(u32 busNo, u32 devNo) +uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) { CONTROLVM_MESSAGE msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = busNo; - msg.cmd.deviceChangeState.devNo = devNo; + msg.cmd.deviceChangeState.busNo = bus_no; + msg.cmd.deviceChangeState.devNo = dev_no; msg.cmd.deviceChangeState.state = SegmentStateRunning; rc = resume_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC resume_device failed. busNo=0x%x devNo=0x%x\n", - busNo, devNo); + bus_no, dev_no); return -1; } return 0; -- cgit v1.2.3-59-g8ed1b From bdb628d080e02936fc8e52d577f55cde0dfb4b22 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:08 -0400 Subject: staging: unisys: fix CamelCase in uislib_client_inject_del_vnic() Fix CamelCase names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 28e6f1f17615..54427a2d12af 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -149,7 +149,7 @@ int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, struct InterruptInfo *intr); int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no); -int uislib_client_inject_del_vnic(u32 busNo, u32 devNo); +int uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no); #ifdef STORAGE_CHANNEL u64 uislib_storage_channel(int client_id); #endif diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 09c71637778f..3d32c43e68e9 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1075,9 +1075,9 @@ uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic); int -uislib_client_inject_del_vnic(u32 busNo, u32 devNo) +uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no) { - return delete_device_glue(busNo, devNo); + return delete_device_glue(bus_no, dev_no); } EXPORT_SYMBOL_GPL(uislib_client_inject_del_vnic); -- cgit v1.2.3-59-g8ed1b From c12ad837bf45c45f9c9583dd0176028722cbf2c1 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:09 -0400 Subject: staging: unisys: fix CamelCase struct name PciId Fix CamelCase name: PciId => pci_id Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h | 2 +- drivers/staging/unisys/include/uisqueue.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index d08c198e0de3..8c32be291aaa 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -148,7 +148,7 @@ struct InterruptInfo { u8 reserved[3]; /* Natural alignment purposes */ }; -struct PciId { +struct pci_id { u16 Domain; u8 Bus; u8 Slot; diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 04f51e66ebf0..8c307cf7ec23 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -118,7 +118,7 @@ struct extport_info { */ struct switch_info *swtch; - struct PciId pci_id; + struct pci_id pci_id; char name[MAX_NAME_SIZE_UISQUEUE]; union { struct vhba_wwnn wwnn; -- cgit v1.2.3-59-g8ed1b From 4eddbf13902ad72123898830876ca5039560f510 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:10 -0400 Subject: staging: unisys: fix CamelCase name for struct InterruptInfo Fix CamelCase names: InterruptInfo => irq_info Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 4 ++-- drivers/staging/unisys/include/uisqueue.h | 6 +++--- drivers/staging/unisys/include/uisutils.h | 4 ++-- drivers/staging/unisys/uislib/uislib.c | 10 +++++----- drivers/staging/unisys/virthba/virthba.c | 2 +- drivers/staging/unisys/virtpci/virtpci.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 8c32be291aaa..cbe152f8ea27 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -119,7 +119,7 @@ typedef enum { } CONTROLVM_ID; -struct InterruptInfo { +struct irq_info { /**< specifies interrupt info. It is used to send interrupts * for this channel. The peer at the end of this channel * who has registered an interrupt (using recv fields @@ -298,7 +298,7 @@ typedef struct _CONTROLVM_PACKET_DEVICE_CREATE { u64 channelBytes; /**< specifies size of the channel in bytes */ uuid_le dataTypeGuid;/**< specifies format of data in channel */ uuid_le devInstGuid; /**< instance guid for the device */ - struct InterruptInfo intr; /**< specifies interrupt information */ + struct irq_info intr; /**< specifies interrupt information */ } CONTROLVM_PACKET_DEVICE_CREATE; /* for CONTROLVM_DEVICE_CREATE */ typedef struct _CONTROLVM_PACKET_DEVICE_CONFIGURE { diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 8c307cf7ec23..cde29a22a7f4 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -132,7 +132,7 @@ struct device_info { u64 channel_bytes; uuid_le channel_uuid; uuid_le instance_uuid; - struct InterruptInfo intr; + struct irq_info intr; struct switch_info *swtch; char devid[30]; /* "vbus:dev" */ u16 polling; @@ -226,7 +226,7 @@ struct add_virt_iopart { * for DMA, for ex. */ u64 recv_bus_irq_handle; /* used to register to receive * bus level interrupts. */ - struct InterruptInfo intr; /* contains recv & send + struct irq_info intr; /* contains recv & send * interrupt info */ /* recvInterruptHandle is used to register to receive * interrupts on the data channel. Used by GuestLinux/Windows @@ -364,7 +364,7 @@ struct add_virt_guestpart { u32 bus_no; /* bus number for the operation */ u32 device_no; /* number of device on the bus */ uuid_le instance_uuid; /* instance guid for device */ - struct InterruptInfo intr; /* recv/send interrupt info */ + struct irq_info intr; /* recv/send interrupt info */ /* recvInterruptHandle contains info needed in order to * register to receive interrupts on the data channel. * sendInterruptHandle contains handle which is provided to diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 54427a2d12af..d6859c68477d 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -139,14 +139,14 @@ int uislib_client_inject_del_bus(u32 bus_no); int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le inst_uuid, - struct InterruptInfo *intr); + struct irq_info *intr); int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no); int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le inst_uuid, - struct InterruptInfo *intr); + struct irq_info *intr); int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no); int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no); int uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no); diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 3d32c43e68e9..b1f6c6ef801b 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -925,7 +925,7 @@ int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le inst_uuid, - struct InterruptInfo *intr) + struct irq_info *intr) { CONTROLVM_MESSAGE msg; @@ -950,7 +950,7 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, msg.cmd.createDevice.intr = *intr; else memset(&msg.cmd.createDevice.intr, 0, - sizeof(struct InterruptInfo)); + sizeof(struct irq_info)); msg.cmd.createDevice.channelAddr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", @@ -984,7 +984,7 @@ int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, u64 phys_chan_addr, u32 chan_bytes, int is_test_addr, uuid_le inst_uuid, - struct InterruptInfo *intr) + struct irq_info *intr) { CONTROLVM_MESSAGE msg; @@ -1009,7 +1009,7 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, msg.cmd.createDevice.intr = *intr; else memset(&msg.cmd.createDevice.intr, 0, - sizeof(struct InterruptInfo)); + sizeof(struct irq_info)); msg.cmd.createDevice.channelAddr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", @@ -1106,7 +1106,7 @@ uislib_client_add_vnic(u32 busNo) msg.cmd.createDevice.busNo = busNo; msg.cmd.createDevice.devNo = devNo; msg.cmd.createDevice.devInstGuid = NULL_UUID_LE; - memset(&msg.cmd.createDevice.intr, 0, sizeof(struct InterruptInfo)); + memset(&msg.cmd.createDevice.intr, 0, sizeof(struct irq_info)); msg.cmd.createDevice.channelAddr = PhysicalDataChan; msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; msg.cmd.createDevice.dataTypeGuid = UltraVnicChannelProtocolGuid; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 938e2c82c1ab..e4130c9714fc 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -172,7 +172,7 @@ struct virthba_info { struct virtpci_dev *virtpcidev; struct list_head dev_info_list; struct chaninfo chinfo; - struct InterruptInfo intr; /* use recvInterrupt info to receive + struct irq_info intr; /* use recvInterrupt info to receive interrupts when IOs complete */ int interrupt_vector; struct scsipending pending[MAX_PENDING_REQUESTS]; /* Tracks the requests diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index 6e26956c79f4..8a0d43947596 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -60,7 +60,7 @@ struct virtpci_dev { unsigned short device; /* device id for device */ u32 busNo; /* number of bus on which device exists */ u32 deviceNo; /* device's number on the bus */ - struct InterruptInfo intr; /* interrupt info */ + struct irq_info intr; /* interrupt info */ struct device generic_dev; /* generic device */ union { struct scsi_adap_info scsi; diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 2bf2e2f368ef..af35728a7e1d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -63,7 +63,7 @@ typedef enum { typedef struct { VISORCHIPSET_ADDRESSTYPE addrType; HOSTADDRESS channelAddr; - struct InterruptInfo intr; + struct irq_info intr; u64 nChannelBytes; uuid_le channelTypeGuid; uuid_le channelInstGuid; -- cgit v1.2.3-59-g8ed1b From 0e2906ac9f15b5f87145b211b88696e47334232f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:11 -0400 Subject: staging: unisys: remove DEDICATED_SWITCH macro Nobody is using this macro anymore so remove it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index cde29a22a7f4..19c8d5d7dc8b 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -169,9 +169,6 @@ struct bus_info { * by IOVM; 0 otherwise... */ }; -#define DEDICATED_SWITCH(s) ((s->extPortCount == 1) && \ - (s->intPortCount == 1)) - struct sn_list_entry { struct uisscsi_dest pdest; /* scsi bus, target, lun for * phys disk */ -- cgit v1.2.3-59-g8ed1b From 51121ffc8b084adeed670fb4cb42a74a30e45d81 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:12 -0400 Subject: staging: unisys: fix typedef of ULTRA_VBUS_CHANNEL_PROTOCOL Get rid of the typedef ULTRA_VBUS_CHANNEL_PROTOCOL, in favor of the name struct ultra_vbus_channel_protocol. This change finishes the warnings clean up for include/uisqueue.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/vbuschannel.h | 8 ++++---- drivers/staging/unisys/include/uisqueue.h | 2 +- drivers/staging/unisys/virtpci/virtpci.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 1231c454176f..20e0753af945 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -47,7 +47,7 @@ static const uuid_le UltraVbusChannelProtocolGuid = (ULTRA_check_channel_client(pChannel, \ UltraVbusChannelProtocolGuid, \ "vbus", \ - sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL), \ + sizeof(struct ultra_vbus_channel_protocol),\ ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE, \ __FILE__, __LINE__, logCtx)) @@ -55,7 +55,7 @@ static const uuid_le UltraVbusChannelProtocolGuid = #define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes, logCtx) \ (ULTRA_check_channel_server(UltraVbusChannelProtocolGuid, \ "vbus", \ - sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL), \ + sizeof(struct ultra_vbus_channel_protocol),\ actualBytes, \ __FILE__, __LINE__, logCtx)) @@ -75,7 +75,7 @@ typedef struct _ULTRA_VBUS_HEADERINFO { u8 reserved[104]; } ULTRA_VBUS_HEADERINFO; -typedef struct _ULTRA_VBUS_CHANNEL_PROTOCOL { +struct ultra_vbus_channel_protocol { ULTRA_CHANNEL_PROTOCOL ChannelHeader; /* initialized by server */ ULTRA_VBUS_HEADERINFO HdrInfo; /* initialized by server */ /* the remainder of this channel is filled in by the client */ @@ -86,7 +86,7 @@ typedef struct _ULTRA_VBUS_CHANNEL_PROTOCOL { ULTRA_VBUS_DEVICEINFO DevInfo[0]; /* describes client device and * driver for */ /* each device on the bus */ -} ULTRA_VBUS_CHANNEL_PROTOCOL; +}; #define VBUS_CH_SIZE_EXACT(MAXDEVICES) \ (sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL) + ((MAXDEVICES) * \ diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 19c8d5d7dc8b..6e0ec05a4a43 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -158,7 +158,7 @@ struct bus_info { struct device_info **device; u64 guest_handle, recv_bus_irq_handle; uuid_le bus_inst_uuid; - ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *bus_channel; + struct ultra_vbus_channel_protocol __iomem *bus_channel; int bus_channel_bytes; struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/ */ struct proc_dir_entry *proc_info; /* proc/uislib/vbus//info */ diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 91f939570b38..83f1a00c6bed 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -186,7 +186,7 @@ int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem *chanptr) } /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */ -static int write_vbus_chpInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, +static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, ULTRA_VBUS_DEVICEINFO *info) { int off; @@ -205,7 +205,7 @@ static int write_vbus_chpInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, } /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */ -static int write_vbus_busInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, +static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, ULTRA_VBUS_DEVICEINFO *info) { int off; @@ -227,7 +227,7 @@ static int write_vbus_busInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, * ULTRA_VBUS_CHANNEL_PROTOCOL.DevInfo[]. */ static int -write_vbus_devInfo(ULTRA_VBUS_CHANNEL_PROTOCOL *chan, +write_vbus_devInfo(struct ultra_vbus_channel_protocol *chan, ULTRA_VBUS_DEVICEINFO *info, int devix) { int off; -- cgit v1.2.3-59-g8ed1b From f42aea3cb254ea15bc48df24964c446a4caefc2f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:13 -0400 Subject: staging: unisys: Fix VMCALL_IO_CONTROLVM_ADDR_PARAMS structure Remove the typedef from VMCALL_IO_CONTROLVM_ADDR_PARAMS and switch to use struct vmcall_io_controlvm_addr_params. Fix the CamelCase names: ChannelAddress => address ChannelBytes => channel_bytes Unused => unused Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 10 +++++----- drivers/staging/unisys/include/uisutils.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index 0b5b5626af5a..4eeb40184c84 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -113,15 +113,15 @@ typedef struct phys_info IO_DATA_STRUCTURE; /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ #pragma pack(push, 1) /* Parameters to VMCALL_IO_CONTROLVM_ADDR interface */ -typedef struct _VMCALL_IO_CONTROLVM_ADDR_PARAMS { +struct vmcall_io_controlvm_addr_params { /* The Guest-relative physical address of the ControlVm channel. * This VMCall fills this in with the appropriate address. */ - u64 ChannelAddress; /* contents provided by this VMCALL (OUT) */ + u64 address; /* contents provided by this VMCALL (OUT) */ /* the size of the ControlVm channel in bytes This VMCall fills this * in with the appropriate address. */ - u32 ChannelBytes; /* contents provided by this VMCALL (OUT) */ - u8 Unused[4]; /* Unused Bytes in the 64-Bit Aligned Struct */ -} VMCALL_IO_CONTROLVM_ADDR_PARAMS; + u32 channel_bytes; /* contents provided by this VMCALL (OUT) */ + u8 unused[4]; /* Unused Bytes in the 64-Bit Aligned Struct */ +}; #pragma pack(pop) /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index d6859c68477d..60c7bce46018 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -220,15 +220,15 @@ unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, static inline unsigned int issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes) { - VMCALL_IO_CONTROLVM_ADDR_PARAMS params; + struct vmcall_io_controlvm_addr_params params; int result = VMCALL_SUCCESS; u64 physaddr; physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result); if (VMCALL_SUCCESSFUL(result)) { - *control_addr = params.ChannelAddress; - *control_bytes = params.ChannelBytes; + *control_addr = params.address; + *control_bytes = params.channel_bytes; } return result; } -- cgit v1.2.3-59-g8ed1b From 3dbf7b739f781f4195e4ac87c11bb9f250118682 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:14 -0400 Subject: staging: unisys: Fix VMCALL_IO_DIAG_ADDR_PARAMS Remove the typedef from VMCALL_IO_DIAG_ADDR_PARAMS and use the name struct vmcall_io_diag_addr_params instead. Fix CamelCase member names: ChannelAddress => address Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 6 +++--- drivers/staging/unisys/include/uisutils.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index 4eeb40184c84..a7830cac9b8c 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -130,11 +130,11 @@ struct vmcall_io_controlvm_addr_params { /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ #pragma pack(push, 1) /* Parameters to VMCALL_IO_DIAG_ADDR interface */ -typedef struct _VMCALL_IO_DIAG_ADDR_PARAMS { +struct vmcall_io_diag_addr_params { /* The Guest-relative physical address of the diagnostic channel. * This VMCall fills this in with the appropriate address. */ - u64 ChannelAddress; /* contents provided by this VMCALL (OUT) */ -} VMCALL_IO_DIAG_ADDR_PARAMS; + u64 address; /* contents provided by this VMCALL (OUT) */ +}; #pragma pack(pop) /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 60c7bce46018..2ccf155b08cd 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -235,14 +235,14 @@ issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes) static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr) { - VMCALL_IO_DIAG_ADDR_PARAMS params; + struct vmcall_io_diag_addr_params params; int result = VMCALL_SUCCESS; u64 physaddr; physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_IO_DIAG_ADDR, physaddr, result); if (VMCALL_SUCCESSFUL(result)) - *diag_channel_addr = params.ChannelAddress; + *diag_channel_addr = params.address; return result; } -- cgit v1.2.3-59-g8ed1b From 0520cfb1f6bbd47cb80908e1b589218159b52e8d Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:15 -0400 Subject: staging: unisys: fix VMCALL_IO_VISORSERIAL_ADDR_PARAMS Remove the typedef from VMCALL_IO_VISORSERIAL_ADDR_PARAMS and use the name struct vmcall_io_visorserial_addr_params instead. Fix CamelCase member names: ChannelAddress => address Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 6 +++--- drivers/staging/unisys/include/uisutils.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index a7830cac9b8c..c9dc51896287 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -143,12 +143,12 @@ struct vmcall_io_diag_addr_params { /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ #pragma pack(push, 1) /* Parameters to VMCALL_IO_VISORSERIAL_ADDR interface */ -typedef struct _VMCALL_IO_VISORSERIAL_ADDR_PARAMS { +struct vmcall_io_visorserial_addr_params { /* The Guest-relative physical address of the serial console * channel. This VMCall fills this in with the appropriate * address. */ - u64 ChannelAddress; /* contents provided by this VMCALL (OUT) */ -} VMCALL_IO_VISORSERIAL_ADDR_PARAMS; + u64 address; /* contents provided by this VMCALL (OUT) */ +}; #pragma pack(pop) /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 2ccf155b08cd..d6e8983be4c6 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -248,14 +248,14 @@ static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr) static inline unsigned int issue_vmcall_io_visorserial_addr(u64 *channel_addr) { - VMCALL_IO_VISORSERIAL_ADDR_PARAMS params; + struct vmcall_io_visorserial_addr_params params; int result = VMCALL_SUCCESS; u64 physaddr; physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_IO_VISORSERIAL_ADDR, physaddr, result); if (VMCALL_SUCCESSFUL(result)) - *channel_addr = params.ChannelAddress; + *channel_addr = params.address; return result; } -- cgit v1.2.3-59-g8ed1b From 3301335fc8228d50e92d0715a48cfcf22e7a8dfc Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:16 -0400 Subject: staging: unisys: remove volatile from struct log_info_t There's no need for last_cycles to be declared volatile. Take that out. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index d6e8983be4c6..cf9423e46c48 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -279,7 +279,7 @@ static inline s64 issue_vmcall_measurement_do_nothing(void) } struct log_info_t { - volatile unsigned long long last_cycles; + unsigned long long last_cycles; unsigned long long delta_sum[64]; unsigned long long delta_cnt[64]; unsigned long long max_delta[64]; -- cgit v1.2.3-59-g8ed1b From a09ad889f5805e77ec1b42508d5706666304b44a Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:17 -0400 Subject: staging: unisys: Fix VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS Get rid of the typedef for VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, and use the name struct vmcall_channel_version_mismatch_params instead. Fix CamelCase member names: ChannelName => chname ItemName => item_name SourceFileName => file_name SourceLineNumber => line_no And get rid of the lengthof macro in issue_vmcall_channel_mismatch(). Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/vmcallinterface.h | 12 ++++++------ drivers/staging/unisys/include/uisutils.h | 19 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index c9dc51896287..7750086e5bb3 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -154,14 +154,14 @@ struct vmcall_io_visorserial_addr_params { /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ /* Parameters to VMCALL_CHANNEL_MISMATCH interface */ -typedef struct _VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS { - u8 ChannelName[32]; /* Null terminated string giving name of channel +struct vmcall_channel_version_mismatch_params { + u8 chname[32]; /* Null terminated string giving name of channel * (IN) */ - u8 ItemName[32]; /* Null terminated string giving name of + u8 item_name[32]; /* Null terminated string giving name of * mismatched item (IN) */ - u32 SourceLineNumber; /* line# where invoked. (IN) */ - u8 SourceFileName[36]; /* source code where invoked - Null terminated + u32 line_no; /* line# where invoked. (IN) */ + u8 file_name[36]; /* source code where invoked - Null terminated * string (IN) */ -} VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS; +}; #endif /* __IOMONINTF_H__ */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index cf9423e46c48..5f249dc55c68 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -298,28 +298,23 @@ static inline unsigned int issue_vmcall_channel_mismatch(const char *chname, const char *item_name, u32 line_no, const char *path_n_fn) { - VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS params; + struct vmcall_channel_version_mismatch_params params; int result = VMCALL_SUCCESS; u64 physaddr; char *last_slash = NULL; - strlcpy(params.ChannelName, chname, - lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, ChannelName)); - strlcpy(params.ItemName, item_name, - lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, ItemName)); - params.SourceLineNumber = line_no; + strlcpy(params.chname, chname, sizeof(params.chname)); + strlcpy(params.item_name, item_name, sizeof(params.item_name)); + params.line_no = line_no; last_slash = strrchr(path_n_fn, '/'); if (last_slash != NULL) { last_slash++; - strlcpy(params.SourceFileName, last_slash, - lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, - SourceFileName)); + strlcpy(params.file_name, last_slash, sizeof(params.file_name)); } else - strlcpy(params.SourceFileName, + strlcpy(params.file_name, "Cannot determine source filename", - lengthof(VMCALL_CHANNEL_VERSION_MISMATCH_PARAMS, - SourceFileName)); + sizeof(params.file_name)); physaddr = virt_to_phys(¶ms); ISSUE_IO_VMCALL(VMCALL_CHANNEL_VERSION_MISMATCH, physaddr, result); -- cgit v1.2.3-59-g8ed1b From 32b6b291871ef333ae49ada031ee3c5a407a0a94 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:18 -0400 Subject: staging: unisys: Fix ULTRA_VBUS_DEVICEINFO Remove the typedef from ULTRA_VBUS_DEVICEINFO and use struct ultra_vbus_deviceinfo instead. Fix CamelCase member names: devType => devtype drvName => drvname infoStrings => infostrs Fix indentation on function definitions that were affected by the structure's name change. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/vbuschannel.h | 13 ++++++------ .../unisys/common-spar/include/vbusdeviceinfo.h | 24 +++++++++++----------- drivers/staging/unisys/include/uisutils.h | 22 ++++++++++---------- drivers/staging/unisys/include/vbushelper.h | 16 +++++++-------- drivers/staging/unisys/uislib/uisutils.c | 15 +++++++------- drivers/staging/unisys/virtpci/virtpci.c | 12 +++++------ drivers/staging/unisys/visorchipset/visorchipset.h | 4 ++-- .../unisys/visorchipset/visorchipset_main.c | 4 ++-- 8 files changed, 54 insertions(+), 56 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 20e0753af945..5b854243bcaf 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -79,13 +79,12 @@ struct ultra_vbus_channel_protocol { ULTRA_CHANNEL_PROTOCOL ChannelHeader; /* initialized by server */ ULTRA_VBUS_HEADERINFO HdrInfo; /* initialized by server */ /* the remainder of this channel is filled in by the client */ - ULTRA_VBUS_DEVICEINFO ChpInfo; /* describes client chipset device and - * driver */ - ULTRA_VBUS_DEVICEINFO BusInfo; /* describes client bus device and - * driver */ - ULTRA_VBUS_DEVICEINFO DevInfo[0]; /* describes client device and - * driver for */ - /* each device on the bus */ + struct ultra_vbus_deviceinfo ChpInfo; + /* describes client chipset device and driver */ + struct ultra_vbus_deviceinfo BusInfo; + /* describes client bus device and driver */ + struct ultra_vbus_deviceinfo DevInfo[0]; + /* describes client device and driver for each device on the bus */ }; #define VBUS_CH_SIZE_EXACT(MAXDEVICES) \ diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index 3bbdc2bb7ebf..f13dddc1b5c8 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -25,13 +25,13 @@ * It is filled in by the client side to provide info about the device * and driver from the client's perspective. */ -typedef struct _ULTRA_VBUS_DEVICEINFO { - u8 devType[16]; /* short string identifying the device type */ - u8 drvName[16]; /* driver .sys file name */ - u8 infoStrings[96]; /* sequence of tab-delimited id strings: */ +struct ultra_vbus_deviceinfo { + u8 devtype[16]; /* short string identifying the device type */ + u8 drvname[16]; /* driver .sys file name */ + u8 infostrs[96]; /* sequence of tab-delimited id strings: */ /* */ u8 reserved[128]; /* pad size to 256 bytes */ -} ULTRA_VBUS_DEVICEINFO; +}; #pragma pack(pop) @@ -147,15 +147,15 @@ vbuschannel_itoa(char *p, int remain, int num) * Returns the number of bytes written to

. */ static inline int -vbuschannel_devinfo_to_string(ULTRA_VBUS_DEVICEINFO *devinfo, +vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo, char *p, int remain, int devix) { char *psrc; int nsrc, x, i, pad; int chars = 0; - psrc = &(devinfo->devType[0]); - nsrc = sizeof(devinfo->devType); + psrc = &(devinfo->devtype[0]); + nsrc = sizeof(devinfo->devtype); if (vbuschannel_sanitize_buffer(NULL, 0, psrc, nsrc) <= 0) return 0; @@ -184,8 +184,8 @@ vbuschannel_devinfo_to_string(ULTRA_VBUS_DEVICEINFO *devinfo, VBUSCHANNEL_ADDACHAR(' ', p, remain, chars); /* emit driver name */ - psrc = &(devinfo->drvName[0]); - nsrc = sizeof(devinfo->drvName); + psrc = &(devinfo->drvname[0]); + nsrc = sizeof(devinfo->drvname); x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc); p += x; remain -= x; @@ -196,8 +196,8 @@ vbuschannel_devinfo_to_string(ULTRA_VBUS_DEVICEINFO *devinfo, VBUSCHANNEL_ADDACHAR(' ', p, remain, chars); /* emit strings */ - psrc = &(devinfo->infoStrings[0]); - nsrc = sizeof(devinfo->infoStrings); + psrc = &(devinfo->infostrs[0]); + nsrc = sizeof(devinfo->infostrs); x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc); p += x; remain -= x; diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 5f249dc55c68..b47543bef71b 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -114,18 +114,18 @@ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, char *format, ...); int uisctrl_register_req_handler(int type, void *fptr, - ULTRA_VBUS_DEVICEINFO *chipset_driver_info); + struct ultra_vbus_deviceinfo *chipset_driver_info); int uisctrl_register_req_handler_ex(uuid_le switch_guid, - const char *switch_type_name, - int (*fptr)(struct io_msgs *), - unsigned long min_channel_bytes, - int (*svr_channel_ok)(unsigned long - channel_bytes), - int (*svr_channel_init)(void *x, - unsigned char *client_str, - u32 client_str_len, - u64 bytes), - ULTRA_VBUS_DEVICEINFO *chipset_driver_info); + const char *switch_type_name, + int (*fptr)(struct io_msgs *), + unsigned long min_channel_bytes, + int (*svr_channel_ok)(unsigned long + channel_bytes), + int (*svr_channel_init)(void *x, + unsigned char *client_str, + u32 client_str_len, + u64 bytes), + struct ultra_vbus_deviceinfo *chipset_driver_info); int uisctrl_unregister_req_handler_ex(uuid_le switch_uuid); unsigned char *util_map_virt(struct phys_info *sg); diff --git a/drivers/staging/unisys/include/vbushelper.h b/drivers/staging/unisys/include/vbushelper.h index 1bde549ec0df..84abe5f99f54 100644 --- a/drivers/staging/unisys/include/vbushelper.h +++ b/drivers/staging/unisys/include/vbushelper.h @@ -26,19 +26,19 @@ #define TARGET_HOSTNAME "linuxguest" static inline void bus_device_info_init( - ULTRA_VBUS_DEVICEINFO * bus_device_info_ptr, + struct ultra_vbus_deviceinfo *bus_device_info_ptr, const char *dev_type, const char *drv_name, const char *ver, const char *ver_tag) { - memset(bus_device_info_ptr, 0, sizeof(ULTRA_VBUS_DEVICEINFO)); - snprintf(bus_device_info_ptr->devType, - sizeof(bus_device_info_ptr->devType), + memset(bus_device_info_ptr, 0, sizeof(struct ultra_vbus_deviceinfo)); + snprintf(bus_device_info_ptr->devtype, + sizeof(bus_device_info_ptr->devtype), "%s", (dev_type) ? dev_type : "unknownType"); - snprintf(bus_device_info_ptr->drvName, - sizeof(bus_device_info_ptr->drvName), + snprintf(bus_device_info_ptr->drvname, + sizeof(bus_device_info_ptr->drvname), "%s", (drv_name) ? drv_name : "unknownDriver"); - snprintf(bus_device_info_ptr->infoStrings, - sizeof(bus_device_info_ptr->infoStrings), "%s\t%s\t%s", + snprintf(bus_device_info_ptr->infostrs, + sizeof(bus_device_info_ptr->infostrs), "%s\t%s\t%s", (ver) ? ver : "unknownVer", (ver_tag) ? ver_tag : "unknownVerTag", TARGET_HOSTNAME); diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 31f517aa141f..a8466e30c22a 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -75,7 +75,7 @@ EXPORT_SYMBOL_GPL(uisutil_add_proc_line_ex); int uisctrl_register_req_handler(int type, void *fptr, - ULTRA_VBUS_DEVICEINFO *chipset_driver_info) + struct ultra_vbus_deviceinfo *chipset_driver_info) { LOGINF("type = %d, fptr = 0x%p.\n", type, fptr); @@ -106,15 +106,14 @@ EXPORT_SYMBOL_GPL(uisctrl_register_req_handler); int uisctrl_register_req_handler_ex(uuid_le switch_uuid, - const char *switch_type_name, - int (*controlfunc)(struct io_msgs *), - unsigned long min_channel_bytes, - int (*server_channel_ok)(unsigned long - channel_bytes), - int (*server_channel_init)(void *x, + const char *switch_type_name, + int (*controlfunc)(struct io_msgs *), + unsigned long min_channel_bytes, + int (*server_channel_ok)(unsigned long channel_bytes), + int (*server_channel_init)(void *x, unsigned char *client_str, u32 client_str_len, u64 bytes), - ULTRA_VBUS_DEVICEINFO *chipset_driver_info) + struct ultra_vbus_deviceinfo *chipset_driver_info) { struct req_handler_info *pReqHandlerInfo; int rc = 0; /* assume failure */ diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 83f1a00c6bed..73d4329f9a4a 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -137,7 +137,7 @@ static struct device virtpci_rootbus_device = { }; /* filled in with info about parent chipset driver when we register with it */ -static ULTRA_VBUS_DEVICEINFO Chipset_DriverInfo; +static struct ultra_vbus_deviceinfo Chipset_DriverInfo; static const struct sysfs_ops virtpci_driver_sysfs_ops = { .show = virtpci_driver_attr_show, @@ -152,7 +152,7 @@ static struct virtpci_dev *VpcidevListHead; static DEFINE_RWLOCK(VpcidevListLock); /* filled in with info about this driver, wrt it servicing client busses */ -static ULTRA_VBUS_DEVICEINFO Bus_DriverInfo; +static struct ultra_vbus_deviceinfo Bus_DriverInfo; /*****************************************************/ /* debugfs entries */ @@ -187,7 +187,7 @@ int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem *chanptr) /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */ static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, - ULTRA_VBUS_DEVICEINFO *info) + struct ultra_vbus_deviceinfo *info) { int off; @@ -206,7 +206,7 @@ static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */ static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, - ULTRA_VBUS_DEVICEINFO *info) + struct ultra_vbus_deviceinfo *info) { int off; @@ -228,7 +228,7 @@ static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, */ static int write_vbus_devInfo(struct ultra_vbus_channel_protocol *chan, - ULTRA_VBUS_DEVICEINFO *info, int devix) + struct ultra_vbus_deviceinfo *info, int devix) { int off; @@ -760,7 +760,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, { struct device *vbus; void *pChan; - ULTRA_VBUS_DEVICEINFO devInfo; + struct ultra_vbus_deviceinfo devInfo; const char *stype; if (!dev) { diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index af35728a7e1d..23834765a468 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -254,7 +254,7 @@ typedef struct { void visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, - ULTRA_VBUS_DEVICEINFO *driverInfo); + struct ultra_vbus_deviceinfo *driverInfo); /** Register functions (in the bus driver) to get called by visorchipset * whenever a bus or device appears for which this service partition is @@ -265,7 +265,7 @@ visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, void visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, - ULTRA_VBUS_DEVICEINFO *driverInfo); + struct ultra_vbus_deviceinfo *driverInfo); typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (CONTROLVM_MESSAGE *msg, int status); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e5df39554a1a..ce4e731a2e4a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -587,7 +587,7 @@ clear_chipset_events(void) void visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, - ULTRA_VBUS_DEVICEINFO *driverInfo) + struct ultra_vbus_deviceinfo *driverInfo) { down(&NotifierLock); if (notifiers == NULL) { @@ -611,7 +611,7 @@ EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); void visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, - ULTRA_VBUS_DEVICEINFO *driverInfo) + struct ultra_vbus_deviceinfo *driverInfo) { down(&NotifierLock); if (notifiers == NULL) { -- cgit v1.2.3-59-g8ed1b From e99454578a571f248a852180cb7560d45ed6a5dd Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:19 -0400 Subject: staging: unisys: remove old doxygen comments from timskmod.h Remove doxygen comments and fix what's left so it's still useful. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/timskmod.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index b14494ff6c1b..98e8b20a44a0 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -71,7 +71,6 @@ /** Try to evaulate the provided expression, and do a RETINT(x) iff * the expression evaluates to < 0. - * @param x the expression to try */ #define ASSERT(cond) \ do { if (!(cond)) \ @@ -89,11 +88,6 @@ (void *)(p2) = SWAPPOINTERS_TEMP; \ } while (0) -/** - * @addtogroup driverlogging - * @{ - */ - #define PRINTKDRV(fmt, args...) LOGINF(fmt, ## args) #define TBDDRV(fmt, args...) LOGERR(fmt, ## args) #define HUHDRV(fmt, args...) LOGERR(fmt, ## args) @@ -114,8 +108,6 @@ #define INFODEVX(devno, fmt, args...) LOGINFDEVX(devno, fmt, ## args) #define DEBUGDEV(devname, fmt, args...) DBGINFDEV(devname, fmt, ## args) -/* @} */ - /** Verifies the consistency of your PRIVATEDEVICEDATA structure using * conventional "signature" fields: *

@@ -139,7 +131,7 @@ ((fd)->sig2 == fd)) /** Sleep for an indicated number of seconds (for use in kernel mode). - * @param x the number of seconds to sleep. + * x - the number of seconds to sleep. */ #define SLEEP(x) \ do { current->state = TASK_INTERRUPTIBLE; \ @@ -147,7 +139,7 @@ } while (0) /** Sleep for an indicated number of jiffies (for use in kernel mode). - * @param x the number of jiffies to sleep. + * x - the number of jiffies to sleep. */ #define SLEEPJIFFIES(x) \ do { current->state = TASK_INTERRUPTIBLE; \ -- cgit v1.2.3-59-g8ed1b From 38d1fd3d0e2bf9f91e9b018b05c3730a2a454ee8 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:20 -0400 Subject: staging: unisys: remove redundant max macro No need to have another max macro when the kernel has one already. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/timskmod.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index 98e8b20a44a0..de11f440e1e3 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -146,10 +146,6 @@ schedule_timeout(x); \ } while (0) -#ifndef max -#define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif - static inline struct cdev *cdev_alloc_init(struct module *owner, const struct file_operations *fops) { -- cgit v1.2.3-59-g8ed1b From 9024db5584454b1b9b361f087e206611f8c4c55f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:21 -0400 Subject: staging: unisys: remove unused struct network_policy Nobody is using this structure, so remove it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 6e0ec05a4a43..e87f3cd1f55e 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -179,16 +179,6 @@ struct sn_list_entry { struct sn_list_entry *next; }; -struct network_policy { - u32 promiscuous:1; - u32 macassign:1; - u32 peerforwarding:1; - u32 nonotify:1; - u32 standby:1; - u32 callhome:2; - char ip_addr[30]; -}; - /* * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by * code that processes the ControlVm channel messages. -- cgit v1.2.3-59-g8ed1b From def249afb3beb07e6eb1cd9f8d5979c3dead1310 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:22 -0400 Subject: staging: unisys: remove unused fields from iopart structures The bus_no and dev_no fields in several of the iopart command parameter structures are unused. Remove them. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisqueue.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index e87f3cd1f55e..db9d2051ae2f 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -244,21 +244,15 @@ struct add_vdisk_iopart { struct uisscsi_dest pdest; /* scsi bus, target, lun for phys disk */ u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical disk */ u32 serlen; /* length of serial num */ - u32 bus_no; - u32 dev_no; }; struct del_vdisk_iopart { void *chanptr; /* pointer to data channel */ struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ - u32 bus_no; - u32 dev_no; }; struct del_virt_iopart { void *chanptr; /* pointer to data channel */ - u32 bus_no; - u32 dev_no; }; struct det_virt_iopart { /* detach internal port */ -- cgit v1.2.3-59-g8ed1b From 96b38e0d5274735d193dd5d57c201ac6e0691e90 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 3 Oct 2014 14:09:23 -0400 Subject: staging: unisys: remove unused vmcall functions from uisutils.h Delete the issue_vmcall_measurement_do_nothing() and issue_vmcall_fatal() functions, because they are unused. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index b47543bef71b..677ed7e609af 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -269,15 +269,6 @@ static inline s64 issue_vmcall_query_guest_virtual_time_offset(void) return result; } -static inline s64 issue_vmcall_measurement_do_nothing(void) -{ - u64 result = VMCALL_SUCCESS; - u64 physaddr = 0; - - ISSUE_IO_VMCALL(VMCALL_MEASUREMENT_DO_NOTHING, physaddr, result); - return result; -} - struct log_info_t { unsigned long long last_cycles; unsigned long long delta_sum[64]; @@ -321,16 +312,6 @@ static inline unsigned int issue_vmcall_channel_mismatch(const char *chname, return result; } -static inline unsigned int issue_vmcall_fatal(void) -{ - int result = VMCALL_SUCCESS; - u64 physaddr = 0; - - ISSUE_IO_VMCALL(VMCALL_GENERIC_SURRENDER_QUANTUM_FOREVER, physaddr, - result); - return result; -} - #define UIS_DAEMONIZE(nam) void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln); #define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__) -- cgit v1.2.3-59-g8ed1b From 682adec4d8c5f111b5a1cba6fb64b24607fe4362 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:27:39 +0530 Subject: staging: unisys: common-spar: include: channels: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 ++-- drivers/staging/unisys/common-spar/include/channels/vbuschannel.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index b1dd73d1f42c..806d5b3bca48 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -594,7 +594,7 @@ struct uiscmdrsp_scsitaskmgmt { * For windows guests, this is a pointer to a location that a waiting * thread is testing to see if the taskmgmt command has completed. * When the rsp is received by guest, the thread receiving the - * response uses this to notify the the thread waiting for taskmgmt + * response uses this to notify the thread waiting for taskmgmt * command completion. Its value is preserved by iopart & returned * as is in the task mgmt rsp. */ void *notifyresult; @@ -641,7 +641,7 @@ struct uiscmdrsp_vdiskmgmt { * For windows guests, this is a pointer to a location that a waiting * thread is testing to see if the taskmgmt command has completed. * When the rsp is received by guest, the thread receiving the - * response uses this to notify the the thread waiting for taskmgmt + * response uses this to notify the thread waiting for taskmgmt * command completion. Its value is preserved by iopart & returned * as is in the task mgmt rsp. */ void *notifyresult; diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 5b854243bcaf..420b7d859522 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -67,11 +67,11 @@ typedef struct _ULTRA_VBUS_HEADERINFO { u32 devInfoCount; /* num of items in DevInfo member */ /* (this is the allocated size) */ u32 chpInfoByteOffset; /* byte offset from beginning of this struct */ - /* to the the ChpInfo struct (below) */ + /* to the ChpInfo struct (below) */ u32 busInfoByteOffset; /* byte offset from beginning of this struct */ - /* to the the BusInfo struct (below) */ + /* to the BusInfo struct (below) */ u32 devInfoByteOffset; /* byte offset from beginning of this struct */ - /* to the the DevInfo array (below) */ + /* to the DevInfo array (below) */ u8 reserved[104]; } ULTRA_VBUS_HEADERINFO; -- cgit v1.2.3-59-g8ed1b From 9b0a6292df615a62269e6849a02332d85fd3b52a Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:27:50 +0530 Subject: staging: unisys: virtpci: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 73d4329f9a4a..f782916cbf2b 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -752,7 +752,7 @@ static int virtpci_device_resume(struct device *dev) /* For a child device just created on a client bus, fill in * information about the driver that is controlling this device into - * the the appropriate slot within the vbus channel of the bus + * the appropriate slot within the vbus channel of the bus * instance. */ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, -- cgit v1.2.3-59-g8ed1b From 7ba75289115b9059d261de297041f8b754899f22 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Sun, 5 Oct 2014 01:26:47 +0300 Subject: staging: rts5208: Delete braces are not necessary Fix checkpatch.pl warning: WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index bbbf7968a0b6..11610826acf1 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -584,9 +584,8 @@ static int start_stop_unit(struct scsi_cmnd *srb, struct rtsx_chip *chip) case MAKE_MEDIUM_READY: case LOAD_MEDIUM: - if (check_card_ready(chip, lun)) { + if (check_card_ready(chip, lun)) return TRANSPORT_GOOD; - } set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); TRACE_RET(chip, TRANSPORT_FAILED); -- cgit v1.2.3-59-g8ed1b From e3fe42b149c4c8ee13ade4112ed38e6d9a85c7b7 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Fri, 3 Oct 2014 09:16:53 +0530 Subject: Staging: iio: adc: Refine delay computation As per comment in function ad7280_delay, conversion delay may take up to 250us. We cannot rely on msleep for this because it may sleep longer than intended time for values less than 20ms, so use usleep_range instead. Problem detected using checkpatch.pl. Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7280a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index d215edf66af2..4d4870787eed 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -188,7 +188,7 @@ static void ad7280_delay(struct ad7280_state *st) if (st->readback_delay_us < 50) udelay(st->readback_delay_us); else - msleep(1); + usleep_range(250, 500); } static int __ad7280_read32(struct ad7280_state *st, unsigned *val) -- cgit v1.2.3-59-g8ed1b From 29aeb33aca91724a71289fbe8520d2689b5c9b71 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Mon, 6 Oct 2014 15:10:25 +0530 Subject: Staging: iio: adc: Fix line over 80 characters This patch fixes the following checkpatch.pl warning: WARNING: line over 80 characters Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7192.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index c110a255d4e8..f6526aa22e8a 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -223,7 +223,8 @@ static int ad7192_setup(struct ad7192_state *st, id &= AD7192_ID_MASK; if (id != st->devid) - dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n", id); + dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n", + id); switch (pdata->clock_source_sel) { case AD7192_CLK_EXT_MCLK1_2: -- cgit v1.2.3-59-g8ed1b From 31c4670ff3eda5036121811a18785c6e6a9a9e78 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Mon, 6 Oct 2014 15:11:06 +0530 Subject: Staging: iio: adc: Fixing line over 80 characters This patch fixes the following checkpatch.pl warning: WARNING: line over 80 charcaters Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7816.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 734a7e4886a0..48b1c3740030 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -152,7 +152,8 @@ static ssize_t ad7816_show_available_modes(struct device *dev, return sprintf(buf, "full\npower-save\n"); } -static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7816_show_available_modes, NULL, 0); +static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7816_show_available_modes, + NULL, 0); static ssize_t ad7816_show_channel(struct device *dev, struct device_attribute *attr, -- cgit v1.2.3-59-g8ed1b From 33341553562ce1293795b4bef0e305a96385a9a1 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Fri, 3 Oct 2014 15:02:48 +0300 Subject: staging: iio: light: Remove unnecessary line continuations This fixes the following checkpatch.pl warning: WARNING: Avoid unnecessary line continuations Signed-off-by: Roberta Dobrescu Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2x7x_core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c index e0d88fa2a5b5..b3d73a9a42ab 100644 --- a/drivers/staging/iio/light/tsl2x7x_core.c +++ b/drivers/staging/iio/light/tsl2x7x_core.c @@ -1573,8 +1573,7 @@ static struct attribute *tsl2x7x_ALS_device_attrs[] = { &dev_attr_power_state.attr, &dev_attr_in_illuminance0_calibscale_available.attr, &dev_attr_in_illuminance0_integration_time.attr, - &iio_const_attr_in_illuminance0_integration_time_available\ - .dev_attr.attr, + &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, &dev_attr_in_illuminance0_target_input.attr, &dev_attr_in_illuminance0_calibrate.attr, &dev_attr_in_illuminance0_lux_table.attr, @@ -1591,8 +1590,7 @@ static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = { &dev_attr_power_state.attr, &dev_attr_in_illuminance0_calibscale_available.attr, &dev_attr_in_illuminance0_integration_time.attr, - &iio_const_attr_in_illuminance0_integration_time_available\ - .dev_attr.attr, + &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, &dev_attr_in_illuminance0_target_input.attr, &dev_attr_in_illuminance0_calibrate.attr, &dev_attr_in_illuminance0_lux_table.attr, @@ -1611,8 +1609,7 @@ static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = { &dev_attr_power_state.attr, &dev_attr_in_illuminance0_calibscale_available.attr, &dev_attr_in_illuminance0_integration_time.attr, - &iio_const_attr_in_illuminance0_integration_time_available\ - .dev_attr.attr, + &iio_const_attr_in_illuminance0_integration_time_available.dev_attr.attr, &dev_attr_in_illuminance0_target_input.attr, &dev_attr_in_illuminance0_calibrate.attr, &dev_attr_in_illuminance0_lux_table.attr, -- cgit v1.2.3-59-g8ed1b From a724d08d01116a0019c84e3c54c8e5e37ce4dcbb Mon Sep 17 00:00:00 2001 From: Darshana Padmadas Date: Fri, 3 Oct 2014 19:27:29 +0530 Subject: Staging: iio: meter: Kconfig: Add module name information in Kconfig This patch updates Kconfig with paragraphs that describe config symbol fully. Found using checkpatch.pl. Signed-off-by: Darshana Padmadas Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/meter/Kconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig index e53274b64ae1..64cd3704ec6e 100644 --- a/drivers/staging/iio/meter/Kconfig +++ b/drivers/staging/iio/meter/Kconfig @@ -10,6 +10,9 @@ config ADE7753 Say yes here to build support for Analog Devices ADE7753 Single-Phase Multifunction Metering IC with di/dt Sensor Interface. + To compile this driver as a module, choose M here: the + module will be called ade7753. + config ADE7754 tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver" depends on SPI @@ -17,6 +20,9 @@ config ADE7754 Say yes here to build support for Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver. + To compile this driver as a module, choose M here: the + module will be called ade7754. + config ADE7758 tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver" depends on SPI @@ -26,6 +32,9 @@ config ADE7758 Say yes here to build support for Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC with Per Phase Information Driver. + To compile this driver as a module, choose M here: the + module will be called ade7758. + config ADE7759 tristate "Analog Devices ADE7759 Active Energy Metering IC Driver" depends on SPI @@ -33,6 +42,9 @@ config ADE7759 Say yes here to build support for Analog Devices ADE7758 Active Energy Metering IC with di/dt Sensor Interface. + To compile this driver as a module, choose M here: the + module will be called ade7759. + config ADE7854 tristate "Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC Driver" depends on SPI || I2C @@ -40,6 +52,9 @@ config ADE7854 Say yes here to build support for Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC Driver. + To compile this driver as a module, choose M here: the + module will be called ade7854. + config ADE7854_I2C tristate "support I2C bus connection" depends on ADE7854 && I2C -- cgit v1.2.3-59-g8ed1b From ff39a252cdeaec8dda1ed40a86b4a44173aad008 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Fri, 3 Oct 2014 23:34:50 +0300 Subject: staging: iio: Fix missing blank line warning Fixes "Missing a blank line after declarations" checkpatch.pl warning in Documentation/generic_buffer.c Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Documentation/generic_buffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c index 044ea196aa6f..31dfb21587ff 100644 --- a/drivers/staging/iio/Documentation/generic_buffer.c +++ b/drivers/staging/iio/Documentation/generic_buffer.c @@ -47,6 +47,7 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels) { int bytes = 0; int i = 0; + while (i < num_channels) { if (bytes % channels[i].bytes == 0) channels[i].location = bytes; @@ -74,12 +75,14 @@ void print2byte(int input, struct iio_channel_info *info) input = input >> info->shift; if (info->is_signed) { int16_t val = input; + val &= (1 << info->bits_used) - 1; val = (int16_t)(val << (16 - info->bits_used)) >> (16 - info->bits_used); printf("%05f ", ((float)val + info->offset)*info->scale); } else { uint16_t val = input; + val &= (1 << info->bits_used) - 1; printf("%05f ", ((float)val + info->offset)*info->scale); } @@ -97,6 +100,7 @@ void process_scan(char *data, int num_channels) { int k; + for (k = 0; k < num_channels; k++) switch (channels[k].bytes) { /* only a few cases implemented so far */ -- cgit v1.2.3-59-g8ed1b From 79bdd48a7f25132588e819d214a5ce9b9f1c266f Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Fri, 3 Oct 2014 23:35:54 +0300 Subject: staging: iio: Fix missing blank line warning Fixes "Missing a blank line after declarations" checkpatch.pl warning in Documentation/iio_utils.h Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Documentation/iio_utils.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h index 0973a092224a..568eff06f803 100644 --- a/drivers/staging/iio/Documentation/iio_utils.h +++ b/drivers/staging/iio/Documentation/iio_utils.h @@ -34,6 +34,7 @@ inline int iioutils_break_up_name(const char *full_name, char *current; char *w, *r; char *working; + current = strdup(full_name); working = strtok(current, "_\0"); w = working; @@ -335,6 +336,7 @@ inline int build_channel_array(const char *device_dir, if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"), "_en") == 0) { int current_enabled = 0; + current = &(*ci_array)[count++]; ret = asprintf(&filename, "%s/%s", scan_el_dir, ent->d_name); @@ -506,6 +508,7 @@ inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify) FILE *sysfsfp; int test; char *temp = malloc(strlen(basedir) + strlen(filename) + 2); + if (temp == NULL) return -ENOMEM; sprintf(temp, "%s/%s", basedir, filename); @@ -554,6 +557,7 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify) int ret = 0; FILE *sysfsfp; char *temp = malloc(strlen(basedir) + strlen(filename) + 2); + if (temp == NULL) { printf("Memory allocation failed\n"); return -ENOMEM; @@ -614,6 +618,7 @@ int read_sysfs_posint(char *filename, char *basedir) int ret; FILE *sysfsfp; char *temp = malloc(strlen(basedir) + strlen(filename) + 2); + if (temp == NULL) { printf("Memory allocation failed"); return -ENOMEM; @@ -636,6 +641,7 @@ int read_sysfs_float(char *filename, char *basedir, float *val) int ret = 0; FILE *sysfsfp; char *temp = malloc(strlen(basedir) + strlen(filename) + 2); + if (temp == NULL) { printf("Memory allocation failed"); return -ENOMEM; @@ -658,6 +664,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str) int ret = 0; FILE *sysfsfp; char *temp = malloc(strlen(basedir) + strlen(filename) + 2); + if (temp == NULL) { printf("Memory allocation failed"); return -ENOMEM; -- cgit v1.2.3-59-g8ed1b From 96cb9ab1892d28ec424ab2fde05791c80d4716ca Mon Sep 17 00:00:00 2001 From: Roxana Blaj Date: Sat, 4 Oct 2014 14:26:13 +0300 Subject: staging: iio: addac: fix line over 80 characters This fixes checkpatch.pl warning: WARNING: line over 80 characters Signed-off-by: Roxana Blaj Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/addac/adt7316.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec50bf34628d..ec40fbb698a6 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -30,6 +30,7 @@ extern const struct dev_pm_ops adt7316_pm_ops; #else #define ADT7316_PM_OPS NULL #endif -int adt7316_probe(struct device *dev, struct adt7316_bus *bus, const char *name); +int adt7316_probe(struct device *dev, struct adt7316_bus *bus, + const char *name); #endif -- cgit v1.2.3-59-g8ed1b From 237d0bf9b5e15c102c690e2a4e38bf1d592624cc Mon Sep 17 00:00:00 2001 From: Roxana Blaj Date: Tue, 7 Oct 2014 00:18:48 +0300 Subject: staging: iio: addac: annotate Kconfig entries with module name information This fixes the checkpatch.pl warning: WARNING: please write a paragraph that describes the config symbol fully Signed-off-by: Roxana Blaj Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/addac/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/iio/addac/Kconfig b/drivers/staging/iio/addac/Kconfig index e6795e0bed1d..0ed7e13e2283 100644 --- a/drivers/staging/iio/addac/Kconfig +++ b/drivers/staging/iio/addac/Kconfig @@ -10,6 +10,9 @@ config ADT7316 Say yes here to build support for Analog Devices ADT7316, ADT7317, ADT7318 and ADT7516, ADT7517, ADT7519 temperature sensors, ADC and DAC. + To compile this driver as a module, choose M here: the module will + be called adt7316. + config ADT7316_SPI tristate "support SPI bus connection" depends on SPI && ADT7316 @@ -18,6 +21,9 @@ config ADT7316_SPI Say yes here to build SPI bus support for Analog Devices ADT7316/7/8 and ADT7516/7/9. + To compile this driver as a module, choose M here: the module will + be called adt7316_spi. + config ADT7316_I2C tristate "support I2C bus connection" depends on I2C && ADT7316 @@ -25,4 +31,7 @@ config ADT7316_I2C Say yes here to build I2C bus support for Analog Devices ADT7316/7/8 and ADT7516/7/9. + To compile this driver as a module, choose M here: the module will + be called adt7316_i2c. + endmenu -- cgit v1.2.3-59-g8ed1b From 76ad1c42bbb58abdae86a13c86fc38714d6c7db2 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Sat, 4 Oct 2014 18:39:53 +0530 Subject: Staging: iio: gyro: Added description for config symbol. The following patch fixes the checkpatch.pl warning by adding description for a config symbol. WARNING: please write a paragraph that describes the config symbol fully. Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/gyro/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig index 88b199bb2926..f62f68fd6f3f 100644 --- a/drivers/staging/iio/gyro/Kconfig +++ b/drivers/staging/iio/gyro/Kconfig @@ -7,7 +7,10 @@ config ADIS16060 tristate "Analog Devices ADIS16060 Yaw Rate Gyroscope with SPI driver" depends on SPI help - Say yes here to build support for Analog Devices adis16060 wide bandwidth + Say Y (yes) here to build support for Analog Devices adis16060 wide bandwidth yaw rate gyroscope with SPI. + To compile this driver as a module, say M here: the module will be + called adis16060. If unsure, say N. + endmenu -- cgit v1.2.3-59-g8ed1b From 30439b29b8edaaecd611f96051dd292dd1474a5e Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sat, 4 Oct 2014 19:54:25 +0530 Subject: staging: iio: accel: Update Kconfig description with module name information This patch fixes checkpatch.pl warning. WARNING: please write a paragraph that describes the config symbol fully Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/Kconfig | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index ad45dfbdf417..07b7ffa00ab5 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -9,53 +9,71 @@ config ADIS16201 select IIO_ADIS_LIB select IIO_ADIS_LIB_BUFFER if IIO_BUFFER help - Say yes here to build support for Analog Devices adis16201 dual-axis + Say Y here to build support for Analog Devices adis16201 dual-axis digital inclinometer and accelerometer. + To compile this driver as a module, say M here: the module will + be called adis16201. + config ADIS16203 tristate "Analog Devices ADIS16203 Programmable 360 Degrees Inclinometer" depends on SPI select IIO_ADIS_LIB select IIO_ADIS_LIB_BUFFER if IIO_BUFFER help - Say yes here to build support for Analog Devices adis16203 Programmable + Say Y here to build support for Analog Devices adis16203 Programmable 360 Degrees Inclinometer. + To compile this driver as a module, say M here: the module will be + called adis16203. + config ADIS16204 tristate "Analog Devices ADIS16204 Programmable High-g Digital Impact Sensor and Recorder" depends on SPI select IIO_ADIS_LIB select IIO_ADIS_LIB_BUFFER if IIO_BUFFER help - Say yes here to build support for Analog Devices adis16204 Programmable + Say Y here to build support for Analog Devices adis16204 Programmable High-g Digital Impact Sensor and Recorder. + To compile this driver as a module, say M here: the module will be + called adis16204. + config ADIS16209 tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" depends on SPI select IIO_ADIS_LIB select IIO_ADIS_LIB_BUFFER if IIO_BUFFER help - Say yes here to build support for Analog Devices adis16209 dual-axis digital inclinometer + Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer and accelerometer. + To compile this driver as a module, say M here: the module will be + called adis16209. + config ADIS16220 tristate "Analog Devices ADIS16220 Programmable Digital Vibration Sensor" depends on SPI select IIO_ADIS_LIB help - Say yes here to build support for Analog Devices adis16220 programmable + Say Y here to build support for Analog Devices adis16220 programmable digital vibration sensor. + To compile this driver as a module, say M here: the module will be + called adis16220. + config ADIS16240 tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder" depends on SPI select IIO_ADIS_LIB select IIO_ADIS_LIB_BUFFER if IIO_BUFFER help - Say yes here to build support for Analog Devices adis16240 programmable + Say Y here to build support for Analog Devices adis16240 programmable impact Sensor and recorder. + To compile this driver as a module, say M here: the module will be + called adis16240. + config LIS3L02DQ tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver" depends on SPI @@ -63,16 +81,21 @@ config LIS3L02DQ depends on !IIO_BUFFER || IIO_KFIFO_BUF depends on GPIOLIB help - Say yes here to build SPI support for the ST microelectronics + Say Y here to build SPI support for the ST microelectronics accelerometer. The driver supplies direct access via sysfs files and an event interface via a character device. + To compile this driver as a module, say M here: the module will be + called lis3l02dq. + config SCA3000 depends on IIO_BUFFER depends on SPI tristate "VTI SCA3000 series accelerometers" help - Say yes here to build support for the VTI SCA3000 series of SPI + Say Y here to build support for the VTI SCA3000 series of SPI accelerometers. These devices use a hardware ring buffer. + To compile this driver as a module, say M here: the module will be + called sca3000. endmenu -- cgit v1.2.3-59-g8ed1b From d1e5041345d3976af580d9ac9728e1819b458e3c Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 17:03:31 +0530 Subject: Staging: iio: Documentation: Added missing blank line after declarations. The following patch fixes the following checkpatch.pl warning by adding a blank line after declarations. WARNING: Missing blank line after declarations. Signed-off-by: Heena Sirwani Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Documentation/lsiio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c index 24ae9694eb41..a82c93da10bd 100644 --- a/drivers/staging/iio/Documentation/lsiio.c +++ b/drivers/staging/iio/Documentation/lsiio.c @@ -46,6 +46,7 @@ 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; @@ -107,6 +108,7 @@ static void dump_devices(void) 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); @@ -118,6 +120,7 @@ static void dump_devices(void) 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); -- cgit v1.2.3-59-g8ed1b From edead9b1f9fa1e28e493ccaa831d0ac7aa0de74b Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 17:04:10 +0530 Subject: Staging: iio: Documentation: Simplify error handling. This also has the nice effect of removing of a temporary variable from stack and fixes the following checkpatch.pl warning: WARNING: Missing blank line after declarations. Signed-off-by: Heena Sirwani Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Documentation/lsiio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c index a82c93da10bd..3b436f13b872 100644 --- a/drivers/staging/iio/Documentation/lsiio.c +++ b/drivers/staging/iio/Documentation/lsiio.c @@ -69,11 +69,8 @@ static int dump_one_device(const char *dev_dir_name) 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; - } + if (verblevel >= VERBLEVEL_SENSORS) + return dump_channels(dev_dir_name); return 0; } -- cgit v1.2.3-59-g8ed1b From d0e68ce1999e34a29d6b71ced4088d0f916878d4 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 17:04:43 +0530 Subject: Staging: iio: Documentation: Added check for sscanf return value. The following patch fixes the following checkpatch.pl warning by adding a check for sscanf return value. WARNING: unchecked sscanf return value. Signed-off-by: Heena Sirwani Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Documentation/lsiio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c index 3b436f13b872..98a0de098130 100644 --- a/drivers/staging/iio/Documentation/lsiio.c +++ b/drivers/staging/iio/Documentation/lsiio.c @@ -63,9 +63,12 @@ static int dump_one_device(const char *dev_dir_name) { char name[IIO_MAX_NAME_LENGTH]; int dev_idx; + int retval; - sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device), + retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device), "%i", &dev_idx); + if (retval != 1) + return -EINVAL; read_sysfs_string("name", dev_dir_name, name); printf("Device %03d: %s\n", dev_idx, name); @@ -78,9 +81,12 @@ static int dump_one_trigger(const char *dev_dir_name) { char name[IIO_MAX_NAME_LENGTH]; int dev_idx; + int retval; - sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger), + retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger), "%i", &dev_idx); + if (retval != 1) + return -EINVAL; read_sysfs_string("name", dev_dir_name, name); printf("Trigger %03d: %s\n", dev_idx, name); return 0; -- cgit v1.2.3-59-g8ed1b From 5c0ec98eba9537cf754b5cb2025e16fb71088cec Mon Sep 17 00:00:00 2001 From: Darshana Padmadas Date: Sat, 4 Oct 2014 21:55:26 +0530 Subject: Staging: iio: trigger: Add module name information in Kconfig This patch updates Kconfig with paragraphs that describe config symbol fully. Found using checkpatch.pl. Signed-off-by: Darshana Padmadas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/trigger/Kconfig b/drivers/staging/iio/trigger/Kconfig index 2fd18c60323d..710a2f3e787e 100644 --- a/drivers/staging/iio/trigger/Kconfig +++ b/drivers/staging/iio/trigger/Kconfig @@ -1,4 +1,4 @@ -# + # # Industrial I/O standalone triggers # comment "Triggers - standalone" @@ -12,6 +12,9 @@ config IIO_PERIODIC_RTC_TRIGGER Provides support for using periodic capable real time clocks as IIO triggers. + To compile this driver as a module, choose M here: the + module will be called iio-trig-periodic-rtc. + config IIO_BFIN_TMR_TRIGGER tristate "Blackfin TIMER trigger" depends on BLACKFIN -- cgit v1.2.3-59-g8ed1b From a2bc425bb372caf4d471309353889c6228120287 Mon Sep 17 00:00:00 2001 From: Darshana Padmadas Date: Sat, 4 Oct 2014 21:55:27 +0530 Subject: Staging: iio: trigger: Break line over 80 characters This patch breaks a line that is over 80 characters as reported by checkpatch.pl Signed-off-by: Darshana Padmadas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c index 8f0a2ffa7150..d1df701909b3 100644 --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c @@ -72,7 +72,8 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev, if (val > 0) { ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val); if (ret == 0 && trig_info->state && trig_info->frequency == 0) - ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 1); + ret = rtc_irq_set_state(trig_info->rtc, + &trig_info->task, 1); } else if (val == 0) { ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0); } else -- cgit v1.2.3-59-g8ed1b From 18434f3b41e60f5ca80b1d55a793ad85134181a6 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Fri, 3 Oct 2014 09:27:18 +0530 Subject: Staging: lustre: lnet: Declare ping_srv_workitems static This patch makes ping_srv_workitems static as it is used only in the file ping_test.c This problem is detected by sparse. Signed-off-by: Vaishali Thakkar Acked-by: Daniel Baluta Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/ping_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index 750cac4afbb2..d8c0df6e6852 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -44,7 +44,7 @@ #define LST_PING_TEST_MAGIC 0xbabeface -int ping_srv_workitems = SFW_TEST_WI_MAX; +static int ping_srv_workitems = SFW_TEST_WI_MAX; module_param(ping_srv_workitems, int, 0644); MODULE_PARM_DESC(ping_srv_workitems, "# PING server workitems"); -- cgit v1.2.3-59-g8ed1b From ec17e8113b5a17bc3326de7c50ea7f42c6272b48 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Fri, 3 Oct 2014 10:44:25 +0530 Subject: Staging: lustre: lnet: selftest: Made a function static. The following patch makes a function static as it is not used by other files. The patch fixes the warning: WARNING: symbol 'brw_check_bulk' was not declared. Should it be static? The above warning was reported by sparse. Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index a94f336d578c..bf6f125064eb 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -233,7 +233,7 @@ brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic) } } -int +static int brw_check_bulk(srpc_bulk_t *bk, int pattern, __u64 magic) { int i; -- cgit v1.2.3-59-g8ed1b From 6888871cb05cd4d182bf504ed3f804a9bba20ce8 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Fri, 3 Oct 2014 10:44:58 +0530 Subject: Staging: lustre: lnet: selftest: Made a function static. The following patch makes a function static as it is not used by other files. The patch fixes the warning: WARNING: symbol 'brw_server_rpc_done' was not declared. Should it be static? The above warning was reported by sparse. Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index bf6f125064eb..9e04695bfdbc 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -358,7 +358,7 @@ out: return; } -void +static void brw_server_rpc_done(srpc_server_rpc_t *rpc) { srpc_bulk_t *blk = rpc->srpc_bulk; -- cgit v1.2.3-59-g8ed1b From 0c05ef92f64e6e16095e0cf8ae3ec3529624621f Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Fri, 3 Oct 2014 10:45:38 +0530 Subject: Staging: lustre: lnet: selftest: Made a function static. The following patch makes a function static as it is not used by other files. The patch fixes the warning: WARNING: symbol 'brw_bulk_ready' was not declared. Should it be static? The above warning was reported by sparse. Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 9e04695bfdbc..d7b26b0a57e2 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -378,7 +378,7 @@ brw_server_rpc_done(srpc_server_rpc_t *rpc) sfw_free_pages(rpc); } -int +static int brw_bulk_ready(srpc_server_rpc_t *rpc, int status) { __u64 magic = BRW_MAGIC; -- cgit v1.2.3-59-g8ed1b From 4a1b86dc6c3e0678cbad701599b161b3d9f9ce42 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Fri, 3 Oct 2014 10:46:09 +0530 Subject: Staging: lustre: lnet: selftest: Made a function static. The following patch makes a function static as it is not used by other files. The patch fixes the warning: WARNING: symbol 'brw_server_handle' was not declared. Should it be static? The above warning was reported by sparse. Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index d7b26b0a57e2..463da076fa70 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -414,7 +414,7 @@ brw_bulk_ready(srpc_server_rpc_t *rpc, int status) return 0; } -int +static int brw_server_handle(struct srpc_server_rpc *rpc) { struct srpc_service *sv = rpc->srpc_scd->scd_svc; -- cgit v1.2.3-59-g8ed1b From 12afe4935a35c2bdd71da59e86afa6e9d5fd6562 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Sun, 5 Oct 2014 17:28:06 +0530 Subject: Staging: lustre: Replace non-standard spin-lock's macro This patch replaces non-standard spin lock macro with standard linux function. This is done using Coccinelle and semantic patch used is as follows: @@ expression x; @@ - TREE_READ_LOCK_IRQ(x) + spin_lock_irq(&x->tree_lock) @@ expression x; @@ - TREE_READ_UNLOCK_IRQ(x) + spin_unlock_irq(&x->tree_lock) Signed-off-by: Vaishali Thakkar Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index b0bb7095dde5..662bdf04a451 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -275,14 +275,14 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 *hash, struct page *page; int found; - TREE_READ_LOCK_IRQ(mapping); + spin_lock_irq(&mapping->tree_lock); found = radix_tree_gang_lookup(&mapping->page_tree, (void **)&page, offset, 1); if (found > 0) { struct lu_dirpage *dp; page_cache_get(page); - TREE_READ_UNLOCK_IRQ(mapping); + spin_unlock_irq(&mapping->tree_lock); /* * In contrast to find_lock_page() we are sure that directory * page cannot be truncated (while DLM lock is held) and, @@ -326,7 +326,7 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 *hash, } } else { - TREE_READ_UNLOCK_IRQ(mapping); + spin_unlock_irq(&mapping->tree_lock); page = NULL; } return page; -- cgit v1.2.3-59-g8ed1b From c4226c547f3c1e69989f843cf8d3d7b2f295ad3f Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Sun, 5 Oct 2014 17:28:12 +0530 Subject: Staging: lustre: Replace non-standard spinlock macro definations This patch replaces non-standard spin lock macro with standard linux function. This is done using Coccinelle and semantic patch used is as follows: @@ expression x; @@ - TREE_READ_LOCK_IRQ(x) + spin_lock_irq(&(x)->tree_lock) @@ expression x; @@ - TREE_READ_UNLOCK_IRQ(x) + spin_unlock_irq(&(x)->tree_lock) Also semantic patch result is modified by droping ->, inner & and adding . for simplification of code. Signed-off-by: Vaishali Thakkar Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index a8bcc51057f1..d614752c4c20 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1880,8 +1880,8 @@ void ll_delete_inode(struct inode *inode) /* Workaround for LU-118 */ if (inode->i_data.nrpages) { - TREE_READ_LOCK_IRQ(&inode->i_data); - TREE_READ_UNLOCK_IRQ(&inode->i_data); + spin_lock_irq(&inode->i_data.tree_lock); + spin_unlock_irq(&inode->i_data.tree_lock); LASSERTF(inode->i_data.nrpages == 0, "inode=%lu/%u(%p) nrpages=%lu, see " "http://jira.whamcloud.com/browse/LU-118\n", -- cgit v1.2.3-59-g8ed1b From 0f320bd82d243713fac7274f2cbe3d2ab7dba40d Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Sun, 5 Oct 2014 17:28:18 +0530 Subject: Staging: lustre: Remove non-standard spinlock macro definitions This patch removes non-standard spinlock's macros as they are no longer used by this driver. Signed-off-by: Vaishali Thakkar Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index e94ab343ab25..e03775606712 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -91,8 +91,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, # define inode_dio_read(i) atomic_inc(&(i)->i_dio_count) /* inode_dio_done(i) use as-is for read unlock */ -#define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock) -#define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock) #ifndef FS_HAS_FIEMAP #define FS_HAS_FIEMAP (0) -- cgit v1.2.3-59-g8ed1b From fa4d19c4effee121198dc33d419c00a375e65b27 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:27:10 +0530 Subject: staging: lustre: lustre: ptlrpc: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 20341b27a06a..e8d00408117a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -448,7 +448,7 @@ struct timeout_item* ptlrpc_new_timeout(int time, enum timeout_event event, } /** - * Register timeout event on the the pinger thread. + * Register timeout event on the pinger thread. * Note: the timeout list is an sorted list with increased timeout value. */ static struct timeout_item* -- cgit v1.2.3-59-g8ed1b From c2487192be5a8fe87a5be5fd92e4bc56c9f0da4d Mon Sep 17 00:00:00 2001 From: Kumari Radha Date: Sun, 5 Oct 2014 20:22:54 +0530 Subject: staging: lustre: lustre: obdclass: Added missing line after declaration Added missing line after declaration fixing the following checkpatch.pl warning in dt_object.c: WARNING: Missing a blank line after declarations Signed-off-by: Kumari Radha Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/dt_object.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 52256c26bf07..909f542f8b86 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -950,8 +950,8 @@ int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, { struct dt_device *dt = data; struct obd_statfs osfs; - int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { *eof = 1; rc = snprintf(page, count, "%u\n", @@ -967,8 +967,8 @@ int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off, { struct dt_device *dt = data; struct obd_statfs osfs; - int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_blocks; @@ -989,8 +989,8 @@ int lprocfs_dt_rd_kbytesfree(char *page, char **start, off_t off, { struct dt_device *dt = data; struct obd_statfs osfs; - int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bfree; @@ -1011,8 +1011,8 @@ int lprocfs_dt_rd_kbytesavail(char *page, char **start, off_t off, { struct dt_device *dt = data; struct obd_statfs osfs; - int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bavail; @@ -1033,8 +1033,8 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off, { struct dt_device *dt = data; struct obd_statfs osfs; - int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { *eof = 1; rc = snprintf(page, count, "%llu\n", osfs.os_files); @@ -1049,8 +1049,8 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, { struct dt_device *dt = data; struct obd_statfs osfs; - int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { *eof = 1; rc = snprintf(page, count, "%llu\n", osfs.os_ffree); -- cgit v1.2.3-59-g8ed1b From f09b372b154391b70e571f4404ec45c014a01594 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:27:00 +0530 Subject: staging: lustre: lustre: llite: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index c99b74117152..f1f75c7edee0 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -368,7 +368,7 @@ int ll_file_release(struct inode *inode, struct file *file) fd = LUSTRE_FPRIVATE(file); LASSERT(fd != NULL); - /* The last ref on @file, maybe not the the owner pid of statahead. + /* The last ref on @file, maybe not the owner pid of statahead. * Different processes can open the same dir, "ll_opendir_key" means: * it is me that should stop the statahead thread. */ if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd && -- cgit v1.2.3-59-g8ed1b From 5ed57d6dc6aab12515a8afc62e0d2cd0ae95c3f8 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 17:26:14 +0530 Subject: Staging: lustre: lustre: lmv: Removed variable that is not very useful. The following patch removes a variable that is not very useful using coccinelle. The semantic patch used was: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1a5821289c39..9543c15f990e 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -2310,7 +2310,6 @@ retry: static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { struct lmv_obd *lmv = &obd->u.lmv; - int rc = 0; switch (stage) { case OBD_CLEANUP_EARLY: @@ -2324,7 +2323,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) default: break; } - return rc; + return 0; } static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, -- cgit v1.2.3-59-g8ed1b From 8482727897ff03f16fae8694c4496bd079a65feb Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 17:26:47 +0530 Subject: Staging: lustre: lustre: mgc: Remove variable that is not very useful. The following patch removes a variable that is not very useful using coccinelle. The semantic patch used was: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mgc/mgc_request.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index bc263adf09d4..bbef5c96d605 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -510,8 +510,6 @@ static void do_requeue(struct config_llog_data *cld) static int mgc_requeue_thread(void *data) { - int rc = 0; - CDEBUG(D_MGC, "Starting requeue thread\n"); /* Keep trying failed locks periodically */ @@ -592,7 +590,7 @@ static int mgc_requeue_thread(void *data) complete(&rq_exit); CDEBUG(D_MGC, "Ending requeue thread\n"); - return rc; + return 0; } /* Add a cld to the list to requeue. Start the requeue thread if needed. @@ -1055,8 +1053,6 @@ static int mgc_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) { - int rc = 0; - LASSERT(imp->imp_obd == obd); CDEBUG(D_MGC, "import event %#x\n", event); @@ -1090,7 +1086,7 @@ static int mgc_import_event(struct obd_device *obd, CERROR("Unknown import event %#x\n", event); LBUG(); } - return rc; + return 0; } enum { -- cgit v1.2.3-59-g8ed1b From e588f1bf8e8e9ec43369a35c11d4d8c8a846a4a7 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 17:27:18 +0530 Subject: Staging: lustre: lustre: lov: Remove variable that is not very useful. The following patch removes a variable that is not very useful using coccinelle. The semantic patch used was: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_obd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 94dfd64bd283..71ad166e2cbc 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -847,7 +847,6 @@ out: static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { - int rc = 0; struct lov_obd *lov = &obd->u.lov; switch (stage) { @@ -865,7 +864,7 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) break; } - return rc; + return 0; } static int lov_cleanup(struct obd_device *obd) -- cgit v1.2.3-59-g8ed1b From 114114a2a340e999277ce3fa833b4546f4e9b853 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 17:27:54 +0530 Subject: Staging: lustre: lustre: osc: Remove variable that is not very useful. The following patch removes a variable that is not very useful using coccinelle. The semantic patch used was: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_cache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 7734d666b7a1..806fd397b721 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -539,7 +539,6 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; - int rc = 0; LASSERT(atomic_read(&ext->oe_users) > 0); LASSERT(sanity_check(ext) == 0); @@ -571,7 +570,7 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) osc_io_unplug_async(env, osc_cli(obj), obj); } osc_extent_put(env, ext); - return rc; + return 0; } static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) -- cgit v1.2.3-59-g8ed1b From 41f8d410aee43a00b2e5e1c3b916049fad0f8643 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 17:28:30 +0530 Subject: Staging: lustre: lustre: osc: Remove variable that is not very useful. The following patch removes a variable that is not very useful using coccinelle. The semantic patch used was: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_request.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 44657a06b8a5..ca16c081e9df 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -3217,8 +3217,6 @@ out_ptlrpcd: static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { - int rc = 0; - switch (stage) { case OBD_CLEANUP_EARLY: { struct obd_import *imp; @@ -3253,7 +3251,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) break; } } - return rc; + return 0; } int osc_cleanup(struct obd_device *obd) -- cgit v1.2.3-59-g8ed1b From 882e7e215db8934c1c1f2ff4f71c19d2275596b2 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 17:29:11 +0530 Subject: Staging: lustre: lustre: osc: Changed the return code of a function from int to void. The following patch changes the return code of a function from int to void as the return value was not used by the callers. Signed-off-by: Heena Sirwani Reviewed-by: Octavian Purdila Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_cache.c | 3 +-- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 806fd397b721..ec04935c65ea 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -536,7 +536,7 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, /** * Drop user count of osc_extent, and unplug IO asynchronously. */ -int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) +void osc_extent_release(const struct lu_env *env, struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; @@ -570,7 +570,6 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) osc_io_unplug_async(env, osc_cli(obj), obj); } osc_extent_put(env, ext); - return 0; } static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index ebbd95c0cea8..365b2787b3c8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -678,7 +678,7 @@ struct osc_extent { int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, int sent, int rc); -int osc_extent_release(const struct lu_env *env, struct osc_extent *ext); +void osc_extent_release(const struct lu_env *env, struct osc_extent *ext); /** @} osc */ -- cgit v1.2.3-59-g8ed1b From cf29a7b6eae8f74a2bb39fe01ee8aed9a3a5f665 Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Wed, 8 Oct 2014 00:42:05 +0530 Subject: Staging: lustre: Fix checkpatch warning: Missing blank line The following checkpatch warning was fixed : WARNING: Missing a blank line after declarations Signed-off-by: Tina Johnson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d614752c4c20..09b90f6a41c8 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -712,6 +712,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur) list_for_each(tmp, &dentry->d_subdirs) { struct dentry *d = list_entry(tmp, struct dentry, d_u.d_child); + lustre_dump_dentry(d, recur - 1); } } @@ -1152,6 +1153,7 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) lock_res_and_lock(lock); if (lock->l_resource->lr_lvb_inode) { struct ll_inode_info *lli; + lli = ll_i2info(lock->l_resource->lr_lvb_inode); if (lli->lli_inode_magic == LLI_INODE_MAGIC) { inode = igrab(lock->l_resource->lr_lvb_inode); @@ -1850,6 +1852,7 @@ void ll_read_inode2(struct inode *inode, void *opaque) if (S_ISREG(inode->i_mode)) { struct ll_sb_info *sbi = ll_i2sbi(inode); + inode->i_op = &ll_file_inode_operations; inode->i_fop = sbi->ll_fop; inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops; -- cgit v1.2.3-59-g8ed1b From 566be54df121cf36b99d01515ab267424117c89c Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Wed, 8 Oct 2014 00:42:06 +0530 Subject: Staging: lustre: Fix checkpatch warning: Unnecessary braces The following checkpatch warning was fixed : WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Tina Johnson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 09b90f6a41c8..3c086b4d0ea5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1122,9 +1122,8 @@ void ll_put_super(struct super_block *sb) } next = 0; - while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) { + while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) class_manual_cleanup(obd); - } if (sbi->ll_flags & LL_SBI_VERBOSE) LCONSOLE_WARN("Unmounted %s\n", profilenm ? profilenm : ""); @@ -1734,11 +1733,10 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) if (body->valid & OBD_MD_FLTYPE) inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT); LASSERT(inode->i_mode != 0); - if (S_ISREG(inode->i_mode)) { + if (S_ISREG(inode->i_mode)) inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS + 1, LL_MAX_BLKSIZE_BITS); - } else { + else inode->i_blkbits = inode->i_sb->s_blocksize_bits; - } if (body->valid & OBD_MD_FLUID) inode->i_uid = make_kuid(&init_user_ns, body->uid); if (body->valid & OBD_MD_FLGID) -- cgit v1.2.3-59-g8ed1b From f44b902adf7c9f0e794540e3537fc328dae17298 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:27:30 +0530 Subject: staging: rtl8712: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index d9c1561e3272..5aae4cce8477 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -527,7 +527,7 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); psecnetwork->IELength = 0; - /* If the the driver wants to use the bssid to create the connection. + /* If the driver wants to use the bssid to create the connection. * If not, we copy the connecting AP's MAC address to it so that * the driver just has the bssid information for PMKIDList searching. */ -- cgit v1.2.3-59-g8ed1b From 14ad732c2d19858cc43b4b7421d63b82575bc84e Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Fri, 3 Oct 2014 19:33:39 +0530 Subject: staging: rtl8712: Fixed else not required after return WARNING: else is generally not required after return checkpatch.pl warning in osdep_service.h Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/osdep_service.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index d7a357b8d2d1..5153ad9c2c75 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -88,17 +88,13 @@ static inline u32 _down_sema(struct semaphore *sema) { if (down_interruptible(sema)) return _FAIL; - else - return _SUCCESS; + return _SUCCESS; } static inline u32 end_of_queue_search(struct list_head *head, struct list_head *plist) { - if (head == plist) - return true; - else - return false; + return (head == plist); } static inline void sleep_schedulable(int ms) -- cgit v1.2.3-59-g8ed1b From 366ba427032eaefdec9d3fd318f23eea2b26ead6 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 14:23:18 +0530 Subject: staging: rtl8712: Delete explicit comparison with false and NULL This patch delete explicit comparison to false and NULL in files of rtl8712. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/recv_linux.c | 2 +- drivers/staging/rtl8712/rtl871x_io.c | 2 +- drivers/staging/rtl8712/rtl871x_ioctl_set.c | 20 +++++++++----------- drivers/staging/rtl8712/rtl871x_mp.c | 4 ++-- drivers/staging/rtl8712/usb_intf.c | 10 +++++----- drivers/staging/rtl8712/usb_ops_linux.c | 6 +++--- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 495ee1205e02..0631f3638257 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -146,7 +146,7 @@ void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf) dev_kfree_skb_any(precvbuf->pskb); precvbuf->pskb = NULL; precvbuf->reuse = false; - if (precvbuf->irp_pending == false) + if (!precvbuf->irp_pending) r8712_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c index d7b63aedead7..3a0236606396 100644 --- a/drivers/staging/rtl8712/rtl871x_io.c +++ b/drivers/staging/rtl8712/rtl871x_io.c @@ -93,7 +93,7 @@ static uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl) pintfhdl->intf_option = 0; pintfhdl->adapter = dev; pintfhdl->intf_dev = (u8 *)&(adapter->dvobjpriv); - if (_init_intf_hdl(adapter, pintfhdl) == false) + if (!_init_intf_hdl(adapter, pintfhdl)) goto register_intf_hdl_fail; return _SUCCESS; register_intf_hdl_fail: diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index 9d47eb472837..a240b6389683 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -77,7 +77,7 @@ static u8 do_join(struct _adapter *padapter) /* when set_ssid/set_bssid for do_join(), but scanning queue * is empty we try to issue sitesurvey firstly */ - if (pmlmepriv->sitesurveyctrl.traffic_busy == false) + if (!pmlmepriv->sitesurveyctrl.traffic_busy) r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid); return true; } else { @@ -143,8 +143,7 @@ u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid) _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { - if (check_fwstate(pmlmepriv, - WIFI_STATION_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) goto _Abort_Set_BSSID; /* driver is in * WIFI_ADHOC_MASTER_STATE */ } else { @@ -177,7 +176,7 @@ void r8712_set_802_11_ssid(struct _adapter *padapter, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; - if (padapter->hw_init_completed == false) + if (!padapter->hw_init_completed) return; spin_lock_irqsave(&pmlmepriv->lock, irqL); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { @@ -188,10 +187,9 @@ void r8712_set_802_11_ssid(struct _adapter *padapter, if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { - if ((check_fwstate(pmlmepriv, - WIFI_STATION_STATE) == false)) { - if (r8712_is_same_ibss(padapter, - pnetwork) == false) { + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (!r8712_is_same_ibss(padapter, + pnetwork)) { /* if in WIFI_ADHOC_MASTER_STATE or * WIFI_ADHOC_STATE, create bss or * rejoin again @@ -227,7 +225,7 @@ void r8712_set_802_11_ssid(struct _adapter *padapter, } if (padapter->securitypriv.btkip_countermeasure == true) goto _Abort_Set_SSID; - if (validate_ssid(ssid) == false) + if (!validate_ssid(ssid)) goto _Abort_Set_SSID; memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); pmlmepriv->assoc_by_bssid = false; @@ -308,10 +306,10 @@ u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter) unsigned long irqL; u8 ret = true; - if (padapter == NULL) + if (!padapter) return false; pmlmepriv = &padapter->mlmepriv; - if (padapter->hw_init_completed == false) + if (!padapter->hw_init_completed) return false; spin_lock_irqsave(&pmlmepriv->lock, irqL); if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index 2ec660ad78af..3d913b9701bb 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -56,7 +56,7 @@ static int init_mp_priv(struct mp_priv *pmp_priv) pmp_priv->pallocated_mp_xmitframe_buf = kmalloc(NR_MP_XMITFRAME * sizeof(struct mp_xmit_frame) + 4, GFP_ATOMIC); - if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) { + if (!pmp_priv->pallocated_mp_xmitframe_buf) { res = _FAIL; goto _exit_init_mp_priv; } @@ -173,7 +173,7 @@ u8 r8712_bb_reg_write(struct _adapter *pAdapter, u16 offset, u32 value) oldValue = r8712_bb_reg_read(pAdapter, iocmd.value); oldValue &= (0xFFFFFFFF >> ((4 - shift) * 8)); value = oldValue | (newValue << (shift * 8)); - if (fw_iocmd_write(pAdapter, iocmd, value) == false) + if (!fw_iocmd_write(pAdapter, iocmd, value)) return false; iocmd.value += 4; oldValue = r8712_bb_reg_read(pAdapter, iocmd.value); diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index a3d733b145eb..da3856dda728 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -292,13 +292,13 @@ static void r8712_usb_dvobj_deinit(struct _adapter *padapter) void rtl871x_intf_stop(struct _adapter *padapter) { /*disable_hw_interrupt*/ - if (padapter->bSurpriseRemoved == false) { + if (!padapter->bSurpriseRemoved) { /*device still exists, so driver can do i/o operation * TODO: */ } /* cancel in irp */ - if (padapter->dvobjpriv.inirp_deinit != NULL) + if (padapter->dvobjpriv.inirp_deinit) padapter->dvobjpriv.inirp_deinit(padapter); /* cancel out irp */ r8712_usb_write_port_cancel(padapter); @@ -318,7 +318,7 @@ void r871x_dev_unload(struct _adapter *padapter) r8712_stop_drv_threads(padapter); /*s5.*/ - if (padapter->bSurpriseRemoved == false) { + if (!padapter->bSurpriseRemoved) { padapter->hw_init_completed = false; rtl8712_hal_deinit(padapter); } @@ -402,7 +402,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, /* step 3. * initialize the dvobj_priv */ - if (padapter->dvobj_init == NULL) + if (!padapter->dvobj_init) goto error; else { status = padapter->dvobj_init(padapter); @@ -568,7 +568,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) && (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00)) || - (AutoloadFail == false)) { + (!AutoloadFail)) { mac[0] = 0x00; mac[1] = 0xe0; mac[2] = 0x4c; diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index e89d2b07fcb9..e0a155a4fac1 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -267,7 +267,7 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) return _FAIL; - if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) { + if (!precvbuf->reuse == false || !precvbuf->pskb) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); if (NULL != precvbuf->pskb) precvbuf->reuse = true; @@ -275,10 +275,10 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) if (precvbuf != NULL) { r8712_init_recvbuf(adapter, precvbuf); /* re-assign for linux based on skb */ - if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) { + if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); - if (precvbuf->pskb == NULL) + if (!precvbuf->pskb) return _FAIL; tmpaddr = (addr_t)precvbuf->pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); -- cgit v1.2.3-59-g8ed1b From a724e4e3b2bfdd3c1988820ff44d9a514591ebd4 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Sun, 5 Oct 2014 01:41:58 +0300 Subject: staging: rtl8723au: include: fix space prohibited before Fix checkpatch.pl issues with space prohibited before semicolon in Hal8723UHWImg_CE.h Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/Hal8723UHWImg_CE.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/Hal8723UHWImg_CE.h b/drivers/staging/rtl8723au/include/Hal8723UHWImg_CE.h index bbeaab48057a..c834b3a738d7 100644 --- a/drivers/staging/rtl8723au/include/Hal8723UHWImg_CE.h +++ b/drivers/staging/rtl8723au/include/Hal8723UHWImg_CE.h @@ -19,7 +19,7 @@ extern u8 Rtl8723UFwUMCBCutImgArrayWithoutBT[Rtl8723UUMCBCutImgArrayWithoutBTLen extern const u8 Rtl8723SFwUMCBCutMPImgArray[Rtl8723SUMCBCutMPImgArrayLength]; #define Rtl8723EBTImgArrayLength 15276 -extern u8 Rtl8723EFwBTImgArray[Rtl8723EBTImgArrayLength] ; +extern u8 Rtl8723EFwBTImgArray[Rtl8723EBTImgArrayLength]; #define Rtl8723UPHY_REG_Array_PGLength 336 extern u32 Rtl8723UPHY_REG_Array_PG[Rtl8723UPHY_REG_Array_PGLength]; -- cgit v1.2.3-59-g8ed1b From 15c389c14ce638ae3e93c26182218fb7ad6b0b4d Mon Sep 17 00:00:00 2001 From: Mahati Chamarthy Date: Sun, 5 Oct 2014 13:11:39 +0530 Subject: Staging: rtl8723au: include: Remove unnecessary macro This patch removes a macro which is not used anywhere except in the header file. Existing usage in the header file is replaced with the actual value. Signed-off-by: Mahati Chamarthy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm_debug.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm_debug.h b/drivers/staging/rtl8723au/include/odm_debug.h index 4d935a33ccb3..8509a04b6a52 100644 --- a/drivers/staging/rtl8723au/include/odm_debug.h +++ b/drivers/staging/rtl8723au/include/odm_debug.h @@ -91,8 +91,7 @@ #define ODM_COMP_INIT BIT(31) /*------------------------Export Macro Definition---------------------------*/ - #define DbgPrint printk - #define RT_PRINTK(fmt, args...) DbgPrint("%s(): " fmt, __func__, ## args); + #define RT_PRINTK(fmt, args...) printk("%s(): " fmt, __func__, ## args); #ifndef ASSERT #define ASSERT(expr) @@ -101,7 +100,7 @@ #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \ { \ - DbgPrint("[ODM-8723A] "); \ + printk("[ODM-8723A] "); \ RT_PRINTK fmt; \ } @@ -113,25 +112,25 @@ #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ if(!(expr)) { \ - DbgPrint("Assertion failed! %s at ......\n", #expr); \ - DbgPrint(" ......%s,%s,line=%d\n", __FILE__, __func__, __LINE__);\ + printk("Assertion failed! %s at ......\n", #expr); \ + printk(" ......%s,%s,line=%d\n", __FILE__, __func__, __LINE__);\ RT_PRINTK fmt; \ ASSERT(false); \ } -#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } -#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } -#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } +#define ODM_dbg_enter() { printk("==> %s\n", __func__); } +#define ODM_dbg_exit() { printk("<== %s\n", __func__); } +#define ODM_dbg_trace(str) { printk("%s:%s\n", __func__, str); } #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel){ \ int __i; \ u8 * __ptr = (u8 *)ptr; \ - DbgPrint("[ODM] "); \ - DbgPrint(title_str); \ - DbgPrint(" "); \ + printk("[ODM] "); \ + printk(title_str); \ + printk(" "); \ for (__i=0; __i < 6; __i++) \ - DbgPrint("%02X%s", __ptr[__i], (__i == 5) ? "" : "-"); \ - DbgPrint("\n"); \ + printk("%02X%s", __ptr[__i], (__i == 5) ? "" : "-"); \ + printk("\n"); \ } void ODM_InitDebugSetting23a(struct dm_odm_t *pDM_Odm); -- cgit v1.2.3-59-g8ed1b From 911f2921c41cece94689bc0bb4dc9f7723d40839 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 14:45:56 +0530 Subject: Staging: rtl8723au: os_dep: Removed variable that is always 0. The following patch removes a variable that is always 0 using coccinelle. The semaintic patch used is as follows: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index bd6953af0a03..de2a3f546cfb 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -471,7 +471,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index, int set_tx, const u8 *sta_addr, struct key_params *keyparms) { - int ret = 0; int key_len; struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct rtw_adapter *padapter = netdev_priv(dev); @@ -708,7 +707,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u8 key_index, exit: - return ret; + return 0; } #endif @@ -2432,20 +2431,16 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, static int rtw_cfg80211_monitor_if_open(struct net_device *ndev) { - int ret = 0; - DBG_8723A("%s\n", __func__); - return ret; + return 0; } static int rtw_cfg80211_monitor_if_close(struct net_device *ndev) { - int ret = 0; - DBG_8723A("%s\n", __func__); - return ret; + return 0; } static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, @@ -2574,11 +2569,9 @@ fail: static int rtw_cfg80211_monitor_if_set_mac_address(struct net_device *ndev, void *addr) { - int ret = 0; - DBG_8723A("%s\n", __func__); - return ret; + return 0; } static const struct net_device_ops rtw_cfg80211_monitor_if_ops = { -- cgit v1.2.3-59-g8ed1b From f9800f82b6c403d4ba595383859030360b67dae0 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Tue, 7 Oct 2014 14:46:30 +0530 Subject: Staging: rtl8723au: core: Removed variable that is always 0. The following patch removes a variable that is always 0 using coccinelle. The following semantic patch was used: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 6b4092f05da5..eb5d60ca2397 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1122,7 +1122,6 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; - int ret = 0; DBG_8723A("%s(acl_num =%d) = %pM\n", __func__, pacl_list->num, addr); @@ -1148,7 +1147,7 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num); - return ret; + return 0; } static void update_bcn_fixed_ie(struct rtw_adapter *padapter) @@ -1698,7 +1697,6 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset) { struct list_head *phead, *plist; - int ret = 0; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1706,7 +1704,7 @@ int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_o u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; if ((pmlmeinfo->state&0x03) != MSR_AP) - return ret; + return 0; DBG_8723A("%s(%s): with ch:%u, offset:%u\n", __func__, padapter->pnetdev->name, new_ch, ch_offset); @@ -1724,13 +1722,12 @@ int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_o issue_action_spct_ch_switch23a (padapter, bc_addr, new_ch, ch_offset); - return ret; + return 0; } int rtw_sta_flush23a(struct rtw_adapter *padapter) { struct list_head *phead, *plist, *ptmp; - int ret = 0; struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1743,7 +1740,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name); if ((pmlmeinfo->state&0x03) != MSR_AP) - return ret; + return 0; spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; @@ -1769,7 +1766,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) associated_clients_update23a(padapter, true); - return ret; + return 0; } /* called > TSR LEVEL for USB or SDIO Interface*/ -- cgit v1.2.3-59-g8ed1b From 6d36fe3edc99165c8d1be60445b807a613d2c918 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Fri, 3 Oct 2014 13:08:21 +0300 Subject: staging: rtl8188eu: Fix prefer ether_addr_copy() over memcpy() This patch fixes "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in rtw_ap.c Pahole showed that the addresses are aligned. Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 9224e029ef2b..7de7ba197be1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -888,7 +888,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->Rssi = 0; - memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + ether_addr_copy(pbss_network->MacAddress, myid(&(padapter->eeprompriv))); /* beacon interval */ p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ @@ -1164,7 +1164,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) if (!paclnode->valid) { INIT_LIST_HEAD(&paclnode->list); - memcpy(paclnode->addr, addr, ETH_ALEN); + ether_addr_copy(paclnode->addr, addr); paclnode->valid = true; -- cgit v1.2.3-59-g8ed1b From c9e27530b25fd8a01149a749488aef1353856c5e Mon Sep 17 00:00:00 2001 From: Mahati Chamarthy Date: Sat, 4 Oct 2014 21:57:02 +0530 Subject: Staging: rtl8188eu: include: Remove unnecessary macro This patch removes a macro which is not used anywhere except in the header file. The existing usage in the header file is replaced with the actual value. Signed-off-by: Mahati Chamarthy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_debug.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_debug.h b/drivers/staging/rtl8188eu/include/odm_debug.h index db7b44e16c48..6bc905756d1e 100644 --- a/drivers/staging/rtl8188eu/include/odm_debug.h +++ b/drivers/staging/rtl8188eu/include/odm_debug.h @@ -83,9 +83,8 @@ #define ODM_COMP_INIT BIT31 /*------------------------Export Marco Definition---------------------------*/ -#define DbgPrint pr_info #define RT_PRINTK(fmt, args...) \ - DbgPrint("%s(): " fmt, __func__, ## args); + pr_info("%s(): " fmt, __func__, ## args); #ifndef ASSERT #define ASSERT(expr) @@ -94,7 +93,7 @@ #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ if (((comp) & pDM_Odm->DebugComponents) && \ (level <= pDM_Odm->DebugLevel)) { \ - DbgPrint("[ODM-8188E] "); \ + pr_info("[ODM-8188E] "); \ RT_PRINTK fmt; \ } @@ -106,27 +105,27 @@ #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ if (!(expr)) { \ - DbgPrint("Assertion failed! %s at ......\n", #expr); \ - DbgPrint(" ......%s,%s,line=%d\n", __FILE__, \ + pr_info("Assertion failed! %s at ......\n", #expr); \ + pr_info(" ......%s,%s,line=%d\n", __FILE__, \ __func__, __LINE__); \ RT_PRINTK fmt; \ ASSERT(false); \ } -#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } -#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } -#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } +#define ODM_dbg_enter() { pr_info("==> %s\n", __func__); } +#define ODM_dbg_exit() { pr_info("<== %s\n", __func__); } +#define ODM_dbg_trace(str) { pr_info("%s:%s\n", __func__, str); } #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ if (((comp) & pDM_Odm->DebugComponents) && \ (level <= pDM_Odm->DebugLevel)) { \ int __i; \ u8 *__ptr = (u8 *)ptr; \ - DbgPrint("[ODM] "); \ - DbgPrint(title_str); \ - DbgPrint(" "); \ + pr_info("[ODM] "); \ + pr_info(title_str); \ + pr_info(" "); \ for (__i = 0; __i < 6; __i++) \ - DbgPrint("%02X%s", __ptr[__i], (__i == 5)?"":"-");\ - DbgPrint("\n"); \ + pr_info("%02X%s", __ptr[__i], (__i == 5)?"":"-");\ + pr_info("\n"); \ } void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); -- cgit v1.2.3-59-g8ed1b From 049845dfd60968edab1f928993ae0d7fcb27703e Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:27:21 +0530 Subject: staging: rtl8188eu: core: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 9935e66935af..350d2e73b419 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -456,7 +456,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecnetwork->IELength = 0; /* Added by Albert 2009/02/18 */ - /* If the the driver wants to use the bssid to create the connection. */ + /* If the driver wants to use the bssid to create the connection. */ /* If not, we have to copy the connecting AP's MAC address to it so that */ /* the driver just has the bssid information for PMKIDList searching. */ -- cgit v1.2.3-59-g8ed1b From 0b7d9bc2a44908363dfaf119b2538e839aab45c0 Mon Sep 17 00:00:00 2001 From: Mahati Chamarthy Date: Mon, 6 Oct 2014 22:07:17 +0530 Subject: Staging: rtl8188eu: include: Remove unused macros This patch removes macros that are never used. Signed-off-by: Mahati Chamarthy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_debug.h | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_debug.h b/drivers/staging/rtl8188eu/include/odm_debug.h index 6bc905756d1e..914f831a5b77 100644 --- a/drivers/staging/rtl8188eu/include/odm_debug.h +++ b/drivers/staging/rtl8188eu/include/odm_debug.h @@ -97,12 +97,6 @@ RT_PRINTK fmt; \ } -#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ - RT_PRINTK fmt; \ - } - #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ if (!(expr)) { \ pr_info("Assertion failed! %s at ......\n", #expr); \ @@ -111,22 +105,6 @@ RT_PRINTK fmt; \ ASSERT(false); \ } -#define ODM_dbg_enter() { pr_info("==> %s\n", __func__); } -#define ODM_dbg_exit() { pr_info("<== %s\n", __func__); } -#define ODM_dbg_trace(str) { pr_info("%s:%s\n", __func__, str); } - -#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ - int __i; \ - u8 *__ptr = (u8 *)ptr; \ - pr_info("[ODM] "); \ - pr_info(title_str); \ - pr_info(" "); \ - for (__i = 0; __i < 6; __i++) \ - pr_info("%02X%s", __ptr[__i], (__i == 5)?"":"-");\ - pr_info("\n"); \ - } void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); -- cgit v1.2.3-59-g8ed1b From 9cc56fa82765203cf32429dbb47f4f2c73f138aa Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 18:39:47 +0530 Subject: Staging: rtl8188eu: core: Remove variable that is not very useful. The following patch removes a variable which is not very useful using coccinelle. The following semaintic patch was used: @@ identifier ret; @@ -int ret = 0; ... when != ret when strict -return ret; +return 0; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 7de7ba197be1..d61842ed673e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -1186,7 +1186,6 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) { struct list_head *plist, *phead; - int ret = 0; struct rtw_wlan_acl_node *paclnode; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; @@ -1217,7 +1216,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) spin_unlock_bh(&(pacl_node_q->lock)); DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); - return ret; + return 0; } static void update_bcn_fixed_ie(struct adapter *padapter) @@ -1753,7 +1752,6 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) { struct list_head *phead, *plist; - int ret = 0; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1761,7 +1759,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return ret; + return 0; DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); @@ -1782,13 +1780,12 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset); - return ret; + return 0; } int rtw_sta_flush(struct adapter *padapter) { struct list_head *phead, *plist; - int ret = 0; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1798,7 +1795,7 @@ int rtw_sta_flush(struct adapter *padapter) DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return ret; + return 0; spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; @@ -1822,7 +1819,7 @@ int rtw_sta_flush(struct adapter *padapter) associated_clients_update(padapter, true); - return ret; + return 0; } /* called > TSR LEVEL for USB or SDIO Interface*/ -- cgit v1.2.3-59-g8ed1b From 44396c7bce449eb6bcb862c6336f5da9ff44c867 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Fri, 3 Oct 2014 13:23:00 +0300 Subject: staging: gs_fpgaboot: remove unnecessary 'out of memory' message This patch fixes "Possible unnecessary 'out of memory' message" checkpatch.pl warning in gs_fpgaboot.c Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index 6aa9d7c30139..1875bd3b823f 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -316,10 +316,8 @@ static int gs_fpgaboot(void) struct fpgaimage *fimage; fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL); - if (fimage == NULL) { - pr_err("No memory is available\n"); + if (fimage == NULL) goto err_out; - } err = gs_load_image(fimage, file); if (err) { -- cgit v1.2.3-59-g8ed1b From 1f74d5f688faea24107de37893b7fd5a0e56ac49 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Fri, 3 Oct 2014 14:04:25 +0300 Subject: staging: speakup: Fixed else after return or break warning The following patch fixes the checkpatch.pl warning: drivers/staging/speakup/kobjects.c:812 warning: else is not generally useful after a break or return Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index bcc7f62654f4..1486147f3bac 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -809,10 +809,10 @@ static ssize_t message_store_helper(const char *buf, size_t count, if (msg_stored == -ENOMEM) reset = 1; break; - } else { - used++; } + used++; + cp = linefeed + 1; } -- cgit v1.2.3-59-g8ed1b From 333c474b828e52bce8731e97fef27c2e950b5728 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Sat, 4 Oct 2014 13:36:27 +0300 Subject: staging: speakup: Change char * array type as static const This patch fixes "char * array declaration might be better as static const" checkpatch.pl warning in kobjects.c Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 1486147f3bac..b12c76de60b0 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -81,7 +81,7 @@ static ssize_t chars_chartab_show(struct kobject *kobj, static void report_char_chartab_status(int reset, int received, int used, int rejected, int do_characters) { - char *object_type[] = { + static char const *object_type[] = { "character class entries", "character descriptions", }; -- cgit v1.2.3-59-g8ed1b From 0f709488c52c11abc36f7f9ba077f8232cb7cd9d Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Tue, 7 Oct 2014 10:59:18 +0300 Subject: staging: speakup: Change char * array type as static const This patch fixes "char * array declaration might be better as static const" checkpatch.pl warning in main.c Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index 3f30a1b6e72c..e9f0c150d246 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -695,7 +695,7 @@ static void say_next_word(struct vc_data *vc) static void spell_word(struct vc_data *vc) { - static char *delay_str[] = { "", ",", ".", ". .", ". . ." }; + static char const *delay_str[] = { "", ",", ".", ". .", ". . ." }; char *cp = buf, *str_cap = spk_str_caps_stop; char *cp1, *last_cap = spk_str_caps_stop; u_char ch; -- cgit v1.2.3-59-g8ed1b From c65cfb5e5a456759bce8b4986407d95a2d02e8a8 Mon Sep 17 00:00:00 2001 From: Esra Altintas Date: Tue, 7 Oct 2014 22:45:55 +0300 Subject: staging: speakup: remove jiffies comparison using time_after_eq() in speakup_dtlk.c The following patch fixes the checkpatch.pl warning: WARNING: Comparing jiffies is almost always wrong; prefer time_after, time_before and friends Signed-off-by: Esra Altintas Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/speakup_dtlk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/speakup_dtlk.c b/drivers/staging/speakup/speakup_dtlk.c index d7d515273896..4e059ea78d4c 100644 --- a/drivers/staging/speakup/speakup_dtlk.c +++ b/drivers/staging/speakup/speakup_dtlk.c @@ -231,7 +231,7 @@ static void do_catch_up(struct spk_synth *synth) if (ch == '\n') ch = PROCSPEECH; spk_out(ch); - if ((jiffies >= jiff_max) && (ch == SPACE)) { + if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { spk_out(PROCSPEECH); spin_lock_irqsave(&speakup_info.spinlock, flags); delay_time_val = delay_time->u.n.value; -- cgit v1.2.3-59-g8ed1b From c9a114e70ab0da81797da84e5bc8737e4e82ad91 Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Tue, 7 Oct 2014 06:33:54 +0530 Subject: staging: octeon-usb: Removed unnessecary else after return WARNING: else is generally not useful after return or break checkpatch.pl warning in octeon-hcd.c Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 5f9db4cbb381..6ddde6af7e3a 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -640,8 +640,7 @@ static inline int __cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe) { if (pipe->pid_toggle) return 2; /* Data1 */ - else - return 0; /* Data0 */ + return 0; /* Data0 */ } /** -- cgit v1.2.3-59-g8ed1b From 6c71ea543a0f0132edbe40854b0e31bf9507af5b Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Tue, 7 Oct 2014 15:58:48 +0300 Subject: staging: octeon: Fix warning of prefer ether_addr_copy. This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file ethernet.c Pahole shows that the addresses are aligned. Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 8f9e3fb4871d..47d4277dc1ab 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -452,7 +452,7 @@ int cvm_oct_common_init(struct net_device *dev) mac = of_get_mac_address(priv->of_node); if (mac) - memcpy(dev->dev_addr, mac, ETH_ALEN); + ether_addr_copy(dev->dev_addr, mac); else eth_hw_addr_random(dev); -- cgit v1.2.3-59-g8ed1b From 109d672065bd9045cbb00a0759faa1c94d8a7f98 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Wed, 8 Oct 2014 00:41:10 +0200 Subject: staging: unisys: Remove typedef and rename struct to lowercase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove typedef and rename struct to lowercase (ultra_segment_state) in unisys Signed-off-by: Veronika Kabátová Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/controlframework.h | 10 +++++----- .../common-spar/include/channels/controlvmchannel.h | 6 +++--- drivers/staging/unisys/visorchipset/visorchipset_main.c | 15 ++++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index fd4726e754ea..bbcf5ac4f0b7 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -36,7 +36,7 @@ /* Define Ki scale page to be traditional 4KB page */ #define ULTRA_MEMORY_PAGE_Ki (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_Ki) -typedef struct _ULTRA_SEGMENT_STATE { +struct ultra_segment_state { u16 Enabled:1; /* Bit 0: May enter other states */ u16 Active:1; /* Bit 1: Assigned to active partition */ u16 Alive:1; /* Bit 2: Configure message sent to @@ -53,14 +53,14 @@ typedef struct _ULTRA_SEGMENT_STATE { * operating */ /* Note: don't use high bit unless we need to switch to ushort * which is non-compliant */ -} ULTRA_SEGMENT_STATE; -static const ULTRA_SEGMENT_STATE SegmentStateRunning = { +}; +static const struct ultra_segment_state SegmentStateRunning = { 1, 1, 1, 0, 1, 1, 1, 1 }; -static const ULTRA_SEGMENT_STATE SegmentStatePaused = { +static const struct ultra_segment_state SegmentStatePaused = { 1, 1, 1, 0, 1, 1, 1, 0 }; -static const ULTRA_SEGMENT_STATE SegmentStateStandby = { +static const struct ultra_segment_state SegmentStateStandby = { 1, 1, 0, 0, 1, 1, 1, 0 }; typedef union { diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index cbe152f8ea27..cfd99997cfee 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -390,13 +390,13 @@ typedef struct _CONTROLVM_MESSAGE_PACKET { } reconfigureDevice; /* for CONTROLVM_DEVICE_RECONFIGURE */ struct { u32 busNo; - ULTRA_SEGMENT_STATE state; + struct ultra_segment_state state; u8 reserved[2]; /* Natural alignment purposes */ } busChangeState; /* for CONTROLVM_BUS_CHANGESTATE */ struct { u32 busNo; u32 devNo; - ULTRA_SEGMENT_STATE state; + struct ultra_segment_state state; struct { u32 physicalDevice:1; /* =1 if message is for * a physical device */ @@ -407,7 +407,7 @@ typedef struct _CONTROLVM_MESSAGE_PACKET { struct { u32 busNo; u32 devNo; - ULTRA_SEGMENT_STATE state; + struct ultra_segment_state state; u8 reserved[6]; /* Natural alignment purposes */ } deviceChangeStateEvent; /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */ struct { diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index ce4e731a2e4a..320124a240ac 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -346,9 +346,9 @@ static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response); static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, ULTRA_CHIPSET_FEATURE features); -static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER * - msgHdr, int response, - ULTRA_SEGMENT_STATE state); +static void controlvm_respond_physdev_changestate( + CONTROLVM_MESSAGE_HEADER *msgHdr, int response, + struct ultra_segment_state state); static ssize_t toolaction_show(struct device *dev, struct device_attribute *attr, @@ -741,7 +741,8 @@ controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr, - int response, ULTRA_SEGMENT_STATE state) + int response, struct ultra_segment_state + state) { CONTROLVM_MESSAGE outmsg; @@ -857,7 +858,7 @@ bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response) static void device_changestate_responder(CONTROLVM_ID cmdId, ulong busNo, ulong devNo, int response, - ULTRA_SEGMENT_STATE responseState) + struct ultra_segment_state responseState) { VISORCHIPSET_DEVICE_INFO *p = NULL; CONTROLVM_MESSAGE outmsg; @@ -991,7 +992,7 @@ bus_epilog(u32 busNo, } static void -device_epilog(u32 busNo, u32 devNo, ULTRA_SEGMENT_STATE state, u32 cmd, +device_epilog(u32 busNo, u32 devNo, struct ultra_segment_state state, u32 cmd, CONTROLVM_MESSAGE_HEADER *msgHdr, int response, BOOL needResponse, BOOL for_visorbus) { @@ -1303,7 +1304,7 @@ my_device_changestate(CONTROLVM_MESSAGE *inmsg) CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; ulong busNo = cmd->deviceChangeState.busNo; ulong devNo = cmd->deviceChangeState.devNo; - ULTRA_SEGMENT_STATE state = cmd->deviceChangeState.state; + struct ultra_segment_state state = cmd->deviceChangeState.state; VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; -- cgit v1.2.3-59-g8ed1b From ab08cda0e9af22d0bb03af4b69c63644a142d886 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Sun, 5 Oct 2014 01:47:37 +0300 Subject: staging: comedi: Fix cast to restricted __be32 This patch fixes "cast to restricted __be32" sparse warning in ni_stc.h Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_stc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 29efce30eb7f..131e9049f21b 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1464,7 +1464,7 @@ struct ni_private { unsigned short ai_fifo_buffer[0x2000]; uint8_t eeprom_buffer[M_SERIES_EEPROM_SIZE]; - uint32_t serial_number; + __be32 serial_number; struct mite_struct *mite; struct mite_channel *ai_mite_chan; -- cgit v1.2.3-59-g8ed1b From 2d00485cacf729149eccceccadac95f86df3b1e1 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:26:49 +0530 Subject: staging: comedi: drivers: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 01796cd28e5b..8ed150689f97 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -35,7 +35,7 @@ * automatically. * * The PCI230+ and PCI260+ have the same PCI device IDs as the PCI230 and - * PCI260, but can be distinguished by the the size of the PCI regions. A + * PCI260, but can be distinguished by the size of the PCI regions. A * card will be configured as a "+" model if detected as such. * * Subdevices: -- cgit v1.2.3-59-g8ed1b From ea0db9b2fd284104a9fd1cead85252a83375c71f Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 11:59:29 +0530 Subject: Staging: comedi: drivers: Compressed two lines of code into one. The following patch compresses two lines of code into one using coccinelle and removes an unused variable. The following semantic patch was used: @@ expression ret; identifier f; @@ -ret = +return f(...); -return ret; Signed-off-by: Heena Sirwani Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 4f7829010a99..a43b5beffc4b 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -494,13 +494,10 @@ EXPORT_SYMBOL_GPL(mite_bytes_read_from_memory_ub); unsigned mite_dma_tcr(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; - int tcr; int lkar; lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel)); - tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel)); - - return tcr; + return readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel)); } EXPORT_SYMBOL_GPL(mite_dma_tcr); -- cgit v1.2.3-59-g8ed1b From fe43ec5350d34244dedf3e6647f991f7c348c82d Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 13:46:09 +0530 Subject: Staging: comedi: Compressed two lines of code into one. The following patch compressed two lines of code into one using coccinelle and removed an unused variable. The semantic patch used is as follows: @@ expression ret; identifier f; @@ -ret = +return f(...); -return ret; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 495969f46e76..224af2b2a685 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1718,7 +1718,6 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file) { struct comedi_subdevice *s; - int ret; if (arg >= dev->n_subdevices) return -EINVAL; @@ -1732,9 +1731,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, if (s->busy != file) return -EBUSY; - ret = do_cancel(dev, s); - - return ret; + return do_cancel(dev, s); } /* -- cgit v1.2.3-59-g8ed1b From c6c04f05115eaca1badc0232a8f75e2e120f8f15 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 7 Oct 2014 23:20:24 +0530 Subject: staging: comedi: Remove unecessary function and it's call Function aref_invalid has unreachable code as it right now just returns 0 after declaring a variable. This patch removes this function and it's single call. As it is static so it's obvious that it is not used anywhere other than this file or somewhere, where this is included. I also build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/range.c | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c index b6849545b810..9a1dc56f21d1 100644 --- a/drivers/staging/comedi/range.c +++ b/drivers/staging/comedi/range.c @@ -97,39 +97,6 @@ int do_rangeinfo_ioctl(struct comedi_device *dev, return 0; } -static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec) -{ - unsigned int aref; - - /* disable reporting invalid arefs... maybe someday */ - return 0; - - aref = CR_AREF(chanspec); - switch (aref) { - case AREF_DIFF: - if (s->subdev_flags & SDF_DIFF) - return 0; - break; - case AREF_COMMON: - if (s->subdev_flags & SDF_COMMON) - return 0; - break; - case AREF_GROUND: - if (s->subdev_flags & SDF_GROUND) - return 0; - break; - case AREF_OTHER: - if (s->subdev_flags & SDF_OTHER) - return 0; - break; - default: - break; - } - dev_dbg(s->device->class_dev, "subdevice does not support aref %i", - aref); - return 1; -} - /** * comedi_check_chanlist() - Validate each element in a chanlist. * @s: comedi_subdevice struct @@ -153,8 +120,7 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, else range_len = 0; if (chan >= s->n_chan || - CR_RANGE(chanspec) >= range_len || - aref_invalid(s, chanspec)) { + CR_RANGE(chanspec) >= range_len) { dev_warn(dev->class_dev, "bad chanlist[%d]=0x%08x chan=%d range length=%d\n", i, chanspec, chan, range_len); -- cgit v1.2.3-59-g8ed1b From ca4be88731488574e436406f540881fd7cf19b8d Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Tue, 7 Oct 2014 10:10:32 +0200 Subject: staging: lustre: fix sparse errors Mark functions static that are not used or declared outside of lo.c. Signed-off-by: Thomas Gummerer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/lo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index be31dfc5fa4b..17e1643fd675 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -35,7 +35,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" -int +static int lolnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) { LASSERT(!lntmsg->msg_routing); @@ -44,7 +44,7 @@ lolnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) return lnet_parse(ni, &lntmsg->msg_hdr, ni->ni_nid, lntmsg, 0); } -int +static int lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, unsigned int niov, struct iovec *iov, lnet_kiov_t *kiov, @@ -86,7 +86,7 @@ lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, static int lolnd_instanced; -void +static void lolnd_shutdown(lnet_ni_t *ni) { CDEBUG(D_NET, "shutdown\n"); @@ -95,7 +95,7 @@ lolnd_shutdown(lnet_ni_t *ni) lolnd_instanced = 0; } -int +static int lolnd_startup(lnet_ni_t *ni) { LASSERT(ni->ni_lnd == &the_lolnd); -- cgit v1.2.3-59-g8ed1b From 4d1d413aea840f0cc2fa025c0f52702bab9a53dc Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Fri, 3 Oct 2014 10:17:22 -0500 Subject: drivers: staging: lustre: Fix "else should follow close brace '}'" errors Fix checkpatch.pl "else should follow close brace '}'" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 6 ++---- drivers/staging/lustre/lustre/llite/dir.c | 3 +-- drivers/staging/lustre/lustre/lov/lov_pack.c | 3 +-- drivers/staging/lustre/lustre/obdclass/dt_object.c | 3 +-- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index e03775606712..8156b4c0f568 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -137,8 +137,7 @@ ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount) ); path_put(&path); return rc; - } - else + } else return -ENOSYS; } @@ -147,8 +146,7 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) if (sb->s_qcop->quota_off) { return sb->s_qcop->quota_off(sb, off ); - } - else + } else return -ENOSYS; } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 662bdf04a451..9e8bfdcfe5a4 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1509,8 +1509,7 @@ out_rmdir: cmd == LL_IOC_MDC_GETINFO)) { rc = 0; goto skip_lmm; - } - else + } else goto out_req; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 5edd6a3a9c54..5356d5324176 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -438,8 +438,7 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, if (copy_from_user(&lum, lump, lum_size)) { rc = -EFAULT; goto out_set; - } - else if ((lum.lmm_magic != LOV_USER_MAGIC) && + } else if ((lum.lmm_magic != LOV_USER_MAGIC) && (lum.lmm_magic != LOV_USER_MAGIC_V3)) { rc = -EINVAL; goto out_set; diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 909f542f8b86..e7be26ec7521 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -332,8 +332,7 @@ static struct dt_object *dt_reg_open(const struct lu_env *env, result = dt_lookup_dir(env, p, name, fid); if (result == 0){ o = dt_locate(env, dt, fid); - } - else + } else o = ERR_PTR(result); return o; diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 87b9764a4f19..1f4e76896da5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -694,8 +694,7 @@ default_queue: if (queue == PTLRPC_NRS_QUEUE_HP && !nrs_svc_has_hp(svc)) { rc = -ENODEV; goto out; - } - else if (queue == PTLRPC_NRS_QUEUE_BOTH && !nrs_svc_has_hp(svc)) + } else if (queue == PTLRPC_NRS_QUEUE_BOTH && !nrs_svc_has_hp(svc)) queue = PTLRPC_NRS_QUEUE_REG; /** -- cgit v1.2.3-59-g8ed1b From 9c234f6cb4c4cfe681bc8364c24152443684639f Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Thu, 2 Oct 2014 18:10:23 -0500 Subject: drivers: staging: lustre: Fix "'foo* bar' should be 'foo *bar'" errors Fix checkpatch.pl "'foo* bar' should be 'foo *bar'" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/dt_object.h | 2 +- drivers/staging/lustre/lustre/include/lu_object.h | 4 ++-- drivers/staging/lustre/lustre/include/lustre_lib.h | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- drivers/staging/lustre/lustre/include/obd_class.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/llite/statahead.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index 212ebaea8555..c2e7622469ca 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -617,7 +617,7 @@ struct dt_index_operations { int (*load)(const struct lu_env *env, const struct dt_it *di, __u64 hash); int (*key_rec)(const struct lu_env *env, - const struct dt_it *di, void* key_rec); + const struct dt_it *di, void *key_rec); } dio_it; }; diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 6015ee5c4b64..2ddb2b054d8d 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -1120,7 +1120,7 @@ struct lu_context_key { }; #define LU_KEY_INIT(mod, type) \ - static void* mod##_key_init(const struct lu_context *ctx, \ + static void *mod##_key_init(const struct lu_context *ctx, \ struct lu_context_key *key) \ { \ type *value; \ @@ -1137,7 +1137,7 @@ struct lu_context_key { #define LU_KEY_FINI(mod, type) \ static void mod##_key_fini(const struct lu_context *ctx, \ - struct lu_context_key *key, void* data) \ + struct lu_context_key *key, void *data) \ { \ type *info = data; \ \ diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index 12c7590e61fa..bf135630c39a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -85,7 +85,7 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id); /* client.c */ -int client_sanobd_setup(struct obd_device *obddev, struct lustre_cfg* lcfg); +int client_sanobd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg); struct client_obd *client_conn2cli(struct lustre_handle *conn); struct md_open_data; diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 0a024d3cfeb7..d4da2431b407 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2951,7 +2951,7 @@ void ptlrpcd_decref(void); * procfs output related functions * @{ */ -const char* ll_opcode2str(__u32 opcode); +const char *ll_opcode2str(__u32 opcode); #if defined (CONFIG_PROC_FS) void ptlrpc_lprocfs_register_obd(struct obd_device *obd); void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 882e40bd584c..4a29261c514d 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -414,7 +414,7 @@ do { \ #define EXP_MD_COUNTER_INCREMENT(exp, op) #endif -static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp) +static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp) { /* Always add in ldlm_stats */ tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 3c086b4d0ea5..e45070d7f219 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2399,7 +2399,7 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen) return buf; } -static char* ll_d_path(struct dentry *dentry, char *buf, int bufsize) +static char *ll_d_path(struct dentry *dentry, char *buf, int bufsize) { char *path = NULL; diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 06b71bcf97a7..85d451f17c02 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -915,7 +915,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, return rc; } -static void ll_statahead_one(struct dentry *parent, const char* entry_name, +static void ll_statahead_one(struct dentry *parent, const char *entry_name, int entry_name_len) { struct inode *dir = parent->d_inode; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index da769db0af77..978d886a1103 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -42,7 +42,7 @@ #include "llog_internal.h" /* helper functions for calling the llog obd methods */ -static struct llog_ctxt* llog_new_ctxt(struct obd_device *obd) +static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd) { struct llog_ctxt *ctxt; diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 1f4e76896da5..0c3f667d498f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -175,7 +175,7 @@ const char *ll_opcode2str(__u32 opcode) return ll_rpc_opcode_table[offset].opname; } -const char* ll_eopcode2str(__u32 opcode) +const char *ll_eopcode2str(__u32 opcode) { LASSERT(ll_eopcode_table[opcode].opcode == opcode); return ll_eopcode_table[opcode].opname; diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index e8d00408117a..b9cbbbd5322e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -428,7 +428,7 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import); * Register a timeout callback to the pinger list, and the callback will * be called when timeout happens. */ -struct timeout_item* ptlrpc_new_timeout(int time, enum timeout_event event, +struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event, timeout_cb_t cb, void *data) { struct timeout_item *ti; -- cgit v1.2.3-59-g8ed1b From c15fd709a657ee67c5a4dacc74a696af767939e3 Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Tue, 7 Oct 2014 01:26:00 +0530 Subject: staging: bcm: Removed else which was not required after return WARNING:else is generally not required after return checkpatch.pl warning in LeakyBucket.c Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/LeakyBucket.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index d6b55f993b57..86b79d6438d4 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -82,13 +82,12 @@ static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet if (false != psSF->bValid && psSF->ucDirection) { if (0 != psSF->uiCurrentTokenCount) { return psSF->uiCurrentTokenCount; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, - DBG_LVL_ALL, - "Not enough tokens in queue %zd Available %u\n", - psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); - psSF->uiPendedLast = 1; } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, + DBG_LVL_ALL, + "Not enough tokens in queue %zd Available %u\n", + psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); + psSF->uiPendedLast = 1; } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", -- cgit v1.2.3-59-g8ed1b From 9d1ffa072462443cdf0fdb24d81db7c9e7a4867d Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Tue, 7 Oct 2014 06:09:19 +0530 Subject: staging: bcm: Removed unnecessary else after return WARNING: else is generally not required after return chaeckpatch.pl warning in led_control.c Signed-off-by: Sarah Khan Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/led_control.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c index 074fc39ed678..181f17ff0a24 100644 --- a/drivers/staging/bcm/led_control.c +++ b/drivers/staging/bcm/led_control.c @@ -95,8 +95,7 @@ static INT ScaleRateofTransfer(ULONG rate) return 9; else if ((rate > 500) && (rate <= 600)) return 10; - else - return MAX_NUM_OF_BLINKS; + return MAX_NUM_OF_BLINKS; } static INT blink_in_normal_bandwidth(struct bcm_mini_adapter *ad, -- cgit v1.2.3-59-g8ed1b From 821a464c1c369bce8b2b82565fb702836b78a99e Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Tue, 7 Oct 2014 17:59:24 +0530 Subject: staging: bcm: Removed unnecessary braces after return WARNING: else is generally not useful after return checkpatch.pl warning in PHSModule.c Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/PHSModule.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index 5f4e503d54ec..262613436d1e 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -1244,19 +1244,15 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, if (eClsContext == eActiveClassifierRuleContext) return ERR_CLSASSIFIER_TABLE_FULL; - else { - /* Lets replace the oldest rule if we are looking in - * old Rule table */ - if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF) - psaClassifiertable->uiOldestPhsRuleIndex = 0; - - iClassifierIndex = - psaClassifiertable->uiOldestPhsRuleIndex; - psClassifierRules = - &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; + /* Lets replace the oldest rule if we are looking in + * old Rule table */ + if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF) + psaClassifiertable->uiOldestPhsRuleIndex = 0; - (psaClassifiertable->uiOldestPhsRuleIndex)++; - } + iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex; + psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; + + psaClassifiertable->uiOldestPhsRuleIndex++; } if (eClsContext == eOldClassifierRuleContext) { -- cgit v1.2.3-59-g8ed1b From f39b81f55012a1d27012fcdc850b537d3050be1f Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Tue, 7 Oct 2014 14:37:31 +0300 Subject: staging: bcm: Fixed else after return or break warning This patch fixes checkpatch.pl warning in files of bcm WARNING : else is not generally useful after a break or return Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceMisc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c index e5bcfec2a6cf..1f31b8f05884 100644 --- a/drivers/staging/bcm/InterfaceMisc.c +++ b/drivers/staging/bcm/InterfaceMisc.c @@ -102,12 +102,11 @@ int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, DBG_LVL_ALL, "WRM failed status :%d", retval); psIntfAdapter->psAdapter->DeviceAccess = false; return retval; - } else { - psIntfAdapter->psAdapter->DeviceAccess = false; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, - DBG_LVL_ALL, "WRM sent %d", retval); - return STATUS_SUCCESS; } + psIntfAdapter->psAdapter->DeviceAccess = false; + BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, + DBG_LVL_ALL, "WRM sent %d", retval); + return STATUS_SUCCESS; } int BcmRDM(void *arg, -- cgit v1.2.3-59-g8ed1b From 0bfacefd092130a397ce8f5fc13d10f846c96e28 Mon Sep 17 00:00:00 2001 From: Roxana Blaj Date: Fri, 3 Oct 2014 15:36:11 +0300 Subject: staging: rtl8192u: add spaces around '=', '+=', '<', '||' This fixes the checkpatch.pl errors: ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '+=' (ctx:VxV) ERROR: spaces required around that '<' (ctx:VxV) ERROR: spaces required around that '||' (ctx:VxE) Signed-off-by: Roxana Blaj Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index f66ad8a0dfe0..b301b757d2f5 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -78,17 +78,17 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, * Transform from little endian to big endian * and pending zero */ - for (i=0; i < frag_length; i+=4) { - *seg_ptr++ = ((i+0)txbuf_size= (u16)i; + tcb_desc->txbuf_size = (u16)i; skb_put(skb, i); - if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\ + if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index) || + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||\ (priv->ieee80211->queue_stop)) { RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); -- cgit v1.2.3-59-g8ed1b From 896be407e61abcfd5eb978e64e3b1acdd3519a7e Mon Sep 17 00:00:00 2001 From: Roxana Blaj Date: Fri, 3 Oct 2014 15:36:12 +0300 Subject: staging: rtl8192u: remove unnecessary line continuations This fixes the checkpatch.pl warning: WARNING: Avoid unnecessary line continuations Signed-off-by: Roxana Blaj Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index b301b757d2f5..2c321b7b8bae 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -88,7 +88,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, skb_put(skb, i); if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index) || - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||\ + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || (priv->ieee80211->queue_stop)) { RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); -- cgit v1.2.3-59-g8ed1b From 095ff453473b3fdbb529e8d3b555dcaff00edc6f Mon Sep 17 00:00:00 2001 From: Roxana Blaj Date: Fri, 3 Oct 2014 15:36:13 +0300 Subject: staging: rtl8192u: add intermediate variable This use for more readability. It also fixes checkpatch.pl warning: WARNING: line over 80 characters Signed-off-by: Roxana Blaj Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index 2c321b7b8bae..c230be290ab6 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -45,6 +45,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, unsigned char *seg_ptr; cb_desc *tcb_desc; u8 bLastIniPkt; + u8 index; firmware_init_param(dev); //Fragmentation might be required @@ -87,9 +88,10 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, tcb_desc->txbuf_size = (u16)i; skb_put(skb, i); - if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index) || - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || - (priv->ieee80211->queue_stop)) { + index = tcb_desc->queue_index; + if (!priv->ieee80211->check_nic_enough_desc(dev, index) || + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[index])) || + (priv->ieee80211->queue_stop)) { RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); } else { -- cgit v1.2.3-59-g8ed1b From f8c6b7e3c33d422e9bef47660619d7ff6ce7e85b Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Sat, 4 Oct 2014 22:25:46 +0300 Subject: staging: rtl8192u: Remove defined but unused function This patch fixes "symbol 'dm_change_rxpath_selection_setting' was not declared. Should it be static?" sparse warning in r8192U_dm.c After setting it as static, it causes to unused function sparse warning, because it is not used anywhere. Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 79 ------------------------------------ 1 file changed, 79 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index b0b66fba563b..bda153d55f7a 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1810,85 +1810,6 @@ void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type, } } /* DM_ChangeDynamicInitGainThresh */ -void -dm_change_rxpath_selection_setting( - struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive); - - - if(DM_Type == 0) - { - if(DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.Enable = (u8)DM_Value; - } - else if(DM_Type == 1) - { - if(DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } - else if(DM_Type == 2) - { - if(DM_Value > 40) - DM_Value = 40; - DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } - else if(DM_Type == 3) - { - if(DM_Value > 25) - DM_Value = 25; - DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } - else if(DM_Type == 4) - { - if(DM_Value >= CCK_Rx_Version_MAX) - DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method= (u8)DM_Value; - } - else if(DM_Type == 10) - { - if(DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } - else if(DM_Type == 11) - { - if(DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } - else if(DM_Type == 12) - { - if(DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } - else if(DM_Type == 13) - { - if(DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } - else if(DM_Type == 20) - { - if(DM_Value > 1) - DM_Value = 1; - pRA->ping_rssi_enable = (u8)DM_Value; - } - else if(DM_Type == 21) - { - if(DM_Value > 30) - DM_Value = 30; - pRA->ping_rssi_thresh_for_ra = DM_Value; - } -} - - /*----------------------------------------------------------------------------- * Function: dm_dig_init() * -- cgit v1.2.3-59-g8ed1b From c7a348cf8db9cf2c202850f7eb1b70e4d7401da0 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Sat, 4 Oct 2014 22:25:47 +0300 Subject: staging: rtl8192u: Fixes symbol as static This patch fixes "symbol 'ieee80211_send_probe_requests_rsl' was not declared. Should it be static?" sparse warning in ieee80211_softmac.c Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index a85bb232be97..88f4836176c6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -411,7 +411,7 @@ static void ieee80211_send_probe(struct ieee80211_device *ieee) } } -void ieee80211_send_probe_requests(struct ieee80211_device *ieee) +static void ieee80211_send_probe_requests(struct ieee80211_device *ieee) { if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ ieee80211_send_probe(ieee); -- cgit v1.2.3-59-g8ed1b From 657eb9798aed8f62685e97ea0cd6dc6df6b9f458 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Tue, 7 Oct 2014 00:05:45 +0300 Subject: staging: rtl8192u: Missing a blank line after declarations. Missing a blank line after declarations" checkpatch.pl warning in r819xU_phy.c Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index e9c15fe8ded5..058960251bac 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1463,6 +1463,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev) u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel) { struct r8192_priv *priv = ieee80211_priv(dev); + RT_TRACE(COMP_CH, "%s(), SwChnlInProgress: %d\n", __func__, priv->SwChnlInProgress); if (!priv->up) -- cgit v1.2.3-59-g8ed1b From f9eb26cfcad6a684fbb2671ca32a6961ae601c04 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 7 Oct 2014 23:21:07 +0530 Subject: staging: rtl8192u: ieee80211: Indent if statement This patch indents single statement below if statement in files of rtl8192u: ieee80211. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 6 +++--- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 88f4836176c6..a1c745b1cf99 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -517,7 +517,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); if(channel_map[ieee->current_network.channel] == 1) - ieee80211_send_probe_requests(ieee); + ieee80211_send_probe_requests(ieee); queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -1103,7 +1103,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco if(ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); if (wmm_info_len) //QOS - hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS); + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS); hdr->listen_interval = 0xa; //FIXME @@ -1533,7 +1533,7 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) break; if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - ieee80211_softmac_new_net(ieee, target); + ieee80211_softmac_new_net(ieee, target); } spin_unlock_irqrestore(&ieee->lock, flags); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 68f5ede86633..ae1b3cf2866c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -172,7 +172,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point(info, start, stop, &iwe, custom); + start = iwe_stream_add_point(info, start, stop, &iwe, custom); /* Add quality statistics */ /* TODO: Fix these values... */ iwe.cmd = IWEVQUAL; -- cgit v1.2.3-59-g8ed1b From 3286ae5f62a51edccdc40729a79ed5da54f00646 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Tue, 7 Oct 2014 15:16:17 +0300 Subject: staging: rtl8192u: Add space after enum definition Fix checkpatch.pl warning: WARNING:missing space after enum definition Signed-off-by: Melike Yurtoglu Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware.h b/drivers/staging/rtl8192u/r819xU_firmware.h index c48c884aa1af..cfa222350a9a 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.h +++ b/drivers/staging/rtl8192u/r819xU_firmware.h @@ -12,15 +12,15 @@ #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN) //#endif -typedef enum _firmware_init_step{ +typedef enum _firmware_init_step { FW_INIT_STEP0_BOOT = 0, FW_INIT_STEP1_MAIN = 1, FW_INIT_STEP2_DATA = 2, -}firmware_init_step_e; +} firmware_init_step_e; -typedef enum _opt_rst_type{ +typedef enum _opt_rst_type { OPT_SYSTEM_RESET = 0, OPT_FIRMWARE_RESET = 1, -}opt_rst_type_e; +} opt_rst_type_e; #endif -- cgit v1.2.3-59-g8ed1b From ac23fed85801685017fc7bf4567c6dfa024719b7 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Fri, 3 Oct 2014 16:13:06 +0300 Subject: staging: vt6655: Fixed else after return or break warning The following patch fixes the checkpatch.pl warning: drivers/staging/vt6655/hostap.c warning: else is not generally useful after a break or return Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/hostap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index ae0dade229d8..2db08df0656d 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -182,8 +182,7 @@ int vt6655_hostap_set_hostapd(struct vnt_private *pDevice, if (val) return hostap_enable_hostapd(pDevice, rtnl_locked); - else - return hostap_disable_hostapd(pDevice, rtnl_locked); + return hostap_disable_hostapd(pDevice, rtnl_locked); } /* -- cgit v1.2.3-59-g8ed1b From 99fdb36ec3651f946122c0f6261738bf4f89b8ae Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Fri, 3 Oct 2014 17:09:49 +0300 Subject: staging: vt6655: Fixed else after return or break warning The following patch fixes the checkpatch.pl warning: drivers/staging/vt6655/vntwifi.c warning: else is not generally useful after a break or return Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/vntwifi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 59f66fe47352..9cc3a67399ed 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -578,8 +578,7 @@ VNTWIFIbyGetKeyCypher( if (bGroupKey) return pMgmt->byCSSGK; - else - return pMgmt->byCSSPK; + return pMgmt->byCSSPK; } bool @@ -614,8 +613,7 @@ VNTWIFIwGetMaxSupportRate( if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A) return RATE_6M; - else - return RATE_1M; + return RATE_1M; } void -- cgit v1.2.3-59-g8ed1b From d84e63378b69bc5e12ffd1cdecbf3401badc62eb Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Mon, 6 Oct 2014 13:23:35 +0300 Subject: staging: vt6655: Fix do not use // c99 comments. This patch fixes "do not use // C99 comments" errors in datarate.h Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/datarate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h index 0509c4fd2a42..d55b07455cc2 100644 --- a/drivers/staging/vt6655/datarate.h +++ b/drivers/staging/vt6655/datarate.h @@ -75,4 +75,4 @@ DATARATEbyGetRateIdx( unsigned char byRate ); -#endif //__DATARATE_H__ +#endif /* __DATARATE_H__ */ -- cgit v1.2.3-59-g8ed1b From b7f0790d73f189ef1584656644ca53663fa96c22 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Mon, 6 Oct 2014 16:21:46 +0300 Subject: staging: vt6655: Fixed else after return or break warning. This patch fixes multiple instances of checkpatch.pl WARNING : else is not generally useful after a break or return in device_main.c Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 54e16f40d8ed..8baeb8c4f4f1 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -2915,9 +2915,8 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { rc = -EFAULT; break; - } else { - rc = 0; } + rc = 0; pReq = (PSCmdRequest)rq; pReq->wResult = MAGIC_CODE; break; @@ -2934,9 +2933,8 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { rc = -EFAULT; break; - } else { - rc = 0; } + rc = 0; if (test_and_set_bit(0, (void *)&(pMgmt->uCmdBusy))) return -EBUSY; -- cgit v1.2.3-59-g8ed1b From 3aaa06e1cbfcd8d24be2f369b414242c29776eb2 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Mon, 6 Oct 2014 23:26:50 +0300 Subject: staging: vt6655: fix do not use // c99 comments. This patch fixes "do not use // C99 comments" checkpatch.pl errors in hostap.h Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/hostap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/hostap.h b/drivers/staging/vt6655/hostap.h index 17df4e403fcf..fc5f9ed4674b 100644 --- a/drivers/staging/vt6655/hostap.h +++ b/drivers/staging/vt6655/hostap.h @@ -55,4 +55,4 @@ int vt6655_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked); int vt6655_hostap_ioctl(struct vnt_private *, struct iw_point *p); -#endif // __HOSTAP_H__ +#endif /* __HOSTAP_H__ */ -- cgit v1.2.3-59-g8ed1b From 14cd1df4baf1f6f2dd0b521ec99afa151427b06b Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 15:46:53 +0300 Subject: staging: vt6655: Remove unnecessary else after return This patch fixes checkpatch.pl warning in files of vt6655 WARNING: else is not generally useful after a break or return Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index de54923e8861..b8a64c07b97a 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1792,18 +1792,17 @@ BBuGetFrameTime( uFrameTime++; return uPreamble + uFrameTime; - } else { - uFrameTime = (cbFrameLength * 8 + 22) / uRate; /* ???????? */ - uTmp = ((uFrameTime * uRate) - 22) / 8; - if (cbFrameLength != uTmp) - uFrameTime++; + } + uFrameTime = (cbFrameLength * 8 + 22) / uRate; /* ???????? */ + uTmp = ((uFrameTime * uRate) - 22) / 8; + if (cbFrameLength != uTmp) + uFrameTime++; - uFrameTime = uFrameTime * 4; /* ??????? */ - if (byPktType != PK_TYPE_11A) - uFrameTime += 6; /* ?????? */ + uFrameTime = uFrameTime * 4; /* ??????? */ + if (byPktType != PK_TYPE_11A) + uFrameTime += 6; /* ?????? */ - return 20 + uFrameTime; /* ?????? */ - } + return 20 + uFrameTime; /* ?????? */ } /* -- cgit v1.2.3-59-g8ed1b From 61d566a5a3b6ee9aed5c89463af4342a26f295dc Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 20:41:48 +0530 Subject: staging: vt6655: Remove unnecessary cast for argument of kfree This patch removes all occurrences of unnecessary cast on the argument to kfree, all over in rtl8712. There is no need of the cast on the argument to kfree. Greped to find occurrences. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 8baeb8c4f4f1..1e1664ec1663 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1204,7 +1204,7 @@ static void device_free_rd0_ring(struct vnt_private *pDevice) dev_kfree_skb(pRDInfo->skb); - kfree((void *)pDesc->pRDInfo); + kfree(pDesc->pRDInfo); } } @@ -1221,7 +1221,7 @@ static void device_free_rd1_ring(struct vnt_private *pDevice) dev_kfree_skb(pRDInfo->skb); - kfree((void *)pDesc->pRDInfo); + kfree(pDesc->pRDInfo); } } @@ -1305,7 +1305,7 @@ static void device_free_td0_ring(struct vnt_private *pDevice) if (pTDInfo->skb) dev_kfree_skb(pTDInfo->skb); - kfree((void *)pDesc->pTDInfo); + kfree(pDesc->pTDInfo); } } @@ -1324,7 +1324,7 @@ static void device_free_td1_ring(struct vnt_private *pDevice) if (pTDInfo->skb) dev_kfree_skb(pTDInfo->skb); - kfree((void *)pDesc->pTDInfo); + kfree(pDesc->pTDInfo); } } -- cgit v1.2.3-59-g8ed1b From 0c074871f75e11c4dd383e0d83fc9b09ae685125 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 19:01:47 +0300 Subject: staging: vt6655: Removing else after break statement to fix warning This patch fixes the checkpatch.pl warning in key.c file WARNING: else is not useful after a break or return Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/key.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 211afae306c7..12e8b87c0a60 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -374,9 +374,8 @@ bool KeybRemoveKey( } s_vCheckKeyTableValid(pTable, dwIoBase); return true; - } else { - return false; } + return false; } for (i = 0; i < MAX_KEY_TABLE; i++) { @@ -394,9 +393,8 @@ bool KeybRemoveKey( } s_vCheckKeyTableValid(pTable, dwIoBase); return true; - } else { - return false; } + return false; } } return false; -- cgit v1.2.3-59-g8ed1b From 5de55f6524b3d8687f5d13aa7827e2798fd2cff7 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 18:38:51 +0300 Subject: staging: vt6655: Use ether_addr_copy function This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file key.c Pahole shows that the addresses are aligned Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 12e8b87c0a60..02caffb06e59 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -267,7 +267,7 @@ bool KeybSetKey( } } if (j < (MAX_KEY_TABLE-1)) { - memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN); + ether_addr_copy(pTable->KeyTable[j].abyBSSID, pbyBSSID); pTable->KeyTable[j].bInUse = true; if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key -- cgit v1.2.3-59-g8ed1b From c5e1150178abe6fc3d967953dc74694e51b07ff3 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 18:25:31 +0300 Subject: staging: vt6655: Use ether_addr_copy function This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file device_main.c Pahole shows that the addresses are aligned Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 1e1664ec1663..3eb8e5c5366e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -362,9 +362,9 @@ device_set_options(struct vnt_private *pDevice) unsigned char abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; unsigned char abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); - memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); - memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN); + ether_addr_copy(pDevice->abyBroadcastAddr, abyBroadcastAddr); + ether_addr_copy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042); + ether_addr_copy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel); pDevice->uChannel = pDevice->sOpts.channel_num; pDevice->wRTSThreshold = pDevice->sOpts.rts_thresh; -- cgit v1.2.3-59-g8ed1b From 5ab665eb2485e6fbbb763eceb7cc60930461a4e8 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 16:05:47 +0300 Subject: staging: vt6655: Use ether_addr_copy function This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file iwctl.c Pahole shows that the addresses are aligned Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iwctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 14a62bdae278..94b4859e2f25 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -1756,7 +1756,7 @@ int iwctl_siwencodeext(struct net_device *dev, } /**************Translate iw_encode_ext to viawget_wpa_param****************/ - memcpy(param->addr, addr, ETH_ALEN); + ether_addr_copy(param->addr, addr); param->u.wpa_key.alg_name = (int)alg_name; param->u.wpa_key.set_tx = set_tx; param->u.wpa_key.key_index = key_idx; -- cgit v1.2.3-59-g8ed1b From cfafe92c1e9408190748f528a8d21d6d8678c248 Mon Sep 17 00:00:00 2001 From: Kumari Radha Date: Wed, 8 Oct 2014 12:44:57 +0530 Subject: staging: media: omap24xx: Remove unnecessary 'out of memory' message This patch removes unnecessay out of memory message fixing the following checkpach.pl warning in omap24xxcam.c: WARNING: Possible unnecessary 'out of memory' message Signed-off-by: Kumari Radha Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/omap24xx/omap24xxcam.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/media/omap24xx/omap24xxcam.c b/drivers/staging/media/omap24xx/omap24xxcam.c index d590b3e8b70c..5ca2bf5353fe 100644 --- a/drivers/staging/media/omap24xx/omap24xxcam.c +++ b/drivers/staging/media/omap24xx/omap24xxcam.c @@ -1737,10 +1737,8 @@ static int omap24xxcam_probe(struct platform_device *pdev) int irq; cam = kzalloc(sizeof(*cam), GFP_KERNEL); - if (!cam) { - dev_err(&pdev->dev, "could not allocate memory\n"); + if (!cam) goto err; - } platform_set_drvdata(pdev, cam); -- cgit v1.2.3-59-g8ed1b From b717a65a7b3156d8b078a72559d6ae63a1b55d54 Mon Sep 17 00:00:00 2001 From: Kumari Radha Date: Wed, 8 Oct 2014 12:45:44 +0530 Subject: staging: media: omap4iss: Remove unnecessary 'out of memory' message This patch removes unnecessay out of memory message fixing the following checkpach.pl warning in iss.c: WARNING: Possible unnecessary 'out of memory' message Signed-off-by: Kumari Radha Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/omap4iss/iss.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index d548371db65a..6e9e869e5875 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -1357,10 +1357,8 @@ static int iss_probe(struct platform_device *pdev) return -EINVAL; iss = devm_kzalloc(&pdev->dev, sizeof(*iss), GFP_KERNEL); - if (!iss) { - dev_err(&pdev->dev, "Could not allocate memory\n"); + if (!iss) return -ENOMEM; - } mutex_init(&iss->iss_mutex); -- cgit v1.2.3-59-g8ed1b From d92c54f6c079988317c5c95bdd2dadf7ce71e45c Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 7 Oct 2014 23:20:07 +0530 Subject: staging: media: ompa4iss: Replace sprintf with snprintf This patch replaces sprintf with snprintf as sprintf does not check for buffer overflow. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 92c2d5b743c7..47f86b306cb6 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1231,7 +1231,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) v4l2_subdev_init(sd, &csi2_ops); sd->internal_ops = &csi2_internal_ops; - sprintf(name, "CSI2%s", subname); + snprintf(name, sizeof(name), "CSI2%s", subname); snprintf(sd->name, sizeof(sd->name), "OMAP4 ISS %s", name); sd->grp_id = 1 << 16; /* group ID for iss subdevs */ -- cgit v1.2.3-59-g8ed1b From c3cefd3c3c289e93934bba7b6c746b3d6698777c Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 11:17:28 +0530 Subject: staging: media: cxd2009: use usleep_range() This patch fixes checkpatch.pl warning in file cxd2099.c WARNING : msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/cxd2099/cxd2099.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/cxd2099/cxd2099.c b/drivers/staging/media/cxd2099/cxd2099.c index 73e7b2c9e4a7..657ea480c6e7 100644 --- a/drivers/staging/media/cxd2099/cxd2099.c +++ b/drivers/staging/media/cxd2099/cxd2099.c @@ -527,7 +527,7 @@ static int slot_reset(struct dvb_ca_en50221 *ca, int slot) u8 val; #endif for (i = 0; i < 100; i++) { - msleep(10); + usleep_range(10000, 11000); #if 0 read_reg(ci, 0x06, &val); dev_info(&ci->i2c->dev, "%d:%02x\n", i, val); -- cgit v1.2.3-59-g8ed1b From 2129e17ef511a3682a731fdee9b678596bc32b75 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 09:12:17 +0530 Subject: staging: media: davinci_vpfe: Replace *__iomem with __iomem * This patch fixes defective positional use of __iomem, wherever present in media: davinci_vpfe. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/dm365_ipipe.h | 4 +- .../staging/media/davinci_vpfe/dm365_ipipe_hw.c | 62 +++++++++++----------- .../staging/media/davinci_vpfe/dm365_ipipe_hw.h | 58 ++++++++++---------- drivers/staging/media/davinci_vpfe/dm365_ipipeif.h | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 10 ++-- drivers/staging/media/davinci_vpfe/dm365_isif.h | 6 +-- drivers/staging/media/davinci_vpfe/dm365_resizer.h | 2 +- 7 files changed, 72 insertions(+), 72 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h index cf4204603eb8..d81b29e19309 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h @@ -120,8 +120,8 @@ struct vpfe_ipipe_device { enum ipipe_input_entity input; unsigned int output; struct v4l2_ctrl_handler ctrls; - void *__iomem base_addr; - void *__iomem isp5_base_addr; + void __iomem *base_addr; + void __iomem *isp5_base_addr; struct ipipe_module_params config; }; diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c index b2daf5e63f88..e2cdbb1a0454 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c @@ -24,7 +24,7 @@ #define IPIPE_MODE_CONTINUOUS 0 #define IPIPE_MODE_SINGLE_SHOT 1 -static void ipipe_clock_enable(void *__iomem base_addr) +static void ipipe_clock_enable(void __iomem *base_addr) { /* enable IPIPE MMR for register write access */ regw_ip(base_addr, IPIPE_GCK_MMR_DEFAULT, IPIPE_GCK_MMR); @@ -34,7 +34,7 @@ static void ipipe_clock_enable(void *__iomem base_addr) } static void -rsz_set_common_params(void *__iomem rsz_base, struct resizer_params *params) +rsz_set_common_params(void __iomem *rsz_base, struct resizer_params *params) { struct rsz_common_params *rsz_common = ¶ms->rsz_common; u32 val; @@ -66,7 +66,7 @@ rsz_set_common_params(void *__iomem rsz_base, struct resizer_params *params) } static void -rsz_set_rsz_regs(void *__iomem rsz_base, unsigned int rsz_id, +rsz_set_rsz_regs(void __iomem *rsz_base, unsigned int rsz_id, struct resizer_params *params) { struct resizer_scale_param *rsc_params; @@ -171,7 +171,7 @@ rsz_set_rsz_regs(void *__iomem rsz_base, unsigned int rsz_id, /*set the registers of either RSZ0 or RSZ1 */ static void -ipipe_setup_resizer(void *__iomem rsz_base, struct resizer_params *params) +ipipe_setup_resizer(void __iomem *rsz_base, struct resizer_params *params) { /* enable MMR gate to write to Resizer */ regw_rsz(rsz_base, 1, RSZ_GCK_MMR); @@ -302,8 +302,8 @@ int config_rsz_hw(struct vpfe_resizer_device *resizer, struct resizer_params *config) { struct vpfe_device *vpfe_dev = to_vpfe_device(resizer); - void *__iomem ipipe_base = vpfe_dev->vpfe_ipipe.base_addr; - void *__iomem rsz_base = vpfe_dev->vpfe_resizer.base_addr; + void __iomem *ipipe_base = vpfe_dev->vpfe_ipipe.base_addr; + void __iomem *rsz_base = vpfe_dev->vpfe_resizer.base_addr; /* enable VPSS clock */ vpss_enable_clock(VPSS_IPIPE_CLOCK, 1); @@ -315,7 +315,7 @@ int config_rsz_hw(struct vpfe_resizer_device *resizer, } static void -rsz_set_y_address(void *__iomem rsz_base, unsigned int address, +rsz_set_y_address(void __iomem *rsz_base, unsigned int address, unsigned int offset) { u32 val; @@ -330,7 +330,7 @@ rsz_set_y_address(void *__iomem rsz_base, unsigned int address, } static void -rsz_set_c_address(void *__iomem rsz_base, unsigned int address, +rsz_set_c_address(void __iomem *rsz_base, unsigned int address, unsigned int offset) { u32 val; @@ -352,7 +352,7 @@ rsz_set_c_address(void *__iomem rsz_base, unsigned int address, * @address: the address to set */ int -resizer_set_outaddr(void *__iomem rsz_base, struct resizer_params *params, +resizer_set_outaddr(void __iomem *rsz_base, struct resizer_params *params, int resize_no, unsigned int address) { struct resizer_scale_param *rsc_param; @@ -411,7 +411,7 @@ resizer_set_outaddr(void *__iomem rsz_base, struct resizer_params *params, } void -ipipe_set_lutdpc_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, +ipipe_set_lutdpc_regs(void __iomem *base_addr, void __iomem *isp5_base_addr, struct vpfe_ipipe_lutdpc *dpc) { u32 max_tbl_size = LUT_DPC_MAX_SIZE >> 1; @@ -446,7 +446,7 @@ ipipe_set_lutdpc_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, } static void -set_dpc_thresholds(void *__iomem base_addr, +set_dpc_thresholds(void __iomem *base_addr, struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_thr) { regw_ip(base_addr, dpc_thr->corr_thr.r & OTFDPC_DPC2_THR_MASK, @@ -467,7 +467,7 @@ set_dpc_thresholds(void *__iomem base_addr, DPC_OTF_2D_THR_B); } -void ipipe_set_otfdpc_regs(void *__iomem base_addr, +void ipipe_set_otfdpc_regs(void __iomem *base_addr, struct vpfe_ipipe_otfdpc *otfdpc) { struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_2_0 = &otfdpc->alg_cfg.dpc_2_0; @@ -523,7 +523,7 @@ void ipipe_set_otfdpc_regs(void *__iomem base_addr, /* 2D Noise filter */ void -ipipe_set_d2f_regs(void *__iomem base_addr, unsigned int id, +ipipe_set_d2f_regs(void __iomem *base_addr, unsigned int id, struct vpfe_ipipe_nf *noise_filter) { @@ -571,7 +571,7 @@ ipipe_set_d2f_regs(void *__iomem base_addr, unsigned int id, (((decimal & 0x1f) | ((integer & 0x7) << 5))) /* Green Imbalance Correction */ -void ipipe_set_gic_regs(void *__iomem base_addr, struct vpfe_ipipe_gic *gic) +void ipipe_set_gic_regs(void __iomem *base_addr, struct vpfe_ipipe_gic *gic) { u32 val; @@ -609,7 +609,7 @@ void ipipe_set_gic_regs(void *__iomem base_addr, struct vpfe_ipipe_gic *gic) #define IPIPE_U13Q9(decimal, integer) \ (((decimal & 0x1ff) | ((integer & 0xf) << 9))) /* White balance */ -void ipipe_set_wb_regs(void *__iomem base_addr, struct vpfe_ipipe_wb *wb) +void ipipe_set_wb_regs(void __iomem *base_addr, struct vpfe_ipipe_wb *wb) { u32 val; @@ -635,7 +635,7 @@ void ipipe_set_wb_regs(void *__iomem base_addr, struct vpfe_ipipe_wb *wb) } /* CFA */ -void ipipe_set_cfa_regs(void *__iomem base_addr, struct vpfe_ipipe_cfa *cfa) +void ipipe_set_cfa_regs(void __iomem *base_addr, struct vpfe_ipipe_cfa *cfa) { ipipe_clock_enable(base_addr); @@ -671,7 +671,7 @@ void ipipe_set_cfa_regs(void *__iomem base_addr, struct vpfe_ipipe_cfa *cfa) } void -ipipe_set_rgb2rgb_regs(void *__iomem base_addr, unsigned int id, +ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id, struct vpfe_ipipe_rgb2rgb *rgb) { u32 offset_mask = RGB2RGB_1_OFST_MASK; @@ -724,7 +724,7 @@ ipipe_set_rgb2rgb_regs(void *__iomem base_addr, unsigned int id, } static void -ipipe_update_gamma_tbl(void *__iomem isp5_base_addr, +ipipe_update_gamma_tbl(void __iomem *isp5_base_addr, struct vpfe_ipipe_gamma_entry *table, int size, u32 addr) { int count; @@ -738,7 +738,7 @@ ipipe_update_gamma_tbl(void *__iomem isp5_base_addr, } void -ipipe_set_gamma_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, +ipipe_set_gamma_regs(void __iomem *base_addr, void __iomem *isp5_base_addr, struct vpfe_ipipe_gamma *gamma) { int table_size; @@ -770,7 +770,7 @@ ipipe_set_gamma_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, } void -ipipe_set_3d_lut_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, +ipipe_set_3d_lut_regs(void __iomem *base_addr, void __iomem *isp5_base_addr, struct vpfe_ipipe_3d_lut *lut_3d) { struct vpfe_ipipe_3d_lut_entry *tbl; @@ -819,7 +819,7 @@ ipipe_set_3d_lut_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, /* Lumina adjustments */ void -ipipe_set_lum_adj_regs(void *__iomem base_addr, struct ipipe_lum_adj *lum_adj) +ipipe_set_lum_adj_regs(void __iomem *base_addr, struct ipipe_lum_adj *lum_adj) { u32 val; @@ -834,7 +834,7 @@ ipipe_set_lum_adj_regs(void *__iomem base_addr, struct ipipe_lum_adj *lum_adj) #define IPIPE_S12Q8(decimal, integer) \ (((decimal & 0xff) | ((integer & 0xf) << 8))) -void ipipe_set_rgb2ycbcr_regs(void *__iomem base_addr, +void ipipe_set_rgb2ycbcr_regs(void __iomem *base_addr, struct vpfe_ipipe_rgb2yuv *yuv) { u32 val; @@ -866,7 +866,7 @@ void ipipe_set_rgb2ycbcr_regs(void *__iomem base_addr, /* YUV 422 conversion */ void -ipipe_set_yuv422_conv_regs(void *__iomem base_addr, +ipipe_set_yuv422_conv_regs(void __iomem *base_addr, struct vpfe_ipipe_yuv422_conv *conv) { u32 val; @@ -879,7 +879,7 @@ ipipe_set_yuv422_conv_regs(void *__iomem base_addr, } void -ipipe_set_gbce_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, +ipipe_set_gbce_regs(void __iomem *base_addr, void __iomem *isp5_base_addr, struct vpfe_ipipe_gbce *gbce) { unsigned int count; @@ -906,7 +906,7 @@ ipipe_set_gbce_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, } void -ipipe_set_ee_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, +ipipe_set_ee_regs(void __iomem *base_addr, void __iomem *isp5_base_addr, struct vpfe_ipipe_yee *ee) { unsigned int count; @@ -950,7 +950,7 @@ ipipe_set_ee_regs(void *__iomem base_addr, void *__iomem isp5_base_addr, } /* Chromatic Artifact Correction. CAR */ -static void ipipe_set_mf(void *__iomem base_addr) +static void ipipe_set_mf(void __iomem *base_addr) { /* typ to dynamic switch */ regw_ip(base_addr, VPFE_IPIPE_CAR_DYN_SWITCH, CAR_TYP); @@ -959,7 +959,7 @@ static void ipipe_set_mf(void *__iomem base_addr) } static void -ipipe_set_gain_ctrl(void *__iomem base_addr, struct vpfe_ipipe_car *car) +ipipe_set_gain_ctrl(void __iomem *base_addr, struct vpfe_ipipe_car *car) { regw_ip(base_addr, VPFE_IPIPE_CAR_CHR_GAIN_CTRL, CAR_TYP); regw_ip(base_addr, car->hpf, CAR_HPF_TYP); @@ -975,7 +975,7 @@ ipipe_set_gain_ctrl(void *__iomem base_addr, struct vpfe_ipipe_car *car) CAR_GN2_MIN); } -void ipipe_set_car_regs(void *__iomem base_addr, struct vpfe_ipipe_car *car) +void ipipe_set_car_regs(void __iomem *base_addr, struct vpfe_ipipe_car *car) { u32 val; @@ -1010,7 +1010,7 @@ void ipipe_set_car_regs(void *__iomem base_addr, struct vpfe_ipipe_car *car) } /* Chromatic Gain Suppression */ -void ipipe_set_cgs_regs(void *__iomem base_addr, struct vpfe_ipipe_cgs *cgs) +void ipipe_set_cgs_regs(void __iomem *base_addr, struct vpfe_ipipe_cgs *cgs) { ipipe_clock_enable(base_addr); regw_ip(base_addr, cgs->en, CGS_EN); @@ -1025,12 +1025,12 @@ void ipipe_set_cgs_regs(void *__iomem base_addr, struct vpfe_ipipe_cgs *cgs) regw_ip(base_addr, cgs->h_min, CGS_GN1_H_MIN); } -void rsz_src_enable(void *__iomem rsz_base, int enable) +void rsz_src_enable(void __iomem *rsz_base, int enable) { regw_rsz(rsz_base, enable, RSZ_SRC_EN); } -int rsz_enable(void *__iomem rsz_base, int rsz_id, int enable) +int rsz_enable(void __iomem *rsz_base, int rsz_id, int enable) { if (rsz_id == RSZ_A) { regw_rsz(rsz_base, enable, RSZ_EN_A); diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h index 81176fb9d164..2bf2f7a69173 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h @@ -490,29 +490,29 @@ #define RSZ_RGB_TYP_SHIFT 0 #define RSZ_RGB_ALPHA_MASK 0xff -static inline u32 regr_ip(void *__iomem addr, u32 offset) +static inline u32 regr_ip(void __iomem *addr, u32 offset) { return readl(addr + offset); } -static inline void regw_ip(void *__iomem addr, u32 val, u32 offset) +static inline void regw_ip(void __iomem *addr, u32 val, u32 offset) { writel(val, addr + offset); } -static inline u32 w_ip_table(void *__iomem addr, u32 val, u32 offset) +static inline u32 w_ip_table(void __iomem *addr, u32 val, u32 offset) { writel(val, addr + offset); return val; } -static inline u32 regr_rsz(void *__iomem addr, u32 offset) +static inline u32 regr_rsz(void __iomem *addr, u32 offset) { return readl(addr + offset); } -static inline u32 regw_rsz(void *__iomem addr, u32 val, u32 offset) +static inline u32 regw_rsz(void __iomem *addr, u32 val, u32 offset) { writel(val, addr + offset); @@ -520,39 +520,39 @@ static inline u32 regw_rsz(void *__iomem addr, u32 val, u32 offset) } int config_ipipe_hw(struct vpfe_ipipe_device *ipipe); -int resizer_set_outaddr(void *__iomem rsz_base, struct resizer_params *params, +int resizer_set_outaddr(void __iomem *rsz_base, struct resizer_params *params, int resize_no, unsigned int address); -int rsz_enable(void *__iomem rsz_base, int rsz_id, int enable); -void rsz_src_enable(void *__iomem rsz_base, int enable); +int rsz_enable(void __iomem *rsz_base, int rsz_id, int enable); +void rsz_src_enable(void __iomem *rsz_base, int enable); void rsz_set_in_pix_format(unsigned char y_c); int config_rsz_hw(struct vpfe_resizer_device *resizer, struct resizer_params *config); -void ipipe_set_d2f_regs(void *__iomem base_addr, unsigned int id, +void ipipe_set_d2f_regs(void __iomem *base_addr, unsigned int id, struct vpfe_ipipe_nf *noise_filter); -void ipipe_set_rgb2rgb_regs(void *__iomem base_addr, unsigned int id, +void ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id, struct vpfe_ipipe_rgb2rgb *rgb); -void ipipe_set_yuv422_conv_regs(void *__iomem base_addr, +void ipipe_set_yuv422_conv_regs(void __iomem *base_addr, struct vpfe_ipipe_yuv422_conv *conv); -void ipipe_set_lum_adj_regs(void *__iomem base_addr, +void ipipe_set_lum_adj_regs(void __iomem *base_addr, struct ipipe_lum_adj *lum_adj); -void ipipe_set_rgb2ycbcr_regs(void *__iomem base_addr, +void ipipe_set_rgb2ycbcr_regs(void __iomem *base_addr, struct vpfe_ipipe_rgb2yuv *yuv); -void ipipe_set_lutdpc_regs(void *__iomem base_addr, - void *__iomem isp5_base_addr, struct vpfe_ipipe_lutdpc *lutdpc); -void ipipe_set_otfdpc_regs(void *__iomem base_addr, +void ipipe_set_lutdpc_regs(void __iomem *base_addr, + void __iomem *isp5_base_addr, struct vpfe_ipipe_lutdpc *lutdpc); +void ipipe_set_otfdpc_regs(void __iomem *base_addr, struct vpfe_ipipe_otfdpc *otfdpc); -void ipipe_set_3d_lut_regs(void *__iomem base_addr, - void *__iomem isp5_base_addr, struct vpfe_ipipe_3d_lut *lut_3d); -void ipipe_set_gamma_regs(void *__iomem base_addr, - void *__iomem isp5_base_addr, struct vpfe_ipipe_gamma *gamma); -void ipipe_set_ee_regs(void *__iomem base_addr, - void *__iomem isp5_base_addr, struct vpfe_ipipe_yee *ee); -void ipipe_set_gbce_regs(void *__iomem base_addr, - void *__iomem isp5_base_addr, struct vpfe_ipipe_gbce *gbce); -void ipipe_set_gic_regs(void *__iomem base_addr, struct vpfe_ipipe_gic *gic); -void ipipe_set_cfa_regs(void *__iomem base_addr, struct vpfe_ipipe_cfa *cfa); -void ipipe_set_car_regs(void *__iomem base_addr, struct vpfe_ipipe_car *car); -void ipipe_set_cgs_regs(void *__iomem base_addr, struct vpfe_ipipe_cgs *cgs); -void ipipe_set_wb_regs(void *__iomem base_addr, struct vpfe_ipipe_wb *wb); +void ipipe_set_3d_lut_regs(void __iomem *base_addr, + void __iomem *isp5_base_addr, struct vpfe_ipipe_3d_lut *lut_3d); +void ipipe_set_gamma_regs(void __iomem *base_addr, + void __iomem *isp5_base_addr, struct vpfe_ipipe_gamma *gamma); +void ipipe_set_ee_regs(void __iomem *base_addr, + void __iomem *isp5_base_addr, struct vpfe_ipipe_yee *ee); +void ipipe_set_gbce_regs(void __iomem *base_addr, + void __iomem *isp5_base_addr, struct vpfe_ipipe_gbce *gbce); +void ipipe_set_gic_regs(void __iomem *base_addr, struct vpfe_ipipe_gic *gic); +void ipipe_set_cfa_regs(void __iomem *base_addr, struct vpfe_ipipe_cfa *cfa); +void ipipe_set_car_regs(void __iomem *base_addr, struct vpfe_ipipe_car *car); +void ipipe_set_cgs_regs(void __iomem *base_addr, struct vpfe_ipipe_cgs *cgs); +void ipipe_set_wb_regs(void __iomem *base_addr, struct vpfe_ipipe_wb *wb); #endif /* _DAVINCI_VPFE_DM365_IPIPE_HW_H */ diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h index 608701fc5fed..cea3d61335af 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h @@ -134,7 +134,7 @@ struct vpfe_ipipeif_device { unsigned int output; struct vpfe_video_device video_in; struct v4l2_ctrl_handler ctrls; - void *__iomem ipipeif_base_addr; + void __iomem *ipipeif_base_addr; struct ipipeif_params config; int dpcm_predictor; int gain; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 0d535b062e4e..f00cd9f23227 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -70,17 +70,17 @@ static const u32 isif_srggb_pattern = ISIF_COLPTN_Gb_G << ISIF_CCOLP_CP15_4 | ISIF_COLPTN_B_Mg << ISIF_CCOLP_CP17_6; -static inline u32 isif_read(void *__iomem base_addr, u32 offset) +static inline u32 isif_read(void __iomem *base_addr, u32 offset) { return readl(base_addr + offset); } -static inline void isif_write(void *__iomem base_addr, u32 val, u32 offset) +static inline void isif_write(void __iomem *base_addr, u32 val, u32 offset) { writel(val, base_addr + offset); } -static inline u32 isif_merge(void *__iomem base_addr, u32 mask, u32 val, +static inline u32 isif_merge(void __iomem *base_addr, u32 mask, u32 val, u32 offset) { u32 new_val = (isif_read(base_addr, offset) & ~mask) | (val & mask); @@ -646,7 +646,7 @@ static void isif_config_gain_offset(struct vpfe_isif_device *isif) { struct vpfe_isif_gain_offsets_adj *gain_off_ptr = &isif->isif_cfg.bayer.config_params.gain_offset; - void *__iomem base = isif->isif_cfg.base_addr; + void __iomem *base = isif->isif_cfg.base_addr; u32 val; val = ((gain_off_ptr->gain_sdram_en & 1) << GAIN_SDRAM_EN_SHIFT) | @@ -1991,7 +1991,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev) struct media_entity *me = &sd->entity; static resource_size_t res_len; struct resource *res; - void *__iomem addr; + void __iomem *addr; int status; int i = 0; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.h b/drivers/staging/media/davinci_vpfe/dm365_isif.h index 473fd2cfe350..89e814e9c0d7 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.h +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.h @@ -159,9 +159,9 @@ struct isif_oper_config { struct isif_params_raw bayer; enum isif_data_pack data_pack; struct isif_gain_values isif_gain_params; - void *__iomem base_addr; - void *__iomem linear_tbl0_addr; - void *__iomem linear_tbl1_addr; + void __iomem *base_addr; + void __iomem *linear_tbl0_addr; + void __iomem *linear_tbl1_addr; }; #define ISIF_PAD_SINK 0 diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.h b/drivers/staging/media/davinci_vpfe/dm365_resizer.h index 59a79422b914..93b0f44030aa 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.h +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.h @@ -228,7 +228,7 @@ struct vpfe_resizer_device { struct dm365_resizer_device resizer_a; struct dm365_resizer_device resizer_b; struct resizer_params config; - void *__iomem base_addr; + void __iomem *base_addr; }; int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, -- cgit v1.2.3-59-g8ed1b From 2430454e92860003cb52122fd661177e9eeb6165 Mon Sep 17 00:00:00 2001 From: Mahati Chamarthy Date: Wed, 8 Oct 2014 19:55:16 +0530 Subject: Staging: rtl8723au: include: Remove unused macros This patch removes macros that are never used. Signed-off-by: Mahati Chamarthy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm_debug.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm_debug.h b/drivers/staging/rtl8723au/include/odm_debug.h index 8509a04b6a52..83be5bab9e09 100644 --- a/drivers/staging/rtl8723au/include/odm_debug.h +++ b/drivers/staging/rtl8723au/include/odm_debug.h @@ -104,12 +104,6 @@ RT_PRINTK fmt; \ } -#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ - if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \ - { \ - RT_PRINTK fmt; \ - } - #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ if(!(expr)) { \ printk("Assertion failed! %s at ......\n", #expr); \ @@ -117,21 +111,6 @@ RT_PRINTK fmt; \ ASSERT(false); \ } -#define ODM_dbg_enter() { printk("==> %s\n", __func__); } -#define ODM_dbg_exit() { printk("<== %s\n", __func__); } -#define ODM_dbg_trace(str) { printk("%s:%s\n", __func__, str); } - -#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ - if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel){ \ - int __i; \ - u8 * __ptr = (u8 *)ptr; \ - printk("[ODM] "); \ - printk(title_str); \ - printk(" "); \ - for (__i=0; __i < 6; __i++) \ - printk("%02X%s", __ptr[__i], (__i == 5) ? "" : "-"); \ - printk("\n"); \ - } void ODM_InitDebugSetting23a(struct dm_odm_t *pDM_Odm); -- cgit v1.2.3-59-g8ed1b From 4ecdc381d768eb978b782ccb66c959db7231f2d8 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 10:15:42 +0530 Subject: staging: rtl8723au: core: Replace open coded version with existing hweight function This patch replaces the open coded version with Linux's existing hweight functions. The original version checked each of the low four bits, accumulating and returning the result. Instead, use a mask to select those four bits, and pass the result to hweight8. It also makes the code in this function simpler. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 9f6ce7d071cd..799b9cf63263 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -117,12 +117,7 @@ Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType) u8 Efuse_CalculateWordCnts23a(u8 word_en) { - u8 word_cnts = 0; - if (!(word_en & BIT(0))) word_cnts++; /* 0 : write enable */ - if (!(word_en & BIT(1))) word_cnts++; - if (!(word_en & BIT(2))) word_cnts++; - if (!(word_en & BIT(3))) word_cnts++; - return word_cnts; + return hweight8((~word_en) & 0xf); } /* */ -- cgit v1.2.3-59-g8ed1b From aa21894b3c16d673eb394fc14f445a78cc572cb2 Mon Sep 17 00:00:00 2001 From: Kumari Radha Date: Sat, 4 Oct 2014 00:45:14 +0530 Subject: staging: ft1000: ft1000-pcmcia: Replace printks with netdev_ and dev_ This patch replaces printk(KERN_INFO ... with dev_info and printk(KERN_ERR ... with netdev_err fixing following checkpatch.pl warnings in ft1000_hw.c: WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... Signed-off-by: Kumari Radha Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 44575c78cf0c..9574775ba3b5 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -2154,14 +2154,14 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, if (flarion_ft1000_cnt > 1) { flarion_ft1000_cnt--; - printk(KERN_INFO - "ft1000: This driver can not support more than one instance\n"); + dev_info(&link->dev, + "This driver can not support more than one instance\n"); return NULL; } dev = alloc_etherdev(sizeof(struct ft1000_info)); if (!dev) { - printk(KERN_ERR "ft1000: failed to allocate etherdev\n"); + dev_err(&link->dev, "Failed to allocate etherdev\n"); return NULL; } @@ -2209,17 +2209,17 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, dev->irq = link->irq; dev->base_addr = link->resource[0]->start; if (pcmcia_get_mac_from_cis(link, dev)) { - printk(KERN_ERR "ft1000: Could not read mac address\n"); + netdev_err(dev, "Could not read mac address\n"); goto err_dev; } if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) { - printk(KERN_ERR "ft1000: Could not request_irq\n"); + netdev_err(dev, "Could not request_irq\n"); goto err_dev; } if (request_region(dev->base_addr, 256, dev->name) == NULL) { - printk(KERN_ERR "ft1000: Could not request_region\n"); + netdev_err(dev, "Could not request_region\n"); goto err_irq; } -- cgit v1.2.3-59-g8ed1b From a15dbf99abd0ea9db59749a5cafd7caea84472dc Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Wed, 8 Oct 2014 12:20:23 +0530 Subject: Staging: lustre: Fix checkpatch error: Unnecessary comparison Removed unnecessary comparison against NULL to remove following checkpatch error: ERROR: spaces required around that '!=' Signed-off-by: Tina Johnson Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index e45070d7f219..0311b96a2eeb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1122,7 +1122,7 @@ void ll_put_super(struct super_block *sb) } next = 0; - while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) + while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next))) class_manual_cleanup(obd); if (sbi->ll_flags & LL_SBI_VERBOSE) -- cgit v1.2.3-59-g8ed1b From ef96fdddcd386c88fee1f2078a174943472b615e Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 22:56:44 +0530 Subject: staging: lustre: lustre: llite: use DIV_ROUND_UP The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. Coccinelle script used : // @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/rw26.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 4c77ae8b9350..eac2131e6b85 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -417,7 +417,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, result = iov_iter_get_pages_alloc(iter, &pages, count, &offs); if (likely(result > 0)) { - int n = (result + offs + PAGE_SIZE - 1) / PAGE_SIZE; + int n = DIV_ROUND_UP(result + offs, PAGE_SIZE); result = ll_direct_IO_26_seg(env, io, rw, inode, file->f_mapping, result, file_offset, -- cgit v1.2.3-59-g8ed1b From 7489df369598abef03f22ff97b1e2bfb044f1d02 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sun, 5 Oct 2014 10:33:56 +0200 Subject: staging: wlan-ng: add blank lines after declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes "missing blank line after declaration" warnings by checkpatch.pl Signed-off-by: Veronika Kabátová Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 1f2c78cc0086..20d146b61ba7 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1376,6 +1376,7 @@ int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len); static inline int hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val) { int result = 0; + result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16)); if (result == 0) *((u16 *) val) = le16_to_cpu(*((u16 *) val)); @@ -1385,6 +1386,7 @@ static inline int hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val) static inline int hfa384x_drvr_setconfig16(hfa384x_t *hw, u16 rid, u16 val) { u16 value = cpu_to_le16(val); + return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value)); } @@ -1402,6 +1404,7 @@ static inline int hfa384x_drvr_setconfig16_async(hfa384x_t *hw, u16 rid, u16 val) { u16 value = cpu_to_le16(val); + return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value), NULL, NULL); } -- cgit v1.2.3-59-g8ed1b From fb282bcd9c957387097cde370905784993281df6 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Sat, 4 Oct 2014 02:30:35 +0300 Subject: staging: wlan-ng: remove unnecessary 'out of memory' message This patch fixes "Possible unnecessary 'out of memory' message" checkpatch.pl warning in hfa384x_usb.c Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 898bde73c59a..55d2f563e308 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -3583,12 +3583,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, } skb = dev_alloc_skb(skblen); - if (skb == NULL) { - netdev_err(hw->wlandev->netdev, - "alloc_skb failed trying to allocate %d bytes\n", - skblen); + if (skb == NULL) return; - } /* only prepend the prism header if in the right mode */ if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) && -- cgit v1.2.3-59-g8ed1b From 8e4ec4fe040861b69fcb2c60394355f0c600e38f Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 6 Oct 2014 11:26:39 +0530 Subject: staging: android: ion: Replace "the the " with "the" This patch replace "the the " with "the". The replacement couldn't be automated because sometimes the first "the" was meant to be another word. Signed-off-by: Tapasweni Pathak Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 56604f41ec48..290d4d22c102 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -902,7 +902,7 @@ void ion_pages_sync_for_device(struct device *dev, struct page *page, sg_set_page(&sg, page, size, 0); /* * This is not correct - sg_dma_address needs a dma_addr_t that is valid - * for the the targeted device, but this works on the currently targeted + * for the targeted device, but this works on the currently targeted * hardware. */ sg_dma_address(&sg) = page_to_phys(page); -- cgit v1.2.3-59-g8ed1b From 2ff6179f162b205fc98bb2083b653f46c52d6642 Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Sun, 5 Oct 2014 01:05:57 +0300 Subject: staging: vt6656: remove unnecessary 'out of memory' message This patch fixes "Possible unnecessary 'out of memory' message" checkpatch.pl warning in main_usb.c Signed-off-by: Melike Yurtoglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 2fbff907ce8a..04ae6a22f138 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -431,11 +431,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) for (ii = 0; ii < priv->num_tx_context; ii++) { tx_context = kmalloc(sizeof(struct vnt_usb_send_context), GFP_KERNEL); - if (tx_context == NULL) { - dev_err(&priv->usb->dev, - "allocate tx usb context failed\n"); + if (tx_context == NULL) goto free_tx; - } priv->tx_context[ii] = tx_context; tx_context->priv = priv; @@ -471,10 +468,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) } rcb->skb = dev_alloc_skb(priv->rx_buf_sz); - if (rcb->skb == NULL) { - dev_err(&priv->usb->dev, "Failed to alloc rx skb\n"); + if (rcb->skb == NULL) goto free_rx_tx; - } rcb->in_use = false; @@ -491,7 +486,6 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); if (priv->int_buf.data_buf == NULL) { - dev_err(&priv->usb->dev, "Failed to alloc int buf\n"); usb_free_urb(priv->interrupt_urb); goto free_rx_tx; } -- cgit v1.2.3-59-g8ed1b From ca5dd0b83da6132a85b3c384eb0504a2c9cfd008 Mon Sep 17 00:00:00 2001 From: Heena Sirwani Date: Mon, 6 Oct 2014 10:19:09 +0530 Subject: Staging: dgnc: Compress two lines of code into one. The following patch merges two lines of code into one using coccinelle and removes unused variables. The semantic patch used is as follows: @@ expression ret; identifier f; @@ -ret = +return f(...); -return ret; Signed-off-by: Heena Sirwani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index a17f4f6095c8..f0b1ec7847e7 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -964,7 +964,6 @@ static int cls_drain(struct tty_struct *tty, uint seconds) unsigned long flags; struct channel_t *ch; struct un_t *un; - int rc = 0; if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; @@ -984,12 +983,11 @@ static int cls_drain(struct tty_struct *tty, uint seconds) /* * NOTE: Do something with time passed in. */ - rc = wait_event_interruptible(un->un_flags_wait, - ((un->un_flags & UN_EMPTY) == 0)); /* If ret is non-zero, user ctrl-c'ed us */ - return rc; + return wait_event_interruptible(un->un_flags_wait, + ((un->un_flags & UN_EMPTY) == 0)); } -- cgit v1.2.3-59-g8ed1b From 1f26adc94a9f11440f4756e41b2f572afde61f5e Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Tue, 7 Oct 2014 13:08:12 +0300 Subject: staging: dgnc: Remove non-standard APR/RAPR printing macros This patch removes non-standard macros used by dgnc driver for printing error or debugging messages. These are replaced by dev_err/dev_dbg (when possible) or pr_err. There were cases where the message is completely removed since is not adding any useful information. Signed-off-by: Roberta Dobrescu Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 18 ++++-------------- drivers/staging/dgnc/dgnc_driver.c | 20 +++++++++----------- drivers/staging/dgnc/dgnc_driver.h | 15 ++------------- drivers/staging/dgnc/dgnc_neo.c | 25 +++++++++---------------- drivers/staging/dgnc/dgnc_tty.c | 15 +++++++++++---- 5 files changed, 35 insertions(+), 58 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index f0b1ec7847e7..c1c4bb9b0354 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -724,10 +724,8 @@ static void cls_tasklet(unsigned long data) int state = 0; int ports = 0; - if (!bd || bd->magic != DGNC_BOARD_MAGIC) { - APR(("poll_tasklet() - NULL or bad bd.\n")); + if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - } /* Cache a couple board values */ spin_lock_irqsave(&bd->bd_lock, flags); @@ -799,20 +797,12 @@ static irqreturn_t cls_intr(int irq, void *voidbrd) unsigned char poll_reg; unsigned long flags; - if (!brd) { - APR(("Received interrupt (%d) with null board associated\n", - irq)); - return IRQ_NONE; - } - /* - * Check to make sure its for us. + * Check to make sure it didn't receive interrupt with a null board + * associated or a board pointer that wasn't ours. */ - if (brd->magic != DGNC_BOARD_MAGIC) { - APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", - irq)); + if (!brd || brd->magic != DGNC_BOARD_MAGIC) return IRQ_NONE; - } spin_lock_irqsave(&brd->bd_intr_lock, flags); diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 21546659ff07..0eafd1f35a82 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -207,8 +207,6 @@ static int __init dgnc_init_module(void) { int rc = 0; - APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART)); - /* * Initialize global stuff */ @@ -254,8 +252,6 @@ static int dgnc_start(void) /* make sure that the globals are init'd before we do anything else */ dgnc_init_globals(); - APR(("For the tools package or updated drivers please visit http://www.digi.com\n")); - /* * Register our base character device into the kernel. * This allows the download daemon to connect to the downld device @@ -265,7 +261,7 @@ static int dgnc_start(void) */ rc = register_chrdev(0, "dgnc", &dgnc_BoardFops); if (rc <= 0) { - APR(("Can't register dgnc driver device (%d)\n", rc)); + pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc); return -ENXIO; } dgnc_Major = rc; @@ -281,7 +277,7 @@ static int dgnc_start(void) rc = dgnc_tty_preinit(); if (rc < 0) { - APR(("tty preinit - not enough memory (%d)\n", rc)); + pr_err(DRVSTR ": tty preinit - not enough memory (%d)\n", rc); return rc; } @@ -468,7 +464,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->membase = pci_resource_start(pdev, 4); if (!brd->membase) { - APR(("card has no PCI IO resources, failing board.\n")); + dev_err(&brd->pdev->dev, + "Card has no PCI IO resources, failing.\n"); return -ENODEV; } @@ -555,7 +552,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) break; default: - APR(("Did not find any compatible Neo or Classic PCI boards in system.\n")); + dev_err(&brd->pdev->dev, + "Didn't find any compatible Neo/Classic PCI boards.\n"); return -ENXIO; } @@ -567,7 +565,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) rc = dgnc_tty_register(brd); if (rc < 0) { dgnc_tty_uninit(brd); - APR(("Can't register tty devices (%d)\n", rc)); + pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc); brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; goto failed; @@ -575,7 +573,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) rc = dgnc_finalize_board_init(brd); if (rc < 0) { - APR(("Can't finalize board init (%d)\n", rc)); + pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc); brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; @@ -585,7 +583,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) rc = dgnc_tty_init(brd); if (rc < 0) { dgnc_tty_uninit(brd); - APR(("Can't init tty devices (%d)\n", rc)); + pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc); brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index f901957c757f..d5de3e2f2945 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -42,21 +42,10 @@ * *************************************************************************/ -/* - * Driver identification, error and debugging statments - * - * In theory, you can change all occurrences of "digi" in the next - * three lines, and the driver printk's will all automagically change. - * - * APR((fmt, args, ...)); Always prints message - */ +/* Driver identification, error and debugging statments */ #define PROCSTR "dgnc" /* /proc entries */ #define DEVSTR "/dev/dg/dgnc" /* /dev entries */ -#define DRVSTR "dgnc" /* Driver name string - * displayed by APR */ -#define APR(args) do { printk(DRVSTR": "); printk args; \ - } while (0) -#define RAPR(args) do { printk args; } while (0) +#define DRVSTR "dgnc" /* Driver name string */ #define TRC_TO_CONSOLE 1 diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index a5bd08fef270..27a525ead878 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -530,10 +530,11 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port) int linestatus; unsigned long flags; - if (!brd) - return; - - if (brd->magic != DGNC_BOARD_MAGIC) + /* + * Check to make sure it didn't receive interrupt with a null board + * associated or a board pointer that wasn't ours. + */ + if (!brd || brd->magic != DGNC_BOARD_MAGIC) return; if (port > brd->maxports) @@ -869,10 +870,8 @@ static void neo_tasklet(unsigned long data) int state = 0; int ports = 0; - if (!bd || bd->magic != DGNC_BOARD_MAGIC) { - APR(("poll_tasklet() - NULL or bad bd.\n")); + if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - } /* Cache a couple board values */ spin_lock_irqsave(&bd->bd_lock, flags); @@ -955,18 +954,12 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) unsigned long flags; unsigned long flags2; - if (!brd) { - APR(("Received interrupt (%d) with null board associated\n", irq)); - return IRQ_NONE; - } - /* - * Check to make sure its for us. + * Check to make sure it didn't receive interrupt with a null board + * associated or a board pointer that wasn't ours. */ - if (brd->magic != DGNC_BOARD_MAGIC) { - APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", irq)); + if (!brd || brd->magic != DGNC_BOARD_MAGIC) return IRQ_NONE; - } brd->intr_count++; diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 03c15069731f..1580bccc6a2d 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -233,7 +233,8 @@ int dgnc_tty_register(struct dgnc_board *brd) /* Register tty devices */ rc = tty_register_driver(&brd->SerialDriver); if (rc < 0) { - APR(("Can't register tty device (%d)\n", rc)); + dev_dbg(&brd->pdev->dev, + "Can't register tty device (%d)\n", rc); return rc; } brd->dgnc_Major_Serial_Registered = TRUE; @@ -281,7 +282,9 @@ int dgnc_tty_register(struct dgnc_board *brd) /* Register Transparent Print devices */ rc = tty_register_driver(&brd->PrintDriver); if (rc < 0) { - APR(("Can't register Transparent Print device (%d)\n", rc)); + dev_dbg(&brd->pdev->dev, + "Can't register Transparent Print device(%d)\n", + rc); return rc; } brd->dgnc_Major_TransparentPrint_Registered = TRUE; @@ -1546,14 +1549,18 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) * 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)); + dev_dbg(tty->dev, + "tty->count is 1, un open count is %d\n", + un->un_open_count); un->un_open_count = 1; } if (un->un_open_count) un->un_open_count--; else - APR(("bad serial port open count of %d\n", un->un_open_count)); + dev_dbg(tty->dev, + "bad serial port open count of %d\n", + un->un_open_count); ch->ch_open_count--; -- cgit v1.2.3-59-g8ed1b From feba47a74d21c8a9f31e1d6e7f60802bb3807246 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 13:49:51 +0300 Subject: staging: dgnc: Remove space before tabs This patch fixes the warning of "Please, no space before tab" produced by checkpatch.pl. The modified file: dgnc_tty.c Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 1580bccc6a2d..b0fcbe7bdfe4 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -3096,7 +3096,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, struct digi_getcounter buf; buf.norun = ch->ch_err_overrun; - buf.noflow = 0; /* The driver doesn't keep this stat */ + buf.noflow = 0; /* The driver doesn't keep this stat */ buf.nframe = ch->ch_err_frame; buf.nparity = ch->ch_err_parity; buf.nbreak = ch->ch_err_break; -- cgit v1.2.3-59-g8ed1b From 399521341942bf7458302c23ef5736be4501ef49 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Tue, 7 Oct 2014 15:26:23 +0300 Subject: staging: gdm724x: Fix warning of prefer ether_addr_copy. This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file gdm_lte.c Pahole shows that the addresses are aligned. Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index c657639f884b..73eede163820 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -626,7 +626,7 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf, void *addr = buf + sizeof(struct iphdr) + sizeof(struct udphdr) + offsetof(struct dhcp_packet, chaddr); - memcpy(nic->dest_mac_addr, addr, ETH_ALEN); + ether_addr_copy(nic->dest_mac_addr, addr); } } @@ -639,7 +639,7 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf, } /* Format the data so that it can be put to skb */ - memcpy(mac_header_data, nic->dest_mac_addr, ETH_ALEN); + ether_addr_copy(mac_header_data, nic->dest_mac_addr); memcpy(mac_header_data + ETH_ALEN, nic->src_mac_addr, ETH_ALEN); vlan_eth.h_vlan_TCI = htons(nic->vlan_id); @@ -842,9 +842,9 @@ static void form_mac_address(u8 *dev_addr, u8 *nic_src, u8 *nic_dest, { /* Form the dev_addr */ if (!mac_address) - memcpy(dev_addr, gdm_lte_macaddr, ETH_ALEN); + ether_addr_copy(dev_addr, gdm_lte_macaddr); else - memcpy(dev_addr, mac_address, ETH_ALEN); + ether_addr_copy(dev_addr, mac_address); /* The last byte of the mac address * should be less than or equal to 0xFC @@ -858,7 +858,7 @@ static void form_mac_address(u8 *dev_addr, u8 *nic_src, u8 *nic_dest, memcpy(nic_src, dev_addr, 3); /* Copy the nic_dest from dev_addr*/ - memcpy(nic_dest, dev_addr, ETH_ALEN); + ether_addr_copy(nic_dest, dev_addr); } static void validate_mac_address(u8 *mac_address) -- cgit v1.2.3-59-g8ed1b From 48131a6bda18d65a6c63de1e6c54dcf40eb6057c Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Tue, 7 Oct 2014 11:41:08 +0300 Subject: staging: gdm724x: Fix incorrect type in assignment This patch fixes following sparse warnings: drivers/staging/gdm724x/gdm_mux.c:389:32: warning: incorrect type in assignment (different base types) drivers/staging/gdm724x/gdm_mux.c:389:32: expected unsigned int [unsigned] start_flag drivers/staging/gdm724x/gdm_mux.c:389:32: got restricted __le32 [usertype] drivers/staging/gdm724x/gdm_mux.c:391:34: warning: incorrect type in assignment (different base types) drivers/staging/gdm724x/gdm_mux.c:391:34: expected unsigned int [unsigned] payload_size drivers/staging/gdm724x/gdm_mux.c:391:34: got restricted __le32 [usertype] drivers/staging/gdm724x/gdm_mux.c:392:33: warning: incorrect type in assignment (different base types) drivers/staging/gdm724x/gdm_mux.c:392:33: expected unsigned short [unsigned] packet_type drivers/staging/gdm724x/gdm_mux.c:392:33: got restricted __le16 [usertype] Sparse found above warnings, so this patch changes variable types of structs. Because expected and got variable types are different. Signed-off-by: Ebru Akagunduz Reviewed-by: Octavian Purdila Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_mux.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h index 0163b243d3e0..3d50383c6ced 100644 --- a/drivers/staging/gdm724x/gdm_mux.h +++ b/drivers/staging/gdm724x/gdm_mux.h @@ -35,10 +35,10 @@ #define RETRY_TIMER 30 /* msec */ struct mux_pkt_header { - unsigned int start_flag; - unsigned int seq_num; - unsigned int payload_size; - unsigned short packet_type; + __le32 start_flag; + __le32 seq_num; + __le32 payload_size; + __le16 packet_type; unsigned char data[0]; }; -- cgit v1.2.3-59-g8ed1b From 35b042a550e727cdc32a5d0a146ea5947b6a1c53 Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Mon, 6 Oct 2014 00:25:51 +0530 Subject: staging: gdm72xx: Removed unnecesarry out of memory usage WARNING: Possible unnecessary out of memory usage checkpatch.pl warning in gdm_wimax.c Signed-off-by: Sarah Khan Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_wimax.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index f5a3378c3951..5b7747f6b847 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -605,10 +605,8 @@ static void gdm_wimax_netif_rx(struct net_device *dev, char *buf, int len) int ret; skb = dev_alloc_skb(len + 2); - if (!skb) { - netdev_err(dev, "%s: dev_alloc_skb failed!\n", __func__); + if (!skb) return; - } skb_reserve(skb, 2); dev->stats.rx_packets++; -- cgit v1.2.3-59-g8ed1b From d8ad8b0cad4cb9596b751a2dc10ff7559cee721c Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Wed, 8 Oct 2014 03:59:55 +0200 Subject: staging: unisys: Remove typedef and rename enum to lowercase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove typedef and rename enum to lowercase (control_vm_id) Signed-off-by: Veronika Kabátová Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 6 +++--- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset.h | 8 ++++---- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index cfd99997cfee..f7ca6d167d60 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -88,7 +88,7 @@ static const uuid_le UltraControlvmChannelProtocolGuid = * - issued on the EventQueue queue (q #2) in the ControlVm channel * - responded to on the EventAckQueue queue (q #3) in the ControlVm channel */ -typedef enum { +enum control_vm_id { CONTROLVM_INVALID = 0, /* SWITCH commands required Parameter: SwitchNumber */ /* BUS commands required Parameter: BusNumber */ @@ -117,7 +117,7 @@ typedef enum { CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */ CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */ -} CONTROLVM_ID; +}; struct irq_info { /**< specifies interrupt info. It is used to send interrupts @@ -239,7 +239,7 @@ typedef enum { * looking at the flags.response field. */ typedef struct _CONTROLVM_MESSAGE_HEADER { - u32 Id; /* See CONTROLVM_ID. */ + u32 Id; /* See control_vm_id. */ /* For requests, indicates the message type. */ /* For responses, indicates the type of message we are responding to. */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 677ed7e609af..f8ffa0263e29 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -155,7 +155,7 @@ u64 uislib_storage_channel(int client_id); #endif int uislib_get_owned_pdest(struct uisscsi_dest *pdest); -int uislib_send_event(CONTROLVM_ID id, CONTROLVM_MESSAGE_PACKET *event); +int uislib_send_event(enum control_vm_id id, CONTROLVM_MESSAGE_PACKET *event); /* structure used by vhba & vnic to keep track of queue & thread info */ struct chaninfo { diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 23834765a468..cb93da931f75 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -82,7 +82,7 @@ typedef struct { uuid_le devInstGuid; VISORCHIPSET_STATE state; VISORCHIPSET_CHANNEL_INFO chanInfo; - u32 Reserved1; /* CONTROLVM_ID */ + u32 Reserved1; /* control_vm_id */ u64 Reserved2; u32 switchNo; /* when devState.attached==1 */ u32 internalPortNo; /* when devState.attached==1 */ @@ -169,7 +169,7 @@ typedef struct { u8 *authService3; u8 *securityContext; u64 Reserved; - u32 Reserved2; /* CONTROLVM_ID */ + u32 Reserved2; /* control_vm_id */ struct device dev; BOOL dev_exists; CONTROLVM_MESSAGE_HEADER pendingMsgHdr; @@ -192,7 +192,7 @@ typedef struct { u8 *ipGateway; u8 *ipDNS; u64 Reserved1; - u32 Reserved2; /* CONTROLVM_ID */ + u32 Reserved2; /* control_vm_id */ struct device dev; BOOL dev_exists; CONTROLVM_MESSAGE_HEADER pendingMsgHdr; @@ -209,7 +209,7 @@ typedef struct { u32 busNo; /* valid only when state.attached == 1 */ u32 devNo; /* valid only when state.attached == 1 */ u64 Reserved1; - u32 Reserved2; /* CONTROLVM_ID */ + u32 Reserved2; /* control_vm_id */ CONTROLVM_MESSAGE_HEADER pendingMsgHdr; MYPROCOBJECT *procObject; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 320124a240ac..ee03c59dc889 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -817,7 +817,7 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type) EXPORT_SYMBOL_GPL(visorchipset_save_message); static void -bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response) +bus_responder(enum control_vm_id cmdId, ulong busNo, int response) { VISORCHIPSET_BUS_INFO *p = NULL; BOOL need_clear = FALSE; @@ -856,7 +856,7 @@ bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response) } static void -device_changestate_responder(CONTROLVM_ID cmdId, +device_changestate_responder(enum control_vm_id cmdId, ulong busNo, ulong devNo, int response, struct ultra_segment_state responseState) { @@ -893,7 +893,7 @@ device_changestate_responder(CONTROLVM_ID cmdId, } static void -device_responder(CONTROLVM_ID cmdId, ulong busNo, ulong devNo, int response) +device_responder(enum control_vm_id cmdId, ulong busNo, ulong devNo, int response) { VISORCHIPSET_DEVICE_INFO *p = NULL; BOOL need_clear = FALSE; -- cgit v1.2.3-59-g8ed1b From 3830d03dee563f95833801b6c72a596f5fb3aa4e Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Wed, 8 Oct 2014 03:47:35 +0200 Subject: staging: unisys: Union ULTRA_COMPONENT_VERSION not used, removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unused union ULTRA_COMPONENT_VERSION Signed-off-by: Veronika Kabátová Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlframework.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index bbcf5ac4f0b7..e718557f1c20 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -63,15 +63,5 @@ static const struct ultra_segment_state SegmentStatePaused = { static const struct ultra_segment_state SegmentStateStandby = { 1, 1, 0, 0, 1, 1, 1, 0 }; -typedef union { - u64 Full; - struct { - u8 Major; /* will be 1 for the first release and - * increment thereafter */ - u8 Minor; - u16 Maintenance; - u32 Revision; /* Subversion revision */ - } Part; -} ULTRA_COMPONENT_VERSION; #endif /* _CONTROL_FRAMEWORK_H_ not defined */ -- cgit v1.2.3-59-g8ed1b From a7a4f87e3c7462ec70533e78ad2bce19d158e9d7 Mon Sep 17 00:00:00 2001 From: Kumari Radha Date: Wed, 8 Oct 2014 14:48:44 +0530 Subject: staging: vme: devices: Added a paragraph to describe Kconfig symbol This patch adds module name information about config symbol fixing the following checkpatch.pl warning in Kconfig: WARNING: please write a paragraph that describes the config symbol fully Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/vme/devices/Kconfig b/drivers/staging/vme/devices/Kconfig index 8e8bbb1dcd9b..1d2ff0cc41f1 100644 --- a/drivers/staging/vme/devices/Kconfig +++ b/drivers/staging/vme/devices/Kconfig @@ -8,6 +8,9 @@ config VME_USER VME windows in a manner at least semi-compatible with the interface provided with the original driver at . + To compile this driver as a module, choose M here. The module will + be called vme_user. If unsure, say N. + config VME_PIO2 tristate "GE PIO2 VME" depends on STAGING && GPIOLIB -- cgit v1.2.3-59-g8ed1b From f999ac00c76f998b5ef861a599c72fb4572dc9c0 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Tue, 7 Oct 2014 02:50:28 +0300 Subject: staging: slicoss: Fix warning of prefer ether_addr_copy(). This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file slicoss.c Pahole shows that the addresses are aligned. Signed-off-by: Dilek Uzulmez 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 56ca3b6c1444..f48eeb168e0b 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1788,7 +1788,7 @@ static int slic_mcast_add_list(struct adapter *adapter, char *address) if (mcaddr == NULL) return 1; - memcpy(mcaddr->address, address, ETH_ALEN); + ether_addr_copy(mcaddr->address, address); mcaddr->next = adapter->mcastaddrs; adapter->mcastaddrs = mcaddr; -- cgit v1.2.3-59-g8ed1b From 646da830fd61a74947581b3675e1919361f16cd2 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 20:41:26 +0530 Subject: staging: rtl8712: Remove unnecessary cast for argument of kfree This patch removes all occurrences of unnecessary cast on the argument to kfree, all over in rtl8712. There is no need of the cast on the argument to kfree. Greped to find occurrences. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 54 +++++++++++++-------------- drivers/staging/rtl8712/rtl871x_io.c | 4 +- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 +- drivers/staging/rtl8712/rtl871x_mlme.c | 4 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 5aae4cce8477..92101b98c49a 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -205,12 +205,12 @@ void r8712_free_cmd_obj(struct cmd_obj *pcmd) { if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) - kfree((unsigned char *)pcmd->parmbuf); + kfree(pcmd->parmbuf); if (pcmd->rsp != NULL) { if (pcmd->rspsz != 0) - kfree((unsigned char *)pcmd->rsp); + kfree(pcmd->rsp); } - kfree((unsigned char *)pcmd); + kfree(pcmd); } /* @@ -232,7 +232,7 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, return _FAIL; psurveyPara = kmalloc(sizeof(*psurveyPara), GFP_ATOMIC); if (psurveyPara == NULL) { - kfree((unsigned char *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, @@ -264,7 +264,7 @@ u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) return _FAIL; pbsetdataratepara = kmalloc(sizeof(*pbsetdataratepara), GFP_ATOMIC); if (pbsetdataratepara == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, @@ -286,7 +286,7 @@ u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) return _FAIL; psetchplanpara = kmalloc(sizeof(*psetchplanpara), GFP_ATOMIC); if (psetchplanpara == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetchplanpara, @@ -307,7 +307,7 @@ u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) return _FAIL; pssetbasicratepara = kmalloc(sizeof(*pssetbasicratepara), GFP_ATOMIC); if (pssetbasicratepara == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, @@ -329,7 +329,7 @@ u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type) return _FAIL; pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC); if (pwriteptmparm == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetPT)); @@ -349,7 +349,7 @@ u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type) return _FAIL; pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC); if (pwriteptmparm == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetDIG)); @@ -369,7 +369,7 @@ u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type) return _FAIL; pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC); if (pwriteptmparm == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetRA)); @@ -389,7 +389,7 @@ u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) return _FAIL; pwriterfparm = kmalloc(sizeof(*pwriterfparm), GFP_ATOMIC); if (pwriterfparm == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg)); @@ -410,7 +410,7 @@ u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) return _FAIL; prdrfparm = kmalloc(sizeof(*prdrfparm), GFP_ATOMIC); if (prdrfparm == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } INIT_LIST_HEAD(&ph2c->list); @@ -626,7 +626,7 @@ u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ return _FAIL; pdisconnect = kmalloc(sizeof(*pdisconnect), GFP_ATOMIC); if (pdisconnect == NULL) { - kfree((u8 *)pdisconnect_cmd); + kfree(pdisconnect_cmd); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect, @@ -648,7 +648,7 @@ u8 r8712_setopmode_cmd(struct _adapter *padapter, return _FAIL; psetop = kmalloc(sizeof(*psetop), GFP_ATOMIC); if (psetop == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); @@ -672,13 +672,13 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) return _FAIL; psetstakey_para = kmalloc(sizeof(*psetstakey_para), GFP_ATOMIC); if (psetstakey_para == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } psetstakey_rsp = kmalloc(sizeof(*psetstakey_rsp), GFP_ATOMIC); if (psetstakey_rsp == NULL) { - kfree((u8 *) ph2c); - kfree((u8 *) psetstakey_para); + kfree(ph2c); + kfree(psetstakey_para); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); @@ -712,7 +712,7 @@ u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode) return _FAIL; psetrfintfsparm = kmalloc(sizeof(*psetrfintfsparm), GFP_ATOMIC); if (psetrfintfsparm == NULL) { - kfree((unsigned char *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetrfintfsparm, @@ -734,7 +734,7 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter, return _FAIL; psetrttblparm = kmalloc(sizeof(*psetrttblparm), GFP_ATOMIC); if (psetrttblparm == NULL) { - kfree((unsigned char *)ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, @@ -755,7 +755,7 @@ u8 r8712_gettssi_cmd(struct _adapter *padapter, u8 offset, u8 *pval) return _FAIL; prdtssiparm = kmalloc(sizeof(*prdtssiparm), GFP_ATOMIC); if (prdtssiparm == NULL) { - kfree((unsigned char *) ph2c); + kfree(ph2c); return _FAIL; } INIT_LIST_HEAD(&ph2c->list); @@ -781,7 +781,7 @@ u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) return _FAIL; psetMacAddr_para = kmalloc(sizeof(*psetMacAddr_para), GFP_ATOMIC); if (psetMacAddr_para == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para, @@ -803,13 +803,13 @@ u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr) return _FAIL; psetassocsta_para = kmalloc(sizeof(*psetassocsta_para), GFP_ATOMIC); if (psetassocsta_para == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); return _FAIL; } psetassocsta_rsp = kmalloc(sizeof(*psetassocsta_rsp), GFP_ATOMIC); if (psetassocsta_rsp == NULL) { - kfree((u8 *)ph2c); - kfree((u8 *)psetassocsta_para); + kfree(ph2c); + kfree(psetassocsta_para); return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_); @@ -831,7 +831,7 @@ u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) return _FAIL; paddbareq_parm = kmalloc(sizeof(*paddbareq_parm), GFP_ATOMIC); if (paddbareq_parm == NULL) { - kfree((unsigned char *)ph2c); + kfree(ph2c); return _FAIL; } paddbareq_parm->tid = tid; @@ -852,7 +852,7 @@ u8 r8712_wdg_wk_cmd(struct _adapter *padapter) return _FAIL; pdrvintcmd_param = kmalloc(sizeof(*pdrvintcmd_param), GFP_ATOMIC); if (pdrvintcmd_param == NULL) { - kfree((unsigned char *)ph2c); + kfree(ph2c); return _FAIL; } pdrvintcmd_param->i_cid = WDG_WK_CID; @@ -1026,7 +1026,7 @@ u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, return _FAIL; param = kzalloc(sizeof(*param), GFP_ATOMIC); if (param == NULL) { - kfree((unsigned char *) ph2c); + kfree(ph2c); return _FAIL; } diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c index 3a0236606396..e4e5b13cb927 100644 --- a/drivers/staging/rtl8712/rtl871x_io.c +++ b/drivers/staging/rtl8712/rtl871x_io.c @@ -142,7 +142,7 @@ uint r8712_alloc_io_queue(struct _adapter *adapter) alloc_io_queue_fail: if (pio_queue) { kfree(pio_queue->pallocated_free_ioreqs_buf); - kfree((u8 *)pio_queue); + kfree(pio_queue); } adapter->pio_queue = NULL; return _FAIL; @@ -156,6 +156,6 @@ void r8712_free_io_queue(struct _adapter *adapter) kfree(pio_queue->pallocated_free_ioreqs_buf); adapter->pio_queue = NULL; unregister_intf_hdl(&pio_queue->intf); - kfree((u8 *)pio_queue); + kfree(pio_queue); } } diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 8e42ce06e5d7..b4ffc0e31110 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -505,7 +505,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, } } exit: - kfree((u8 *)pwep); + kfree(pwep); return ret; } @@ -2216,7 +2216,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) } if (ret == 0 && copy_to_user(p->pointer, param, p->length)) ret = -EFAULT; - kfree((u8 *)param); + kfree(param); return ret; } diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 00f2e0fc4ac5..4b602fe1dba1 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -923,7 +923,7 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) ignore_joinbss_callback: spin_unlock_irqrestore(&pmlmepriv->lock, irqL); if (sizeof(struct list_head) == 4 * sizeof(u32)) - kfree((u8 *)pnetwork); + kfree(pnetwork); } void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf) @@ -1218,7 +1218,7 @@ sint r8712_set_auth(struct _adapter *adapter, psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC); if (psetauthparm == NULL) { - kfree((unsigned char *)pcmd); + kfree(pcmd); return _FAIL; } psetauthparm->mode = (u8)psecuritypriv->AuthAlgrthm; -- cgit v1.2.3-59-g8ed1b From ad96f37f06596c6a7bd4dae3cf364bbb4ab7d7a4 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 23:33:40 +0530 Subject: staging: wlan-ng: replace kmalloc and memset with kzalloc Replace kmalloc and memset with a single call of kzalloc in file of wlan-ng. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index 6c38f797d1ab..e907380f9163 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -986,8 +986,8 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, u32 currlen; u32 currdaddr; - rstmsg = kmalloc(sizeof(*rstmsg), GFP_KERNEL); - rwrmsg = kmalloc(sizeof(*rwrmsg), GFP_KERNEL); + rstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL); + rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL); if (!rstmsg || !rwrmsg) { kfree(rstmsg); kfree(rwrmsg); @@ -997,7 +997,6 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, } /* Initialize the messages */ - memset(rstmsg, 0, sizeof(*rstmsg)); strcpy(rstmsg->devname, wlandev->name); rstmsg->msgcode = DIDmsg_p2req_ramdl_state; rstmsg->msglen = sizeof(*rstmsg); @@ -1011,7 +1010,6 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, rstmsg->exeaddr.len = sizeof(u32); rstmsg->resultcode.len = sizeof(u32); - memset(rwrmsg, 0, sizeof(*rwrmsg)); strcpy(rwrmsg->devname, wlandev->name); rwrmsg->msgcode = DIDmsg_p2req_ramdl_write; rwrmsg->msglen = sizeof(*rwrmsg); -- cgit v1.2.3-59-g8ed1b From 146ea83566881aecb68dbf15e30a1c945116d1c4 Mon Sep 17 00:00:00 2001 From: Esra Altintas Date: Wed, 8 Oct 2014 14:32:10 +0300 Subject: staging: speakup: Use time_after_eq to compare jiffies in speakup_keypc.c The following patch fixes the checkpatch.pl warning: WARNING: Comparing jiffies is almost always wrong; prefer time_after, time_before and friends Signed-off-by: Esra Altintas Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/speakup_keypc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/speakup_keypc.c b/drivers/staging/speakup/speakup_keypc.c index 4ed38898a17a..cef20fdda646 100644 --- a/drivers/staging/speakup/speakup_keypc.c +++ b/drivers/staging/speakup/speakup_keypc.c @@ -229,7 +229,7 @@ spin_lock_irqsave(&speakup_info.spinlock, flags); ch = PROCSPEECH; outb_p(ch, synth_port); SWAIT; - if ((jiffies >= jiff_max) && (ch == SPACE)) { + if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { timeout = 1000; while (synth_writable()) if (--timeout <= 0) -- cgit v1.2.3-59-g8ed1b From 583bea6c40fa281a6735a717d1855f31f2c6b187 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 22:55:45 +0530 Subject: staging: comedi: use DIV_ROUND_UP The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. Coccinelle script used : // @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 3e5bccbc9c39..859b722188cc 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -317,8 +317,7 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) case COMEDI_SUBD_DO: case COMEDI_SUBD_DIO: bits_per_sample = 8 * bytes_per_sample(s); - num_samples = (cmd->chanlist_len + bits_per_sample - 1) / - bits_per_sample; + num_samples = DIV_ROUND_UP(cmd->chanlist_len, bits_per_sample); break; default: num_samples = cmd->chanlist_len; -- cgit v1.2.3-59-g8ed1b From 97996da1787d55cda95fd4209a4affbef9346c53 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 22:56:01 +0530 Subject: staging: comedi: drivers: use DIV_ROUND_UP The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. Coccinelle script used : // @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 0e7621e890c3..bc0745058057 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1976,7 +1976,7 @@ static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags) divider = (*nanosec) / base; break; case CMDF_ROUND_UP: - divider = (*nanosec + base - 1) / base; + divider = DIV_ROUND_UP(*nanosec, base); break; } -- cgit v1.2.3-59-g8ed1b From ffceca8c1739938b58cdc5ce375d33a13150f7af Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 22:56:15 +0530 Subject: staging: iio: adc: use DIV_ROUND_UP The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. Coccinelle script used : // @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/spear_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index c5492ba50751..67a364c2e794 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -98,7 +98,7 @@ static void spear_adc_set_clk(struct spear_adc_state *st, u32 val) u32 clk_high, clk_low, count; u32 apb_clk = clk_get_rate(st->clk); - count = (apb_clk + val - 1) / val; + count = DIV_ROUND_UP(apb_clk, val); clk_low = count / 2; clk_high = count - clk_low; st->current_clk = apb_clk / count; -- cgit v1.2.3-59-g8ed1b From dea7503ac4c53edfd0d25d6a1c8b360b3db700d7 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 22:56:57 +0530 Subject: staging: octeon-usb: use DIV_ROUND_UP The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. Coccinelle script used : // @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 6ddde6af7e3a..7ac64efc6520 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -743,7 +743,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, * such that USB is as close as possible to 125Mhz */ { - int divisor = (octeon_get_clock_rate()+125000000-1)/125000000; + int divisor = DIV_ROUND_UP(octeon_get_clock_rate(), 125000000); /* Lower than 4 doesn't seem to work properly */ if (divisor < 4) divisor = 4; @@ -1606,8 +1606,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, * Calculate the number of packets to transfer. If the length is zero * we still need to transfer one packet */ - packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / - pipe->max_packet; + packets_to_transfer = DIV_ROUND_UP(bytes_to_transfer, + pipe->max_packet); if (packets_to_transfer == 0) packets_to_transfer = 1; else if ((packets_to_transfer > 1) && @@ -1852,8 +1852,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * zero we still need to transfer one packet */ packets_to_transfer = - (bytes_to_transfer + pipe->max_packet - 1) / - pipe->max_packet; + DIV_ROUND_UP(bytes_to_transfer, pipe->max_packet); if (packets_to_transfer == 0) packets_to_transfer = 1; else if ((packets_to_transfer > 1) && -- cgit v1.2.3-59-g8ed1b From d9798aa6c33b4da68d9f798e71dca138c9501f74 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 8 Oct 2014 23:13:47 +0530 Subject: staging: comedi: drivers: Use DIV_ROUND_CLOSEST The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. The Coccinelle script used: // @haskernel@ @@ @depends on haskernel@ expression x,__divisor; @@ - (((x) + ((__divisor) / 2)) / (__divisor)) + DIV_ROUND_CLOSEST(x,__divisor) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index bc0745058057..11a12d787e4c 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1970,7 +1970,7 @@ static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags) switch (flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: - divider = (*nanosec + base / 2) / base; + divider = DIV_ROUND_CLOSEST(*nanosec, base); break; case CMDF_ROUND_DOWN: divider = (*nanosec) / base; -- cgit v1.2.3-59-g8ed1b From 84995ca471ab409413b4938b8133a56ec36ff2f5 Mon Sep 17 00:00:00 2001 From: Esra Altintas Date: Wed, 8 Oct 2014 21:21:50 +0300 Subject: staging: bcm: Removed unnecessary 'else' after 'return' statement in Qos.c The following patch fixes the checkpatch.pl warning: WARNING: else is not generally useful after a break or return Signed-off-by: Esra Altintas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Qos.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index b3ac614cd35f..0f16c6342799 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -978,8 +978,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, if (pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2]) return TRUE; - else - return false; + return false; } -- cgit v1.2.3-59-g8ed1b From 038862c4a3853c680d09b3884ae003803d4cbdfe Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Wed, 8 Oct 2014 23:32:11 +0300 Subject: staging: vt6655: Use ether_addr_copy function This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file iwctl.c Pahole shows that the addresses are aligned Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iwctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 94b4859e2f25..8f3e190a55b9 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -1728,7 +1728,7 @@ int iwctl_siwencodeext(struct net_device *dev, goto error; } //recover addr - memcpy(addr, ext->addr.sa_data, ETH_ALEN); + ether_addr_copy(addr, ext->addr.sa_data); //recover key_idx key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1; //recover set_tx -- cgit v1.2.3-59-g8ed1b From aa59d88f9916bf046298c19e402d9c48d0613d3c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:14 -0700 Subject: staging: comedi: adl_pci9111: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index d18d8f21af23..076866e121a0 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -561,7 +561,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) dev_dbg(dev->class_dev, "fifo overflow\n"); outb(0, dev->iobase + PCI9111_INT_CLR_REG); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } @@ -578,7 +578,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) spin_unlock_irqrestore(&dev->spinlock, irq_flags); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From f5b5164d935ed0a1603a040d631afc6b7004d449 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:15 -0700 Subject: staging: comedi: adl_pci9118: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index e18fd9569a2b..7b1720f8fb30 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -766,7 +766,7 @@ static irqreturn_t pci9118_interrupt(int irq, void *d) interrupt_pci9118_ai_onesample(dev, s); interrupt_exit: - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From c55e892b0635f0e55f2bfaee02b747e4abe7ed7a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:16 -0700 Subject: staging: comedi: adv_pci1710: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 5539bd294862..5f387fabe1f5 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -749,14 +749,14 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, if (status & Status_FE) { dev_dbg(dev->class_dev, "A/D FIFO empty (%4x)\n", status); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } if (status & Status_FF) { dev_dbg(dev->class_dev, "A/D FIFO Full status (Fatal Error!) (%4x)\n", status); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } @@ -790,7 +790,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } /* @@ -837,14 +837,14 @@ static void pci1710_handle_fifo(struct comedi_device *dev, if (!(m & Status_FH)) { dev_dbg(dev->class_dev, "A/D FIFO not half full! (%4x)\n", m); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } if (m & Status_FF) { dev_dbg(dev->class_dev, "A/D FIFO Full status (Fatal Error!) (%4x)\n", m); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } @@ -865,12 +865,12 @@ static void pci1710_handle_fifo(struct comedi_device *dev, devpriv->ai_act_scan >= cmd->stop_arg) { /* all data sampled */ s->async->events |= COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } /* -- cgit v1.2.3-59-g8ed1b From 781f1f189e9726da6134cc8483b39fb7d56b073d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:17 -0700 Subject: staging: comedi: amplc_pci224: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 3bbbb57f19d6..7ca6a6179cf2 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -537,7 +537,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, devpriv->ao_stop_count == 0) { /* FIFO empty at end of counted acquisition. */ s->async->events |= COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } break; @@ -618,7 +618,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, outw(devpriv->daccon, dev->iobase + PCI224_DACCON); } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static int pci224_ao_inttrig_start(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From f923f780704b810d31b62b2ad4e19198e6be0b63 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:18 -0700 Subject: staging: comedi: cb_pcidas: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 1ec363b7505c..e7ab6bcfa90b 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1319,7 +1319,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) spin_unlock_irqrestore(&dev->spinlock, flags); } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static irqreturn_t cb_pcidas_interrupt(int irq, void *d) @@ -1419,7 +1419,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 62fc6407ea18267858963ee01c1238240ddce621 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:19 -0700 Subject: staging: comedi: cb_pcidas64: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 3b6bffc66918..eafbe9f56060 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2836,7 +2836,7 @@ static void handle_ai_interrupt(struct comedi_device *dev, async->events |= COMEDI_CB_EOA; } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static inline unsigned int prev_ao_dma_index(struct comedi_device *dev) @@ -3020,7 +3020,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, if (ao_stopped_by_error(dev, cmd)) async->events |= COMEDI_CB_ERROR; } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static irqreturn_t handle_interrupt(int irq, void *d) -- cgit v1.2.3-59-g8ed1b From 2588ab409c6eaf82061b7ac1b4e86801862fbf13 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:20 -0700 Subject: staging: comedi: das16: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 2d8e86cec47a..222a32ff0d32 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -586,7 +586,7 @@ static void das16_interrupt(struct comedi_device *dev) cfc_write_array_to_buffer(s, devpriv->dma_buffer[buffer_index], num_bytes); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static void das16_timer_interrupt(unsigned long arg) -- cgit v1.2.3-59-g8ed1b From 05664aa4d378f05629c4bbcb7dd59d775578c482 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:21 -0700 Subject: staging: comedi: das16m1: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 24b63c452f51..f98bcbe0d72a 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -460,7 +460,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) dev_err(dev->class_dev, "fifo overflow\n"); } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s) -- cgit v1.2.3-59-g8ed1b From 837a12643bd8367e0999b73a9a1e746fa52863f0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:22 -0700 Subject: staging: comedi: das800: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index d75e5528258c..e284d202b7e7 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -521,7 +521,7 @@ static irqreturn_t das800_interrupt(int irq, void *d) if (fifo_overflow) { spin_unlock_irqrestore(&dev->spinlock, irq_flags); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } @@ -537,7 +537,7 @@ static irqreturn_t das800_interrupt(int irq, void *d) das800_disable(dev); async->events |= COMEDI_CB_EOA; } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From fe43b8f5ded501013c61924efcbbe836d73a4ad6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:23 -0700 Subject: staging: comedi: das1800: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index a53d87ce9b14..7b0b65e883f6 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -656,7 +656,7 @@ static void das1800_ai_handler(struct comedi_device *dev) outb(CLEAR_INTR_MASK & ~OVF, dev->iobase + DAS1800_STATUS); dev_err(dev->class_dev, "FIFO overflow\n"); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } /* stop taking data if appropriate */ @@ -674,7 +674,7 @@ static void das1800_ai_handler(struct comedi_device *dev) async->events |= COMEDI_CB_EOA; } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static int das1800_ai_poll(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From 4f6f009b204fca46136de98c10332de5f3e91ce8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:24 -0700 Subject: staging: comedi: dt282x: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index cc974a5e5cf6..f23d883f2544 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -579,8 +579,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) handled = 1; } #endif - cfc_handle_events(dev, s); - cfc_handle_events(dev, s_ao); + comedi_handle_events(dev, s); + comedi_handle_events(dev, s_ao); return IRQ_RETVAL(handled); } -- cgit v1.2.3-59-g8ed1b From 5d758b98fab68055854134b8012cf0cf1774b7e1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:25 -0700 Subject: staging: comedi: dt3000: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt3000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 825561046b6f..6544f4482740 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -363,7 +363,7 @@ static irqreturn_t dt3k_interrupt(int irq, void *d) if (debug_n_ints >= 10) s->async->events |= COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From b48e57e5b40469c81df768b2c2f0d54224feff79 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:26 -0700 Subject: staging: comedi: gsc_hpdi: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index b8975a4606ea..e99edaa3b9fa 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -272,7 +272,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) if (devpriv->dio_count == 0) async->events |= COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 9e1a0824cb02ce376c5315028e54a2eef61b1d31 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:27 -0700 Subject: staging: comedi: ni_660x: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_660x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 5b6794c8232e..1e4dd82b12ea 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -780,7 +780,7 @@ static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev, struct ni_gpct *counter = s->private; ni_tio_handle_interrupt(counter, s); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static irqreturn_t ni_660x_interrupt(int irq, void *d) -- cgit v1.2.3-59-g8ed1b From 4a706e2e2de33db474c67a7011c29326d2891693 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:28 -0700 Subject: staging: comedi: ni_at_a2150: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 72ec857d073e..f1fe9efda6df 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -188,14 +188,14 @@ static irqreturn_t a2150_interrupt(int irq, void *d) if (status & OVFL_BIT) { dev_err(dev->class_dev, "fifo overflow\n"); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } if ((status & DMA_TC_BIT) == 0) { dev_err(dev->class_dev, "caught non-dma interrupt? Aborting.\n"); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } @@ -255,7 +255,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d) async->events |= COMEDI_CB_BLOCK; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); /* clear interrupt */ outw(0x00, dev->iobase + DMA_TC_CLEAR_REG); -- cgit v1.2.3-59-g8ed1b From 1c27ce6055d47305670e0d67ea02446795f82fe0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:29 -0700 Subject: staging: comedi: ni_labpc_common: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 35bc2c25ddfb..72dc78632cd5 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -876,7 +876,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) /* clear error interrupt */ devpriv->write_byte(dev, 0x1, ADC_FIFO_CLEAR_REG); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); dev_err(dev->class_dev, "overrun\n"); return IRQ_HANDLED; } @@ -896,7 +896,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) /* clear error interrupt */ devpriv->write_byte(dev, 0x1, ADC_FIFO_CLEAR_REG); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); dev_err(dev->class_dev, "overflow\n"); return IRQ_HANDLED; } @@ -914,7 +914,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) async->events |= COMEDI_CB_EOA; } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From b9a69a19c999e43036137b629e80d25e9053386c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:30 -0700 Subject: staging: comedi: ni_mio_common: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 320b080149b6..c855787e28f3 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1462,7 +1462,7 @@ static void handle_gpct_interrupt(struct comedi_device *dev, ni_tio_handle_interrupt(&devpriv->counter_dev->counters[counter_index], s); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); #endif } @@ -1518,7 +1518,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, if (comedi_is_subdevice_running(s)) { s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } return; } @@ -1533,7 +1533,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, if (status & (AI_Overrun_St | AI_Overflow_St)) s->async->events |= COMEDI_CB_OVERFLOW; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return; } if (status & AI_SC_TC_St) { @@ -1559,7 +1559,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, if ((status & AI_STOP_St)) ni_handle_eos(dev, s); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status) @@ -1635,7 +1635,7 @@ static void handle_b_interrupt(struct comedi_device *dev, } #endif - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, @@ -3693,7 +3693,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev) M_Offset_CDIO_Command); /* s->async->events |= COMEDI_CB_EOA; */ } - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } static int ni_serial_hw_readwrite8(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From bd5ebdf0722e5624292c05456057e00547e7e2c4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:31 -0700 Subject: staging: comedi: ni_pcidio: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 5252cba82e5e..0bb776366264 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -485,7 +485,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d) } out: - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); #if 0 if (!tag) writeb(0x03, dev->mmio + Master_DMA_And_Interrupt_Control); -- cgit v1.2.3-59-g8ed1b From fa0e93d573734e19a18f782af9ca21182c2058c8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:32 -0700 Subject: staging: comedi: pcl812: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index fd5ea6e01619..700e4ef49019 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -939,7 +939,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d) pcl812_ai_clear_eoc(dev); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From a2ca8c86515aec54f772533b3fc7e21a635cdab3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:33 -0700 Subject: staging: comedi: pcl816: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). 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, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index aa6487132017..e4383ac2b505 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -355,7 +355,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d) pcl816_ai_clear_eoc(dev); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } @@ -566,7 +566,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_poll_ptr = top1; /* new buffer position */ spin_unlock_irqrestore(&dev->spinlock, flags); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return comedi_buf_n_bytes_ready(s); } -- cgit v1.2.3-59-g8ed1b From 11e7c09aee65e496dbe27e4d57bede97f7a5af4c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:34 -0700 Subject: staging: comedi: pcl818: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). 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 ac19e83ce62a..618591d3b3b3 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -669,7 +669,7 @@ static irqreturn_t pcl818_interrupt(int irq, void *d) pcl818_ai_clear_eoc(dev); - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 44aaad2d5f775e9dcb269f5202d2bc4b9d10d3fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:35 -0700 Subject: staging: comedi: quatech_daqp_cs: use comedi_handle_events() cfc_handle_events() is just a wrapper around comedi_handle_events(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 6407df0404f0..21e99fdf28ad 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -247,7 +247,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) s->async->events |= COMEDI_CB_BLOCK; - cfc_handle_events(dev, s); + comedi_handle_events(dev, s); } return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 48b89ec6fa370c45da9761334b77962e5bc4b505 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:11:36 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_handle_events() This inline function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index ce2835972507..d381bc1b2a2b 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -60,12 +60,6 @@ cfc_read_array_from_buffer(struct comedi_subdevice *s, void *data, return comedi_read_array_from_buffer(s, data, num_bytes); } -static inline unsigned int cfc_handle_events(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - return comedi_handle_events(dev, s); -} - /** * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source * @src: pointer to the trigger source to validate -- cgit v1.2.3-59-g8ed1b From a2c344e94e0918bf1bf96f5335088fbd9eab382f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:18 -0700 Subject: staging: comedi: hwdrv_apci3200: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 5e321f91172f..470b3f0d457f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2560,8 +2560,7 @@ static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) comedi_buf_write_free(s, (7 + 12) * sizeof(unsigned int)); - /* Send events */ - comedi_event(dev, s); + comedi_handle_events(dev, s); /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ -- cgit v1.2.3-59-g8ed1b From c8fd3539713008f134b8934f14f943606ae987e3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:19 -0700 Subject: staging: comedi: addi_apci_1032: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1032.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 840cb289507a..12601a9337f3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -260,7 +260,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d) s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff; comedi_buf_put(s, s->state); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); /* enable the interrupt */ outl(ctrl, dev->iobase + APCI1032_CTRL_REG); -- cgit v1.2.3-59-g8ed1b From 5b6f0e9482921c4c8eeae2c01f246147b2cb4faa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:20 -0700 Subject: staging: comedi: addi_apci_1564: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 688b015a834e..cf544ab1fc65 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -97,7 +97,7 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) & 0xffff; comedi_buf_put(s, s->state); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); /* enable the interrupt */ outl(status, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); -- cgit v1.2.3-59-g8ed1b From f47906a3421af0864dc93c812347c553efa208ee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:21 -0700 Subject: staging: comedi: addi_apci_3xxx: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index a296bd5b2c0c..fe9ac2d72694 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -374,7 +374,7 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d) comedi_buf_put(s, val); s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From a2c4e3671c0ae8559f82fb11083a688f61bce23e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:22 -0700 Subject: staging: comedi: amplc_pc236_common: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pc236_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_pc236_common.c b/drivers/staging/comedi/drivers/amplc_pc236_common.c index 963c5d868b81..04c3d73ec5ba 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236_common.c +++ b/drivers/staging/comedi/drivers/amplc_pc236_common.c @@ -137,7 +137,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d) if (dev->attached && handled) { comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); } return IRQ_RETVAL(handled); } -- cgit v1.2.3-59-g8ed1b From bc8816511dd91352c15cf20698e2af022aa6f862 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:23 -0700 Subject: staging: comedi: comedi_parport: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_parport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index bf002988192d..0bc3844073ee 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -228,7 +228,7 @@ static irqreturn_t parport_interrupt(int irq, void *d) comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 285d1ff1629b1a83ee7c09b23b74fd2a92854d80 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:24 -0700 Subject: staging: comedi: dmm32at: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 7215e09305cf..7e69d317b7ef 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -514,8 +514,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d) } } - /* flush the buffer */ - comedi_event(dev, s); + comedi_handle_events(dev, s); } /* reset the interrupt */ -- cgit v1.2.3-59-g8ed1b From 001cce48b407d63d09b5dfb27a04017cbfc9e4e7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:25 -0700 Subject: staging: comedi: dt2814: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2814.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 9216c35c414e..9805be13005a 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -230,7 +230,7 @@ static irqreturn_t dt2814_interrupt(int irq, void *d) s->async->events |= COMEDI_CB_EOA; } - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 0c56f057dc1e4f9ee0303f412f0814d720d76f34 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:26 -0700 Subject: staging: comedi: ni_6527: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_6527.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 45fb601e4080..b77354bc75e6 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -210,7 +210,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d) if (status & NI6527_STATUS_EDGE) { comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); } writeb(NI6527_CLR_IRQS, dev->mmio + NI6527_CLR_REG); -- cgit v1.2.3-59-g8ed1b From 9207b6b0aa320eb0ef02084e6199e709c20d522b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:27 -0700 Subject: staging: comedi: ni_65xx: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 3b642861eb36..3c27f532aa6e 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -510,7 +510,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d) comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From c827d2b7500eb5d7efa768177a1d89336df09d61 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:28 -0700 Subject: staging: comedi: ni_atmio16d: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_atmio16d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index fc3c19de7005..24f8bca9ba05 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -220,7 +220,7 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d) comedi_buf_put(s, inw(dev->iobase + AD_FIFO_REG)); - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From ae4ac0dbf1385a2e33a6621235b5bcddae5cba4e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:29 -0700 Subject: staging: comedi: pcl726: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl726.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index dc179bd02dfd..be43cdaf9479 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -237,7 +237,7 @@ static irqreturn_t pcl726_interrupt(int irq, void *d) comedi_buf_put(s, 0); s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); - comedi_event(dev, s); + comedi_handle_events(dev, s); } return IRQ_HANDLED; -- cgit v1.2.3-59-g8ed1b From ff6f21a5eee870f565aad1e29e71d9b5a4f255f3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:30 -0700 Subject: staging: comedi: hwdrv_apci3120: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 2950815b65f4..db6e14269c92 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1329,15 +1329,14 @@ static void apci3120_interrupt_dma(int irq, void *d) if (!(cmd->flags & CMDF_WAKE_EOS)) { s->async->events |= COMEDI_CB_EOS; - comedi_event(dev, s); + comedi_handle_events(dev, s); } } if (cmd->stop_src == TRIG_COUNT) if (devpriv->ui_AiActualScan >= cmd->stop_arg) { /* all data sampled */ - apci3120_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); + comedi_handle_events(dev, s); return; } @@ -1416,7 +1415,7 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) if (err == 0) s->async->events |= COMEDI_CB_OVERFLOW; - comedi_event(dev, s); + comedi_handle_events(dev, s); return 0; } @@ -1539,12 +1538,8 @@ static void apci3120_interrupt(int irq, void *d) outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - /* stop timer 0 and timer 1 */ - apci3120_cancel(dev, s); - - /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */ s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); + comedi_handle_events(dev, s); break; -- cgit v1.2.3-59-g8ed1b From 215ecf8a524b3892536fc38317bb1dad2a47be04 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:31 -0700 Subject: staging: comedi: hwdrv_apci3120: do comedi_handle_events() at end of interrupt Currently comedi_handle_events() is done by both the DMA and non-DMA helper functions that are called by the interrupt handler. For aesthetics, move the comedi_handle_events() to the end of the interrupt handler and do it in one place. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index db6e14269c92..b06142b27df7 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1327,16 +1327,13 @@ static void apci3120_interrupt_dma(int irq, void *d) devpriv->ul_DmaBufferVirtual[devpriv-> ui_DmaActualBuffer], samplesinbuf); - if (!(cmd->flags & CMDF_WAKE_EOS)) { + if (!(cmd->flags & CMDF_WAKE_EOS)) s->async->events |= COMEDI_CB_EOS; - comedi_handle_events(dev, s); - } } if (cmd->stop_src == TRIG_COUNT) if (devpriv->ui_AiActualScan >= cmd->stop_arg) { /* all data sampled */ s->async->events |= COMEDI_CB_EOA; - comedi_handle_events(dev, s); return; } @@ -1415,8 +1412,6 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) if (err == 0) s->async->events |= COMEDI_CB_OVERFLOW; - comedi_handle_events(dev, s); - return 0; } @@ -1539,8 +1534,6 @@ static void apci3120_interrupt(int irq, void *d) dev->iobase + APCI3120_WR_ADDRESS); s->async->events |= COMEDI_CB_EOA; - comedi_handle_events(dev, s); - break; case APCI3120_TIMER: @@ -1593,6 +1586,7 @@ static void apci3120_interrupt(int irq, void *d) } } + comedi_handle_events(dev, s); } /* -- cgit v1.2.3-59-g8ed1b From 7ff4b5847c7063c2f60bd1c40f59160389ae2449 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:32 -0700 Subject: staging: comedi: addi_apci_2032: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Also, comedi_handle_events() does nothing if no events are set so the local variable 'do_event' can be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_2032.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index aea3da325359..ad7529459429 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -178,7 +178,6 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) struct comedi_cmd *cmd = &s->async->cmd; struct apci2032_int_private *subpriv; unsigned int val; - bool do_event = false; if (!dev->attached) return IRQ_NONE; @@ -220,19 +219,16 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) if (subpriv->stop_count == 0) { /* end of acquisition */ s->async->events |= COMEDI_CB_EOA; - apci2032_int_stop(dev, s); } } } else { - apci2032_int_stop(dev, s); s->async->events |= COMEDI_CB_OVERFLOW; } - do_event = true; } spin_unlock(&subpriv->spinlock); - if (do_event) - comedi_event(dev, s); + + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 066021912a40c1ae76e696f24f87451becb7612b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:33 -0700 Subject: staging: comedi: amplc_dio200_common: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Also, comedi_handle_events() does nothing if no events are set so the local variable 'oldevents' can be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 2c1bfb09601d..944d454b7a37 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -272,7 +272,6 @@ static void dio200_read_scan_intr(struct comedi_device *dev, s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Error! Stop acquisition. */ - dio200_stop_intr(dev, s); s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW; dev_err(dev->class_dev, "buffer overflow\n"); } @@ -281,10 +280,8 @@ static void dio200_read_scan_intr(struct comedi_device *dev, if (cmd->stop_src == TRIG_COUNT) { if (subpriv->stopcount > 0) { subpriv->stopcount--; - if (subpriv->stopcount == 0) { + if (subpriv->stopcount == 0) s->async->events |= COMEDI_CB_EOA; - dio200_stop_intr(dev, s); - } } } } @@ -297,13 +294,11 @@ static int dio200_handle_read_intr(struct comedi_device *dev, unsigned triggered; unsigned intstat; unsigned cur_enabled; - unsigned int oldevents; unsigned long flags; triggered = 0; spin_lock_irqsave(&subpriv->spinlock, flags); - oldevents = s->async->events; if (board->has_int_sce) { /* * Collect interrupt sources that have triggered and disable @@ -356,8 +351,7 @@ static int dio200_handle_read_intr(struct comedi_device *dev, } spin_unlock_irqrestore(&subpriv->spinlock, flags); - if (oldevents != s->async->events) - comedi_event(dev, s); + comedi_handle_events(dev, s); return (triggered != 0); } -- cgit v1.2.3-59-g8ed1b From 2405124744245aff25e72c625456f609bca8ccd2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:34 -0700 Subject: staging: comedi: comedi_test: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. For aesthetics, add a local variable for the comedi_subdevice pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 00c03df72523..8845075cd3cc 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -164,7 +164,8 @@ static void waveform_ai_interrupt(unsigned long arg) { struct comedi_device *dev = (struct comedi_device *)arg; struct waveform_private *devpriv = dev->private; - struct comedi_async *async = dev->read_subdev->async; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int i, j; /* all times in microsec */ @@ -203,7 +204,7 @@ static void waveform_ai_interrupt(unsigned long arg) devpriv->usec_current + i * devpriv->scan_period + j * devpriv->convert_period); - cfc_write_to_buffer(dev->read_subdev, sample); + cfc_write_to_buffer(s, sample); } } @@ -216,7 +217,7 @@ static void waveform_ai_interrupt(unsigned long arg) else mod_timer(&devpriv->timer, jiffies + 1); - comedi_event(dev, dev->read_subdev); + comedi_handle_events(dev, s); } static int waveform_ai_cmdtest(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From 3fa1eb64d6d670676946ccd42d48452aecb96c2d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:35 -0700 Subject: staging: comedi: me4000: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Also, comedi_handle_events() does nothing if no events are set so the check can be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 6561b00bea59..6516ac0c7b46 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1178,8 +1178,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) outl(tmp, dev->iobase + ME4000_AI_CTRL_REG); } - if (s->async->events) - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 421c600dc408e98035ec7f297133f96e37d21d29 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:36 -0700 Subject: staging: comedi: pcl711: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. The pcl711_ai_set_mode() call when the end-of-acquisition is detected can then be removed. The (*cancel) does the same thing. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 47f4887108a7..b6e7f342935d 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -217,12 +217,10 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } else { s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig)) { - pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG); + if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig)) s->async->events |= COMEDI_CB_EOA; - } } - comedi_event(dev, s); + comedi_handle_events(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From c746db4e2b92ee603e8071302fbe56700c05aa61 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:37 -0700 Subject: staging: comedi: pcmmio: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Also, comedi_handle_events() does nothing if no events are set so the local variable 'oldevents' can be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index fc40ee2b34e9..6d60d40733f4 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -337,7 +337,6 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, { struct pcmmio_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int oldevents = s->async->events; unsigned int val = 0; unsigned long flags; int i; @@ -359,29 +358,20 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, /* Write the scan to the buffer. */ if (comedi_buf_put(s, val) && - comedi_buf_put(s, val >> 16)) { + comedi_buf_put(s, val >> 16)) s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); - } else { - /* Overflow! Stop acquisition!! */ - /* TODO: STOP_ACQUISITION_CALL_HERE!! */ - pcmmio_stop_intr(dev, s); - } /* Check for end of acquisition. */ if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count > 0) { devpriv->stop_count--; - if (devpriv->stop_count == 0) { + if (devpriv->stop_count == 0) s->async->events |= COMEDI_CB_EOA; - /* TODO: STOP_ACQUISITION_CALL_HERE!! */ - pcmmio_stop_intr(dev, s); - } } done: spin_unlock_irqrestore(&devpriv->spinlock, flags); - if (oldevents != s->async->events) - comedi_event(dev, s); + comedi_handle_events(dev, s); } static irqreturn_t interrupt_pcmmio(int irq, void *d) -- cgit v1.2.3-59-g8ed1b From bc43ae066239c122d643f4fefac38b03221be6d1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:38 -0700 Subject: staging: comedi: pcmuio: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Also, comedi_handle_events() does nothing if no events are set so the local variable 'oldevents' can be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmuio.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index d4fe2ec25ecf..28e659889e4f 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -317,7 +317,6 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, int asic = pcmuio_subdevice_to_asic(s); struct pcmuio_asic *chip = &devpriv->asics[asic]; struct comedi_cmd *cmd = &s->async->cmd; - unsigned oldevents = s->async->events; unsigned int val = 0; unsigned long flags; unsigned int i; @@ -339,31 +338,22 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, /* Write the scan to the buffer. */ if (comedi_buf_put(s, val) && - comedi_buf_put(s, val >> 16)) { + comedi_buf_put(s, val >> 16)) s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); - } else { - /* Overflow! Stop acquisition!! */ - /* TODO: STOP_ACQUISITION_CALL_HERE!! */ - pcmuio_stop_intr(dev, s); - } /* Check for end of acquisition. */ if (cmd->stop_src == TRIG_COUNT) { if (chip->stop_count > 0) { chip->stop_count--; - if (chip->stop_count == 0) { + if (chip->stop_count == 0) s->async->events |= COMEDI_CB_EOA; - /* TODO: STOP_ACQUISITION_CALL_HERE!! */ - pcmuio_stop_intr(dev, s); - } } } done: spin_unlock_irqrestore(&chip->spinlock, flags); - if (oldevents != s->async->events) - comedi_event(dev, s); + comedi_handle_events(dev, s); } static int pcmuio_handle_asic_interrupt(struct comedi_device *dev, int asic) -- cgit v1.2.3-59-g8ed1b From 365dae93f72fdb281cf04cc43b93d4e044f3c70d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:39 -0700 Subject: staging: comedi: s626: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. The s626_mc_disable() call when the end-of-acquisition is detected can then be removed. The (*cancel) does the same thing. For aesthetics, also remove the 'finished' local variable and just return the ai_cmd_running state. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 11a12d787e4c..efd438f0ca62 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1480,7 +1480,6 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev) * from the final ADC of the previous poll list scan. */ uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1; - bool finished = false; int i; /* get the data and hand it over to comedi */ @@ -1505,25 +1504,16 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev) devpriv->ai_sample_count--; if (devpriv->ai_sample_count <= 0) { devpriv->ai_cmd_running = 0; - - /* Stop RPS program */ - s626_mc_disable(dev, S626_MC1_ERPS1, S626_P_MC1); - - /* send end of acquisition */ async->events |= COMEDI_CB_EOA; - - /* disable master interrupt */ - finished = true; } } if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT) s626_dio_set_irq(dev, cmd->scan_begin_arg); - /* tell comedi that data is there */ - comedi_event(dev, s); + comedi_handle_events(dev, s); - return finished; + return !devpriv->ai_cmd_running; } static irqreturn_t s626_irq_handler(int irq, void *d) -- cgit v1.2.3-59-g8ed1b From 351a7bffbd4a02dd8a46209a4c6582860a72601d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:40 -0700 Subject: staging: comedi: rtd520: clear FIFO when canceling async command Clear the A/D FIFO as part of the analog input (*cancel) to help with cleaning up the async command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 7d4cb140959c..7d04a7ec3d30 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1083,6 +1083,7 @@ static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_count = 0; /* stop and don't transfer any more */ status = readw(dev->mmio + LAS0_IT); overrun = readl(dev->mmio + LAS0_OVERRUN) & 0xffff; + writel(0, dev->mmio + LAS0_ADC_FIFO_CLEAR); return 0; } -- cgit v1.2.3-59-g8ed1b From a708e091598cd8937bcdba66d49d01d81df9b9ed Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:41 -0700 Subject: staging: comedi: rtd520: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. The code to cancel the async command can then be removed from rtd_interrupt(). Since the (*cancel) will also clear the FIFO, the ai_read_dregs() function can also be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 55 ++++----------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 7d04a7ec3d30..1a62e8f249ae 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -632,35 +632,6 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } -/* - unknown amout of data is waiting in fifo. -*/ -static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s) -{ - struct rtd_private *devpriv = dev->private; - - while (readl(dev->mmio + LAS0_ADC) & FS_ADC_NOT_EMPTY) { - unsigned short d = readw(devpriv->las1 + LAS1_ADC_FIFO); - - if (0 == devpriv->ai_count) { /* done */ - continue; /* read rest */ - } - - d = d >> 3; /* low 3 bits are marker lines */ - if (test_bit(s->async->cur_chan, devpriv->chan_is_bipolar)) - /* convert to comedi unsigned data */ - d = comedi_offset_munge(s, d); - d &= s->maxdata; - - if (!comedi_buf_put(s, d)) - return -1; - - if (devpriv->ai_count > 0) /* < 0, means read forever */ - devpriv->ai_count--; - } - return 0; -} - /* Handle all rtd520 interrupts. Runs atomically and is never re-entered. @@ -703,8 +674,6 @@ static irqreturn_t rtd_interrupt(int irq, void *d) if (0 == devpriv->ai_count) goto xfer_done; - - comedi_event(dev, s); } else if (devpriv->xfer_count > 0) { if (fifo_status & FS_ADC_NOT_EMPTY) { /* FIFO not empty */ @@ -713,8 +682,6 @@ static irqreturn_t rtd_interrupt(int irq, void *d) if (0 == devpriv->ai_count) goto xfer_done; - - comedi_event(dev, s); } } } @@ -726,28 +693,16 @@ static irqreturn_t rtd_interrupt(int irq, void *d) /* clear the interrupt */ writew(status, dev->mmio + LAS0_CLEAR); readw(dev->mmio + LAS0_CLEAR); + + comedi_handle_events(dev, s); + return IRQ_HANDLED; xfer_abort: - writel(0, dev->mmio + LAS0_ADC_FIFO_CLEAR); s->async->events |= COMEDI_CB_ERROR; - devpriv->ai_count = 0; /* stop and don't transfer any more */ - /* fall into xfer_done */ xfer_done: - /* pacer stop source: SOFTWARE */ - writel(0, dev->mmio + LAS0_PACER_STOP); - writel(0, dev->mmio + LAS0_PACER); /* stop pacer */ - writel(0, dev->mmio + LAS0_ADC_CONVERSION); - writew(0, dev->mmio + LAS0_IT); - - if (devpriv->ai_count > 0) { /* there shouldn't be anything left */ - fifo_status = readl(dev->mmio + LAS0_ADC); - ai_read_dregs(dev, s); /* read anything left in FIFO */ - } - - s->async->events |= COMEDI_CB_EOA; /* signal end to comedi */ - comedi_event(dev, s); + s->async->events |= COMEDI_CB_EOA; /* clear the interrupt */ status = readw(dev->mmio + LAS0_IT); @@ -757,6 +712,8 @@ xfer_done: fifo_status = readl(dev->mmio + LAS0_ADC); overrun = readl(dev->mmio + LAS0_OVERRUN) & 0xffff; + comedi_handle_events(dev, s); + return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 39064f23284c68d3ce98e7f7b673a0ffa78c17ce Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:42 -0700 Subject: staging: comedi: amplc_pci230: use comedi_handle_events() Use comedi_handle_events() to automatically (*cancel) the async command for an end-of-acquisition or if an error/overflow occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 48 ++++++++++----------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 8ed150689f97..b8fded313d64 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1089,8 +1089,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, ret = comedi_buf_get(s, &data); if (ret == 0) { s->async->events |= COMEDI_CB_OVERFLOW; - pci230_ao_stop(dev, s); - dev_err(dev->class_dev, "AO buffer underrun\n"); return; } pci230_ao_write_nofifo(dev, data, chan); @@ -1102,7 +1100,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, if (devpriv->ao_scan_count == 0) { /* End of acquisition. */ async->events |= COMEDI_CB_EOA; - pci230_ao_stop(dev, s); } } } @@ -1204,13 +1201,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } } - if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) { - /* Stopping AO due to completion or error. */ - pci230_ao_stop(dev, s); + if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) running = false; - } else { + else running = true; - } async->events |= events; return running; } @@ -1235,7 +1229,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev, /* Not using DAC FIFO. */ spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags); pci230_handle_ao_nofifo(dev, s); - comedi_event(dev, s); + comedi_handle_events(dev, s); } else { /* Using DAC FIFO. */ /* Read DACSWTRIG register to trigger conversion. */ @@ -1265,7 +1259,7 @@ static void pci230_ao_start(struct comedi_device *dev, /* Preload FIFO data. */ run = pci230_handle_ao_fifo(dev, s); - comedi_event(dev, s); + comedi_handle_events(dev, s); if (!run) { /* Stopped. */ return; @@ -2134,11 +2128,8 @@ static void pci230_handle_ai(struct comedi_device *dev, events |= COMEDI_CB_BLOCK; } async->events |= events; - if (async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | - COMEDI_CB_OVERFLOW)) { - /* disable hardware conversions */ - pci230_ai_stop(dev, s); - } else { + if (!(async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | + COMEDI_CB_OVERFLOW))) { /* update FIFO interrupt trigger level */ pci230_ai_update_fifo_trigger_level(dev, s); } @@ -2355,7 +2346,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d) unsigned char status_int, valid_status_int, temp_ier; struct comedi_device *dev = (struct comedi_device *)d; struct pci230_private *devpriv = dev->private; - struct comedi_subdevice *s; + struct comedi_subdevice *s_ao = dev->write_subdev; + struct comedi_subdevice *s_ai = dev->read_subdev; unsigned long irqflags; /* Read interrupt status/enable register. */ @@ -2385,23 +2377,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d) * two. */ - if (valid_status_int & PCI230_INT_ZCLK_CT1) { - s = dev->write_subdev; - pci230_handle_ao_nofifo(dev, s); - comedi_event(dev, s); - } + if (valid_status_int & PCI230_INT_ZCLK_CT1) + pci230_handle_ao_nofifo(dev, s_ao); - if (valid_status_int & PCI230P2_INT_DAC) { - s = dev->write_subdev; - pci230_handle_ao_fifo(dev, s); - comedi_event(dev, s); - } + if (valid_status_int & PCI230P2_INT_DAC) + pci230_handle_ao_fifo(dev, s_ao); - if (valid_status_int & PCI230_INT_ADC) { - s = dev->read_subdev; - pci230_handle_ai(dev, s); - comedi_event(dev, s); - } + if (valid_status_int & PCI230_INT_ADC) + pci230_handle_ai(dev, s_ai); /* Reenable interrupts. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); @@ -2410,6 +2393,9 @@ static irqreturn_t pci230_interrupt(int irq, void *d) devpriv->intr_running = false; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + comedi_handle_events(dev, s_ao); + comedi_handle_events(dev, s_ai); + return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 46a5c3913bd2b0fa102f3d4ce9f7e9bdf9942772 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:13 -0700 Subject: staging: comedi: amplc_pci224: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 7ca6a6179cf2..9fcf6f77c96e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -514,7 +514,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, { struct pci224_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int bytes_per_scan = cfc_bytes_per_scan(s); + unsigned int bytes_per_scan = comedi_bytes_per_scan(s); unsigned int num_scans; unsigned int room; unsigned short dacstat; -- cgit v1.2.3-59-g8ed1b From 36df06978adb2e960bad458a47a44e3f1cd4be2b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:14 -0700 Subject: staging: comedi: amplc_pci230: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index b8fded313d64..a04ce6bd3705 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1124,7 +1124,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, /* Get DAC FIFO status. */ dacstat = inw(devpriv->daqio + PCI230_DACCON); /* Determine number of scans available in buffer. */ - num_scans = comedi_buf_read_n_available(s) / cfc_bytes_per_scan(s); + num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s); if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_scan_count) -- cgit v1.2.3-59-g8ed1b From 1b8db39fd9c403e90238797529694ba45d36b4e8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:15 -0700 Subject: staging: comedi: das16: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 222a32ff0d32..5d47d0a1d45f 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -764,7 +764,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) return -1; } - devpriv->adc_byte_count = cmd->stop_arg * cfc_bytes_per_scan(s); + devpriv->adc_byte_count = cmd->stop_arg * comedi_bytes_per_scan(s); if (devpriv->can_burst) outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV_REG); -- cgit v1.2.3-59-g8ed1b From f4fc1dbe2944784457279a794cd77b72883fd9cb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:16 -0700 Subject: staging: comedi: mite: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index a43b5beffc4b..bc12765368ec 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -550,7 +550,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - u32 stop_count = cmd->stop_arg * cfc_bytes_per_scan(s); + u32 stop_count = cmd->stop_arg * comedi_bytes_per_scan(s); unsigned int old_alloc_count = async->buf_read_alloc_count; u32 nbytes_ub, nbytes_lb; int count; -- cgit v1.2.3-59-g8ed1b From 03bb28fcfd20a883c82b41e1a2e4c53db61405f5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:17 -0700 Subject: staging: comedi: pcl812: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 700e4ef49019..72ae48f4d256 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -556,8 +556,8 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev, /* we use EOS, so adapt DMA buffer to one scan */ if (devpriv->ai_eos) { - devpriv->dmabytestomove[0] = cfc_bytes_per_scan(s); - devpriv->dmabytestomove[1] = cfc_bytes_per_scan(s); + devpriv->dmabytestomove[0] = comedi_bytes_per_scan(s); + devpriv->dmabytestomove[1] = comedi_bytes_per_scan(s); devpriv->dma_runs_to_end = 1; } else { devpriv->dmabytestomove[0] = devpriv->hwdmasize; @@ -572,7 +572,7 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev, devpriv->dma_runs_to_end = 1; } else { /* how many samples we must transfer? */ - bytes = cmd->stop_arg * cfc_bytes_per_scan(s); + bytes = cmd->stop_arg * comedi_bytes_per_scan(s); /* how many DMA pages we must fill */ devpriv->dma_runs_to_end = -- cgit v1.2.3-59-g8ed1b From 3d18aa60ec898092462d28e5e8e50b89082357d4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:18 -0700 Subject: staging: comedi: pcl816: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index e4383ac2b505..65cbafb85698 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -160,7 +160,7 @@ static void pcl816_ai_setup_dma(struct comedi_device *dev, bytes = devpriv->hwdmasize; if (cmd->stop_src == TRIG_COUNT) { /* how many */ - bytes = cmd->stop_arg * cfc_bytes_per_scan(s); + bytes = cmd->stop_arg * comedi_bytes_per_scan(s); /* how many DMA pages we must fill */ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; -- cgit v1.2.3-59-g8ed1b From ab192afc6571c49570ff52ab9c833a8f61ae6b18 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:19 -0700 Subject: staging: comedi: pcl818: use comedi_bytes_per_scan() This inline function is just a wrapper around comedi_bytes_per_scan(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 618591d3b3b3..9921e1fa7515 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -352,7 +352,7 @@ static void pcl818_ai_setup_dma(struct comedi_device *dev, disable_dma(devpriv->dma); /* disable dma */ bytes = devpriv->hwdmasize; if (cmd->stop_src == TRIG_COUNT) { - bytes = cmd->stop_arg * cfc_bytes_per_scan(s); + bytes = cmd->stop_arg * comedi_bytes_per_scan(s); devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; devpriv->last_dma_run = bytes % devpriv->hwdmasize; devpriv->dma_runs_to_end--; -- cgit v1.2.3-59-g8ed1b From f3055f9ef3b12b8c4c2029fb76d0163733090594 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:41:20 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_bytes_per_scan() This inline function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index d381bc1b2a2b..d8a6a8e27c51 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -23,11 +23,6 @@ #include "../comedidev.h" -static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s) -{ - return comedi_bytes_per_scan(s); -} - static inline void cfc_inc_scan_progress(struct comedi_subdevice *s, unsigned int num_bytes) { -- cgit v1.2.3-59-g8ed1b From eac783a6b723672b4b684a92e9cc3d4e8383e03e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:46:05 -0700 Subject: staging: comedi: mite: use comedi_inc_scan_progress() This inline function is just a wrapper around comedi_inc_scan_progress(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index bc12765368ec..ffc9e61d6cdd 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -539,7 +539,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, return 0; comedi_buf_write_free(s, count); - cfc_inc_scan_progress(s, count); + comedi_inc_scan_progress(s, count); async->events |= COMEDI_CB_BLOCK; return 0; } -- cgit v1.2.3-59-g8ed1b From 5d0d813d34cded724450f1149e9402bc6fbc3270 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:46:06 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_inc_scan_progress() This inline function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index d8a6a8e27c51..0f4b360cf9ec 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -23,12 +23,6 @@ #include "../comedidev.h" -static inline void cfc_inc_scan_progress(struct comedi_subdevice *s, - unsigned int num_bytes) -{ - comedi_inc_scan_progress(s, num_bytes); -} - static inline unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, const void *data, unsigned int num_bytes) -- cgit v1.2.3-59-g8ed1b From 5d096c3b2609d894d93348e4df90a720f8645dd1 Mon Sep 17 00:00:00 2001 From: Rahul Bedarkar Date: Wed, 1 Oct 2014 22:26:01 +0530 Subject: staging: bcm: fix sparse warning in module_param This patch fixes sparse warning in module_param warning: pointer targets in return differ in signedness [-Wpointer-sign] Signed-off-by: Rahul Bedarkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceInit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index bb61d34886b3..9eaffd884a4c 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -15,7 +15,7 @@ static struct usb_device_id InterfaceUsbtable[] = { MODULE_DEVICE_TABLE(usb, InterfaceUsbtable); static int debug = -1; -module_param(debug, uint, 0600); +module_param(debug, int, 0600); MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); static const u32 default_msg = -- cgit v1.2.3-59-g8ed1b From 748d9dd1b1b6cd88a0dbc0b3dd49fb51dcb1c9de Mon Sep 17 00:00:00 2001 From: Rahul Bedarkar Date: Wed, 1 Oct 2014 22:41:36 +0530 Subject: staging: dgap: remove unused variable 'orig_count' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes sparse warning warning: variable ‘orig_count’ set but not used [-Wunused-but-set-variable] Signed-off-by: Rahul Bedarkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index d0be1cebf5a9..2f2aa59600e5 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -2629,7 +2629,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, char __iomem *vaddr; u16 head, tail, tmask, remain; int bufcount, n; - int orig_count; ulong lock_flags; if (!tty) @@ -2650,13 +2649,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, if (!count) return 0; - /* - * 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; - spin_lock_irqsave(&ch->ch_lock, lock_flags); /* Get our space available for the channel from the board */ -- cgit v1.2.3-59-g8ed1b From 9f2b744475b141a2d8e1bf047ecd06a054f300e3 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Wed, 8 Oct 2014 20:12:48 +0900 Subject: staging: dgap: remove unnecessary if statement for checking NULL dgap_release_remap() function is only called after the memory has been remapped so if statement for checking NULL doesn't need. And also release_mem_region() calls are moved after iounmap() calls. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 2f2aa59600e5..38077878f61a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1013,15 +1013,10 @@ static int dgap_do_remap(struct board_t *brd) static void dgap_release_remap(struct board_t *brd) { - if (brd->re_map_membase) { - release_mem_region(brd->membase, 0x200000); - iounmap(brd->re_map_membase); - } - - if (brd->re_map_port) { - release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); - iounmap(brd->re_map_port); - } + iounmap(brd->re_map_port); + iounmap(brd->re_map_membase); + release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); + release_mem_region(brd->membase, 0x200000); } /***************************************************************************** * -- cgit v1.2.3-59-g8ed1b From 263bd1cb84a86c675a8edff6eee5b8c12c889f50 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Wed, 8 Oct 2014 20:13:21 +0900 Subject: staging: dgap: change function names properly dgap_do_remap() and dgap_release_remap() names could be changed to dgap_remap() and dgap_unmap(). Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 38077878f61a..d0eb5ea43965 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -78,8 +78,8 @@ static void dgap_cleanup_board(struct board_t *brd); static void dgap_poll_handler(ulong dummy); static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); static void dgap_remove_one(struct pci_dev *dev); -static int dgap_do_remap(struct board_t *brd); -static void dgap_release_remap(struct board_t *brd); +static int dgap_remap(struct board_t *brd); +static void dgap_unmap(struct board_t *brd); static irqreturn_t dgap_intr(int irq, void *voidbrd); static int dgap_tty_open(struct tty_struct *tty, struct file *file); @@ -621,7 +621,7 @@ free_flipbuf: dgap_free_flipbuf(brd); cleanup_brd: dgap_cleanup_nodes(); - dgap_release_remap(brd); + dgap_unmap(brd); kfree(brd); return rc; @@ -683,7 +683,7 @@ static void dgap_cleanup_board(struct board_t *brd) tasklet_kill(&brd->helper_tasklet); - dgap_release_remap(brd); + dgap_unmap(brd); /* Free all allocated channels structs */ for (i = 0; i < MAXPORTS ; i++) @@ -804,7 +804,7 @@ static struct board_t *dgap_found_board(struct pci_dev *pdev, int id, tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet, (unsigned long) brd); - ret = dgap_do_remap(brd); + ret = dgap_remap(brd); if (ret) goto free_brd; @@ -979,7 +979,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type, /* * Remap PCI memory. */ -static int dgap_do_remap(struct board_t *brd) +static int dgap_remap(struct board_t *brd) { if (!brd || brd->magic != DGAP_BOARD_MAGIC) return -EIO; @@ -1011,7 +1011,7 @@ static int dgap_do_remap(struct board_t *brd) return 0; } -static void dgap_release_remap(struct board_t *brd) +static void dgap_unmap(struct board_t *brd) { iounmap(brd->re_map_port); iounmap(brd->re_map_membase); -- cgit v1.2.3-59-g8ed1b From e92c3511b91fa1e5b76b755fadece3637bb0de61 Mon Sep 17 00:00:00 2001 From: Nitin Kuppelur Date: Wed, 1 Oct 2014 17:04:27 +0200 Subject: Staging: rtl8712:ieee80211 remove unnecessary else Removed unnecessary else after return/break to solve checkpatch.pl warning Signed-off-by: Nitin Kuppelur Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index fe9459e483c5..eb23b08cb7fd 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -124,11 +124,10 @@ u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit) if (*p == index) { *len = *(p + 1); return p; - } else { - tmp = *(p + 1); - p += (tmp + 2); - i += (tmp + 2); } + tmp = *(p + 1); + p += (tmp + 2); + i += (tmp + 2); if (i >= limit) break; } @@ -237,10 +236,9 @@ unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) goto check_next_ie; *wpa_ie_len = *(pbuf + 1); return pbuf; - } else { - *wpa_ie_len = 0; - return NULL; } + *wpa_ie_len = 0; + return NULL; check_next_ie: limit = limit - (pbuf - pie) - 2 - len; if (limit <= 0) @@ -414,7 +412,7 @@ int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) cnt += in_ie[cnt+1]+2; match = true; break; - } else + } cnt += in_ie[cnt+1]+2; /* goto next */ } return match; -- cgit v1.2.3-59-g8ed1b From a15522c0a4208ce076f093668e9658a7b08c20b1 Mon Sep 17 00:00:00 2001 From: Serguey Parkhomovsky Date: Tue, 7 Oct 2014 20:42:45 -0700 Subject: staging: rtl8712: fix unnecessary elses after return/break in rtl8712_efuse.c This patch fixes two unnecessary else conditions that were found by checkpatch.pl. Signed-off-by: Serguey Parkhomovsky Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_efuse.c | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c index c9eeb4270ab9..97b78392e6c8 100644 --- a/drivers/staging/rtl8712/rtl8712_efuse.c +++ b/drivers/staging/rtl8712/rtl8712_efuse.c @@ -414,19 +414,18 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, bResult = false; } break; - } else { /* write header fail */ - bResult = false; - if (0xFF == efuse_data) - return bResult; /* nothing damaged. */ - /* call rescue procedure */ - if (fix_header(padapter, efuse_data, efuse_addr) == - false) - return false; /* rescue fail */ - - if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */ - break; - /* otherwise, take another risk... */ } + /* write header fail */ + bResult = false; + if (0xFF == efuse_data) + return bResult; /* nothing damaged. */ + /* call rescue procedure */ + if (!fix_header(padapter, efuse_data, efuse_addr)) + return false; /* rescue fail */ + + if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */ + break; + /* otherwise, take another risk... */ } return bResult; } @@ -541,15 +540,16 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, } idx++; break; - } else { - if ((data[idx] != pktdata[i]) || (data[idx+1] != - pktdata[i+1])) { - word_en &= ~BIT(i >> 1); - newdata[j++] = data[idx]; - newdata[j++] = data[idx + 1]; - } - idx += 2; } + + if ((data[idx] != pktdata[i]) || (data[idx+1] != + pktdata[i+1])) { + word_en &= ~BIT(i >> 1); + newdata[j++] = data[idx]; + newdata[j++] = data[idx + 1]; + } + idx += 2; + if (idx == cnts) break; } -- cgit v1.2.3-59-g8ed1b From 6232876b723bb7954dd23405963155d8fb8dd654 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 7 Oct 2014 17:53:20 +0200 Subject: staging: gs_fpgaboot: Use print_hex_dump_bytes instead of pr_info Use print_hex_dump_bytes instead of pr_info Signed-off-by: Dzmitry Sledneu Reviewed-by: Insop Song Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index 1875bd3b823f..cbf70cefe6f5 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -46,27 +46,6 @@ 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); @@ -220,9 +199,9 @@ static int gs_download_image(struct fpgaimage *fimage, enum wbus bus_bytes) size = fimage->lendata; #ifdef DEBUG_FPGA - datadump("bitfile sample", bitdata, 0x100); + print_hex_dump_bytes("bitfile sample: ", DUMP_PREFIX_OFFSET, + bitdata, 0x100); #endif /* DEBUG_FPGA */ - if (!xl_supported_prog_bus_width(bus_bytes)) { pr_err("unsupported program bus width %d\n", bus_bytes); -- cgit v1.2.3-59-g8ed1b From 812283cd54637633c1b5aa8d86667afe6c507f0e Mon Sep 17 00:00:00 2001 From: Soren Brinkmann Date: Thu, 2 Oct 2014 09:13:35 -0700 Subject: staging: Add Xilinx Clocking Wizard driver Add a driver for the Xilinx Clocking Wizard soft IP. The clocking wizard provides an AXI interface to dynamically reconfigure the clocking resources of Xilinx FPGAs. Signed-off-by: Soren Brinkmann Acked-by: Laurent Pinchart Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/clocking-wizard/Kconfig | 9 + drivers/staging/clocking-wizard/Makefile | 1 + drivers/staging/clocking-wizard/TODO | 12 + .../clocking-wizard/clk-xlnx-clock-wizard.c | 335 +++++++++++++++++++++ drivers/staging/clocking-wizard/dt-binding.txt | 30 ++ 7 files changed, 390 insertions(+) create mode 100644 drivers/staging/clocking-wizard/Kconfig create mode 100644 drivers/staging/clocking-wizard/Makefile create mode 100644 drivers/staging/clocking-wizard/TODO create mode 100644 drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c create mode 100644 drivers/staging/clocking-wizard/dt-binding.txt diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 4690ae9a267f..80ad2078eea2 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -108,4 +108,6 @@ source "drivers/staging/skein/Kconfig" source "drivers/staging/unisys/Kconfig" +source "drivers/staging/clocking-wizard/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index c780a0e70e15..17aa2231e208 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -46,3 +46,4 @@ obj-$(CONFIG_MTD_SPINAND_MT29F) += mt29f_spinand/ obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ obj-$(CONFIG_CRYPTO_SKEIN) += skein/ obj-$(CONFIG_UNISYSSPAR) += unisys/ +obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ diff --git a/drivers/staging/clocking-wizard/Kconfig b/drivers/staging/clocking-wizard/Kconfig new file mode 100644 index 000000000000..357af02c562c --- /dev/null +++ b/drivers/staging/clocking-wizard/Kconfig @@ -0,0 +1,9 @@ +# +# Xilinx Clocking Wizard Driver +# + +config COMMON_CLK_XLNX_CLKWZRD + tristate "Xilinx Clocking Wizard" + depends on COMMON_CLK && OF + ---help--- + Support for the Xilinx Clocking Wizard IP core clock generator. diff --git a/drivers/staging/clocking-wizard/Makefile b/drivers/staging/clocking-wizard/Makefile new file mode 100644 index 000000000000..5ad352f521fe --- /dev/null +++ b/drivers/staging/clocking-wizard/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clk-xlnx-clock-wizard.o diff --git a/drivers/staging/clocking-wizard/TODO b/drivers/staging/clocking-wizard/TODO new file mode 100644 index 000000000000..ebe99db7d153 --- /dev/null +++ b/drivers/staging/clocking-wizard/TODO @@ -0,0 +1,12 @@ +TODO: + - support for fractional multiplier + - support for fractional divider (output 0 only) + - support for set_rate() operations (may benefit from Stephen Boyd's + refactoring of the clk primitives: https://lkml.org/lkml/2014/9/5/766) + - review arithmetic + - overflow after multiplication? + - maximize accuracy before divisions + +Patches to: + Greg Kroah-Hartman + Sören Brinkmann diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c new file mode 100644 index 000000000000..b8d89525bffd --- /dev/null +++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c @@ -0,0 +1,335 @@ +/* + * Xilinx 'Clocking Wizard' driver + * + * Copyright (C) 2013 - 2014 Xilinx + * + * Sören Brinkmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License v2 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, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +#define WZRD_NUM_OUTPUTS 7 +#define WZRD_ACLK_MAX_FREQ 250000000UL + +#define WZRD_CLK_CFG_REG(n) (0x200 + 4 * n) + +#define WZRD_CLkOUT0_FRAC_EN BIT(18) +#define WZRD_CLkFBOUT_FRAC_EN BIT(26) + +#define WZRD_CLKFBOUT_MULT_SHIFT 8 +#define WZRD_CLKFBOUT_MULT_MASK (0xff << WZRD_CLKFBOUT_MULT_SHIFT) +#define WZRD_DIVCLK_DIVIDE_SHIFT 0 +#define WZRD_DIVCLK_DIVIDE_MASK (0xff << WZRD_DIVCLK_DIVIDE_SHIFT) +#define WZRD_CLKOUT_DIVIDE_SHIFT 0 +#define WZRD_CLKOUT_DIVIDE_MASK (0xff << WZRD_DIVCLK_DIVIDE_SHIFT) + +enum clk_wzrd_int_clks { + wzrd_clk_mul, + wzrd_clk_mul_div, + wzrd_clk_int_max +}; + +/** + * struct clk_wzrd: + * @clk_data: Clock data + * @nb: Notifier block + * @base: Memory base + * @clk_in1: Handle to input clock 'clk_in1' + * @axi_clk: Handle to input clock 's_axi_aclk' + * @clks_internal: Internal clocks + * @clkout: Output clocks + * @speed_grade: Speed grade of the device + * @suspended: Flag indicating power state of the device + */ +struct clk_wzrd { + struct clk_onecell_data clk_data; + struct notifier_block nb; + void __iomem *base; + struct clk *clk_in1; + struct clk *axi_clk; + struct clk *clks_internal[wzrd_clk_int_max]; + struct clk *clkout[WZRD_NUM_OUTPUTS]; + int speed_grade; + bool suspended; +}; +#define to_clk_wzrd(_nb) container_of(_nb, struct clk_wzrd, nb) + +/* maximum frequencies for input/output clocks per speed grade */ +static const unsigned long clk_wzrd_max_freq[] = { + 800000000UL, + 933000000UL, + 1066000000UL +}; + +static int clk_wzrd_clk_notifier(struct notifier_block *nb, unsigned long event, + void *data) +{ + unsigned long max; + struct clk_notifier_data *ndata = data; + struct clk_wzrd *clk_wzrd = to_clk_wzrd(nb); + + if (clk_wzrd->suspended) + return NOTIFY_OK; + + if (ndata->clk == clk_wzrd->clk_in1) + max = clk_wzrd_max_freq[clk_wzrd->speed_grade - 1]; + if (ndata->clk == clk_wzrd->axi_clk) + max = WZRD_ACLK_MAX_FREQ; + + switch (event) { + case PRE_RATE_CHANGE: + if (ndata->new_rate > max) + return NOTIFY_BAD; + return NOTIFY_OK; + case POST_RATE_CHANGE: + case ABORT_RATE_CHANGE: + default: + return NOTIFY_DONE; + } +} + +static int __maybe_unused clk_wzrd_suspend(struct device *dev) +{ + struct clk_wzrd *clk_wzrd = dev_get_drvdata(dev); + + clk_disable_unprepare(clk_wzrd->axi_clk); + clk_wzrd->suspended = true; + + return 0; +} + +static int __maybe_unused clk_wzrd_resume(struct device *dev) +{ + int ret; + struct clk_wzrd *clk_wzrd = dev_get_drvdata(dev); + + ret = clk_prepare_enable(clk_wzrd->axi_clk); + if (ret) { + dev_err(dev, "unable to enable s_axi_aclk\n"); + return ret; + } + + clk_wzrd->suspended = false; + + return 0; +} + +static SIMPLE_DEV_PM_OPS(clk_wzrd_dev_pm_ops, clk_wzrd_suspend, + clk_wzrd_resume); + +static int clk_wzrd_probe(struct platform_device *pdev) +{ + int i, ret; + u32 reg; + unsigned long rate; + const char *clk_name; + struct clk_wzrd *clk_wzrd; + struct resource *mem; + struct device_node *np = pdev->dev.of_node; + + clk_wzrd = devm_kzalloc(&pdev->dev, sizeof(*clk_wzrd), GFP_KERNEL); + if (!clk_wzrd) + return -ENOMEM; + platform_set_drvdata(pdev, clk_wzrd); + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + clk_wzrd->base = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(clk_wzrd->base)) + return PTR_ERR(clk_wzrd->base); + + ret = of_property_read_u32(np, "speed-grade", &clk_wzrd->speed_grade); + if (!ret) { + if (clk_wzrd->speed_grade < 1 || clk_wzrd->speed_grade > 3) { + dev_warn(&pdev->dev, "invalid speed grade '%d'\n", + clk_wzrd->speed_grade); + clk_wzrd->speed_grade = 0; + } + } + + clk_wzrd->clk_in1 = devm_clk_get(&pdev->dev, "clk_in1"); + if (IS_ERR(clk_wzrd->clk_in1)) { + if (clk_wzrd->clk_in1 != ERR_PTR(-EPROBE_DEFER)) + dev_err(&pdev->dev, "clk_in1 not found\n"); + return PTR_ERR(clk_wzrd->clk_in1); + } + + clk_wzrd->axi_clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); + if (IS_ERR(clk_wzrd->axi_clk)) { + if (clk_wzrd->axi_clk != ERR_PTR(-EPROBE_DEFER)) + dev_err(&pdev->dev, "s_axi_aclk not found\n"); + return PTR_ERR(clk_wzrd->axi_clk); + } + ret = clk_prepare_enable(clk_wzrd->axi_clk); + if (ret) { + dev_err(&pdev->dev, "enabling s_axi_aclk failed\n"); + return ret; + } + rate = clk_get_rate(clk_wzrd->axi_clk); + if (rate > WZRD_ACLK_MAX_FREQ) { + dev_err(&pdev->dev, "s_axi_aclk frequency (%lu) too high\n", + rate); + ret = -EINVAL; + goto err_disable_clk; + } + + /* we don't support fractional div/mul yet */ + reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) & + WZRD_CLkFBOUT_FRAC_EN; + reg |= readl(clk_wzrd->base + WZRD_CLK_CFG_REG(2)) & + WZRD_CLkOUT0_FRAC_EN; + if (reg) + dev_warn(&pdev->dev, "fractional div/mul not supported\n"); + + /* register multiplier */ + reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) & + WZRD_CLKFBOUT_MULT_MASK) >> WZRD_CLKFBOUT_MULT_SHIFT; + clk_name = kasprintf(GFP_KERNEL, "%s_mul", dev_name(&pdev->dev)); + if (!clk_name) { + ret = -ENOMEM; + goto err_disable_clk; + } + clk_wzrd->clks_internal[wzrd_clk_mul] = clk_register_fixed_factor( + &pdev->dev, clk_name, + __clk_get_name(clk_wzrd->clk_in1), + 0, reg, 1); + kfree(clk_name); + if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul])) { + dev_err(&pdev->dev, "unable to register fixed-factor clock\n"); + ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul]); + goto err_disable_clk; + } + + /* register div */ + reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) & + WZRD_DIVCLK_DIVIDE_MASK) >> WZRD_DIVCLK_DIVIDE_SHIFT; + clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev)); + clk_wzrd->clks_internal[wzrd_clk_mul_div] = clk_register_fixed_factor( + &pdev->dev, clk_name, + __clk_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]), + 0, 1, reg); + if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div])) { + dev_err(&pdev->dev, "unable to register divider clock\n"); + ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]); + goto err_rm_int_clk; + } + + /* register div per output */ + for (i = WZRD_NUM_OUTPUTS - 1; i >= 0 ; i--) { + const char *clkout_name; + if (of_property_read_string_index(np, "clock-output-names", i, + &clkout_name)) { + dev_err(&pdev->dev, + "clock output name not specified\n"); + ret = -EINVAL; + goto err_rm_int_clks; + } + reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(2) + i * 12); + reg &= WZRD_CLKOUT_DIVIDE_MASK; + reg >>= WZRD_CLKOUT_DIVIDE_SHIFT; + clk_wzrd->clkout[i] = clk_register_fixed_factor(&pdev->dev, + clkout_name, clk_name, 0, 1, reg); + if (IS_ERR(clk_wzrd->clkout[i])) { + int j; + for (j = i + 1; j < WZRD_NUM_OUTPUTS; j++) + clk_unregister(clk_wzrd->clkout[j]); + dev_err(&pdev->dev, + "unable to register divider clock\n"); + ret = PTR_ERR(clk_wzrd->clkout[i]); + goto err_rm_int_clks; + } + } + + kfree(clk_name); + + clk_wzrd->clk_data.clks = clk_wzrd->clkout; + clk_wzrd->clk_data.clk_num = ARRAY_SIZE(clk_wzrd->clkout); + of_clk_add_provider(np, of_clk_src_onecell_get, &clk_wzrd->clk_data); + + if (clk_wzrd->speed_grade) { + clk_wzrd->nb.notifier_call = clk_wzrd_clk_notifier; + + ret = clk_notifier_register(clk_wzrd->clk_in1, + &clk_wzrd->nb); + if (ret) + dev_warn(&pdev->dev, + "unable to register clock notifier\n"); + + ret = clk_notifier_register(clk_wzrd->axi_clk, &clk_wzrd->nb); + if (ret) + dev_warn(&pdev->dev, + "unable to register clock notifier\n"); + } + + return 0; + +err_rm_int_clks: + clk_unregister(clk_wzrd->clks_internal[1]); +err_rm_int_clk: + kfree(clk_name); + clk_unregister(clk_wzrd->clks_internal[0]); +err_disable_clk: + clk_disable_unprepare(clk_wzrd->axi_clk); + + return ret; +} + +static int clk_wzrd_remove(struct platform_device *pdev) +{ + int i; + struct clk_wzrd *clk_wzrd = platform_get_drvdata(pdev); + + of_clk_del_provider(pdev->dev.of_node); + + for (i = 0; i < WZRD_NUM_OUTPUTS; i++) + clk_unregister(clk_wzrd->clkout[i]); + for (i = 0; i < wzrd_clk_int_max; i++) + clk_unregister(clk_wzrd->clks_internal[i]); + + if (clk_wzrd->speed_grade) { + clk_notifier_unregister(clk_wzrd->axi_clk, &clk_wzrd->nb); + clk_notifier_unregister(clk_wzrd->clk_in1, &clk_wzrd->nb); + } + + clk_disable_unprepare(clk_wzrd->axi_clk); + + return 0; +} + +static const struct of_device_id clk_wzrd_ids[] = { + { .compatible = "xlnx,clocking-wizard" }, + { }, +}; +MODULE_DEVICE_TABLE(of, clk_wzrd_ids); + +static struct platform_driver clk_wzrd_driver = { + .driver = { + .name = "clk-wizard", + .of_match_table = clk_wzrd_ids, + .pm = &clk_wzrd_dev_pm_ops, + }, + .probe = clk_wzrd_probe, + .remove = clk_wzrd_remove, +}; +module_platform_driver(clk_wzrd_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Soeren Brinkmann ; + compatible = "xlnx,clocking-wizard"; + speed-grade = <1>; + clock-names = "clk_in1", "s_axi_aclk"; + clocks = <&clkc 15>, <&clkc 15>; + clock-output-names = "clk_out0", "clk_out1", "clk_out2", + "clk_out3", "clk_out4", "clk_out5", + "clk_out6", "clk_out7"; + }; -- cgit v1.2.3-59-g8ed1b From 8e3d161acc23ccf46c5d7b10c934d06ed79a7e48 Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Thu, 2 Oct 2014 18:28:41 -0500 Subject: drivers: staging: rtl8723au: core: Fix "'foo * bar' should be 'foo *bar'" errors Fix checkpatch.pl "'foo * bar' should be 'foo *bar'" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_led.c | 3 ++- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723au/core/rtw_security.c | 27 +++++++++++++------------- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index eb5d60ca2397..aedbd8f77529 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1816,7 +1816,7 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) { struct mlme_priv *mlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct sta_priv * pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta; struct security_priv *psecuritypriv = &padapter->securitypriv; struct list_head *phead, *plist, *ptmp; diff --git a/drivers/staging/rtl8723au/core/rtw_led.c b/drivers/staging/rtl8723au/core/rtw_led.c index 989cda29a57e..fa3dcff263d7 100644 --- a/drivers/staging/rtl8723au/core/rtw_led.c +++ b/drivers/staging/rtl8723au/core/rtw_led.c @@ -51,7 +51,8 @@ void BlinkWorkItemCallback23a(struct work_struct *work) /* Description: */ /* Reset status of led_8723a object. */ /* */ -void ResetLedStatus23a(struct led_8723a * pLed) { +void ResetLedStatus23a(struct led_8723a *pLed) +{ pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ pLed->bLedOn = false; /* true if LED is ON, false if LED is OFF. */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 1f6006439bbb..00e7ad06b5bd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1766,7 +1766,7 @@ exit: return ret; } -int rtw_set_auth23a(struct rtw_adapter * adapter, +int rtw_set_auth23a(struct rtw_adapter *adapter, struct security_priv *psecuritypriv) { struct cmd_obj *pcmd; diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index 76371ae69377..b4886222fd5e 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -30,12 +30,12 @@ struct arc4context u8 state[256]; }; -static void arcfour_init(struct arc4context *parc4ctx, u8 * key, u32 key_len) +static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) { u32 t, u; u32 keyindex; u32 stateindex; - u8 * state; + u8 *state; u32 counter; state = parc4ctx->state; @@ -62,7 +62,7 @@ static u32 arcfour_byte( struct arc4context *parc4ctx) u32 x; u32 y; u32 sx, sy; - u8 * state; + u8 *state; state = parc4ctx->state; x = (parc4ctx->x + 1) & 0xff; @@ -78,8 +78,8 @@ static u32 arcfour_byte( struct arc4context *parc4ctx) } static void arcfour_encrypt( struct arc4context *parc4ctx, - u8 * dest, - u8 * src, + u8 *dest, + u8 *src, u32 len) { u32 i; @@ -221,7 +221,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, u8 keyindex; struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sk_buff * skb = precvframe->pkt; + struct sk_buff *skb = precvframe->pkt; pframe = skb->data; @@ -266,7 +266,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, /* 3 ===== TKIP related ===== */ -static u32 secmicgetuint32(u8 * p) +static u32 secmicgetuint32(u8 *p) /* Convert from Byte[] to u32 in a portable way */ { s32 i; @@ -280,7 +280,7 @@ static u32 secmicgetuint32(u8 * p) return res; } -static void secmicputuint32(u8 * p, u32 val) +static void secmicputuint32(u8 *p, u32 val) /* Convert from long to Byte[] in a portable way */ { long i; @@ -304,7 +304,7 @@ static void secmicclear(struct mic_data *pmicdata) } -void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 * key) +void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 *key) { /* Set the key */ @@ -340,7 +340,7 @@ void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b) } -void rtw_secmicappend23a(struct mic_data *pmicdata, u8 * src, u32 nbytes) +void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbytes) { /* This is simple */ @@ -352,7 +352,7 @@ void rtw_secmicappend23a(struct mic_data *pmicdata, u8 * src, u32 nbytes) } -void rtw_secgetmic23a(struct mic_data *pmicdata, u8 * dst) +void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst) { /* Append the minimum padding */ @@ -374,7 +374,8 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 * dst) } -void rtw_seccalctkipmic23a(u8 * key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) +void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, u32 data_len, + u8 *mic_code, u8 pri) { struct mic_data micdata; @@ -728,7 +729,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, struct sta_info *stainfo; struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sk_buff * skb = precvframe->pkt; + struct sk_buff *skb = precvframe->pkt; int res = _SUCCESS; pframe = skb->data; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 09c44a55d4a6..5c4006aa23b2 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1080,7 +1080,7 @@ bool is_ap_in_tkip23a(struct rtw_adapter *padapter) return false; } -bool should_forbid_n_rate23a(struct rtw_adapter * padapter) +bool should_forbid_n_rate23a(struct rtw_adapter *padapter) { u32 i; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -- cgit v1.2.3-59-g8ed1b From 8ce6b2d2b7e3d4a5d08c31b6ba5c659800c28daf Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Fri, 3 Oct 2014 10:36:40 -0500 Subject: drivers: staging: rtl8723au: Fix "open brace '{' following struct go on the same line" errors Fix checkpatch.pl "open brace '{' following struct go on the same line" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_security.c | 3 +-- drivers/staging/rtl8723au/include/rtl8723a_dm.h | 3 +-- drivers/staging/rtl8723au/include/rtl8723a_recv.h | 3 +-- drivers/staging/rtl8723au/include/rtw_cmd.h | 3 +-- drivers/staging/rtl8723au/include/rtw_ht.h | 3 +-- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 6 ++---- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index b4886222fd5e..5da620c7ba82 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -23,8 +23,7 @@ #define CRC32_POLY 0x04c11db7 -struct arc4context -{ +struct arc4context { u32 x; u32 y; u8 state[256]; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_dm.h b/drivers/staging/rtl8723au/include/rtl8723a_dm.h index 18112225e53f..bf236e8e47a2 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_dm.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_dm.h @@ -37,8 +37,7 @@ enum{ #define IQK_BB_REG_NUM 9 #define HP_THERMAL_NUM 8 /* duplicate code,will move to ODM ######### */ -struct dm_priv -{ +struct dm_priv { u32 InitODMFlag; /* Upper and Lower Signal threshold for Rate Adaptive*/ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_recv.h b/drivers/staging/rtl8723au/include/rtl8723a_recv.h index 885d4d3859f8..0109052a4fbb 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_recv.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_recv.h @@ -35,8 +35,7 @@ #define PHY_LINKQUALITY_SLID_WIN_MAX 20 -struct phy_stat -{ +struct phy_stat { unsigned int phydw0; unsigned int phydw1; unsigned int phydw2; diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index ef67068a5fe3..8ffe5def3d4d 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -450,8 +450,7 @@ struct getrfintfs_parm { u8 rfintfs; }; -struct Tx_Beacon_param -{ +struct Tx_Beacon_param { struct wlan_bssid_ex network; }; diff --git a/drivers/staging/rtl8723au/include/rtw_ht.h b/drivers/staging/rtl8723au/include/rtw_ht.h index cfc947daf08b..780eb8944118 100644 --- a/drivers/staging/rtl8723au/include/rtw_ht.h +++ b/drivers/staging/rtl8723au/include/rtw_ht.h @@ -19,8 +19,7 @@ #include "linux/ieee80211.h" #include "wifi.h" -struct ht_priv -{ +struct ht_priv { bool ht_option; bool ampdu_enable;/* for enable Tx A-MPDU */ /* u8 baddbareq_issued[16]; */ diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 97c3c4478f29..51dba1fa4c5d 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -270,8 +270,7 @@ struct action_handler { int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); }; -struct ss_res -{ +struct ss_res { int state; int bss_cnt; int channel_idx; @@ -318,8 +317,7 @@ struct FW_Sta_Info { * 5. ... and so on, till survey done. */ -struct mlme_ext_info -{ +struct mlme_ext_info { u32 state; u32 reauth_count; u32 reassoc_count; -- cgit v1.2.3-59-g8ed1b From 175dbfae60c79a2a413abdf2d99b75089cc86e23 Mon Sep 17 00:00:00 2001 From: Giedrius Statkevičius Date: Sat, 4 Oct 2014 00:31:17 +0300 Subject: staging: rts5208: combine ifs where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Join together chained if's where possible to lower the indentation level. In a lot of places of this code the indentation level is already very high. As a result, this patch increases the code flow and readability. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 100 ++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 56 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index a7ade8b4e7f2..0db63fbe3db4 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -289,12 +289,10 @@ int rtsx_reset_chip(struct rtsx_chip *chip) /* Enable ASPM */ if (chip->aspm_l0s_l1_en) { if (chip->dynamic_aspm) { - if (CHK_SDIO_EXIST(chip)) { - if (CHECK_PID(chip, 0x5288)) { - retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } + if (CHK_SDIO_EXIST(chip) && CHECK_PID(chip, 0x5288)) { + retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); } } else { if (CHECK_PID(chip, 0x5208)) @@ -350,18 +348,14 @@ int rtsx_reset_chip(struct rtsx_chip *chip) } - if (CHECK_PID(chip, 0x5288)) { - if (!CHK_SDIO_EXIST(chip)) { - retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFFFF, - 0x0103); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - retval = rtsx_write_cfg_dw(chip, 2, 0x84, 0xFF, 0x03); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); + if (CHECK_PID(chip, 0x5288) && !CHK_SDIO_EXIST(chip)) { + retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFFFF, 0x0103); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); - } + retval = rtsx_write_cfg_dw(chip, 2, 0x84, 0xFF, 0x03); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); } RTSX_WRITE_REG(chip, IRQSTAT0, LINK_RDY_INT, LINK_RDY_INT); @@ -1727,10 +1721,8 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip) chip->ocp_int = ocp_int & status; #endif - if (chip->sd_io) { - if (chip->int_reg & DATA_DONE_INT) - chip->int_reg &= ~(u32)DATA_DONE_INT; - } + if (chip->sd_io && (chip->int_reg & DATA_DONE_INT)) + chip->int_reg &= ~(u32)DATA_DONE_INT; return STATUS_SUCCESS; } @@ -1796,31 +1788,29 @@ void rtsx_do_before_power_down(struct rtsx_chip *chip, int pm_stat) void rtsx_enable_aspm(struct rtsx_chip *chip) { - if (chip->aspm_l0s_l1_en && chip->dynamic_aspm) { - if (!chip->aspm_enabled) { - dev_dbg(rtsx_dev(chip), "Try to enable ASPM\n"); - chip->aspm_enabled = 1; + if (chip->aspm_l0s_l1_en && chip->dynamic_aspm && !chip->aspm_enabled) { + dev_dbg(rtsx_dev(chip), "Try to enable ASPM\n"); + chip->aspm_enabled = 1; - if (chip->asic_code && CHECK_PID(chip, 0x5208)) - rtsx_write_phy_register(chip, 0x07, 0); - if (CHECK_PID(chip, 0x5208)) { - rtsx_write_register(chip, ASPM_FORCE_CTL, 0xF3, - 0x30 | chip->aspm_level[0]); - } else { - rtsx_write_config_byte(chip, LCTLR, - chip->aspm_l0s_l1_en); - } + if (chip->asic_code && CHECK_PID(chip, 0x5208)) + rtsx_write_phy_register(chip, 0x07, 0); + if (CHECK_PID(chip, 0x5208)) { + rtsx_write_register(chip, ASPM_FORCE_CTL, 0xF3, + 0x30 | chip->aspm_level[0]); + } else { + rtsx_write_config_byte(chip, LCTLR, + chip->aspm_l0s_l1_en); + } - if (CHK_SDIO_EXIST(chip)) { - u16 val = chip->aspm_l0s_l1_en | 0x0100; + if (CHK_SDIO_EXIST(chip)) { + u16 val = chip->aspm_l0s_l1_en | 0x0100; - if (CHECK_PID(chip, 0x5288)) - rtsx_write_cfg_dw(chip, 2, 0xC0, - 0xFFFF, val); - else - rtsx_write_cfg_dw(chip, 1, 0xC0, - 0xFFFF, val); - } + if (CHECK_PID(chip, 0x5288)) + rtsx_write_cfg_dw(chip, 2, 0xC0, + 0xFFFF, val); + else + rtsx_write_cfg_dw(chip, 1, 0xC0, + 0xFFFF, val); } } } @@ -1830,21 +1820,19 @@ void rtsx_disable_aspm(struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5208)) rtsx_monitor_aspm_config(chip); - if (chip->aspm_l0s_l1_en && chip->dynamic_aspm) { - if (chip->aspm_enabled) { - dev_dbg(rtsx_dev(chip), "Try to disable ASPM\n"); - chip->aspm_enabled = 0; + if (chip->aspm_l0s_l1_en && chip->dynamic_aspm && chip->aspm_enabled) { + dev_dbg(rtsx_dev(chip), "Try to disable ASPM\n"); + chip->aspm_enabled = 0; - if (chip->asic_code && CHECK_PID(chip, 0x5208)) - rtsx_write_phy_register(chip, 0x07, 0x0129); - if (CHECK_PID(chip, 0x5208)) - rtsx_write_register(chip, ASPM_FORCE_CTL, - 0xF3, 0x30); - else - rtsx_write_config_byte(chip, LCTLR, 0x00); + if (chip->asic_code && CHECK_PID(chip, 0x5208)) + rtsx_write_phy_register(chip, 0x07, 0x0129); + if (CHECK_PID(chip, 0x5208)) + rtsx_write_register(chip, ASPM_FORCE_CTL, + 0xF3, 0x30); + else + rtsx_write_config_byte(chip, LCTLR, 0x00); - wait_timeout(1); - } + wait_timeout(1); } } -- cgit v1.2.3-59-g8ed1b From e050dda1e5de6e39dc6b3dbed9571e6b430e6f54 Mon Sep 17 00:00:00 2001 From: Giedrius Statkevičius Date: Sat, 4 Oct 2014 00:31:18 +0300 Subject: staging: rts5208: get rid of Camel Case, remove unneeded lines and parantheses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert labels from Camel Case to lower case, remove unnecessary parantheses around operands of dereference operators and remove unneeded empty lines before }. Gets rid of a checkpatch.pl "check" that code should avoid Camel Case, also the code had a bunch of &(a) where a is some variable so it gets rid of them too. Finally, in a few places there were a empty line before } so remove them. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 52 +++++++++++++++---------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 0db63fbe3db4..146b33734b74 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -314,7 +314,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - } chip->aspm_enabled = 1; @@ -345,7 +344,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - } if (CHECK_PID(chip, 0x5288) && !CHK_SDIO_EXIST(chip)) { @@ -397,7 +395,6 @@ int rtsx_reset_chip(struct rtsx_chip *chip) reg); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - } if (chip->driver_first_load && @@ -416,7 +413,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip) chip->int_reg = rtsx_readl(chip, RTSX_BIPR); if (chip->hw_bypass_sd) - goto NextCard; + goto nextcard; dev_dbg(rtsx_dev(chip), "In %s, chip->int_reg = 0x%x\n", __func__, chip->int_reg); if (chip->int_reg & SD_EXIST) { @@ -440,7 +437,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip) 0); } -NextCard: +nextcard: if (chip->int_reg & XD_EXIST) chip->need_reset |= XD_CARD; if (chip->int_reg & MS_EXIST) @@ -646,7 +643,6 @@ static int rts5288_init(struct rtsx_chip *chip) chip->lun_mode = SD_MS_1LUN; else chip->lun_mode = DEFAULT_SINGLE; - } return STATUS_SUCCESS; @@ -654,9 +650,9 @@ static int rts5288_init(struct rtsx_chip *chip) int rtsx_init_chip(struct rtsx_chip *chip) { - struct sd_info *sd_card = &(chip->sd_card); - struct xd_info *xd_card = &(chip->xd_card); - struct ms_info *ms_card = &(chip->ms_card); + struct sd_info *sd_card = &chip->sd_card; + struct xd_info *xd_card = &chip->xd_card; + struct ms_info *ms_card = &chip->ms_card; int retval; unsigned int i; @@ -734,7 +730,6 @@ int rtsx_init_chip(struct rtsx_chip *chip) retval = rts5288_init(chip); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - } if (chip->ss_en == 2) @@ -836,7 +831,6 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip) } else { if (reg0 & 0x03) maybe_support_aspm = 1; - } if (reg_changed) { @@ -861,7 +855,7 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip) void rtsx_polling_func(struct rtsx_chip *chip) { #ifdef SUPPORT_SD_LOCK - struct sd_info *sd_card = &(chip->sd_card); + struct sd_info *sd_card = &chip->sd_card; #endif int ss_allowed; @@ -869,7 +863,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) return; if (rtsx_chk_stat(chip, RTSX_STAT_DELINK)) - goto Delink_Stage; + goto delink_stage; if (chip->polling_config) { u8 val; @@ -882,7 +876,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) #ifdef SUPPORT_OCP if (chip->ocp_int) { - rtsx_read_register(chip, OCPSTAT, &(chip->ocp_stat)); + rtsx_read_register(chip, OCPSTAT, &chip->ocp_stat); if (chip->card_exist & SD_CARD) sd_power_off_card3v3(chip); @@ -926,7 +920,6 @@ void rtsx_polling_func(struct rtsx_chip *chip) rtsx_read_cfg_dw(chip, 1, 0x04, &val); if (val & 0x07) ss_allowed = 0; - } } } else { @@ -984,7 +977,6 @@ void rtsx_polling_func(struct rtsx_chip *chip) if (chip->auto_power_down && !chip->card_ready && !chip->sd_io) rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL); - } } @@ -1007,7 +999,6 @@ void rtsx_polling_func(struct rtsx_chip *chip) break; } - #ifdef SUPPORT_OCP if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) { if (chip->ocp_stat & @@ -1053,7 +1044,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) } #endif -Delink_Stage: +delink_stage: if (chip->auto_delink_en && chip->auto_delink_allowed && !chip->card_ready && !chip->card_ejected && !chip->sd_io) { int enter_L1 = chip->auto_delink_in_L1 && ( @@ -1095,7 +1086,6 @@ Delink_Stage: if (enter_L1) rtsx_enter_L1(chip); - } } @@ -1670,12 +1660,12 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip) if (status & SD_INT) { if (status & SD_EXIST) { - set_bit(SD_NR, &(chip->need_reset)); + set_bit(SD_NR, &chip->need_reset); } else { - set_bit(SD_NR, &(chip->need_release)); + set_bit(SD_NR, &chip->need_release); chip->sd_reset_counter = 0; chip->sd_show_cnt = 0; - clear_bit(SD_NR, &(chip->need_reset)); + clear_bit(SD_NR, &chip->need_reset); } } else { /* If multi-luns, it's possible that @@ -1685,35 +1675,35 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip) all existed cards should be reset. */ if (exit_ss && (status & SD_EXIST)) - set_bit(SD_NR, &(chip->need_reinit)); + set_bit(SD_NR, &chip->need_reinit); } if (!CHECK_PID(chip, 0x5288) || CHECK_BARO_PKG(chip, QFN)) { if (status & XD_INT) { if (status & XD_EXIST) { - set_bit(XD_NR, &(chip->need_reset)); + set_bit(XD_NR, &chip->need_reset); } else { - set_bit(XD_NR, &(chip->need_release)); + set_bit(XD_NR, &chip->need_release); chip->xd_reset_counter = 0; chip->xd_show_cnt = 0; - clear_bit(XD_NR, &(chip->need_reset)); + clear_bit(XD_NR, &chip->need_reset); } } else { if (exit_ss && (status & XD_EXIST)) - set_bit(XD_NR, &(chip->need_reinit)); + set_bit(XD_NR, &chip->need_reinit); } } if (status & MS_INT) { if (status & MS_EXIST) { - set_bit(MS_NR, &(chip->need_reset)); + set_bit(MS_NR, &chip->need_reset); } else { - set_bit(MS_NR, &(chip->need_release)); + set_bit(MS_NR, &chip->need_release); chip->ms_reset_counter = 0; chip->ms_show_cnt = 0; - clear_bit(MS_NR, &(chip->need_reset)); + clear_bit(MS_NR, &chip->need_reset); } } else { if (exit_ss && (status & MS_EXIST)) - set_bit(MS_NR, &(chip->need_reinit)); + set_bit(MS_NR, &chip->need_reinit); } } -- cgit v1.2.3-59-g8ed1b From 21e69b7274ca82b0d180a0a7353ab79bed98509a Mon Sep 17 00:00:00 2001 From: Giedrius Statkevičius Date: Sat, 4 Oct 2014 00:31:19 +0300 Subject: staging: rts5208: align divided lines to opening paranthesis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make all divided lines aligned to the opening paranthesis. Basically makes all lines aligned to the opening paranthesis to make the code more readable and it also gets rid of a lot of checkpatch.pl "checks". Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 87 +++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 146b33734b74..b47eadee2571 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -126,10 +126,11 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip) if (chip->ignore_sd && CHK_SDIO_EXIST(chip)) { if (chip->asic_code) { RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF, - MS_INS_PU | SD_WP_PU | SD_CD_PU | SD_CMD_PU); + MS_INS_PU | SD_WP_PU | + SD_CD_PU | SD_CMD_PU); } else { RTSX_WRITE_REG(chip, FPGA_PULL_CTL, 0xFF, - FPGA_SD_PULL_CTL_EN); + FPGA_SD_PULL_CTL_EN); } RTSX_WRITE_REG(chip, CARD_SHARE_MODE, 0xFF, CARD_SHARE_48_SD); @@ -137,7 +138,7 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip) RTSX_WRITE_REG(chip, 0xFF2C, 0x01, 0x01); RTSX_WRITE_REG(chip, SDIO_CTRL, 0xFF, - SDIO_BUS_CTRL | SDIO_CD_CTRL); + SDIO_BUS_CTRL | SDIO_CD_CTRL); chip->sd_int = 1; chip->sd_io = 1; @@ -201,7 +202,7 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); } else { RTSX_WRITE_REG(chip, FPGA_PULL_CTL, - FPGA_SD_PULL_CTL_BIT | 0x20, 0); + FPGA_SD_PULL_CTL_BIT | 0x20, 0); } retval = card_share_mode(chip, SD_CARD); if (retval != STATUS_SUCCESS) @@ -268,7 +269,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip) #ifdef LED_AUTO_BLINK RTSX_WRITE_REG(chip, CARD_AUTO_BLINK, 0xFF, - LED_BLINK_SPEED | BLINK_EN | LED_GPIO0); + LED_BLINK_SPEED | BLINK_EN | LED_GPIO0); #endif if (chip->asic_code) { @@ -297,7 +298,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip) } else { if (CHECK_PID(chip, 0x5208)) RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, - 0xFF, 0x3F); + 0xFF, 0x3F); retval = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en); @@ -337,10 +338,10 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (CHK_SDIO_EXIST(chip)) { if (CHECK_PID(chip, 0x5288)) retval = rtsx_write_cfg_dw(chip, 2, 0xC0, - 0xFF00, 0x0100); + 0xFF00, 0x0100); else retval = rtsx_write_cfg_dw(chip, 1, 0xC0, - 0xFF00, 0x0100); + 0xFF00, 0x0100); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); @@ -381,7 +382,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip) reg &= 0xFE7F; reg |= 0x80; retval = rtsx_write_phy_register(chip, 0x00, - reg); + reg); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); @@ -392,13 +393,13 @@ int rtsx_reset_chip(struct rtsx_chip *chip) reg &= 0xFFF7; retval = rtsx_write_phy_register(chip, 0x1C, - reg); + reg); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); } if (chip->driver_first_load && - (chip->ic_version < IC_VER_C)) + (chip->ic_version < IC_VER_C)) rtsx_calibration(chip); } else { @@ -434,7 +435,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip) } else { chip->sd_io = 0; RTSX_WRITE_REG(chip, SDIO_CTRL, SDIO_BUS_CTRL | SDIO_CD_CTRL, - 0); + 0); } nextcard: @@ -475,10 +476,10 @@ nextcard: if (chip->ft2_fast_mode) { RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0xFF, - MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON); + MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON); udelay(chip->pmos_pwr_on_interval); RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0xFF, - MS_POWER_ON | SD_POWER_ON); + MS_POWER_ON | SD_POWER_ON); wait_timeout(200); } @@ -847,8 +848,8 @@ static void rtsx_monitor_aspm_config(struct rtsx_chip *chip) chip->sdio_aspm = 0; } rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFF, - 0x30 | chip->aspm_level[0] | - (chip->aspm_level[1] << 2)); + 0x30 | chip->aspm_level[0] | + (chip->aspm_level[1] << 2)); } } @@ -945,7 +946,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) #ifdef SUPPORT_SDIO_ASPM if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip) && - chip->aspm_l0s_l1_en && chip->dynamic_aspm) { + chip->aspm_l0s_l1_en && chip->dynamic_aspm) { if (chip->sd_io) { dynamic_configure_sdio_aspm(chip); } else { @@ -1009,7 +1010,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { if (chip->card_exist & SD_CARD) { rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, - 0); + 0); card_power_off(chip, SD_CARD); chip->card_fail |= SD_CARD; } @@ -1017,7 +1018,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) if (chip->ocp_stat & (MS_OC_NOW | MS_OC_EVER)) { if (chip->card_exist & MS_CARD) { rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, - 0); + 0); card_power_off(chip, MS_CARD); chip->card_fail |= MS_CARD; } @@ -1028,15 +1029,15 @@ void rtsx_polling_func(struct rtsx_chip *chip) chip->ocp_stat); if (chip->card_exist & SD_CARD) { rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, - 0); + 0); chip->card_fail |= SD_CARD; } else if (chip->card_exist & MS_CARD) { rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, - 0); + 0); chip->card_fail |= MS_CARD; } else if (chip->card_exist & XD_CARD) { rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, - 0); + 0); chip->card_fail |= XD_CARD; } card_power_off(chip, SD_CARD); @@ -1046,7 +1047,7 @@ void rtsx_polling_func(struct rtsx_chip *chip) delink_stage: if (chip->auto_delink_en && chip->auto_delink_allowed && - !chip->card_ready && !chip->card_ejected && !chip->sd_io) { + !chip->card_ready && !chip->card_ejected && !chip->sd_io) { int enter_L1 = chip->auto_delink_in_L1 && ( chip->aspm_l0s_l1_en || chip->ss_en); int delink_stage1_cnt = chip->delink_stage1_step; @@ -1069,8 +1070,8 @@ delink_stage: rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1); rtsx_write_register(chip, - CHANGE_LINK_STATE, 0x0A, - 0x0A); + CHANGE_LINK_STATE, + 0x0A, 0x0A); if (enter_L1) rtsx_enter_L1(chip); @@ -1082,7 +1083,9 @@ delink_stage: if (enter_L1) rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1); - rtsx_write_register(chip, CHANGE_LINK_STATE, 0x02, 0x02); + rtsx_write_register(chip, + CHANGE_LINK_STATE, + 0x02, 0x02); if (enter_L1) rtsx_enter_L1(chip); @@ -1099,7 +1102,7 @@ delink_stage: rtsx_set_phy_reg_bit(chip, 0x1C, 2); rtsx_write_register(chip, CHANGE_LINK_STATE, - 0x0A, 0x0A); + 0x0A, 0x0A); } chip->auto_delink_cnt++; @@ -1203,7 +1206,7 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 addr, u8 *data) } int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask, - u32 val) + u32 val) { u8 mode = 0, tmp; int i; @@ -1263,7 +1266,7 @@ int rtsx_read_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 *val) } int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, - int len) + int len) { u32 *data, *mask; u16 offset = addr % 4; @@ -1308,7 +1311,7 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, for (i = 0; i < dw_len; i++) { retval = rtsx_write_cfg_dw(chip, func, aligned_addr + i * 4, - mask[i], data[i]); + mask[i], data[i]); if (retval != STATUS_SUCCESS) { vfree(data); vfree(mask); @@ -1323,7 +1326,7 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, } int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, - int len) + int len) { u32 *data; u16 offset = addr % 4; @@ -1344,7 +1347,7 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, for (i = 0; i < dw_len; i++) { retval = rtsx_read_cfg_dw(chip, func, aligned_addr + i * 4, - data + i); + data + i); if (retval != STATUS_SUCCESS) { vfree(data); TRACE_RET(chip, STATUS_FAIL); @@ -1650,7 +1653,7 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip) chip->int_reg = rtsx_readl(chip, RTSX_BIPR); if (((chip->int_reg & int_enable) == 0) || - (chip->int_reg == 0xFFFFFFFF)) + (chip->int_reg == 0xFFFFFFFF)) return STATUS_FAIL; status = chip->int_reg &= (int_enable | 0x7FFFFF); @@ -1756,14 +1759,14 @@ void rtsx_do_before_power_down(struct rtsx_chip *chip, int pm_stat) if (pm_stat == PM_S1) { dev_dbg(rtsx_dev(chip), "Host enter S1\n"); rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, - HOST_ENTER_S1); + HOST_ENTER_S1); } else if (pm_stat == PM_S3) { if (chip->s3_pwr_off_delay > 0) wait_timeout(chip->s3_pwr_off_delay); dev_dbg(rtsx_dev(chip), "Host enter S3\n"); rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, - HOST_ENTER_S3); + HOST_ENTER_S3); } if (chip->do_delink_before_power_down && chip->auto_delink_en) @@ -1786,10 +1789,10 @@ void rtsx_enable_aspm(struct rtsx_chip *chip) rtsx_write_phy_register(chip, 0x07, 0); if (CHECK_PID(chip, 0x5208)) { rtsx_write_register(chip, ASPM_FORCE_CTL, 0xF3, - 0x30 | chip->aspm_level[0]); + 0x30 | chip->aspm_level[0]); } else { rtsx_write_config_byte(chip, LCTLR, - chip->aspm_l0s_l1_en); + chip->aspm_l0s_l1_en); } if (CHK_SDIO_EXIST(chip)) { @@ -1797,10 +1800,10 @@ void rtsx_enable_aspm(struct rtsx_chip *chip) if (CHECK_PID(chip, 0x5288)) rtsx_write_cfg_dw(chip, 2, 0xC0, - 0xFFFF, val); + 0xFFFF, val); else rtsx_write_cfg_dw(chip, 1, 0xC0, - 0xFFFF, val); + 0xFFFF, val); } } } @@ -1818,7 +1821,7 @@ void rtsx_disable_aspm(struct rtsx_chip *chip) rtsx_write_phy_register(chip, 0x07, 0x0129); if (CHECK_PID(chip, 0x5208)) rtsx_write_register(chip, ASPM_FORCE_CTL, - 0xF3, 0x30); + 0xF3, 0x30); else rtsx_write_config_byte(chip, LCTLR, 0x00); @@ -1885,7 +1888,7 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) for (j = 0; j < 256; j++) { rtsx_add_cmd(chip, WRITE_REG_CMD, reg_addr++, 0xFF, - *ptr); + *ptr); ptr++; } @@ -1899,7 +1902,7 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len) for (j = 0; j < buf_len%256; j++) { rtsx_add_cmd(chip, WRITE_REG_CMD, reg_addr++, 0xFF, - *ptr); + *ptr); ptr++; } -- cgit v1.2.3-59-g8ed1b From fbbf359c4ca026e631fde19caff765af5c1afb12 Mon Sep 17 00:00:00 2001 From: Giedrius Statkevičius Date: Sat, 4 Oct 2014 00:31:20 +0300 Subject: staging: rts5208: divide lines to make them less than 80 characters long MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make a couple of lines shorter than the max limit by diving them and also make sure to align them properly where possible. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index b47eadee2571..71dc6eea75d3 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -291,7 +291,8 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (chip->aspm_l0s_l1_en) { if (chip->dynamic_aspm) { if (CHK_SDIO_EXIST(chip) && CHECK_PID(chip, 0x5288)) { - retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en); + retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, + chip->aspm_l0s_l1_en); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); } @@ -309,9 +310,13 @@ int rtsx_reset_chip(struct rtsx_chip *chip) if (CHK_SDIO_EXIST(chip)) { chip->aspm_level[1] = chip->aspm_l0s_l1_en; if (CHECK_PID(chip, 0x5288)) - retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en); + retval = rtsx_write_cfg_dw(chip, 2, + 0xC0, 0xFF, + chip->aspm_l0s_l1_en); else - retval = rtsx_write_cfg_dw(chip, 1, 0xC0, 0xFF, chip->aspm_l0s_l1_en); + retval = rtsx_write_cfg_dw(chip, 1, + 0xC0, 0xFF, + chip->aspm_l0s_l1_en); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); @@ -954,7 +959,8 @@ void rtsx_polling_func(struct rtsx_chip *chip) dev_dbg(rtsx_dev(chip), "SDIO enter ASPM!\n"); rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFC, - 0x30 | (chip->aspm_level[1] << 2)); + 0x30 | + (chip->aspm_level[1] << 2)); chip->sdio_aspm = 1; } } @@ -976,8 +982,10 @@ void rtsx_polling_func(struct rtsx_chip *chip) turn_off_led(chip, LED_GPIO); - if (chip->auto_power_down && !chip->card_ready && !chip->sd_io) - rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL); + if (chip->auto_power_down && !chip->card_ready && + !chip->sd_io) + rtsx_force_power_down(chip, + SSC_PDCTL | OC_PDCTL); } } @@ -1067,7 +1075,9 @@ delink_stage: dev_dbg(rtsx_dev(chip), "False card inserted, do force delink\n"); if (enter_L1) - rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1); + rtsx_write_register(chip, + HOST_SLEEP_STATE, + 0x03, 1); rtsx_write_register(chip, CHANGE_LINK_STATE, @@ -1076,12 +1086,15 @@ delink_stage: if (enter_L1) rtsx_enter_L1(chip); - chip->auto_delink_cnt = delink_stage3_cnt + 1; + chip->auto_delink_cnt = + delink_stage3_cnt + 1; } else { dev_dbg(rtsx_dev(chip), "No card inserted, do delink\n"); if (enter_L1) - rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 1); + rtsx_write_register(chip, + HOST_SLEEP_STATE, + 0x03, 1); rtsx_write_register(chip, CHANGE_LINK_STATE, -- cgit v1.2.3-59-g8ed1b From 609fc15ef8908aff8822f26a7a987d12246cbc3f Mon Sep 17 00:00:00 2001 From: Giedrius Statkevičius Date: Sat, 4 Oct 2014 00:31:21 +0300 Subject: staging: rts5208: use ternary operators to reduce indentation level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert code in format of if (a) if(b) { [...] } to one line with a simple ternary operation to avoid unnecesary increase of indentation level. Signed-off-by: Giedrius Statkevičius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 90 ++++++++++--------------------------- 1 file changed, 23 insertions(+), 67 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 71dc6eea75d3..ffcf5deb49b2 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -309,14 +309,10 @@ int rtsx_reset_chip(struct rtsx_chip *chip) chip->aspm_level[0] = chip->aspm_l0s_l1_en; if (CHK_SDIO_EXIST(chip)) { chip->aspm_level[1] = chip->aspm_l0s_l1_en; - if (CHECK_PID(chip, 0x5288)) - retval = rtsx_write_cfg_dw(chip, 2, - 0xC0, 0xFF, - chip->aspm_l0s_l1_en); - else - retval = rtsx_write_cfg_dw(chip, 1, - 0xC0, 0xFF, - chip->aspm_l0s_l1_en); + retval = rtsx_write_cfg_dw(chip, + CHECK_PID(chip, 0x5288) ? 2 : 1, + 0xC0, 0xFF, + chip->aspm_l0s_l1_en); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); @@ -341,12 +337,9 @@ int rtsx_reset_chip(struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); if (CHK_SDIO_EXIST(chip)) { - if (CHECK_PID(chip, 0x5288)) - retval = rtsx_write_cfg_dw(chip, 2, 0xC0, - 0xFF00, 0x0100); - else - retval = rtsx_write_cfg_dw(chip, 1, 0xC0, - 0xFF00, 0x0100); + retval = rtsx_write_cfg_dw(chip, + CHECK_PID(chip, 0x5288) ? 2 : 1, + 0xC0, 0xFF00, 0x0100); if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); @@ -537,10 +530,7 @@ static int rts5208_init(struct rtsx_chip *chip) RTSX_WRITE_REG(chip, CLK_SEL, 0x03, 0x03); RTSX_READ_REG(chip, CLK_SEL, &val); - if (val == 0) - chip->asic_code = 1; - else - chip->asic_code = 0; + chip->asic_code = val == 0 ? 1 : 0; if (chip->asic_code) { retval = rtsx_read_phy_register(chip, 0x1C, ®); @@ -550,10 +540,7 @@ static int rts5208_init(struct rtsx_chip *chip) dev_dbg(rtsx_dev(chip), "Value of phy register 0x1C is 0x%x\n", reg); chip->ic_version = (reg >> 4) & 0x07; - if (reg & PHY_DEBUG_MODE) - chip->phy_debug_mode = 1; - else - chip->phy_debug_mode = 0; + chip->phy_debug_mode = reg & PHY_DEBUG_MODE ? 1 : 0; } else { RTSX_READ_REG(chip, 0xFE80, &val); @@ -563,16 +550,10 @@ static int rts5208_init(struct rtsx_chip *chip) RTSX_READ_REG(chip, PDINFO, &val); dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val); - if (val & AUX_PWR_DETECTED) - chip->aux_pwr_exist = 1; - else - chip->aux_pwr_exist = 0; + chip->aux_pwr_exist = val & AUX_PWR_DETECTED ? 1 : 0; RTSX_READ_REG(chip, 0xFE50, &val); - if (val & 0x01) - chip->hw_bypass_sd = 1; - else - chip->hw_bypass_sd = 0; + chip->hw_bypass_sd = val & 0x01 ? 1 : 0; rtsx_read_config_byte(chip, 0x0E, &val); if (val & 0x80) @@ -582,10 +563,7 @@ static int rts5208_init(struct rtsx_chip *chip) if (chip->use_hw_setting) { RTSX_READ_REG(chip, CHANGE_LINK_STATE, &val); - if (val & 0x80) - chip->auto_delink_en = 1; - else - chip->auto_delink_en = 0; + chip->auto_delink_en = val & 0x80 ? 1 : 0; } return STATUS_SUCCESS; @@ -599,33 +577,21 @@ static int rts5288_init(struct rtsx_chip *chip) RTSX_WRITE_REG(chip, CLK_SEL, 0x03, 0x03); RTSX_READ_REG(chip, CLK_SEL, &val); - if (val == 0) - chip->asic_code = 1; - else - chip->asic_code = 0; + chip->asic_code = val == 0 ? 1 : 0; chip->ic_version = 0; chip->phy_debug_mode = 0; RTSX_READ_REG(chip, PDINFO, &val); dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val); - if (val & AUX_PWR_DETECTED) - chip->aux_pwr_exist = 1; - else - chip->aux_pwr_exist = 0; + chip->aux_pwr_exist = val & AUX_PWR_DETECTED ? 1 : 0; RTSX_READ_REG(chip, CARD_SHARE_MODE, &val); dev_dbg(rtsx_dev(chip), "CARD_SHARE_MODE: 0x%x\n", val); - if (val & 0x04) - chip->baro_pkg = QFN; - else - chip->baro_pkg = LQFP; + chip->baro_pkg = val & 0x04 ? QFN : LQFP; RTSX_READ_REG(chip, 0xFE5A, &val); - if (val & 0x10) - chip->hw_bypass_sd = 1; - else - chip->hw_bypass_sd = 0; + chip->hw_bypass_sd = val & 0x10 ? 1 : 0; retval = rtsx_read_cfg_dw(chip, 0, 0x718, &lval); if (retval != STATUS_SUCCESS) @@ -640,10 +606,7 @@ static int rts5288_init(struct rtsx_chip *chip) if (chip->use_hw_setting) { RTSX_READ_REG(chip, CHANGE_LINK_STATE, &val); - if (val & 0x80) - chip->auto_delink_en = 1; - else - chip->auto_delink_en = 0; + chip->auto_delink_en = val & 0x80 ? 1 : 0; if (CHECK_BARO_PKG(chip, LQFP)) chip->lun_mode = SD_MS_1LUN; @@ -1522,7 +1485,7 @@ int rtsx_set_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit) if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - if (0 == (value & (1 << bit))) { + if ((value & (1 << bit)) == 0) { value |= (1 << bit); retval = rtsx_write_phy_register(chip, reg, value); if (retval != STATUS_SUCCESS) @@ -1595,12 +1558,9 @@ void rtsx_enter_ss(struct rtsx_chip *chip) rtsx_force_power_down(chip, SSC_PDCTL | OC_PDCTL); } - if (CHK_SDIO_EXIST(chip)) { - if (CHECK_PID(chip, 0x5288)) - rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF00, 0x0100); - else - rtsx_write_cfg_dw(chip, 1, 0xC0, 0xFF00, 0x0100); - } + if (CHK_SDIO_EXIST(chip)) + rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1, + 0xC0, 0xFF00, 0x0100); if (chip->auto_delink_en) { rtsx_write_register(chip, HOST_SLEEP_STATE, 0x01, 0x01); @@ -1811,12 +1771,8 @@ void rtsx_enable_aspm(struct rtsx_chip *chip) if (CHK_SDIO_EXIST(chip)) { u16 val = chip->aspm_l0s_l1_en | 0x0100; - if (CHECK_PID(chip, 0x5288)) - rtsx_write_cfg_dw(chip, 2, 0xC0, - 0xFFFF, val); - else - rtsx_write_cfg_dw(chip, 1, 0xC0, - 0xFFFF, val); + rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1, + 0xC0, 0xFFF, val); } } } -- cgit v1.2.3-59-g8ed1b From 9109fcff29c67ccdd541fa2bcd1cd58a1134ddf9 Mon Sep 17 00:00:00 2001 From: Aleh Suprunovich Date: Tue, 7 Oct 2014 14:52:52 +0300 Subject: staging: octeon-usb: fix checkpatch.pl warnings fixed several 'line over 80 characters' in places where it can be done without changing/refactoring code Signed-off-by: Aleh Suprunovich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 7ac64efc6520..4337a2fe282e 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1327,7 +1327,8 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb) /* Loop writing the FIFO data for this packet into memory */ while (bytes > 0) { - *ptr++ = __cvmx_usb_read_csr32(usb, USB_FIFO_ADDRESS(channel, usb->index)); + *ptr++ = __cvmx_usb_read_csr32(usb, + USB_FIFO_ADDRESS(channel, usb->index)); bytes -= 4; } CVMX_SYNCW; @@ -1478,7 +1479,8 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) fifo = &usb->nonperiodic; fifo->entry[fifo->head].channel = channel; - fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8); + fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb, + CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8); fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize+3)>>2; fifo->head++; if (fifo->head > MAX_CHANNELS) @@ -1699,7 +1701,9 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, usbc_hcintmsk.s.stallmsk = 1; usbc_hcintmsk.s.xfercomplmsk = 1; } - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), usbc_hcintmsk.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCINTMSKX(channel, usb->index), + usbc_hcintmsk.u32); /* Enable the channel interrupt to propagate */ usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb, @@ -2879,9 +2883,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) struct usb_ctrlrequest *header = cvmx_phys_to_ptr(transaction->control_header); if (header->wLength) - transaction->stage = CVMX_USB_STAGE_DATA; + transaction->stage = + CVMX_USB_STAGE_DATA; else - transaction->stage = CVMX_USB_STAGE_STATUS; + transaction->stage = + CVMX_USB_STAGE_STATUS; } break; case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: @@ -2889,9 +2895,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) struct usb_ctrlrequest *header = cvmx_phys_to_ptr(transaction->control_header); if (header->wLength) - transaction->stage = CVMX_USB_STAGE_DATA; + transaction->stage = + CVMX_USB_STAGE_DATA; else - transaction->stage = CVMX_USB_STAGE_STATUS; + transaction->stage = + CVMX_USB_STAGE_STATUS; } break; case CVMX_USB_STAGE_DATA: @@ -3013,7 +3021,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * is complete, the pipe sleeps until the next * schedule interval */ - if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { + if (pipe->transfer_dir == + CVMX_USB_DIRECTION_OUT) { /* * If no space left or this wasn't a max * size packet then this transfer is -- cgit v1.2.3-59-g8ed1b From b9fc9cf29e5d5a545bd00b7fa4eed2c9ae3e3ccb Mon Sep 17 00:00:00 2001 From: Roberto Medina Date: Wed, 8 Oct 2014 21:18:44 +0200 Subject: Staging: octeon: ethernet-tx: fixed coding style warnings, missing blank lines Fixed coding style warnings due to missing blank lines. Dubious additions removed. Signed-off-by: Roberto Medina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-tx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 4e54d8540219..b7a7854d3f7e 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -77,6 +77,7 @@ static DECLARE_TASKLET(cvm_oct_tx_cleanup_tasklet, cvm_oct_tx_do_cleanup, 0); static inline int32_t cvm_oct_adjust_skb_to_free(int32_t skb_to_free, int fau) { int32_t undo; + undo = skb_to_free > 0 ? MAX_SKB_TO_FREE : skb_to_free + MAX_SKB_TO_FREE; if (undo > 0) @@ -89,6 +90,7 @@ static inline int32_t cvm_oct_adjust_skb_to_free(int32_t skb_to_free, int fau) static void cvm_oct_kick_tx_poll_watchdog(void) { union cvmx_ciu_timx ciu_timx; + ciu_timx.u64 = 0; ciu_timx.s.one_shot = 1; ciu_timx.s.len = cvm_oct_tx_poll_interval; @@ -118,9 +120,11 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev) total_freed += skb_to_free; if (skb_to_free > 0) { struct sk_buff *to_free_list = NULL; + spin_lock_irqsave(&priv->tx_free_list[qos].lock, flags); while (skb_to_free > 0) { struct sk_buff *t; + t = __skb_dequeue(&priv->tx_free_list[qos]); t->next = to_free_list; to_free_list = t; @@ -131,6 +135,7 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev) /* Do the actual freeing outside of the lock. */ while (to_free_list) { struct sk_buff *t = to_free_list; + to_free_list = to_free_list->next; dev_kfree_skb_any(t); } @@ -258,6 +263,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); if (gmx_prt_cfg.s.duplex == 0) { int add_bytes = 64 - skb->len; + if ((skb_tail_pointer(skb) + add_bytes) <= skb_end_pointer(skb)) memset(__skb_put(skb, add_bytes), 0, @@ -289,6 +295,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) CVM_OCT_SKB_CB(skb)[0] = hw_buffer.u64; for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { struct skb_frag_struct *fs = skb_shinfo(skb)->frags + i; + hw_buffer.s.addr = XKPHYS_TO_PHYS( (u64)(page_address(fs->page.p) + fs->page_offset)); @@ -495,6 +502,7 @@ skip_xmit: while (skb_to_free > 0) { struct sk_buff *t = __skb_dequeue(&priv->tx_free_list[qos]); + t->next = to_free_list; to_free_list = t; skb_to_free--; @@ -505,6 +513,7 @@ skip_xmit: /* Do the actual freeing outside of the lock. */ while (to_free_list) { struct sk_buff *t = to_free_list; + to_free_list = to_free_list->next; dev_kfree_skb_any(t); } @@ -550,6 +559,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev) /* Get a work queue entry */ cvmx_wqe_t *work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL); + if (unlikely(work == NULL)) { printk_ratelimited("%s: Failed to allocate a work queue entry\n", dev->name); @@ -713,6 +723,7 @@ static void cvm_oct_tx_do_cleanup(unsigned long arg) for (port = 0; port < TOTAL_NUMBER_OF_PORTS; port++) { if (cvm_oct_device[port]) { struct net_device *dev = cvm_oct_device[port]; + cvm_oct_free_tx_skbs(dev); } } -- cgit v1.2.3-59-g8ed1b From fbc6d797e90fb502c3b2151158fb8e9d3feae7db Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:10 +0300 Subject: staging: rtl8723au: core: rtw_cmd: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_ap.c Warning: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 4eaa50297b95..d2d7edf38fc6 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -359,6 +359,7 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, /* prepare ssid list */ if (ssid) { int i; + for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { if (ssid[i].ssid_len) { memcpy(&psurveyPara->ssid[i], &ssid[i], @@ -371,6 +372,7 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, /* prepare channel list */ if (ch) { int i; + for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { if (ch[i].hw_value && !(ch[i].flags & IEEE80211_CHAN_DISABLED)) { @@ -719,6 +721,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); } else { int idx = psecuritypriv->dot118021XGrpKeyid; + memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[idx].skey, 16); } -- cgit v1.2.3-59-g8ed1b From 99ea15d6599177149393d62075ec29d61bea5fc3 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:12 +0300 Subject: staging: rtl8723au: core: rtw_ieee80211: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_ieee80211.c Warning: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 6274cb397c92..c78d6eb0ef89 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -69,6 +69,7 @@ int rtw_get_bit_value_from_ieee_value23a(u8 val) {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; int i = 0; + while (dot11_rate_table[i] != 0) { if (dot11_rate_table[i] == val) return BIT(i); -- cgit v1.2.3-59-g8ed1b From 96d92eb7165170f45dd62dc6c71361ecca25e4b8 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:13 +0300 Subject: staging: rtl8723au: core: rtw_led: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_led.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_led.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8723au/core/rtw_led.c b/drivers/staging/rtl8723au/core/rtw_led.c index fa3dcff263d7..c66e727a2bca 100644 --- a/drivers/staging/rtl8723au/core/rtw_led.c +++ b/drivers/staging/rtl8723au/core/rtw_led.c @@ -44,6 +44,7 @@ static void BlinkTimerCallback(unsigned long data) void BlinkWorkItemCallback23a(struct work_struct *work) { struct led_8723a *pLed = container_of(work, struct led_8723a, BlinkWorkItem); + BlinkHandler23a(pLed); } -- cgit v1.2.3-59-g8ed1b From 29ed932fb25a952b80d4f64c860c7d6e3c6ea796 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:14 +0300 Subject: staging: rtl8723au: core: rtw_mlme: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_mlme.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 00e7ad06b5bd..62894702be29 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1515,18 +1515,21 @@ out: inline bool rtw_is_scan_deny(struct rtw_adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; + return (atomic_read(&mlmepriv->set_scan_deny) != 0) ? true : false; } void rtw_clear_scan_deny(struct rtw_adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; + atomic_set(&mlmepriv->set_scan_deny, 0); } void rtw_set_scan_deny_timer_hdl(unsigned long data) { struct rtw_adapter *adapter = (struct rtw_adapter *)data; + rtw_clear_scan_deny(adapter); } @@ -2151,6 +2154,7 @@ bool rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, if (p && p[1] > 0) { u32 rx_packet_offset, max_recvbuf_sz; + if (pmlmepriv->qos_option == 0) { out_len = *pout_len; pframe = rtw_set_ie23a(out_ie + out_len, -- cgit v1.2.3-59-g8ed1b From 2ce71bda7bc16e1d2530f48e506a26529141231f Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:15 +0300 Subject: staging: rtl8723au: core: rtw_mlme_ext: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_mlme_ext.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 3eb77de17e3a..9298b382b6c6 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -331,6 +331,7 @@ rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt) int rtw_ch_set_search_ch23a(struct rt_channel_info *ch_set, const u32 ch) { int i; + for (i = 0; ch_set[i]. ChannelNum != 0; i++) { if (ch == ch_set[i].ChannelNum) break; @@ -1572,6 +1573,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->uapsd_bk = 0; if (pmlmepriv->qos_option) { const u8 *end = pos + left; + p = pos; for (;;) { @@ -2599,7 +2601,9 @@ static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da, if (ssid_ie && cur_network->Ssid.ssid_len) { uint remainder_ielen; u8 *remainder_ie; + remainder_ie = ssid_ie + 2; + remainder_ielen = pframe - remainder_ie; DBG_8723A_LEVEL(_drv_warning_, "%s(%s): " @@ -2862,6 +2866,7 @@ static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, if (psta) { /* for AP mode */ #ifdef CONFIG_8723AU_AP_MODE unsigned short val16; + ether_addr_copy(mgmt->da, psta->hwaddr); ether_addr_copy(mgmt->sa, myid(&padapter->eeprompriv)); ether_addr_copy(mgmt->bssid, myid(&padapter->eeprompriv)); @@ -3306,6 +3311,7 @@ static void issue_assocreq(struct rtw_adapter *padapter) !memcmp(p + 2, WMM_OUI23A, 4) || !memcmp(p + 2, WPS_OUI23A, 4)) { u8 plen = p[1]; + if (!padapter->registrypriv.wifi_spec) { /* Commented by Kurt 20110629 */ /* In some older APs, WPS handshake */ @@ -4070,6 +4076,7 @@ static void rtw_site_survey(struct rtw_adapter *padapter) if (ScanType == SCAN_ACTIVE) /* obey the channel plan setting... */ { int i; + for (i = 0;isitesurvey_res.ssid[i].ssid_len) { /* todo: to issue two probe req??? */ @@ -4293,6 +4300,7 @@ static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter, bssid->IELength); if (p && p[1] > 0) { struct ieee80211_ht_cap *pHT_caps; + pHT_caps = (struct ieee80211_ht_cap *)(p + 2); if (pHT_caps->cap_info & @@ -4319,6 +4327,7 @@ static void start_create_ibss(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; + pmlmeext->cur_channel = (u8)pnetwork->DSConfig; pmlmeinfo->bcn_interval = pnetwork->beacon_interval; -- cgit v1.2.3-59-g8ed1b From d2db1cff21f6b49c10f56eac692a86eb7ce59eba Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:16 +0300 Subject: staging: rtl8723au: core: rtw_pwrctrl: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_pwrctrl.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 1b2af7381d82..bf72c5ed6e24 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -178,6 +178,7 @@ exit: static void pwr_state_check_handler(unsigned long data) { struct rtw_adapter *padapter = (struct rtw_adapter *)data; + rtw_ps_cmd23a(padapter); } @@ -470,6 +471,7 @@ void rtw_free_pwrctrl_priv(struct rtw_adapter *adapter) inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ms); } -- cgit v1.2.3-59-g8ed1b From 547f975e60ce64b2b5318e47f210fec4cd225d7e Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:17 +0300 Subject: staging: rtl8723au: core: rtw_wlan_util: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_wlan_util.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 5c4006aa23b2..c0b0047a9d3a 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1153,6 +1153,7 @@ bool is_ap_in_wep23a(struct rtw_adapter *padapter) static int wifirate2_ratetbl_inx23a(unsigned char rate) { int inx = 0; + rate = rate & 0x7f; switch (rate) { @@ -1311,6 +1312,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) u8 epigram_vendor_flag; u8 ralink_vendor_flag; const u8 *p; + epigram_vendor_flag = 0; ralink_vendor_flag = 0; -- cgit v1.2.3-59-g8ed1b From 831fa5f6f68f368e60bdaafb944827d829a8ced7 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:18 +0300 Subject: staging: rtl8723au: core: rtw_recv: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_recv.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 5bc7734d9a72..4dca863657ec 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -215,6 +215,7 @@ u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter) { u32 cnt = 0; struct recv_frame *pending_frame; + while ((pending_frame = rtw_alloc_recvframe23a(&adapter->recvpriv.uc_swdec_pending_queue))) { rtw_free_recvframe23a(pending_frame); DBG_8723A("%s: dequeue uc_swdec_pending_queue\n", __func__); @@ -239,6 +240,7 @@ int rtw_enqueue_recvbuf23a_to_head(struct recv_buf *precvbuf, struct rtw_queue * int rtw_enqueue_recvbuf23a(struct recv_buf *precvbuf, struct rtw_queue *queue) { unsigned long irqL; + spin_lock_irqsave(&queue->lock, irqL); list_del_init(&precvbuf->list); @@ -364,6 +366,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter, if (bmic_err == true) { int i; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-8)-*(pframemic-1) =" "0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:" @@ -483,6 +486,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, if (prxattrib->encrypt > 0) { u8 *iv = precv_frame->pkt->data + prxattrib->hdrlen; + prxattrib->key_index = (((iv[3]) >> 6) & 0x3); if (prxattrib->key_index > WEP_KEYS) { @@ -1066,6 +1070,7 @@ int sta2ap_data_frame(struct rtw_adapter *adapter, } } else { u8 *myhwaddr = myid(&adapter->eeprompriv); + if (!ether_addr_equal(pattrib->ra, myhwaddr)) { ret = RTW_RX_HANDLED; goto exit; -- cgit v1.2.3-59-g8ed1b From b8576413516065cba71b1dd48174397737337e40 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 01:22:19 +0300 Subject: staging: rtl8723au: core: rtw_xmit: Add blank line after declarations The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_xmit.c WARNING: Missing a blank line after declarations Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 7a8038156cea..6c75794af82d 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -315,6 +315,7 @@ static void update_attrib_vcs_info(struct rtw_adapter *padapter, struct xmit_fra /* check HT op mode */ if (pattrib->ht_en) { u8 HTOpMode = pmlmeinfo->HT_protection; + if ((pmlmeext->cur_bwmode && (HTOpMode == 2 || HTOpMode == 3)) || (!pmlmeext->cur_bwmode && HTOpMode == 3)) { pattrib->vcs_mode = RTS_CTS; @@ -464,6 +465,7 @@ static int update_attrib(struct rtw_adapter *padapter, if (pattrib->pktlen > 282 + 24) { if (pattrib->ether_type == ETH_P_IP) {/* IP header */ u8 *pframe = skb->data; + pframe += ETH_HLEN; if ((pframe[21] == 68 && pframe[23] == 67) || -- cgit v1.2.3-59-g8ed1b From 25ef419dc92a16d64380d85655b4381a2fb22dfb Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Thu, 9 Oct 2014 22:46:32 +0300 Subject: staging: vt6655: Use ether_addr_copy function This patch fixes the following checkpatch.pl warnings: WARNING: "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" in file device_main.c Pahole shows that the addresses are aligned Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 3eb8e5c5366e..ed5e71237007 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1591,7 +1591,7 @@ static int device_open(struct net_device *dev) device_init_registers(pDevice); MACvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr); - memcpy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN); + ether_addr_copy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr); device_set_multi(pDevice->dev); // Init for Key Management -- cgit v1.2.3-59-g8ed1b From f3512d5fe86097a09267c547d60d15c8f3b61e15 Mon Sep 17 00:00:00 2001 From: Esra Altintas Date: Thu, 9 Oct 2014 21:37:44 +0300 Subject: staging: vt6655: Fixed C99 // comment errors in wpa.h The following patch fixes the checkpatch.pl warning: ERROR: do not use C99 // comments Signed-off-by: Esra Altintas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wpa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/wpa.h b/drivers/staging/vt6655/wpa.h index 1d1918a12641..d012cb97043f 100644 --- a/drivers/staging/vt6655/wpa.h +++ b/drivers/staging/vt6655/wpa.h @@ -80,4 +80,4 @@ WPAb_Is_RSN( PWLAN_IE_RSN_EXT pRSN ); -#endif // __WPA_H__ +#endif /* __WPA_H__ */ -- cgit v1.2.3-59-g8ed1b From 3ad96c140d3c49dd90359d08a70275c9030e7f4a Mon Sep 17 00:00:00 2001 From: Esra Altintas Date: Thu, 9 Oct 2014 20:20:25 +0300 Subject: staging: rtl8712: Fix unnecessary parentheses style warning in rtl871x_xmit.c This fixes the following checkpatch.pl warning: WARNING: Unnecessary parentheses - maybe == should be = ? Signed-off-by: Esra Altintas Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index f49acaf04076..9d26fd26d0d4 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -486,7 +486,7 @@ static sint make_wlanhdr(struct _adapter *padapter , u8 *hdr, memset(hdr, 0, WLANHDR_OFFSET); SetFrameSubType(fctrl, pattrib->subtype); if (pattrib->subtype & WIFI_DATA_TYPE) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { /* to_ds = 1, fr_ds = 0; */ SetToDs(fctrl); memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), -- cgit v1.2.3-59-g8ed1b From e6768831352fb78b10347e6d421e79bd9e2c82f4 Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Thu, 9 Oct 2014 19:30:05 +0530 Subject: Staging: lustre: Fix line over 80 characters warning The following checkpatch warning was fixed: WARNING: line over 80 characters Signed-off-by: Tina Johnson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 0311b96a2eeb..43ab250b087e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -250,7 +250,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, data->ocd_brw_size = MD_MAX_BRW_SIZE; - err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, data, NULL); + err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, + data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing " "recovery, of which this client is not a " @@ -757,9 +758,9 @@ void ll_kill_super(struct super_block *sb) return; sbi = ll_s2sbi(sb); - /* we need to restore s_dev from changed for clustered NFS before put_super - * because new kernels have cached s_dev and change sb->s_dev in - * put_super not affected real removing devices */ + /* we need to restore s_dev from changed for clustered NFS before + * put_super because new kernels have cached s_dev and change sb->s_dev + * in put_super not affected real removing devices */ if (sbi) { sb->s_dev = sbi->ll_sdev_orig; sbi->ll_umounting = 1; @@ -1734,7 +1735,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT); LASSERT(inode->i_mode != 0); if (S_ISREG(inode->i_mode)) - inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS + 1, LL_MAX_BLKSIZE_BITS); + inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS + 1, + LL_MAX_BLKSIZE_BITS); else inode->i_blkbits = inode->i_sb->s_blocksize_bits; if (body->valid & OBD_MD_FLUID) -- cgit v1.2.3-59-g8ed1b From f4c84dafdb892e5f2ae3a10bf753745cdfbecbd5 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 9 Oct 2014 08:29:11 +0530 Subject: staging: rtl8192u: Remove unused code Below return statement dm_send_rssi_tofw function has dead code. This patch removes dead code from dm_send_rssi_tofw. This was detected by smatch. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index bda153d55f7a..cf4d3dc5dc76 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -3475,7 +3475,6 @@ static void dm_check_txrateandretrycount(struct net_device *dev) static void dm_send_rssi_tofw(struct net_device *dev) { - DCMD_TXCMD_T tx_cmd; struct r8192_priv *priv = ieee80211_priv(dev); // If we test chariot, we should stop the TX command ? @@ -3483,9 +3482,6 @@ static void dm_send_rssi_tofw(struct net_device *dev) // 0x1e0(byte) to notify driver. write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); return; - tx_cmd.Op = TXCMD_SET_RX_RSSI; - tx_cmd.Length = 4; - tx_cmd.Value = priv->undecorated_smoothed_pwdb; } /*---------------------------Define function prototype------------------------*/ -- cgit v1.2.3-59-g8ed1b From 9dfb753b2d65f449844fe5d7fce15770a3c27cb6 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 16:35:29 +0300 Subject: staging: rtl8723au: core: rtw_mlme: fix void function return statements The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_mlme.c WARNING: void function return statements are not generally useful Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 62894702be29..7b6a5a9dc9b4 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -218,8 +218,6 @@ void rtw_generate_random_ibss23a(u8 *pibss) pibss[3] = curtime & 0xff;/* p[0]; */ pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */ pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */ - - return; } void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) @@ -579,8 +577,6 @@ void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); - - return; } void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf) @@ -650,8 +646,6 @@ exit: kfree(survey->bss); survey->bss = NULL; - - return; } void -- cgit v1.2.3-59-g8ed1b From 6ff432714e6064250e02ec55628836cadd923e91 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 16:35:30 +0300 Subject: staging: rtl8723au: core: rtw_pwrctrl: Fix void function return statements style warning. The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_pwrctrl.c WARNING: void function return statements are not generally useful Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index bf72c5ed6e24..32f1ab515f91 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -172,7 +172,6 @@ void rtw_ps_processor23a(struct rtw_adapter *padapter) exit: rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); pwrpriv->ps_processing = false; - return; } static void pwr_state_check_handler(unsigned long data) -- cgit v1.2.3-59-g8ed1b From a2d50bc892d3a6d7d9d7b60603dc67f6278749e2 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 16:35:31 +0300 Subject: staging: rtl8723au: core: rtw_wlan_util: Fix void function return statements style warning. The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_wlan_util.c WARNING: void function return statements are not generally useful Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index c0b0047a9d3a..0126a3fa7fc9 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -608,8 +608,6 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) DBG_8723A("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); } - - return; } static void bwmode_update_check(struct rtw_adapter *padapter, const u8 *p) @@ -750,7 +748,6 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, const u8 *p) else cap->mcs.rx_mask[i] &= MCS_rate_2R23A[i]; } - return; } void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p) @@ -771,7 +768,6 @@ void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p) pmlmeinfo->HT_info_enable = 1; memcpy(&pmlmeinfo->HT_info, p + 2, p[1]); - return; } void HTOnAssocRsp23a(struct rtw_adapter *padapter) -- cgit v1.2.3-59-g8ed1b From 22d59f4eb1d66de2748011189ca5d77cd33d01c4 Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 16:35:32 +0300 Subject: staging: rtl8723au: core: rtw_security: Fix void function return statements style warning. The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_security.c WARNING: void function return statements are not generally useful Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_security.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index 5da620c7ba82..60e944554ec5 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -259,8 +259,6 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, crc[1], payload[length - 3], crc[0], payload[length - 4])); } - - return; } /* 3 ===== TKIP related ===== */ -- cgit v1.2.3-59-g8ed1b From 2c7c63a30595ea99fbd65eff0d020948a5b882be Mon Sep 17 00:00:00 2001 From: Yeliz Taneroglu Date: Thu, 9 Oct 2014 16:35:33 +0300 Subject: staging: rtl8723au: core: rtw_ap: Fix void function return statements style warning. The following patch fixes the checkpatch.pl warning: drivers/staging/rtl8723au/core/rtw_ap.c WARNING: void function return statements are not generally useful Signed-off-by: Yeliz Taneroglu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index aedbd8f77529..75ae2492699a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1216,8 +1216,6 @@ static void update_bcn_wmm_ie(struct rtw_adapter *padapter) static void update_bcn_wps_ie(struct rtw_adapter *padapter) { DBG_8723A("%s\n", __func__); - - return; } static void update_bcn_p2p_ie(struct rtw_adapter *padapter) -- cgit v1.2.3-59-g8ed1b From 5e8dc1cbf7bf18306221ec3fea57be0683107b7a Mon Sep 17 00:00:00 2001 From: "Vladimir A. Nazarenko" Date: Thu, 9 Oct 2014 15:37:17 +1100 Subject: staging: vt6655: delete non-standard ioctl 0xFF Custom ioctl 0xff is legacy code that was used for patched version of wpa_supplicant, where function wpa_authen_Status_transfer() called this ioctl to tell authentication status to the driver. While from upstream was added only driver code to the kernel but not patches to the wpa_supplicant we can safely remove this unused ioctl. Signed-off-by: Vladimir A. Nazarenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 970e80d92fb9..f8e990fcc6fd 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -618,38 +618,6 @@ int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq) pReq->wResult = 0; break; -#ifdef WPA_SM_Transtatus - case 0xFF: - memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname)); - wpa_Result.proto = 0; - wpa_Result.key_mgmt = 0; - wpa_Result.eap_type = 0; - wpa_Result.authenticated = false; - pDevice->fWPA_Authened = false; - if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { - result = -EFAULT; - break; - } - - if (wpa_Result.authenticated == true) { -#ifdef SndEvt_ToAPI - { - union iwreq_data wrqu; - - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; - wrqu.data.length = pItemSSID->len; - wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); - } -#endif - pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */ - } - pReq->wResult = 0; - break; -#endif - default: pr_debug("Private command not support..\n"); } -- cgit v1.2.3-59-g8ed1b From 5ba1b07a6eae38886b7e27d662da2786d0613386 Mon Sep 17 00:00:00 2001 From: "Vladimir A. Nazarenko" Date: Thu, 9 Oct 2014 15:38:23 +1100 Subject: staging: vt6655: remove global variable wpa_Result This variable unused, so remove it. Signed-off-by: Vladimir A. Nazarenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 8 -------- drivers/staging/vt6655/ioctl.c | 4 ---- 2 files changed, 12 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index ed5e71237007..ff8bd7a5db87 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1553,9 +1553,6 @@ static int device_open(struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); int i; -#ifdef WPA_SM_Transtatus - extern SWPAResult wpa_Result; -#endif pDevice->rx_buf_sz = PKT_BUF_SZ; if (!device_init_rings(pDevice)) @@ -1567,11 +1564,6 @@ static int device_open(struct net_device *dev) return i; #ifdef WPA_SM_Transtatus - memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname)); - wpa_Result.proto = 0; - wpa_Result.key_mgmt = 0; - wpa_Result.eap_type = 0; - wpa_Result.authenticated = false; pDevice->fWPA_Authened = false; #endif pr_debug("call device init rd0 ring\n"); diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index f8e990fcc6fd..628f5b2359c5 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -38,10 +38,6 @@ #include "wpactl.h" #include "rf.h" -#ifdef WPA_SM_Transtatus -SWPAResult wpa_Result; -#endif - int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq) { PSCmdRequest pReq = (PSCmdRequest)rq; -- cgit v1.2.3-59-g8ed1b From ebf72ccf53f0fd494c41e856f255d09bc19d2ff4 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Thu, 9 Oct 2014 13:40:11 +0900 Subject: staging: dgap: introduce dgap_stop() The dgap_init_module() need to unwind for cleanup variables properly. Because dgap_init_module() calls dgap_cleanup_module() for freeing variables but this function is possible to free variables which are not allocated. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index d0eb5ea43965..ad8c8ecaaf06 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -71,6 +71,7 @@ MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product lin MODULE_SUPPORTED_DEVICE("dgap"); static int dgap_start(void); +static void dgap_stop(void); static void dgap_init_globals(void); static struct board_t *dgap_found_board(struct pci_dev *pdev, int id, int boardnum); @@ -479,19 +480,20 @@ static int dgap_init_module(void) rc = pci_register_driver(&dgap_driver); if (rc) - goto err_cleanup; + goto err_stop; rc = dgap_create_driver_sysfiles(&dgap_driver); if (rc) - goto err_cleanup; + goto err_unregister; dgap_driver_state = DRIVER_READY; return 0; -err_cleanup: - - dgap_cleanup_module(); +err_unregister: + pci_unregister_driver(&dgap_driver); +err_stop: + dgap_stop(); return rc; } @@ -561,6 +563,21 @@ failed_class: return rc; } +static void dgap_stop(void) +{ + unsigned long lock_flags; + + spin_lock_irqsave(&dgap_poll_lock, lock_flags); + dgap_poll_stop = 1; + spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); + + del_timer_sync(&dgap_poll_timer); + + device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); + class_destroy(dgap_class); + unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); +} + static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; -- cgit v1.2.3-59-g8ed1b From 402eede3c0b29949cb9c46fcbc2d476c5d266d76 Mon Sep 17 00:00:00 2001 From: "Vladimir A. Nazarenko" Date: Thu, 9 Oct 2014 16:33:33 +1100 Subject: staging: vt6655: remove useless #if 1 There is code encapsulated in #if 1, let's remove it. Signed-off-by: Vladimir A. Nazarenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 4 ---- drivers/staging/vt6655/wpactl.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index ff8bd7a5db87..6a77f0df1a63 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -854,8 +854,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) return -ENODEV; } -#if 1 - #ifdef DEBUG pr_debug("after get pci_info memaddr is %x, io addr is %x,io_size is %d\n", pDevice->memaddr, pDevice->ioaddr, pDevice->io_size); @@ -892,8 +890,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) } } } -#endif - #endif pDevice->PortOffset = ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size); diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index dab1e8078652..cc39829cbacc 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -550,8 +550,6 @@ static int wpa_get_scan(struct vnt_private *pDevice, int ret = 0; u16 count = 0; u16 ii, jj; -#if 1 - unsigned char *ptempBSS; ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC); @@ -583,7 +581,6 @@ static int wpa_get_scan(struct vnt_private *pDevice, } kfree(ptempBSS); -#endif //******mike:bubble sort by stronger RSSI*****// -- cgit v1.2.3-59-g8ed1b From 02c2d43c2615ddc5d6e25f071b0f8d39ebc2d35d Mon Sep 17 00:00:00 2001 From: Dzmitry Sledneu Date: Thu, 9 Oct 2014 09:22:43 +0200 Subject: staging: gs_fpgaboot: Fix "out of memory" error handling Fix "out of memory" error handling Signed-off-by: Dzmitry Sledneu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index cbf70cefe6f5..0c18c4c311b4 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -295,8 +295,8 @@ static int gs_fpgaboot(void) struct fpgaimage *fimage; fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL); - if (fimage == NULL) - goto err_out; + if (!fimage) + return -ENOMEM; err = gs_load_image(fimage, file); if (err) { @@ -338,7 +338,6 @@ err_out2: err_out1: kfree(fimage); -err_out: return -1; } -- cgit v1.2.3-59-g8ed1b From f582d9a8b95535d7728a0b9ea54afa1f59df3f68 Mon Sep 17 00:00:00 2001 From: Rene Kolarik Date: Thu, 9 Oct 2014 20:29:32 +0200 Subject: drivers: staging: imx-drm driver cleanup Wrapping two too long lines in two files of the imx-drm driver. Signed-off-by: Rene Kolarik Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-drm-core.c | 3 ++- drivers/staging/imx-drm/imx-tve.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 9cb222e2996f..3ca1acdae72b 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -632,7 +632,8 @@ static int imx_drm_platform_probe(struct platform_device *pdev) continue; } - component_match_add(&pdev->dev, &match, compare_of, remote); + component_match_add(&pdev->dev, &match, compare_of, + remote); of_node_put(remote); } of_node_put(port); diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 42c651be6c20..f22b2ac4627e 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -665,7 +665,8 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data) ret = regmap_read(tve->regmap, TVE_COM_CONF_REG, &val); if (ret < 0) { - dev_err(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) { -- cgit v1.2.3-59-g8ed1b From 3f8ddea02c1c8f42a7a88d5db8ebf045cb0e82fa Mon Sep 17 00:00:00 2001 From: John Ledbetter Date: Thu, 9 Oct 2014 11:05:08 -0400 Subject: staging: rtl8192e: Fix pointer type declaration style errors This fixes the following checkpatch.pl errors: drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c:1290 error: "foo* bar" should be "foo *bar" drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c:1305 error: "foo * bar" should be "foo *bar" Signed-off-by: John Ledbetter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 0ffed2d06b58..552d943b1761 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -1287,7 +1287,7 @@ void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, void rtl8192_tx_fill_cmd_desc(struct net_device *dev, struct tx_desc_cmd *entry, - struct cb_desc *cb_desc, struct sk_buff* skb) + struct cb_desc *cb_desc, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, @@ -1302,7 +1302,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device *dev, if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { entry->CmdInit = DESC_PACKET_TYPE_INIT; } else { - struct tx_desc * entry_tmp = (struct tx_desc *)entry; + struct tx_desc *entry_tmp = (struct tx_desc *)entry; entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; -- cgit v1.2.3-59-g8ed1b From 586e8b6845a9efdc2cfefc91e949a10806d2c623 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Fri, 10 Oct 2014 07:43:36 +0530 Subject: staging: vt6655: Remove unused code inside switch case This patch removes dead code in private_ioctl function and iwctl_siwmode function, in file ioctl.c. Inside switch, for a case no code gets executed after break. This was detected by smatch. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.c | 40 ---------------------------------------- drivers/staging/vt6655/iwctl.c | 9 --------- 2 files changed, 49 deletions(-) diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 628f5b2359c5..c2b6763c8ab9 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -45,7 +45,6 @@ int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq) int result = 0; PWLAN_IE_SSID pItemSSID; SCmdBSSJoin sJoinCmd; - SCmdZoneTypeSet sZoneTypeCmd; SCmdScan sScanCmd; SCmdStartAP sStartAPCmd; SCmdSetWEP sWEPCmd; @@ -108,45 +107,6 @@ int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq) result = -EOPNOTSUPP; break; - if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { - result = -EFAULT; - break; - } - - if (sZoneTypeCmd.bWrite == true) { - /* write zonetype */ - if (sZoneTypeCmd.ZoneType == ZoneType_USA) { - /* set to USA */ - pr_debug("set_ZoneType:USA\n"); - } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) { - /* set to Japan */ - pr_debug("set_ZoneType:Japan\n"); - } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) { - /* set to Europe */ - pr_debug("set_ZoneType:Europe\n"); - } - } else { - /* read zonetype */ - unsigned char zonetype = 0; - - if (zonetype == 0x00) { /* USA */ - sZoneTypeCmd.ZoneType = ZoneType_USA; - } else if (zonetype == 0x01) { /* Japan */ - sZoneTypeCmd.ZoneType = ZoneType_Japan; - } else if (zonetype == 0x02) { /* Europe */ - sZoneTypeCmd.ZoneType = ZoneType_Europe; - } else { /* Unknown ZoneType */ - pr_err("Error:ZoneType[%x] Unknown ???\n", zonetype); - result = -EFAULT; - break; - } - if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { - result = -EFAULT; - break; - } - } - break; - case WLAN_CMD_BSS_JOIN: if (pDevice->bMACSuspend == true) { if (pDevice->bRadioOff == true) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 8f3e190a55b9..cc261d7dd058 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -464,15 +464,6 @@ int iwctl_siwmode(struct net_device *dev, rc = -EOPNOTSUPP; break; - if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { - pMgmt->eConfigMode = WMAC_CONFIG_AP; - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - - } - pr_debug("set mode to Access Point\n"); - break; - case IW_MODE_REPEAT: pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; rc = -EOPNOTSUPP; -- cgit v1.2.3-59-g8ed1b From 4a2bc3bdfffcb31e7ba4d47358c0193d4fc259dc Mon Sep 17 00:00:00 2001 From: "Vladimir A. Nazarenko" Date: Fri, 10 Oct 2014 12:27:01 +1100 Subject: staging: vt6655: delete SndEvt_ToAPI code It's never enabled, so we can safely remove it. Signed-off-by: Vladimir A. Nazarenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 6a77f0df1a63..c8f262f58c7b 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -2911,14 +2911,8 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) case IOCTL_CMD_SET: -#ifdef SndEvt_ToAPI - if ((((PSCmdRequest)rq)->wCmdCode != WLAN_CMD_SET_EVT) && - !(pDevice->flags & DEVICE_FLAGS_OPENED)) -#else - if (!(pDevice->flags & DEVICE_FLAGS_OPENED) && - (((PSCmdRequest)rq)->wCmdCode != WLAN_CMD_SET_WPA)) -#endif - { + if (!(pDevice->flags & DEVICE_FLAGS_OPENED) && + (((PSCmdRequest)rq)->wCmdCode != WLAN_CMD_SET_WPA)) { rc = -EFAULT; break; } -- cgit v1.2.3-59-g8ed1b From 30e89958bca3da4288cb47d59e439d06364e4bd0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:24 +0200 Subject: staging: rtl8723au: Fix alignment of mac_addr for ether_addr_copy() usage Make sure struct eeprom_priv->mac_addr is 2 byte aligned to work with ether_addr_copy() Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_eeprom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/rtw_eeprom.h b/drivers/staging/rtl8723au/include/rtw_eeprom.h index e5121a2a64b4..a86f36e49dd1 100644 --- a/drivers/staging/rtl8723au/include/rtw_eeprom.h +++ b/drivers/staging/rtl8723au/include/rtw_eeprom.h @@ -107,12 +107,12 @@ enum rt_customer_id }; struct eeprom_priv { + u8 mac_addr[6]; /* PermanentAddress */ u8 bautoload_fail_flag; u8 bloadfile_fail_flag; u8 bloadmac_fail_flag; /* u8 bempty; */ /* u8 sys_config; */ - u8 mac_addr[6]; /* PermanentAddress */ /* u8 config0; */ u16 channel_plan; /* u8 country_string[3]; */ -- cgit v1.2.3-59-g8ed1b From 0f200704837fc110b8265efe97afa94ca1fa30c4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:27 +0200 Subject: staging: rtl8723au: Remove write-only struct xmit_priv->vcs_type Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - drivers/staging/rtl8723au/os_dep/os_intfs.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 32a844170327..134ad6e50025 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -297,7 +297,6 @@ struct xmit_priv { u8 vcs_setting; u8 vcs; - u8 vcs_type; u64 tx_bytes; u64 tx_pkts; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index b34eaec9dd48..19cb11bde2ce 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -389,7 +389,6 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) /* xmit_priv */ pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; pxmitpriv->vcs = pregistrypriv->vcs_type; - pxmitpriv->vcs_type = pregistrypriv->vcs_type; /* pxmitpriv->rts_thresh = pregistrypriv->rts_thresh; */ pxmitpriv->frag_len = pregistrypriv->frag_thresh; -- cgit v1.2.3-59-g8ed1b From 0ceb7b15e8b637d66574bb28d8422dc20933203f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:28 +0200 Subject: staging: rtl8723au: Use enum values for vcs_type Be consistent in the use of enum VCS_TYPE Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 0126a3fa7fc9..c0325c96d616 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -829,7 +829,7 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->cts2self = 0; break; case 1: /* on */ - if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ + if (pregpriv->vcs_type == RTS_CTS) { psta->rtsen = 1; psta->cts2self = 0; } else { @@ -840,7 +840,7 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) case 2: /* auto */ default: if (pmlmeinfo->ERP_enable && pmlmeinfo->ERP_IE & BIT(1)) { - if (pregpriv->vcs_type == 1) { + if (pregpriv->vcs_type == RTS_CTS) { psta->rtsen = 1; psta->cts2self = 0; } else { -- cgit v1.2.3-59-g8ed1b From 70b88f5b36720acf8640c1807ab73bc851ccfd85 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:29 +0200 Subject: staging: rtl8723au: Eliminate write-once variable xmit_priv->vcs_setting Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - drivers/staging/rtl8723au/os_dep/os_intfs.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 6c75794af82d..8994bd848af8 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1295,7 +1295,7 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) uint protection; const u8 *p; - switch (pxmitpriv->vcs_setting) { + switch (pregistrypriv->vrtl_carrier_sense) { case DISABLE_VCS: pxmitpriv->vcs = NONE_VCS; break; diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 134ad6e50025..70cd4b69d8f8 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -295,7 +295,6 @@ struct xmit_priv { struct rtw_adapter *adapter; - u8 vcs_setting; u8 vcs; u64 tx_bytes; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 19cb11bde2ce..ddd0a9f1eefb 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -387,7 +387,6 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) int ret = _SUCCESS; /* xmit_priv */ - pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; pxmitpriv->vcs = pregistrypriv->vcs_type; /* pxmitpriv->rts_thresh = pregistrypriv->rts_thresh; */ pxmitpriv->frag_len = pregistrypriv->frag_thresh; -- cgit v1.2.3-59-g8ed1b From b1950117408a6f38ce254ef3cca9399038188613 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:31 +0200 Subject: staging: rtl8723au: Use register define REQ_NQOS_SEQ instead of hardcoded value Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sreset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 58ed980795a6..29a29d92a6ac 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -107,7 +107,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) mlmeext_joinbss_event_callback23a(padapter, 1); /* restore Sequence No. */ - rtl8723au_write8(padapter, 0x4dc, padapter->xmitpriv.nqos_ssn); + rtl8723au_write8(padapter, REG_NQOS_SEQ, padapter->xmitpriv.nqos_ssn); sreset_restore_security_station(padapter); } -- cgit v1.2.3-59-g8ed1b From 516f29e1c8013bfd66eb093cc97ec5d7b7182e4f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:32 +0200 Subject: staging: rtl8723au: Don't read REQ_NQOS_SEQ 16 bits and write back 8 bits This fixes a potential endian bug Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 2 +- drivers/staging/rtl8723au/include/rtw_xmit.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index bf919f6e4128..f906317579bc 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -727,7 +727,7 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) rtl8723au_write8(padapter, REG_TXPAUSE, 0xff); /* keep sn */ - padapter->xmitpriv.nqos_ssn = rtl8723au_read16(padapter, REG_NQOS_SEQ); + padapter->xmitpriv.nqos_ssn = rtl8723au_read8(padapter, REG_NQOS_SEQ); if (pwrpriv->bkeepfwalive != true) { u32 v32; diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 70cd4b69d8f8..780ec0665f20 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -330,7 +330,7 @@ struct xmit_priv { struct list_head xmitextbuf_list; /* track buffers for cleanup */ uint free_xmit_extbuf_cnt; - u16 nqos_ssn; + u8 nqos_ssn; int ack_tx; struct mutex ack_tx_mutex; struct submit_ctx ack_tx_ops; -- cgit v1.2.3-59-g8ed1b From f7d6e7c77022569712dfdb59b170870c8d624702 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:33 +0200 Subject: staging: rtl8723au: Re-organize struct xmit_priv for better packing Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_xmit.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 780ec0665f20..4318f50d6df7 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -295,8 +295,6 @@ struct xmit_priv { struct rtw_adapter *adapter; - u8 vcs; - u64 tx_bytes; u64 tx_pkts; u64 tx_drop; @@ -305,6 +303,8 @@ struct xmit_priv { struct hw_xmit *hwxmits; u8 hwxmit_entry; + u8 vcs; + u8 nqos_ssn; u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength from * large to small. it's value is 0->vo, 1->vi, @@ -330,7 +330,6 @@ struct xmit_priv { struct list_head xmitextbuf_list; /* track buffers for cleanup */ uint free_xmit_extbuf_cnt; - u8 nqos_ssn; int ack_tx; struct mutex ack_tx_mutex; struct submit_ctx ack_tx_ops; -- cgit v1.2.3-59-g8ed1b From f8cfb86e890028fec730804d56e782781cfb0c1a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:35 +0200 Subject: staging: rtl8723au: Remove unused struct zero_bulkout_content Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index a3349ac57bae..c333bef90efe 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -18,13 +18,6 @@ #include #include -struct zero_bulkout_context { - void *pbuf; - void *purb; - void *pirp; - void *padapter; -}; - void rtl8723au_read_port_cancel(struct rtw_adapter *padapter) { struct recv_buf *precvbuf; -- cgit v1.2.3-59-g8ed1b From 60b152ced8a86b267fdfadd67377b47cf18b0b75 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:36 +0200 Subject: staging: rtl8723au: Fold struct wlan_phy_info into struct wlan_bssid_ex Half the entries of struct wlan_phy_info weren't used and this makes the code a little cleaner Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 40 +++++++++++------------ drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 ++-- drivers/staging/rtl8723au/include/wlan_bssdef.h | 10 ++---- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 +- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 7b6a5a9dc9b4..92bf1e415a95 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -354,12 +354,12 @@ rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct rtw_adapter *padapter, bool update_ie) { - u8 ss_ori = dst->PhyInfo.SignalStrength; - u8 sq_ori = dst->PhyInfo.SignalQuality; + u8 ss_ori = dst->SignalStrength; + u8 sq_ori = dst->SignalQuality; long rssi_ori = dst->Rssi; - u8 ss_smp = src->PhyInfo.SignalStrength; - u8 sq_smp = src->PhyInfo.SignalQuality; + u8 ss_smp = src->SignalStrength; + u8 sq_smp = src->SignalQuality; long rssi_smp = src->Rssi; u8 ss_final; @@ -387,16 +387,16 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)src->PhyInfo.SignalStrength + - (u32)dst->PhyInfo.SignalStrength * 4) / 5; - sq_final = ((u32)src->PhyInfo.SignalQuality + - (u32)dst->PhyInfo.SignalQuality * 4) / 5; + ss_final = ((u32)src->SignalStrength + + (u32)dst->SignalStrength * 4) / 5; + sq_final = ((u32)src->SignalQuality + + (u32)dst->SignalQuality * 4) / 5; rssi_final = src->Rssi+dst->Rssi * 4 / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ - ss_final = dst->PhyInfo.SignalStrength; - sq_final = dst->PhyInfo.SignalQuality; + ss_final = dst->SignalStrength; + sq_final = dst->SignalQuality; rssi_final = dst->Rssi; } @@ -405,14 +405,13 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, if (update_ie) memcpy(dst, src, get_wlan_bssid_ex_sz(src)); - dst->PhyInfo.SignalStrength = ss_final; - dst->PhyInfo.SignalQuality = sq_final; + dst->SignalStrength = ss_final; + dst->SignalQuality = sq_final; dst->Rssi = rssi_final; DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, " "RawRSSI:%ld\n", __func__, dst->Ssid.ssid, dst->MacAddress, - dst->PhyInfo.SignalStrength, - dst->PhyInfo.SignalQuality, dst->Rssi); + dst->SignalStrength, dst->SignalQuality, dst->Rssi); } static void update_current_network(struct rtw_adapter *adapter, @@ -489,8 +488,8 @@ static void rtw_update_scanned_network(struct rtw_adapter *adapter, pnetwork->join_res = 0; /* bss info not receiving from the right channel */ - if (pnetwork->network.PhyInfo.SignalQuality == 101) - pnetwork->network.PhyInfo.SignalQuality = 0; + if (pnetwork->network.SignalQuality == 101) + pnetwork->network.SignalQuality = 0; } else { /* * we have an entry and we are going to update it. But @@ -1026,15 +1025,14 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter, rtw_set_signal_stat_timer(&padapter->recvpriv); padapter->recvpriv.signal_strength = - ptarget_wlan->network.PhyInfo.SignalStrength; - padapter->recvpriv.signal_qual = - ptarget_wlan->network.PhyInfo.SignalQuality; + ptarget_wlan->network.SignalStrength; + padapter->recvpriv.signal_qual = ptarget_wlan->network.SignalQuality; /* * the ptarget_wlan->network.Rssi is raw data, we use - * ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) + * ptarget_wlan->network.SignalStrength instead (has scaled) */ padapter->recvpriv.rssi = translate_percentage_to_dbm( - ptarget_wlan->network.PhyInfo.SignalStrength); + ptarget_wlan->network.SignalStrength); DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n", __func__, padapter->recvpriv.signal_strength, padapter->recvpriv.rssi, padapter->recvpriv.signal_qual); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9298b382b6c6..0dd7d22eba28 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4204,9 +4204,9 @@ static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter, /* get the signal strength */ /* in dBM.raw data */ bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower; - bssid->PhyInfo.SignalQuality = + bssid->SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = + bssid->SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ @@ -4313,7 +4313,7 @@ static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter, /* mark bss info receiving from nearby channel as SignalQuality 101 */ if (bssid->DSConfig != rtw_get_oper_ch23a(padapter)) - bssid->PhyInfo.SignalQuality = 101; + bssid->SignalQuality = 101; return bssid; fail: diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 96e8074a7c18..037942c27d9b 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -67,13 +67,6 @@ struct ndis_802_11_key { u8 KeyMaterial[32]; /* variable length depending on above field */ }; -struct wlan_phy_info { - u8 SignalStrength;/* in percentage) */ - u8 SignalQuality;/* in percentage) */ - u8 Optimum_antenna; /* for Antenna diversity */ - u8 Reserved_0; -}; - struct wlan_bcn_info { /* these infor get from rtw_get_encrypt_info when * * translate scan to UI */ @@ -99,7 +92,8 @@ struct wlan_bssid_ex { u32 DSConfig; /* Frequency, units are kHz */ enum nl80211_iftype ifmode; unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; - struct wlan_phy_info PhyInfo; + u8 SignalStrength;/* in percentage */ + u8 SignalQuality;/* in percentage */ u32 IELength; u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and capability info*/ } __packed; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index de2a3f546cfb..c567df6c6321 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -275,7 +275,8 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, &pnetwork->network)) { notify_signal = 100 * translate_percentage_to_dbm(padapter->recvpriv.signal_strength); /* dbm */ } else { - notify_signal = 100 * translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength); /* dbm */ + notify_signal = 100 * translate_percentage_to_dbm( + pnetwork->network.SignalStrength); /* dbm */ } bss = cfg80211_inform_bss(wiphy, notify_channel, -- cgit v1.2.3-59-g8ed1b From 218189b7dc847681516285a1af89b6fb0b17a061 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:37 +0200 Subject: staging: rtl8723au: Remove unused struct ndis_802_11_key Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wlan_bssdef.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 037942c27d9b..8acc41840e32 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -57,16 +57,6 @@ enum { Ndis802_11Encryption3KeyAbsent, }; -/* Key mapping keys require a BSSID */ -struct ndis_802_11_key { - u32 Length; /* Length of this structure */ - u32 KeyIndex; - u32 KeyLength; /* length of key in bytes */ - unsigned char BSSID[6]; - unsigned long long KeyRSC; - u8 KeyMaterial[32]; /* variable length depending on above field */ -}; - struct wlan_bcn_info { /* these infor get from rtw_get_encrypt_info when * * translate scan to UI */ -- cgit v1.2.3-59-g8ed1b From eb18cf6b23c007859a72d3ed425840d8f480ecfa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:38 +0200 Subject: staging: rtl8723au: Eliminate write-only struct wlan_network->aid Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 3 --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/include/wlan_bssdef.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 92bf1e415a95..21484e757b15 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -110,7 +110,6 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv, gfp_t gfp) pnetwork->network_type = 0; pnetwork->fixed = false; pnetwork->last_scanned = jiffies; - pnetwork->aid = 0; pnetwork->join_res = 0; } @@ -484,7 +483,6 @@ static void rtw_update_scanned_network(struct rtw_adapter *adapter, pnetwork->last_scanned = jiffies; pnetwork->network_type = 0; - pnetwork->aid = 0; pnetwork->join_res = 0; /* bss info not receiving from the right channel */ @@ -1021,7 +1019,6 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter, cur_network->network.beacon_interval = ptarget_wlan->network.beacon_interval; cur_network->network.tsf = ptarget_wlan->network.tsf; - cur_network->aid = pnetwork->join_res; rtw_set_signal_stat_timer(&padapter->recvpriv); padapter->recvpriv.signal_strength = diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0dd7d22eba28..e4f4934e357d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4875,7 +4875,7 @@ void report_join_res23a(struct rtw_adapter *padapter, int res) pjoinbss_evt = (struct joinbss_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)&pjoinbss_evt->network.network, &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); - pjoinbss_evt->network.join_res = pjoinbss_evt->network.aid = res; + pjoinbss_evt->network.join_res = res; DBG_8723A("report_join_res23a(%d)\n", res); diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 8acc41840e32..95b32e15a4d0 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -99,7 +99,6 @@ struct wlan_network { /* set to fixed when not to be removed as site-surveying */ int fixed; unsigned long last_scanned; /* timestamp for the network */ - int aid; /* will only be valid when a BSS is joined. */ int join_res; struct wlan_bssid_ex network; /* must be the last item */ struct wlan_bcn_info BcnInfo; -- cgit v1.2.3-59-g8ed1b From ab3136cc876ac5c109cfe28d05f8c1247a899d39 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:34 +0200 Subject: staging: rtl8723au: Remove a stack of write only counters We don't do anything with these, so get rid of them Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 6 ------ drivers/staging/rtl8723au/include/rtw_xmit.h | 5 ----- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 16 ---------------- 3 files changed, 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 8994bd848af8..4c2f0a1201bf 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -184,12 +184,6 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, sema_init(&pxmitpriv->tx_retevt, 0); - /* per AC pending irp */ - pxmitpriv->beq_cnt = 0; - pxmitpriv->bkq_cnt = 0; - pxmitpriv->viq_cnt = 0; - pxmitpriv->voq_cnt = 0; - pxmitpriv->ack_tx = false; mutex_init(&pxmitpriv->ack_tx_mutex); rtw_sctx_init23a(&pxmitpriv->ack_tx_ops, 0); diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 4318f50d6df7..abe4316b9124 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -315,11 +315,6 @@ struct xmit_priv { u8 txirp_cnt;/* */ struct tasklet_struct xmit_tasklet; - /* per AC pending irp */ - int beq_cnt; - int bkq_cnt; - int viq_cnt; - int voq_cnt; struct rtw_queue free_xmitbuf_queue; struct list_head xmitbuf_list; /* track buffers for cleanup */ diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index c333bef90efe..3e19b3b2c1c2 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -46,18 +46,6 @@ static void usb_write_port23a_complete(struct urb *purb) unsigned long irqL; switch (pxmitbuf->flags) { - case VO_QUEUE_INX: - pxmitpriv->voq_cnt--; - break; - case VI_QUEUE_INX: - pxmitpriv->viq_cnt--; - break; - case BE_QUEUE_INX: - pxmitpriv->beq_cnt--; - break; - case BK_QUEUE_INX: - pxmitpriv->bkq_cnt--; - break; case HIGH_QUEUE_INX: #ifdef CONFIG_8723AU_AP_MODE rtw_chk_hi_queue_cmd23a(padapter); @@ -159,19 +147,15 @@ int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, switch (addr) { case VO_QUEUE_INX: - pxmitpriv->voq_cnt++; pxmitbuf->flags = VO_QUEUE_INX; break; case VI_QUEUE_INX: - pxmitpriv->viq_cnt++; pxmitbuf->flags = VI_QUEUE_INX; break; case BE_QUEUE_INX: - pxmitpriv->beq_cnt++; pxmitbuf->flags = BE_QUEUE_INX; break; case BK_QUEUE_INX: - pxmitpriv->bkq_cnt++; pxmitbuf->flags = BK_QUEUE_INX; break; case HIGH_QUEUE_INX: -- cgit v1.2.3-59-g8ed1b From e1499e81497cd46f296c4680096323f0aadd2604 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 11 Oct 2014 02:25:34 +0200 Subject: staging: vt6655: card.c: replace memcpy() by ether_addr_copy() using coccinelle This patch focuses on fixing the following warning generated by checkpatch.pl for the file rxtx.c : Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) The changes were applied using the following coccinelle rule: @@ expression e1, e2; @@ - memcpy(e1, e2, ETH_ALEN); + ether_addr_copy(e1, e2); According to ether_addr_copy() description and functionality, all Ethernet addresses should align to the u16 datatype. Here is the output of pahole for the relevant datastructures: struct pmkid_candidate { NDIS_802_11_MAC_ADDRESS BSSID; /* 0 6 */ /* XXX 2 bytes hole, try to pack */ long unsigned int Flags; /* 8 4 */ /* size: 12, cachelines: 1, members: 2 */ /* sum members: 10, holes: 1, sum holes: 2 */ /* last cacheline: 12 bytes */ }; Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 5a6950264bdc..f2a33a9742c6 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -1000,7 +1000,7 @@ CARDbAdd_PMKID_Candidate( else pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); + ether_addr_copy(pCandidateList->BSSID, pbyBSSID); pDevice->gsPMKIDCandidate.NumCandidates++; pr_debug("NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); -- cgit v1.2.3-59-g8ed1b From 87bb326eada535ed72ca312878bb5ba69bad870b Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 11 Oct 2014 02:34:07 +0200 Subject: staging: vt6655: dpc.c: replace memcpy() by ether_addr_copy() using coccinelle This patch focuses on fixing the following warning generated by checkpatch.pl for the file dpc.c : Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) The changes were applied using the following coccinelle rule: @@ expression e1, e2; @@ - memcpy(e1, e2, ETH_ALEN); + ether_addr_copy(e1, e2); According to ether_addr_copy() description and functionality, all Ethernet addresses should align to the u16 datatype. Here is the output of pahole for the relevant datastructures: struct tagS802_11Header { short unsigned int wFrameCtl; /* 0 2 */ short unsigned int wDurationID; /* 2 2 */ unsigned char abyAddr1[6]; /* 4 6 */ unsigned char abyAddr2[6]; /* 10 6 */ unsigned char abyAddr3[6]; /* 16 6 */ short unsigned int wSeqCtl; /* 22 2 */ unsigned char abyAddr4[6]; /* 24 6 */ /* size: 30, cachelines: 1, members: 7 */ /* last cacheline: 30 bytes */ }; struct iw_michaelmicfailure { __u32 flags; /* 0 4 */ struct sockaddr src_addr; /* 4 16 */ __u8 tsc[8]; /* 20 8 */ /* size: 28, cachelines: 1, members: 3 */ /* last cacheline: 28 bytes */ }; struct sockaddr { sa_family_t sa_family; /* 0 2 */ char sa_data[14]; /* 2 14 */ /* size: 16, cachelines: 1, members: 2 */ /* last cacheline: 16 bytes */ }; There is one thing to note though, sa_data is a char array of size 14. And the number of bytes copied using memcpy() or ether_addr_copy() is 6. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 8515b8c80801..344e12f1184e 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -742,7 +742,8 @@ device_receive_frame( } ev.src_addr.sa_family = ARPHRD_ETHER; - memcpy(ev.src_addr.sa_data, pMACHeader->abyAddr2, ETH_ALEN); + ether_addr_copy(ev.src_addr.sa_data, + pMACHeader->abyAddr2); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = sizeof(ev); wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); -- cgit v1.2.3-59-g8ed1b From 85061eb97aac1f7848a57bb5a6a6754c0f0489a0 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 11 Oct 2014 02:37:21 +0200 Subject: staging: vt6655: wmgr.c and wmgr.h: replace memcpy() by ether_addr_copy() using coccinelle and pack variable This patch focuses on fixing the following warning generated by checkpatch.pl for the file wmgr.c : Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) The changes were applied using the following coccinelle rule: @@ expression e1, e2; @@ - memcpy(e1, e2, ETH_ALEN); + ether_addr_copy(e1, e2); According to ether_addr_copy() description and functionality, all Ethernet addresses should align to the u16 datatype. To maintain that the array abyCurrBSSID in tagSMgmtObject is aligned, it was placed after the int uCurrChannel in the struct definition. This was done in wmgr.h Here is the output of pahole for the relevant datastructures: struct sockaddr { sa_family_t sa_family; /* 0 2 */ char sa_data[14]; /* 2 14 */ /* size: 16, cachelines: 1, members: 2 */ /* last cacheline: 16 bytes */ }; struct tagSMgmtObject { void * pAdapter; /* 0 4 */ unsigned char abyMACAddr[6]; /* 4 6 */ /* XXX 2 bytes hole, try to pack */ WMAC_CONFIG_MODE eConfigMode; /* 12 4 */ CARD_PHY_TYPE eCurrentPHYMode; /* 16 4 */ CARD_PHY_TYPE eConfigPHYMode; /* 20 4 */ WMAC_CURRENT_MODE eCurrMode; /* 24 4 */ WMAC_BSS_STATE eCurrState; /* 28 4 */ PKnownBSS pCurrBSS; /* 32 4 */ unsigned char byCSSGK; /* 36 1 */ unsigned char byCSSPK; /* 37 1 */ /* XXX 2 bytes hole, try to pack */ unsigned int uCurrChannel; /* 40 4 */ unsigned char abyCurrBSSID[6]; /* 44 6 */ unsigned char abyCurrSuppRates[19]; /* 50 19 */ /* --- cacheline 1 boundary (64 bytes) was 5 bytes ago --- */ unsigned char abyCurrExtSuppRates[19]; /* 69 19 */ unsigned char abyCurrSSID[35]; /* 88 35 */ /* XXX 1 byte hole, try to pack */ short unsigned int wCurrCapInfo; /* 124 2 */ short unsigned int wCurrAID; /* 126 2 */ /* --- cacheline 2 boundary (128 bytes) --- */ short unsigned int wCurrATIMWindow; /* 128 2 */ short unsigned int wCurrBeaconPeriod; /* 130 2 */ bool bIsDS; /* 132 1 */ unsigned char byERPContext; /* 133 1 */ /* XXX 2 bytes hole, try to pack */ CMD_STATE eCommandState; /* 136 4 */ unsigned int uScanChannel; /* 140 4 */ unsigned char abyDesireSSID[35]; /* 144 35 */ unsigned char abyDesireBSSID[6]; /* 179 6 */ /* XXX 1 byte hole, try to pack */ short unsigned int wIBSSBeaconPeriod; /* 186 2 */ short unsigned int wIBSSATIMWindow; /* 188 2 */ /* XXX 2 bytes hole, try to pack */ /* --- cacheline 3 boundary (192 bytes) --- */ unsigned int uIBSSChannel; /* 192 4 */ unsigned char abyIBSSSuppRates[19]; /* 196 19 */ unsigned char byAPBBType; /* 215 1 */ unsigned char abyWPAIE[64]; /* 216 64 */ /* --- cacheline 4 boundary (256 bytes) was 24 bytes ago --- */ short unsigned int wWPAIELen; /* 280 2 */ /* XXX 2 bytes hole, try to pack */ unsigned int uAssocCount; /* 284 4 */ bool bMoreData; /* 288 1 */ /* XXX 3 bytes hole, try to pack */ WMAC_SCAN_STATE eScanState; /* 292 4 */ WMAC_SCAN_TYPE eScanType; /* 296 4 */ unsigned int uScanStartCh; /* 300 4 */ unsigned int uScanEndCh; /* 304 4 */ short unsigned int wScanSteps; /* 308 2 */ /* XXX 2 bytes hole, try to pack */ unsigned int uScanBSSType; /* 312 4 */ unsigned char abyScanSSID[35]; /* 316 35 */ /* --- cacheline 5 boundary (320 bytes) was 31 bytes ago --- */ unsigned char abyScanBSSID[6]; /* 351 6 */ /* XXX 3 bytes hole, try to pack */ WMAC_AUTHENTICATION_MODE eAuthenMode; /* 360 4 */ WMAC_ENCRYPTION_MODE eEncryptionMode; /* 364 4 */ bool bShareKeyAlgorithm; /* 368 1 */ unsigned char abyChallenge[128]; /* 369 128 */ /* --- cacheline 7 boundary (448 bytes) was 49 bytes ago --- */ bool bPrivacyInvoked; /* 497 1 */ bool bInTIM; /* 498 1 */ bool bMulticastTIM; /* 499 1 */ unsigned char byDTIMCount; /* 500 1 */ unsigned char byDTIMPeriod; /* 501 1 */ /* XXX 2 bytes hole, try to pack */ WMAC_POWER_MODE ePSMode; /* 504 4 */ short unsigned int wListenInterval; /* 508 2 */ short unsigned int wCountToWakeUp; /* 510 2 */ /* --- cacheline 8 boundary (512 bytes) --- */ bool bInTIMWake; /* 512 1 */ /* XXX 3 bytes hole, try to pack */ unsigned char * pbyPSPacketPool; /* 516 4 */ unsigned char byPSPacketPool[36]; /* 520 36 */ bool bRxBeaconInTBTTWake; /* 556 1 */ unsigned char abyPSTxMap[65]; /* 557 65 */ /* XXX 2 bytes hole, try to pack */ /* --- cacheline 9 boundary (576 bytes) was 48 bytes ago --- */ unsigned int uCmdBusy; /* 624 4 */ unsigned int uCmdHostAPBusy; /* 628 4 */ unsigned char * pbyMgmtPacketPool; /* 632 4 */ unsigned char byMgmtPacketPool[2352]; /* 636 2352 */ /* --- cacheline 46 boundary (2944 bytes) was 44 bytes ago --- */ struct timer_list sTimerSecondCallback; /* 2988 52 */ /* --- cacheline 47 boundary (3008 bytes) was 32 bytes ago --- */ SRxMgmtPacket sRxPacket; /* 3040 28 */ KnownBSS sBSSList[42]; /* 3068 57288 */ /* --- cacheline 943 boundary (60352 bytes) was 4 bytes ago --- */ KnownNodeDB sNodeDBTable[65]; /* 60356 20800 */ /* --- cacheline 1268 boundary (81152 bytes) was 4 bytes ago --- */ /* Bitfield combined with previous fields */ SPMKIDCache gsPMKIDCache; /* 0 356 */ bool bRoaming; /* 0 1 */ SAssocInfo sAssocInfo; /* 0 7064 */ bool b11hEnable; /* 0 1 */ bool bSwitchChannel; /* 0 1 */ unsigned char byNewChannel; /* 0 1 */ PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep; /* 0 4 */ unsigned int uLengthOfRepEIDs; /* 0 4 */ unsigned char abyCurrentMSRReq[2352]; /* 0 2352 */ unsigned char abyCurrentMSRRep[2352]; /* 0 2352 */ unsigned char abyIECountry[2340]; /* 0 2340 */ unsigned char abyIBSSDFSOwner[6]; /* 0 6 */ unsigned char byIBSSDFSRecovery; /* 0 1 */ struct sk_buff skb; /* 0 192 */ /* XXX last struct has 4 bytes of padding */ /* --- cacheline 1497 boundary (95808 bytes) was 32 bytes ago --- */ /* size: 95840, cachelines: 1498, members: 81 */ /* sum members: 95813, holes: 13, sum holes: 27 */ /* padding: 30112 */ /* paddings: 1, sum paddings: 4 */ /* last cacheline: 32 bytes */ /* BRAIN FART ALERT! 95840 != 95813 + 27(holes), diff = 0 */ }; struct pmkid_candidate { NDIS_802_11_MAC_ADDRESS BSSID; /* 0 6 */ /* XXX 2 bytes hole, try to pack */ long unsigned int Flags; /* 8 4 */ /* size: 12, cachelines: 1, members: 2 */ /* sum members: 10, holes: 1, sum holes: 2 */ /* last cacheline: 12 bytes */ }; Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wmgr.c | 5 +++-- drivers/staging/vt6655/wmgr.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index c73c39d7adfd..a1bada1173f3 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -1022,7 +1022,8 @@ s_vMgrRxAssocResponse( } memset(&wrqu, 0, sizeof(wrqu)); - memcpy(wrqu.ap_addr.sa_data, &pMgmt->abyCurrBSSID[0], ETH_ALEN); + ether_addr_copy(wrqu.ap_addr.sa_data, + &pMgmt->abyCurrBSSID[0]); wrqu.ap_addr.sa_family = ARPHRD_ETHER; wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); } @@ -4419,7 +4420,7 @@ bAdd_PMKID_Candidate( else pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); + ether_addr_copy(pCandidateList->BSSID, pbyBSSID); pDevice->gsPMKIDCandidate.NumCandidates++; pr_debug("NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index ce939b30ac2a..a00652bfec4e 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -204,10 +204,10 @@ typedef struct tagSMgmtObject { // Current state vars unsigned int uCurrChannel; + unsigned char abyCurrBSSID[WLAN_BSSID_LEN]; unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; unsigned char abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - unsigned char abyCurrBSSID[WLAN_BSSID_LEN]; unsigned short wCurrCapInfo; unsigned short wCurrAID; unsigned short wCurrATIMWindow; -- cgit v1.2.3-59-g8ed1b From 2359b5c2d950a101af883e51bdbffc1bf83325c4 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 11 Oct 2014 02:42:45 +0200 Subject: staging: vt6655: replace memcpy() by ether_addr_copy() using coccinelle and pack variables This patch focuses on fixing the following warning generated by checkpatch.pl for the file rxtx.c : Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) The changes were applied using the following coccinelle rule: @@ expression e1, e2; @@ - memcpy(e1, e2, ETH_ALEN); + ether_addr_copy(e1, e2); After applying the rule, some referencing operations were adjusted manually to avoid a gcc compilation warning. According to ether_addr_copy() description and functionality, all Ethernet addresses should align to the u16 datatype. A check was made on the following datastructures: - vnt_mic_hdr - tagS802_11Header - tagSEthernetHeader - vnt_rts_g - ieee80211_rts - vnt_private To maintain that the array abyCurrentNetAddr in vnt_private is aligned, it was placed before the boolean bLinkPass in the struct definition. The definition can be found in device.h. A couple of variables were packed in holes detected by pahole. Output of pahole when running it on rxtx.o after the changes: truct tagSEthernetHeader { unsigned char abyDstAddr[6]; /* 0 6 */ unsigned char abySrcAddr[6]; /* 6 6 */ short unsigned int wType; /* 12 2 */ /* size: 14, cachelines: 1, members: 3 */ /* last cacheline: 14 bytes */ }; struct tagS802_11Header { short unsigned int wFrameCtl; /* 0 2 */ short unsigned int wDurationID; /* 2 2 */ unsigned char abyAddr1[6]; /* 4 6 */ unsigned char abyAddr2[6]; /* 10 6 */ unsigned char abyAddr3[6]; /* 16 6 */ short unsigned int wSeqCtl; /* 22 2 */ unsigned char abyAddr4[6]; /* 24 6 */ /* size: 30, cachelines: 1, members: 7 */ /* last cacheline: 30 bytes */ }; struct ieee80211_rts { __le16 frame_control; /* 0 2 */ __le16 duration; /* 2 2 */ u8 ra[6]; /* 4 6 */ u8 ta[6]; /* 10 6 */ /* size: 16, cachelines: 1, members: 4 */ /* last cacheline: 16 bytes */ }; struct vnt_private { struct pci_dev * pcid; /* 0 4 */ struct net_device * dev; /* 4 4 */ dma_addr_t pool_dma; /* 8 4 */ dma_addr_t rd0_pool_dma; /* 12 4 */ dma_addr_t rd1_pool_dma; /* 16 4 */ dma_addr_t td0_pool_dma; /* 20 4 */ dma_addr_t td1_pool_dma; /* 24 4 */ dma_addr_t tx_bufs_dma0; /* 28 4 */ dma_addr_t tx_bufs_dma1; /* 32 4 */ dma_addr_t tx_beacon_dma; /* 36 4 */ unsigned char * tx0_bufs; /* 40 4 */ unsigned char * tx1_bufs; /* 44 4 */ unsigned char * tx_beacon_bufs; /* 48 4 */ CHIP_TYPE chip_id; /* 52 4 */ void * PortOffset; /* 56 4 */ long unsigned int dwIsr; /* 60 4 */ /*--- cacheline 1 boundary (64 bytes) ---*/ u32 memaddr; /* 64 4 */ u32 ioaddr; /* 68 4 */ u32 io_size; /* 72 4 */ unsigned char byRevId; /* 76 1 */ unsigned char byRxMode; /* 77 1 */ short unsigned int SubSystemID; /* 78 2 */ short unsigned int SubVendorID; /* 80 2 */ spinlock_t lock; /* 82 2 */ int nTxQueues; /* 84 4 */ volatile int iTDUsed; /* 88 8 */ volatile PSTxDesc apCurrTD; /* 96 8 */ volatile PSTxDesc apTailTD; /* 104 8 */ volatile PSTxDesc apTD0Rings; /* 112 4 */ volatile PSTxDesc apTD1Rings; /* 116 4 */ volatile PSRxDesc aRD0Ring; /* 120 4 */ volatile PSRxDesc aRD1Ring; /* 124 4 */ /*--- cacheline 2 boundary (128 bytes) ---*/ volatile PSRxDesc pCurrRD; /* 128 8 */ SCache sDupRxCache; /* 136 44 */ SDeFragControlBlock sRxDFCB[64]; /* 180 2048 */ /*--- cacheline 34 boundary (2176 bytes) was 52 bytes ago ---*/ unsigned int cbDFCB; /* 2228 4 */ unsigned int cbFreeDFCB; /* 2232 4 */ unsigned int uCurrentDFCBIdx; /* 2236 4 */ /*--- cacheline 35 boundary (2240 bytes) ---*/ OPTIONS sOpts; /* 2240 52 */ u32 flags; /* 2292 4 */ u32 rx_buf_sz; /* 2296 4 */ int multicast_limit; /* 2300 4 */ /*--- cacheline 36 boundary (2304 bytes) ---*/ pid_t MLMEThr_pid; /* 2304 4 */ struct completion notify; /* 2308 16 */ struct semaphore mlme_semaphore; /* 2324 16 */ u32 rx_bytes; /* 2340 4 */ unsigned char byLocalID; /* 2344 1 */ unsigned char byRFType; /* 2345 1 */ unsigned char byMaxPwrLevel; /* 2346 1 */ unsigned char byZoneType; /* 2347 1 */ bool bZoneRegExist; /* 2348 1 */ unsigned char byOriginalZonetype; /* 2349 1 */ unsigned char abyMacContext[384]; /* 2350 384 */ /*--- cacheline 42 boundary (2688 bytes) was 46 bytes ago ---*/ unsigned char abyCurrentNetAddr[6]; /* 2734 6 */ bool bLinkPass; /* 2740 1 */ /* XXX 3 bytes hole, try to pack */ SStatCounter scStatistic; /* 2744 776 */ /*--- cacheline 55 boundary (3520 bytes) ---*/ SDot11Counters s802_11Counter; /* 3520 172 */ /*--- cacheline 57 boundary (3648 bytes) was 44 bytes ago ---*/ PSMgmtObject pMgmt; /* 3692 4 */ SMgmtObject sMgmtObj; /* 3696 95840 */ /*--- cacheline 1555 boundary (99520 bytes) was 16 bytes ago ---*/ /* Bitfield combined with previous fields */ unsigned int uCurrRSSI; /* 0 4 */ unsigned char byCurrSQ; /* 0 1 */ long unsigned int dwTxAntennaSel; /* 0 4 */ long unsigned int dwRxAntennaSel; /* 0 4 */ unsigned char byAntennaCount; /* 0 1 */ unsigned char byRxAntennaMode; /* 0 1 */ unsigned char byTxAntennaMode; /* 0 1 */ bool bTxRxAntInv; /* 0 1 */ unsigned char * pbyTmpBuff; /* 0 4 */ unsigned int uSIFS; /* 0 4 */ unsigned int uDIFS; /* 0 4 */ unsigned int uEIFS; /* 0 4 */ unsigned int uSlot; /* 0 4 */ unsigned int uCwMin; /* 0 4 */ unsigned int uCwMax; /* 0 4 */ unsigned char bySIFS; /* 0 1 */ unsigned char byDIFS; /* 0 1 */ unsigned char byEIFS; /* 0 1 */ unsigned char bySlot; /* 0 1 */ unsigned char byCWMaxMin; /* 0 1 */ CARD_PHY_TYPE eCurrentPHYType; /* 0 4 */ VIA_BB_TYPE byBBType; /* 0 4 */ VIA_PKT_TYPE byPacketType; /* 0 4 */ short unsigned int wBasicRate; /* 0 2 */ unsigned char byACKRate; /* 0 1 */ unsigned char byTopOFDMBasicRate; /* 0 1 */ unsigned char byTopCCKBasicRate; /* 0 1 */ unsigned char byMinChannel; /* 0 1 */ unsigned char byMaxChannel; /* 0 1 */ unsigned int uConnectionRate; /* 0 4 */ unsigned char byPreambleType; /* 0 1 */ unsigned char byShortPreamble; /* 0 1 */ short unsigned int wCurrentRate; /* 0 2 */ short unsigned int wRTSThreshold; /* 0 2 */ short unsigned int wFragmentationThreshold; /* 0 2 */ unsigned char byShortRetryLimit; /* 0 1 */ unsigned char byLongRetryLimit; /* 0 1 */ enum nl80211_iftype op_mode; /* 0 4 */ unsigned char byOpMode; /* 0 1 */ bool bBSSIDFilter; /* 0 1 */ short unsigned int wMaxTransmitMSDULifetime; /* 0 2 */ unsigned char abyBSSID[6]; /* 0 6 */ unsigned char abyDesireBSSID[6]; /* 0 6 */ short unsigned int wACKDuration; /* 0 2 */ short unsigned int wRTSTransmitLen; /* 0 2 */ unsigned char byRTSServiceField; /* 0 1 */ unsigned char byRTSSignalField; /* 0 1 */ long unsigned int dwMaxReceiveLifetime; /* 0 4 */ bool bEncryptionEnable; /* 0 1 */ bool bLongHeader; /* 0 1 */ bool bShortSlotTime; /* 0 1 */ bool bProtectMode; /* 0 1 */ bool bNonERPPresent; /* 0 1 */ bool bBarkerPreambleMd; /* 0 1 */ unsigned char byERPFlag; /* 0 1 */ short unsigned int wUseProtectCntDown; /* 0 2 */ bool bRadioControlOff; /* 0 1 */ bool bRadioOff; /* 0 1 */ bool bEnablePSMode; /* 0 1 */ short unsigned int wListenInterval; /* 0 2 */ bool bPWBitOn; /* 0 1 */ WMAC_POWER_MODE ePSMode; /* 0 4 */ unsigned char byRadioCtl; /* 0 1 */ unsigned char byGPIO; /* 0 1 */ bool bHWRadioOff; /* 0 1 */ bool bPrvActive4RadioOFF; /* 0 1 */ bool bGPIOBlockRead; /* 0 1 */ short unsigned int wSeqCounter; /* 0 2 */ short unsigned int wBCNBufLen; /* 0 2 */ bool bBeaconBufReady; /* 0 1 */ bool bBeaconSent; /* 0 1 */ bool bIsBeaconBufReadySet; /* 0 1 */ unsigned int cbBeaconBufReadySetCnt; /* 0 4 */ bool bFixRate; /* 0 1 */ unsigned char byCurrentCh; /* 0 1 */ unsigned int uScanTime; /* 0 4 */ CMD_STATE eCommandState; /* 0 4 */ CMD_CODE eCommand; /* 0 4 */ bool bBeaconTx; /* 0 1 */ bool bStopBeacon; /* 0 1 */ bool bStopDataPkt; /* 0 1 */ bool bStopTx0Pkt; /* 0 1 */ unsigned int uAutoReConnectTime; /* 0 4 */ CMD_ITEM eCmdQueue[32]; /* 0 1408 */ unsigned int uCmdDequeueIdx; /* 0 4 */ unsigned int uCmdEnqueueIdx; /* 0 4 */ unsigned int cbFreeCmdQueue; /* 0 4 */ bool bCmdRunning; /* 0 1 */ bool bCmdClear; /* 0 1 */ bool bRoaming; /* 0 1 */ unsigned char abyIPAddr[4]; /* 0 4 */ long unsigned int ulTxPower; /* 0 4 */ NDIS_802_11_WEP_STATUS eEncryptionStatus; /* 0 4 */ bool bTransmitKey; /* 0 1 */ NDIS_802_11_WEP_STATUS eOldEncryptionStatus; /* 0 4 */ SKeyManagement sKey; /* 0 3784 */ long unsigned int dwIVCounter; /* 0 4 */ u64 qwPacketNumber; /* 0 8 */ unsigned int uCurrentWEPMode; /* 0 4 */ RC4Ext SBox; /* 0 264 */ unsigned char abyPRNG[35]; /* 0 35 */ unsigned char byKeyIndex; /* 0 1 */ unsigned int uKeyLength; /* 0 4 */ unsigned char abyKey[29]; /* 0 29 */ bool bAES; /* 0 1 */ unsigned char byCntMeasure; /* 0 1 */ unsigned int uAssocCount; /* 0 4 */ bool bMoreData; /* 0 1 */ bool bGrpAckPolicy; /* 0 1 */ bool bAssocInfoSet; /* 0 1 */ unsigned char byAutoFBCtrl; /* 0 1 */ bool bTxMICFail; /* 0 1 */ bool bRxMICFail; /* 0 1 */ unsigned int uRATEIdx; /* 0 4 */ bool bUpdateBBVGA; /* 0 1 */ unsigned int uBBVGADiffCount; /* 0 4 */ unsigned char byBBVGANew; /* 0 1 */ unsigned char byBBVGACurrent; /* 0 1 */ unsigned char abyBBVGA[4]; /* 0 4 */ long int ldBmThreshold[4]; /* 0 16 */ unsigned char byBBPreEDRSSI; /* 0 1 */ unsigned char byBBPreEDIndex; /* 0 1 */ bool bRadioCmd; /* 0 1 */ long unsigned int dwDiagRefCount; /* 0 4 */ unsigned char byFOETuning; /* 0 1 */ unsigned char byAutoPwrTunning; /* 0 1 */ short int sPSetPointCCK; /* 0 2 */ short int sPSetPointOFDMG; /* 0 2 */ short int sPSetPointOFDMA; /* 0 2 */ long int lPFormulaOffset; /* 0 4 */ short int sPThreshold; /* 0 2 */ char cAdjustStep; /* 0 1 */ char cMinTxAGC; /* 0 1 */ unsigned char byCCKPwr; /* 0 1 */ unsigned char byOFDMPwrG; /* 0 1 */ unsigned char byCurPwr; /* 0 1 */ char byCurPwrdBm; /* 0 1 */ unsigned char abyCCKPwrTbl[15]; /* 0 15 */ unsigned char abyOFDMPwrTbl[57]; /* 0 57 */ char abyCCKDefaultPwr[15]; /* 0 15 */ char abyOFDMDefaultPwr[57]; /* 0 57 */ char abyRegPwr[57]; /* 0 57 */ char abyLocalPwr[57]; /* 0 57 */ unsigned char byBBCR4d; /* 0 1 */ unsigned char byBBCRc9; /* 0 1 */ unsigned char byBBCR88; /* 0 1 */ unsigned char byBBCR09; /* 0 1 */ struct timer_list sTimerCommand; /* 0 52 */ struct timer_list sTimerTxData; /* 0 52 */ long unsigned int nTxDataTimeCout; /* 0 4 */ bool fTxDataInSleep; /* 0 1 */ bool IsTxDataTrigger; /* 0 1 */ bool fWPA_Authened; /* 0 1 */ unsigned char byReAssocCount; /* 0 1 */ unsigned char byLinkWaitCount; /* 0 1 */ unsigned char abyNodeName[17]; /* 0 17 */ bool bDiversityRegCtlON; /* 0 1 */ bool bDiversityEnable; /* 0 1 */ long unsigned int ulDiversityNValue; /* 0 4 */ long unsigned int ulDiversityMValue; /* 0 4 */ unsigned char byTMax; /* 0 1 */ unsigned char byTMax2; /* 0 1 */ unsigned char byTMax3; /* 0 1 */ long unsigned int ulSQ3TH; /* 0 4 */ long unsigned int uDiversityCnt; /* 0 4 */ unsigned char byAntennaState; /* 0 1 */ long unsigned int ulRatio_State0; /* 0 4 */ long unsigned int ulRatio_State1; /* 0 4 */ struct timer_list TimerSQ3Tmax1; /* 0 52 */ struct timer_list TimerSQ3Tmax2; /* 0 52 */ struct timer_list TimerSQ3Tmax3; /* 0 52 */ long unsigned int uNumSQ3[12]; /* 0 48 */ short unsigned int wAntDiversityMaxRate; /* 0 2 */ SEthernetHeader sTxEthHeader; /* 0 14 */ SEthernetHeader sRxEthHeader; /* 0 14 */ unsigned char abyBroadcastAddr[6]; /* 0 6 */ unsigned char abySNAP_RFC1042[6]; /* 0 6 */ unsigned char abySNAP_Bridgetunnel[6]; /* 0 6 */ unsigned char abyEEPROM[256]; /* 0 256 */ SPMKID gsPMKID; /* 0 360 */ SPMKIDCandidateEvent gsPMKIDCandidate; /* 0 72 */ bool b11hEnable; /* 0 1 */ unsigned char abyCountryCode[3]; /* 0 3 */ unsigned int uNumOfMeasureEIDs; /* 0 4 */ PWLAN_IE_MEASURE_REQ pCurrMeasureEID; /* 0 4 */ bool bMeasureInProgress; /* 0 1 */ unsigned char byOrgChannel; /* 0 1 */ unsigned char byOrgRCR; /* 0 1 */ long unsigned int dwOrgMAR0; /* 0 4 */ long unsigned int dwOrgMAR4; /* 0 4 */ unsigned char byBasicMap; /* 0 1 */ unsigned char byCCAFraction; /* 0 1 */ unsigned char abyRPIs[8]; /* 0 8 */ long unsigned int dwRPIs[8]; /* 0 32 */ bool bChannelSwitch; /* 0 1 */ unsigned char byNewChannel; /* 0 1 */ unsigned char byChannelSwitchCount; /* 0 1 */ bool bQuietEnable; /* 0 1 */ bool bEnableFirstQuiet; /* 0 1 */ unsigned char byQuietStartCount; /* 0 1 */ unsigned int uQuietEnqueue; /* 0 4 */ long unsigned int dwCurrentQuietEndTime; /* 0 4 */ SQuietControl sQuiet[8]; /* 0 96 */ bool bCountryInfo5G; /* 0 1 */ bool bCountryInfo24G; /* 0 1 */ short unsigned int wBeaconInterval; /* 0 2 */ struct net_device * wpadev; /* 0 4 */ bool bWPADEVUp; /* 0 1 */ struct sk_buff * skb; /* 0 4 */ unsigned int bwextcount; /* 0 4 */ bool bWPASuppWextEnabled; /* 0 1 */ bool bEnableHostapd; /* 0 1 */ bool bEnable8021x; /* 0 1 */ bool bEnableHostWEP; /* 0 1 */ struct net_device * apdev; /* 0 4 */ int (*tx_80211)(struct sk_buff *, struct net_device *); /* 0 4 */ unsigned int uChannel; /* 0 4 */ bool bMACSuspend; /* 0 1 */ struct iw_statistics wstats; /* 0 32 */ bool bCommit; /* 0 1 */ /*--- cacheline 1672 boundary (107008 bytes) ---*/ /* size: 107008, cachelines: 1672, members: 279 */ /* sum members: 107005, holes: 1, sum holes: 3 */ /* padding: 41471 */ /* BRAIN FART ALERT! 107008 != 107005 + 3(holes), diff = 0 */ }; struct vnt_mic_hdr { u8 id; /* 0 1 */ u8 tx_priority; /* 1 1 */ u8 mic_addr2[6]; /* 2 6 */ u8 ccmp_pn[6]; /* 8 6 */ __be16 payload_len; /* 14 2 */ __be16 hlen; /* 16 2 */ __le16 frame_control; /* 18 2 */ u8 addr1[6]; /* 20 6 */ u8 addr2[6]; /* 26 6 */ u8 addr3[6]; /* 32 6 */ __le16 seq_ctrl; /* 38 2 */ u8 addr4[6]; /* 40 6 */ u16 packing; /* 46 2 */ /* size: 48, cachelines: 1, members: 13 */ /* last cacheline: 48 bytes */ }; struct vnt_rts_g { struct vnt_phy_field b; /* 0 4 */ struct vnt_phy_field a; /* 4 4 */ __le16 duration_ba; /* 8 2 */ __le16 duration_aa; /* 10 2 */ __le16 duration_bb; /* 12 2 */ u16 reserved; /* 14 2 */ struct ieee80211_rts data; /* 16 16 */ /* size: 32, cachelines: 1, members: 7 */ /* last cacheline: 32 bytes */ }; Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 8 +-- drivers/staging/vt6655/rxtx.c | 113 ++++++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 44 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index ddd356aa7eaf..ab6be41d4964 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -356,9 +356,12 @@ struct vnt_private { u32 io_size; unsigned char byRevId; + unsigned char byRxMode; unsigned short SubSystemID; unsigned short SubVendorID; + spinlock_t lock; + int nTxQueues; volatile int iTDUsed[TYPE_MAXTD]; @@ -384,9 +387,6 @@ struct vnt_private { u32 rx_buf_sz; int multicast_limit; - unsigned char byRxMode; - - spinlock_t lock; pid_t MLMEThr_pid; struct completion notify; @@ -403,8 +403,8 @@ struct vnt_private { bool bZoneRegExist; unsigned char byOriginalZonetype; unsigned char abyMacContext[MAC_MAX_CONTEXT_REG]; - bool bLinkPass; // link status: OK or fail unsigned char abyCurrentNetAddr[ETH_ALEN]; + bool bLinkPass; // link status: OK or fail // Adapter statistics SStatCounter scStatistic; diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 7a183f55e7eb..da7c0a8674b6 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -264,7 +264,7 @@ s_vFillTxKey( /* MICHDR0 */ mic_hdr->id = 0x59; mic_hdr->tx_priority = 0; - memcpy(mic_hdr->mic_addr2, pMACHeader->abyAddr2, ETH_ALEN); + ether_addr_copy(mic_hdr->mic_addr2, pMACHeader->abyAddr2); /* ccmp pn big endian order */ mic_hdr->ccmp_pn[0] = (u8)(pTransmitKey->dwTSC47_16 >> 24); @@ -282,17 +282,17 @@ s_vFillTxKey( else mic_hdr->hlen = cpu_to_be16(22); - memcpy(mic_hdr->addr1, pMACHeader->abyAddr1, ETH_ALEN); - memcpy(mic_hdr->addr2, pMACHeader->abyAddr2, ETH_ALEN); + ether_addr_copy(mic_hdr->addr1, pMACHeader->abyAddr1); + ether_addr_copy(mic_hdr->addr2, pMACHeader->abyAddr2); /* MICHDR2 */ - memcpy(mic_hdr->addr3, pMACHeader->abyAddr3, ETH_ALEN); + ether_addr_copy(mic_hdr->addr3, pMACHeader->abyAddr3); mic_hdr->frame_control = cpu_to_le16(pMACHeader->wFrameCtl & 0xc78f); mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->wSeqCtl & 0xf); if (pDevice->bLongHeader) - memcpy(mic_hdr->addr4, pMACHeader->abyAddr4, ETH_ALEN); + ether_addr_copy(mic_hdr->addr4, pMACHeader->abyAddr4); } } @@ -853,14 +853,18 @@ s_vFillRTSHead( if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || (pDevice->op_mode == NL80211_IFTYPE_AP)) { - memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + psEthHeader->abyDstAddr); } else { - memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ra, + pDevice->abyBSSID); } if (pDevice->op_mode == NL80211_IFTYPE_AP) - memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ta, + pDevice->abyBSSID); else - memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN); + ether_addr_copy(buf->data.ta, + psEthHeader->abySrcAddr); } else { struct vnt_rts_g_fb *buf = pvRTS; @@ -917,15 +921,19 @@ s_vFillRTSHead( if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || (pDevice->op_mode == NL80211_IFTYPE_AP)) { - memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + psEthHeader->abyDstAddr); } else { - memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ra, + pDevice->abyBSSID); } if (pDevice->op_mode == NL80211_IFTYPE_AP) - memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ta, + pDevice->abyBSSID); else - memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN); + ether_addr_copy(buf->data.ta, + psEthHeader->abySrcAddr); } // if (byFBOption == AUTO_FB_NONE) } else if (byPktType == PK_TYPE_11A) { @@ -950,15 +958,19 @@ s_vFillRTSHead( if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || (pDevice->op_mode == NL80211_IFTYPE_AP)) { - memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + psEthHeader->abyDstAddr); } else { - memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ra, + pDevice->abyBSSID); } if (pDevice->op_mode == NL80211_IFTYPE_AP) - memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ta, + pDevice->abyBSSID); else - memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN); + ether_addr_copy(buf->data.ta, + psEthHeader->abySrcAddr); } else { struct vnt_rts_a_fb *buf = pvRTS; @@ -990,14 +1002,18 @@ s_vFillRTSHead( if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || (pDevice->op_mode == NL80211_IFTYPE_AP)) { - memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + psEthHeader->abyDstAddr); } else { - memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ra, + pDevice->abyBSSID); } if (pDevice->op_mode == NL80211_IFTYPE_AP) - memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ta, + pDevice->abyBSSID); else - memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN); + ether_addr_copy(buf->data.ta, + psEthHeader->abySrcAddr); } } else if (byPktType == PK_TYPE_11B) { struct vnt_rts_ab *buf = pvRTS; @@ -1018,15 +1034,17 @@ s_vFillRTSHead( if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || (pDevice->op_mode == NL80211_IFTYPE_AP)) { - memcpy(&buf->data.ra, psEthHeader->abyDstAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + psEthHeader->abyDstAddr); } else { - memcpy(&buf->data.ra, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ra, pDevice->abyBSSID); } if (pDevice->op_mode == NL80211_IFTYPE_AP) - memcpy(&buf->data.ta, pDevice->abyBSSID, ETH_ALEN); + ether_addr_copy(buf->data.ta, pDevice->abyBSSID); else - memcpy(&buf->data.ta, psEthHeader->abySrcAddr, ETH_ALEN); + ether_addr_copy(buf->data.ta, + psEthHeader->abySrcAddr); } } @@ -1093,7 +1111,8 @@ s_vFillCTSHead( buf->reserved2 = 0x0; - memcpy(&buf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + pDevice->abyCurrentNetAddr); } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) struct vnt_cts *buf = pvCTS; /* Get SignalField, ServiceField & Length */ @@ -1116,7 +1135,8 @@ s_vFillCTSHead( IEEE80211_STYPE_CTS); buf->reserved2 = 0x0; - memcpy(&buf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); + ether_addr_copy(buf->data.ra, + pDevice->abyCurrentNetAddr); } } } @@ -2105,19 +2125,28 @@ vGenerateMACHeader( pMACHeader->wFrameCtl = TYPE_802_11_DATA; if (pDevice->op_mode == NL80211_IFTYPE_AP) { - memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN); - memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); - memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); + ether_addr_copy(&(pMACHeader->abyAddr1[0]), + &(psEthHeader->abyDstAddr[0])); + ether_addr_copy(&(pMACHeader->abyAddr2[0]), + &(pDevice->abyBSSID[0])); + ether_addr_copy(&(pMACHeader->abyAddr3[0]), + &(psEthHeader->abySrcAddr[0])); pMACHeader->wFrameCtl |= FC_FROMDS; } else { if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { - memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN); - memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - memcpy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); + ether_addr_copy(&(pMACHeader->abyAddr1[0]), + &(psEthHeader->abyDstAddr[0])); + ether_addr_copy(&(pMACHeader->abyAddr2[0]), + &(psEthHeader->abySrcAddr[0])); + ether_addr_copy(&(pMACHeader->abyAddr3[0]), + &(pDevice->abyBSSID[0])); } else { - memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN); - memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - memcpy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); + ether_addr_copy(&(pMACHeader->abyAddr3[0]), + &(psEthHeader->abyDstAddr[0])); + ether_addr_copy(&(pMACHeader->abyAddr2[0]), + &(psEthHeader->abySrcAddr[0])); + ether_addr_copy(&(pMACHeader->abyAddr1[0]), + &(pDevice->abyBSSID[0])); pMACHeader->wFrameCtl |= FC_TODS; } } @@ -2311,8 +2340,10 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket) memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); - memcpy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), ETH_ALEN); - memcpy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), ETH_ALEN); + ether_addr_copy(&(sEthHeader.abyDstAddr[0]), + &(pPacket->p80211Header->sA3.abyAddr1[0])); + ether_addr_copy(&(sEthHeader.abySrcAddr[0]), + &(pPacket->p80211Header->sA3.abyAddr2[0])); //========================= // No Fragmentation //========================= @@ -2804,8 +2835,10 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb, } memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); - memcpy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), ETH_ALEN); - memcpy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), ETH_ALEN); + ether_addr_copy(&(sEthHeader.abyDstAddr[0]), + &(p80211Header->sA3.abyAddr1[0])); + ether_addr_copy(&(sEthHeader.abySrcAddr[0]), + &(p80211Header->sA3.abyAddr2[0])); //========================= // No Fragmentation //========================= -- cgit v1.2.3-59-g8ed1b From d09e9b160fc18116942101743693f5535bc5136a Mon Sep 17 00:00:00 2001 From: Jeff Kirsher Date: Wed, 15 Oct 2014 15:53:27 -0700 Subject: staging: bcm: remove driver The Beceem WiMAX driver was barely function in its current state and was non-functional on 64 bit systems. Based on repeated statements from Greg KH that he wanted the driver removed, I am removing the driver. CC: Matthias Beyer CC: Kevin McKinney Signed-off-by: Jeff Kirsher Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 7 - drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/bcm/Adapter.h | 474 --- drivers/staging/bcm/Bcmchar.c | 2652 -------------- drivers/staging/bcm/Bcmnet.c | 240 -- drivers/staging/bcm/CmHost.c | 2254 ------------ drivers/staging/bcm/CmHost.h | 62 - drivers/staging/bcm/DDRInit.c | 1355 ------- drivers/staging/bcm/DDRInit.h | 9 - drivers/staging/bcm/Debug.h | 242 -- drivers/staging/bcm/HandleControlPacket.c | 241 -- drivers/staging/bcm/HostMIBSInterface.h | 192 - drivers/staging/bcm/IPv6Protocol.c | 476 --- drivers/staging/bcm/IPv6ProtocolHdr.h | 85 - drivers/staging/bcm/InterfaceAdapter.h | 79 - drivers/staging/bcm/InterfaceDld.c | 317 -- drivers/staging/bcm/InterfaceIdleMode.c | 274 -- drivers/staging/bcm/InterfaceIdleMode.h | 15 - drivers/staging/bcm/InterfaceInit.c | 729 ---- drivers/staging/bcm/InterfaceInit.h | 26 - drivers/staging/bcm/InterfaceIsr.c | 190 - drivers/staging/bcm/InterfaceIsr.h | 15 - drivers/staging/bcm/InterfaceMacros.h | 18 - drivers/staging/bcm/InterfaceMisc.c | 246 -- drivers/staging/bcm/InterfaceMisc.h | 42 - drivers/staging/bcm/InterfaceRx.c | 289 -- drivers/staging/bcm/InterfaceRx.h | 7 - drivers/staging/bcm/InterfaceTx.c | 213 -- drivers/staging/bcm/InterfaceTx.h | 7 - drivers/staging/bcm/Ioctl.h | 226 -- drivers/staging/bcm/Kconfig | 6 - drivers/staging/bcm/LeakyBucket.c | 363 -- drivers/staging/bcm/Macros.h | 352 -- drivers/staging/bcm/Makefile | 12 - drivers/staging/bcm/Misc.c | 1587 -------- drivers/staging/bcm/PHSDefines.h | 94 - drivers/staging/bcm/PHSModule.c | 1699 --------- drivers/staging/bcm/PHSModule.h | 59 - drivers/staging/bcm/Protocol.h | 128 - drivers/staging/bcm/Prototypes.h | 217 -- drivers/staging/bcm/Qos.c | 1199 ------ drivers/staging/bcm/Queue.h | 29 - drivers/staging/bcm/TODO | 26 - drivers/staging/bcm/Transmit.c | 271 -- drivers/staging/bcm/Typedefs.h | 47 - drivers/staging/bcm/cntrl_SignalingInterface.h | 311 -- drivers/staging/bcm/headers.h | 78 - drivers/staging/bcm/hostmibs.c | 164 - drivers/staging/bcm/led_control.c | 951 ----- drivers/staging/bcm/led_control.h | 84 - drivers/staging/bcm/nvm.c | 4661 ------------------------ drivers/staging/bcm/nvm.h | 286 -- drivers/staging/bcm/sort.c | 52 - drivers/staging/bcm/target_params.h | 57 - drivers/staging/bcm/vendorspecificextn.c | 145 - drivers/staging/bcm/vendorspecificextn.h | 18 - 57 files changed, 23881 deletions(-) delete mode 100644 drivers/staging/bcm/Adapter.h delete mode 100644 drivers/staging/bcm/Bcmchar.c delete mode 100644 drivers/staging/bcm/Bcmnet.c delete mode 100644 drivers/staging/bcm/CmHost.c delete mode 100644 drivers/staging/bcm/CmHost.h delete mode 100644 drivers/staging/bcm/DDRInit.c delete mode 100644 drivers/staging/bcm/DDRInit.h delete mode 100644 drivers/staging/bcm/Debug.h delete mode 100644 drivers/staging/bcm/HandleControlPacket.c delete mode 100644 drivers/staging/bcm/HostMIBSInterface.h delete mode 100644 drivers/staging/bcm/IPv6Protocol.c delete mode 100644 drivers/staging/bcm/IPv6ProtocolHdr.h delete mode 100644 drivers/staging/bcm/InterfaceAdapter.h delete mode 100644 drivers/staging/bcm/InterfaceDld.c delete mode 100644 drivers/staging/bcm/InterfaceIdleMode.c delete mode 100644 drivers/staging/bcm/InterfaceIdleMode.h delete mode 100644 drivers/staging/bcm/InterfaceInit.c delete mode 100644 drivers/staging/bcm/InterfaceInit.h delete mode 100644 drivers/staging/bcm/InterfaceIsr.c delete mode 100644 drivers/staging/bcm/InterfaceIsr.h delete mode 100644 drivers/staging/bcm/InterfaceMacros.h delete mode 100644 drivers/staging/bcm/InterfaceMisc.c delete mode 100644 drivers/staging/bcm/InterfaceMisc.h delete mode 100644 drivers/staging/bcm/InterfaceRx.c delete mode 100644 drivers/staging/bcm/InterfaceRx.h delete mode 100644 drivers/staging/bcm/InterfaceTx.c delete mode 100644 drivers/staging/bcm/InterfaceTx.h delete mode 100644 drivers/staging/bcm/Ioctl.h delete mode 100644 drivers/staging/bcm/Kconfig delete mode 100644 drivers/staging/bcm/LeakyBucket.c delete mode 100644 drivers/staging/bcm/Macros.h delete mode 100644 drivers/staging/bcm/Makefile delete mode 100644 drivers/staging/bcm/Misc.c delete mode 100644 drivers/staging/bcm/PHSDefines.h delete mode 100644 drivers/staging/bcm/PHSModule.c delete mode 100644 drivers/staging/bcm/PHSModule.h delete mode 100644 drivers/staging/bcm/Protocol.h delete mode 100644 drivers/staging/bcm/Prototypes.h delete mode 100644 drivers/staging/bcm/Qos.c delete mode 100644 drivers/staging/bcm/Queue.h delete mode 100644 drivers/staging/bcm/TODO delete mode 100644 drivers/staging/bcm/Transmit.c delete mode 100644 drivers/staging/bcm/Typedefs.h delete mode 100644 drivers/staging/bcm/cntrl_SignalingInterface.h delete mode 100644 drivers/staging/bcm/headers.h delete mode 100644 drivers/staging/bcm/hostmibs.c delete mode 100644 drivers/staging/bcm/led_control.c delete mode 100644 drivers/staging/bcm/led_control.h delete mode 100644 drivers/staging/bcm/nvm.c delete mode 100644 drivers/staging/bcm/nvm.h delete mode 100644 drivers/staging/bcm/sort.c delete mode 100644 drivers/staging/bcm/target_params.h delete mode 100644 drivers/staging/bcm/vendorspecificextn.c delete mode 100644 drivers/staging/bcm/vendorspecificextn.h diff --git a/MAINTAINERS b/MAINTAINERS index a20df9bf8ab0..d0dd1f35b81d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1883,13 +1883,6 @@ W: http://bcache.evilpiepirate.org S: Maintained: F: drivers/md/bcache/ -BECEEM BCS200/BCS220-3/BCSM250 WIMAX SUPPORT -M: Kevin McKinney -M: Matthias Beyer -L: devel@driverdev.osuosl.org -S: Maintained -F: drivers/staging/bcm* - BEFS FILE SYSTEM S: Orphan F: Documentation/filesystems/befs.txt diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 80ad2078eea2..3b01fef54a35 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -62,8 +62,6 @@ source "drivers/staging/xgifb/Kconfig" source "drivers/staging/emxx_udc/Kconfig" -source "drivers/staging/bcm/Kconfig" - source "drivers/staging/ft1000/Kconfig" source "drivers/staging/speakup/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 17aa2231e208..26ecead09901 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -25,7 +25,6 @@ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_FB_XGI) += xgifb/ obj-$(CONFIG_USB_EMXX) += emxx_udc/ -obj-$(CONFIG_BCM_WIMAX) += bcm/ obj-$(CONFIG_FT1000) += ft1000/ obj-$(CONFIG_SPEAKUP) += speakup/ obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217) += cptm1217/ diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h deleted file mode 100644 index 940c852e17b7..000000000000 --- a/drivers/staging/bcm/Adapter.h +++ /dev/null @@ -1,474 +0,0 @@ -/*********************************** -* Adapter.h -************************************/ -#ifndef __ADAPTER_H__ -#define __ADAPTER_H__ - -#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256 -#include "Debug.h" - -struct bcm_leader { - USHORT Vcid; - USHORT PLength; - UCHAR Status; - UCHAR Unused[3]; -} __packed; - -struct bcm_packettosend { - struct bcm_leader Leader; - UCHAR ucPayload; -} __packed; - -struct bcm_control_packet { - PVOID ControlBuff; - UINT ControlBuffLen; - struct bcm_control_packet *next; -} __packed; - -struct bcm_link_request { - struct bcm_leader Leader; - UCHAR szData[4]; -} __packed; - -#define MAX_IP_RANGE_LENGTH 4 -#define MAX_PORT_RANGE 4 -#define MAX_PROTOCOL_LENGTH 32 -#define IPV6_ADDRESS_SIZEINBYTES 0x10 - -union u_ip_address { - struct { - /* Source Ip Address Range */ - ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; - /* Source Ip Mask Address Range */ - ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; - }; - struct { - /* Source Ip Address Range */ - ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; - /* Source Ip Mask Address Range */ - ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4]; - }; - struct { - UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS]; - UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS]; - }; - struct { - UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES]; - UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES]; - }; -}; - -struct bcm_hdr_suppression_contextinfo { - /* Intermediate buffer to accumulate pkt Header for PHS */ - UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; - /* Intermediate buffer containing pkt Header after PHS */ - UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; -}; - -struct bcm_classifier_rule { - ULONG ulSFID; - UCHAR ucReserved[2]; - B_UINT16 uiClassifierRuleIndex; - bool bUsed; - USHORT usVCID_Value; - /* This field detemines the Classifier Priority */ - B_UINT8 u8ClassifierRulePriority; - union u_ip_address stSrcIpAddress; - UCHAR ucIPSourceAddressLength; /* Ip Source Address Length */ - - union u_ip_address stDestIpAddress; - /* Ip Destination Address Length */ - UCHAR ucIPDestinationAddressLength; - UCHAR ucIPTypeOfServiceLength; /* Type of service Length */ - UCHAR ucTosLow; /* Tos Low */ - UCHAR ucTosHigh; /* Tos High */ - UCHAR ucTosMask; /* Tos Mask */ - - UCHAR ucProtocolLength; /* protocol Length */ - UCHAR ucProtocol[MAX_PROTOCOL_LENGTH]; /* protocol Length */ - USHORT usSrcPortRangeLo[MAX_PORT_RANGE]; - USHORT usSrcPortRangeHi[MAX_PORT_RANGE]; - UCHAR ucSrcPortRangeLength; - - USHORT usDestPortRangeLo[MAX_PORT_RANGE]; - USHORT usDestPortRangeHi[MAX_PORT_RANGE]; - UCHAR ucDestPortRangeLength; - - bool bProtocolValid; - bool bTOSValid; - bool bDestIpValid; - bool bSrcIpValid; - - /* For IPv6 Addressing */ - UCHAR ucDirection; - bool bIpv6Protocol; - UINT32 u32PHSRuleID; - struct bcm_phs_rule sPhsRule; - UCHAR u8AssociatedPHSI; - - /* Classification fields for ETH CS */ - UCHAR ucEthCSSrcMACLen; - UCHAR au8EThCSSrcMAC[MAC_ADDRESS_SIZE]; - UCHAR au8EThCSSrcMACMask[MAC_ADDRESS_SIZE]; - UCHAR ucEthCSDestMACLen; - UCHAR au8EThCSDestMAC[MAC_ADDRESS_SIZE]; - UCHAR au8EThCSDestMACMask[MAC_ADDRESS_SIZE]; - UCHAR ucEtherTypeLen; - UCHAR au8EthCSEtherType[NUM_ETHERTYPE_BYTES]; - UCHAR usUserPriority[2]; - USHORT usVLANID; - USHORT usValidityBitMap; -}; - -struct bcm_fragmented_packet_info { - bool bUsed; - ULONG ulSrcIpAddress; - USHORT usIpIdentification; - struct bcm_classifier_rule *pstMatchedClassifierEntry; - bool bOutOfOrderFragment; -}; - -struct bcm_packet_info { - /* classification extension Rule */ - ULONG ulSFID; - USHORT usVCID_Value; - UINT uiThreshold; - /* This field determines the priority of the SF Queues */ - B_UINT8 u8TrafficPriority; - - bool bValid; - bool bActive; - bool bActivateRequestSent; - - B_UINT8 u8QueueType; /* BE or rtPS */ - - /* maximum size of the bucket for the queue */ - UINT uiMaxBucketSize; - UINT uiCurrentQueueDepthOnTarget; - UINT uiCurrentBytesOnHost; - UINT uiCurrentPacketsOnHost; - UINT uiDroppedCountBytes; - UINT uiDroppedCountPackets; - UINT uiSentBytes; - UINT uiSentPackets; - UINT uiCurrentDrainRate; - UINT uiThisPeriodSentBytes; - LARGE_INTEGER liDrainCalculated; - UINT uiCurrentTokenCount; - LARGE_INTEGER liLastUpdateTokenAt; - UINT uiMaxAllowedRate; - UINT NumOfPacketsSent; - UCHAR ucDirection; - USHORT usCID; - struct bcm_mibs_parameters stMibsExtServiceFlowTable; - UINT uiCurrentRxRate; - UINT uiThisPeriodRxBytes; - UINT uiTotalRxBytes; - UINT uiTotalTxBytes; - UINT uiPendedLast; - UCHAR ucIpVersion; - - union { - struct { - struct sk_buff *FirstTxQueue; - struct sk_buff *LastTxQueue; - }; - struct { - struct sk_buff *ControlHead; - struct sk_buff *ControlTail; - }; - }; - - bool bProtocolValid; - bool bTOSValid; - bool bDestIpValid; - bool bSrcIpValid; - - bool bActiveSet; - bool bAdmittedSet; - bool bAuthorizedSet; - bool bClassifierPriority; - UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH]; - bool bHeaderSuppressionEnabled; - spinlock_t SFQueueLock; - void *pstSFIndication; - struct timeval stLastUpdateTokenAt; - atomic_t uiPerSFTxResourceCount; - UINT uiMaxLatency; - UCHAR bIPCSSupport; - UCHAR bEthCSSupport; -}; - -struct bcm_tarang_data { - struct bcm_tarang_data *next; - struct bcm_mini_adapter *Adapter; - struct sk_buff *RxAppControlHead; - struct sk_buff *RxAppControlTail; - int AppCtrlQueueLen; - bool MacTracingEnabled; - bool bApplicationToExit; - struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs; - ULONG RxCntrlMsgBitMask; -}; - -struct bcm_targetdsx_buffer { - ULONG ulTargetDsxBuffer; - B_UINT16 tid; - bool valid; -}; - -typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID); - -typedef int (*FP_FLASH_WRITE_STATUS)(struct bcm_mini_adapter *, UINT, PVOID); - -/* - * Driver adapter data structure - */ -struct bcm_mini_adapter { - struct bcm_mini_adapter *next; - struct net_device *dev; - u32 msg_enable; - CHAR *caDsxReqResp; - atomic_t ApplicationRunning; - bool AppCtrlQueueOverFlow; - atomic_t CurrentApplicationCount; - atomic_t RegisteredApplicationCount; - bool LinkUpStatus; - bool TimerActive; - u32 StatisticsPointer; - struct sk_buff *RxControlHead; - struct sk_buff *RxControlTail; - struct semaphore RxAppControlQueuelock; - struct semaphore fw_download_sema; - struct bcm_tarang_data *pTarangs; - spinlock_t control_queue_lock; - wait_queue_head_t process_read_wait_queue; - - /* the pointer to the first packet we have queued in send - * deserialized miniport support variables - */ - atomic_t TotalPacketCount; - atomic_t TxPktAvail; - - /* this to keep track of the Tx and Rx MailBox Registers. */ - atomic_t CurrNumFreeTxDesc; - /* to keep track the no of byte received */ - USHORT PrevNumRecvDescs; - USHORT CurrNumRecvDescs; - UINT u32TotalDSD; - struct bcm_packet_info PackInfo[NO_OF_QUEUES]; - struct bcm_classifier_rule astClassifierTable[MAX_CLASSIFIERS]; - bool TransferMode; - - /*************** qos ******************/ - bool bETHCSEnabled; - ULONG BEBucketSize; - ULONG rtPSBucketSize; - UCHAR LinkStatus; - bool AutoLinkUp; - bool AutoSyncup; - - int major; - int minor; - wait_queue_head_t tx_packet_wait_queue; - wait_queue_head_t process_rx_cntrlpkt; - atomic_t process_waiting; - bool fw_download_done; - - char *txctlpacket[MAX_CNTRL_PKTS]; - atomic_t cntrlpktCnt; - atomic_t index_app_read_cntrlpkt; - atomic_t index_wr_txcntrlpkt; - atomic_t index_rd_txcntrlpkt; - UINT index_datpkt; - struct semaphore rdmwrmsync; - - struct bcm_targetdsx_buffer astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS]; - ULONG ulFreeTargetBufferCnt; - ULONG ulCurrentTargetBuffer; - ULONG ulTotalTargetBuffersAvailable; - unsigned long chip_id; - wait_queue_head_t lowpower_mode_wait_queue; - bool bFlashBoot; - bool bBinDownloaded; - bool bCfgDownloaded; - bool bSyncUpRequestSent; - USHORT usBestEffortQueueIndex; - wait_queue_head_t ioctl_fw_dnld_wait_queue; - bool waiting_to_fw_download_done; - pid_t fw_download_process_pid; - struct bcm_target_params *pstargetparams; - bool device_removed; - bool DeviceAccess; - bool bIsAutoCorrectEnabled; - bool bDDRInitDone; - int DDRSetting; - ULONG ulPowerSaveMode; - spinlock_t txtransmitlock; - B_UINT8 txtransmit_running; - /* Thread for control packet handling */ - struct task_struct *control_packet_handler; - /* thread for transmitting packets. */ - struct task_struct *transmit_packet_thread; - - /* LED Related Structures */ - struct bcm_led_info LEDInfo; - - /* Driver State for LED Blinking */ - enum bcm_led_events DriverState; - /* Interface Specific */ - PVOID pvInterfaceAdapter; - int (*bcm_file_download)(PVOID, - struct file *, - unsigned int); - int (*bcm_file_readback_from_chip)(PVOID, - struct file *, - unsigned int); - int (*interface_rdm)(PVOID, - UINT, - PVOID, - int); - int (*interface_wrm)(PVOID, - UINT, - PVOID, - int); - int (*interface_transmit)(PVOID, PVOID , UINT); - bool IdleMode; - bool bDregRequestSentInIdleMode; - bool bTriedToWakeUpFromlowPowerMode; - bool bShutStatus; - bool bWakeUpDevice; - unsigned int usIdleModePattern; - /* BOOLEAN bTriedToWakeUpFromShutdown; */ - bool bLinkDownRequested; - int downloadDDR; - struct bcm_phs_extension stBCMPhsContext; - struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo; - uint8_t ucaPHSPktRestoreBuf[2048]; - uint8_t bPHSEnabled; - bool AutoFirmDld; - bool bMipsConfig; - bool bDPLLConfig; - UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; - UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; - struct bcm_fragmented_packet_info - astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES]; - atomic_t uiMBupdate; - UINT32 PmuMode; - enum bcm_nvm_type eNVMType; - UINT uiSectorSize; - UINT uiSectorSizeInCFG; - bool bSectorSizeOverride; - bool bStatusWrite; - UINT uiNVMDSDSize; - UINT uiVendorExtnFlag; - /* it will always represent chosen DSD at any point of time. - * Generally it is Active DSD but in case of NVM RD/WR it - * might be different. - */ - UINT ulFlashCalStart; - ULONG ulFlashControlSectionStart; - ULONG ulFlashWriteSize; - ULONG ulFlashID; - FP_FLASH_WRITE fpFlashWrite; - FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck; - - struct semaphore NVMRdmWrmLock; - struct device *pstCreatedClassDevice; - - /* BOOLEAN InterfaceUpStatus; */ - struct bcm_flash2x_cs_info *psFlash2xCSInfo; - struct bcm_flash_cs_info *psFlashCSInfo; - struct bcm_flash2x_vendor_info *psFlash2xVendorInfo; - UINT uiFlashBaseAdd; /* Flash start address */ - /* Active ISO offset chosen before f/w download */ - UINT uiActiveISOOffset; - enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */ - /* Active DSD val chosen before f/w download */ - enum bcm_flash2x_section_val eActiveDSD; - /* For accessing Active DSD chosen before f/w download */ - UINT uiActiveDSDOffsetAtFwDld; - UINT uiFlashLayoutMajorVersion; - UINT uiFlashLayoutMinorVersion; - bool bAllDSDWriteAllow; - bool bSigCorrupted; - /* this should be set who so ever want to change the Headers. - * after Write it should be reset immediately. - */ - bool bHeaderChangeAllowed; - int SelectedChip; - bool bEndPointHalted; - /* while bFlashRawRead will be true, Driver - * ignore map lay out and consider flash as of without any map. - */ - bool bFlashRawRead; - bool bPreparingForLowPowerMode; - bool bDoSuspend; - UINT syscfgBefFwDld; - bool StopAllXaction; - /* Used to Support extended CAPI requirements from */ - UINT32 liTimeSinceLastNetEntry; - struct semaphore LowPowerModeSync; - ULONG liDrainCalculated; - UINT gpioBitMap; - struct bcm_debug_state stDebugState; -}; - -#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev) - -struct bcm_eth_header { - UCHAR au8DestinationAddress[6]; - UCHAR au8SourceAddress[6]; - USHORT u16Etype; -} __packed; - -struct bcm_firmware_info { - void __user *pvMappedFirmwareAddress; - ULONG u32FirmwareLength; - ULONG u32StartingAddress; -} __packed; - -/* holds the value of net_device structure.. */ -extern struct net_device *gblpnetdev; - -struct bcm_ddr_setting { - UINT ulRegAddress; - UINT ulRegValue; -}; -int InitAdapter(struct bcm_mini_adapter *psAdapter); - -/* ===================================================================== - * Beceem vendor request codes for EP0 - * ===================================================================== - */ - -#define BCM_REQUEST_READ 0x2 -#define BCM_REQUEST_WRITE 0x1 -#define EP2_MPS_REG 0x0F0110A0 -#define EP2_MPS 0x40 - -#define EP2_CFG_REG 0x0F0110A8 -#define EP2_CFG_INT 0x27 -#define EP2_CFG_BULK 0x25 - -#define EP4_MPS_REG 0x0F0110F0 -#define EP4_MPS 0x8C - -#define EP4_CFG_REG 0x0F0110F8 - -#define ISO_MPS_REG 0x0F0110C8 -#define ISO_MPS 0x00000000 - -#define EP1 0 -#define EP2 1 -#define EP3 2 -#define EP4 3 -#define EP5 4 -#define EP6 5 - -enum bcm_einterface_setting { - DEFAULT_SETTING_0 = 0, - ALTERNATE_SETTING_1 = 1, -}; - -#endif /* __ADAPTER_H__ */ diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c deleted file mode 100644 index 88ce2da531c6..000000000000 --- a/drivers/staging/bcm/Bcmchar.c +++ /dev/null @@ -1,2652 +0,0 @@ -#include - -#include "headers.h" - -static int bcm_handle_nvm_read_cmd(struct bcm_mini_adapter *ad, - PUCHAR read_data, - struct bcm_nvm_readwrite *nvm_rw) -{ - INT status = STATUS_FAILURE; - - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - kfree(read_data); - return -EACCES; - } - - status = BeceemNVMRead(ad, (PUINT)read_data, - nvm_rw->uiOffset, - nvm_rw->uiNumBytes); - up(&ad->NVMRdmWrmLock); - - if (status != STATUS_SUCCESS) { - kfree(read_data); - return status; - } - - if (copy_to_user(nvm_rw->pBuffer, read_data, nvm_rw->uiNumBytes)) { - kfree(read_data); - return -EFAULT; - } - - return STATUS_SUCCESS; -} - -static int handle_flash2x_adapter(struct bcm_mini_adapter *ad, - PUCHAR read_data, - struct bcm_nvm_readwrite *nvm_rw) -{ - /* - * New Requirement:- - * DSD section updation will be allowed in two case:- - * 1. if DSD sig is present in DSD header means dongle - * is ok and updation is fruitfull - * 2. if point 1 failes then user buff should have - * DSD sig. this point ensures that if dongle is - * corrupted then user space program first modify - * the DSD header with valid DSD sig so that this - * as well as further write may be worthwhile. - * - * This restriction has been put assuming that - * if DSD sig is corrupted, DSD data won't be - * considered valid. - */ - INT status; - ULONG dsd_magic_num_in_usr_buff = 0; - - status = BcmFlash2xCorruptSig(ad, ad->eActiveDSD); - if (status == STATUS_SUCCESS) - return STATUS_SUCCESS; - - if (((nvm_rw->uiOffset + nvm_rw->uiNumBytes) != - ad->uiNVMDSDSize) || - (nvm_rw->uiNumBytes < SIGNATURE_SIZE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "DSD Sig is present neither in Flash nor User provided Input.."); - up(&ad->NVMRdmWrmLock); - kfree(read_data); - return status; - } - - dsd_magic_num_in_usr_buff = - ntohl(*(PUINT)(read_data + nvm_rw->uiNumBytes - - SIGNATURE_SIZE)); - if (dsd_magic_num_in_usr_buff != DSD_IMAGE_MAGIC_NUMBER) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "DSD Sig is present neither in Flash nor User provided Input.."); - up(&ad->NVMRdmWrmLock); - kfree(read_data); - return status; - } - - return STATUS_SUCCESS; -} - -/*************************************************************** -* Function - bcm_char_open() -* -* Description - This is the "open" entry point for the character -* driver. -* -* Parameters - inode: Pointer to the Inode structure of char device -* filp : File pointer of the char device -* -* Returns - Zero(Success) -****************************************************************/ - -static int bcm_char_open(struct inode *inode, struct file *filp) -{ - struct bcm_mini_adapter *ad = NULL; - struct bcm_tarang_data *tarang = NULL; - - ad = GET_BCM_ADAPTER(gblpnetdev); - tarang = kzalloc(sizeof(struct bcm_tarang_data), GFP_KERNEL); - if (!tarang) - return -ENOMEM; - - tarang->Adapter = ad; - tarang->RxCntrlMsgBitMask = 0xFFFFFFFF & ~(1 << 0xB); - - down(&ad->RxAppControlQueuelock); - tarang->next = ad->pTarangs; - ad->pTarangs = tarang; - up(&ad->RxAppControlQueuelock); - - /* Store the Adapter structure */ - filp->private_data = tarang; - - /* Start Queuing the control response Packets */ - atomic_inc(&ad->ApplicationRunning); - - nonseekable_open(inode, filp); - return 0; -} - -static int bcm_char_release(struct inode *inode, struct file *filp) -{ - struct bcm_tarang_data *tarang, *tmp, *ptmp; - struct bcm_mini_adapter *ad = NULL; - struct sk_buff *pkt, *npkt; - - tarang = (struct bcm_tarang_data *)filp->private_data; - - if (tarang == NULL) - return 0; - - ad = tarang->Adapter; - - down(&ad->RxAppControlQueuelock); - - tmp = ad->pTarangs; - for (ptmp = NULL; tmp; ptmp = tmp, tmp = tmp->next) { - if (tmp == tarang) - break; - } - - if (tmp) { - if (!ptmp) - ad->pTarangs = tmp->next; - else - ptmp->next = tmp->next; - } else { - up(&ad->RxAppControlQueuelock); - return 0; - } - - pkt = tarang->RxAppControlHead; - while (pkt) { - npkt = pkt->next; - kfree_skb(pkt); - pkt = npkt; - } - - up(&ad->RxAppControlQueuelock); - - /* Stop Queuing the control response Packets */ - atomic_dec(&ad->ApplicationRunning); - - kfree(tarang); - - /* remove this filp from the asynchronously notified filp's */ - filp->private_data = NULL; - return 0; -} - -static ssize_t bcm_char_read(struct file *filp, - char __user *buf, - size_t size, - loff_t *f_pos) -{ - struct bcm_tarang_data *tarang = filp->private_data; - struct bcm_mini_adapter *ad = tarang->Adapter; - struct sk_buff *packet = NULL; - ssize_t pkt_len = 0; - int wait_ret_val = 0; - unsigned long ret = 0; - - wait_ret_val = wait_event_interruptible( - ad->process_read_wait_queue, - (tarang->RxAppControlHead || - ad->device_removed)); - - if ((wait_ret_val == -ERESTARTSYS)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Exiting as i've been asked to exit!!!\n"); - return wait_ret_val; - } - - if (ad->device_removed) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device Removed... Killing the Apps...\n"); - return -ENODEV; - } - - if (false == ad->fw_download_done) - return -EACCES; - - down(&ad->RxAppControlQueuelock); - - if (tarang->RxAppControlHead) { - packet = tarang->RxAppControlHead; - DEQUEUEPACKET(tarang->RxAppControlHead, - tarang->RxAppControlTail); - tarang->AppCtrlQueueLen--; - } - - up(&ad->RxAppControlQueuelock); - - if (packet) { - pkt_len = packet->len; - ret = copy_to_user(buf, packet->data, - min_t(size_t, pkt_len, size)); - if (ret) { - dev_kfree_skb(packet); - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Returning from copy to user failure\n"); - return -EFAULT; - } - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Read %zd Bytes From Adapter packet = %p by process %d!\n", - pkt_len, packet, current->pid); - dev_kfree_skb(packet); - } - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<\n"); - return pkt_len; -} - -static int bcm_char_ioctl_reg_read_private(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_rdm_buffer rdm_buff = {0}; - struct bcm_ioctl_buffer io_buff; - PCHAR temp_buff; - INT status = STATUS_FAILURE; - UINT buff_len; - u16 temp_value; - int bytes; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(rdm_buff)) - return -EINVAL; - - if (copy_from_user(&rdm_buff, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - if (io_buff.OutputLength > USHRT_MAX || - io_buff.OutputLength == 0) { - return -EINVAL; - } - - buff_len = io_buff.OutputLength; - temp_value = 4 - (buff_len % 4); - buff_len += temp_value % 4; - - temp_buff = kmalloc(buff_len, GFP_KERNEL); - if (!temp_buff) - return -ENOMEM; - - bytes = rdmalt(ad, (UINT)rdm_buff.Register, - (PUINT)temp_buff, buff_len); - if (bytes > 0) { - status = STATUS_SUCCESS; - if (copy_to_user(io_buff.OutputBuffer, temp_buff, bytes)) { - kfree(temp_buff); - return -EFAULT; - } - } else { - status = bytes; - } - - kfree(temp_buff); - return status; -} - -static int bcm_char_ioctl_reg_write_private(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_wrm_buffer wrm_buff = {0}; - struct bcm_ioctl_buffer io_buff; - UINT tmp = 0; - INT status; - - /* Copy Ioctl Buffer structure */ - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(wrm_buff)) - return -EINVAL; - - /* Get WrmBuffer structure */ - if (copy_from_user(&wrm_buff, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - tmp = wrm_buff.Register & EEPROM_REJECT_MASK; - if (!((ad->pstargetparams->m_u32Customize) & VSG_MODE) && - ((tmp == EEPROM_REJECT_REG_1) || - (tmp == EEPROM_REJECT_REG_2) || - (tmp == EEPROM_REJECT_REG_3) || - (tmp == EEPROM_REJECT_REG_4))) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - - status = wrmalt(ad, (UINT)wrm_buff.Register, - (PUINT)wrm_buff.Data, sizeof(ULONG)); - - if (status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Done\n"); - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Failed\n"); - status = -EFAULT; - } - return status; -} - -static int bcm_char_ioctl_eeprom_reg_read(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_rdm_buffer rdm_buff = {0}; - struct bcm_ioctl_buffer io_buff; - PCHAR temp_buff = NULL; - UINT tmp = 0; - INT status; - int bytes; - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle Mode, Blocking Rdms\n"); - return -EACCES; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(rdm_buff)) - return -EINVAL; - - if (copy_from_user(&rdm_buff, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - if (io_buff.OutputLength > USHRT_MAX || - io_buff.OutputLength == 0) { - return -EINVAL; - } - - temp_buff = kmalloc(io_buff.OutputLength, GFP_KERNEL); - if (!temp_buff) - return STATUS_FAILURE; - - if ((((ULONG)rdm_buff.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)rdm_buff.Register & 0x3)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "RDM Done On invalid Address : %x Access Denied.\n", - (int)rdm_buff.Register); - - kfree(temp_buff); - return -EINVAL; - } - - tmp = rdm_buff.Register & EEPROM_REJECT_MASK; - bytes = rdmaltWithLock(ad, (UINT)rdm_buff.Register, - (PUINT)temp_buff, io_buff.OutputLength); - - if (bytes > 0) { - status = STATUS_SUCCESS; - if (copy_to_user(io_buff.OutputBuffer, temp_buff, bytes)) { - kfree(temp_buff); - return -EFAULT; - } - } else { - status = bytes; - } - - kfree(temp_buff); - return status; -} - -static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, - struct bcm_mini_adapter *ad, - UINT cmd) -{ - struct bcm_wrm_buffer wrm_buff = {0}; - struct bcm_ioctl_buffer io_buff; - UINT tmp = 0; - INT status; - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle Mode, Blocking Wrms\n"); - return -EACCES; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(wrm_buff)) - return -EINVAL; - - /* Get WrmBuffer structure */ - if (copy_from_user(&wrm_buff, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - if ((((ULONG)wrm_buff.Register & 0x0F000000) != 0x0F000000) || - ((ULONG)wrm_buff.Register & 0x3)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "WRM Done On invalid Address : %x Access Denied.\n", - (int)wrm_buff.Register); - return -EINVAL; - } - - tmp = wrm_buff.Register & EEPROM_REJECT_MASK; - if (!((ad->pstargetparams->m_u32Customize) & VSG_MODE) && - ((tmp == EEPROM_REJECT_REG_1) || - (tmp == EEPROM_REJECT_REG_2) || - (tmp == EEPROM_REJECT_REG_3) || - (tmp == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - - status = wrmaltWithLock(ad, (UINT)wrm_buff.Register, - (PUINT)wrm_buff.Data, - wrm_buff.Length); - - if (status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, OSAL_DBG, - DBG_LVL_ALL, "WRM Done\n"); - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "WRM Failed\n"); - status = -EFAULT; - } - return status; -} - -static int bcm_char_ioctl_gpio_set_request(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_gpio_info gpio_info = {0}; - struct bcm_ioctl_buffer io_buff; - UCHAR reset_val[4]; - UINT value = 0; - UINT bit = 0; - UINT operation = 0; - INT status; - int bytes; - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "GPIO Can't be set/clear in Low power Mode"); - return -EACCES; - } - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(gpio_info)) - return -EINVAL; - - if (copy_from_user(&gpio_info, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - bit = gpio_info.uiGpioNumber; - operation = gpio_info.uiGpioValue; - value = (1< is not correspond to LED !!!", - value); - return -EINVAL; - } - - /* Set - setting 1 */ - if (operation) { - /* Set the gpio output register */ - status = wrmaltWithLock(ad, - BCM_GPIO_OUTPUT_SET_REG, - (PUINT)(&value), sizeof(UINT)); - - if (status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Set the GPIO bit\n"); - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Failed to set the %dth GPIO\n", - bit); - return status; - } - } else { - /* Set the gpio output register */ - status = wrmaltWithLock(ad, - BCM_GPIO_OUTPUT_CLR_REG, - (PUINT)(&value), sizeof(UINT)); - - if (status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Set the GPIO bit\n"); - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Failed to clear the %dth GPIO\n", - bit); - return status; - } - } - - bytes = rdmaltWithLock(ad, (UINT)GPIO_MODE_REGISTER, - (PUINT)reset_val, sizeof(UINT)); - if (bytes < 0) { - status = bytes; - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "GPIO_MODE_REGISTER read failed"); - return status; - } - status = STATUS_SUCCESS; - - /* Set the gpio mode register to output */ - *(UINT *)reset_val |= (1<IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "GPIO Can't be set/clear in Low power Mode"); - return -EACCES; - } - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(thread_req)) - return -EINVAL; - - if (copy_from_user(&thread_req, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - /* if LED thread is running(Actively or Inactively) - * set it state to make inactive - */ - if (ad->LEDInfo.led_thread_running) { - if (thread_req.ThreadState == LED_THREAD_ACTIVATION_REQ) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "Activating thread req"); - ad->DriverState = LED_THREAD_ACTIVE; - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "DeActivating Thread req....."); - ad->DriverState = LED_THREAD_INACTIVE; - } - - /* signal thread. */ - wake_up(&ad->LEDInfo.notify_led_event); - } - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_gpio_status_request(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_gpio_info gpio_info = {0}; - struct bcm_ioctl_buffer io_buff; - ULONG bit = 0; - UCHAR read[4]; - INT status; - int bytes; - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) - return -EACCES; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(gpio_info)) - return -EINVAL; - - if (copy_from_user(&gpio_info, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - bit = gpio_info.uiGpioNumber; - - /* Set the gpio output register */ - bytes = rdmaltWithLock(ad, (UINT)GPIO_PIN_STATE_REGISTER, - (PUINT)read, sizeof(UINT)); - - if (bytes < 0) { - status = bytes; - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "RDM Failed\n"); - return status; - } - status = STATUS_SUCCESS; - return status; -} - -static int bcm_char_ioctl_gpio_multi_request(void __user *argp, - struct bcm_mini_adapter *ad) -{ - 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 io_buff; - UCHAR reset_val[4]; - INT status = STATUS_FAILURE; - int bytes; - - memset(pgpio_multi_info, 0, - MAX_IDX * sizeof(struct bcm_gpio_multi_info)); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) - return -EINVAL; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(gpio_multi_info)) - return -EINVAL; - if (io_buff.OutputLength > sizeof(gpio_multi_info)) - io_buff.OutputLength = sizeof(gpio_multi_info); - - if (copy_from_user(&gpio_multi_info, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - if (IsReqGpioIsLedInNVM(ad, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) - == false) { - BCM_DEBUG_PRINT(ad, 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, - ad->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 *)reset_val = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - pgpio_multi_info[WIMAX_IDX].uiGPIOValue; - - if (*(UINT *) reset_val) - status = wrmaltWithLock(ad, - BCM_GPIO_OUTPUT_SET_REG, - (PUINT)reset_val, sizeof(ULONG)); - - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "WRM to BCM_GPIO_OUTPUT_SET_REG Failed."); - return status; - } - - /* Clear to 0's in GPIO OUTPUT REGISTER */ - *(UINT *)reset_val = - (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & - pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & - (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); - - if (*(UINT *) reset_val) - status = wrmaltWithLock(ad, - BCM_GPIO_OUTPUT_CLR_REG, (PUINT)reset_val, - sizeof(ULONG)); - - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "WRM to BCM_GPIO_OUTPUT_CLR_REG Failed."); - return status; - } - } - - if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { - bytes = rdmaltWithLock(ad, (UINT)GPIO_PIN_STATE_REGISTER, - (PUINT)reset_val, sizeof(UINT)); - - if (bytes < 0) { - status = bytes; - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "RDM to GPIO_PIN_STATE_REGISTER Failed."); - return status; - } - status = STATUS_SUCCESS; - - pgpio_multi_info[WIMAX_IDX].uiGPIOValue = - (*(UINT *)reset_val & - pgpio_multi_info[WIMAX_IDX].uiGPIOMask); - } - - status = copy_to_user(io_buff.OutputBuffer, &gpio_multi_info, - io_buff.OutputLength); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Failed while copying Content to IOBufer for user space err:%d", - status); - return -EFAULT; - } - return status; -} - -static int bcm_char_ioctl_gpio_mode_request(void __user *argp, - struct bcm_mini_adapter *ad) -{ - 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 io_buff; - UCHAR reset_val[4]; - INT status; - int bytes; - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) - return -EINVAL; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength > sizeof(gpio_multi_mode)) - return -EINVAL; - if (io_buff.OutputLength > sizeof(gpio_multi_mode)) - io_buff.OutputLength = sizeof(gpio_multi_mode); - - if (copy_from_user(&gpio_multi_mode, io_buff.InputBuffer, - io_buff.InputLength)) - return -EFAULT; - - bytes = rdmaltWithLock(ad, (UINT)GPIO_MODE_REGISTER, - (PUINT)reset_val, sizeof(UINT)); - - if (bytes < 0) { - status = bytes; - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Read of GPIO_MODE_REGISTER failed"); - return status; - } - status = STATUS_SUCCESS; - - /* Validating the request */ - if (IsReqGpioIsLedInNVM(ad, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) - == false) { - BCM_DEBUG_PRINT(ad, 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, - ad->gpioBitMap); - return -EINVAL; - } - - if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { - /* write all OUT's (1's) */ - *(UINT *) reset_val |= - (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); - - /* write all IN's (0's) */ - *(UINT *) reset_val &= - ~((~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 *)reset_val; - - status = wrmaltWithLock(ad, GPIO_MODE_REGISTER, - (PUINT)reset_val, sizeof(ULONG)); - if (status == STATUS_SUCCESS) { - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "WRM to GPIO_MODE_REGISTER Done"); - } else { - BCM_DEBUG_PRINT(ad, 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 *)reset_val; - } - - status = copy_to_user(io_buff.OutputBuffer, &gpio_multi_mode, - io_buff.OutputLength); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Failed while copying Content to IOBufer for user space err:%d", - status); - return -EFAULT; - } - return status; -} - -static int bcm_char_ioctl_misc_request(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - PVOID buff = NULL; - INT status; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength < sizeof(struct bcm_link_request)) - return -EINVAL; - - if (io_buff.InputLength > MAX_CNTL_PKT_SIZE) - return -EINVAL; - - buff = memdup_user(io_buff.InputBuffer, - io_buff.InputLength); - if (IS_ERR(buff)) - return PTR_ERR(buff); - - down(&ad->LowPowerModeSync); - status = wait_event_interruptible_timeout( - ad->lowpower_mode_wait_queue, - !ad->bPreparingForLowPowerMode, - (1 * HZ)); - - if (status == -ERESTARTSYS) - goto cntrlEnd; - - if (ad->bPreparingForLowPowerMode) { - BCM_DEBUG_PRINT(ad, 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(ad, (PVOID)buff); - -cntrlEnd: - up(&ad->LowPowerModeSync); - kfree(buff); - return status; -} - -static int bcm_char_ioctl_buffer_download_start( - struct bcm_mini_adapter *ad) -{ - INT status; - - if (down_trylock(&ad->NVMRdmWrmLock)) { - BCM_DEBUG_PRINT(ad, 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(ad, DBG_TYPE_PRINTK, 0, 0, - "Starting the firmware download PID =0x%x!!!!\n", - current->pid); - - if (down_trylock(&ad->fw_download_sema)) - return -EBUSY; - - ad->bBinDownloaded = false; - ad->fw_download_process_pid = current->pid; - ad->bCfgDownloaded = false; - ad->fw_download_done = false; - netif_carrier_off(ad->dev); - netif_stop_queue(ad->dev); - status = reset_card_proc(ad); - if (status) { - pr_err(PFX "%s: reset_card_proc Failed!\n", ad->dev->name); - up(&ad->fw_download_sema); - up(&ad->NVMRdmWrmLock); - return status; - } - mdelay(10); - - up(&ad->NVMRdmWrmLock); - return status; -} - -static int bcm_char_ioctl_buffer_download(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_firmware_info *fw_info = NULL; - struct bcm_ioctl_buffer io_buff; - INT status; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Starting the firmware download PID =0x%x!!!!\n", current->pid); - - if (!down_trylock(&ad->fw_download_sema)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Invalid way to download buffer. Use Start and then call this!!!\n"); - up(&ad->fw_download_sema); - return -EINVAL; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) { - up(&ad->fw_download_sema); - return -EFAULT; - } - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Length for FW DLD is : %lx\n", io_buff.InputLength); - - if (io_buff.InputLength > sizeof(struct bcm_firmware_info)) { - up(&ad->fw_download_sema); - return -EINVAL; - } - - fw_info = kmalloc(sizeof(*fw_info), GFP_KERNEL); - if (!fw_info) { - up(&ad->fw_download_sema); - return -ENOMEM; - } - - if (copy_from_user(fw_info, io_buff.InputBuffer, - io_buff.InputLength)) { - up(&ad->fw_download_sema); - kfree(fw_info); - return -EFAULT; - } - - if (!fw_info->pvMappedFirmwareAddress || - (fw_info->u32FirmwareLength == 0)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Something else is wrong %lu\n", - fw_info->u32FirmwareLength); - up(&ad->fw_download_sema); - kfree(fw_info); - status = -EINVAL; - return status; - } - - status = bcm_ioctl_fw_download(ad, fw_info); - - if (status != STATUS_SUCCESS) { - if (fw_info->u32StartingAddress == CONFIG_BEGIN_ADDR) - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "IOCTL: Configuration File Upload Failed\n"); - else - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "IOCTL: Firmware File Upload Failed\n"); - - /* up(&ad->fw_download_sema); */ - - if (ad->LEDInfo.led_thread_running & - BCM_LED_THREAD_RUNNING_ACTIVELY) { - ad->DriverState = DRIVER_INIT; - ad->LEDInfo.bLedInitDone = false; - wake_up(&ad->LEDInfo.notify_led_event); - } - } - - if (status != STATUS_SUCCESS) - up(&ad->fw_download_sema); - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, - "IOCTL: Firmware File Uploaded\n"); - kfree(fw_info); - return status; -} - -static int bcm_char_ioctl_buffer_download_stop(void __user *argp, - struct bcm_mini_adapter *ad) -{ - INT status; - int timeout = 0; - - if (!down_trylock(&ad->fw_download_sema)) { - up(&ad->fw_download_sema); - return -EINVAL; - } - - if (down_trylock(&ad->NVMRdmWrmLock)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "FW download blocked as EEPROM Read/Write is in progress\n"); - up(&ad->fw_download_sema); - return -EACCES; - } - - ad->bBinDownloaded = TRUE; - ad->bCfgDownloaded = TRUE; - atomic_set(&ad->CurrNumFreeTxDesc, 0); - ad->CurrNumRecvDescs = 0; - ad->downloadDDR = 0; - - /* setting the Mips to Run */ - status = run_card_proc(ad); - - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Firm Download Failed\n"); - up(&ad->fw_download_sema); - up(&ad->NVMRdmWrmLock); - return status; - } - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "Firm Download Over...\n"); - - mdelay(10); - - /* Wait for MailBox Interrupt */ - if (StartInterruptUrb((struct bcm_interface_adapter *)ad->pvInterfaceAdapter)) - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Unable to send interrupt...\n"); - - timeout = 5*HZ; - ad->waiting_to_fw_download_done = false; - wait_event_timeout(ad->ioctl_fw_dnld_wait_queue, - ad->waiting_to_fw_download_done, timeout); - ad->fw_download_process_pid = INVALID_PID; - ad->fw_download_done = TRUE; - atomic_set(&ad->CurrNumFreeTxDesc, 0); - ad->CurrNumRecvDescs = 0; - ad->PrevNumRecvDescs = 0; - atomic_set(&ad->cntrlpktCnt, 0); - ad->LinkUpStatus = 0; - ad->LinkStatus = 0; - - if (ad->LEDInfo.led_thread_running & - BCM_LED_THREAD_RUNNING_ACTIVELY) { - ad->DriverState = FW_DOWNLOAD_DONE; - wake_up(&ad->LEDInfo.notify_led_event); - } - - if (!timeout) - status = -ENODEV; - - up(&ad->fw_download_sema); - up(&ad->NVMRdmWrmLock); - return status; -} - -static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *ad) -{ - INT status; - INT nvm_access; - - nvm_access = down_trylock(&ad->NVMRdmWrmLock); - if (nvm_access) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n"); - return -EACCES; - } - - down(&ad->RxAppControlQueuelock); - status = reset_card_proc(ad); - flushAllAppQ(); - up(&ad->RxAppControlQueuelock); - up(&ad->NVMRdmWrmLock); - ResetCounters(ad); - return status; -} - -static int bcm_char_ioctl_qos_threshold(ULONG arg, - struct bcm_mini_adapter *ad) -{ - USHORT i; - - for (i = 0; i < NO_OF_QUEUES; i++) { - if (get_user(ad->PackInfo[i].uiThreshold, - (unsigned long __user *)arg)) { - return -EFAULT; - } - } - return 0; -} - -static int bcm_char_ioctl_switch_transfer_mode(void __user *argp, - struct bcm_mini_adapter *ad) -{ - UINT data = 0; - - if (copy_from_user(&data, argp, sizeof(UINT))) - return -EFAULT; - - if (data) { - /* Allow All Packets */ - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n"); - ad->TransferMode = ETH_PACKET_TUNNELING_MODE; - } else { - /* Allow IP only Packets */ - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n"); - ad->TransferMode = IP_PACKET_ONLY_MODE; - } - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_get_driver_version(void __user *argp) -{ - struct bcm_ioctl_buffer io_buff; - ulong len; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - len = min_t(ulong, io_buff.OutputLength, strlen(DRV_VERSION) + 1); - - if (copy_to_user(io_buff.OutputBuffer, DRV_VERSION, len)) - return -EFAULT; - - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_get_current_status(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_link_state link_state; - struct bcm_ioctl_buffer io_buff; - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "copy_from_user failed..\n"); - return -EFAULT; - } - - if (io_buff.OutputLength != sizeof(link_state)) - return -EINVAL; - - memset(&link_state, 0, sizeof(link_state)); - link_state.bIdleMode = ad->IdleMode; - link_state.bShutdownMode = ad->bShutStatus; - link_state.ucLinkStatus = ad->LinkStatus; - - if (copy_to_user(io_buff.OutputBuffer, &link_state, min_t(size_t, - sizeof(link_state), io_buff.OutputLength))) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy_to_user Failed..\n"); - return -EFAULT; - } - return STATUS_SUCCESS; -} - - -static int bcm_char_ioctl_set_mac_tracing(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - UINT tracing_flag; - - /* copy ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&tracing_flag, io_buff.InputBuffer, sizeof(UINT))) - return -EFAULT; - - if (tracing_flag) - ad->pTarangs->MacTracingEnabled = TRUE; - else - ad->pTarangs->MacTracingEnabled = false; - - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_get_dsx_indication(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - ULONG sf_id = 0; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.OutputLength < sizeof(struct bcm_add_indication_alt)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Mismatch req: %lx needed is =0x%zx!!!", - io_buff.OutputLength, - sizeof(struct bcm_add_indication_alt)); - return -EINVAL; - } - - if (copy_from_user(&sf_id, io_buff.InputBuffer, sizeof(sf_id))) - return -EFAULT; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Get DSX Data SF ID is =%lx\n", sf_id); - get_dsx_sf_data_to_application(ad, sf_id, io_buff.OutputBuffer); - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_get_host_mibs(void __user *argp, - struct bcm_mini_adapter *ad, - struct bcm_tarang_data *tarang) -{ - struct bcm_ioctl_buffer io_buff; - INT status = STATUS_FAILURE; - PVOID temp_buff; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.OutputLength != sizeof(struct bcm_host_stats_mibs)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Length Check failed %lu %zd\n", io_buff.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(ad, temp_buff); - GetDroppedAppCntrlPktMibs(temp_buff, tarang); - - if (status != STATUS_FAILURE) { - if (copy_to_user(io_buff.OutputBuffer, temp_buff, - sizeof(struct bcm_host_stats_mibs))) { - kfree(temp_buff); - return -EFAULT; - } - } - - kfree(temp_buff); - return status; -} - -static int bcm_char_ioctl_bulk_wrm(void __user *argp, - struct bcm_mini_adapter *ad, UINT cmd) -{ - struct bcm_bulk_wrm_buffer *bulk_buff; - struct bcm_ioctl_buffer io_buff; - UINT tmp = 0; - INT status = STATUS_FAILURE; - PCHAR buff = NULL; - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0, - "Device in Idle/Shutdown Mode, Blocking Wrms\n"); - return -EACCES; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.InputLength < sizeof(ULONG) * 2) - return -EINVAL; - - buff = memdup_user(io_buff.InputBuffer, - io_buff.InputLength); - if (IS_ERR(buff)) - return PTR_ERR(buff); - - bulk_buff = (struct bcm_bulk_wrm_buffer *)buff; - - if (((ULONG)bulk_buff->Register & 0x0F000000) != 0x0F000000 || - ((ULONG)bulk_buff->Register & 0x3)) { - BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0, - "WRM Done On invalid Address : %x Access Denied.\n", - (int)bulk_buff->Register); - kfree(buff); - return -EINVAL; - } - - tmp = bulk_buff->Register & EEPROM_REJECT_MASK; - if (!((ad->pstargetparams->m_u32Customize)&VSG_MODE) && - ((tmp == EEPROM_REJECT_REG_1) || - (tmp == EEPROM_REJECT_REG_2) || - (tmp == EEPROM_REJECT_REG_3) || - (tmp == EEPROM_REJECT_REG_4)) && - (cmd == IOCTL_BCM_REGISTER_WRITE)) { - - kfree(buff); - BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0, - "EEPROM Access Denied, not in VSG Mode\n"); - return -EFAULT; - } - - if (bulk_buff->SwapEndian == false) - status = wrmWithLock(ad, (UINT)bulk_buff->Register, - (PCHAR)bulk_buff->Values, - io_buff.InputLength - 2*sizeof(ULONG)); - else - status = wrmaltWithLock(ad, (UINT)bulk_buff->Register, - (PUINT)bulk_buff->Values, - io_buff.InputLength - 2*sizeof(ULONG)); - - if (status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n"); - - kfree(buff); - return status; -} - -static int bcm_char_ioctl_get_nvm_size(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (ad->eNVMType == NVM_EEPROM || ad->eNVMType == NVM_FLASH) { - if (copy_to_user(io_buff.OutputBuffer, &ad->uiNVMDSDSize, - sizeof(UINT))) - return -EFAULT; - } - - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_cal_init(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - UINT sector_size = 0; - INT status = STATUS_FAILURE; - - if (ad->eNVMType == NVM_FLASH) { - if (copy_from_user(&io_buff, argp, - sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(§or_size, io_buff.InputBuffer, - sizeof(UINT))) - return -EFAULT; - - if ((sector_size < MIN_SECTOR_SIZE) || - (sector_size > MAX_SECTOR_SIZE)) { - if (copy_to_user(io_buff.OutputBuffer, - &ad->uiSectorSize, sizeof(UINT))) - return -EFAULT; - } else { - if (IsFlash2x(ad)) { - if (copy_to_user(io_buff.OutputBuffer, - &ad->uiSectorSize, sizeof(UINT))) - return -EFAULT; - } else { - if ((TRUE == ad->bShutStatus) || - (TRUE == ad->IdleMode)) { - BCM_DEBUG_PRINT(ad, - DBG_TYPE_PRINTK, 0, 0, - "Device is in Idle/Shutdown Mode\n"); - return -EACCES; - } - - ad->uiSectorSize = sector_size; - BcmUpdateSectorSize(ad, - ad->uiSectorSize); - } - } - status = STATUS_SUCCESS; - } else { - status = STATUS_FAILURE; - } - return status; -} - -static int bcm_char_ioctl_set_debug(void __user *argp, - struct bcm_mini_adapter *ad) -{ -#ifdef DEBUG - struct bcm_ioctl_buffer io_buff; - struct bcm_user_debug_state user_debug_state; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "In SET_DEBUG ioctl\n"); - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&user_debug_state, io_buff.InputBuffer, - sizeof(struct bcm_user_debug_state))) - return -EFAULT; - - BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0, - "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ", - user_debug_state.OnOff, user_debug_state.Type); - /* user_debug_state.Subtype <<= 1; */ - user_debug_state.Subtype = 1 << user_debug_state.Subtype; - BCM_DEBUG_PRINT (ad, DBG_TYPE_PRINTK, 0, 0, - "actual Subtype=0x%x\n", user_debug_state.Subtype); - - /* Update new 'DebugState' in the ad */ - ad->stDebugState.type |= user_debug_state.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 (user_debug_state.OnOff) - ad->stDebugState.subtype[user_debug_state.Type] |= - user_debug_state.Subtype; - else - ad->stDebugState.subtype[user_debug_state.Type] &= - ~user_debug_state.Subtype; - - BCM_SHOW_DEBUG_BITMAP(ad); -#endif - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_nvm_rw(void __user *argp, - struct bcm_mini_adapter *ad, UINT cmd) -{ - struct bcm_nvm_readwrite nvm_rw; - struct timeval tv0, tv1; - struct bcm_ioctl_buffer io_buff; - PUCHAR read_data = NULL; - INT status = STATUS_FAILURE; - - memset(&tv0, 0, sizeof(struct timeval)); - memset(&tv1, 0, sizeof(struct timeval)); - if ((ad->eNVMType == NVM_FLASH) && - (ad->uiFlashLayoutMajorVersion == 0)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n"); - return -EFAULT; - } - - if (IsFlash2x(ad)) { - if ((ad->eActiveDSD != DSD0) && - (ad->eActiveDSD != DSD1) && - (ad->eActiveDSD != DSD2)) { - - BCM_DEBUG_PRINT(ad, 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(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (copy_from_user(&nvm_rw, - (IOCTL_BCM_NVM_READ == cmd) ? - io_buff.OutputBuffer : io_buff.InputBuffer, - sizeof(struct bcm_nvm_readwrite))) - return -EFAULT; - - /* - * Deny the access if the offset crosses the cal area limit. - */ - if (nvm_rw.uiNumBytes > ad->uiNVMDSDSize) - return STATUS_FAILURE; - - if (nvm_rw.uiOffset > - ad->uiNVMDSDSize - nvm_rw.uiNumBytes) - return STATUS_FAILURE; - - read_data = memdup_user(nvm_rw.pBuffer, - nvm_rw.uiNumBytes); - if (IS_ERR(read_data)) - return PTR_ERR(read_data); - - do_gettimeofday(&tv0); - if (IOCTL_BCM_NVM_READ == cmd) { - int ret = bcm_handle_nvm_read_cmd(ad, read_data, - &nvm_rw); - if (ret != STATUS_SUCCESS) - return ret; - } else { - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - kfree(read_data); - return -EACCES; - } - - ad->bHeaderChangeAllowed = TRUE; - if (IsFlash2x(ad)) { - int ret = handle_flash2x_adapter(ad, - read_data, - &nvm_rw); - if (ret != STATUS_SUCCESS) - return ret; - } - - status = BeceemNVMWrite(ad, (PUINT)read_data, - nvm_rw.uiOffset, nvm_rw.uiNumBytes, - nvm_rw.bVerify); - if (IsFlash2x(ad)) - BcmFlash2xWriteSig(ad, ad->eActiveDSD); - - ad->bHeaderChangeAllowed = false; - - up(&ad->NVMRdmWrmLock); - - if (status != STATUS_SUCCESS) { - kfree(read_data); - return status; - } - } - - do_gettimeofday(&tv1); - BCM_DEBUG_PRINT(ad, 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(read_data); - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_flash2x_section_read(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_flash2x_readwrite flash_2x_read = {0}; - struct bcm_ioctl_buffer io_buff; - PUCHAR read_buff = NULL; - UINT nob = 0; - UINT buff_size = 0; - UINT read_bytes = 0; - UINT read_offset = 0; - INT status = STATUS_FAILURE; - void __user *OutPutBuff; - - if (IsFlash2x(ad) != TRUE) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); - return -EINVAL; - } - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called"); - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&flash_2x_read, io_buff.InputBuffer, - sizeof(struct bcm_flash2x_readwrite))) - return -EFAULT; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nflash_2x_read.Section :%x", - flash_2x_read.Section); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nflash_2x_read.offset :%x", - flash_2x_read.offset); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nflash_2x_read.numOfBytes :%x", - flash_2x_read.numOfBytes); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nflash_2x_read.bVerify :%x\n", - flash_2x_read.bVerify); - - /* This was internal to driver for raw read. - * now it has ben exposed to user space app. - */ - if (validateFlash2xReadWrite(ad, &flash_2x_read) == false) - return STATUS_FAILURE; - - nob = flash_2x_read.numOfBytes; - if (nob > ad->uiSectorSize) - buff_size = ad->uiSectorSize; - else - buff_size = nob; - - read_offset = flash_2x_read.offset; - OutPutBuff = io_buff.OutputBuffer; - read_buff = kzalloc(buff_size , GFP_KERNEL); - - if (read_buff == NULL) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Memory allocation failed for Flash 2.x Read Structure"); - return -ENOMEM; - } - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - kfree(read_buff); - return -EACCES; - } - - while (nob) { - if (nob > ad->uiSectorSize) - read_bytes = ad->uiSectorSize; - else - read_bytes = nob; - - /* Reading the data from Flash 2.x */ - status = BcmFlash2xBulkRead(ad, (PUINT)read_buff, - flash_2x_read.Section, read_offset, read_bytes); - if (status) { - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Flash 2x read err with status :%d", - status); - break; - } - - BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, read_buff, read_bytes); - - status = copy_to_user(OutPutBuff, read_buff, read_bytes); - if (status) { - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Copy to use failed with status :%d", status); - up(&ad->NVMRdmWrmLock); - kfree(read_buff); - return -EFAULT; - } - nob = nob - read_bytes; - if (nob) { - read_offset = read_offset + read_bytes; - OutPutBuff = OutPutBuff + read_bytes; - } - } - - up(&ad->NVMRdmWrmLock); - kfree(read_buff); - return status; -} - -static int bcm_char_ioctl_flash2x_section_write(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_flash2x_readwrite sFlash2xWrite = {0}; - struct bcm_ioctl_buffer io_buff; - PUCHAR write_buff; - void __user *input_addr; - UINT nob = 0; - UINT buff_size = 0; - UINT write_off = 0; - UINT write_bytes = 0; - INT status = STATUS_FAILURE; - - if (IsFlash2x(ad) != TRUE) { - BCM_DEBUG_PRINT(ad, 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 - */ - ad->bAllDSDWriteAllow = false; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_FLASH2X_SECTION_WRITE Called"); - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - /* Reading FLASH 2.x READ structure */ - if (copy_from_user(&sFlash2xWrite, io_buff.InputBuffer, - sizeof(struct bcm_flash2x_readwrite))) - return -EFAULT; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xWrite.Section :%x", sFlash2xWrite.Section); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xWrite.offset :%d", sFlash2xWrite.offset); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xWrite.numOfBytes :%x", sFlash2xWrite.numOfBytes); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xWrite.bVerify :%x\n", sFlash2xWrite.bVerify); - - if ((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) - && (sFlash2xWrite.Section != VSA2)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Only VSA write is allowed"); - return -EINVAL; - } - - if (validateFlash2xReadWrite(ad, &sFlash2xWrite) == false) - return STATUS_FAILURE; - - input_addr = sFlash2xWrite.pDataBuff; - write_off = sFlash2xWrite.offset; - nob = sFlash2xWrite.numOfBytes; - - if (nob > ad->uiSectorSize) - buff_size = ad->uiSectorSize; - else - buff_size = nob; - - write_buff = kmalloc(buff_size, GFP_KERNEL); - - if (write_buff == NULL) - return -ENOMEM; - - /* extracting the remainder of the given offset. */ - write_bytes = ad->uiSectorSize; - if (write_off % ad->uiSectorSize) { - write_bytes = ad->uiSectorSize - - (write_off % ad->uiSectorSize); - } - - if (nob < write_bytes) - write_bytes = nob; - - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - kfree(write_buff); - return -EACCES; - } - - BcmFlash2xCorruptSig(ad, sFlash2xWrite.Section); - do { - status = copy_from_user(write_buff, input_addr, write_bytes); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy to user failed with status :%d", status); - up(&ad->NVMRdmWrmLock); - kfree(write_buff); - return -EFAULT; - } - BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, write_buff, write_bytes); - - /* Writing the data from Flash 2.x */ - status = BcmFlash2xBulkWrite(ad, (PUINT)write_buff, - sFlash2xWrite.Section, - write_off, - write_bytes, - sFlash2xWrite.bVerify); - - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Flash 2x read err with status :%d", status); - break; - } - - nob = nob - write_bytes; - if (nob) { - write_off = write_off + write_bytes; - input_addr = input_addr + write_bytes; - if (nob > ad->uiSectorSize) - write_bytes = ad->uiSectorSize; - else - write_bytes = nob; - } - } while (nob > 0); - - BcmFlash2xWriteSig(ad, sFlash2xWrite.Section); - up(&ad->NVMRdmWrmLock); - kfree(write_buff); - return status; -} - -static int bcm_char_ioctl_flash2x_section_bitmap(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_flash2x_bitmap *flash_2x_bit_map; - struct bcm_ioctl_buffer io_buff; - -BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.OutputLength != sizeof(struct bcm_flash2x_bitmap)) - return -EINVAL; - - flash_2x_bit_map = kzalloc(sizeof(struct bcm_flash2x_bitmap), - GFP_KERNEL); - - if (flash_2x_bit_map == NULL) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Memory is not available"); - return -ENOMEM; - } - - /* Reading the Flash Sectio Bit map */ - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - kfree(flash_2x_bit_map); - return -EACCES; - } - - BcmGetFlash2xSectionalBitMap(ad, flash_2x_bit_map); - up(&ad->NVMRdmWrmLock); - if (copy_to_user(io_buff.OutputBuffer, flash_2x_bit_map, - sizeof(struct bcm_flash2x_bitmap))) { - kfree(flash_2x_bit_map); - return -EFAULT; - } - - kfree(flash_2x_bit_map); - return STATUS_FAILURE; -} - -static int bcm_char_ioctl_set_active_section(void __user *argp, - struct bcm_mini_adapter *ad) -{ - enum bcm_flash2x_section_val flash_2x_section_val = 0; - INT status = STATUS_FAILURE; - struct bcm_ioctl_buffer io_buff; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_SET_ACTIVE_SECTION Called"); - - if (IsFlash2x(ad) != TRUE) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); - return -EINVAL; - } - - status = copy_from_user(&io_buff, argp, - sizeof(struct bcm_ioctl_buffer)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - - status = copy_from_user(&flash_2x_section_val, - io_buff.InputBuffer, sizeof(INT)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of flash section val failed"); - return -EFAULT; - } - - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - return -EACCES; - } - - status = BcmSetActiveSection(ad, flash_2x_section_val); - if (status) - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Failed to make it's priority Highest. status %d", - status); - - up(&ad->NVMRdmWrmLock); - - return status; -} - -static int bcm_char_ioctl_copy_section(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_flash2x_copy_section copy_sect_strut = {0}; - struct bcm_ioctl_buffer io_buff; - INT status = STATUS_SUCCESS; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_COPY_SECTION Called"); - - ad->bAllDSDWriteAllow = false; - if (IsFlash2x(ad) != TRUE) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); - return -EINVAL; - } - - status = copy_from_user(&io_buff, argp, - sizeof(struct bcm_ioctl_buffer)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed status :%d", - status); - return -EFAULT; - } - - status = copy_from_user(©_sect_strut, io_buff.InputBuffer, - sizeof(struct bcm_flash2x_copy_section)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of Copy_Section_Struct failed with status :%d", - status); - return -EFAULT; - } - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Source SEction :%x", copy_sect_strut.SrcSection); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Destination SEction :%x", copy_sect_strut.DstSection); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "offset :%x", copy_sect_strut.offset); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "nob :%x", copy_sect_strut.numOfBytes); - - if (IsSectionExistInFlash(ad, copy_sect_strut.SrcSection) == false) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Source Section<%x> does not exist in Flash ", - copy_sect_strut.SrcSection); - return -EINVAL; - } - - if (IsSectionExistInFlash(ad, copy_sect_strut.DstSection) == false) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Destinatio Section<%x> does not exist in Flash ", - copy_sect_strut.DstSection); - return -EINVAL; - } - - if (copy_sect_strut.SrcSection == copy_sect_strut.DstSection) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Source and Destination section should be different"); - return -EINVAL; - } - - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&ad->NVMRdmWrmLock); - return -EACCES; - } - - if (copy_sect_strut.SrcSection == ISO_IMAGE1 || - copy_sect_strut.SrcSection == ISO_IMAGE2) { - if (IsNonCDLessDevice(ad)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Device is Non-CDLess hence won't have ISO !!"); - status = -EINVAL; - } else if (copy_sect_strut.numOfBytes == 0) { - status = BcmCopyISO(ad, copy_sect_strut); - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Partial Copy of ISO section is not Allowed.."); - status = STATUS_FAILURE; - } - up(&ad->NVMRdmWrmLock); - return status; - } - - status = BcmCopySection(ad, copy_sect_strut.SrcSection, - copy_sect_strut.DstSection, - copy_sect_strut.offset, - copy_sect_strut.numOfBytes); - up(&ad->NVMRdmWrmLock); - return status; -} - -static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - INT status = STATUS_SUCCESS; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - " IOCTL_BCM_GET_FLASH_CS_INFO Called"); - - status = copy_from_user(&io_buff, argp, - sizeof(struct bcm_ioctl_buffer)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - - if (ad->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Connected device does not have flash"); - return -EINVAL; - } - - if (IsFlash2x(ad) == TRUE) { - if (io_buff.OutputLength < sizeof(struct bcm_flash2x_cs_info)) - return -EINVAL; - - if (copy_to_user(io_buff.OutputBuffer, - ad->psFlash2xCSInfo, - sizeof(struct bcm_flash2x_cs_info))) - return -EFAULT; - } else { - if (io_buff.OutputLength < sizeof(struct bcm_flash_cs_info)) - return -EINVAL; - - if (copy_to_user(io_buff.OutputBuffer, ad->psFlashCSInfo, - sizeof(struct bcm_flash_cs_info))) - return -EFAULT; - } - return status; -} - -static int bcm_char_ioctl_select_dsd(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_ioctl_buffer io_buff; - INT status = STATUS_FAILURE; - UINT sect_offset = 0; - enum bcm_flash2x_section_val flash_2x_section_val; - - flash_2x_section_val = NO_SECTION_VAL; - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_SELECT_DSD Called"); - - if (IsFlash2x(ad) != TRUE) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); - return -EINVAL; - } - - status = copy_from_user(&io_buff, argp, - sizeof(struct bcm_ioctl_buffer)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed"); - return -EFAULT; - } - status = copy_from_user(&flash_2x_section_val, io_buff.InputBuffer, - sizeof(INT)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy of flash section val failed"); - return -EFAULT; - } - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Read Section :%d", flash_2x_section_val); - if ((flash_2x_section_val != DSD0) && - (flash_2x_section_val != DSD1) && - (flash_2x_section_val != DSD2)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Passed section<%x> is not DSD section", - flash_2x_section_val); - return STATUS_FAILURE; - } - - sect_offset = BcmGetSectionValStartOffset(ad, flash_2x_section_val); - if (sect_offset == INVALID_OFFSET) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Provided Section val <%d> does not exist in Flash 2.x", - flash_2x_section_val); - return -EINVAL; - } - - ad->bAllDSDWriteAllow = TRUE; - ad->ulFlashCalStart = sect_offset; - ad->eActiveDSD = flash_2x_section_val; - - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_nvm_raw_read(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_nvm_readwrite nvm_read; - struct bcm_ioctl_buffer io_buff; - unsigned int nob; - INT buff_size; - INT read_offset = 0; - UINT read_bytes = 0; - PUCHAR read_buff; - void __user *OutPutBuff; - INT status = STATUS_FAILURE; - - if (ad->eNVMType != NVM_FLASH) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "NVM TYPE is not Flash"); - return -EINVAL; - } - - /* Copy Ioctl Buffer structure */ - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "copy_from_user 1 failed\n"); - return -EFAULT; - } - - if (copy_from_user(&nvm_read, io_buff.OutputBuffer, - sizeof(struct bcm_nvm_readwrite))) - return -EFAULT; - - nob = nvm_read.uiNumBytes; - /* In Raw-Read max Buff size : 64MB */ - - if (nob > DEFAULT_BUFF_SIZE) - buff_size = DEFAULT_BUFF_SIZE; - else - buff_size = nob; - - read_offset = nvm_read.uiOffset; - OutPutBuff = nvm_read.pBuffer; - - read_buff = kzalloc(buff_size , GFP_KERNEL); - if (read_buff == NULL) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Memory allocation failed for Flash 2.x Read Structure"); - return -ENOMEM; - } - down(&ad->NVMRdmWrmLock); - - if ((ad->IdleMode == TRUE) || - (ad->bShutStatus == TRUE) || - (ad->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - kfree(read_buff); - up(&ad->NVMRdmWrmLock); - return -EACCES; - } - - ad->bFlashRawRead = TRUE; - - while (nob) { - if (nob > DEFAULT_BUFF_SIZE) - read_bytes = DEFAULT_BUFF_SIZE; - else - read_bytes = nob; - - /* Reading the data from Flash 2.x */ - status = BeceemNVMRead(ad, (PUINT)read_buff, - read_offset, read_bytes); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Flash 2x read err with status :%d", - status); - break; - } - - BCM_DEBUG_PRINT_BUFFER(ad, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, read_buff, read_bytes); - - status = copy_to_user(OutPutBuff, read_buff, read_bytes); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_PRINTK, 0, 0, - "Copy to use failed with status :%d", - status); - up(&ad->NVMRdmWrmLock); - kfree(read_buff); - return -EFAULT; - } - nob = nob - read_bytes; - if (nob) { - read_offset = read_offset + read_bytes; - OutPutBuff = OutPutBuff + read_bytes; - } - } - ad->bFlashRawRead = false; - up(&ad->NVMRdmWrmLock); - kfree(read_buff); - return status; -} - -static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp, - struct bcm_mini_adapter *ad, - struct bcm_tarang_data *tarang) -{ - struct bcm_ioctl_buffer io_buff; - INT status = STATUS_FAILURE; - ULONG rx_cntrl_msg_bit_mask = 0; - - /* Copy Ioctl Buffer structure */ - status = copy_from_user(&io_buff, argp, - sizeof(struct bcm_ioctl_buffer)); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "copy of Ioctl buffer is failed from user space"); - return -EFAULT; - } - - if (io_buff.InputLength != sizeof(unsigned long)) - return -EINVAL; - - status = copy_from_user(&rx_cntrl_msg_bit_mask, io_buff.InputBuffer, - io_buff.InputLength); - if (status) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "copy of control bit mask failed from user space"); - return -EFAULT; - } - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\n Got user defined cntrl msg bit mask :%lx", - rx_cntrl_msg_bit_mask); - tarang->RxCntrlMsgBitMask = rx_cntrl_msg_bit_mask; - - return status; -} - -static int bcm_char_ioctl_get_device_driver_info(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_driver_info dev_info; - struct bcm_ioctl_buffer io_buff; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); - - memset(&dev_info, 0, sizeof(dev_info)); - dev_info.MaxRDMBufferSize = BUFFER_4K; - dev_info.u32DSDStartOffset = EEPROM_CALPARAM_START; - dev_info.u32RxAlignmentCorrection = 0; - dev_info.u32NVMType = ad->eNVMType; - dev_info.u32InterfaceType = BCM_USB; - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.OutputLength < sizeof(dev_info)) - return -EINVAL; - - if (copy_to_user(io_buff.OutputBuffer, &dev_info, sizeof(dev_info))) - return -EFAULT; - - return STATUS_SUCCESS; -} - -static int bcm_char_ioctl_time_since_net_entry(void __user *argp, - struct bcm_mini_adapter *ad) -{ - struct bcm_time_elapsed time_elapsed_since_net_entry = {0}; - struct bcm_ioctl_buffer io_buff; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); - - if (copy_from_user(&io_buff, argp, sizeof(struct bcm_ioctl_buffer))) - return -EFAULT; - - if (io_buff.OutputLength < sizeof(struct bcm_time_elapsed)) - return -EINVAL; - - time_elapsed_since_net_entry.ul64TimeElapsedSinceNetEntry = - get_seconds() - ad->liTimeSinceLastNetEntry; - - if (copy_to_user(io_buff.OutputBuffer, &time_elapsed_since_net_entry, - sizeof(struct bcm_time_elapsed))) - return -EFAULT; - - return STATUS_SUCCESS; -} - - -static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) -{ - struct bcm_tarang_data *tarang = filp->private_data; - void __user *argp = (void __user *)arg; - struct bcm_mini_adapter *ad = tarang->Adapter; - INT status = STATUS_FAILURE; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", - cmd, arg); - - if (_IOC_TYPE(cmd) != BCM_IOCTL) - return -EFAULT; - if (_IOC_DIR(cmd) & _IOC_READ) - status = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd)); - else if (_IOC_DIR(cmd) & _IOC_WRITE) - status = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd)); - else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE)) - status = STATUS_SUCCESS; - - if (status) - return -EFAULT; - - if (ad->device_removed) - return -EFAULT; - - if (false == ad->fw_download_done) { - switch (cmd) { - case IOCTL_MAC_ADDR_REQ: - case IOCTL_LINK_REQ: - case IOCTL_CM_REQUEST: - case IOCTL_SS_INFO_REQ: - case IOCTL_SEND_CONTROL_MESSAGE: - case IOCTL_IDLE_REQ: - case IOCTL_BCM_GPIO_SET_REQUEST: - case IOCTL_BCM_GPIO_STATUS_REQUEST: - return -EACCES; - default: - break; - } - } - - status = vendorextnIoctl(ad, cmd, arg); - if (status != CONTINUE_COMMON_PATH) - return status; - - switch (cmd) { - /* Rdms for Swin Idle... */ - case IOCTL_BCM_REGISTER_READ_PRIVATE: - status = bcm_char_ioctl_reg_read_private(argp, ad); - return status; - - case IOCTL_BCM_REGISTER_WRITE_PRIVATE: - status = bcm_char_ioctl_reg_write_private(argp, ad); - return status; - - case IOCTL_BCM_REGISTER_READ: - case IOCTL_BCM_EEPROM_REGISTER_READ: - status = bcm_char_ioctl_eeprom_reg_read(argp, ad); - return status; - - case IOCTL_BCM_REGISTER_WRITE: - case IOCTL_BCM_EEPROM_REGISTER_WRITE: - status = bcm_char_ioctl_eeprom_reg_write(argp, ad, cmd); - return status; - - case IOCTL_BCM_GPIO_SET_REQUEST: - status = bcm_char_ioctl_gpio_set_request(argp, ad); - return status; - - case BCM_LED_THREAD_STATE_CHANGE_REQ: - status = bcm_char_ioctl_led_thread_state_change_req(argp, - ad); - return status; - - case IOCTL_BCM_GPIO_STATUS_REQUEST: - status = bcm_char_ioctl_gpio_status_request(argp, ad); - return status; - - case IOCTL_BCM_GPIO_MULTI_REQUEST: - status = bcm_char_ioctl_gpio_multi_request(argp, ad); - return status; - - case IOCTL_BCM_GPIO_MODE_REQUEST: - status = bcm_char_ioctl_gpio_mode_request(argp, ad); - return status; - - case IOCTL_MAC_ADDR_REQ: - case IOCTL_LINK_REQ: - case IOCTL_CM_REQUEST: - case IOCTL_SS_INFO_REQ: - case IOCTL_SEND_CONTROL_MESSAGE: - case IOCTL_IDLE_REQ: - status = bcm_char_ioctl_misc_request(argp, ad); - return status; - - case IOCTL_BCM_BUFFER_DOWNLOAD_START: - status = bcm_char_ioctl_buffer_download_start(ad); - return status; - - case IOCTL_BCM_BUFFER_DOWNLOAD: - status = bcm_char_ioctl_buffer_download(argp, ad); - return status; - - case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: - status = bcm_char_ioctl_buffer_download_stop(argp, ad); - return status; - - - case IOCTL_BE_BUCKET_SIZE: - status = 0; - if (get_user(ad->BEBucketSize, - (unsigned long __user *)arg)) - status = -EFAULT; - break; - - case IOCTL_RTPS_BUCKET_SIZE: - status = 0; - if (get_user(ad->rtPSBucketSize, - (unsigned long __user *)arg)) - status = -EFAULT; - break; - - case IOCTL_CHIP_RESET: - status = bcm_char_ioctl_chip_reset(ad); - return status; - - case IOCTL_QOS_THRESHOLD: - status = bcm_char_ioctl_qos_threshold(arg, ad); - return status; - - case IOCTL_DUMP_PACKET_INFO: - DumpPackInfo(ad); - DumpPhsRules(&ad->stBCMPhsContext); - status = STATUS_SUCCESS; - break; - - case IOCTL_GET_PACK_INFO: - if (copy_to_user(argp, &ad->PackInfo, - sizeof(struct bcm_packet_info)*NO_OF_QUEUES)) - return -EFAULT; - status = STATUS_SUCCESS; - break; - - case IOCTL_BCM_SWITCH_TRANSFER_MODE: - status = bcm_char_ioctl_switch_transfer_mode(argp, ad); - return status; - - case IOCTL_BCM_GET_DRIVER_VERSION: - status = bcm_char_ioctl_get_driver_version(argp); - return status; - - case IOCTL_BCM_GET_CURRENT_STATUS: - status = bcm_char_ioctl_get_current_status(argp, ad); - return status; - - case IOCTL_BCM_SET_MAC_TRACING: - status = bcm_char_ioctl_set_mac_tracing(argp, ad); - return status; - - case IOCTL_BCM_GET_DSX_INDICATION: - status = bcm_char_ioctl_get_dsx_indication(argp, ad); - return status; - - case IOCTL_BCM_GET_HOST_MIBS: - status = bcm_char_ioctl_get_host_mibs(argp, ad, tarang); - return status; - - case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: - if ((false == ad->bTriedToWakeUpFromlowPowerMode) && - (TRUE == ad->IdleMode)) { - ad->usIdleModePattern = ABORT_IDLE_MODE; - ad->bWakeUpDevice = TRUE; - wake_up(&ad->process_rx_cntrlpkt); - } - - status = STATUS_SUCCESS; - break; - - case IOCTL_BCM_BULK_WRM: - status = bcm_char_ioctl_bulk_wrm(argp, ad, cmd); - return status; - - case IOCTL_BCM_GET_NVM_SIZE: - status = bcm_char_ioctl_get_nvm_size(argp, ad); - return status; - - case IOCTL_BCM_CAL_INIT: - status = bcm_char_ioctl_cal_init(argp, ad); - return status; - - case IOCTL_BCM_SET_DEBUG: - status = bcm_char_ioctl_set_debug(argp, ad); - return status; - - case IOCTL_BCM_NVM_READ: - case IOCTL_BCM_NVM_WRITE: - status = bcm_char_ioctl_nvm_rw(argp, ad, cmd); - return status; - - case IOCTL_BCM_FLASH2X_SECTION_READ: - status = bcm_char_ioctl_flash2x_section_read(argp, ad); - return status; - - case IOCTL_BCM_FLASH2X_SECTION_WRITE: - status = bcm_char_ioctl_flash2x_section_write(argp, ad); - return status; - - case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP: - status = bcm_char_ioctl_flash2x_section_bitmap(argp, ad); - return status; - - case IOCTL_BCM_SET_ACTIVE_SECTION: - status = bcm_char_ioctl_set_active_section(argp, ad); - return status; - - case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION: - /* Right Now we are taking care of only DSD */ - ad->bAllDSDWriteAllow = false; - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); - status = STATUS_SUCCESS; - break; - - case IOCTL_BCM_COPY_SECTION: - status = bcm_char_ioctl_copy_section(argp, ad); - return status; - - case IOCTL_BCM_GET_FLASH_CS_INFO: - status = bcm_char_ioctl_get_flash_cs_info(argp, ad); - return status; - - case IOCTL_BCM_SELECT_DSD: - status = bcm_char_ioctl_select_dsd(argp, ad); - return status; - - case IOCTL_BCM_NVM_RAW_READ: - status = bcm_char_ioctl_nvm_raw_read(argp, ad); - return status; - - case IOCTL_BCM_CNTRLMSG_MASK: - status = bcm_char_ioctl_cntrlmsg_mask(argp, ad, tarang); - return status; - - case IOCTL_BCM_GET_DEVICE_DRIVER_INFO: - status = bcm_char_ioctl_get_device_driver_info(argp, ad); - return status; - - case IOCTL_BCM_TIME_SINCE_NET_ENTRY: - status = bcm_char_ioctl_time_since_net_entry(argp, ad); - return status; - - case IOCTL_CLOSE_NOTIFICATION: - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_CLOSE_NOTIFICATION"); - break; - - default: - pr_info(DRV_NAME ": unknown ioctl cmd=%#x\n", cmd); - status = STATUS_FAILURE; - break; - } - return status; -} - - -static const struct file_operations bcm_fops = { - .owner = THIS_MODULE, - .open = bcm_char_open, - .release = bcm_char_release, - .read = bcm_char_read, - .unlocked_ioctl = bcm_char_ioctl, - .llseek = no_llseek, -}; - -int register_control_device_interface(struct bcm_mini_adapter *ad) -{ - - if (ad->major > 0) - return ad->major; - - ad->major = register_chrdev(0, DEV_NAME, &bcm_fops); - if (ad->major < 0) { - pr_err(DRV_NAME ": could not created character device\n"); - return ad->major; - } - - ad->pstCreatedClassDevice = device_create(bcm_class, NULL, - MKDEV(ad->major, 0), - ad, DEV_NAME); - - if (IS_ERR(ad->pstCreatedClassDevice)) { - pr_err(DRV_NAME ": class device create failed\n"); - unregister_chrdev(ad->major, DEV_NAME); - return PTR_ERR(ad->pstCreatedClassDevice); - } - - return 0; -} - -void unregister_control_device_interface(struct bcm_mini_adapter *ad) -{ - if (ad->major > 0) { - device_destroy(bcm_class, MKDEV(ad->major, 0)); - unregister_chrdev(ad->major, DEV_NAME); - } -} - diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c deleted file mode 100644 index e57767684cee..000000000000 --- a/drivers/staging/bcm/Bcmnet.c +++ /dev/null @@ -1,240 +0,0 @@ -#include "headers.h" - -struct net_device *gblpnetdev; - -static INT bcm_open(struct net_device *dev) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - - if (ad->fw_download_done == false) { - pr_notice(PFX "%s: link up failed (download in progress)\n", - dev->name); - return -EBUSY; - } - - if (netif_msg_ifup(ad)) - pr_info(PFX "%s: enabling interface\n", dev->name); - - if (ad->LinkUpStatus) { - if (netif_msg_link(ad)) - pr_info(PFX "%s: link up\n", dev->name); - - netif_carrier_on(ad->dev); - netif_start_queue(ad->dev); - } - - return 0; -} - -static INT bcm_close(struct net_device *dev) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - - if (netif_msg_ifdown(ad)) - pr_info(PFX "%s: disabling interface\n", dev->name); - - netif_carrier_off(dev); - netif_stop_queue(dev); - - return 0; -} - -static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb, - void *accel_priv, select_queue_fallback_t fallback) -{ - return ClassifyPacket(netdev_priv(dev), skb); -} - -/******************************************************************* -* Function - bcm_transmit() -* -* Description - This is the main transmit function for our virtual -* interface(eth0). It handles the ARP packets. It -* clones this packet and then Queue it to a suitable -* Queue. Then calls the transmit_packet(). -* -* Parameter - skb - Pointer to the socket buffer structure -* dev - Pointer to the virtual net device structure -* -*********************************************************************/ - -static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - u16 qindex = skb_get_queue_mapping(skb); - - - if (ad->device_removed || !ad->LinkUpStatus) - goto drop; - - if (ad->TransferMode != IP_PACKET_ONLY_MODE) - goto drop; - - if (INVALID_QUEUE_INDEX == qindex) - goto drop; - - if (ad->PackInfo[qindex].uiCurrentPacketsOnHost >= - SF_MAX_ALLOWED_PACKETS_TO_BACKUP) - return NETDEV_TX_BUSY; - - /* Now Enqueue the packet */ - if (netif_msg_tx_queued(ad)) - pr_info(PFX "%s: enqueueing packet to queue %d\n", - dev->name, qindex); - - spin_lock(&ad->PackInfo[qindex].SFQueueLock); - ad->PackInfo[qindex].uiCurrentBytesOnHost += skb->len; - ad->PackInfo[qindex].uiCurrentPacketsOnHost++; - - *((B_UINT32 *) skb->cb + SKB_CB_LATENCY_OFFSET) = jiffies; - ENQUEUEPACKET(ad->PackInfo[qindex].FirstTxQueue, - ad->PackInfo[qindex].LastTxQueue, skb); - atomic_inc(&ad->TotalPacketCount); - spin_unlock(&ad->PackInfo[qindex].SFQueueLock); - - /* FIXME - this is racy and incorrect, replace with work queue */ - if (!atomic_read(&ad->TxPktAvail)) { - atomic_set(&ad->TxPktAvail, 1); - wake_up(&ad->tx_packet_wait_queue); - } - return NETDEV_TX_OK; - - drop: - dev_kfree_skb(skb); - return NETDEV_TX_OK; -} - - - -/** -@ingroup init_functions -Register other driver entry points with the kernel -*/ -static const struct net_device_ops bcmNetDevOps = { - .ndo_open = bcm_open, - .ndo_stop = bcm_close, - .ndo_start_xmit = bcm_transmit, - .ndo_change_mtu = eth_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, - .ndo_select_queue = bcm_select_queue, -}; - -static struct device_type wimax_type = { - .name = "wimax", -}; - -static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) -{ - cmd->supported = 0; - cmd->advertising = 0; - cmd->speed = SPEED_10000; - cmd->duplex = DUPLEX_FULL; - cmd->port = PORT_TP; - cmd->phy_address = 0; - cmd->transceiver = XCVR_INTERNAL; - cmd->autoneg = AUTONEG_DISABLE; - cmd->maxtxpkt = 0; - cmd->maxrxpkt = 0; - return 0; -} - -static void bcm_get_drvinfo(struct net_device *dev, - struct ethtool_drvinfo *info) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - struct bcm_interface_adapter *intf_ad = ad->pvInterfaceAdapter; - struct usb_device *udev = interface_to_usbdev(intf_ad->interface); - - strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); - strlcpy(info->version, DRV_VERSION, sizeof(info->version)); - snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u", - ad->uiFlashLayoutMajorVersion, - ad->uiFlashLayoutMinorVersion); - - usb_make_path(udev, info->bus_info, sizeof(info->bus_info)); -} - -static u32 bcm_get_link(struct net_device *dev) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - - return ad->LinkUpStatus; -} - -static u32 bcm_get_msglevel(struct net_device *dev) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - - return ad->msg_enable; -} - -static void bcm_set_msglevel(struct net_device *dev, u32 level) -{ - struct bcm_mini_adapter *ad = GET_BCM_ADAPTER(dev); - - ad->msg_enable = level; -} - -static const struct ethtool_ops bcm_ethtool_ops = { - .get_settings = bcm_get_settings, - .get_drvinfo = bcm_get_drvinfo, - .get_link = bcm_get_link, - .get_msglevel = bcm_get_msglevel, - .set_msglevel = bcm_set_msglevel, -}; - -int register_networkdev(struct bcm_mini_adapter *ad) -{ - struct net_device *net = ad->dev; - struct bcm_interface_adapter *intf_ad = ad->pvInterfaceAdapter; - struct usb_interface *udev = intf_ad->interface; - struct usb_device *xdev = intf_ad->udev; - - int result; - - net->netdev_ops = &bcmNetDevOps; - net->ethtool_ops = &bcm_ethtool_ops; - net->mtu = MTU_SIZE; /* 1400 Bytes */ - net->tx_queue_len = TX_QLEN; - net->flags |= IFF_NOARP; - - netif_carrier_off(net); - - SET_NETDEV_DEVTYPE(net, &wimax_type); - - /* Read the MAC Address from EEPROM */ - result = ReadMacAddressFromNVM(ad); - if (result != STATUS_SUCCESS) { - dev_err(&udev->dev, - PFX "Error in Reading the mac Address: %d", result); - return -EIO; - } - - result = register_netdev(net); - if (result) - return result; - - gblpnetdev = ad->dev; - - if (netif_msg_probe(ad)) - dev_info(&udev->dev, PFX "%s: register usb-%s-%s %pM\n", - net->name, xdev->bus->bus_name, xdev->devpath, - net->dev_addr); - - return 0; -} - -void unregister_networkdev(struct bcm_mini_adapter *ad) -{ - struct net_device *net = ad->dev; - struct bcm_interface_adapter *intf_ad = ad->pvInterfaceAdapter; - struct usb_interface *udev = intf_ad->interface; - struct usb_device *xdev = intf_ad->udev; - - if (netif_msg_probe(ad)) - dev_info(&udev->dev, PFX "%s: unregister usb-%s%s\n", - net->name, xdev->bus->bus_name, xdev->devpath); - - unregister_netdev(ad->dev); -} diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c deleted file mode 100644 index adca0ce4d05f..000000000000 --- a/drivers/staging/bcm/CmHost.c +++ /dev/null @@ -1,2254 +0,0 @@ -/************************************************************ - * CMHOST.C - * This file contains the routines for handling Connection - * Management. - ************************************************************/ - -#include "headers.h" - -enum E_CLASSIFIER_ACTION { - eInvalidClassifierAction, - eAddClassifier, - eReplaceClassifier, - eDeleteClassifier -}; - -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, - B_UINT16 tid); -static void restore_endianess_of_pstClassifierEntry( - struct bcm_classifier_rule *pstClassifierEntry, - enum bcm_ipaddr_context eIpAddrContext); - -static void apply_phs_rule_to_all_classifiers( - register struct bcm_mini_adapter *Adapter, - register UINT uiSearchRuleIndex, - USHORT uVCID, - struct bcm_phs_rule *sPhsRule, - struct bcm_phs_rules *cPhsRule, - struct bcm_add_indication_alt *pstAddIndication); - -/************************************************************ - * Function - SearchSfid - * - * Description - This routinue would search QOS queues having - * specified SFID as input parameter. - * - * Parameters - Adapter: Pointer to the Adapter structure - * uiSfid : Given SFID for matching - * - * Returns - Queue index for this SFID(If matched) - * Else Invalid Queue Index(If Not matched) - ************************************************************/ -int SearchSfid(struct bcm_mini_adapter *Adapter, UINT uiSfid) -{ - int i; - - for (i = (NO_OF_QUEUES-1); i >= 0; i--) - if (Adapter->PackInfo[i].ulSFID == uiSfid) - return i; - - return NO_OF_QUEUES+1; -} - -/*************************************************************** - * Function -SearchFreeSfid - * - * Description - This routinue would search Free available SFID. - * - * Parameter - Adapter: Pointer to the Adapter structure - * - * Returns - Queue index for the free SFID - * Else returns Invalid Index. - ****************************************************************/ -static int SearchFreeSfid(struct bcm_mini_adapter *Adapter) -{ - int i; - - for (i = 0; i < (NO_OF_QUEUES-1); i++) - if (Adapter->PackInfo[i].ulSFID == 0) - return i; - - return NO_OF_QUEUES+1; -} - -/* - * Function: SearchClsid - * Description: This routinue would search Classifier having specified ClassifierID as input parameter - * Input parameters: struct bcm_mini_adapter *Adapter - Adapter Context - * unsigned int uiSfid - The SF in which the classifier is to searched - * B_UINT16 uiClassifierID - The classifier ID to be searched - * Return: int :Classifier table index of matching entry - */ -static int SearchClsid(struct bcm_mini_adapter *Adapter, - ULONG ulSFID, - B_UINT16 uiClassifierID) -{ - int i; - - for (i = 0; i < MAX_CLASSIFIERS; i++) { - if ((Adapter->astClassifierTable[i].bUsed) && - (Adapter->astClassifierTable[i].uiClassifierRuleIndex - == uiClassifierID) && - (Adapter->astClassifierTable[i].ulSFID == ulSFID)) - return i; - } - - return MAX_CLASSIFIERS+1; -} - -/* - * @ingroup ctrl_pkt_functions - * This routinue would search Free available Classifier entry in classifier table. - * @return free Classifier Entry index in classifier table for specified SF - */ -static int SearchFreeClsid(struct bcm_mini_adapter *Adapter /**Adapter Context*/) -{ - int i; - - for (i = 0; i < MAX_CLASSIFIERS; i++) { - if (!Adapter->astClassifierTable[i].bUsed) - return i; - } - - return MAX_CLASSIFIERS+1; -} - -static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, - UINT uiSearchRuleIndex) -{ - /* deleting all the packet held in the SF */ - flush_queue(Adapter, uiSearchRuleIndex); - - /* Deleting the all classifiers for this SF */ - DeleteAllClassifiersForSF(Adapter, uiSearchRuleIndex); - - /* Resetting only MIBS related entries in the SF */ - memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, - sizeof(struct bcm_mibs_table)); -} - -static inline VOID -CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, - B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc, - bool bIpVersion6, enum bcm_ipaddr_context eIpAddrContext) -{ - int i = 0; - UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS; - UCHAR *ptrClassifierIpAddress = NULL; - UCHAR *ptrClassifierIpMask = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (bIpVersion6) - nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES; - - /* Destination Ip Address */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Ip Address Range Length:0x%X ", u8IpAddressLen); - if ((bIpVersion6 ? (IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2) : - (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) { - - union u_ip_address *st_dest_ip = - &pstClassifierEntry->stDestIpAddress; - - union u_ip_address *st_src_ip = - &pstClassifierEntry->stSrcIpAddress; - - /* - * checking both the mask and address togethor in Classification. - * So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2 - * (nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask) - */ - if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->ucIPDestinationAddressLength = - u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); - if (bIpVersion6) { - ptrClassifierIpAddress = - st_dest_ip->ucIpv6Address; - ptrClassifierIpMask = - st_dest_ip->ucIpv6Mask; - } else { - ptrClassifierIpAddress = - st_dest_ip->ucIpv4Address; - ptrClassifierIpMask = - st_dest_ip->ucIpv4Mask; - } - } else if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->ucIPSourceAddressLength = - u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); - if (bIpVersion6) { - ptrClassifierIpAddress = - st_src_ip->ucIpv6Address; - ptrClassifierIpMask = st_src_ip->ucIpv6Mask; - } else { - ptrClassifierIpAddress = - st_src_ip->ucIpv4Address; - ptrClassifierIpMask = st_src_ip->ucIpv4Mask; - } - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Address Length:0x%X\n", - pstClassifierEntry->ucIPDestinationAddressLength); - while ((u8IpAddressLen >= nSizeOfIPAddressInBytes) - && (i < MAX_IP_RANGE_LENGTH)) { - memcpy(ptrClassifierIpAddress + - (i * nSizeOfIPAddressInBytes), - (pu8IpAddressMaskSrc - + (i * nSizeOfIPAddressInBytes * 2)), - nSizeOfIPAddressInBytes); - - if (!bIpVersion6) { - if (eIpAddrContext == eSrcIpAddress) { - st_src_ip->ulIpv4Addr[i] = - ntohl(st_src_ip->ulIpv4Addr[i]); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - CONN_MSG, - DBG_LVL_ALL, - "Src Ip Address:0x%luX ", - st_src_ip->ulIpv4Addr[i]); - } else if (eIpAddrContext == eDestIpAddress) { - st_dest_ip->ulIpv4Addr[i] = - ntohl(st_dest_ip->ulIpv4Addr[i]); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - CONN_MSG, - DBG_LVL_ALL, - "Dest Ip Address:0x%luX ", - st_dest_ip->ulIpv4Addr[i]); - } - } - u8IpAddressLen -= nSizeOfIPAddressInBytes; - if (u8IpAddressLen >= nSizeOfIPAddressInBytes) { - memcpy(ptrClassifierIpMask + - (i * nSizeOfIPAddressInBytes), - (pu8IpAddressMaskSrc - + nSizeOfIPAddressInBytes - + (i * nSizeOfIPAddressInBytes * 2)), - nSizeOfIPAddressInBytes); - - if (!bIpVersion6) { - if (eIpAddrContext == eSrcIpAddress) { - st_src_ip->ulIpv4Mask[i] = - ntohl(st_src_ip->ulIpv4Mask[i]); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - CONN_MSG, - DBG_LVL_ALL, - "Src Ip Mask Address:0x%luX ", - st_src_ip->ulIpv4Mask[i]); - } else if (eIpAddrContext == eDestIpAddress) { - st_dest_ip->ulIpv4Mask[i] = - ntohl(st_dest_ip->ulIpv4Mask[i]); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - CONN_MSG, - DBG_LVL_ALL, - "Dest Ip Mask Address:0x%luX ", - st_dest_ip->ulIpv4Mask[i]); - } - } - u8IpAddressLen -= nSizeOfIPAddressInBytes; - } - if (u8IpAddressLen == 0) - pstClassifierEntry->bDestIpValid = TRUE; - - i++; - } - if (bIpVersion6) { - /* Restore EndianNess of Struct */ - restore_endianess_of_pstClassifierEntry( - pstClassifierEntry, - eIpAddrContext - ); - } - } -} - -void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool bFreeAll) -{ - int i; - struct bcm_targetdsx_buffer *curr_buf; - - for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) { - curr_buf = &Adapter->astTargetDsxBuffer[i]; - - if (curr_buf->valid) - continue; - - if ((bFreeAll) || (curr_buf->tid == TID)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", - TID, curr_buf->ulTargetDsxBuffer); - curr_buf->valid = 1; - curr_buf->tid = 0; - Adapter->ulFreeTargetBufferCnt++; - } - } -} - -/* - * @ingroup ctrl_pkt_functions - * copy classifier rule into the specified SF index - */ -static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, - struct bcm_convergence_types *psfCSType, - UINT uiSearchRuleIndex, - UINT nClassifierIndex) -{ - struct bcm_classifier_rule *pstClassifierEntry = NULL; - /* VOID *pvPhsContext = NULL; */ - int i; - /* UCHAR ucProtocolLength=0; */ - /* ULONG ulPhsStatus; */ - - struct bcm_packet_class_rules *pack_class_rule = - &psfCSType->cCPacketClassificationRule; - - if (Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 || - nClassifierIndex > (MAX_CLASSIFIERS-1)) - return; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Storing Classifier Rule Index : %X", - ntohs(pack_class_rule->u16PacketClassificationRuleIndex)); - - if (nClassifierIndex > MAX_CLASSIFIERS-1) - return; - - pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; - if (pstClassifierEntry) { - /* Store if Ipv6 */ - pstClassifierEntry->bIpv6Protocol = - (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false; - - /* Destinaiton Port */ - pstClassifierEntry->ucDestPortRangeLength = - pack_class_rule->u8ProtocolDestPortRangeLength / 4; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Destination Port Range Length:0x%X ", - pstClassifierEntry->ucDestPortRangeLength); - - if (pack_class_rule->u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) { - for (i = 0; i < (pstClassifierEntry->ucDestPortRangeLength); i++) { - pstClassifierEntry->usDestPortRangeLo[i] = - *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+i)); - pstClassifierEntry->usDestPortRangeHi[i] = - *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+2+i)); - pstClassifierEntry->usDestPortRangeLo[i] = - ntohs(pstClassifierEntry->usDestPortRangeLo[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - CONN_MSG, DBG_LVL_ALL, - "Destination Port Range Lo:0x%X ", - pstClassifierEntry->usDestPortRangeLo[i]); - pstClassifierEntry->usDestPortRangeHi[i] = - ntohs(pstClassifierEntry->usDestPortRangeHi[i]); - } - } else { - pstClassifierEntry->ucDestPortRangeLength = 0; - } - - /* Source Port */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Source Port Range Length:0x%X ", - pack_class_rule->u8ProtocolSourcePortRangeLength); - if (pack_class_rule->u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) { - pstClassifierEntry->ucSrcPortRangeLength = - pack_class_rule->u8ProtocolSourcePortRangeLength/4; - for (i = 0; i < (pstClassifierEntry->ucSrcPortRangeLength); i++) { - pstClassifierEntry->usSrcPortRangeLo[i] = - *((PUSHORT)(pack_class_rule-> - u8ProtocolSourcePortRange+i)); - pstClassifierEntry->usSrcPortRangeHi[i] = - *((PUSHORT)(pack_class_rule-> - u8ProtocolSourcePortRange+2+i)); - pstClassifierEntry->usSrcPortRangeLo[i] = - ntohs(pstClassifierEntry->usSrcPortRangeLo[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - CONN_MSG, DBG_LVL_ALL, - "Source Port Range Lo:0x%X ", - pstClassifierEntry->usSrcPortRangeLo[i]); - pstClassifierEntry->usSrcPortRangeHi[i] = - ntohs(pstClassifierEntry->usSrcPortRangeHi[i]); - } - } - /* Destination Ip Address and Mask */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Ip Destination Parameters : "); - CopyIpAddrToClassifier(pstClassifierEntry, - pack_class_rule->u8IPDestinationAddressLength, - pack_class_rule->u8IPDestinationAddress, - (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? - TRUE : false, eDestIpAddress); - - /* Source Ip Address and Mask */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Ip Source Parameters : "); - - CopyIpAddrToClassifier(pstClassifierEntry, - pack_class_rule->u8IPMaskedSourceAddressLength, - pack_class_rule->u8IPMaskedSourceAddress, - (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false, - eSrcIpAddress); - - /* TOS */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "TOS Length:0x%X ", - pack_class_rule->u8IPTypeOfServiceLength); - if (pack_class_rule->u8IPTypeOfServiceLength == 3) { - pstClassifierEntry->ucIPTypeOfServiceLength = - pack_class_rule->u8IPTypeOfServiceLength; - pstClassifierEntry->ucTosLow = - pack_class_rule->u8IPTypeOfService[0]; - pstClassifierEntry->ucTosHigh = - pack_class_rule->u8IPTypeOfService[1]; - pstClassifierEntry->ucTosMask = - pack_class_rule->u8IPTypeOfService[2]; - pstClassifierEntry->bTOSValid = TRUE; - } - if (pack_class_rule->u8Protocol == 0) { - /* we didn't get protocol field filled in by the BS */ - pstClassifierEntry->ucProtocolLength = 0; - } else { - pstClassifierEntry->ucProtocolLength = 1; /* 1 valid protocol */ - } - - pstClassifierEntry->ucProtocol[0] = pack_class_rule->u8Protocol; - pstClassifierEntry->u8ClassifierRulePriority = - pack_class_rule->u8ClassifierRulePriority; - - /* store the classifier rule ID and set this classifier entry as valid */ - pstClassifierEntry->ucDirection = - Adapter->PackInfo[uiSearchRuleIndex].ucDirection; - pstClassifierEntry->uiClassifierRuleIndex = - ntohs(pack_class_rule->u16PacketClassificationRuleIndex); - pstClassifierEntry->usVCID_Value = - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; - pstClassifierEntry->ulSFID = - Adapter->PackInfo[uiSearchRuleIndex].ulSFID; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", - uiSearchRuleIndex, - pstClassifierEntry->ucDirection, - pstClassifierEntry->uiClassifierRuleIndex, - pstClassifierEntry->usVCID_Value); - - if (pack_class_rule->u8AssociatedPHSI) - pstClassifierEntry->u8AssociatedPHSI = - pack_class_rule->u8AssociatedPHSI; - - /* Copy ETH CS Parameters */ - pstClassifierEntry->ucEthCSSrcMACLen = - (pack_class_rule->u8EthernetSourceMACAddressLength); - memcpy(pstClassifierEntry->au8EThCSSrcMAC, - pack_class_rule->u8EthernetSourceMACAddress, - MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSSrcMACMask, - pack_class_rule->u8EthernetSourceMACAddress - + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEthCSDestMACLen = - (pack_class_rule->u8EthernetDestMacAddressLength); - memcpy(pstClassifierEntry->au8EThCSDestMAC, - pack_class_rule->u8EthernetDestMacAddress, - MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSDestMACMask, - pack_class_rule->u8EthernetDestMacAddress - + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEtherTypeLen = - (pack_class_rule->u8EthertypeLength); - memcpy(pstClassifierEntry->au8EthCSEtherType, - pack_class_rule->u8Ethertype, - NUM_ETHERTYPE_BYTES); - memcpy(pstClassifierEntry->usUserPriority, - &pack_class_rule->u16UserPriority, 2); - pstClassifierEntry->usVLANID = - ntohs(pack_class_rule->u16VLANID); - pstClassifierEntry->usValidityBitMap = - ntohs(pack_class_rule->u16ValidityBitMap); - - pstClassifierEntry->bUsed = TRUE; - } -} - -/* - * @ingroup ctrl_pkt_functions - */ -static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, - UINT uiSearchRuleIndex, UINT nClassifierIndex) -{ - struct bcm_classifier_rule *pstClassifierEntry = NULL; - B_UINT16 u16PacketClassificationRuleIndex; - USHORT usVCID; - /* VOID *pvPhsContext = NULL; */ - /*ULONG ulPhsStatus; */ - - usVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; - - if (nClassifierIndex > MAX_CLASSIFIERS-1) - return; - - if (usVCID == 0) - return; - - u16PacketClassificationRuleIndex = - Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; - pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; - if (pstClassifierEntry) { - pstClassifierEntry->bUsed = false; - pstClassifierEntry->uiClassifierRuleIndex = 0; - memset(pstClassifierEntry, 0, - sizeof(struct bcm_classifier_rule)); - - /* Delete the PHS Rule for this classifier */ - PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, - u16PacketClassificationRuleIndex); - } -} - -/* - * @ingroup ctrl_pkt_functions - */ -VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, - UINT uiSearchRuleIndex) -{ - struct bcm_classifier_rule *pstClassifierEntry = NULL; - int i; - /* B_UINT16 u16PacketClassificationRuleIndex; */ - USHORT ulVCID; - /* VOID *pvPhsContext = NULL; */ - /* ULONG ulPhsStatus; */ - - ulVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; - - if (ulVCID == 0) - return; - - for (i = 0; i < MAX_CLASSIFIERS; i++) { - if (Adapter->astClassifierTable[i].usVCID_Value == ulVCID) { - pstClassifierEntry = &Adapter->astClassifierTable[i]; - - if (pstClassifierEntry->bUsed) - DeleteClassifierRuleFromSF(Adapter, - uiSearchRuleIndex, i); - } - } - - /* Delete All Phs Rules Associated with this SF */ - PhsDeleteSFRules(&Adapter->stBCMPhsContext, ulVCID); -} - -/* - * This routinue copies the Connection Management - * related data into the Adapter structure. - * @ingroup ctrl_pkt_functions - */ -static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* PackInfo[uiSearchRuleIndex]; - USHORT uVCID = curr_packinfo->usVCID_Value; - UINT UGIValue = 0; - - curr_packinfo->bValid = TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Search Rule Index = %d\n", uiSearchRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Updating Queue %d", uiSearchRuleIndex); - - ulSFID = ntohl(psfLocalSet->u32SFID); - /* Store IP Version used */ - /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ - - curr_packinfo->bIPCSSupport = 0; - curr_packinfo->bEthCSSupport = 0; - - /* Enable IP/ETh CS Support As Required */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "CopyToAdapter : u8CSSpecification : %X\n", - psfLocalSet->u8CSSpecification); - switch (psfLocalSet->u8CSSpecification) { - case eCSPacketIPV4: - curr_packinfo->bIPCSSupport = IPV4_CS; - break; - case eCSPacketIPV6: - curr_packinfo->bIPCSSupport = IPV6_CS; - break; - case eCS802_3PacketEthernet: - case eCS802_1QPacketVLAN: - curr_packinfo->bEthCSSupport = ETH_CS_802_3; - break; - case eCSPacketIPV4Over802_1QVLAN: - case eCSPacketIPV4Over802_3Ethernet: - curr_packinfo->bIPCSSupport = IPV4_CS; - curr_packinfo->bEthCSSupport = ETH_CS_802_3; - break; - case eCSPacketIPV6Over802_1QVLAN: - case eCSPacketIPV6Over802_3Ethernet: - curr_packinfo->bIPCSSupport = IPV6_CS; - curr_packinfo->bEthCSSupport = ETH_CS_802_3; - break; - default: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Error in value of CS Classification.. setting default to IP CS\n"); - curr_packinfo->bIPCSSupport = IPV4_CS; - break; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", - uiSearchRuleIndex, - curr_packinfo->bEthCSSupport, - curr_packinfo->bIPCSSupport); - - /* Store IP Version used */ - /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ - if (curr_packinfo->bIPCSSupport == IPV6_CS) - curr_packinfo->ucIpVersion = IPV6; - else - curr_packinfo->ucIpVersion = IPV4; - - /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */ - if (!Adapter->bETHCSEnabled) - curr_packinfo->bEthCSSupport = 0; - - if (psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32) - memcpy(curr_packinfo->ucServiceClassName, - psfLocalSet->u8ServiceClassName, - psfLocalSet->u8ServiceClassNameLength); - - curr_packinfo->u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; - - if (curr_packinfo->u8QueueType == BE && curr_packinfo->ucDirection) - Adapter->usBestEffortQueueIndex = uiSearchRuleIndex; - - curr_packinfo->ulSFID = ntohl(psfLocalSet->u32SFID); - - curr_packinfo->u8TrafficPriority = psfLocalSet->u8TrafficPriority; - - /* copy all the classifier in the Service Flow param structure */ - for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Classifier index =%d", i); - psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Classifier index =%d", i); - - if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) - curr_packinfo->bClassifierPriority = TRUE; - - if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) - curr_packinfo->bClassifierPriority = TRUE; - - if (ucDsxType == DSA_ACK) { - eClassifierAction = eAddClassifier; - } else if (ucDsxType == DSC_ACK) { - switch (psfCSType->u8ClassfierDSCAction) { - case 0: /* DSC Add Classifier */ - eClassifierAction = eAddClassifier; - break; - case 1: /* DSC Replace Classifier */ - eClassifierAction = eReplaceClassifier; - break; - case 2: /* DSC Delete Classifier */ - eClassifierAction = eDeleteClassifier; - break; - default: - eClassifierAction = eInvalidClassifierAction; - } - } - - u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); - - switch (eClassifierAction) { - case eAddClassifier: - /* Get a Free Classifier Index From Classifier table for this SF to add the Classifier */ - /* Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, - ulSFID, - u16PacketClassificationRuleIndex); - - if (nClassifierIndex > MAX_CLASSIFIERS) { - nClassifierIndex = SearchFreeClsid(Adapter); - if (nClassifierIndex > MAX_CLASSIFIERS) { - /* Failed To get a free Entry */ - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - CONN_MSG, - DBG_LVL_ALL, - "Error Failed To get a free Classifier Entry"); - break; - } - /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ - CopyClassifierRuleToSF(Adapter, psfCSType, - uiSearchRuleIndex, - nClassifierIndex); - } else { - /* This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - CONN_MSG, - DBG_LVL_ALL, - "CopyToAdapter: Error The Specified Classifier Already Exists and attempted To Add Classifier with Same PCRI : 0x%x\n", - u16PacketClassificationRuleIndex); - } - break; - case eReplaceClassifier: - /* Get the Classifier Index From Classifier table for this SF and replace existing Classifier */ - /* with the new classifier Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, ulSFID, - u16PacketClassificationRuleIndex); - if (nClassifierIndex > MAX_CLASSIFIERS) { - /* Failed To search the classifier */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - CONN_MSG, DBG_LVL_ALL, - "Error Search for Classifier To be replaced failed"); - break; - } - /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ - CopyClassifierRuleToSF(Adapter, psfCSType, - uiSearchRuleIndex, nClassifierIndex); - break; - case eDeleteClassifier: - /* Get the Classifier Index From Classifier table for this SF and replace existing Classifier */ - /* with the new classifier Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, ulSFID, - u16PacketClassificationRuleIndex); - if (nClassifierIndex > MAX_CLASSIFIERS) { - /* Failed To search the classifier */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - CONN_MSG, DBG_LVL_ALL, - "Error Search for Classifier To be deleted failed"); - break; - } - - /* Delete This classifier */ - DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, - nClassifierIndex); - break; - default: - /* Invalid Action for classifier */ - break; - } - } - - /* Repeat parsing Classification Entries to process PHS Rules */ - for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) { - psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "psfCSType->u8PhsDSCAction : 0x%x\n", - psfCSType->u8PhsDSCAction); - - switch (psfCSType->u8PhsDSCAction) { - case eDeleteAllPHSRules: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, - "Deleting All PHS Rules For VCID: 0x%X\n", - uVCID); - - /* Delete All the PHS rules for this Service flow */ - PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID); - break; - case eDeletePHSRule: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, - "PHS DSC Action = Delete PHS Rule\n"); - - if (psfCSType->cPhsRule.u8PHSI) - PhsDeletePHSRule(&Adapter->stBCMPhsContext, - uVCID, - psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); - - break; - default: - if (ucDsxType == DSC_ACK) { - /* BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC\n",psfCSType->cPhsRule.u8PHSI)); */ - break; /* FOr DSC ACK Case PHS DSC Action must be in valid set */ - } - /* Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified */ - /* No Break Here . Intentionally! */ - - case eAddPHSRule: - case eSetPHSRule: - if (psfCSType->cPhsRule.u8PHSI) { - /* Apply This PHS Rule to all classifiers whose Associated PHSI Match */ - apply_phs_rule_to_all_classifiers(Adapter, - uiSearchRuleIndex, - uVCID, - &sPhsRule, - &psfCSType->cPhsRule, - pstAddIndication); - } - break; - } - } - - if (psfLocalSet->u32MaxSustainedTrafficRate == 0) { - /* No Rate Limit . Set Max Sustained Traffic Rate to Maximum */ - curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; - } else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > WIMAX_MAX_ALLOWED_RATE) { - /* Too large Allowed Rate specified. Limiting to Wi Max Allowed rate */ - curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; - } else { - curr_packinfo->uiMaxAllowedRate = - ntohl(psfLocalSet->u32MaxSustainedTrafficRate); - } - - curr_packinfo->uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); - if (curr_packinfo->uiMaxLatency == 0) /* 0 should be treated as infinite */ - curr_packinfo->uiMaxLatency = MAX_LATENCY_ALLOWED; - - if ((curr_packinfo->u8QueueType == ERTPS || - curr_packinfo->u8QueueType == UGS)) - UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval); - - if (UGIValue == 0) - UGIValue = DEFAULT_UG_INTERVAL; - - /* - * For UGI based connections... - * DEFAULT_UGI_FACTOR*UGIInterval worth of data is the max token count at host... - * The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput... - * In case of non-UGI based connection, 200 frames worth of data is the max token count at host... - */ - curr_packinfo->uiMaxBucketSize = - (DEFAULT_UGI_FACTOR*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; - - if (curr_packinfo->uiMaxBucketSize < WIMAX_MAX_MTU*8) { - UINT UGIFactor = 0; - /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows: - * 1. Any packet from Host to FW can go out in different packet size. - * 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped. - * 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer - */ - UGIFactor = (curr_packinfo->uiMaxLatency/UGIValue + 1); - - if (UGIFactor > DEFAULT_UGI_FACTOR) - curr_packinfo->uiMaxBucketSize = - (UGIFactor*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; - - if (curr_packinfo->uiMaxBucketSize > WIMAX_MAX_MTU*8) - curr_packinfo->uiMaxBucketSize = WIMAX_MAX_MTU*8; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency, - UGIValue); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", - curr_packinfo->uiMaxAllowedRate, - ntohl(psfLocalSet->u32MaxSustainedTrafficRate), - curr_packinfo->uiMaxBucketSize); - - /* copy the extended SF Parameters to Support MIBS */ - CopyMIBSExtendedSFParameters(Adapter, psfLocalSet, uiSearchRuleIndex); - - /* store header suppression enabled flag per SF */ - curr_packinfo->bHeaderSuppressionEnabled = - !(psfLocalSet->u8RequesttransmissionPolicy & - MASK_DISABLE_HEADER_SUPPRESSION); - - kfree(curr_packinfo->pstSFIndication); - curr_packinfo->pstSFIndication = pstAddIndication; - - /* Re Sort the SF list in PackInfo according to Traffic Priority */ - SortPackInfo(Adapter); - - /* Re Sort the Classifier Rules table and re - arrange - * according to Classifier Rule Priority - */ - SortClassifiers(Adapter); - DumpPhsRules(&Adapter->stBCMPhsContext); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "%s <=====", __func__); -} - -/*********************************************************************** - * Function - DumpCmControlPacket - * - * Description - This routinue Dumps the Contents of the AddIndication - * Structure in the Connection Management Control Packet - * - * Parameter - pvBuffer: Pointer to the buffer containing the - * AddIndication data. - * - * Returns - None - *************************************************************************/ -static VOID DumpCmControlPacket(PVOID pvBuffer) -{ - int uiLoopIndex; - int nIndex; - struct bcm_add_indication_alt *pstAddIndication; - UINT nCurClassifierCnt; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - pstAddIndication = pvBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Type: 0x%X", pstAddIndication->u8Type); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Direction: 0x%X", pstAddIndication->u8Direction); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TID: 0x%X", ntohs(pstAddIndication->u16TID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", ntohs(pstAddIndication->u16CID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VCID: 0x%X", ntohs(pstAddIndication->u16VCID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " AuthorizedSet--->"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID: 0x%X", htonl(pstAddIndication->sfAuthorizedSet.u32SFID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", htons(pstAddIndication->sfAuthorizedSet.u16CID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength: 0x%X", - pstAddIndication->sfAuthorizedSet.u8ServiceClassNameLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName: 0x%X ,0x%X , 0x%X, 0x%X, 0x%X, 0x%X", - pstAddIndication->sfAuthorizedSet.u8ServiceClassName[0], - pstAddIndication->sfAuthorizedSet.u8ServiceClassName[1], - pstAddIndication->sfAuthorizedSet.u8ServiceClassName[2], - pstAddIndication->sfAuthorizedSet.u8ServiceClassName[3], - pstAddIndication->sfAuthorizedSet.u8ServiceClassName[4], - pstAddIndication->sfAuthorizedSet.u8ServiceClassName[5]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService: 0x%X", pstAddIndication->sfAuthorizedSet.u8MBSService); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet: 0x%X", pstAddIndication->sfAuthorizedSet.u8QosParamSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority: 0x%X, %p", - pstAddIndication->sfAuthorizedSet.u8TrafficPriority, &pstAddIndication->sfAuthorizedSet.u8TrafficPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxSustainedTrafficRate: 0x%X 0x%p", - pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate, - &pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst: 0x%X", pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", - pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength: 0x%X", - pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam: 0x%X", - pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParam[0]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType: 0x%X", - pstAddIndication->sfAuthorizedSet.u8ServiceFlowSchedulingType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter: 0x%X", pstAddIndication->sfAuthorizedSet.u32ToleratedJitter); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency: 0x%X", pstAddIndication->sfAuthorizedSet.u32MaximumLatency); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%X", - pstAddIndication->sfAuthorizedSet.u8FixedLengthVSVariableLengthSDUIndicator); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize: 0x%X", pstAddIndication->sfAuthorizedSet.u8SDUSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID: 0x%X", pstAddIndication->sfAuthorizedSet.u16TargetSAID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable: 0x%X", pstAddIndication->sfAuthorizedSet.u8ARQEnable); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQWindowSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRetryTxTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRetryRxTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQBlockLifeTime); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQSyncLossTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder: 0x%X", pstAddIndication->sfAuthorizedSet.u8ARQDeliverInOrder); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRxPurgeTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize: 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQBlockSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification: 0x%X", pstAddIndication->sfAuthorizedSet.u8CSSpecification); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService: 0x%X", - pstAddIndication->sfAuthorizedSet.u8TypeOfDataDeliveryService); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime: 0x%X", pstAddIndication->sfAuthorizedSet.u16SDUInterArrivalTime); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase: 0x%X", pstAddIndication->sfAuthorizedSet.u16TimeBase); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference: 0x%X", pstAddIndication->sfAuthorizedSet.u8PagingPreference); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval: 0x%X", - pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x %x %x ", - *(unsigned int *)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping, - *(unsigned int *)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[4], - *(USHORT *)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[8]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference: 0x%X", - pstAddIndication->sfAuthorizedSet.u8TrafficIndicationPreference); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Received: 0x%X", pstAddIndication->sfAuthorizedSet.u8TotalClassifiers); - - nCurClassifierCnt = pstAddIndication->sfAuthorizedSet.u8TotalClassifiers; - if (nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) - nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.bValid %d", pstAddIndication->sfAuthorizedSet.bValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.u16MacOverhead %x", pstAddIndication->sfAuthorizedSet.u16MacOverhead); - if (!pstAddIndication->sfAuthorizedSet.bValid) - pstAddIndication->sfAuthorizedSet.bValid = 1; - for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) { - struct bcm_convergence_types *psfCSType = NULL; - - psfCSType = &pstAddIndication->sfAuthorizedSet.cConvergenceSLTypes[nIndex]; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "psfCSType = %p", psfCSType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "CCPacketClassificationRuleSI====>"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); - - for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8Protocol); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); - - for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); - - for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32]: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength:0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM", - psfCSType->cCPacketClassificationRule. - u8EthernetDestMacAddress); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: %pM", - psfCSType->cCPacketClassificationRule. - u8EthernetSourceMACAddress); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8EthertypeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3]: 0x%02X ,0x%02X ,0x%02X ", - psfCSType->cCPacketClassificationRule.u8Ethertype[0], - psfCSType->cCPacketClassificationRule.u8Ethertype[1], - psfCSType->cCPacketClassificationRule.u8Ethertype[2]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority: 0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID: 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI: 0x%02X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex: 0x%X ", - psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1]: 0x%X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); -#ifdef VERSION_D5 - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8IPv6FlowLable[6]: 0x%*ph ", - 6, psfCSType->cCPacketClassificationRule. - u8IPv6FlowLable); -#endif - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid: 0x%02X", pstAddIndication->sfAuthorizedSet.bValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "AdmittedSet--->"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID: 0x%X", pstAddIndication->sfAdmittedSet.u32SFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", pstAddIndication->sfAdmittedSet.u16CID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength: 0x%X", - pstAddIndication->sfAdmittedSet.u8ServiceClassNameLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, - "u8ServiceClassName: 0x%*ph", - 6, pstAddIndication->sfAdmittedSet.u8ServiceClassName); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService: 0x%02X", pstAddIndication->sfAdmittedSet.u8MBSService); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet: 0x%02X", pstAddIndication->sfAdmittedSet.u8QosParamSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority: 0x%02X", pstAddIndication->sfAdmittedSet.u8TrafficPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst: 0x%X", pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate: 0x%X", - pstAddIndication->sfAdmittedSet.u32MinReservedTrafficRate); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength: 0x%02X", - pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam: 0x%02X", - pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParam[0]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType: 0x%02X", - pstAddIndication->sfAdmittedSet.u8ServiceFlowSchedulingType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter: 0x%X", pstAddIndication->sfAdmittedSet.u32ToleratedJitter); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency: 0x%X", pstAddIndication->sfAdmittedSet.u32MaximumLatency); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X", - pstAddIndication->sfAdmittedSet.u8FixedLengthVSVariableLengthSDUIndicator); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize: 0x%02X", pstAddIndication->sfAdmittedSet.u8SDUSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID: 0x%02X", pstAddIndication->sfAdmittedSet.u16TargetSAID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable: 0x%02X", pstAddIndication->sfAdmittedSet.u8ARQEnable); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQWindowSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRetryTxTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRetryRxTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQBlockLifeTime); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQSyncLossTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder: 0x%02X", pstAddIndication->sfAdmittedSet.u8ARQDeliverInOrder); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRxPurgeTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize: 0x%X", pstAddIndication->sfAdmittedSet.u16ARQBlockSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification: 0x%02X", pstAddIndication->sfAdmittedSet.u8CSSpecification); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService: 0x%02X", - pstAddIndication->sfAdmittedSet.u8TypeOfDataDeliveryService); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime: 0x%X", pstAddIndication->sfAdmittedSet.u16SDUInterArrivalTime); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase: 0x%X", pstAddIndication->sfAdmittedSet.u16TimeBase); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference: 0x%X", pstAddIndication->sfAdmittedSet.u8PagingPreference); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference: 0x%02X", - pstAddIndication->sfAdmittedSet.u8TrafficIndicationPreference); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Received: 0x%X", pstAddIndication->sfAdmittedSet.u8TotalClassifiers); - - nCurClassifierCnt = pstAddIndication->sfAdmittedSet.u8TotalClassifiers; - if (nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) - nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; - - for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) { - struct bcm_convergence_types *psfCSType = NULL; - - psfCSType = &pstAddIndication->sfAdmittedSet.cConvergenceSLTypes[nIndex]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength: 0x%02X", - psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8IPTypeOfService[3]: 0x%*ph", - 3, psfCSType->cCPacketClassificationRule. - u8IPTypeOfService); - for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", psfCSType->cCPacketClassificationRule.u8Protocol); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); - - for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); - - for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32]: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%*ph ", - 4, psfCSType->cCPacketClassificationRule. - u8ProtocolSourcePortRange); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%*ph ", - 4, psfCSType->cCPacketClassificationRule. - u8ProtocolDestPortRange); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM", - psfCSType->cCPacketClassificationRule. - u8EthernetDestMacAddress); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: %pM", - psfCSType->cCPacketClassificationRule. - u8EthernetSourceMACAddress); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8Ethertype[3]: 0x%*ph", - 3, psfCSType->cCPacketClassificationRule. - u8Ethertype); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority: 0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID: 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI: 0x%02X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex: 0x%X ", - psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength: 0x%02X", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1]: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); -#ifdef VERSION_D5 - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, "u8IPv6FlowLable[6]: 0x%*ph ", - 6, psfCSType->cCPacketClassificationRule. - u8IPv6FlowLable); -#endif - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid: 0x%X", pstAddIndication->sfAdmittedSet.bValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " ActiveSet--->"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID: 0x%X", pstAddIndication->sfActiveSet.u32SFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID: 0x%X", pstAddIndication->sfActiveSet.u16CID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength: 0x%X", pstAddIndication->sfActiveSet.u8ServiceClassNameLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, - "u8ServiceClassName: 0x%*ph", - 6, pstAddIndication->sfActiveSet.u8ServiceClassName); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService: 0x%02X", pstAddIndication->sfActiveSet.u8MBSService); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet: 0x%02X", pstAddIndication->sfActiveSet.u8QosParamSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority: 0x%02X", pstAddIndication->sfActiveSet.u8TrafficPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst: 0x%X", pstAddIndication->sfActiveSet.u32MaxTrafficBurst); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate: 0x%X", - pstAddIndication->sfActiveSet.u32MinReservedTrafficRate); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength: 0x%02X", - pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam: 0x%02X", - pstAddIndication->sfActiveSet.u8VendorSpecificQoSParam[0]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType: 0x%02X", - pstAddIndication->sfActiveSet.u8ServiceFlowSchedulingType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter: 0x%X", pstAddIndication->sfActiveSet.u32ToleratedJitter); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency: 0x%X", pstAddIndication->sfActiveSet.u32MaximumLatency); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X", - pstAddIndication->sfActiveSet.u8FixedLengthVSVariableLengthSDUIndicator); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize: 0x%X", pstAddIndication->sfActiveSet.u8SDUSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TargetSAID: 0x%X", pstAddIndication->sfActiveSet.u16TargetSAID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQEnable: 0x%X", pstAddIndication->sfActiveSet.u8ARQEnable); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQWindowSize: 0x%X", pstAddIndication->sfActiveSet.u16ARQWindowSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryTxTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQRetryTxTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryRxTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQRetryRxTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockLifeTime: 0x%X", pstAddIndication->sfActiveSet.u16ARQBlockLifeTime); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQSyncLossTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQSyncLossTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQDeliverInOrder: 0x%X", pstAddIndication->sfActiveSet.u8ARQDeliverInOrder); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRxPurgeTimeOut: 0x%X", pstAddIndication->sfActiveSet.u16ARQRxPurgeTimeOut); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockSize: 0x%X", pstAddIndication->sfActiveSet.u16ARQBlockSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8CSSpecification: 0x%X", pstAddIndication->sfActiveSet.u8CSSpecification); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TypeOfDataDeliveryService: 0x%X", - pstAddIndication->sfActiveSet.u8TypeOfDataDeliveryService); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16SDUInterArrivalTime: 0x%X", pstAddIndication->sfActiveSet.u16SDUInterArrivalTime); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TimeBase: 0x%X", pstAddIndication->sfActiveSet.u16TimeBase); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference: 0x%X", pstAddIndication->sfActiveSet.u8PagingPreference); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference: 0x%X", - pstAddIndication->sfActiveSet.u8TrafficIndicationPreference); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Received: 0x%X", pstAddIndication->sfActiveSet.u8TotalClassifiers); - - nCurClassifierCnt = pstAddIndication->sfActiveSet.u8TotalClassifiers; - if (nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) - nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; - - for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) { - struct bcm_convergence_types *psfCSType = NULL; - struct bcm_packet_class_rules *clsRule = NULL; - - psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; - clsRule = &psfCSType->cCPacketClassificationRule; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ", - clsRule->u8ClassifierRulePriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ", - clsRule->u8IPTypeOfServiceLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", - clsRule->u8IPTypeOfService[0], - clsRule->u8IPTypeOfService[1], - clsRule->u8IPTypeOfService[2]); - - for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8Protocol: 0x%X ", - clsRule->u8Protocol); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - "u8IPMaskedSourceAddressLength: 0x%X ", - clsRule->u8IPMaskedSourceAddressLength); - - for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - "u8IPMaskedSourceAddress[32]: 0x%X ", - clsRule->u8IPMaskedSourceAddress[uiLoopIndex]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - "u8IPDestinationAddressLength: 0x%02X ", - clsRule->u8IPDestinationAddressLength); - - for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8IPDestinationAddress[32]:0x%X ", - clsRule->u8IPDestinationAddress[uiLoopIndex]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8ProtocolSourcePortRangeLength: 0x%X ", - clsRule->u8ProtocolSourcePortRangeLength); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", - clsRule->u8ProtocolSourcePortRange[0], - clsRule->u8ProtocolSourcePortRange[1], - clsRule->u8ProtocolSourcePortRange[2], - clsRule->u8ProtocolSourcePortRange[3]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8ProtocolDestPortRangeLength: 0x%X ", - clsRule->u8ProtocolDestPortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", - clsRule->u8ProtocolDestPortRange[0], - clsRule->u8ProtocolDestPortRange[1], - clsRule->u8ProtocolDestPortRange[2], - clsRule->u8ProtocolDestPortRange[3]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8EthernetDestMacAddressLength: 0x%X ", - clsRule->u8EthernetDestMacAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", - clsRule->u8EthernetDestMacAddress[0], - clsRule->u8EthernetDestMacAddress[1], - clsRule->u8EthernetDestMacAddress[2], - clsRule->u8EthernetDestMacAddress[3], - clsRule->u8EthernetDestMacAddress[4], - clsRule->u8EthernetDestMacAddress[5]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8EthernetSourceMACAddressLength: 0x%X ", - clsRule->u8EthernetDestMacAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", - clsRule->u8EthernetSourceMACAddress[0], - clsRule->u8EthernetSourceMACAddress[1], - clsRule->u8EthernetSourceMACAddress[2], - clsRule->u8EthernetSourceMACAddress[3], - clsRule->u8EthernetSourceMACAddress[4], - clsRule->u8EthernetSourceMACAddress[5]); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u8EthertypeLength: 0x%X ", - clsRule->u8EthertypeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ", - clsRule->u8Ethertype[0], - clsRule->u8Ethertype[1], - clsRule->u8Ethertype[2]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u16UserPriority: 0x%X ", - clsRule->u16UserPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u16VLANID: 0x%X ", - clsRule->u16VLANID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", - clsRule->u8AssociatedPHSI); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u16PacketClassificationRuleIndex:0x%X ", - clsRule->u16PacketClassificationRuleIndex); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8VendorSpecificClassifierParamLength:0x%X ", - clsRule->u8VendorSpecificClassifierParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8VendorSpecificClassifierParam[1]:0x%X ", - clsRule->u8VendorSpecificClassifierParam[0]); -#ifdef VERSION_D5 - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ", - clsRule->u8IPv6FlowLableLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, - DBG_LVL_ALL, - " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", - clsRule->u8IPv6FlowLable[0], - clsRule->u8IPv6FlowLable[1], - clsRule->u8IPv6FlowLable[2], - clsRule->u8IPv6FlowLable[3], - clsRule->u8IPv6FlowLable[4], - clsRule->u8IPv6FlowLable[5]); -#endif - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, - " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid); -} - -static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, - ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer) -{ - UINT nBytesToRead = sizeof(struct bcm_connect_mgr_params); - - if (ulAddrSFParamSet == 0 || NULL == pucDestBuffer) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Got Param address as 0!!"); - return 0; - } - ulAddrSFParamSet = ntohl(ulAddrSFParamSet); - - /* Read out the SF Param Set At the indicated Location */ - if (rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0) - return STATUS_FAILURE; - - return 1; -} - -static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, - ULONG ulAddrSFParamSet) -{ - UINT nBytesToWrite = sizeof(struct bcm_connect_mgr_params); - int ret = 0; - - if (ulAddrSFParamSet == 0 || NULL == pucSrcBuffer) - return 0; - - ret = wrm(Adapter, ulAddrSFParamSet, (u8 *)pucSrcBuffer, nBytesToWrite); - if (ret < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "%s:%d WRM failed", __func__, __LINE__); - return ret; - } - return 1; -} - -ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, - PVOID pvBuffer, UINT *puBufferLength) -{ - struct bcm_add_indication_alt *pstAddIndicationAlt = NULL; - struct bcm_add_indication *pstAddIndication = NULL; - struct bcm_del_request *pstDeletionRequest; - UINT uiSearchRuleIndex; - ULONG ulSFID; - - pstAddIndicationAlt = pvBuffer; - - /* - * In case of DSD Req By MS, we should immediately delete this SF so that - * we can stop the further classifying the pkt for this SF. - */ - if (pstAddIndicationAlt->u8Type == DSD_REQ) { - pstDeletionRequest = pvBuffer; - - ulSFID = ntohl(pstDeletionRequest->u32SFID); - uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); - - if (uiSearchRuleIndex < NO_OF_QUEUES) { - deleteSFBySfid(Adapter, uiSearchRuleIndex); - Adapter->u32TotalDSD++; - } - return 1; - } - - if ((pstAddIndicationAlt->u8Type == DSD_RSP) || - (pstAddIndicationAlt->u8Type == DSD_ACK)) { - /* No Special handling send the message as it is */ - return 1; - } - /* For DSA_REQ, only up to "psfAuthorizedSet" parameter should be accessed by driver! */ - - pstAddIndication = kmalloc(sizeof(struct bcm_add_indication), - GFP_KERNEL); - if (pstAddIndication == NULL) - return 0; - - /* AUTHORIZED SET */ - pstAddIndication->psfAuthorizedSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, - pstAddIndicationAlt->u16TID); - if (!pstAddIndication->psfAuthorizedSet) { - kfree(pstAddIndication); - return 0; - } - - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet, - (ULONG)pstAddIndication->psfAuthorizedSet) != 1) { - kfree(pstAddIndication); - return 0; - } - - /* this can't possibly be right */ - pstAddIndication->psfAuthorizedSet = - (struct bcm_connect_mgr_params *) ntohl( - (ULONG)pstAddIndication->psfAuthorizedSet); - - if (pstAddIndicationAlt->u8Type == DSA_REQ) { - struct bcm_add_request AddRequest; - - AddRequest.u8Type = pstAddIndicationAlt->u8Type; - AddRequest.eConnectionDir = pstAddIndicationAlt->u8Direction; - AddRequest.u16TID = pstAddIndicationAlt->u16TID; - AddRequest.u16CID = pstAddIndicationAlt->u16CID; - AddRequest.u16VCID = pstAddIndicationAlt->u16VCID; - AddRequest.psfParameterSet = pstAddIndication->psfAuthorizedSet; - (*puBufferLength) = sizeof(struct bcm_add_request); - memcpy(pvBuffer, &AddRequest, sizeof(struct bcm_add_request)); - kfree(pstAddIndication); - return 1; - } - - /* Since it's not DSA_REQ, we can access all field in pstAddIndicationAlt */ - /* We need to extract the structure from the buffer and pack it differently */ - - pstAddIndication->u8Type = pstAddIndicationAlt->u8Type; - pstAddIndication->eConnectionDir = pstAddIndicationAlt->u8Direction; - pstAddIndication->u16TID = pstAddIndicationAlt->u16TID; - pstAddIndication->u16CID = pstAddIndicationAlt->u16CID; - pstAddIndication->u16VCID = pstAddIndicationAlt->u16VCID; - pstAddIndication->u8CC = pstAddIndicationAlt->u8CC; - - /* ADMITTED SET */ - pstAddIndication->psfAdmittedSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, - pstAddIndicationAlt->u16TID); - if (!pstAddIndication->psfAdmittedSet) { - kfree(pstAddIndication); - return 0; - } - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, - (ULONG)pstAddIndication->psfAdmittedSet) != 1) { - kfree(pstAddIndication); - return 0; - } - - pstAddIndication->psfAdmittedSet = - (struct bcm_connect_mgr_params *) ntohl( - (ULONG) pstAddIndication->psfAdmittedSet); - - /* ACTIVE SET */ - pstAddIndication->psfActiveSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, - pstAddIndicationAlt->u16TID); - if (!pstAddIndication->psfActiveSet) { - kfree(pstAddIndication); - return 0; - } - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, - (ULONG)pstAddIndication->psfActiveSet) != 1) { - kfree(pstAddIndication); - return 0; - } - - pstAddIndication->psfActiveSet = - (struct bcm_connect_mgr_params *) ntohl( - (ULONG)pstAddIndication->psfActiveSet); - - (*puBufferLength) = sizeof(struct bcm_add_indication); - *(struct bcm_add_indication *)pvBuffer = *pstAddIndication; - kfree(pstAddIndication); - return 1; -} - -static inline struct bcm_add_indication_alt -*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, - register PVOID pvBuffer) -{ - ULONG ulStatus = 0; - struct bcm_add_indication *pstAddIndication = NULL; - struct bcm_add_indication_alt *pstAddIndicationDest = NULL; - - pstAddIndication = pvBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "=====>"); - if ((pstAddIndication->u8Type == DSD_REQ) || - (pstAddIndication->u8Type == DSD_RSP) || - (pstAddIndication->u8Type == DSD_ACK)) - return pvBuffer; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Inside RestoreCmControlResponseMessage "); - /* - * Need to Allocate memory to contain the SUPER Large structures - * Our driver can't create these structures on Stack :( - */ - pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), - GFP_KERNEL); - - if (pstAddIndicationDest) { - memset(pstAddIndicationDest, 0, - sizeof(struct bcm_add_indication_alt)); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, - "Failed to allocate memory for SF Add Indication Structure "); - return NULL; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-u8Type : 0x%X", - pstAddIndication->u8Type); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-u8Direction : 0x%X", - pstAddIndication->eConnectionDir); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-u8TID : 0x%X", - ntohs(pstAddIndication->u16TID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-u8CID : 0x%X", - ntohs(pstAddIndication->u16CID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-u16VCID : 0x%X", - ntohs(pstAddIndication->u16VCID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-autorized set loc : %p", - pstAddIndication->psfAuthorizedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-admitted set loc : %p", - pstAddIndication->psfAdmittedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "AddIndication-Active set loc : %p", - pstAddIndication->psfActiveSet); - - pstAddIndicationDest->u8Type = pstAddIndication->u8Type; - pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir; - pstAddIndicationDest->u16TID = pstAddIndication->u16TID; - pstAddIndicationDest->u16CID = pstAddIndication->u16CID; - pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID; - pstAddIndicationDest->u8CC = pstAddIndication->u8CC; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Restoring Active Set "); - ulStatus = RestoreSFParam(Adapter, - (ULONG)pstAddIndication->psfActiveSet, - (PUCHAR)&pstAddIndicationDest->sfActiveSet); - if (ulStatus != 1) - goto failed_restore_sf_param; - - if (pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = - MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Restoring Admitted Set "); - ulStatus = RestoreSFParam(Adapter, - (ULONG)pstAddIndication->psfAdmittedSet, - (PUCHAR)&pstAddIndicationDest->sfAdmittedSet); - if (ulStatus != 1) - goto failed_restore_sf_param; - - if (pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = - MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Restoring Authorized Set "); - ulStatus = RestoreSFParam(Adapter, - (ULONG)pstAddIndication->psfAuthorizedSet, - (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); - if (ulStatus != 1) - goto failed_restore_sf_param; - - if (pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = - MAX_CLASSIFIERS_IN_SF; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Dumping the whole raw packet"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "============================================================"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - " pstAddIndicationDest->sfActiveSet size %zx %p", - sizeof(*pstAddIndicationDest), pstAddIndicationDest); - /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, - * DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, - * sizeof(*pstAddIndicationDest)); - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "============================================================"); - return pstAddIndicationDest; -failed_restore_sf_param: - kfree(pstAddIndicationDest); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "<====="); - return NULL; -} - -ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter) -{ - ULONG ulTargetDsxBuffersBase = 0; - ULONG ulCntTargetBuffers; - ULONG i; - int Status; - - if (!Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Adapter was NULL!!!"); - return 0; - } - - if (Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer) - return 1; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", - sizeof(struct bcm_connect_mgr_params)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Reading DSX buffer From Target location %x ", - DSX_MESSAGE_EXCHANGE_BUFFER); - - Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, - (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); - if (Status < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "RDM failed!!"); - return 0; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Base Address Of DSX Target Buffer : 0x%lx", - ulTargetDsxBuffersBase); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); - ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / - sizeof(struct bcm_connect_mgr_params); - - Adapter->ulTotalTargetBuffersAvailable = - ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ? - MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - " Total Target DSX Buffer setup %lx ", - Adapter->ulTotalTargetBuffersAvailable); - - for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) { - Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer = ulTargetDsxBuffersBase; - Adapter->astTargetDsxBuffer[i].valid = 1; - Adapter->astTargetDsxBuffer[i].tid = 0; - ulTargetDsxBuffersBase += sizeof(struct bcm_connect_mgr_params); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Target DSX Buffer %lx setup at 0x%lx", - i, Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer); - } - Adapter->ulCurrentTargetBuffer = 0; - Adapter->ulFreeTargetBufferCnt = Adapter->ulTotalTargetBuffersAvailable; - return 1; -} - -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, - B_UINT16 tid) -{ - ULONG dsx_buf; - ULONG idx, max_try; - - if ((Adapter->ulTotalTargetBuffersAvailable == 0) - || (Adapter->ulFreeTargetBufferCnt == 0)) { - ClearTargetDSXBuffer(Adapter, tid, false); - return 0; - } - - idx = Adapter->ulCurrentTargetBuffer; - max_try = Adapter->ulTotalTargetBuffersAvailable; - while ((max_try) && (Adapter->astTargetDsxBuffer[idx].valid != 1)) { - idx = (idx+1) % Adapter->ulTotalTargetBuffersAvailable; - max_try--; - } - - if (max_try == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", - Adapter->ulFreeTargetBufferCnt); - ClearTargetDSXBuffer(Adapter, tid, false); - return 0; - } - - dsx_buf = Adapter->astTargetDsxBuffer[idx].ulTargetDsxBuffer; - Adapter->astTargetDsxBuffer[idx].valid = 0; - Adapter->astTargetDsxBuffer[idx].tid = tid; - Adapter->ulFreeTargetBufferCnt--; - idx = (idx+1)%Adapter->ulTotalTargetBuffersAvailable; - Adapter->ulCurrentTargetBuffer = idx; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "GetNextTargetBufferLocation :Returning address %lx tid %d\n", - dsx_buf, tid); - - return dsx_buf; -} - -int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter) -{ - /* - * Need to Allocate memory to contain the SUPER Large structures - * Our driver can't create these structures on Stack - */ - Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt) - + LEADER_SIZE, GFP_KERNEL); - if (!Adapter->caDsxReqResp) - return -ENOMEM; - - return 0; -} - -int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter) -{ - kfree(Adapter->caDsxReqResp); - return 0; -} - -/* - * @ingroup ctrl_pkt_functions - * This routinue would process the Control responses - * for the Connection Management. - * @return - Queue index for the free SFID else returns Invalid Index. - */ -bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* u16TID, false); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Error in restoring Service Flow param structure from DSx message"); - return false; - } - - DumpCmControlPacket(pstAddIndication); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>"); - pLeader = (struct bcm_leader *)Adapter->caDsxReqResp; - - pLeader->Status = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ; - pLeader->Vcid = 0; - - ClearTargetDSXBuffer(Adapter, pstAddIndication->u16TID, false); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n", pstAddIndication->u16TID); - switch (pstAddIndication->u8Type) { - case DSA_REQ: - pLeader->PLength = sizeof(struct bcm_add_indication_alt); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength); - *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) - = *pstAddIndication; - ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID)); - CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); - kfree(pstAddIndication); - break; - case DSA_RSP: - pLeader->PLength = sizeof(struct bcm_add_indication_alt); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d", - pLeader->PLength); - *((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE])) - = *pstAddIndication; - ((struct bcm_add_indication_alt *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; - /* FALLTHROUGH */ - case DSA_ACK: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X", - ntohs(pstAddIndication->u16VCID)); - uiSearchRuleIndex = SearchFreeSfid(Adapter); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "uiSearchRuleIndex:0x%X ", - uiSearchRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Direction:0x%X ", - pstAddIndication->u8Direction); - if (uiSearchRuleIndex < NO_OF_QUEUES) { - Adapter->PackInfo[uiSearchRuleIndex].ucDirection = - pstAddIndication->u8Direction; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "bValid:0x%X ", - pstAddIndication->sfActiveSet.bValid); - if (pstAddIndication->sfActiveSet.bValid == TRUE) - Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE; - - if (pstAddIndication->sfAuthorizedSet.bValid == TRUE) - Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet = TRUE; - - if (pstAddIndication->sfAdmittedSet.bValid == TRUE) - Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE; - - if (pstAddIndication->sfActiveSet.bValid == false) { - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; - Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = false; - if (pstAddIndication->sfAdmittedSet.bValid) - psfLocalSet = &pstAddIndication->sfAdmittedSet; - else if (pstAddIndication->sfAuthorizedSet.bValid) - psfLocalSet = &pstAddIndication->sfAuthorizedSet; - } else { - psfLocalSet = &pstAddIndication->sfActiveSet; - Adapter->PackInfo[uiSearchRuleIndex].bActive = TRUE; - } - - if (!psfLocalSet) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No set is valid\n"); - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; - Adapter->PackInfo[uiSearchRuleIndex].bValid = false; - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; - kfree(pstAddIndication); - } else if (psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSA ACK"); - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstAddIndication->u16VCID); - Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pstAddIndication->u16CID); - - if (UPLINK_DIR == pstAddIndication->u8Direction) - atomic_set(&Adapter->PackInfo[uiSearchRuleIndex].uiPerSFTxResourceCount, DEFAULT_PERSFCOUNT); - - CopyToAdapter(Adapter, psfLocalSet, uiSearchRuleIndex, DSA_ACK, pstAddIndication); - /* don't free pstAddIndication */ - - /* Inside CopyToAdapter, Sorting of all the SFs take place. - * Hence any access to the newly added SF through uiSearchRuleIndex is invalid. - * SHOULD BE STRICTLY AVOIDED. - */ - /* *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID; */ - memcpy((((PUCHAR)pvBuffer)+1), &psfLocalSet->u32SFID, 4); - - if (pstAddIndication->sfActiveSet.bValid == TRUE) { - if (UPLINK_DIR == pstAddIndication->u8Direction) { - if (!Adapter->LinkUpStatus) { - netif_carrier_on(Adapter->dev); - netif_start_queue(Adapter->dev); - Adapter->LinkUpStatus = 1; - if (netif_msg_link(Adapter)) - pr_info(PFX "%s: link up\n", Adapter->dev->name); - atomic_set(&Adapter->TxPktAvail, 1); - wake_up(&Adapter->tx_packet_wait_queue); - Adapter->liTimeSinceLastNetEntry = get_seconds(); - } - } - } - } else { - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; - Adapter->PackInfo[uiSearchRuleIndex].bValid = false; - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; - kfree(pstAddIndication); - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID"); - kfree(pstAddIndication); - return false; - } - break; - case DSC_REQ: - pLeader->PLength = sizeof(struct bcm_change_indication); - pstChangeIndication = (struct bcm_change_indication *)pstAddIndication; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength); - - *((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; - ((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; - - CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); - kfree(pstAddIndication); - break; - case DSC_RSP: - pLeader->PLength = sizeof(struct bcm_change_indication); - pstChangeIndication = (struct bcm_change_indication *)pstAddIndication; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength); - *((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; - ((struct bcm_change_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK; - /* FALLTHROUGH */ - case DSC_ACK: - pstChangeIndication = (struct bcm_change_indication *)pstAddIndication; - uiSearchRuleIndex = SearchSfid(Adapter, ntohl(pstChangeIndication->sfActiveSet.u32SFID)); - if (uiSearchRuleIndex > NO_OF_QUEUES-1) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received"); - - if (uiSearchRuleIndex < NO_OF_QUEUES) { - Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction; - if (pstChangeIndication->sfActiveSet.bValid == TRUE) - Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE; - - if (pstChangeIndication->sfAuthorizedSet.bValid == TRUE) - Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet = TRUE; - - if (pstChangeIndication->sfAdmittedSet.bValid == TRUE) - Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE; - - if (pstChangeIndication->sfActiveSet.bValid == false) { - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; - Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = false; - - if (pstChangeIndication->sfAdmittedSet.bValid) - psfLocalSet = &pstChangeIndication->sfAdmittedSet; - else if (pstChangeIndication->sfAuthorizedSet.bValid) - psfLocalSet = &pstChangeIndication->sfAuthorizedSet; - } else { - psfLocalSet = &pstChangeIndication->sfActiveSet; - Adapter->PackInfo[uiSearchRuleIndex].bActive = TRUE; - } - - if (!psfLocalSet) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No set is valid\n"); - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; - Adapter->PackInfo[uiSearchRuleIndex].bValid = false; - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = 0; - kfree(pstAddIndication); - } else if (psfLocalSet->bValid && (pstChangeIndication->u8CC == 0)) { - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstChangeIndication->u16VCID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "CC field is %d bvalid = %d\n", - pstChangeIndication->u8CC, psfLocalSet->bValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "VCID= %d\n", ntohs(pstChangeIndication->u16VCID)); - Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pstChangeIndication->u16CID); - CopyToAdapter(Adapter, psfLocalSet, uiSearchRuleIndex, DSC_ACK, pstAddIndication); - - *(PULONG)(((PUCHAR)pvBuffer)+1) = psfLocalSet->u32SFID; - } else if (pstChangeIndication->u8CC == 6) { - deleteSFBySfid(Adapter, uiSearchRuleIndex); - kfree(pstAddIndication); - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID"); - kfree(pstAddIndication); - return false; - } - break; - case DSD_REQ: - pLeader->PLength = sizeof(struct bcm_del_indication); - *((struct bcm_del_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *((struct bcm_del_indication *)pstAddIndication); - - ulSFID = ntohl(((struct bcm_del_indication *)pstAddIndication)->u32SFID); - uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD - Removing connection %x", uiSearchRuleIndex); - - if (uiSearchRuleIndex < NO_OF_QUEUES) { - /* Delete All Classifiers Associated with this SFID */ - deleteSFBySfid(Adapter, uiSearchRuleIndex); - Adapter->u32TotalDSD++; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSD RESPONSE TO MAC"); - ((struct bcm_del_indication *)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSD_RSP; - CopyBufferToControlPacket(Adapter, (PVOID)Adapter->caDsxReqResp); - /* FALLTHROUGH */ - case DSD_RSP: - /* Do nothing as SF has already got Deleted */ - break; - case DSD_ACK: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n"); - break; - default: - kfree(pstAddIndication); - return false; - } - return TRUE; -} - -int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, - UINT uiSFId, void __user *user_buffer) -{ - int status = 0; - struct bcm_packet_info *psSfInfo = NULL; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "status =%d", status); - status = SearchSfid(Adapter, uiSFId); - if (status >= NO_OF_QUEUES) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "SFID %d not present in queue !!!", uiSFId); - return -EINVAL; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "status =%d", status); - psSfInfo = &Adapter->PackInfo[status]; - if (psSfInfo->pstSFIndication - && copy_to_user(user_buffer, psSfInfo->pstSFIndication, - sizeof(struct bcm_add_indication_alt))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "copy to user failed SFID %d, present in queue !!!", - uiSFId); - status = -EFAULT; - return status; - } - return STATUS_SUCCESS; -} - -VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, - PUINT puiBuffer) -{ - B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1)); - struct bcm_stim_sfhostnotify *pHostInfo = NULL; - UINT uiSearchRuleIndex = 0; - ULONG ulSFID = 0; - - puiBuffer += 2; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg); - - while (u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) { - u32NumofSFsinMsg--; - pHostInfo = (struct bcm_stim_sfhostnotify *)puiBuffer; - puiBuffer = (PUINT)(pHostInfo + 1); - - ulSFID = ntohl(pHostInfo->SFID); - uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "SFID: 0x%lx\n", ulSFID); - - if (uiSearchRuleIndex >= NO_OF_QUEUES - || uiSearchRuleIndex == HiPriority) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, - "The SFID <%lx> doesn't exist in host entry or is Invalid\n", - ulSFID); - continue; - } - - if (pHostInfo->RetainSF == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, "Going to Delete SF"); - deleteSFBySfid(Adapter, uiSearchRuleIndex); - } else { - struct bcm_packet_info *packinfo = - &Adapter->PackInfo[uiSearchRuleIndex]; - - packinfo->usVCID_Value = ntohs(pHostInfo->VCID); - packinfo->usCID = ntohs(pHostInfo->newCID); - packinfo->bActive = false; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, - "pHostInfo->QoSParamSet: 0x%x\n", - pHostInfo->QoSParamSet); - - if (pHostInfo->QoSParamSet & 0x1) - packinfo->bAuthorizedSet = TRUE; - if (pHostInfo->QoSParamSet & 0x2) - packinfo->bAdmittedSet = TRUE; - if (pHostInfo->QoSParamSet & 0x4) { - packinfo->bActiveSet = TRUE; - packinfo->bActive = TRUE; - } - } - } -} - -static void restore_endianess_of_pstClassifierEntry( - struct bcm_classifier_rule *pstClassifierEntry, - enum bcm_ipaddr_context eIpAddrContext) -{ - int i; - union u_ip_address *stSrc = &pstClassifierEntry->stSrcIpAddress; - union u_ip_address *stDest = &pstClassifierEntry->stDestIpAddress; - - for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) { - if (eIpAddrContext == eSrcIpAddress) { - stSrc->ulIpv6Addr[i] = ntohl(stSrc->ulIpv6Addr[i]); - stSrc->ulIpv6Mask[i] = ntohl(stSrc->ulIpv6Mask[i]); - } else if (eIpAddrContext == eDestIpAddress) { - stDest->ulIpv6Addr[i] = ntohl(stDest->ulIpv6Addr[i]); - stDest->ulIpv6Mask[i] = ntohl(stDest->ulIpv6Mask[i]); - } - } -} - -static void apply_phs_rule_to_all_classifiers( - register struct bcm_mini_adapter *Adapter, /* u8Direction == UPLINK_DIR) { - for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) { - curr_classifier = - &Adapter->astClassifierTable[uiClassifierIndex]; - if ((curr_classifier->bUsed) && - (curr_classifier->ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && - (curr_classifier->u8AssociatedPHSI == cPhsRule->u8PHSI)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n", - curr_classifier->uiClassifierRuleIndex, - cPhsRule->u8PHSI); - /* Update The PHS Rule for this classifier as Associated PHSI id defined */ - - /* Copy the PHS Rule */ - sPhsRule->u8PHSI = cPhsRule->u8PHSI; - sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength; - sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength; - sPhsRule->u8PHSS = cPhsRule->u8PHSS; - sPhsRule->u8PHSV = cPhsRule->u8PHSV; - memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS); - memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS); - sPhsRule->u8RefCnt = 0; - sPhsRule->bUnclassifiedPHSRule = false; - sPhsRule->PHSModifiedBytes = 0; - sPhsRule->PHSModifiedNumPackets = 0; - sPhsRule->PHSErrorNumPackets = 0; - - /* bPHSRuleAssociated = TRUE; */ - /* Store The PHS Rule for this classifier */ - - PhsUpdateClassifierRule( - &Adapter->stBCMPhsContext, - uVCID, - curr_classifier->uiClassifierRuleIndex, - sPhsRule, - curr_classifier->u8AssociatedPHSI); - - /* Update PHS Rule For the Classifier */ - if (sPhsRule->u8PHSI) { - curr_classifier->u32PHSRuleID = sPhsRule->u8PHSI; - memcpy(&curr_classifier->sPhsRule, sPhsRule, sizeof(struct bcm_phs_rule)); - } - } - } - } else { - /* Error PHS Rule specified in signaling could not be applied to any classifier */ - - /* Copy the PHS Rule */ - sPhsRule->u8PHSI = cPhsRule->u8PHSI; - sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength; - sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength; - sPhsRule->u8PHSS = cPhsRule->u8PHSS; - sPhsRule->u8PHSV = cPhsRule->u8PHSV; - memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS); - memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS); - sPhsRule->u8RefCnt = 0; - sPhsRule->bUnclassifiedPHSRule = TRUE; - sPhsRule->PHSModifiedBytes = 0; - sPhsRule->PHSModifiedNumPackets = 0; - sPhsRule->PHSErrorNumPackets = 0; - /* Store The PHS Rule for this classifier */ - - /* - * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, - * clsid will be zero hence we can't have multiple PHS rules for the same SF. - * To support multiple PHS rule, passing u8PHSI. - */ - PhsUpdateClassifierRule( - &Adapter->stBCMPhsContext, - uVCID, - sPhsRule->u8PHSI, - sPhsRule, - sPhsRule->u8PHSI); - } -} diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h deleted file mode 100644 index 0887d3f49e2f..000000000000 --- a/drivers/staging/bcm/CmHost.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * (c) Beceem Communications Inc. - * All Rights Reserved - * - * file : CmHost.h - * author: Rajeev Tirumala - * date : September 8 , 2006 - * brief : Definitions for Connection Management Requests structure - * which we will use to setup our connection structures.Its high - * time we had a header file for CmHost.cpp to isolate the way - * f/w sends DSx messages and the way we interpret them in code. - * Revision History - * - * Date Author Version Description - * 08-Sep-06 Rajeev 0.1 Created - ***************************************************************************/ -#ifndef _CM_HOST_H -#define _CM_HOST_H - -#pragma once -#pragma pack(push, 4) - -#define DSX_MESSAGE_EXCHANGE_BUFFER 0xBF60AC84 /* This contains the pointer */ -#define DSX_MESSAGE_EXCHANGE_BUFFER_SIZE 72000 /* 24 K Bytes */ - -struct bcm_add_indication_alt { - u8 u8Type; - u8 u8Direction; - u16 u16TID; - u16 u16CID; - u16 u16VCID; - struct bcm_connect_mgr_params sfAuthorizedSet; - struct bcm_connect_mgr_params sfAdmittedSet; - struct bcm_connect_mgr_params sfActiveSet; - u8 u8CC; /* < Confirmation Code */ - u8 u8Padd; - u16 u16Padd; -}; - -struct bcm_change_indication { - u8 u8Type; - u8 u8Direction; - u16 u16TID; - u16 u16CID; - u16 u16VCID; - struct bcm_connect_mgr_params sfAuthorizedSet; - struct bcm_connect_mgr_params sfAdmittedSet; - struct bcm_connect_mgr_params sfActiveSet; - u8 u8CC; /* < Confirmation Code */ - u8 u8Padd; - u16 u16Padd; -}; - -unsigned long StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer, unsigned int *puBufferLength); -int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter); -int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter); -unsigned long SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter); -bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer); - -#pragma pack(pop) - -#endif diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c deleted file mode 100644 index 4226c931cd45..000000000000 --- a/drivers/staging/bcm/DDRInit.c +++ /dev/null @@ -1,1355 +0,0 @@ -#include "headers.h" - - - -#define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00 -#define MIPS_CLOCK_REG 0x0f000820 - -/* DDR INIT-133Mhz */ -#define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3_DDRSetting133MHz[] = { - /* DPLL Clock Setting */ - {0x0F000800, 0x00007212}, - {0x0f000820, 0x07F13FFF}, - {0x0f000810, 0x00000F95}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF1B00}, - {0x0f000870, 0x00000002}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - {0x0F00a04C, 0x0000000C}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020001}, - {0x0F007020, 0x04030107}, - {0x0F007024, 0x02000007}, - {0x0F007028, 0x02020202}, - {0x0F00702c, 0x0206060a}, - {0x0F007030, 0x05000000}, - {0x0F007034, 0x00000003}, - {0x0F007038, 0x110a0200}, - {0x0F00703C, 0x02101010}, - {0x0F007040, 0x45751200}, - {0x0F007044, 0x110a0d00}, - {0x0F007048, 0x081b0306}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0000001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x0010246c}, - {0x0F007064, 0x00000010}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00007000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - /* Enable BW improvement within memory controller */ - {0x0F007094, 0x00000104}, - /* Enable 2 ports within X-bar */ - {0x0F00A000, 0x00000016}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; -/* 80Mhz */ -#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3_DDRSetting80MHz[] = { - /* DPLL Clock Setting */ - {0x0f000810, 0x00000F95}, - {0x0f000820, 0x07f1ffff}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - {0x0F00a000, 0x00000016}, - {0x0F00a04C, 0x0000000C}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01000000}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020000}, - {0x0F007020, 0x04020107}, - {0x0F007024, 0x00000007}, - {0x0F007028, 0x02020201}, - {0x0F00702c, 0x0204040a}, - {0x0F007030, 0x04000000}, - {0x0F007034, 0x00000002}, - {0x0F007038, 0x1F060200}, - {0x0F00703C, 0x1C22221F}, - {0x0F007040, 0x8A006600}, - {0x0F007044, 0x221a0800}, - {0x0F007048, 0x02690204}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0000001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x000A15D6}, - {0x0F007064, 0x0000000A}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00004000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - {0x0F007094, 0x00000104}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; -/* 100Mhz */ -#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3_DDRSetting100MHz[] = { - /* DPLL Clock Setting */ - {0x0F000800, 0x00007008}, - {0x0f000810, 0x00000F95}, - {0x0f000820, 0x07F13E3F}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF1B00}, - {0x0f000870, 0x00000002}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - {0x0F00a04C, 0x0000000C}, - /* Enable 2 ports within X-bar */ - {0x0F00A000, 0x00000016}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020001}, - {0x0F007020, 0x04020107}, - {0x0F007024, 0x00000007}, - {0x0F007028, 0x01020201}, - {0x0F00702c, 0x0204040A}, - {0x0F007030, 0x06000000}, - {0x0F007034, 0x00000004}, - {0x0F007038, 0x20080200}, - {0x0F00703C, 0x02030320}, - {0x0F007040, 0x6E7F1200}, - {0x0F007044, 0x01190A00}, - {0x0F007048, 0x06120305}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0000001C}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x00082ED6}, - {0x0F007064, 0x0000000A}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00005000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - /* Enable BW improvement within memory controller */ - {0x0F007094, 0x00000104}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - -/* Net T3B DDR Settings - * DDR INIT-133Mhz - */ -static struct bcm_ddr_setting asDPLL_266MHZ[] = { - {0x0F000800, 0x00007212}, - {0x0f000820, 0x07F13FFF}, - {0x0f000810, 0x00000F95}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF1B00}, - {0x0f000870, 0x00000002} -}; - -#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = { - /* DPLL Clock Setting */ - {0x0f000810, 0x00000F95}, - {0x0f000810, 0x00000F95}, - {0x0f000810, 0x00000F95}, - {0x0f000820, 0x07F13652}, - {0x0f000840, 0x0FFF0800}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000880, 0x000003DD}, - {0x0f000860, 0x00000000}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - /* Enable 2 ports within X-bar */ - {0x0F00A000, 0x00000016}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020001}, - {0x0F007020, 0x04030107}, - {0x0F007024, 0x02000007}, - {0x0F007028, 0x02020202}, - {0x0F00702c, 0x0206060a}, - {0x0F007030, 0x05000000}, - {0x0F007034, 0x00000003}, - {0x0F007038, 0x130a0200}, - {0x0F00703C, 0x02101012}, - {0x0F007040, 0x457D1200}, - {0x0F007044, 0x11130d00}, - {0x0F007048, 0x040D0306}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0000001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x0010246c}, - {0x0F007064, 0x00000012}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00007000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - /* Enable BW improvement within memory controller */ - {0x0F007094, 0x00000104}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000}, - }; - -#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = { - /* DPLL Clock Setting */ - {0x0f000810, 0x00000F95}, - {0x0f000820, 0x07F13FFF}, - {0x0f000840, 0x0FFF1F00}, - {0x0f000880, 0x000003DD}, - {0x0f000860, 0x00000000}, - - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - {0x0F00a000, 0x00000016}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01000000}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020000}, - {0x0F007020, 0x04020107}, - {0x0F007024, 0x00000007}, - {0x0F007028, 0x02020201}, - {0x0F00702c, 0x0204040a}, - {0x0F007030, 0x04000000}, - {0x0F007034, 0x02000002}, - {0x0F007038, 0x1F060202}, - {0x0F00703C, 0x1C22221F}, - {0x0F007040, 0x8A006600}, - {0x0F007044, 0x221a0800}, - {0x0F007048, 0x02690204}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0100001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x000A15D6}, - {0x0F007064, 0x0000000A}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00004000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - {0x0F007094, 0x00000104}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - -/* 100Mhz */ -#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = { - /* DPLL Clock Setting */ - {0x0f000810, 0x00000F95}, - {0x0f000820, 0x07F1369B}, - {0x0f000840, 0x0FFF0800}, - {0x0f000880, 0x000003DD}, - {0x0f000860, 0x00000000}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - /* Enable 2 ports within X-bar */ - {0x0F00A000, 0x00000016}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020000}, - {0x0F007020, 0x04020107}, - {0x0F007024, 0x00000007}, - {0x0F007028, 0x01020201}, - {0x0F00702c, 0x0204040A}, - {0x0F007030, 0x06000000}, - {0x0F007034, 0x02000004}, - {0x0F007038, 0x20080200}, - {0x0F00703C, 0x02030320}, - {0x0F007040, 0x6E7F1200}, - {0x0F007044, 0x01190A00}, - {0x0F007048, 0x06120305}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0100001C}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x00082ED6}, - {0x0F007064, 0x0000000A}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00005000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - /* Enable BW improvement within memory controller */ - {0x0F007094, 0x00000104}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - - -#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[] = { - /* DPLL Clock Setting */ - {0x0f000820, 0x03F1365B}, - {0x0f000810, 0x00002F95}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF0000}, - {0x0f000860, 0x00000000}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - {0x0F00A000, 0x00000016}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020001}, - {0x0F007020, 0x04030107}, - {0x0F007024, 0x02000007}, - {0x0F007028, 0x02020200}, - {0x0F00702c, 0x0206060a}, - {0x0F007030, 0x05000000}, - {0x0F007034, 0x00000003}, - {0x0F007038, 0x200a0200}, - {0x0F00703C, 0x02101020}, - {0x0F007040, 0x45711200}, - {0x0F007044, 0x110D0D00}, - {0x0F007048, 0x04080306}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0100001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x0010245F}, - {0x0F007064, 0x00000010}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00007000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - {0x0F007088, 0x01000001}, - {0x0F00708c, 0x00000101}, - {0x0F007090, 0x00000000}, - /* Enable BW improvement within memory controller */ - {0x0F007094, 0x00040000}, - {0x0F007098, 0x00000000}, - {0x0F0070c8, 0x00000104}, - /* Enable 2 ports within X-bar */ - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - -#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[] = { - /* DPLL Clock Setting */ - {0x0f000810, 0x00002F95}, - {0x0f000820, 0x03F1369B}, - {0x0f000840, 0x0fff0000}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF0000}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020000}, - {0x0F007020, 0x04020107}, - {0x0F007024, 0x00000007}, - {0x0F007028, 0x01020200}, - {0x0F00702c, 0x0204040a}, - {0x0F007030, 0x06000000}, - {0x0F007034, 0x00000004}, - {0x0F007038, 0x1F080200}, - {0x0F00703C, 0x0203031F}, - {0x0F007040, 0x6e001200}, - {0x0F007044, 0x011a0a00}, - {0x0F007048, 0x03000305}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0100001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x00082ED6}, - {0x0F007064, 0x0000000A}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00005000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - {0x0F007088, 0x01000001}, - {0x0F00708c, 0x00000101}, - {0x0F007090, 0x00000000}, - {0x0F007094, 0x00010000}, - {0x0F007098, 0x00000000}, - {0x0F0070C8, 0x00000104}, - /* Enable 2 ports within X-bar */ - {0x0F00A000, 0x00000016}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - -#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[] = { - /* DPLL Clock Setting */ - {0x0f000820, 0x07F13FFF}, - {0x0f000810, 0x00002F95}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - {0x0f000840, 0x0FFF1F00}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0F00a084, 0x1Cffffff}, - {0x0F00a080, 0x1C000000}, - {0x0F00A000, 0x00000016}, - {0x0f007000, 0x00010001}, - {0x0f007004, 0x01000000}, - {0x0f007008, 0x01000001}, - {0x0f00700c, 0x00000000}, - {0x0f007010, 0x01000000}, - {0x0f007014, 0x01000100}, - {0x0f007018, 0x01000000}, - {0x0f00701c, 0x01020000}, - {0x0f007020, 0x04020107}, - {0x0f007024, 0x00000007}, - {0x0f007028, 0x02020200}, - {0x0f00702c, 0x0204040a}, - {0x0f007030, 0x04000000}, - {0x0f007034, 0x00000002}, - {0x0f007038, 0x1d060200}, - {0x0f00703c, 0x1c22221d}, - {0x0f007040, 0x8A116600}, - {0x0f007044, 0x222d0800}, - {0x0f007048, 0x02690204}, - {0x0f00704c, 0x00000000}, - {0x0f007050, 0x0100001c}, - {0x0f007054, 0x00000000}, - {0x0f007058, 0x00000000}, - {0x0f00705c, 0x00000000}, - {0x0f007060, 0x000A15D6}, - {0x0f007064, 0x0000000A}, - {0x0f007068, 0x00000000}, - {0x0f00706c, 0x00000001}, - {0x0f007070, 0x00004000}, - {0x0f007074, 0x00000000}, - {0x0f007078, 0x00000000}, - {0x0f00707c, 0x00000000}, - {0x0f007080, 0x00000000}, - {0x0f007084, 0x00000000}, - {0x0f007088, 0x01000001}, - {0x0f00708c, 0x00000101}, - {0x0f007090, 0x00000000}, - {0x0f007094, 0x00010000}, - {0x0f007098, 0x00000000}, - {0x0F0070C8, 0x00000104}, - {0x0F007018, 0x01010000} -}; - - - - -/* T3 LP-B (UMA-B) */ - -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[] = { - /* DPLL Clock Setting */ - {0x0f000820, 0x03F137DB}, - {0x0f000810, 0x01842795}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - {0x0f000840, 0x0FFF0400}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0f003050, 0x00000021}, /* this is flash/eeprom clock divisor which - * set the flash clock to 20 MHz */ - {0x0F00a084, 0x1Cffffff}, /* Now dump from her in internal memory */ - {0x0F00a080, 0x1C000000}, - {0x0F00A000, 0x00000016}, - {0x0f007000, 0x00010001}, - {0x0f007004, 0x01000001}, - {0x0f007008, 0x01000101}, - {0x0f00700c, 0x00000000}, - {0x0f007010, 0x01000100}, - {0x0f007014, 0x01000100}, - {0x0f007018, 0x01000000}, - {0x0f00701c, 0x01020000}, - {0x0f007020, 0x04030107}, - {0x0f007024, 0x02000007}, - {0x0f007028, 0x02020200}, - {0x0f00702c, 0x0206060a}, - {0x0f007030, 0x050d0d00}, - {0x0f007034, 0x00000003}, - {0x0f007038, 0x170a0200}, - {0x0f00703c, 0x02101012}, - {0x0f007040, 0x45161200}, - {0x0f007044, 0x11250c00}, - {0x0f007048, 0x04da0307}, - {0x0f00704c, 0x00000000}, - {0x0f007050, 0x0000001c}, - {0x0f007054, 0x00000000}, - {0x0f007058, 0x00000000}, - {0x0f00705c, 0x00000000}, - {0x0f007060, 0x00142bb6}, - {0x0f007064, 0x20430014}, - {0x0f007068, 0x00000000}, - {0x0f00706c, 0x00000001}, - {0x0f007070, 0x00009000}, - {0x0f007074, 0x00000000}, - {0x0f007078, 0x00000000}, - {0x0f00707c, 0x00000000}, - {0x0f007080, 0x00000000}, - {0x0f007084, 0x00000000}, - {0x0f007088, 0x01000001}, - {0x0f00708c, 0x00000101}, - {0x0f007090, 0x00000000}, - {0x0f007094, 0x00040000}, - {0x0f007098, 0x00000000}, - {0x0F0070C8, 0x00000104}, - {0x0F007018, 0x01010000} -}; - - -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LPB_DDRSetting133MHz[] = { - /* DPLL Clock Setting */ - {0x0f000820, 0x03F1365B}, - {0x0f000810, 0x00002F95}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF0000}, - {0x0f000860, 0x00000000}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0f003050, 0x00000021}, /* flash/eeprom clock divisor which - * set the flash clock to 20 MHz */ - {0x0F00a084, 0x1Cffffff}, /* dump from here in internal memory */ - {0x0F00a080, 0x1C000000}, - {0x0F00A000, 0x00000016}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020001}, - {0x0F007020, 0x04030107}, - {0x0F007024, 0x02000007}, - {0x0F007028, 0x02020200}, - {0x0F00702c, 0x0206060a}, - {0x0F007030, 0x05000000}, - {0x0F007034, 0x00000003}, - {0x0F007038, 0x190a0200}, - {0x0F00703C, 0x02101017}, - {0x0F007040, 0x45171200}, - {0x0F007044, 0x11290D00}, - {0x0F007048, 0x04080306}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0100001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x0010245F}, - {0x0F007064, 0x00000010}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00007000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - {0x0F007088, 0x01000001}, - {0x0F00708c, 0x00000101}, - {0x0F007090, 0x00000000}, - /* Enable BW improvement within memory controller */ - {0x0F007094, 0x00040000}, - {0x0F007098, 0x00000000}, - {0x0F0070c8, 0x00000104}, - /* Enable 2 ports within X-bar */ - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LPB_DDRSetting100MHz[] = { - /* DPLL Clock Setting */ - {0x0f000810, 0x00002F95}, - {0x0f000820, 0x03F1369B}, - {0x0f000840, 0x0fff0000}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - /* Changed source for X-bar and MIPS clock to APLL */ - {0x0f000840, 0x0FFF0000}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0f003050, 0x00000021}, /* flash/eeprom clock divisor which - * set the flash clock to 20 MHz */ - {0x0F00a084, 0x1Cffffff}, /* dump from here in internal memory */ - {0x0F00a080, 0x1C000000}, - /* Memcontroller Default values */ - {0x0F007000, 0x00010001}, - {0x0F007004, 0x01010100}, - {0x0F007008, 0x01000001}, - {0x0F00700c, 0x00000000}, - {0x0F007010, 0x01000000}, - {0x0F007014, 0x01000100}, - {0x0F007018, 0x01000000}, - {0x0F00701c, 0x01020000}, - {0x0F007020, 0x04020107}, - {0x0F007024, 0x00000007}, - {0x0F007028, 0x01020200}, - {0x0F00702c, 0x0204040a}, - {0x0F007030, 0x06000000}, - {0x0F007034, 0x00000004}, - {0x0F007038, 0x1F080200}, - {0x0F00703C, 0x0203031F}, - {0x0F007040, 0x6e001200}, - {0x0F007044, 0x011a0a00}, - {0x0F007048, 0x03000305}, - {0x0F00704c, 0x00000000}, - {0x0F007050, 0x0100001c}, - {0x0F007054, 0x00000000}, - {0x0F007058, 0x00000000}, - {0x0F00705c, 0x00000000}, - {0x0F007060, 0x00082ED6}, - {0x0F007064, 0x0000000A}, - {0x0F007068, 0x00000000}, - {0x0F00706c, 0x00000001}, - {0x0F007070, 0x00005000}, - {0x0F007074, 0x00000000}, - {0x0F007078, 0x00000000}, - {0x0F00707C, 0x00000000}, - {0x0F007080, 0x00000000}, - {0x0F007084, 0x00000000}, - {0x0F007088, 0x01000001}, - {0x0F00708c, 0x00000101}, - {0x0F007090, 0x00000000}, - {0x0F007094, 0x00010000}, - {0x0F007098, 0x00000000}, - {0x0F0070C8, 0x00000104}, - /* Enable 2 ports within X-bar */ - {0x0F00A000, 0x00000016}, - /* Enable start bit within memory controller */ - {0x0F007018, 0x01010000} -}; - -#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 /* index for 0x0F007000 */ -static struct bcm_ddr_setting asT3LPB_DDRSetting80MHz[] = { - /* DPLL Clock Setting */ - {0x0f000820, 0x07F13FFF}, - {0x0f000810, 0x00002F95}, - {0x0f000860, 0x00000000}, - {0x0f000880, 0x000003DD}, - {0x0f000840, 0x0FFF1F00}, - {0x0F00a044, 0x1fffffff}, - {0x0F00a040, 0x1f000000}, - {0x0f003050, 0x00000021}, /* flash/eeprom clock divisor - * which set the flash clock to 20 MHz */ - {0x0F00a084, 0x1Cffffff}, /* dump from here in internal memory */ - {0x0F00a080, 0x1C000000}, - {0x0F00A000, 0x00000016}, - {0x0f007000, 0x00010001}, - {0x0f007004, 0x01000000}, - {0x0f007008, 0x01000001}, - {0x0f00700c, 0x00000000}, - {0x0f007010, 0x01000000}, - {0x0f007014, 0x01000100}, - {0x0f007018, 0x01000000}, - {0x0f00701c, 0x01020000}, - {0x0f007020, 0x04020107}, - {0x0f007024, 0x00000007}, - {0x0f007028, 0x02020200}, - {0x0f00702c, 0x0204040a}, - {0x0f007030, 0x04000000}, - {0x0f007034, 0x00000002}, - {0x0f007038, 0x1d060200}, - {0x0f00703c, 0x1c22221d}, - {0x0f007040, 0x8A116600}, - {0x0f007044, 0x222d0800}, - {0x0f007048, 0x02690204}, - {0x0f00704c, 0x00000000}, - {0x0f007050, 0x0100001c}, - {0x0f007054, 0x00000000}, - {0x0f007058, 0x00000000}, - {0x0f00705c, 0x00000000}, - {0x0f007060, 0x000A15D6}, - {0x0f007064, 0x0000000A}, - {0x0f007068, 0x00000000}, - {0x0f00706c, 0x00000001}, - {0x0f007070, 0x00004000}, - {0x0f007074, 0x00000000}, - {0x0f007078, 0x00000000}, - {0x0f00707c, 0x00000000}, - {0x0f007080, 0x00000000}, - {0x0f007084, 0x00000000}, - {0x0f007088, 0x01000001}, - {0x0f00708c, 0x00000101}, - {0x0f007090, 0x00000000}, - {0x0f007094, 0x00010000}, - {0x0f007098, 0x00000000}, - {0x0F0070C8, 0x00000104}, - {0x0F007018, 0x01010000} -}; - - -int ddr_init(struct bcm_mini_adapter *Adapter) -{ - struct bcm_ddr_setting *psDDRSetting = NULL; - ULONG RegCount = 0; - UINT value = 0; - UINT uiResetValue = 0; - UINT uiClockSetting = 0; - int retval = STATUS_SUCCESS; - - switch (Adapter->chip_id) { - case 0xbece3200: - switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3LP_DDRSetting80MHz; - RegCount = (sizeof(asT3LP_DDRSetting80MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting = asT3LP_DDRSetting100MHz; - RegCount = (sizeof(asT3LP_DDRSetting100MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_133_MHZ: - psDDRSetting = asT3LP_DDRSetting133MHz; - RegCount = (sizeof(asT3LP_DDRSetting133MHz) / - sizeof(struct bcm_ddr_setting)); - if (Adapter->bMipsConfig == MIPS_200_MHZ) - uiClockSetting = 0x03F13652; - else - uiClockSetting = 0x03F1365B; - break; - default: - return -EINVAL; - } - - break; - case T3LPB: - case BCS220_2: - case BCS220_2BC: - case BCS250_BC: - case BCS220_3: - /* Set bit 2 and bit 6 to 1 for BBIC 2mA drive - * (please check current value and additionally set these bits) - */ - if ((Adapter->chip_id != BCS220_2) && - (Adapter->chip_id != BCS220_2BC) && - (Adapter->chip_id != BCS220_3)) { - 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)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, __LINE__); - return retval; - } - } - switch (Adapter->DDRSetting) { - - - - case DDR_80_MHZ: - psDDRSetting = asT3LPB_DDRSetting80MHz; - RegCount = (sizeof(asT3B_DDRSetting80MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting = asT3LPB_DDRSetting100MHz; - RegCount = (sizeof(asT3B_DDRSetting100MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_133_MHZ: - psDDRSetting = asT3LPB_DDRSetting133MHz; - RegCount = (sizeof(asT3B_DDRSetting133MHz) / - sizeof(struct bcm_ddr_setting)); - - if (Adapter->bMipsConfig == MIPS_200_MHZ) - uiClockSetting = 0x03F13652; - else - uiClockSetting = 0x03F1365B; - break; - - case DDR_160_MHZ: - psDDRSetting = asT3LPB_DDRSetting160MHz; - RegCount = sizeof(asT3LPB_DDRSetting160MHz) / - sizeof(struct bcm_ddr_setting); - - if (Adapter->bMipsConfig == MIPS_200_MHZ) - uiClockSetting = 0x03F137D2; - else - uiClockSetting = 0x03F137DB; - } - break; - - case 0xbece0110: - case 0xbece0120: - case 0xbece0121: - case 0xbece0130: - case 0xbece0300: - 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; - RegCount = (sizeof(asT3_DDRSetting80MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting = asT3_DDRSetting100MHz; - RegCount = (sizeof(asT3_DDRSetting100MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_133_MHZ: - psDDRSetting = asT3_DDRSetting133MHz; - RegCount = (sizeof(asT3_DDRSetting133MHz) / - sizeof(struct bcm_ddr_setting)); - break; - default: - return -EINVAL; - } - case 0xbece0310: - { - switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3B_DDRSetting80MHz; - RegCount = (sizeof(asT3B_DDRSetting80MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_100_MHZ: - psDDRSetting = asT3B_DDRSetting100MHz; - RegCount = (sizeof(asT3B_DDRSetting100MHz) / - sizeof(struct bcm_ddr_setting)); - break; - case DDR_133_MHZ: - - /* 266Mhz PLL selected. */ - if (Adapter->bDPLLConfig == PLL_266_MHZ) { - memcpy(asT3B_DDRSetting133MHz, asDPLL_266MHZ, - sizeof(asDPLL_266MHZ)); - psDDRSetting = asT3B_DDRSetting133MHz; - RegCount = (sizeof(asT3B_DDRSetting133MHz) / - sizeof(struct bcm_ddr_setting)); - } else { - psDDRSetting = asT3B_DDRSetting133MHz; - RegCount = (sizeof(asT3B_DDRSetting133MHz) / - sizeof(struct bcm_ddr_setting)); - if (Adapter->bMipsConfig == MIPS_200_MHZ) - uiClockSetting = 0x07F13652; - else - uiClockSetting = 0x07F1365B; - } - break; - default: - return -EINVAL; - } - break; - - } - default: - return -EINVAL; - } - - value = 0; - 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; - else - value = psDDRSetting->ulRegValue; - retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, &value, - sizeof(value)); - if (STATUS_SUCCESS != retval) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "%s:%d\n", __func__, __LINE__); - break; - } - - RegCount--; - psDDRSetting++; - } - - if (Adapter->chip_id >= 0xbece3300) { - - mdelay(3); - if ((Adapter->chip_id != BCS220_2) && - (Adapter->chip_id != BCS220_2BC) && - (Adapter->chip_id != BCS220_3)) { - /* drive MDDR to half in case of UMA-B: */ - uiResetValue = 0x01010001; - retval = wrmalt(Adapter, (UINT)0x0F007018, - &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 = 0x00040020; - retval = wrmalt(Adapter, (UINT)0x0F007094, - &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 = 0x01020101; - retval = wrmalt(Adapter, (UINT)0x0F00701c, - &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 = 0x01010000; - retval = wrmalt(Adapter, (UINT)0x0F007018, - &uiResetValue, sizeof(uiResetValue)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - } - mdelay(3); - - /* DC/DC standby change... - * This is to be done only for Hybrid PMU mode. - * with the current h/w there is no way to detect this. - * and since we dont have internal PMU lets do it under - * UMA-B chip id. we will change this when we will have - * internal PMU. - */ - if (Adapter->PmuMode == HYBRID_MODE_7C) { - 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)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - uiResetValue = 0x1322a8; - retval = wrmalt(Adapter, (UINT)0x0f000d1c, - &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)); - 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)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - uiResetValue = 0x132296; - retval = wrmalt(Adapter, (UINT)0x0f000d14, - &uiResetValue, sizeof(uiResetValue)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - } else if (Adapter->PmuMode == HYBRID_MODE_6) { - - 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)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - uiResetValue = 0x6003229a; - retval = wrmalt(Adapter, (UINT)0x0f000d14, - &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)); - 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)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - uiResetValue = 0x1322a8; - retval = wrmalt(Adapter, (UINT)0x0f000d1c, - &uiResetValue, sizeof(uiResetValue)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, - DBG_LVL_ALL, - "%s:%d RDM failed\n", - __func__, - __LINE__); - return retval; - } - } - - } - Adapter->bDDRInitDone = TRUE; - return retval; -} - -int download_ddr_settings(struct bcm_mini_adapter *Adapter) -{ - struct bcm_ddr_setting *psDDRSetting = NULL; - ULONG RegCount = 0; - unsigned long ul_ddr_setting_load_addr = - DDR_DUMP_INTERNAL_DEVICE_MEMORY; - UINT value = 0; - int retval = STATUS_SUCCESS; - bool bOverrideSelfRefresh = false; - - switch (Adapter->chip_id) { - case 0xbece3200: - switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3LP_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz); - RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - break; - case DDR_100_MHZ: - psDDRSetting = asT3LP_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz); - RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3LP_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz); - RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - default: - return -EINVAL; - } - break; - - case T3LPB: - case BCS220_2: - case BCS220_2BC: - case BCS250_BC: - case BCS220_3: - switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3LPB_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting80MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - break; - case DDR_100_MHZ: - psDDRSetting = asT3LPB_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3LPB_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - - case DDR_160_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3LPB_DDRSetting160MHz; - RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz); - RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; - psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ; - - break; - default: - return -EINVAL; - } - break; - case 0xbece0300: - switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz); - RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - break; - case DDR_100_MHZ: - psDDRSetting = asT3_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz); - RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - psDDRSetting = asT3_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz); - RegCount -= T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - default: - return -EINVAL; - } - break; - case 0xbece0310: - { - switch (Adapter->DDRSetting) { - case DDR_80_MHZ: - psDDRSetting = asT3B_DDRSetting80MHz; - RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz); - RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ; - break; - case DDR_100_MHZ: - psDDRSetting = asT3B_DDRSetting100MHz; - RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz); - RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ; - break; - case DDR_133_MHZ: - bOverrideSelfRefresh = TRUE; - psDDRSetting = asT3B_DDRSetting133MHz; - RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz); - RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ; - break; - } - break; - } - default: - return -EINVAL; - } - /* total number of Register that has to be dumped */ - value = RegCount; - retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, - sizeof(value)); - if (retval) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "%s:%d\n", __func__, __LINE__); - - return retval; - } - ul_ddr_setting_load_addr += sizeof(ULONG); - /* signature */ - value = (0x1d1e0dd0); - retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, - sizeof(value)); - if (retval) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "%s:%d\n", __func__, __LINE__); - return retval; - } - - ul_ddr_setting_load_addr += sizeof(ULONG); - RegCount *= (sizeof(struct bcm_ddr_setting)/sizeof(ULONG)); - - while (RegCount && !retval) { - value = psDDRSetting->ulRegAddress; - retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, - sizeof(value)); - ul_ddr_setting_load_addr += sizeof(ULONG); - if (!retval) { - if (bOverrideSelfRefresh - && (psDDRSetting->ulRegAddress - == 0x0F007018)) - value = (psDDRSetting->ulRegValue | (1<<8)); - else - value = psDDRSetting->ulRegValue; - - 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__); - break; - } - } - ul_ddr_setting_load_addr += sizeof(ULONG); - RegCount--; - psDDRSetting++; - } - return retval; -} diff --git a/drivers/staging/bcm/DDRInit.h b/drivers/staging/bcm/DDRInit.h deleted file mode 100644 index b0196fce9255..000000000000 --- a/drivers/staging/bcm/DDRInit.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _DDR_INIT_H_ -#define _DDR_INIT_H_ - - - -int ddr_init(struct bcm_mini_adapter *psAdapter); -int download_ddr_settings(struct bcm_mini_adapter *psAdapter); - -#endif diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h deleted file mode 100644 index 7b331215c1ac..000000000000 --- a/drivers/staging/bcm/Debug.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Debug.h - * - * Dynamic (runtime) debug framework implementation. - * -kaiwan. - */ -#ifndef _DEBUG_H -#define _DEBUG_H -#include -#define NONE 0xFFFF - -/* TYPE and SUBTYPE - * Define valid TYPE (or category or code-path, however you like to think of it) - * and SUBTYPE s. - * Type and SubType are treated as bitmasks. - */ -#define DBG_TYPE_INITEXIT (1 << 0) /* 1 */ -#define DBG_TYPE_TX (1 << 1) /* 2 */ -#define DBG_TYPE_RX (1 << 2) /* 4 */ -#define DBG_TYPE_OTHERS (1 << 3) /* 8 */ -#define NUMTYPES 4 - -/* -SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// - * Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c - * total 17 macros - */ -/* Transmit.c */ -#define TX 1 -#define MP_SEND (TX << 0) -#define NEXT_SEND (TX << 1) -#define TX_FIFO (TX << 2) -#define TX_CONTROL (TX << 3) - -/* Arp.c */ -#define IP_ADDR (TX << 4) -#define ARP_REQ (TX << 5) -#define ARP_RESP (TX << 6) - -/* Leakybucket.c */ -#define TOKEN_COUNTS (TX << 8) -#define CHECK_TOKENS (TX << 9) -#define TX_PACKETS (TX << 10) -#define TIMER (TX << 11) - -/* Qos.c */ -#define QOS TX -#define QUEUE_INDEX (QOS << 12) -#define IPV4_DBG (QOS << 13) -#define IPV6_DBG (QOS << 14) -#define PRUNE_QUEUE (QOS << 15) -#define SEND_QUEUE (QOS << 16) - -/* TX_Misc */ -#define TX_OSAL_DBG (TX << 17) - -/* --SUBTYPEs for ------INIT & EXIT--------------------- - * ------------ TYPE is DBG_TYPE_INITEXIT -----// - * DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c - */ -#define MP 1 -#define DRV_ENTRY (MP << 0) -#define MP_INIT (MP << 1) -#define READ_REG (MP << 3) -#define DISPATCH (MP << 2) -#define CLAIM_ADAP (MP << 4) -#define REG_IO_PORT (MP << 5) -#define INIT_DISP (MP << 6) -#define RX_INIT (MP << 7) - -/* -SUBTYPEs for --RX---------------------------------- - * ------------RX : TYPE is DBG_TYPE_RX -----// - * Receive.c - */ -#define RX 1 -#define RX_DPC (RX << 0) -#define RX_CTRL (RX << 3) -#define RX_DATA (RX << 4) -#define MP_RETURN (RX << 1) -#define LINK_MSG (RX << 2) - -/* -SUBTYPEs for ----OTHER ROUTINES------------------ - * ------------OTHERS : TYPE is DBG_TYPE_OTHER -----// - * HaltnReset,CheckForHang,PnP,Misc,CmHost - * total 12 macros - */ -#define OTHERS 1 -#define ISR OTHERS -#define MP_DPC (ISR << 0) - -/* HaltnReset.c */ -#define HALT OTHERS -#define MP_HALT (HALT << 1) -#define CHECK_HANG (HALT << 2) -#define MP_RESET (HALT << 3) -#define MP_SHUTDOWN (HALT << 4) - -/* pnp.c */ -#define PNP OTHERS -#define MP_PNP (PNP << 5) - -/* Misc.c */ -#define MISC OTHERS -#define DUMP_INFO (MISC << 6) -#define CLASSIFY (MISC << 7) -#define LINK_UP_MSG (MISC << 8) -#define CP_CTRL_PKT (MISC << 9) -#define DUMP_CONTROL (MISC << 10) -#define LED_DUMP_INFO (MISC << 11) - -/* CmHost.c */ -#define CMHOST OTHERS -#define SERIAL (OTHERS << 12) -#define IDLE_MODE (OTHERS << 13) -#define WRM (OTHERS << 14) -#define RDM (OTHERS << 15) - -/* TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? */ -#define PHS_SEND (OTHERS << 16) -#define PHS_RECEIVE (OTHERS << 17) -#define PHS_MODULE (OTHERS << 18) - -#define INTF_INIT (OTHERS << 19) -#define INTF_ERR (OTHERS << 20) -#define INTF_WARN (OTHERS << 21) -#define INTF_NORM (OTHERS << 22) - -#define IRP_COMPLETION (OTHERS << 23) -#define SF_DESCRIPTOR_CNTS (OTHERS << 24) -#define PHS_DISPATCH (OTHERS << 25) -#define OSAL_DBG (OTHERS << 26) -#define NVM_RW (OTHERS << 27) - -#define HOST_MIBS (OTHERS << 28) -#define CONN_MSG (CMHOST << 29) - -/* Debug level - * We have 8 debug levels, in (numerical) increasing order of verbosity. - * IMP: Currently implementing ONLY DBG_LVL_ALL , i.e. , all debug prints will - * appear (of course, iff global debug flag is ON and we match the Type and SubType). - * Finer granularity debug levels are currently not in use, although the feature exists. - * - * Another way to say this: - * All the debug prints currently have 'debug_level' set to DBG_LVL_ALL . - * You can compile-time change that to any of the below, if you wish to. However, as of now, there's - * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion. - */ -#define BCM_ALL 7 -#define BCM_LOW 6 -#define BCM_PRINT 5 -#define BCM_NORMAL 4 -#define BCM_MEDIUM 3 -#define BCM_SCREAM 2 -#define BCM_ERR 1 -/* Not meant for developer in debug prints. - * To be used to disable all prints by setting the DBG_LVL_CURR to this value - */ -#define BCM_NONE 0 - -/* The current driver logging level. - * Everything at this level and (numerically) lower (meaning higher prio) - * is logged. - * Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. - * For eg. to set the logging level to 'errors only' use: - * #define DBG_LVL_CURR (BCM_ERR) - */ - -#define DBG_LVL_CURR (BCM_ALL) -#define DBG_LVL_ALL BCM_ALL - -/* ---Userspace mapping of Debug State. - * Delibrately matches that of the Windows driver.. - * The TestApp's ioctl passes this struct to us. - */ -struct bcm_user_debug_state { - unsigned int Subtype, Type; - unsigned int OnOff; -/* unsigned int debug_level; future expansion */ -} __packed; - -/* ---Kernel-space mapping of Debug State */ -struct bcm_debug_state { - unsigned int type; - /* A bitmap of 32 bits for Subtype per Type. - * Valid indexes in 'subtype' array are *only* 1,2,4 and 8, - * corresponding to valid Type values. Hence we use the 'Type' field - * as the index value, ignoring the array entries 0,3,5,6,7 ! - */ - unsigned int subtype[(NUMTYPES*2)+1]; - unsigned int debug_level; -}; -/* Instantiated in the Adapter structure - * We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not - * we want the function's name printed. - */ -#define DBG_NO_FUNC_PRINT (1 << 31) -#define DBG_LVL_BITMASK 0xFF - -/* --- Only for direct printk's; "hidden" to API. */ -#define DBG_TYPE_PRINTK 3 - -#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \ - do { \ - if (DBG_TYPE_PRINTK == Type) \ - pr_info("%s:" string, __func__, ##args); \ - else if (Adapter && \ - (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ - (Type & Adapter->stDebugState.type) && \ - (SubType & Adapter->stDebugState.subtype[Type])) { \ - if (dbg_level & DBG_NO_FUNC_PRINT) \ - pr_debug("%s:\n", string); \ - else \ - pr_debug("%s:\n" string, __func__, ##args); \ - } \ - } while (0) - -#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) \ - do { \ - if (DBG_TYPE_PRINTK == Type || \ - (Adapter && \ - (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \ - (Type & Adapter->stDebugState.type) && \ - (SubType & Adapter->stDebugState.subtype[Type]))) { \ - pr_debug("%s:\n", __func__); \ - print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \ - 16, 1, buffer, bufferlen, false); \ - } \ - } while (0) - -#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ - int i; \ - for (i = 0; i < (NUMTYPES * 2) + 1; i++) { \ - if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \ - /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ - * Adapter->stDebugState.subtype[i] = 0xffffffff; \ - */ \ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ - i, Adapter->stDebugState.subtype[i]); \ - } \ - } \ -} while (0) - -#endif diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c deleted file mode 100644 index dd5d138a6528..000000000000 --- a/drivers/staging/bcm/HandleControlPacket.c +++ /dev/null @@ -1,241 +0,0 @@ -/** - * @file HandleControlPacket.c - * This file contains the routines to deal with - * sending and receiving of control packets. - */ -#include "headers.h" - -/** - * When a control packet is received, analyze the - * "status" and call appropriate response function. - * Enqueue the control packet for Application. - * @return None - */ -static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter, - struct sk_buff *skb) -{ - struct bcm_tarang_data *pTarang = NULL; - bool HighPriorityMessage = false; - struct sk_buff *newPacket = NULL; - CHAR cntrl_msg_mask_bit = 0; - bool drop_pkt_flag = TRUE; - USHORT usStatus = *(PUSHORT)(skb->data); - - if (netif_msg_pktdata(Adapter)) - print_hex_dump(KERN_DEBUG, PFX "rx control: ", DUMP_PREFIX_NONE, - 16, 1, skb->data, skb->len, 0); - - switch (usStatus) { - case CM_RESPONSES: /* 0xA0 */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, - DBG_LVL_ALL, - "MAC Version Seems to be Non Multi-Classifier, rejected by Driver"); - HighPriorityMessage = TRUE; - break; - case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP: - HighPriorityMessage = TRUE; - if (Adapter->LinkStatus == LINKUP_DONE) - CmControlResponseMessage(Adapter, - (skb->data + sizeof(USHORT))); - break; - case LINK_CONTROL_RESP: /* 0xA2 */ - case STATUS_RSP: /* 0xA1 */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, - DBG_LVL_ALL, "LINK_CONTROL_RESP"); - HighPriorityMessage = TRUE; - LinkControlResponseMessage(Adapter, - (skb->data + sizeof(USHORT))); - break; - case STATS_POINTER_RESP: /* 0xA6 */ - HighPriorityMessage = TRUE; - StatisticsResponse(Adapter, (skb->data + sizeof(USHORT))); - break; - case IDLE_MODE_STATUS: /* 0xA3 */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, - DBG_LVL_ALL, - "IDLE_MODE_STATUS Type Message Got from F/W"); - InterfaceIdleModeRespond(Adapter, (PUINT)(skb->data + - sizeof(USHORT))); - HighPriorityMessage = TRUE; - break; - - case AUTH_SS_HOST_MSG: - HighPriorityMessage = TRUE; - break; - - default: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, - DBG_LVL_ALL, "Got Default Response"); - /* Let the Application Deal with This Packet */ - break; - } - - /* Queue The Control Packet to The Application Queues */ - down(&Adapter->RxAppControlQueuelock); - - for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) { - if (Adapter->device_removed) - break; - - drop_pkt_flag = TRUE; - /* - * There are cntrl msg from A0 to AC. It has been mapped to 0 to - * C bit in the cntrl mask. - * Also, by default AD to BF has been masked to the rest of the - * bits... which wil be ON by default. - * if mask bit is enable to particular pkt status, send it out - * to app else stop it. - */ - cntrl_msg_mask_bit = (usStatus & 0x1F); - /* - * printk("\ninew msg mask bit which is disable in mask:%X", - * cntrl_msg_mask_bit); - */ - if (pTarang->RxCntrlMsgBitMask & (1 << cntrl_msg_mask_bit)) - drop_pkt_flag = false; - - if ((drop_pkt_flag == TRUE) || - (pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN) - || ((pTarang->AppCtrlQueueLen > - MAX_APP_QUEUE_LEN / 2) && - (HighPriorityMessage == false))) { - /* - * Assumption:- - * 1. every tarang manages it own dropped pkt - * statitistics - * 2. Total packet dropped per tarang will be equal to - * the sum of all types of dropped pkt by that - * tarang only. - */ - struct bcm_mibs_dropped_cntrl_msg *msg = - &pTarang->stDroppedAppCntrlMsgs; - switch (*(PUSHORT)skb->data) { - case CM_RESPONSES: - msg->cm_responses++; - break; - case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP: - msg->cm_control_newdsx_multiclassifier_resp++; - break; - case LINK_CONTROL_RESP: - msg->link_control_resp++; - break; - case STATUS_RSP: - msg->status_rsp++; - break; - case STATS_POINTER_RESP: - msg->stats_pointer_resp++; - break; - case IDLE_MODE_STATUS: - msg->idle_mode_status++; - break; - case AUTH_SS_HOST_MSG: - msg->auth_ss_host_msg++; - break; - default: - msg->low_priority_message++; - break; - } - - continue; - } - - newPacket = skb_clone(skb, GFP_KERNEL); - if (!newPacket) - break; - ENQUEUEPACKET(pTarang->RxAppControlHead, - pTarang->RxAppControlTail, newPacket); - pTarang->AppCtrlQueueLen++; - } - up(&Adapter->RxAppControlQueuelock); - wake_up(&Adapter->process_read_wait_queue); - dev_kfree_skb(skb); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, - "After wake_up_interruptible"); -} - -/** - * @ingroup ctrl_pkt_functions - * Thread to handle control pkt reception - */ - -/* pointer to adapter object*/ -int control_packet_handler(struct bcm_mini_adapter *Adapter) -{ - struct sk_buff *ctrl_packet = NULL; - unsigned long flags = 0; - /* struct timeval tv; */ - /* int *puiBuffer = NULL; */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, - "Entering to make thread wait on control packet event!"); - while (1) { - wait_event_interruptible(Adapter->process_rx_cntrlpkt, - atomic_read(&Adapter->cntrlpktCnt) || - Adapter->bWakeUpDevice || - kthread_should_stop()); - - - if (kthread_should_stop()) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CP_CTRL_PKT, - DBG_LVL_ALL, "Exiting\n"); - return 0; - } - if (TRUE == Adapter->bWakeUpDevice) { - Adapter->bWakeUpDevice = false; - if ((false == Adapter->bTriedToWakeUpFromlowPowerMode) - && ((TRUE == Adapter->IdleMode) || - (TRUE == Adapter->bShutStatus))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - CP_CTRL_PKT, DBG_LVL_ALL, - "Calling InterfaceAbortIdlemode\n"); - /* - * Adapter->bTriedToWakeUpFromlowPowerMode - * = TRUE; - */ - InterfaceIdleModeWakeup(Adapter); - } - continue; - } - - while (atomic_read(&Adapter->cntrlpktCnt)) { - spin_lock_irqsave(&Adapter->control_queue_lock, flags); - ctrl_packet = Adapter->RxControlHead; - if (ctrl_packet) { - DEQUEUEPACKET(Adapter->RxControlHead, - Adapter->RxControlTail); - /* Adapter->RxControlHead=ctrl_packet->next; */ - } - - spin_unlock_irqrestore(&Adapter->control_queue_lock, - flags); - handle_rx_control_packet(Adapter, ctrl_packet); - atomic_dec(&Adapter->cntrlpktCnt); - } - - SetUpTargetDsxBuffers(Adapter); - } - return STATUS_SUCCESS; -} - -INT flushAllAppQ(void) -{ - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_tarang_data *pTarang = NULL; - struct sk_buff *PacketToDrop = NULL; - - for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) { - while (pTarang->RxAppControlHead != NULL) { - PacketToDrop = pTarang->RxAppControlHead; - DEQUEUEPACKET(pTarang->RxAppControlHead, - pTarang->RxAppControlTail); - dev_kfree_skb(PacketToDrop); - } - pTarang->AppCtrlQueueLen = 0; - /* dropped contrl packet statistics also should be reset. */ - memset((PVOID)&pTarang->stDroppedAppCntrlMsgs, 0, - sizeof(struct bcm_mibs_dropped_cntrl_msg)); - - } - return STATUS_SUCCESS; -} - - diff --git a/drivers/staging/bcm/HostMIBSInterface.h b/drivers/staging/bcm/HostMIBSInterface.h deleted file mode 100644 index f922ac49b70e..000000000000 --- a/drivers/staging/bcm/HostMIBSInterface.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef _HOST_MIBSINTERFACE_H -#define _HOST_MIBSINTERFACE_H - -/* - * Copyright (c) 2007 Beceem Communications Pvt. Ltd - * File Name: HostMIBSInterface.h - * Abstract: This file contains DS used by the Host to update the Host - * statistics used for the MIBS. - */ - -#define MIBS_MAX_CLASSIFIERS 100 -#define MIBS_MAX_PHSRULES 100 -#define MIBS_MAX_SERVICEFLOWS 17 -#define MIBS_MAX_IP_RANGE_LENGTH 4 -#define MIBS_MAX_PORT_RANGE 4 -#define MIBS_MAX_PROTOCOL_LENGTH 32 -#define MIBS_MAX_PHS_LENGTHS 255 -#define MIBS_IPV6_ADDRESS_SIZEINBYTES 0x10 -#define MIBS_IP_LENGTH_OF_ADDRESS 4 -#define MIBS_MAX_HIST_ENTRIES 12 -#define MIBS_PKTSIZEHIST_RANGE 128 - -union bcm_mibs_ip_addr { - struct { - /* Source Ip Address Range */ - unsigned long ulIpv4Addr[MIBS_MAX_IP_RANGE_LENGTH]; - /* Source Ip Mask Address Range */ - unsigned long ulIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH]; - }; - struct { - /* Source Ip Address Range */ - unsigned long ulIpv6Addr[MIBS_MAX_IP_RANGE_LENGTH * 4]; - /* Source Ip Mask Address Range */ - unsigned long ulIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * 4]; - }; - struct { - unsigned char ucIpv4Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IP_LENGTH_OF_ADDRESS]; - unsigned char ucIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IP_LENGTH_OF_ADDRESS]; - }; - struct { - unsigned char ucIpv6Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; - unsigned char ucIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES]; - }; -}; - -struct bcm_mibs_host_info { - u64 GoodTransmits; - u64 GoodReceives; - /* this to keep track of the Tx and Rx MailBox Registers. */ - unsigned long NumDesUsed; - unsigned long CurrNumFreeDesc; - unsigned long PrevNumFreeDesc; - /* to keep track the no of byte received */ - unsigned long PrevNumRcevBytes; - unsigned long CurrNumRcevBytes; - /* QOS Related */ - unsigned long BEBucketSize; - unsigned long rtPSBucketSize; - unsigned long LastTxQueueIndex; - bool TxOutofDescriptors; - bool TimerActive; - u32 u32TotalDSD; - u32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; - u32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES]; -}; - -struct bcm_mibs_classifier_rule { - unsigned long ulSFID; - unsigned char ucReserved[2]; - u16 uiClassifierRuleIndex; - bool bUsed; - unsigned short usVCID_Value; - u8 u8ClassifierRulePriority; - union bcm_mibs_ip_addr stSrcIpAddress; - /* IP Source Address Length */ - unsigned char ucIPSourceAddressLength; - union bcm_mibs_ip_addr stDestIpAddress; - /* IP Destination Address Length */ - unsigned char ucIPDestinationAddressLength; - unsigned char ucIPTypeOfServiceLength; - unsigned char ucTosLow; - unsigned char ucTosHigh; - unsigned char ucTosMask; - unsigned char ucProtocolLength; - unsigned char ucProtocol[MIBS_MAX_PROTOCOL_LENGTH]; - unsigned short usSrcPortRangeLo[MIBS_MAX_PORT_RANGE]; - unsigned short usSrcPortRangeHi[MIBS_MAX_PORT_RANGE]; - unsigned char ucSrcPortRangeLength; - unsigned short usDestPortRangeLo[MIBS_MAX_PORT_RANGE]; - unsigned short usDestPortRangeHi[MIBS_MAX_PORT_RANGE]; - unsigned char ucDestPortRangeLength; - bool bProtocolValid; - bool bTOSValid; - bool bDestIpValid; - bool bSrcIpValid; - unsigned char ucDirection; - bool bIpv6Protocol; - u32 u32PHSRuleID; -}; - -struct bcm_mibs_phs_rule { - unsigned long ulSFID; - u8 u8PHSI; - u8 u8PHSFLength; - u8 u8PHSF[MIBS_MAX_PHS_LENGTHS]; - u8 u8PHSMLength; - u8 u8PHSM[MIBS_MAX_PHS_LENGTHS]; - u8 u8PHSS; - u8 u8PHSV; - u8 reserved[5]; - long PHSModifiedBytes; - unsigned long PHSModifiedNumPackets; - unsigned long PHSErrorNumPackets; -}; - -struct bcm_mibs_parameters { - u32 wmanIfSfid; - u32 wmanIfCmnCpsSfState; - u32 wmanIfCmnCpsMaxSustainedRate; - u32 wmanIfCmnCpsMaxTrafficBurst; - u32 wmanIfCmnCpsMinReservedRate; - u32 wmanIfCmnCpsToleratedJitter; - u32 wmanIfCmnCpsMaxLatency; - u32 wmanIfCmnCpsFixedVsVariableSduInd; - u32 wmanIfCmnCpsSduSize; - u32 wmanIfCmnCpsSfSchedulingType; - u32 wmanIfCmnCpsArqEnable; - u32 wmanIfCmnCpsArqWindowSize; - u32 wmanIfCmnCpsArqBlockLifetime; - u32 wmanIfCmnCpsArqSyncLossTimeout; - u32 wmanIfCmnCpsArqDeliverInOrder; - u32 wmanIfCmnCpsArqRxPurgeTimeout; - u32 wmanIfCmnCpsArqBlockSize; - u32 wmanIfCmnCpsMinRsvdTolerableRate; - u32 wmanIfCmnCpsReqTxPolicy; - u32 wmanIfCmnSfCsSpecification; - u32 wmanIfCmnCpsTargetSaid; -}; - -struct bcm_mibs_table { - unsigned long ulSFID; - unsigned short usVCID_Value; - unsigned int uiThreshold; - u8 u8TrafficPriority; - bool bValid; - bool bActive; - bool bActivateRequestSent; - u8 u8QueueType; - unsigned int uiMaxBucketSize; - unsigned int uiCurrentQueueDepthOnTarget; - unsigned int uiCurrentBytesOnHost; - unsigned int uiCurrentPacketsOnHost; - unsigned int uiDroppedCountBytes; - unsigned int uiDroppedCountPackets; - unsigned int uiSentBytes; - unsigned int uiSentPackets; - unsigned int uiCurrentDrainRate; - unsigned int uiThisPeriodSentBytes; - u64 liDrainCalculated; - unsigned int uiCurrentTokenCount; - u64 liLastUpdateTokenAt; - unsigned int uiMaxAllowedRate; - unsigned int NumOfPacketsSent; - unsigned char ucDirection; - unsigned short usCID; - struct bcm_mibs_parameters stMibsExtServiceFlowTable; - unsigned int uiCurrentRxRate; - unsigned int uiThisPeriodRxBytes; - unsigned int uiTotalRxBytes; - unsigned int uiTotalTxBytes; -}; - -struct bcm_mibs_dropped_cntrl_msg { - unsigned long cm_responses; - unsigned long cm_control_newdsx_multiclassifier_resp; - unsigned long link_control_resp; - unsigned long status_rsp; - unsigned long stats_pointer_resp; - unsigned long idle_mode_status; - unsigned long auth_ss_host_msg; - unsigned long low_priority_message; -}; - -struct bcm_host_stats_mibs { - struct bcm_mibs_host_info stHostInfo; - struct bcm_mibs_classifier_rule astClassifierTable[MIBS_MAX_CLASSIFIERS]; - struct bcm_mibs_table astSFtable[MIBS_MAX_SERVICEFLOWS]; - struct bcm_mibs_phs_rule astPhsRulesTable[MIBS_MAX_PHSRULES]; - struct bcm_mibs_dropped_cntrl_msg stDroppedAppCntrlMsgs; -}; - -#endif diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c deleted file mode 100644 index 27f3f416f184..000000000000 --- a/drivers/staging/bcm/IPv6Protocol.c +++ /dev/null @@ -1,476 +0,0 @@ -#include "headers.h" - -static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - struct bcm_ipv6_hdr *pstIpv6Header); -static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - struct bcm_ipv6_hdr *pstIpv6Header); -static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header); - -static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload, - UCHAR *pucNextHeader, bool *bParseDone, USHORT *pusPayloadLength) -{ - UCHAR *pucRetHeaderPtr = NULL; - UCHAR *pucPayloadPtr = NULL; - USHORT usNextHeaderOffset = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if ((ppucPayload == NULL) || (*pusPayloadLength == 0) || - (*bParseDone)) { - *bParseDone = TRUE; - return NULL; - } - - pucRetHeaderPtr = *ppucPayload; - pucPayloadPtr = *ppucPayload; - - if (!pucRetHeaderPtr || !pucPayloadPtr) { - *bParseDone = TRUE; - return NULL; - } - - /* Get the Nextt Header Type */ - *bParseDone = false; - - - switch (*pucNextHeader) { - case IPV6HDR_TYPE_HOPBYHOP: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nIPv6 HopByHop Header"); - usNextHeaderOffset += sizeof(struct bcm_ipv6_options_hdr); - break; - - case IPV6HDR_TYPE_ROUTING: - { - struct bcm_ipv6_routing_hdr *pstIpv6RoutingHeader; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nIPv6 Routing Header"); - pstIpv6RoutingHeader = - (struct bcm_ipv6_routing_hdr *)pucPayloadPtr; - usNextHeaderOffset += sizeof(struct bcm_ipv6_routing_hdr); - usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * - IPV6_ADDRESS_SIZEINBYTES; - } - break; - - case IPV6HDR_TYPE_FRAGMENTATION: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nIPv6 Fragmentation Header"); - usNextHeaderOffset += sizeof(struct bcm_ipv6_fragment_hdr); - break; - - case IPV6HDR_TYPE_DESTOPTS: - { - struct bcm_ipv6_dest_options_hdr *pstIpv6DestOptsHdr = - (struct bcm_ipv6_dest_options_hdr *)pucPayloadPtr; - int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nIPv6 DestOpts Header Header"); - usNextHeaderOffset += sizeof(struct bcm_ipv6_dest_options_hdr); - usNextHeaderOffset += nTotalOptions * - IPV6_DESTOPTS_HDR_OPTIONSIZE; - } - break; - - - case IPV6HDR_TYPE_AUTHENTICATION: - { - struct bcm_ipv6_authentication_hdr *pstIpv6AuthHdr = - (struct bcm_ipv6_authentication_hdr *)pucPayloadPtr; - int nHdrLen = pstIpv6AuthHdr->ucLength; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nIPv6 Authentication Header"); - usNextHeaderOffset += nHdrLen * 4; - } - break; - - case IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nIPv6 Encrypted Security Payload Header"); - *bParseDone = TRUE; - break; - - case IPV6_ICMP_HDR_TYPE: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nICMP Header"); - *bParseDone = TRUE; - break; - - case TCP_HEADER_TYPE: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nTCP Header"); - *bParseDone = TRUE; - break; - - case UDP_HEADER_TYPE: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nUDP Header"); - *bParseDone = TRUE; - break; - - default: - *bParseDone = TRUE; - break; - } - - if (*bParseDone == false) { - if (*pusPayloadLength <= usNextHeaderOffset) { - *bParseDone = TRUE; - } else { - *pucNextHeader = *pucPayloadPtr; - pucPayloadPtr += usNextHeaderOffset; - (*pusPayloadLength) -= usNextHeaderOffset; - } - - } - - *ppucPayload = pucPayloadPtr; - return pucRetHeaderPtr; -} - - -static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort, - USHORT *pusDestPort, USHORT usPayloadLength, UCHAR ucNextHeader) -{ - UCHAR *pIpv6HdrScanContext = pucPayload; - bool bDone = false; - UCHAR ucHeaderType = 0; - UCHAR *pucNextHeader = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (!pucPayload || (usPayloadLength == 0)) - return 0; - - *pusSrcPort = *pusDestPort = 0; - ucHeaderType = ucNextHeader; - while (!bDone) { - pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext, - &ucHeaderType, - &bDone, - &usPayloadLength); - if (bDone) { - if ((ucHeaderType == TCP_HEADER_TYPE) || - (ucHeaderType == UDP_HEADER_TYPE)) { - *pusSrcPort = *((PUSHORT)(pucNextHeader)); - *pusDestPort = *((PUSHORT)(pucNextHeader+2)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nProtocol Ports - Src Port :0x%x Dest Port : 0x%x", - ntohs(*pusSrcPort), - ntohs(*pusDestPort)); - } - break; - - } - } - return ucHeaderType; -} - - -/* - * Arg 1 struct bcm_mini_adapter *Adapter is a pointer ot the driver control - * structure - * Arg 2 PVOID pcIpHeader is a pointer to the IP header of the packet - */ -USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, - struct bcm_classifier_rule *pstClassifierRule) -{ - USHORT ushDestPort = 0; - USHORT ushSrcPort = 0; - UCHAR ucNextProtocolAboveIP = 0; - struct bcm_ipv6_hdr *pstIpv6Header = NULL; - bool bClassificationSucceed = false; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "IpVersion6 ==========>\n"); - - pstIpv6Header = pcIpHeader; - - DumpIpv6Header(pstIpv6Header); - - /* - * Try to get the next higher layer protocol - * and the Ports Nos if TCP or UDP - */ - ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + - sizeof(struct bcm_ipv6_hdr)), - &ushSrcPort, - &ushDestPort, - pstIpv6Header->usPayloadLength, - pstIpv6Header->ucNextHeader); - - do { - if (pstClassifierRule->ucDirection == 0) { - /* - * cannot be processed for classification. - * it is a down link connection - */ - break; - } - - if (!pstClassifierRule->bIpv6Protocol) { - /* - * We are looking for Ipv6 Classifiers - * Lets ignore this classifier and try the next one - */ - break; - } - - bClassificationSucceed = MatchSrcIpv6Address(pstClassifierRule, - pstIpv6Header); - if (!bClassificationSucceed) - break; - - bClassificationSucceed = MatchDestIpv6Address(pstClassifierRule, - pstIpv6Header); - if (!bClassificationSucceed) - break; - - /* - * Match the protocol type. - * For IPv6 the next protocol at end of - * Chain of IPv6 prot headers - */ - bClassificationSucceed = MatchProtocol(pstClassifierRule, - ucNextProtocolAboveIP); - if (!bClassificationSucceed) - break; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nIPv6 Protocol Matched"); - - if ((ucNextProtocolAboveIP == TCP_HEADER_TYPE) || - (ucNextProtocolAboveIP == UDP_HEADER_TYPE)) { - /* Match Src Port */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nIPv6 Source Port:%x\n", - ntohs(ushSrcPort)); - bClassificationSucceed = MatchSrcPort(pstClassifierRule, - ntohs(ushSrcPort)); - if (!bClassificationSucceed) - break; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, "\nIPv6 Src Port Matched"); - - /* Match Dest Port */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nIPv6 Destination Port:%x\n", - ntohs(ushDestPort)); - bClassificationSucceed = MatchDestPort(pstClassifierRule, - ntohs(ushDestPort)); - if (!bClassificationSucceed) - break; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "\nIPv6 Dest Port Matched"); - } - } while (0); - - if (bClassificationSucceed == TRUE) { - INT iMatchedSFQueueIndex = 0; - - iMatchedSFQueueIndex = SearchSfid(Adapter, - pstClassifierRule->ulSFID); - if ((iMatchedSFQueueIndex >= NO_OF_QUEUES) || - (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == false)) - bClassificationSucceed = false; - } - - return bClassificationSucceed; -} - - -static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - struct bcm_ipv6_hdr *pstIpv6Header) -{ - UINT uiLoopIndex = 0; - UINT uiIpv6AddIndex = 0; - UINT uiIpv6AddrNoLongWords = 4; - ULONG aulSrcIP[4]; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - union u_ip_address *src_addr = &pstClassifierRule->stSrcIpAddress; - - /* - * This is the no. of Src Addresses ie Range of IP Addresses contained - * in the classifier rule for which we need to match - */ - UINT uiCountIPSrcAddresses = - (UINT)pstClassifierRule->ucIPSourceAddressLength; - - - if (uiCountIPSrcAddresses == 0) - return TRUE; - - - /* First Convert the Ip Address in the packet to Host Endian order */ - for (uiIpv6AddIndex = 0; - uiIpv6AddIndex < uiIpv6AddrNoLongWords; - uiIpv6AddIndex++) - aulSrcIP[uiIpv6AddIndex] = - ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]); - - for (uiLoopIndex = 0; - uiLoopIndex < uiCountIPSrcAddresses; - uiLoopIndex += uiIpv6AddrNoLongWords) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "\n Src Ipv6 Address In Received Packet :\n "); - DumpIpv6Address(aulSrcIP); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "\n Src Ipv6 Mask In Classifier Rule:\n"); - DumpIpv6Address(&src_addr->ulIpv6Mask[uiLoopIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "\n Src Ipv6 Address In Classifier Rule :\n"); - DumpIpv6Address(&src_addr->ulIpv6Addr[uiLoopIndex]); - - for (uiIpv6AddIndex = 0; - uiIpv6AddIndex < uiIpv6AddrNoLongWords; - uiIpv6AddIndex++) { - if ((src_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & - aulSrcIP[uiIpv6AddIndex]) != - src_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) { - /* - * Match failed for current Ipv6 Address - * Try next Ipv6 Address - */ - break; - } - - if (uiIpv6AddIndex == uiIpv6AddrNoLongWords-1) { - /* Match Found */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "Ipv6 Src Ip Address Matched\n"); - return TRUE; - } - } - } - return false; -} - -static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule, - struct bcm_ipv6_hdr *pstIpv6Header) -{ - UINT uiLoopIndex = 0; - UINT uiIpv6AddIndex = 0; - UINT uiIpv6AddrNoLongWords = 4; - ULONG aulDestIP[4]; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - union u_ip_address *dest_addr = &pstClassifierRule->stDestIpAddress; - - /* - * This is the no. of Destination Addresses - * ie Range of IP Addresses contained in the classifier rule - * for which we need to match - */ - UINT uiCountIPDestinationAddresses = - (UINT)pstClassifierRule->ucIPDestinationAddressLength; - - if (uiCountIPDestinationAddresses == 0) - return TRUE; - - - /* First Convert the Ip Address in the packet to Host Endian order */ - for (uiIpv6AddIndex = 0; - uiIpv6AddIndex < uiIpv6AddrNoLongWords; - uiIpv6AddIndex++) - aulDestIP[uiIpv6AddIndex] = - ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]); - - for (uiLoopIndex = 0; - uiLoopIndex < uiCountIPDestinationAddresses; - uiLoopIndex += uiIpv6AddrNoLongWords) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "\n Destination Ipv6 Address In Received Packet :\n "); - DumpIpv6Address(aulDestIP); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "\n Destination Ipv6 Mask In Classifier Rule :\n"); - DumpIpv6Address(&dest_addr->ulIpv6Mask[uiLoopIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "\n Destination Ipv6 Address In Classifier Rule :\n"); - DumpIpv6Address(&dest_addr->ulIpv6Addr[uiLoopIndex]); - - for (uiIpv6AddIndex = 0; - uiIpv6AddIndex < uiIpv6AddrNoLongWords; - uiIpv6AddIndex++) { - if ((dest_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & - aulDestIP[uiIpv6AddIndex]) != - dest_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) { - /* - * Match failed for current Ipv6 Address. - * Try next Ipv6 Address - */ - break; - } - - if (uiIpv6AddIndex == uiIpv6AddrNoLongWords-1) { - /* Match Found */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, - DBG_LVL_ALL, - "Ipv6 Destination Ip Address Matched\n"); - return TRUE; - } - } - } - return false; - -} - -VOID DumpIpv6Address(ULONG *puIpv6Address) -{ - UINT uiIpv6AddrNoLongWords = 4; - UINT uiIpv6AddIndex = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - for (uiIpv6AddIndex = 0; - uiIpv6AddIndex < uiIpv6AddrNoLongWords; - uiIpv6AddIndex++) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - ":%lx", puIpv6Address[uiIpv6AddIndex]); - } - -} - -static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header) -{ - UCHAR ucVersion; - UCHAR ucPrio; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "----Ipv6 Header---"); - ucVersion = pstIpv6Header->ucVersionPrio & 0xf0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Version : %x\n", ucVersion); - ucPrio = pstIpv6Header->ucVersionPrio & 0x0f; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Priority : %x\n", ucPrio); - /* - * BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - * "Flow Label : %x\n",(pstIpv6Header->ucVersionPrio &0xf0); - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Payload Length : %x\n", - ntohs(pstIpv6Header->usPayloadLength)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Next Header : %x\n", pstIpv6Header->ucNextHeader); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Hop Limit : %x\n", pstIpv6Header->ucHopLimit); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Src Address :\n"); - DumpIpv6Address(pstIpv6Header->ulSrcIpAddress); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "Dest Address :\n"); - DumpIpv6Address(pstIpv6Header->ulDestIpAddress); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, - "----Ipv6 Header End---"); - - -} diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h deleted file mode 100644 index 96b36a579af2..000000000000 --- a/drivers/staging/bcm/IPv6ProtocolHdr.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _IPV6_PROTOCOL_DEFINES_ -#define _IPV6_PROTOCOL_DEFINES_ - -#define IPV6HDR_TYPE_HOPBYHOP 0x0 -#define IPV6HDR_TYPE_ROUTING 0x2B -#define IPV6HDR_TYPE_FRAGMENTATION 0x2C -#define IPV6HDR_TYPE_DESTOPTS 0x3c -#define IPV6HDR_TYPE_AUTHENTICATION 0x33 -#define IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD 0x34 -#define MASK_IPV6_CS_SPEC 0x2 - -#define TCP_HEADER_TYPE 0x6 -#define UDP_HEADER_TYPE 0x11 -#define IPV6_ICMP_HDR_TYPE 0x2 -#define IPV6_FLOWLABEL_BITOFFSET 9 - -#define IPV6_MAX_CHAINEDHDR_BUFFBYTES 0x64 -/* - * Size of Dest Options field of Destinations Options Header - * in bytes. - */ -#define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8 - -struct bcm_ipv6_hdr { - unsigned char ucVersionPrio; - unsigned char aucFlowLabel[3]; - unsigned short usPayloadLength; - unsigned char ucNextHeader; - unsigned char ucHopLimit; - unsigned long ulSrcIpAddress[4]; - unsigned long ulDestIpAddress[4]; -}; - -struct bcm_ipv6_routing_hdr { - unsigned char ucNextHeader; - unsigned char ucRoutingType; - unsigned char ucNumAddresses; - unsigned char ucNextAddress; - unsigned long ulReserved; -}; - -struct bcm_ipv6_fragment_hdr { - unsigned char ucNextHeader; - unsigned char ucReserved; - unsigned short usFragmentOffset; - unsigned long ulIdentification; -}; - -struct bcm_ipv6_dest_options_hdr { - unsigned char ucNextHeader; - unsigned char ucHdrExtLen; - unsigned char ucDestOptions[6]; -}; - -struct bcm_ipv6_options_hdr { - unsigned char ucNextHeader; - unsigned char ucMisc[3]; - unsigned long ulJumboPayloadLen; -}; - -struct bcm_ipv6_authentication_hdr { - unsigned char ucNextHeader; - unsigned char ucLength; - unsigned short usReserved; - unsigned long ulSecurityParametersIndex; -}; - -enum bcm_ipaddr_context { - eSrcIpAddress, - eDestIpAddress -}; - -/* Function Prototypes */ - -unsigned short IpVersion6(struct bcm_mini_adapter *Adapter, /* < Pointer to the driver control structure */ - void *pcIpHeader, /* psAdapter; */ - char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - - if (!buff) - return -ENOMEM; - - while (1) { - oldfs = get_fs(); - set_fs(get_ds()); - len = vfs_read(flp, (void __force __user *)buff, - MAX_TRANSFER_CTRL_BYTE_USB, &pos); - set_fs(oldfs); - if (len <= 0) { - if (len < 0) - errno = len; - else - errno = 0; - break; - } - /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, - * DBG_LVL_ALL, buff, - * MAX_TRANSFER_CTRL_BYTE_USB); - */ - errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len); - if (errno) - break; - on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB; - } - - kfree(buff); - return errno; -} - -int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, - unsigned int on_chip_loc) -{ - char *buff, *buff_readback; - unsigned int reg = 0; - mm_segment_t oldfs = {0}; - int errno = 0, len = 0, is_config_file = 0; - loff_t pos = 0; - static int fw_down; - INT Status = STATUS_SUCCESS; - struct bcm_interface_adapter *psIntfAdapter = arg; - int bytes; - - buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); - buff_readback = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); - if (!buff || !buff_readback) { - kfree(buff); - kfree(buff_readback); - - return -ENOMEM; - } - - is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR) ? 1 : 0; - - while (1) { - oldfs = get_fs(); - set_fs(get_ds()); - len = vfs_read(flp, (void __force __user *)buff, - MAX_TRANSFER_CTRL_BYTE_USB, &pos); - set_fs(oldfs); - fw_down++; - - if (len <= 0) { - if (len < 0) - errno = len; - else - errno = 0; - break; - } - - bytes = InterfaceRDM(psIntfAdapter, on_chip_loc, - buff_readback, len); - if (bytes < 0) { - Status = bytes; - goto exit; - } - reg++; - if ((len-sizeof(unsigned int)) < 4) { - if (memcmp(buff_readback, buff, len)) { - Status = -EIO; - goto exit; - } - } else { - len -= 4; - - while (len) { - if (*(unsigned int *)&buff_readback[len] != - *(unsigned int *)&buff[len]) { - Status = -EIO; - goto exit; - } - len -= 4; - } - } - on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB; - } /* End of while(1) */ - -exit: - kfree(buff); - kfree(buff_readback); - return Status; -} - -static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, - struct bcm_firmware_info *psFwInfo) -{ - int retval = STATUS_SUCCESS; - B_UINT32 value = 0; - - if (Adapter->pstargetparams == NULL) { - Adapter->pstargetparams = - kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); - if (Adapter->pstargetparams == NULL) - return -ENOMEM; - } - - if (psFwInfo->u32FirmwareLength != sizeof(struct bcm_target_params)) - return -EIO; - - retval = copy_from_user(Adapter->pstargetparams, - psFwInfo->pvMappedFirmwareAddress, - psFwInfo->u32FirmwareLength); - if (retval) { - kfree(Adapter->pstargetparams); - Adapter->pstargetparams = NULL; - return -EFAULT; - } - - /* Parse the structure and then Download the Firmware */ - beceem_parse_target_struct(Adapter); - - /* Initializing the NVM. */ - BcmInitNVM(Adapter); - retval = InitLedSettings(Adapter); - - if (retval) - return retval; - - if (Adapter->LEDInfo.led_thread_running & - BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->LEDInfo.bLedInitDone = false; - Adapter->DriverState = DRIVER_INIT; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - - if (Adapter->LEDInfo.led_thread_running & - BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = FW_DOWNLOAD; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - - /* Initialize the DDR Controller */ - retval = ddr_init(Adapter); - if (retval) - return retval; - - value = 0; - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, - &value, sizeof(value)); - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, - &value, sizeof(value)); - - if (Adapter->eNVMType == NVM_FLASH) { - retval = PropagateCalParamsFromFlashToMemory(Adapter); - if (retval) - return retval; - } - - retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, - sizeof(struct bcm_target_params), CONFIG_BEGIN_ADDR); - - if (retval) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, - MP_INIT, DBG_LVL_ALL, - "configuration file not downloaded properly"); - else - Adapter->bCfgDownloaded = TRUE; - - return retval; -} - -int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, - struct bcm_firmware_info *psFwInfo) -{ - int retval = STATUS_SUCCESS; - PUCHAR buff = NULL; - - /* Config File is needed for the Driver to download the Config file and - * Firmware. Check for the Config file to be first to be sent from the - * Application - */ - atomic_set(&Adapter->uiMBupdate, false); - if (!Adapter->bCfgDownloaded && - psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) { - /* Can't Download Firmware. */ - return -EINVAL; - } - - /* If Config File, Finish the DDR Settings and then Download CFG File */ - if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) { - retval = bcm_download_config_file(Adapter, psFwInfo); - } else { - buff = kzalloc(psFwInfo->u32FirmwareLength, GFP_KERNEL); - if (buff == NULL) - return -ENOMEM; - - retval = copy_from_user(buff, - psFwInfo->pvMappedFirmwareAddress, - psFwInfo->u32FirmwareLength); - if (retval != STATUS_SUCCESS) { - retval = -EFAULT; - goto error; - } - - retval = buffDnldVerify(Adapter, - buff, - psFwInfo->u32FirmwareLength, - psFwInfo->u32StartingAddress); - - if (retval != STATUS_SUCCESS) - goto error; - } - -error: - kfree(buff); - return retval; -} - -static INT buffDnld(struct bcm_mini_adapter *Adapter, - PUCHAR mappedbuffer, UINT u32FirmwareLength, - ULONG u32StartingAddress) -{ - unsigned int len = 0; - int retval = STATUS_SUCCESS; - - len = u32FirmwareLength; - - while (u32FirmwareLength) { - len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); - retval = wrm(Adapter, u32StartingAddress, mappedbuffer, len); - - if (retval) - break; - u32StartingAddress += len; - u32FirmwareLength -= len; - mappedbuffer += len; - } - return retval; -} - -static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, - PUCHAR mappedbuffer, UINT u32FirmwareLength, - ULONG u32StartingAddress) -{ - UINT len = u32FirmwareLength; - INT retval = STATUS_SUCCESS; - PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); - int bytes; - - if (NULL == readbackbuff) - return -ENOMEM; - - while (u32FirmwareLength && !retval) { - len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); - bytes = rdm(Adapter, u32StartingAddress, readbackbuff, len); - - if (bytes < 0) { - retval = bytes; - break; - } - - if (memcmp(readbackbuff, mappedbuffer, len) != 0) { - pr_err("%s() failed. The firmware doesn't match what was written", - __func__); - retval = -EIO; - } - - u32StartingAddress += len; - u32FirmwareLength -= len; - mappedbuffer += len; - - } /* end of while (u32FirmwareLength && !retval) */ - kfree(readbackbuff); - return retval; -} - -INT buffDnldVerify(struct bcm_mini_adapter *Adapter, - unsigned char *mappedbuffer, - unsigned int u32FirmwareLength, - unsigned long u32StartingAddress) -{ - INT status = STATUS_SUCCESS; - - status = buffDnld(Adapter, mappedbuffer, - u32FirmwareLength, u32StartingAddress); - if (status != STATUS_SUCCESS) - goto error; - - status = buffRdbkVerify(Adapter, mappedbuffer, - u32FirmwareLength, u32StartingAddress); - if (status != STATUS_SUCCESS) - goto error; -error: - return status; -} diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c deleted file mode 100644 index 612c89fba341..000000000000 --- a/drivers/staging/bcm/InterfaceIdleMode.c +++ /dev/null @@ -1,274 +0,0 @@ -#include "headers.h" - -/* -Function: InterfaceIdleModeWakeup - -Description: This is the hardware specific Function for - waking up HW device from Idle mode. - A software abort pattern is written to the - device to wake it and necessary power state - transitions from host are performed here. - -Input parameters: IN struct bcm_mini_adapter *Adapter - - Miniport Adapter Context - -Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface - was successful. - Other - If an error occurred. -*/ - -/* -Function: InterfaceIdleModeRespond - -Description: This is the hardware specific Function for - responding to Idle mode request from target. - Necessary power state transitions from host for - idle mode or other device specific initializations - are performed here. - -Input parameters: IN struct bcm_mini_adapter * Adapter - - Miniport Adapter Context - -Return: BCM_STATUS_SUCCESS - If Idle mode response related - HW configuration was successful. - Other - If an error occurred. -*/ - -/* -"dmem bfc02f00 100" tells how many time device went in Idle mode. -this value will be at address bfc02fa4.just before value d0ea1dle. - -Set time value by writing at bfc02f98 7d0 - -checking the Ack timer expire on kannon by running command -d qcslog .. if it shows e means host has not send response -to f/w with in 200 ms. Response should be -send to f/w with in 200 ms after the Idle/Shutdown req issued - -*/ - - -int InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, - unsigned int *puiBuffer) -{ - int status = STATUS_SUCCESS; - unsigned int uiRegRead = 0; - int bytes; - - if (ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD) { - if (ntohl(*(puiBuffer+1)) == 0) { - - status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, - &uiRegRead, sizeof(uiRegRead)); - if (status) - return status; - - if (Adapter->ulPowerSaveMode == - DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { - uiRegRead = 0x00000000; - status = wrmalt(Adapter, - DEBUG_INTERRUPT_GENERATOR_REGISTOR, - &uiRegRead, sizeof(uiRegRead)); - if (status) - return status; - } - /* Below Register should not br read in case of - * Manual and Protocol Idle mode */ - else if (Adapter->ulPowerSaveMode != - DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { - /* clear on read Register */ - bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG0, - &uiRegRead, sizeof(uiRegRead)); - if (bytes < 0) { - status = bytes; - return status; - } - /* clear on read Register */ - bytes = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG1, - &uiRegRead, sizeof(uiRegRead)); - if (bytes < 0) { - status = bytes; - return status; - } - } - - /* Set Idle Mode Flag to False and - * Clear IdleMode reg. */ - Adapter->IdleMode = false; - Adapter->bTriedToWakeUpFromlowPowerMode = false; - - wake_up(&Adapter->lowpower_mode_wait_queue); - - } else { - if (TRUE == Adapter->IdleMode) - return status; - - uiRegRead = 0; - - if (Adapter->chip_id == BCS220_2 || - Adapter->chip_id == BCS220_2BC || - Adapter->chip_id == BCS250_BC || - Adapter->chip_id == BCS220_3) { - - bytes = rdmalt(Adapter, HPM_CONFIG_MSW, - &uiRegRead, sizeof(uiRegRead)); - if (bytes < 0) { - status = bytes; - return status; - } - - - uiRegRead |= (1<<17); - - status = wrmalt(Adapter, HPM_CONFIG_MSW, - &uiRegRead, sizeof(uiRegRead)); - if (status) - return status; - } - SendIdleModeResponse(Adapter); - } - } else if (ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG) { - OverrideServiceFlowParams(Adapter, puiBuffer); - } - return status; -} - -static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, - unsigned int Pattern) -{ - int status = STATUS_SUCCESS; - unsigned int value; - unsigned int chip_id; - unsigned long timeout = 0, itr = 0; - - int lenwritten = 0; - unsigned char aucAbortPattern[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF}; - struct bcm_interface_adapter *psInterfaceAdapter = - Adapter->pvInterfaceAdapter; - - /* Abort Bus suspend if its already suspended */ - if ((TRUE == psInterfaceAdapter->bSuspended) && - (TRUE == Adapter->bDoSuspend)) - status = usb_autopm_get_interface( - psInterfaceAdapter->interface); - - if ((Adapter->ulPowerSaveMode == - DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) || - (Adapter->ulPowerSaveMode == - DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) { - /* write the SW abort pattern. */ - status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, - &Pattern, sizeof(Pattern)); - if (status) - return status; - } - - if (Adapter->ulPowerSaveMode == - DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { - value = 0x80000000; - status = wrmalt(Adapter, - DEBUG_INTERRUPT_GENERATOR_REGISTOR, - &value, sizeof(value)); - if (status) - return status; - } else if (Adapter->ulPowerSaveMode != - DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { - /* - * Get a Interrupt Out URB and send 8 Bytes Down - * To be Done in Thread Context. - * Not using Asynchronous Mechanism. - */ - status = usb_interrupt_msg(psInterfaceAdapter->udev, - usb_sndintpipe(psInterfaceAdapter->udev, - psInterfaceAdapter->sIntrOut.int_out_endpointAddr), - aucAbortPattern, - 8, - &lenwritten, - 5000); - if (status) - return status; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - IDLE_MODE, DBG_LVL_ALL, - "NOB Sent down :%d", lenwritten); - - /* mdelay(25); */ - - timeout = jiffies + msecs_to_jiffies(50); - while (time_after(timeout, jiffies)) { - itr++; - rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT)); - if (0xbece3200 == (chip_id&~(0xF0))) - chip_id = chip_id&~(0xF0); - if (chip_id == Adapter->chip_id) - break; - } - if (time_before(timeout, jiffies)) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - IDLE_MODE, DBG_LVL_ALL, - "Not able to read chip-id even after 25 msec"); - else - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - IDLE_MODE, DBG_LVL_ALL, - "Number of completed iteration to read chip-id :%lu", itr); - - status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, - &Pattern, sizeof(status)); - if (status) - return status; - } - return status; -} -int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter) -{ - if (Adapter->bTriedToWakeUpFromlowPowerMode) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - IDLE_MODE, DBG_LVL_ALL, - "Wake up already attempted.. ignoring\n"); - } else { - Adapter->bTriedToWakeUpFromlowPowerMode = TRUE; - InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern); - - } - return 0; -} - -void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiRegVal = 0; - INT Status = 0; - int bytes; - - if (Adapter->ulPowerSaveMode == - DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) { - /* clear idlemode interrupt. */ - uiRegVal = 0; - Status = wrmalt(Adapter, - DEBUG_INTERRUPT_GENERATOR_REGISTOR, - &uiRegVal, sizeof(uiRegVal)); - if (Status) - return; - } - - else { - -/* clear Interrupt EP registers. */ - bytes = rdmalt(Adapter, - DEVICE_INT_OUT_EP_REG0, - &uiRegVal, sizeof(uiRegVal)); - if (bytes < 0) { - Status = bytes; - return; - } - - bytes = rdmalt(Adapter, - DEVICE_INT_OUT_EP_REG1, - &uiRegVal, sizeof(uiRegVal)); - if (bytes < 0) { - Status = bytes; - return; - } - } -} - diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h deleted file mode 100644 index 2ef64003aa89..000000000000 --- a/drivers/staging/bcm/InterfaceIdleMode.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _INTERFACE_IDLEMODE_H -#define _INTERFACE_IDLEMODE_H - -INT InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter); - -INT InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, - unsigned int *puiBuffer); - -VOID InterfaceWriteIdleModeWakePattern(struct bcm_mini_adapter *Adapter); - -INT InterfaceWakeUp(struct bcm_mini_adapter *Adapter); - -VOID InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter); -#endif - diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c deleted file mode 100644 index 9eaffd884a4c..000000000000 --- a/drivers/staging/bcm/InterfaceInit.c +++ /dev/null @@ -1,729 +0,0 @@ -#include "headers.h" -#include -static struct usb_device_id InterfaceUsbtable[] = { - { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_SYM) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_TU25) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_226) }, - { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_326) }, - { } -}; -MODULE_DEVICE_TABLE(usb, InterfaceUsbtable); - -static int debug = -1; -module_param(debug, int, 0600); -MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); - -static const u32 default_msg = - NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK - | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR - | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN; - -static int InterfaceAdapterInit(struct bcm_interface_adapter *Adapter); - -static void InterfaceAdapterFree(struct bcm_interface_adapter *psIntfAdapter) -{ - int i = 0; - struct bcm_mini_adapter *ps_ad = psIntfAdapter->psAdapter; - - /* Wake up the wait_queue... */ - if (ps_ad->LEDInfo.led_thread_running & - BCM_LED_THREAD_RUNNING_ACTIVELY) { - ps_ad->DriverState = DRIVER_HALT; - wake_up(&ps_ad->LEDInfo.notify_led_event); - } - reset_card_proc(ps_ad); - - /* - * worst case time taken by the RDM/WRM will be 5 sec. will check after - * every 100 ms to accertain the device is not being accessed. After - * this No RDM/WRM should be made. - */ - while (ps_ad->DeviceAccess) { - BCM_DEBUG_PRINT(ps_ad, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, "Device is being accessed.\n"); - msleep(100); - } - /* Free interrupt URB */ - /* ps_ad->device_removed = TRUE; */ - usb_free_urb(psIntfAdapter->psInterruptUrb); - - /* Free transmit URBs */ - for (i = 0; i < MAXIMUM_USB_TCB; i++) { - if (psIntfAdapter->asUsbTcb[i].urb != NULL) { - usb_free_urb(psIntfAdapter->asUsbTcb[i].urb); - psIntfAdapter->asUsbTcb[i].urb = NULL; - } - } - /* Free receive URB and buffers */ - for (i = 0; i < MAXIMUM_USB_RCB; i++) { - if (psIntfAdapter->asUsbRcb[i].urb != NULL) { - kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer); - usb_free_urb(psIntfAdapter->asUsbRcb[i].urb); - psIntfAdapter->asUsbRcb[i].urb = NULL; - } - } - AdapterFree(ps_ad); -} - -static void ConfigureEndPointTypesThroughEEPROM( - struct bcm_mini_adapter *Adapter) -{ - u32 ulReg; - int bytes; - struct bcm_interface_adapter *interfaceAdapter; - - /* Program EP2 MAX_PKT_SIZE */ - ulReg = ntohl(EP2_MPS_REG); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x128, 4, TRUE); - ulReg = ntohl(EP2_MPS); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x12C, 4, TRUE); - - ulReg = ntohl(EP2_CFG_REG); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE); - interfaceAdapter = - (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter); - if (interfaceAdapter->bHighSpeedDevice) { - ulReg = ntohl(EP2_CFG_INT); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE); - } else { - /* USE BULK EP as TX in FS mode. */ - ulReg = ntohl(EP2_CFG_BULK); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE); - } - - /* Program EP4 MAX_PKT_SIZE. */ - ulReg = ntohl(EP4_MPS_REG); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x13C, 4, TRUE); - ulReg = ntohl(EP4_MPS); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x140, 4, TRUE); - - /* Program TX EP as interrupt(Alternate Setting) */ - bytes = rdmalt(Adapter, 0x0F0110F8, &ulReg, sizeof(u32)); - if (bytes < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, "reading of Tx EP failed\n"); - return; - } - ulReg |= 0x6; - - ulReg = ntohl(ulReg); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1CC, 4, TRUE); - - ulReg = ntohl(EP4_CFG_REG); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C8, 4, TRUE); - /* Program ISOCHRONOUS EP size to zero. */ - ulReg = ntohl(ISO_MPS_REG); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D2, 4, TRUE); - ulReg = ntohl(ISO_MPS); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D6, 4, TRUE); - - /* - * Update EEPROM Version. - * Read 4 bytes from 508 and modify 511 and 510. - */ - ReadBeceemEEPROM(Adapter, 0x1FC, &ulReg); - ulReg &= 0x0101FFFF; - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1FC, 4, TRUE); - - /* - * Update length field if required. - * Also make the string NULL terminated. - */ - - ReadBeceemEEPROM(Adapter, 0xA8, &ulReg); - if ((ulReg&0x00FF0000)>>16 > 0x30) { - ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0xA8, 4, TRUE); - } - ReadBeceemEEPROM(Adapter, 0x148, &ulReg); - if ((ulReg&0x00FF0000)>>16 > 0x30) { - ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x148, 4, TRUE); - } - ulReg = 0; - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x122, 4, TRUE); - ulReg = 0; - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C2, 4, TRUE); -} - -static int usbbcm_device_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ - struct usb_device *udev = interface_to_usbdev(intf); - int retval; - struct bcm_mini_adapter *psAdapter; - struct bcm_interface_adapter *psIntfAdapter; - struct net_device *ndev; - - /* Reserve one extra queue for the bit-bucket */ - ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), - NO_OF_QUEUES + 1); - if (ndev == NULL) { - dev_err(&udev->dev, DRV_NAME ": no memory for device\n"); - return -ENOMEM; - } - - SET_NETDEV_DEV(ndev, &intf->dev); - - psAdapter = netdev_priv(ndev); - psAdapter->dev = ndev; - psAdapter->msg_enable = netif_msg_init(debug, default_msg); - - /* Init default driver debug state */ - - psAdapter->stDebugState.debug_level = DBG_LVL_CURR; - psAdapter->stDebugState.type = DBG_TYPE_INITEXIT; - - /* - * Technically, one can start using BCM_DEBUG_PRINT after this point. - * However, realize that by default the Type/Subtype bitmaps are all - * zero now; so no prints will actually appear until the TestApp turns - * on debug paths via the ioctl(); so practically speaking, in early - * init, no logging happens. - * - * A solution (used below): we explicitly set the bitmaps to 1 for - * Type=DBG_TYPE_INITEXIT and ALL subtype's of the same. Now all bcm - * debug statements get logged, enabling debug during early init. - * Further, we turn this OFF once init_module() completes. - */ - - psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff; - BCM_SHOW_DEBUG_BITMAP(psAdapter); - - retval = InitAdapter(psAdapter); - if (retval) { - dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n"); - AdapterFree(psAdapter); - return retval; - } - - /* Allocate interface adapter structure */ - psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), - GFP_KERNEL); - if (psIntfAdapter == NULL) { - AdapterFree(psAdapter); - return -ENOMEM; - } - - psAdapter->pvInterfaceAdapter = psIntfAdapter; - psIntfAdapter->psAdapter = psAdapter; - - /* Store usb interface in Interface Adapter */ - psIntfAdapter->interface = intf; - usb_set_intfdata(intf, psIntfAdapter); - - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "psIntfAdapter 0x%p\n", psIntfAdapter); - retval = InterfaceAdapterInit(psIntfAdapter); - if (retval) { - /* If the Firmware/Cfg File is not present - * then return success, let the application - * download the files. - */ - if (-ENOENT == retval) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "File Not Found. Use app to download.\n"); - return STATUS_SUCCESS; - } - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, "InterfaceAdapterInit failed.\n"); - usb_set_intfdata(intf, NULL); - udev = interface_to_usbdev(intf); - usb_put_dev(udev); - InterfaceAdapterFree(psIntfAdapter); - return retval; - } - if (psAdapter->chip_id > T3) { - uint32_t uiNackZeroLengthInt = 4; - - retval = - wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, - &uiNackZeroLengthInt, - sizeof(uiNackZeroLengthInt)); - if (retval) - return retval; - } - - /* Check whether the USB-Device Supports remote Wake-Up */ - if (USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) { - /* If Suspend then only support dynamic suspend */ - if (psAdapter->bDoSuspend) { -#ifdef CONFIG_PM - pm_runtime_set_autosuspend_delay(&udev->dev, 0); - intf->needs_remote_wakeup = 1; - usb_enable_autosuspend(udev); - device_init_wakeup(&intf->dev, 1); - INIT_WORK(&psIntfAdapter->usbSuspendWork, - putUsbSuspend); - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Enabling USB Auto-Suspend\n"); -#endif - } else { - intf->needs_remote_wakeup = 0; - usb_disable_autosuspend(udev); - } - } - - psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0; - return retval; -} - -static void usbbcm_disconnect(struct usb_interface *intf) -{ - struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf); - struct bcm_mini_adapter *psAdapter; - struct usb_device *udev = interface_to_usbdev(intf); - - if (psIntfAdapter == NULL) - return; - - psAdapter = psIntfAdapter->psAdapter; - netif_device_detach(psAdapter->dev); - - if (psAdapter->bDoSuspend) - intf->needs_remote_wakeup = 0; - - psAdapter->device_removed = TRUE; - usb_set_intfdata(intf, NULL); - InterfaceAdapterFree(psIntfAdapter); - usb_put_dev(udev); -} - -static int AllocUsbCb(struct bcm_interface_adapter *psIntfAdapter) -{ - int i = 0; - - for (i = 0; i < MAXIMUM_USB_TCB; i++) { - psIntfAdapter->asUsbTcb[i].urb = usb_alloc_urb(0, GFP_KERNEL); - - if (psIntfAdapter->asUsbTcb[i].urb == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_PRINTK, 0, 0, - "Can't allocate Tx urb for index %d\n", - i); - return -ENOMEM; - } - } - - for (i = 0; i < MAXIMUM_USB_RCB; i++) { - psIntfAdapter->asUsbRcb[i].urb = usb_alloc_urb(0, GFP_KERNEL); - - if (psIntfAdapter->asUsbRcb[i].urb == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_PRINTK, 0, 0, - "Can't allocate Rx urb for index %d\n", - i); - return -ENOMEM; - } - - psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = - kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL); - - if (psIntfAdapter->asUsbRcb[i].urb->transfer_buffer == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_PRINTK, 0, 0, - "Can't allocate Rx buffer for index %d\n", - i); - return -ENOMEM; - } - psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = - MAX_DATA_BUFFER_SIZE; - } - return 0; -} - -static int device_run(struct bcm_interface_adapter *psIntfAdapter) -{ - int value = 0; - UINT status = STATUS_SUCCESS; - struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter; - - status = InitCardAndDownloadFirmware(psAd); - if (status != STATUS_SUCCESS) { - pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n"); - return status; - } - if (psAd->fw_download_done) { - if (StartInterruptUrb(psIntfAdapter)) { - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Cannot send interrupt in URB\n"); - } - - /* - * now register the cntrl interface. after downloading the f/w - * waiting for 5 sec to get the mailbox interrupt. - */ - psAd->waiting_to_fw_download_done = false; - value = wait_event_timeout(psAd->ioctl_fw_dnld_wait_queue, - psAd->waiting_to_fw_download_done, - 5 * HZ); - - if (value == 0) - pr_err(DRV_NAME ": Timeout waiting for mailbox interrupt.\n"); - - if (register_control_device_interface(psAd) < 0) { - pr_err(DRV_NAME ": Register Control Device failed.\n"); - return -EIO; - } - } - return 0; -} - -static int select_alternate_setting_for_highspeed_modem( - struct bcm_interface_adapter *psIntfAdapter, - struct usb_endpoint_descriptor **endpoint, - const struct usb_host_interface *iface_desc, - int *usedIntOutForBulkTransfer) -{ - int retval = 0; - struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter; - - /* selecting alternate setting one as a default setting - * for High Speed modem. */ - if (psIntfAdapter->bHighSpeedDevice) - retval = usb_set_interface(psIntfAdapter->udev, - DEFAULT_SETTING_0, - ALTERNATE_SETTING_1); - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "BCM16 is applicable on this dongle\n"); - if (retval || !psIntfAdapter->bHighSpeedDevice) { - *usedIntOutForBulkTransfer = EP2; - *endpoint = &iface_desc->endpoint[EP2].desc; - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n"); - /* - * If Modem is high speed device EP2 should be - * INT OUT End point - * - * If Mode is FS then EP2 should be bulk end - * point - */ - if ((psIntfAdapter->bHighSpeedDevice && - !usb_endpoint_is_int_out(*endpoint)) || - (!psIntfAdapter->bHighSpeedDevice && - !usb_endpoint_is_bulk_out(*endpoint))) { - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Configuring the EEPROM\n"); - /* change the EP2, EP4 to INT OUT end point */ - ConfigureEndPointTypesThroughEEPROM( - psAd); - - /* - * It resets the device and if any thing - * gets changed in USB descriptor it - * will show fail and re-enumerate the - * device - */ - retval = usb_reset_device(psIntfAdapter->udev); - if (retval) { - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, - DRV_ENTRY, DBG_LVL_ALL, - "reset failed. Re-enumerating the device.\n"); - return retval; - } - - } - if (!psIntfAdapter->bHighSpeedDevice && - usb_endpoint_is_bulk_out(*endpoint)) { - /* - * Once BULK is selected in FS mode. - * Revert it back to INT. - * Else USB_IF will fail. - */ - UINT _uiData = ntohl(EP2_CFG_INT); - - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Reverting Bulk to INT as it is in Full Speed mode.\n"); - BeceemEEPROMBulkWrite(psAd, (PUCHAR) & _uiData, 0x136, - 4, TRUE); - } - } else { - *usedIntOutForBulkTransfer = EP4; - *endpoint = &iface_desc->endpoint[EP4].desc; - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, - "Choosing AltSetting as a default setting.\n"); - if (!usb_endpoint_is_int_out(*endpoint)) { - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Dongle does not have BCM16 Fix.\n"); - /* - * change the EP2, EP4 to INT OUT end point and use EP4 - * in altsetting - */ - ConfigureEndPointTypesThroughEEPROM(psAd); - - /* - * It resets the device and if any thing - * gets changed in USB descriptor it - * will show fail and re-enumerate the - * device - */ - retval = usb_reset_device(psIntfAdapter->udev); - if (retval) { - BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT, - DRV_ENTRY, DBG_LVL_ALL, - "reset failed. Re-enumerating the device.\n"); - return retval; - } - } - } - - return 0; -} - -static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter) -{ - struct usb_host_interface *iface_desc; - struct usb_endpoint_descriptor *endpoint; - size_t buffer_size; - unsigned long value; - int retval = 0; - int usedIntOutForBulkTransfer = 0; - bool bBcm16 = false; - UINT uiData = 0; - int bytes; - struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter; - - /* Store the usb dev into interface adapter */ - psIntfAdapter->udev = - usb_get_dev(interface_to_usbdev(psIntfAdapter->interface)); - - psIntfAdapter->bHighSpeedDevice = - (psIntfAdapter->udev->speed == USB_SPEED_HIGH); - psAd->interface_rdm = BcmRDM; - psAd->interface_wrm = BcmWRM; - - bytes = rdmalt(psAd, CHIP_ID_REG, (u32 *) &(psAd->chip_id), - sizeof(u32)); - if (bytes < 0) { - retval = bytes; - BCM_DEBUG_PRINT(psAd, DBG_TYPE_PRINTK, 0, 0, - "CHIP ID Read Failed\n"); - return retval; - } - - if (0xbece3200 == (psAd->chip_id & ~(0xF0))) - psAd->chip_id &= ~0xF0; - - dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n", - psAd->chip_id); - - iface_desc = psIntfAdapter->interface->cur_altsetting; - - if (psAd->chip_id == T3B) { - /* T3B device will have EEPROM, check if EEPROM is proper and - * BCM16 can be done or not. */ - BeceemEEPROMBulkRead(psAd, &uiData, 0x0, 4); - if (uiData == BECM) - bBcm16 = TRUE; - - dev_info(&psIntfAdapter->udev->dev, - "number of alternate setting %d\n", - psIntfAdapter->interface->num_altsetting); - - if (bBcm16 == TRUE) { - retval = select_alternate_setting_for_highspeed_modem( - psIntfAdapter, &endpoint, iface_desc, - &usedIntOutForBulkTransfer); - if (retval) - return retval; - } - } - - iface_desc = psIntfAdapter->interface->cur_altsetting; - - for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) { - endpoint = &iface_desc->endpoint[value].desc; - - if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && - usb_endpoint_is_bulk_in(endpoint)) { - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; - psIntfAdapter->sBulkIn.bulk_in_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sBulkIn.bulk_in_pipe = usb_rcvbulkpipe( - psIntfAdapter->udev, - psIntfAdapter->sBulkIn.bulk_in_endpointAddr); - } - - if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && - usb_endpoint_is_bulk_out(endpoint)) { - psIntfAdapter->sBulkOut.bulk_out_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndbulkpipe( - psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_endpointAddr); - } - - if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && - usb_endpoint_is_int_in(endpoint)) { - buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sIntrIn.int_in_size = buffer_size; - psIntfAdapter->sIntrIn.int_in_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sIntrIn.int_in_interval = - endpoint->bInterval; - psIntfAdapter->sIntrIn.int_in_buffer = - kmalloc(buffer_size, GFP_KERNEL); - if (!psIntfAdapter->sIntrIn.int_in_buffer) - return -EINVAL; - } - - if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && - usb_endpoint_is_int_out(endpoint)) { - if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && - (psAd->chip_id == T3B) && - (value == usedIntOutForBulkTransfer)) { - /* - * use first intout end point as a bulk out end - * point - */ - buffer_size = - le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sBulkOut.bulk_out_size = - buffer_size; - psIntfAdapter->sBulkOut.bulk_out_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sBulkOut.bulk_out_pipe = - usb_sndintpipe(psIntfAdapter->udev, - psIntfAdapter->sBulkOut - .bulk_out_endpointAddr); - psIntfAdapter->sBulkOut.int_out_interval = - endpoint->bInterval; - } else if (value == EP6) { - buffer_size = - le16_to_cpu(endpoint->wMaxPacketSize); - psIntfAdapter->sIntrOut.int_out_size = - buffer_size; - psIntfAdapter->sIntrOut.int_out_endpointAddr = - endpoint->bEndpointAddress; - psIntfAdapter->sIntrOut.int_out_interval = - endpoint->bInterval; - psIntfAdapter->sIntrOut.int_out_buffer = - kmalloc(buffer_size, GFP_KERNEL); - if (!psIntfAdapter->sIntrOut.int_out_buffer) - return -EINVAL; - } - } - } - - usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter); - - psAd->bcm_file_download = InterfaceFileDownload; - psAd->bcm_file_readback_from_chip = InterfaceFileReadbackFromChip; - psAd->interface_transmit = InterfaceTransmitPacket; - - retval = CreateInterruptUrb(psIntfAdapter); - - if (retval) { - BCM_DEBUG_PRINT(psAd, DBG_TYPE_PRINTK, 0, 0, - "Cannot create interrupt urb\n"); - return retval; - } - - retval = AllocUsbCb(psIntfAdapter); - if (retval) - return retval; - - return device_run(psIntfAdapter); -} - -static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message) -{ - struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf); - - psIntfAdapter->bSuspended = TRUE; - - if (psIntfAdapter->bPreparingForBusSuspend) { - psIntfAdapter->bPreparingForBusSuspend = false; - - if (psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) { - psIntfAdapter->psAdapter->IdleMode = TRUE; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Host Entered in PMU Idle Mode.\n"); - } else { - psIntfAdapter->psAdapter->bShutStatus = TRUE; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_INITEXIT, DRV_ENTRY, - DBG_LVL_ALL, - "Host Entered in PMU Shutdown Mode.\n"); - } - } - psIntfAdapter->psAdapter->bPreparingForLowPowerMode = false; - - /* Signaling the control pkt path */ - wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue); - - return 0; -} - -static int InterfaceResume(struct usb_interface *intf) -{ - struct bcm_interface_adapter *psIntfAdapter = usb_get_intfdata(intf); - - mdelay(100); - psIntfAdapter->bSuspended = false; - - StartInterruptUrb(psIntfAdapter); - InterfaceRx(psIntfAdapter); - return 0; -} - -static struct usb_driver usbbcm_driver = { - .name = "usbbcm", - .probe = usbbcm_device_probe, - .disconnect = usbbcm_disconnect, - .suspend = InterfaceSuspend, - .resume = InterfaceResume, - .id_table = InterfaceUsbtable, - .supports_autosuspend = 1, -}; - -struct class *bcm_class; - -static __init int bcm_init(void) -{ - int retval; - - pr_info("%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION); - pr_info("%s\n", DRV_COPYRIGHT); - - bcm_class = class_create(THIS_MODULE, DRV_NAME); - if (IS_ERR(bcm_class)) { - pr_err(DRV_NAME ": could not create class\n"); - return PTR_ERR(bcm_class); - } - - retval = usb_register(&usbbcm_driver); - if (retval < 0) { - pr_err(DRV_NAME ": could not register usb driver\n"); - class_destroy(bcm_class); - return retval; - } - return 0; -} - -static __exit void bcm_exit(void) -{ - usb_deregister(&usbbcm_driver); - class_destroy(bcm_class); -} - -module_init(bcm_init); -module_exit(bcm_exit); - -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_VERSION(DRV_VERSION); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/bcm/InterfaceInit.h b/drivers/staging/bcm/InterfaceInit.h deleted file mode 100644 index ffa6e9667ec4..000000000000 --- a/drivers/staging/bcm/InterfaceInit.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _INTERFACE_INIT_H -#define _INTERFACE_INIT_H - -#define BCM_USB_VENDOR_ID_T3 0x198f -#define BCM_USB_VENDOR_ID_FOXCONN 0x0489 -#define BCM_USB_VENDOR_ID_ZTE 0x19d2 - -#define BCM_USB_PRODUCT_ID_T3 0x0300 -#define BCM_USB_PRODUCT_ID_T3B 0x0210 -#define BCM_USB_PRODUCT_ID_T3L 0x0220 -#define BCM_USB_PRODUCT_ID_SYM 0x15E -#define BCM_USB_PRODUCT_ID_1901 0xe017 -#define BCM_USB_PRODUCT_ID_226 0x0132 /* not sure if this is valid */ -#define BCM_USB_PRODUCT_ID_ZTE_226 0x172 -#define BCM_USB_PRODUCT_ID_ZTE_326 0x173 /* ZTE AX326 */ -#define BCM_USB_PRODUCT_ID_ZTE_TU25 0x0007 - -#define BCM_USB_MINOR_BASE 192 - -int InterfaceInitialize(void); - -int InterfaceExit(void); - -int usbbcm_worker_thread(struct bcm_interface_adapter *psIntfAdapter); - -#endif diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c deleted file mode 100644 index b9f8a7aa24fe..000000000000 --- a/drivers/staging/bcm/InterfaceIsr.c +++ /dev/null @@ -1,190 +0,0 @@ -#include "headers.h" - - -static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/) -{ - int status = urb->status; - struct bcm_interface_adapter *psIntfAdapter = - (struct bcm_interface_adapter *)urb->context; - struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; - - if (netif_msg_intr(Adapter)) - pr_info(PFX "%s: interrupt status %d\n", - Adapter->dev->name, status); - - if (Adapter->device_removed) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, "Device has Got Removed."); - return; - } - - if ((Adapter->bPreparingForLowPowerMode && Adapter->bDoSuspend) || - psIntfAdapter->bSuspended || - psIntfAdapter->bPreparingForBusSuspend) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, - "Interrupt call back is called while suspending the device"); - return; - } - - switch (status) { - /* success */ - case STATUS_SUCCESS: - if (urb->actual_length) { - - if (psIntfAdapter->ulInterruptData[1] & 0xFF) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - INTF_INIT, DBG_LVL_ALL, - "Got USIM interrupt"); - } - - if (psIntfAdapter->ulInterruptData[1] & 0xFF00) { - atomic_set(&Adapter->CurrNumFreeTxDesc, - (psIntfAdapter->ulInterruptData[1] & - 0xFF00) >> 8); - atomic_set(&Adapter->uiMBupdate, TRUE); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - INTF_INIT, DBG_LVL_ALL, - "TX mailbox contains %d", - atomic_read(&Adapter->CurrNumFreeTxDesc)); - } - if (psIntfAdapter->ulInterruptData[1] >> 16) { - Adapter->CurrNumRecvDescs = - (psIntfAdapter->ulInterruptData[1] >> 16); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - INTF_INIT, DBG_LVL_ALL, - "RX mailbox contains %d", - Adapter->CurrNumRecvDescs); - InterfaceRx(psIntfAdapter); - } - if (Adapter->fw_download_done && - !Adapter->downloadDDR && - atomic_read(&Adapter->CurrNumFreeTxDesc)) { - - psIntfAdapter->psAdapter->downloadDDR += 1; - wake_up(&Adapter->tx_packet_wait_queue); - } - if (!Adapter->waiting_to_fw_download_done) { - Adapter->waiting_to_fw_download_done = TRUE; - wake_up(&Adapter->ioctl_fw_dnld_wait_queue); - } - if (!atomic_read(&Adapter->TxPktAvail)) { - atomic_set(&Adapter->TxPktAvail, 1); - wake_up(&Adapter->tx_packet_wait_queue); - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, "Firing interrupt in URB"); - } - break; - case -ENOENT: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, "URB has got disconnected...."); - return; - case -EINPROGRESS: - /* - * This situation may happened when URBunlink is used. for - * detail check usb_unlink_urb documentation. - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, - "Impossibe condition has occurred... something very bad is going on"); - break; - /* return; */ - case -EPIPE: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, - "Interrupt IN endPoint has got halted/stalled...need to clear this"); - Adapter->bEndPointHalted = TRUE; - wake_up(&Adapter->tx_packet_wait_queue); - urb->status = STATUS_SUCCESS; - return; - /* software-driven interface shutdown */ - case -ECONNRESET: /* URB got unlinked */ - case -ESHUTDOWN: /* hardware gone. this is the serious problem */ - /* - * Occurs only when something happens with the - * host controller device - */ - case -ENODEV: /* Device got removed */ - case -EINVAL: - /* - * Some thing very bad happened with the URB. No - * description is available. - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, "interrupt urb error %d", status); - urb->status = STATUS_SUCCESS; - break; - /* return; */ - default: - /* - * This is required to check what is the defaults conditions - * when it occurs.. - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, - "GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", - status); - break; - } - - StartInterruptUrb(psIntfAdapter); - - -} - -int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter) -{ - psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL); - if (!psIntfAdapter->psInterruptUrb) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, - INTF_INIT, DBG_LVL_ALL, - "Cannot allocate interrupt urb"); - return -ENOMEM; - } - psIntfAdapter->psInterruptUrb->transfer_buffer = - psIntfAdapter->ulInterruptData; - psIntfAdapter->psInterruptUrb->transfer_buffer_length = - sizeof(psIntfAdapter->ulInterruptData); - - psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev, - psIntfAdapter->sIntrIn.int_in_endpointAddr); - - usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev, - psIntfAdapter->sIntrIn.int_in_pipe, - psIntfAdapter->psInterruptUrb->transfer_buffer, - psIntfAdapter->psInterruptUrb->transfer_buffer_length, - read_int_callback, psIntfAdapter, - psIntfAdapter->sIntrIn.int_in_interval); - - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, "Interrupt Interval: %d\n", - psIntfAdapter->sIntrIn.int_in_interval); - return 0; -} - - -INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter) -{ - INT status = 0; - - if (!(psIntfAdapter->psAdapter->device_removed || - psIntfAdapter->psAdapter->bEndPointHalted || - psIntfAdapter->bSuspended || - psIntfAdapter->bPreparingForBusSuspend || - psIntfAdapter->psAdapter->StopAllXaction)) { - status = - usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC); - if (status) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, - "Cannot send inturb %d\n", status); - if (status == -EPIPE) { - psIntfAdapter->psAdapter->bEndPointHalted = - TRUE; - wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); - } - } - } - return status; -} - diff --git a/drivers/staging/bcm/InterfaceIsr.h b/drivers/staging/bcm/InterfaceIsr.h deleted file mode 100644 index 3073bd71cfeb..000000000000 --- a/drivers/staging/bcm/InterfaceIsr.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _INTERFACE_ISR_H -#define _INTERFACE_ISR_H - -int CreateInterruptUrb(struct bcm_interface_adapter *psIntfAdapter); - - -INT StartInterruptUrb(struct bcm_interface_adapter *psIntfAdapter); - - -VOID InterfaceEnableInterrupt(struct bcm_mini_adapter *Adapter); - -VOID InterfaceDisableInterrupt(struct bcm_mini_adapter *Adapter); - -#endif - diff --git a/drivers/staging/bcm/InterfaceMacros.h b/drivers/staging/bcm/InterfaceMacros.h deleted file mode 100644 index fedb79437f33..000000000000 --- a/drivers/staging/bcm/InterfaceMacros.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _INTERFACE_MACROS_H -#define _INTERFACE_MACROS_H - -#define BCM_USB_MAX_READ_LENGTH 2048 - -#define MAXIMUM_USB_TCB 128 -#define MAXIMUM_USB_RCB 128 - -#define MAX_BUFFERS_PER_QUEUE 256 - -#define MAX_DATA_BUFFER_SIZE 2048 - -/* Num of Asynchronous reads pending */ -#define NUM_RX_DESC 64 - -#define SYS_CFG 0x0F000C00 - -#endif diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c deleted file mode 100644 index 1f31b8f05884..000000000000 --- a/drivers/staging/bcm/InterfaceMisc.c +++ /dev/null @@ -1,246 +0,0 @@ -#include "headers.h" - -static int adapter_err_occurred(const struct bcm_interface_adapter *ad) -{ - if (ad->psAdapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "Device got removed"); - return -ENODEV; - } - - if ((ad->psAdapter->StopAllXaction == TRUE) && - (ad->psAdapter->chip_id >= T3LPB)) { - BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM, - DBG_LVL_ALL, - "Currently Xaction is not allowed on the bus"); - return -EACCES; - } - - if (ad->bSuspended == TRUE || ad->bPreparingForBusSuspend == TRUE) { - BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM, - DBG_LVL_ALL, - "Bus is in suspended states hence RDM not allowed.."); - return -EACCES; - } - - return 0; -} - -int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter, - unsigned int addr, - void *buff, - int len) -{ - int bytes; - int err = 0; - - if (!psIntfAdapter) - return -EINVAL; - - err = adapter_err_occurred(psIntfAdapter); - if (err) - return err; - - psIntfAdapter->psAdapter->DeviceAccess = TRUE; - - bytes = usb_control_msg(psIntfAdapter->udev, - usb_rcvctrlpipe(psIntfAdapter->udev, 0), - 0x02, - 0xC2, - (addr & 0xFFFF), - ((addr >> 16) & 0xFFFF), - buff, - len, - 5000); - - if (-ENODEV == bytes) - psIntfAdapter->psAdapter->device_removed = TRUE; - - if (bytes < 0) - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, - DBG_LVL_ALL, "RDM failed status :%d", bytes); - else - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, - DBG_LVL_ALL, "RDM sent %d", bytes); - - psIntfAdapter->psAdapter->DeviceAccess = false; - return bytes; -} - -int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, - unsigned int addr, - void *buff, - int len) -{ - int retval = 0; - int err = 0; - - if (!psIntfAdapter) - return -EINVAL; - - err = adapter_err_occurred(psIntfAdapter); - if (err) - return err; - - psIntfAdapter->psAdapter->DeviceAccess = TRUE; - - retval = usb_control_msg(psIntfAdapter->udev, - usb_sndctrlpipe(psIntfAdapter->udev, 0), - 0x01, - 0x42, - (addr & 0xFFFF), - ((addr >> 16) & 0xFFFF), - buff, - len, - 5000); - - if (-ENODEV == retval) - psIntfAdapter->psAdapter->device_removed = TRUE; - - if (retval < 0) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, - DBG_LVL_ALL, "WRM failed status :%d", retval); - psIntfAdapter->psAdapter->DeviceAccess = false; - return retval; - } - psIntfAdapter->psAdapter->DeviceAccess = false; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM, - DBG_LVL_ALL, "WRM sent %d", retval); - return STATUS_SUCCESS; -} - -int BcmRDM(void *arg, - unsigned int addr, - void *buff, - int len) -{ - return InterfaceRDM((struct bcm_interface_adapter *)arg, addr, buff, - len); -} - -int BcmWRM(void *arg, - unsigned int addr, - void *buff, - int len) -{ - return InterfaceWRM((struct bcm_interface_adapter *)arg, addr, buff, - len); -} - -int Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter) -{ - struct bcm_interface_adapter *psIntfAdapter = - (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter); - int status = STATUS_SUCCESS; - - /* - * usb_clear_halt - tells device to clear endpoint halt/stall condition - * @dev: device whose endpoint is halted - * @pipe: endpoint "pipe" being cleared - * @ Context: !in_interrupt () - * - * usb_clear_halt is the synchrnous call and returns 0 on success else - * returns with error code. - * This is used to clear halt conditions for bulk and interrupt - * endpoints only. - * Control and isochronous endpoints never halts. - * - * Any URBs queued for such an endpoint should normally be unlinked by - * the driver before clearing the halt condition. - * - */ - - /* Killing all the submitted urbs to different end points. */ - Bcm_kill_all_URBs(psIntfAdapter); - - /* clear the halted/stalled state for every end point */ - status = usb_clear_halt(psIntfAdapter->udev, - psIntfAdapter->sIntrIn.int_in_pipe); - if (status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, - "Unable to Clear Halt of Interrupt IN end point. :%d ", - status); - - status = usb_clear_halt(psIntfAdapter->udev, - psIntfAdapter->sBulkIn.bulk_in_pipe); - if (status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, - "Unable to Clear Halt of Bulk IN end point. :%d ", - status); - - status = usb_clear_halt(psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_pipe); - if (status != STATUS_SUCCESS) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, - DBG_LVL_ALL, - "Unable to Clear Halt of Bulk OUT end point. :%d ", - status); - - return status; -} - -void Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter) -{ - struct urb *tempUrb = NULL; - unsigned int i; - - /* - * usb_kill_urb - cancel a transfer request and wait for it to finish - * @urb: pointer to URB describing a previously submitted request, - * returns nothing as it is void returned API. - * - * This routine cancels an in-progress request. It is guaranteed that - * upon return all completion handlers will have finished and the URB - * will be totally idle and available for reuse - * - * This routine may not be used in an interrupt context (such as a - * bottom half or a completion handler), or when holding a spinlock, or - * in other situations where the caller can't schedule(). - * - */ - - /* Cancel submitted Interrupt-URB's */ - if (psIntfAdapter->psInterruptUrb) { - if (psIntfAdapter->psInterruptUrb->status == -EINPROGRESS) - usb_kill_urb(psIntfAdapter->psInterruptUrb); - } - - /* Cancel All submitted TX URB's */ - for (i = 0; i < MAXIMUM_USB_TCB; i++) { - tempUrb = psIntfAdapter->asUsbTcb[i].urb; - if (tempUrb) { - if (tempUrb->status == -EINPROGRESS) - usb_kill_urb(tempUrb); - } - } - - for (i = 0; i < MAXIMUM_USB_RCB; i++) { - tempUrb = psIntfAdapter->asUsbRcb[i].urb; - if (tempUrb) { - if (tempUrb->status == -EINPROGRESS) - usb_kill_urb(tempUrb); - } - } - - atomic_set(&psIntfAdapter->uNumTcbUsed, 0); - atomic_set(&psIntfAdapter->uCurrTcb, 0); - - atomic_set(&psIntfAdapter->uNumRcbUsed, 0); - atomic_set(&psIntfAdapter->uCurrRcb, 0); -} - -void putUsbSuspend(struct work_struct *work) -{ - struct bcm_interface_adapter *psIntfAdapter = NULL; - struct usb_interface *intf = NULL; - - psIntfAdapter = container_of(work, struct bcm_interface_adapter, - usbSuspendWork); - intf = psIntfAdapter->interface; - - if (psIntfAdapter->bSuspended == false) - usb_autopm_put_interface(intf); -} - diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h deleted file mode 100644 index 0e5e38b26329..000000000000 --- a/drivers/staging/bcm/InterfaceMisc.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __INTERFACE_MISC_H -#define __INTERFACE_MISC_H - -INT -InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter, - UINT addr, - PVOID buff, - INT len); - -INT -InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, - UINT addr, - PVOID buff, - INT len); - - -int InterfaceFileDownload(PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); - -int InterfaceFileReadbackFromChip(PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); - - -int BcmRDM(PVOID arg, - UINT addr, - PVOID buff, - INT len); - -int BcmWRM(PVOID arg, - UINT addr, - PVOID buff, - INT len); - -INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter); - -VOID Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter); - -#define DISABLE_USB_ZERO_LEN_INT 0x0F011878 - -#endif /* __INTERFACE_MISC_H */ diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c deleted file mode 100644 index 0f179b9382d3..000000000000 --- a/drivers/staging/bcm/InterfaceRx.c +++ /dev/null @@ -1,289 +0,0 @@ -#include "headers.h" - -static void handle_control_packet(struct bcm_interface_adapter *interface, - struct bcm_mini_adapter *ad, - struct bcm_leader *leader, - struct sk_buff *skb, - struct urb *urb) -{ - BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, - "Received control pkt..."); - *(PUSHORT)skb->data = leader->Status; - memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer + - (sizeof(struct bcm_leader)), leader->PLength); - skb->len = leader->PLength + sizeof(USHORT); - - spin_lock(&ad->control_queue_lock); - ENQUEUEPACKET(ad->RxControlHead, ad->RxControlTail, skb); - spin_unlock(&ad->control_queue_lock); - - atomic_inc(&ad->cntrlpktCnt); - wake_up(&ad->process_rx_cntrlpkt); -} - -static void format_eth_hdr_to_stack(struct bcm_interface_adapter *interface, - struct bcm_mini_adapter *ad, - struct bcm_leader *p_leader, - struct sk_buff *skb, - struct urb *urb, - UINT ui_index, - int queue_index, - bool b_header_supression_endabled) -{ - /* - * Data Packet, Format a proper Ethernet Header - * and give it to the stack - */ - BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_DATA, - DBG_LVL_ALL, "Received Data pkt..."); - skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES); - memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + - sizeof(struct bcm_leader), p_leader->PLength); - skb->dev = ad->dev; - - /* currently skb->len has extra ETH_HLEN bytes in the beginning */ - skb_put(skb, p_leader->PLength + ETH_HLEN); - ad->PackInfo[queue_index].uiTotalRxBytes += p_leader->PLength; - ad->PackInfo[queue_index].uiThisPeriodRxBytes += p_leader->PLength; - BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_DATA, - DBG_LVL_ALL, "Received Data pkt of len :0x%X", - p_leader->PLength); - - if (netif_running(ad->dev)) { - /* Moving ahead by ETH_HLEN to the data ptr as received from FW */ - skb_pull(skb, ETH_HLEN); - PHSReceive(ad, p_leader->Vcid, skb, &skb->len, - NULL, b_header_supression_endabled); - - if (!ad->PackInfo[queue_index].bEthCSSupport) { - skb_push(skb, ETH_HLEN); - - memcpy(skb->data, skb->dev->dev_addr, 6); - memcpy(skb->data+6, skb->dev->dev_addr, 6); - (*(skb->data+11))++; - *(skb->data+12) = 0x08; - *(skb->data+13) = 0x00; - p_leader->PLength += ETH_HLEN; - } - - skb->protocol = eth_type_trans(skb, ad->dev); - netif_rx(skb); - } else { - BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, - RX_DATA, DBG_LVL_ALL, - "i/f not up hance freeing SKB..."); - dev_kfree_skb(skb); - } - - ++ad->dev->stats.rx_packets; - ad->dev->stats.rx_bytes += p_leader->PLength; - - for (ui_index = 0; ui_index < MIBS_MAX_HIST_ENTRIES; ui_index++) { - if ((p_leader->PLength <= - MIBS_PKTSIZEHIST_RANGE*(ui_index+1)) && - (p_leader->PLength > MIBS_PKTSIZEHIST_RANGE*(ui_index))) - - ad->aRxPktSizeHist[ui_index]++; - } -} - -static int SearchVcid(struct bcm_mini_adapter *Adapter, unsigned short usVcid) -{ - int iIndex = 0; - - for (iIndex = (NO_OF_QUEUES-1); iIndex >= 0; iIndex--) - if (Adapter->PackInfo[iIndex].usVCID_Value == usVcid) - return iIndex; - return NO_OF_QUEUES+1; - -} - - -static struct bcm_usb_rcb * -GetBulkInRcb(struct bcm_interface_adapter *psIntfAdapter) -{ - struct bcm_usb_rcb *pRcb = NULL; - UINT index = 0; - - if ((atomic_read(&psIntfAdapter->uNumRcbUsed) < MAXIMUM_USB_RCB) && - (psIntfAdapter->psAdapter->StopAllXaction == false)) { - index = atomic_read(&psIntfAdapter->uCurrRcb); - pRcb = &psIntfAdapter->asUsbRcb[index]; - pRcb->bUsed = TRUE; - pRcb->psIntfAdapter = psIntfAdapter; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DPC, - DBG_LVL_ALL, "Got Rx desc %d used %d", index, - atomic_read(&psIntfAdapter->uNumRcbUsed)); - index = (index + 1) % MAXIMUM_USB_RCB; - atomic_set(&psIntfAdapter->uCurrRcb, index); - atomic_inc(&psIntfAdapter->uNumRcbUsed); - } - return pRcb; -} - -/*this is receive call back - when pkt available for receive (BULK IN- end point)*/ -static void read_bulk_callback(struct urb *urb) -{ - struct sk_buff *skb = NULL; - bool bHeaderSupressionEnabled = false; - int QueueIndex = NO_OF_QUEUES + 1; - UINT uiIndex = 0; - struct bcm_usb_rcb *pRcb = (struct bcm_usb_rcb *)urb->context; - struct bcm_interface_adapter *psIntfAdapter = pRcb->psIntfAdapter; - struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; - struct bcm_leader *pLeader = urb->transfer_buffer; - - if (unlikely(netif_msg_rx_status(Adapter))) - pr_info(PFX "%s: rx urb status %d length %d\n", - Adapter->dev->name, urb->status, urb->actual_length); - - if ((Adapter->device_removed == TRUE) || - (TRUE == Adapter->bEndPointHalted) || - (0 == urb->actual_length)) { - pRcb->bUsed = false; - atomic_dec(&psIntfAdapter->uNumRcbUsed); - return; - } - - if (urb->status != STATUS_SUCCESS) { - if (urb->status == -EPIPE) { - Adapter->bEndPointHalted = TRUE; - wake_up(&Adapter->tx_packet_wait_queue); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, - DBG_LVL_ALL, - "Rx URB has got cancelled. status :%d", - urb->status); - } - pRcb->bUsed = false; - atomic_dec(&psIntfAdapter->uNumRcbUsed); - urb->status = STATUS_SUCCESS; - return; - } - - if (Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, - "device is going in low power mode while PMU option selected..hence rx packet should not be process"); - return; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, - "Read back done len %d\n", pLeader->PLength); - if (!pLeader->PLength) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, - "Leader Length 0"); - atomic_dec(&psIntfAdapter->uNumRcbUsed); - return; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, - "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", - pLeader->Status, pLeader->PLength, pLeader->Vcid); - if (MAX_CNTL_PKT_SIZE < pLeader->PLength) { - if (netif_msg_rx_err(Adapter)) - pr_info(PFX "%s: corrupted leader length...%d\n", - Adapter->dev->name, pLeader->PLength); - ++Adapter->dev->stats.rx_dropped; - atomic_dec(&psIntfAdapter->uNumRcbUsed); - return; - } - - QueueIndex = SearchVcid(Adapter, pLeader->Vcid); - if (QueueIndex < NO_OF_QUEUES) { - bHeaderSupressionEnabled = - Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled; - bHeaderSupressionEnabled = - bHeaderSupressionEnabled & Adapter->bPHSEnabled; - } - - skb = dev_alloc_skb(pLeader->PLength + SKB_RESERVE_PHS_BYTES + - SKB_RESERVE_ETHERNET_HEADER); - if (!skb) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "NO SKBUFF!!! Dropping the Packet"); - atomic_dec(&psIntfAdapter->uNumRcbUsed); - return; - } - /* If it is a control Packet, then call handle_bcm_packet ()*/ - if ((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) || - (!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F))) { - handle_control_packet(psIntfAdapter, Adapter, pLeader, skb, - urb); - } else { - format_eth_hdr_to_stack(psIntfAdapter, Adapter, pLeader, skb, - urb, uiIndex, QueueIndex, - bHeaderSupressionEnabled); - } - Adapter->PrevNumRecvDescs++; - pRcb->bUsed = false; - atomic_dec(&psIntfAdapter->uNumRcbUsed); -} - -static int ReceiveRcb(struct bcm_interface_adapter *psIntfAdapter, - struct bcm_usb_rcb *pRcb) -{ - struct urb *urb = pRcb->urb; - int retval = 0; - - usb_fill_bulk_urb(urb, psIntfAdapter->udev, - usb_rcvbulkpipe(psIntfAdapter->udev, - psIntfAdapter->sBulkIn.bulk_in_endpointAddr), - urb->transfer_buffer, - BCM_USB_MAX_READ_LENGTH, - read_bulk_callback, pRcb); - - if (false == psIntfAdapter->psAdapter->device_removed && - false == psIntfAdapter->psAdapter->bEndPointHalted && - false == psIntfAdapter->bSuspended && - false == psIntfAdapter->bPreparingForBusSuspend) { - retval = usb_submit_urb(urb, GFP_ATOMIC); - if (retval) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, - RX_DPC, DBG_LVL_ALL, - "failed submitting read urb, error %d", - retval); - /* if this return value is because of pipe halt. need to clear this. */ - if (retval == -EPIPE) { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE; - wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); - } - - } - } - return retval; -} - -/* -Function: InterfaceRx - -Description: This is the hardware specific Function for Receiving - data packet/control packets from the device. - -Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context - - - -Return: TRUE - If Rx was successful. - Other - If an error occurred. -*/ - -bool InterfaceRx(struct bcm_interface_adapter *psIntfAdapter) -{ - USHORT RxDescCount = NUM_RX_DESC - - atomic_read(&psIntfAdapter->uNumRcbUsed); - - struct bcm_usb_rcb *pRcb = NULL; - - while (RxDescCount) { - pRcb = GetBulkInRcb(psIntfAdapter); - if (pRcb == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, - DBG_TYPE_PRINTK, 0, 0, - "Unable to get Rcb pointer"); - return false; - } - ReceiveRcb(psIntfAdapter, pRcb); - RxDescCount--; - } - return TRUE; -} - diff --git a/drivers/staging/bcm/InterfaceRx.h b/drivers/staging/bcm/InterfaceRx.h deleted file mode 100644 index b4e858bcda34..000000000000 --- a/drivers/staging/bcm/InterfaceRx.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _INTERFACE_RX_H -#define _INTERFACE_RX_H - -bool InterfaceRx(struct bcm_interface_adapter *Adapter); - -#endif - diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c deleted file mode 100644 index 9b3f64b821ed..000000000000 --- a/drivers/staging/bcm/InterfaceTx.c +++ /dev/null @@ -1,213 +0,0 @@ -#include "headers.h" - -static void prepare_low_power_mode(struct urb *urb, - struct bcm_interface_adapter *interface, - struct bcm_mini_adapter *ps_adapter, - struct bcm_mini_adapter *ad, - struct bcm_link_request *p_control_msg, - bool *b_power_down_msg) -{ - if (((p_control_msg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) && - (p_control_msg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE))) { - - *b_power_down_msg = TRUE; - /* - * This covers the bus err while Idle Request msg - * sent down. - */ - if (urb->status != STATUS_SUCCESS) { - ps_adapter->bPreparingForLowPowerMode = false; - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, - "Idle Mode Request msg failed to reach to Modem"); - /* Signalling the cntrl pkt path in Ioctl */ - wake_up(&ps_adapter->lowpower_mode_wait_queue); - StartInterruptUrb(interface); - return; - } - - if (ps_adapter->bDoSuspend == false) { - ps_adapter->IdleMode = TRUE; - /* since going in Idle mode completed hence making this var false */ - ps_adapter->bPreparingForLowPowerMode = false; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, - "Host Entered in Idle Mode State..."); - /* Signalling the cntrl pkt path in Ioctl*/ - wake_up(&ps_adapter->lowpower_mode_wait_queue); - } - - } else if ((p_control_msg->Leader.Status == LINK_UP_CONTROL_REQ) && - (p_control_msg->szData[0] == LINK_UP_ACK) && - (p_control_msg->szData[1] == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) && - (p_control_msg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER)) { - /* - * This covers the bus err while shutdown Request - * msg sent down. - */ - if (urb->status != STATUS_SUCCESS) { - ps_adapter->bPreparingForLowPowerMode = false; - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, - "Shutdown Request Msg failed to reach to Modem"); - /* Signalling the cntrl pkt path in Ioctl */ - wake_up(&ps_adapter->lowpower_mode_wait_queue); - StartInterruptUrb(interface); - return; - } - - *b_power_down_msg = TRUE; - if (ps_adapter->bDoSuspend == false) { - ps_adapter->bShutStatus = TRUE; - /* - * since going in shutdown mode completed hence - * making this var false - */ - ps_adapter->bPreparingForLowPowerMode = false; - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, - "Host Entered in shutdown Mode State..."); - /* Signalling the cntrl pkt path in Ioctl */ - wake_up(&ps_adapter->lowpower_mode_wait_queue); - } - } - - if (ps_adapter->bDoSuspend && *b_power_down_msg) { - /* issuing bus suspend request */ - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, - "Issuing the Bus suspend request to USB stack"); - interface->bPreparingForBusSuspend = TRUE; - schedule_work(&interface->usbSuspendWork); - } -} - -/*this is transmit call-back(BULK OUT)*/ -static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/) -{ - struct bcm_usb_tcb *pTcb = (struct bcm_usb_tcb *)urb->context; - struct bcm_interface_adapter *psIntfAdapter = pTcb->psIntfAdapter; - struct bcm_link_request *pControlMsg = - (struct bcm_link_request *)urb->transfer_buffer; - struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter; - bool bpowerDownMsg = false; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (unlikely(netif_msg_tx_done(Adapter))) - pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, - urb->status); - - if (urb->status != STATUS_SUCCESS) { - if (urb->status == -EPIPE) { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE; - wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, - "Tx URB has got cancelled. status :%d", - urb->status); - } - } - - pTcb->bUsed = false; - atomic_dec(&psIntfAdapter->uNumTcbUsed); - - if (TRUE == psAdapter->bPreparingForLowPowerMode) { - prepare_low_power_mode(urb, psIntfAdapter, psAdapter, Adapter, - pControlMsg, &bpowerDownMsg); - } - - usb_free_coherent(urb->dev, urb->transfer_buffer_length, - urb->transfer_buffer, urb->transfer_dma); -} - - -static struct bcm_usb_tcb *GetBulkOutTcb(struct bcm_interface_adapter *psIntfAdapter) -{ - struct bcm_usb_tcb *pTcb = NULL; - UINT index = 0; - - if ((atomic_read(&psIntfAdapter->uNumTcbUsed) < MAXIMUM_USB_TCB) && - (psIntfAdapter->psAdapter->StopAllXaction == false)) { - index = atomic_read(&psIntfAdapter->uCurrTcb); - pTcb = &psIntfAdapter->asUsbTcb[index]; - pTcb->bUsed = TRUE; - pTcb->psIntfAdapter = psIntfAdapter; - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, - NEXT_SEND, DBG_LVL_ALL, - "Got Tx desc %d used %d", - index, - atomic_read(&psIntfAdapter->uNumTcbUsed)); - index = (index + 1) % MAXIMUM_USB_TCB; - atomic_set(&psIntfAdapter->uCurrTcb, index); - atomic_inc(&psIntfAdapter->uNumTcbUsed); - } - return pTcb; -} - -static int TransmitTcb(struct bcm_interface_adapter *psIntfAdapter, - struct bcm_usb_tcb *pTcb, PVOID data, int len) -{ - - struct urb *urb = pTcb->urb; - int retval = 0; - - urb->transfer_buffer = usb_alloc_coherent(psIntfAdapter->udev, len, - GFP_ATOMIC, &urb->transfer_dma); - if (!urb->transfer_buffer) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "Error allocating memory\n"); - return -ENOMEM; - } - memcpy(urb->transfer_buffer, data, len); - urb->transfer_buffer_length = len; - - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, "Sending Bulk out packet\n"); - /* For T3B,INT OUT end point will be used as bulk out end point */ - if ((psIntfAdapter->psAdapter->chip_id == T3B) && - (psIntfAdapter->bHighSpeedDevice == TRUE)) { - usb_fill_int_urb(urb, psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_pipe, - urb->transfer_buffer, len, write_bulk_callback, pTcb, - psIntfAdapter->sBulkOut.int_out_interval); - } else { - usb_fill_bulk_urb(urb, psIntfAdapter->udev, - psIntfAdapter->sBulkOut.bulk_out_pipe, - urb->transfer_buffer, len, write_bulk_callback, pTcb); - } - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* For DMA transfer */ - - if (false == psIntfAdapter->psAdapter->device_removed && - false == psIntfAdapter->psAdapter->bEndPointHalted && - false == psIntfAdapter->bSuspended && - false == psIntfAdapter->bPreparingForBusSuspend) { - retval = usb_submit_urb(urb, GFP_ATOMIC); - if (retval) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_TX, - NEXT_SEND, DBG_LVL_ALL, - "failed submitting write urb, error %d", - retval); - if (retval == -EPIPE) { - psIntfAdapter->psAdapter->bEndPointHalted = TRUE; - wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue); - } - } - } - return retval; -} - -int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len) -{ - struct bcm_usb_tcb *pTcb = NULL; - struct bcm_interface_adapter *psIntfAdapter = arg; - - pTcb = GetBulkOutTcb(psIntfAdapter); - if (pTcb == NULL) { - BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, - "No URB to transmit packet, dropping packet"); - return -EFAULT; - } - return TransmitTcb(psIntfAdapter, pTcb, data, len); -} - diff --git a/drivers/staging/bcm/InterfaceTx.h b/drivers/staging/bcm/InterfaceTx.h deleted file mode 100644 index 273147577c17..000000000000 --- a/drivers/staging/bcm/InterfaceTx.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _INTERFACE_TX_H -#define _INTERFACE_TX_H - -INT InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len); - -#endif - diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h deleted file mode 100644 index fa5f8671612e..000000000000 --- a/drivers/staging/bcm/Ioctl.h +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef _IOCTL_H_ -#define _IOCTL_H_ - -struct bcm_rdm_buffer { - unsigned long Register; - unsigned long Length; -} __packed; - -struct bcm_wrm_buffer { - unsigned long Register; - unsigned long Length; - unsigned char Data[4]; -} __packed; - -struct bcm_ioctl_buffer { - void __user *InputBuffer; - unsigned long InputLength; - void __user *OutputBuffer; - unsigned long OutputLength; -} __packed; - -struct bcm_gpio_info { - unsigned int uiGpioNumber; /* valid numbers 0-15 */ - unsigned int uiGpioValue; /* 1 set ; 0 not set */ -} __packed; - -struct bcm_user_thread_req { - /* 0->Inactivate LED thread. */ - /* 1->Activate the LED thread */ - unsigned int ThreadState; -} __packed; - -#define LED_THREAD_ACTIVATION_REQ 1 -#define BCM_IOCTL 'k' -#define IOCTL_SEND_CONTROL_MESSAGE _IOW(BCM_IOCTL, 0x801, int) -#define IOCTL_BCM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x802, int) -#define IOCTL_BCM_REGISTER_READ _IOR(BCM_IOCTL, 0x803, int) -#define IOCTL_BCM_COMMON_MEMORY_WRITE _IOW(BCM_IOCTL, 0x804, int) -#define IOCTL_BCM_COMMON_MEMORY_READ _IOR(BCM_IOCTL, 0x805, int) -#define IOCTL_GET_CONTROL_MESSAGE _IOR(BCM_IOCTL, 0x806, int) -#define IOCTL_BCM_FIRMWARE_DOWNLOAD _IOW(BCM_IOCTL, 0x807, int) -#define IOCTL_BCM_SET_SEND_VCID _IOW(BCM_IOCTL, 0x808, int) -#define IOCTL_BCM_SWITCH_TRANSFER_MODE _IOW(BCM_IOCTL, 0x809, int) -#define IOCTL_LINK_REQ _IOW(BCM_IOCTL, 0x80A, int) -#define IOCTL_RSSI_LEVEL_REQ _IOW(BCM_IOCTL, 0x80B, int) -#define IOCTL_IDLE_REQ _IOW(BCM_IOCTL, 0x80C, int) -#define IOCTL_SS_INFO_REQ _IOW(BCM_IOCTL, 0x80D, int) -#define IOCTL_GET_STATISTICS_POINTER _IOW(BCM_IOCTL, 0x80E, int) -#define IOCTL_CM_REQUEST _IOW(BCM_IOCTL, 0x80F, int) -#define IOCTL_INIT_PARAM_REQ _IOW(BCM_IOCTL, 0x810, int) -#define IOCTL_MAC_ADDR_REQ _IOW(BCM_IOCTL, 0x811, int) -#define IOCTL_MAC_ADDR_RESP _IOWR(BCM_IOCTL, 0x812, int) -#define IOCTL_CLASSIFICATION_RULE _IOW(BCM_IOCTL, 0x813, char) -#define IOCTL_CLOSE_NOTIFICATION _IO(BCM_IOCTL, 0x814) -#define IOCTL_LINK_UP _IO(BCM_IOCTL, 0x815) -#define IOCTL_LINK_DOWN _IO(BCM_IOCTL, 0x816, struct bcm_ioctl_buffer) -#define IOCTL_CHIP_RESET _IO(BCM_IOCTL, 0x816) -#define IOCTL_CINR_LEVEL_REQ _IOW(BCM_IOCTL, 0x817, char) -#define IOCTL_WTM_CONTROL_REQ _IOW(BCM_IOCTL, 0x817, char) -#define IOCTL_BE_BUCKET_SIZE _IOW(BCM_IOCTL, 0x818, unsigned long) -#define IOCTL_RTPS_BUCKET_SIZE _IOW(BCM_IOCTL, 0x819, unsigned long) -#define IOCTL_QOS_THRESHOLD _IOW(BCM_IOCTL, 0x820, unsigned long) -#define IOCTL_DUMP_PACKET_INFO _IO(BCM_IOCTL, 0x821) -#define IOCTL_GET_PACK_INFO _IOR(BCM_IOCTL, 0x823, int) -#define IOCTL_BCM_GET_DRIVER_VERSION _IOR(BCM_IOCTL, 0x829, int) -#define IOCTL_BCM_GET_CURRENT_STATUS _IOW(BCM_IOCTL, 0x828, int) -#define IOCTL_BCM_GPIO_SET_REQUEST _IOW(BCM_IOCTL, 0x82A, int) -#define IOCTL_BCM_GPIO_STATUS_REQUEST _IOW(BCM_IOCTL, 0x82b, int) -#define IOCTL_BCM_GET_DSX_INDICATION _IOR(BCM_IOCTL, 0x854, int) -#define IOCTL_BCM_BUFFER_DOWNLOAD_START _IOW(BCM_IOCTL, 0x855, int) -#define IOCTL_BCM_BUFFER_DOWNLOAD _IOW(BCM_IOCTL, 0x856, int) -#define IOCTL_BCM_BUFFER_DOWNLOAD_STOP _IOW(BCM_IOCTL, 0x857, int) -#define IOCTL_BCM_REGISTER_WRITE_PRIVATE _IOW(BCM_IOCTL, 0x826, char) -#define IOCTL_BCM_REGISTER_READ_PRIVATE _IOW(BCM_IOCTL, 0x827, char) -#define IOCTL_BCM_SET_DEBUG _IOW(BCM_IOCTL, 0x824, struct bcm_ioctl_buffer) -#define IOCTL_BCM_EEPROM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x858, int) -#define IOCTL_BCM_EEPROM_REGISTER_READ _IOR(BCM_IOCTL, 0x859, int) -#define IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE _IOR(BCM_IOCTL, 0x860, int) -#define IOCTL_BCM_SET_MAC_TRACING _IOW(BCM_IOCTL, 0x82c, int) -#define IOCTL_BCM_GET_HOST_MIBS _IOW(BCM_IOCTL, 0x853, int) -#define IOCTL_BCM_NVM_READ _IOR(BCM_IOCTL, 0x861, int) -#define IOCTL_BCM_NVM_WRITE _IOW(BCM_IOCTL, 0x862, int) -#define IOCTL_BCM_GET_NVM_SIZE _IOR(BCM_IOCTL, 0x863, int) -#define IOCTL_BCM_CAL_INIT _IOR(BCM_IOCTL, 0x864, int) -#define IOCTL_BCM_BULK_WRM _IOW(BCM_IOCTL, 0x90B, int) -#define IOCTL_BCM_FLASH2X_SECTION_READ _IOR(BCM_IOCTL, 0x865, int) -#define IOCTL_BCM_FLASH2X_SECTION_WRITE _IOW(BCM_IOCTL, 0x866, int) -#define IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP _IOR(BCM_IOCTL, 0x867, int) -#define IOCTL_BCM_SET_ACTIVE_SECTION _IOW(BCM_IOCTL, 0x868, int) -#define IOCTL_BCM_IDENTIFY_ACTIVE_SECTION _IO(BCM_IOCTL, 0x869) -#define IOCTL_BCM_COPY_SECTION _IOW(BCM_IOCTL, 0x870, int) -#define IOCTL_BCM_GET_FLASH_CS_INFO _IOR(BCM_IOCTL, 0x871, int) -#define IOCTL_BCM_SELECT_DSD _IOW(BCM_IOCTL, 0x872, int) -#define IOCTL_BCM_NVM_RAW_READ _IOR(BCM_IOCTL, 0x875, int) -#define IOCTL_BCM_CNTRLMSG_MASK _IOW(BCM_IOCTL, 0x874, int) -#define IOCTL_BCM_GET_DEVICE_DRIVER_INFO _IOR(BCM_IOCTL, 0x877, int) -#define IOCTL_BCM_TIME_SINCE_NET_ENTRY _IOR(BCM_IOCTL, 0x876, int) -#define BCM_LED_THREAD_STATE_CHANGE_REQ _IOW(BCM_IOCTL, 0x878, int) -#define IOCTL_BCM_GPIO_MULTI_REQUEST _IOW(BCM_IOCTL, 0x82D, struct bcm_ioctl_buffer) -#define IOCTL_BCM_GPIO_MODE_REQUEST _IOW(BCM_IOCTL, 0x82E, struct bcm_ioctl_buffer) - -enum bcm_interface_type { - BCM_MII, - BCM_CARDBUS, - BCM_USB, - BCM_SDIO, - BCM_PCMCIA -}; - -struct bcm_driver_info { - enum bcm_nvm_type u32NVMType; - unsigned int MaxRDMBufferSize; - enum bcm_interface_type u32InterfaceType; - unsigned int u32DSDStartOffset; - unsigned int u32RxAlignmentCorrection; - unsigned int u32Reserved[10]; -}; - -struct bcm_nvm_readwrite { - void __user *pBuffer; - uint32_t uiOffset; - uint32_t uiNumBytes; - bool bVerify; -}; - -struct bcm_bulk_wrm_buffer { - unsigned long Register; - unsigned long SwapEndian; - unsigned long Values[1]; -}; - -enum bcm_flash2x_section_val { - NO_SECTION_VAL = 0, /* no section chosen when absolute offset is given for RD/WR */ - ISO_IMAGE1, - ISO_IMAGE2, - DSD0, - DSD1, - DSD2, - VSA0, - VSA1, - VSA2, - SCSI, - CONTROL_SECTION, - ISO_IMAGE1_PART2, - ISO_IMAGE1_PART3, - ISO_IMAGE2_PART2, - ISO_IMAGE2_PART3, - TOTAL_SECTIONS -}; - -/* - * Structure used for READ/WRITE Flash Map2.x - */ -struct bcm_flash2x_readwrite { - enum bcm_flash2x_section_val Section; /* section to be read/written */ - u32 offset; /* offset within section. */ - u32 numOfBytes; /* number of bytes from the offset */ - u32 bVerify; - void __user *pDataBuff; /* buffer for reading/writing */ -}; - -/* - * This structure is used for coping one section to other. - * there are two ways to copy one section to other. - * it NOB =0, complete section will be copied on to other. - * if NOB !=0, only NOB will be copied from the given offset. - */ - -struct bcm_flash2x_copy_section { - enum bcm_flash2x_section_val SrcSection; - enum bcm_flash2x_section_val DstSection; - u32 offset; - u32 numOfBytes; -}; - -/* - * This section provide the complete bitmap of the Flash. - * using this map lib/APP will issue read/write command. - * Fields are defined as : - * Bit [0] = section is present //1:present, 0: Not present - * Bit [1] = section is valid //1: valid, 0: not valid - * Bit [2] = Section is R/W //0: RW, 1: RO - * Bit [3] = Section is Active or not 1 means Active, 0->inactive - * Bit [7...3] = Reserved - */ - -struct bcm_flash2x_bitmap { - unsigned char ISO_IMAGE1; - unsigned char ISO_IMAGE2; - unsigned char DSD0; - unsigned char DSD1; - unsigned char DSD2; - unsigned char VSA0; - unsigned char VSA1; - unsigned char VSA2; - unsigned char SCSI; - unsigned char CONTROL_SECTION; - /* Reserved for future use */ - unsigned char Reserved0; - unsigned char Reserved1; - unsigned char Reserved2; -}; - -struct bcm_time_elapsed { - u64 ul64TimeElapsedSinceNetEntry; - u32 uiReserved[4]; -}; - -enum { - WIMAX_IDX = 0, /* To access WiMAX chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE */ - HOST_IDX, /* To access Host chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE */ - MAX_IDX -}; - -struct bcm_gpio_multi_info { - unsigned int uiGPIOCommand; /* 1 for set and 0 for get */ - unsigned int uiGPIOMask; /* set the corresponding bit to 1 to access GPIO */ - unsigned int uiGPIOValue; /* 0 or 1; value to be set when command is 1. */ -} __packed; - -struct bcm_gpio_multi_mode { - unsigned int uiGPIOMode; /* 1 for OUT mode, 0 for IN mode */ - unsigned int uiGPIOMask; /* GPIO mask to set mode */ -} __packed; - -#endif diff --git a/drivers/staging/bcm/Kconfig b/drivers/staging/bcm/Kconfig deleted file mode 100644 index 8acf4b24a7c9..000000000000 --- a/drivers/staging/bcm/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -config BCM_WIMAX - tristate "Beceem BCS200/BCS220-3 and BCSM250 wimax support" - depends on USB && NET - help - This is an experimental driver for the Beceem WIMAX chipset used - by Sprint 4G. diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c deleted file mode 100644 index 86b79d6438d4..000000000000 --- a/drivers/staging/bcm/LeakyBucket.c +++ /dev/null @@ -1,363 +0,0 @@ -/********************************************************************** -* LEAKYBUCKET.C -* This file contains the routines related to Leaky Bucket Algorithm. -***********************************************************************/ -#include "headers.h" - -/** - * UpdateTokenCount() - Calculates the token count for each channel - * and updates the same in Adapter structure - * @Adapter: Pointer to the Adapter structure. - * - * Return: None - */ -static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) -{ - ULONG liCurrentTime; - INT i = 0; - struct timeval tv; - struct bcm_packet_info *curr_pi; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, - "=====>\n"); - if (NULL == Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, - DBG_LVL_ALL, "Adapter found NULL!\n"); - return; - } - - do_gettimeofday(&tv); - for (i = 0; i < NO_OF_QUEUES; i++) { - curr_pi = &Adapter->PackInfo[i]; - - if (TRUE == curr_pi->bValid && (1 == curr_pi->ucDirection)) { - liCurrentTime = ((tv.tv_sec - - curr_pi->stLastUpdateTokenAt.tv_sec)*1000 + - (tv.tv_usec - curr_pi->stLastUpdateTokenAt.tv_usec) / - 1000); - if (0 != liCurrentTime) { - curr_pi->uiCurrentTokenCount += (ULONG) - ((curr_pi->uiMaxAllowedRate) * - ((ULONG)((liCurrentTime)))/1000); - memcpy(&curr_pi->stLastUpdateTokenAt, &tv, - sizeof(struct timeval)); - curr_pi->liLastUpdateTokenAt = liCurrentTime; - if (curr_pi->uiCurrentTokenCount >= - curr_pi->uiMaxBucketSize) { - curr_pi->uiCurrentTokenCount = - curr_pi->uiMaxBucketSize; - } - } - } - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, - "<=====\n"); -} - - -/** - * IsPacketAllowedForFlow() - This function checks whether the given - * packet from the specified queue can be allowed for transmission by - * checking the token count. - * @Adapter: Pointer to the Adpater structure. - * @iQIndex: The queue Identifier. - * @ulPacketLength: Number of bytes to be transmitted. - * - * Returns: The number of bytes allowed for transmission. - */ -static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, - "IsPacketAllowedForFlow ===>"); - - /* Validate the parameters */ - if (NULL == Adapter || (psSF < Adapter->PackInfo && - (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, - "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", - Adapter, (psSF-Adapter->PackInfo)); - return 0; - } - - if (false != psSF->bValid && psSF->ucDirection) { - if (0 != psSF->uiCurrentTokenCount) { - return psSF->uiCurrentTokenCount; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, - DBG_LVL_ALL, - "Not enough tokens in queue %zd Available %u\n", - psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); - psSF->uiPendedLast = 1; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, - "IPAFF: Queue %zd not valid\n", - psSF-Adapter->PackInfo); - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, - "IsPacketAllowedForFlow <==="); - return 0; -} - -/** -@ingroup tx_functions -This function despatches packet from the specified queue. -@return Zero(success) or Negative value(failure) -*/ -static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**"); - if (!Adapter || !Packet || !psSF) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, - "Got NULL Adapter or Packet"); - return -EINVAL; - } - - if (psSF->liDrainCalculated == 0) - psSF->liDrainCalculated = jiffies; - /* send the packet to the fifo.. */ - PktLen = Packet->len; - Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value); - if (Status == 0) { - for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) { - if ((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && - (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) - Adapter->aTxPktSizeHist[uiIndex]++; - } - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, - "<====="); - return Status; -} - -static void get_data_packet(struct bcm_mini_adapter *ad, - struct bcm_packet_info *ps_sf) -{ - int packet_len; - struct sk_buff *qpacket; - - if (!ps_sf->ucDirection) - return; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "UpdateTokenCount "); - if (ad->IdleMode || ad->bPreparingForLowPowerMode) - return; /* in idle mode */ - - /* Check for Free Descriptors */ - if (atomic_read(&ad->CurrNumFreeTxDesc) <= - MINIMUM_PENDING_DESCRIPTORS) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - " No Free Tx Descriptor(%d) is available for Data pkt..", - atomic_read(&ad->CurrNumFreeTxDesc)); - return; - } - - spin_lock_bh(&ps_sf->SFQueueLock); - qpacket = ps_sf->FirstTxQueue; - - if (qpacket) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "Dequeuing Data Packet"); - - if (ps_sf->bEthCSSupport) - packet_len = qpacket->len; - else - packet_len = qpacket->len - ETH_HLEN; - - packet_len <<= 3; - if (packet_len <= GetSFTokenCount(ad, ps_sf)) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, "Allowed bytes %d", - (packet_len >> 3)); - - DEQUEUEPACKET(ps_sf->FirstTxQueue, ps_sf->LastTxQueue); - ps_sf->uiCurrentBytesOnHost -= (qpacket->len); - ps_sf->uiCurrentPacketsOnHost--; - atomic_dec(&ad->TotalPacketCount); - spin_unlock_bh(&ps_sf->SFQueueLock); - - SendPacketFromQueue(ad, ps_sf, qpacket); - ps_sf->uiPendedLast = false; - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, "For Queue: %zd\n", - ps_sf - ad->PackInfo); - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, - "\nAvailable Tokens = %d required = %d\n", - ps_sf->uiCurrentTokenCount, - packet_len); - /* - this part indicates that because of - non-availability of the tokens - pkt has not been send out hence setting the - pending flag indicating the host to send it out - first next iteration. - */ - ps_sf->uiPendedLast = TRUE; - spin_unlock_bh(&ps_sf->SFQueueLock); - } - } else { - spin_unlock_bh(&ps_sf->SFQueueLock); - } -} - -static void send_control_packet(struct bcm_mini_adapter *ad, - struct bcm_packet_info *ps_sf) -{ - char *ctrl_packet = NULL; - INT status = 0; - - if ((atomic_read(&ad->CurrNumFreeTxDesc) > 0) && - (atomic_read(&ad->index_rd_txcntrlpkt) != - atomic_read(&ad->index_wr_txcntrlpkt))) { - ctrl_packet = ad->txctlpacket - [(atomic_read(&ad->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)]; - if (ctrl_packet) { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, - "Sending Control packet"); - status = SendControlPacket(ad, ctrl_packet); - if (STATUS_SUCCESS == status) { - spin_lock_bh(&ps_sf->SFQueueLock); - ps_sf->NumOfPacketsSent++; - ps_sf->uiSentBytes += ((struct bcm_leader *)ctrl_packet)->PLength; - ps_sf->uiSentPackets++; - atomic_dec(&ad->TotalPacketCount); - ps_sf->uiCurrentBytesOnHost -= ((struct bcm_leader *)ctrl_packet)->PLength; - ps_sf->uiCurrentPacketsOnHost--; - atomic_inc(&ad->index_rd_txcntrlpkt); - spin_unlock_bh(&ps_sf->SFQueueLock); - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, - "SendControlPacket Failed\n"); - } - } else { - BCM_DEBUG_PRINT(ad, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, - " Control Pkt is not available, Indexing is wrong...."); - } - } -} - -/** - * CheckAndSendPacketFromIndex() - This function dequeues the - * data/control packet from the specified queue for transmission. - * @Adapter: Pointer to the driver control structure. - * @iQIndex: The queue Identifier. - * - * Returns: None. - */ -static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, - struct bcm_packet_info *psSF) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "%zd ====>", (psSF-Adapter->PackInfo)); - if ((psSF != &Adapter->PackInfo[HiPriority]) && - Adapter->LinkUpStatus && - atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */ - - get_data_packet(Adapter, psSF); - } else { - send_control_packet(Adapter, psSF); - } -} - - -/** - * transmit_packets() - This function transmits the packets from - * different queues, if free descriptors are available on target. - * @Adapter: Pointer to the Adapter structure. - * - * Returns: None. - */ -VOID transmit_packets(struct bcm_mini_adapter *Adapter) -{ - UINT uiPrevTotalCount = 0; - int iIndex = 0; - - bool exit_flag = TRUE; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "=====>"); - - if (NULL == Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "Got NULL Adapter"); - return; - } - if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "Device removed"); - return; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "\nUpdateTokenCount ====>\n"); - - UpdateTokenCount(Adapter); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "\nPruneQueueAllSF ====>\n"); - - PruneQueueAllSF(Adapter); - - uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount); - - for (iIndex = HiPriority; iIndex >= 0; iIndex--) { - if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) - break; - - if (Adapter->PackInfo[iIndex].bValid && - Adapter->PackInfo[iIndex].uiPendedLast && - Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, - "Calling CheckAndSendPacketFromIndex.."); - CheckAndSendPacketFromIndex(Adapter, - &Adapter->PackInfo[iIndex]); - uiPrevTotalCount--; - } - } - - while (uiPrevTotalCount > 0 && !Adapter->device_removed) { - exit_flag = TRUE; - /* second iteration to parse non-pending queues */ - for (iIndex = HiPriority; iIndex >= 0; iIndex--) { - if (!uiPrevTotalCount || - (TRUE == Adapter->device_removed)) - break; - - if (Adapter->PackInfo[iIndex].bValid && - Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && - !Adapter->PackInfo[iIndex].uiPendedLast) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, - TX_PACKETS, DBG_LVL_ALL, - "Calling CheckAndSendPacketFromIndex.."); - CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); - uiPrevTotalCount--; - exit_flag = false; - } - } - - if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, "In Idle Mode\n"); - break; - } - if (exit_flag == TRUE) - break; - } /* end of inner while loop */ - - update_per_cid_rx(Adapter); - Adapter->txtransmit_running = 0; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "<======"); -} diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h deleted file mode 100644 index dc01e3016d4f..000000000000 --- a/drivers/staging/bcm/Macros.h +++ /dev/null @@ -1,352 +0,0 @@ -/************************************* -* Macros.h -**************************************/ -#ifndef __MACROS_H__ -#define __MACROS_H__ - -#define TX_TIMER_PERIOD 10 /*10 msec*/ -#define MAX_CLASSIFIERS 100 -#define MAX_TARGET_DSX_BUFFERS 24 - -#define MAX_CNTRL_PKTS 100 -#define MAX_DATA_PKTS 200 -#define MAX_ETH_SIZE 1536 -#define MAX_CNTL_PKT_SIZE 2048 - -#define MTU_SIZE 1400 -#define TX_QLEN 5 - -#define MAC_ADDR_REGISTER 0xbf60d000 - - -/* Quality of Service */ -#define NO_OF_QUEUES 17 -#define HiPriority (NO_OF_QUEUES-1) -#define LowPriority 0 -#define BE 2 -#define rtPS 4 -#define ERTPS 5 -#define UGS 6 - -#define BE_BUCKET_SIZE (1024*1024*100) /* 32kb */ -#define rtPS_BUCKET_SIZE (1024*1024*100) /* 8kb */ -#define MAX_ALLOWED_RATE (1024*1024*100) -#define TX_PACKET_THRESHOLD 10 -#define XSECONDS (1*HZ) -#define DSC_ACTIVATE_REQUEST 248 -#define QUEUE_DEPTH_OFFSET 0x1fc01000 -#define MAX_DEVICE_DESC_SIZE 2040 -#define MAX_CTRL_QUEUE_LEN 100 -#define MAX_APP_QUEUE_LEN 200 -#define MAX_LATENCY_ALLOWED 0xFFFFFFFF -#define DEFAULT_UG_INTERVAL 250 -#define DEFAULT_UGI_FACTOR 4 - -#define DEFAULT_PERSFCOUNT 60 -#define MAX_CONNECTIONS 10 -#define MAX_CLASS_NAME_LENGTH 32 - -#define ETH_LENGTH_OF_ADDRESS 6 -#define MAX_MULTICAST_ADDRESSES 32 -#define IP_LENGTH_OF_ADDRESS 4 - -#define IP_PACKET_ONLY_MODE 0 -#define ETH_PACKET_TUNNELING_MODE 1 - -/* Link Request */ -#define SET_MAC_ADDRESS_REQUEST 0 -#define SYNC_UP_REQUEST 1 -#define SYNCED_UP 2 -#define LINK_UP_REQUEST 3 -#define LINK_CONNECTED 4 -#define SYNC_UP_NOTIFICATION 2 -#define LINK_UP_NOTIFICATION 4 - - -#define LINK_NET_ENTRY 0x0002 -#define HMC_STATUS 0x0004 -#define LINK_UP_CONTROL_REQ 0x83 - -#define STATS_POINTER_REQ_STATUS 0x86 -#define NETWORK_ENTRY_REQ_PAYLOAD 198 -#define LINK_DOWN_REQ_PAYLOAD 226 -#define SYNC_UP_REQ_PAYLOAD 228 -#define STATISTICS_POINTER_REQ 237 -#define LINK_UP_REQ_PAYLOAD 245 -#define LINK_UP_ACK 246 - -#define STATS_MSG_SIZE 4 -#define INDEX_TO_DATA 4 - -#define GO_TO_IDLE_MODE_PAYLOAD 210 -#define COME_UP_FROM_IDLE_MODE_PAYLOAD 211 -#define IDLE_MODE_SF_UPDATE_MSG 187 - -#define SKB_RESERVE_ETHERNET_HEADER 16 -#define SKB_RESERVE_PHS_BYTES 32 - -#define IP_PACKET_ONLY_MODE 0 -#define ETH_PACKET_TUNNELING_MODE 1 - -#define ETH_CS_802_3 1 -#define ETH_CS_802_1Q_VLAN 3 -#define IPV4_CS 1 -#define IPV6_CS 2 -#define ETH_CS_MASK 0x3f - -/** \brief Validity bit maps for TLVs in packet classification rule */ - -#define PKT_CLASSIFICATION_USER_PRIORITY_VALID 0 -#define PKT_CLASSIFICATION_VLANID_VALID 1 - -#ifndef MIN -#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b)) -#endif - - -/*Leader related terms */ -#define LEADER_STATUS 0x00 -#define LEADER_STATUS_TCP_ACK 0x1 -#define LEADER_SIZE sizeof(struct bcm_leader) -#define MAC_ADDR_REQ_SIZE sizeof(struct bcm_packettosend) -#define SS_INFO_REQ_SIZE sizeof(struct bcm_packettosend) -#define CM_REQUEST_SIZE (LEADER_SIZE + sizeof(stLocalSFChangeRequest)) -#define IDLE_REQ_SIZE sizeof(struct bcm_packettosend) - - -#define MAX_TRANSFER_CTRL_BYTE_USB (2*1024) - -#define GET_MAILBOX1_REG_REQUEST 0x87 -#define GET_MAILBOX1_REG_RESPONSE 0x67 -#define VCID_CONTROL_PACKET 0x00 - -#define TRANSMIT_NETWORK_DATA 0x00 -#define RECEIVED_NETWORK_DATA 0x20 - -#define CM_RESPONSES 0xA0 -#define STATUS_RSP 0xA1 -#define LINK_CONTROL_RESP 0xA2 -#define IDLE_MODE_STATUS 0xA3 -#define STATS_POINTER_RESP 0xA6 -#define MGMT_MSG_INFO_SW_STATUS 0xA7 -#define AUTH_SS_HOST_MSG 0xA8 - -#define CM_DSA_ACK_PAYLOAD 247 -#define CM_DSC_ACK_PAYLOAD 248 -#define CM_DSD_ACK_PAYLOAD 249 -#define CM_DSDEACTVATE 250 -#define TOTAL_MASKED_ADDRESS_IN_BYTES 32 - -#define MAC_REQ 0 -#define LINK_RESP 1 -#define RSSI_INDICATION 2 - -#define SS_INFO 4 -#define STATISTICS_INFO 5 -#define CM_INDICATION 6 -#define PARAM_RESP 7 -#define BUFFER_1K 1024 -#define BUFFER_2K (BUFFER_1K*2) -#define BUFFER_4K (BUFFER_2K*2) -#define BUFFER_8K (BUFFER_4K*2) -#define BUFFER_16K (BUFFER_8K*2) -#define DOWNLINK_DIR 0 -#define UPLINK_DIR 1 - -#define BCM_SIGNATURE "BECEEM" - - -#define GPIO_OUTPUT_REGISTER 0x0F00003C -#define BCM_GPIO_OUTPUT_SET_REG 0x0F000040 -#define BCM_GPIO_OUTPUT_CLR_REG 0x0F000044 -#define GPIO_MODE_REGISTER 0x0F000034 -#define GPIO_PIN_STATE_REGISTER 0x0F000038 - -struct bcm_link_state { - unsigned char ucLinkStatus; - unsigned char bIdleMode; - unsigned char bShutdownMode; -}; - -enum enLinkStatus { - WAIT_FOR_SYNC = 1, - PHY_SYNC_ACHIVED = 2, - LINKUP_IN_PROGRESS = 3, - LINKUP_DONE = 4, - DREG_RECEIVED = 5, - LINK_STATUS_RESET_RECEIVED = 6, - PERIODIC_WAKE_UP_NOTIFICATION_FRM_FW = 7, - LINK_SHUTDOWN_REQ_FROM_FIRMWARE = 8, - COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW = 9 -}; - -enum bcm_phs_dsc_action { - eAddPHSRule = 0, - eSetPHSRule, - eDeletePHSRule, - eDeleteAllPHSRules -}; - -#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 /* Host to Mac */ -#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 /* Mac to Host */ -#define MASK_DISABLE_HEADER_SUPPRESSION 0x10 /* 0b000010000 */ -#define MINIMUM_PENDING_DESCRIPTORS 5 - -#define SHUTDOWN_HOSTINITIATED_REQUESTPAYLOAD 0xCC -#define SHUTDOWN_ACK_FROM_DRIVER 0x1 -#define SHUTDOWN_NACK_FROM_DRIVER 0x2 - -#define LINK_SYNC_UP_SUBTYPE 0x0001 -#define LINK_SYNC_DOWN_SUBTYPE 0x0001 - - - -#define CONT_MODE 1 -#define SINGLE_DESCRIPTOR 1 - - -#define DESCRIPTOR_LENGTH 0x30 -#define FIRMWARE_DESCS_ADDRESS 0x1F100000 - - -#define CLOCK_RESET_CNTRL_REG_1 0x0F00000C -#define CLOCK_RESET_CNTRL_REG_2 0x0F000840 - - - -#define TX_DESCRIPTOR_HEAD_REGISTER 0x0F010034 -#define RX_DESCRIPTOR_HEAD_REGISTER 0x0F010094 - -#define STATISTICS_BEGIN_ADDR 0xbf60f02c - -#define MAX_PENDING_CTRL_PACKET (MAX_CTRL_QUEUE_LEN-10) - -#define WIMAX_MAX_MTU (MTU_SIZE + ETH_HLEN) -#define AUTO_LINKUP_ENABLE 0x2 -#define AUTO_SYNC_DISABLE 0x1 -#define AUTO_FIRM_DOWNLOAD 0x1 -#define SETTLE_DOWN_TIME 50 - -#define HOST_BUS_SUSPEND_BIT 16 - -#define IDLE_MESSAGE 0x81 - -#define MIPS_CLOCK_133MHz 1 - -#define TARGET_CAN_GO_TO_IDLE_MODE 2 -#define TARGET_CAN_NOT_GO_TO_IDLE_MODE 3 -#define IDLE_MODE_PAYLOAD_LENGTH 8 - -#define IP_HEADER(Buffer) ((IPHeaderFormat *)(Buffer)) -#define IPV4 4 -#define IP_VERSION(byte) (((byte&0xF0)>>4)) - -#define SET_MAC_ADDRESS 193 -#define SET_MAC_ADDRESS_RESPONSE 236 - -#define IDLE_MODE_WAKEUP_PATTERN 0xd0ea1d1e -#define IDLE_MODE_WAKEUP_NOTIFIER_ADDRESS 0x1FC02FA8 -#define IDLE_MODE_MAX_RETRY_COUNT 1000 - -#define CONFIG_BEGIN_ADDR 0xBF60B000 - -#define FIRMWARE_BEGIN_ADDR 0xBFC00000 - -#define INVALID_QUEUE_INDEX NO_OF_QUEUES - -#define INVALID_PID ((pid_t)-1) -#define DDR_80_MHZ 0 -#define DDR_100_MHZ 1 -#define DDR_120_MHZ 2 /* Additional Frequency for T3LP */ -#define DDR_133_MHZ 3 -#define DDR_140_MHZ 4 /* Not Used (Reserved for future) */ -#define DDR_160_MHZ 5 /* Additional Frequency for T3LP */ -#define DDR_180_MHZ 6 /* Not Used (Reserved for future) */ -#define DDR_200_MHZ 7 /* Not Used (Reserved for future) */ - -#define MIPS_200_MHZ 0 -#define MIPS_160_MHZ 1 - -#define PLL_800_MHZ 0 -#define PLL_266_MHZ 1 - -#define DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING 0 -#define DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING 1 -#define DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN 2 -#define DEVICE_POWERSAVE_MODE_AS_RESERVED 3 -#define DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE 4 - - -#define EEPROM_REJECT_REG_1 0x0f003018 -#define EEPROM_REJECT_REG_2 0x0f00301c -#define EEPROM_REJECT_REG_3 0x0f003008 -#define EEPROM_REJECT_REG_4 0x0f003020 -#define EEPROM_REJECT_MASK 0x0fffffff -#define VSG_MODE 0x3 - -/* Idle Mode Related Registers */ -#define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C -#define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC - -#define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e -#define DEVICE_INT_OUT_EP_REG0 0x0F011870 -#define DEVICE_INT_OUT_EP_REG1 0x0F011874 - -#define BIN_FILE "/lib/firmware/macxvi200.bin" -#define CFG_FILE "/lib/firmware/macxvi.cfg" -#define SF_MAX_ALLOWED_PACKETS_TO_BACKUP 128 -#define MIN_VAL(x, y) ((x) < (y) ? (x) : (y)) -#define MAC_ADDRESS_SIZE 6 -#define EEPROM_COMMAND_Q_REG 0x0F003018 -#define EEPROM_READ_DATA_Q_REG 0x0F003020 -#define CHIP_ID_REG 0x0F000000 -#define GPIO_MODE_REG 0x0F000034 -#define GPIO_OUTPUT_REG 0x0F00003C -#define WIMAX_MAX_ALLOWED_RATE (1024*1024*50) - -#define T3 0xbece0300 -#define TARGET_SFID_TXDESC_MAP_LOC 0xBFFFF400 - -#define RWM_READ 0 -#define RWM_WRITE 1 - -#define T3LPB 0xbece3300 -#define BCS220_2 0xbece3311 -#define BCS220_2BC 0xBECE3310 -#define BCS250_BC 0xbece3301 -#define BCS220_3 0xbece3321 - - -#define HPM_CONFIG_LDO145 0x0F000D54 -#define HPM_CONFIG_MSW 0x0F000D58 - -#define T3B 0xbece0310 -enum bcm_nvm_type { - NVM_AUTODETECT = 0, - NVM_EEPROM, - NVM_FLASH, - NVM_UNKNOWN -}; - -enum bcm_pmu_modes { - HYBRID_MODE_7C = 0, - INTERNAL_MODE_6 = 1, - HYBRID_MODE_6 = 2 -}; - -#define MAX_RDM_WRM_RETIRES 1 - -enum eAbortPattern { - ABORT_SHUTDOWN_MODE = 1, - ABORT_IDLE_REG = 1, - ABORT_IDLE_MODE = 2, - ABORT_IDLE_SYNCDOWN = 3 -}; - - -/* Offsets used by driver in skb cb variable */ -#define SKB_CB_CLASSIFICATION_OFFSET 0 -#define SKB_CB_LATENCY_OFFSET 1 -#define SKB_CB_TCPACK_OFFSET 2 - -#endif /* __MACROS_H__ */ diff --git a/drivers/staging/bcm/Makefile b/drivers/staging/bcm/Makefile deleted file mode 100644 index 652b7f87737c..000000000000 --- a/drivers/staging/bcm/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# -# Makefile for Beceem USB Wimax card -# - -obj-$(CONFIG_BCM_WIMAX) += bcm_wimax.o - -bcm_wimax-y := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \ - InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \ - CmHost.o IPv6Protocol.o Qos.o Transmit.o\ - Bcmnet.o DDRInit.o HandleControlPacket.o\ - LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\ - led_control.o nvm.o vendorspecificextn.o diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c deleted file mode 100644 index 883f7394dee6..000000000000 --- a/drivers/staging/bcm/Misc.c +++ /dev/null @@ -1,1587 +0,0 @@ -#include "headers.h" - -static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc); -static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter); -static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer); -static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter); -static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter); - -static void default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiLoopIndex; - - for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++) { - Adapter->PackInfo[uiLoopIndex].uiThreshold = TX_PACKET_THRESHOLD; - Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate = MAX_ALLOWED_RATE; - Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize = 20*1024*1024; - } - - Adapter->BEBucketSize = BE_BUCKET_SIZE; - Adapter->rtPSBucketSize = rtPS_BUCKET_SIZE; - Adapter->LinkStatus = SYNC_UP_REQUEST; - Adapter->TransferMode = IP_PACKET_ONLY_MODE; - Adapter->usBestEffortQueueIndex = -1; -} - -int InitAdapter(struct bcm_mini_adapter *psAdapter) -{ - int i = 0; - int Status = STATUS_SUCCESS; - - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = %p", psAdapter); - - if (psAdapter == NULL) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL"); - return -EINVAL; - } - - sema_init(&psAdapter->NVMRdmWrmLock, 1); - sema_init(&psAdapter->rdmwrmsync, 1); - spin_lock_init(&psAdapter->control_queue_lock); - spin_lock_init(&psAdapter->txtransmitlock); - sema_init(&psAdapter->RxAppControlQueuelock, 1); - sema_init(&psAdapter->fw_download_sema, 1); - sema_init(&psAdapter->LowPowerModeSync, 1); - - for (i = 0; i < NO_OF_QUEUES; i++) - spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock); - i = 0; - - init_waitqueue_head(&psAdapter->process_rx_cntrlpkt); - init_waitqueue_head(&psAdapter->tx_packet_wait_queue); - init_waitqueue_head(&psAdapter->process_read_wait_queue); - init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue); - init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue); - psAdapter->waiting_to_fw_download_done = TRUE; - psAdapter->fw_download_done = false; - - default_wimax_protocol_initialize(psAdapter); - for (i = 0; i < MAX_CNTRL_PKTS; i++) { - psAdapter->txctlpacket[i] = kmalloc(MAX_CNTL_PKT_SIZE, GFP_KERNEL); - if (!psAdapter->txctlpacket[i]) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i); - return -ENOMEM; - } - } - - if (AllocAdapterDsxBuffer(psAdapter)) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers"); - return -EINVAL; - } - - /* Initialize PHS interface */ - if (phs_init(&psAdapter->stBCMPhsContext, psAdapter) != 0) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __func__, __LINE__); - return -ENOMEM; - } - - Status = BcmAllocFlashCSStructure(psAdapter); - if (Status) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Memory Allocation for Flash structure failed"); - return Status; - } - - Status = vendorextnInit(psAdapter); - - if (STATUS_SUCCESS != Status) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Vendor Init Failed"); - return Status; - } - - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised"); - - return STATUS_SUCCESS; -} - -void AdapterFree(struct bcm_mini_adapter *Adapter) -{ - int count; - - beceem_protocol_reset(Adapter); - vendorextnExit(Adapter); - - if (Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler)) - kthread_stop(Adapter->control_packet_handler); - - if (Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread)) - kthread_stop(Adapter->transmit_packet_thread); - - wake_up(&Adapter->process_read_wait_queue); - - if (Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) - kthread_stop(Adapter->LEDInfo.led_cntrl_threadid); - - unregister_networkdev(Adapter); - - /* FIXME: use proper wait_event and refcounting */ - while (atomic_read(&Adapter->ApplicationRunning)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n", atomic_read(&Adapter->ApplicationRunning)); - msleep(100); - } - unregister_control_device_interface(Adapter); - kfree(Adapter->pstargetparams); - - for (count = 0; count < MAX_CNTRL_PKTS; count++) - kfree(Adapter->txctlpacket[count]); - - FreeAdapterDsxBuffer(Adapter); - kfree(Adapter->pvInterfaceAdapter); - - /* Free the PHS Interface */ - PhsCleanup(&Adapter->stBCMPhsContext); - - BcmDeAllocFlashCSStructure(Adapter); - - free_netdev(Adapter->dev); -} - -static int create_worker_threads(struct bcm_mini_adapter *psAdapter) -{ - /* Rx Control Packets Processing */ - psAdapter->control_packet_handler = kthread_run((int (*)(void *)) - control_packet_handler, psAdapter, "%s-rx", DRV_NAME); - if (IS_ERR(psAdapter->control_packet_handler)) { - pr_notice(DRV_NAME ": could not create control thread\n"); - return PTR_ERR(psAdapter->control_packet_handler); - } - - /* Tx Thread */ - psAdapter->transmit_packet_thread = kthread_run((int (*)(void *)) - tx_pkt_handler, psAdapter, "%s-tx", DRV_NAME); - if (IS_ERR(psAdapter->transmit_packet_thread)) { - pr_notice(DRV_NAME ": could not creat transmit thread\n"); - kthread_stop(psAdapter->control_packet_handler); - return PTR_ERR(psAdapter->transmit_packet_thread); - } - return 0; -} - -static struct file *open_firmware_file(struct bcm_mini_adapter *Adapter, const char *path) -{ - struct file *flp = filp_open(path, O_RDONLY, S_IRWXU); - - if (IS_ERR(flp)) { - pr_err(DRV_NAME "Unable To Open File %s, err %ld", path, PTR_ERR(flp)); - flp = NULL; - } - - if (Adapter->device_removed) - flp = NULL; - - return flp; -} - -/* Arguments: - * Logical Adapter - * Path to image file - * Download Address on the chip - */ -static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc) -{ - int errorno = 0; - struct file *flp = NULL; - struct timeval tv = {0}; - - flp = open_firmware_file(Adapter, path); - if (!flp) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); - return -ENOENT; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)file_inode(flp)->i_size, loc); - do_gettimeofday(&tv); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) + (tv.tv_usec / 1000))); - if (Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error %x!!!", -EIO); - errorno = -EIO; - goto exit_download; - } - vfs_llseek(flp, 0, 0); - if (Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!"); - errorno = -EIO; - goto exit_download; - } - -exit_download: - filp_close(flp, NULL); - return errorno; -} - -/** - * @ingroup ctrl_pkt_functions - * This function copies the contents of given buffer - * to the control packet and queues it for transmission. - * @note Do not acquire the spinlock, as it it already acquired. - * @return SUCCESS/FAILURE. - * Arguments: - * Logical Adapter - * Control Packet Buffer - */ -int CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, void *ioBuffer) -{ - struct bcm_leader *pLeader = NULL; - int Status = 0; - unsigned char *ctrl_buff; - unsigned int pktlen = 0; - struct bcm_link_request *pLinkReq = NULL; - PUCHAR pucAddIndication = NULL; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>"); - if (!ioBuffer) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got Null Buffer\n"); - return -EINVAL; - } - - pLinkReq = (struct bcm_link_request *)ioBuffer; - pLeader = (struct bcm_leader *)ioBuffer; /* ioBuffer Contains sw_Status and Payload */ - - if (Adapter->bShutStatus == TRUE && - pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD && - pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE) { - - /* Got sync down in SHUTDOWN..we could not process this. */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n"); - return STATUS_FAILURE; - } - - if ((pLeader->Status == LINK_UP_CONTROL_REQ) && - ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD && - (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) || /* Sync Up Command */ - pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) /* Net Entry Command */ { - - if (Adapter->LinkStatus > PHY_SYNC_ACHIVED) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "LinkStatus is Greater than PHY_SYN_ACHIEVED"); - return STATUS_FAILURE; - } - - if (Adapter->bShutStatus == TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n"); - if (Adapter->bTriedToWakeUpFromlowPowerMode == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Waking up for the First Time..\n"); - Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; /* change it to 1 for current support. */ - Adapter->bWakeUpDevice = TRUE; - wake_up(&Adapter->process_rx_cntrlpkt); - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->bShutStatus, (5 * HZ)); - - if (Status == -ERESTARTSYS) - return Status; - - if (Adapter->bShutStatus) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n"); - return STATUS_FAILURE; - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Wakeup has been tried already...\n"); - } - } - } - - if (Adapter->IdleMode == TRUE) { - /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence\n"); */ - if (pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 || - pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ) { - - if ((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD)) { - if (pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Link Down Sent in Idle Mode\n"); - Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN; /* LINK DOWN sent in Idle Mode */ - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n"); - Adapter->usIdleModePattern = ABORT_IDLE_REG; - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "ABORT_IDLE_MODE pattern is being written\n"); - Adapter->usIdleModePattern = ABORT_IDLE_MODE; - } - - /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent - * the wake up from idlemode is from host - */ - /* Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; */ - Adapter->bWakeUpDevice = TRUE; - wake_up(&Adapter->process_rx_cntrlpkt); - - /* We should not send DREG message down while in idlemode. */ - if (LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0]) - return STATUS_SUCCESS; - - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, !Adapter->IdleMode, (5 * HZ)); - - if (Status == -ERESTARTSYS) - return Status; - - if (Adapter->IdleMode) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n"); - return STATUS_FAILURE; - } - } else { - return STATUS_SUCCESS; - } - } - - /* The Driver has to send control messages with a particular VCID */ - pLeader->Vcid = VCID_CONTROL_PACKET; /* VCID for control packet. */ - - /* Allocate skb for Control Packet */ - pktlen = pLeader->PLength; - ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS]; - - if (!ctrl_buff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed"); - return -ENOMEM; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x", - atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen); - - if (pLeader) { - if ((pLeader->Status == 0x80) || - (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ)) { - /* - * Restructure the DSX message to handle Multiple classifier Support - * Write the Service Flow param Structures directly to the target - * and embed the pointers in the DSX messages sent to target. - */ - /* Lets store the current length of the control packet we are transmitting */ - pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE; - pktlen = pLeader->PLength; - Status = StoreCmControlResponseMessage(Adapter, pucAddIndication, &pktlen); - if (Status != 1) { - ClearTargetDSXBuffer(Adapter, ((struct bcm_add_indication_alt *)pucAddIndication)->u16TID, false); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly "); - return STATUS_FAILURE; - } - /* - * update the leader to use the new length - * The length of the control packet is length of message being sent + Leader length - */ - pLeader->PLength = pktlen; - } - } - - if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE) - return -EINVAL; - - memset(ctrl_buff, 0, pktlen+LEADER_SIZE); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength); - *(struct bcm_leader *)ctrl_buff = *pLeader; - memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet"); - - /* Update the statistics counters */ - spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); - Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost += pLeader->PLength; - Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++; - atomic_inc(&Adapter->TotalPacketCount); - spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock); - Adapter->PackInfo[HiPriority].bValid = TRUE; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x", - Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost, - Adapter->PackInfo[HiPriority].bValid); - Status = STATUS_SUCCESS; - /*Queue the packet for transmission */ - atomic_inc(&Adapter->index_wr_txcntrlpkt); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Calling transmit_packets"); - atomic_set(&Adapter->TxPktAvail, 1); - wake_up(&Adapter->tx_packet_wait_queue); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<===="); - return Status; -} - -/****************************************************************** -* Function - LinkMessage() -* -* Description - This function builds the Sync-up and Link-up request -* packet messages depending on the device Link status. -* -* Parameters - Adapter: Pointer to the Adapter structure. -* -* Returns - None. -*******************************************************************/ -void LinkMessage(struct bcm_mini_adapter *Adapter) -{ - struct bcm_link_request *pstLinkRequest = NULL; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>"); - if (Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) { - pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC); - if (!pstLinkRequest) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); - return; - } - /* sync up request... */ - Adapter->LinkStatus = WAIT_FOR_SYNC; /* current link status */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp..."); - pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD; - pstLinkRequest->szData[1] = LINK_SYNC_UP_SUBTYPE; - pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ; - pstLinkRequest->Leader.PLength = sizeof(ULONG); - Adapter->bSyncUpRequestSent = TRUE; - - } else if (Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) { - pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC); - if (!pstLinkRequest) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!"); - return; - } - /* LINK_UP_REQUEST */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp..."); - pstLinkRequest->szData[0] = LINK_UP_REQ_PAYLOAD; - pstLinkRequest->szData[1] = LINK_NET_ENTRY; - pstLinkRequest->Leader.Status = LINK_UP_CONTROL_REQ; - pstLinkRequest->Leader.PLength = sizeof(ULONG); - } - if (pstLinkRequest) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket"); - CopyBufferToControlPacket(Adapter, pstLinkRequest); - kfree(pstLinkRequest); - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <====="); - return; -} - -/********************************************************************** -* Function - StatisticsResponse() -* -* Description - This function handles the Statistics response packet. -* -* Parameters - Adapter : Pointer to the Adapter structure. -* - pvBuffer: Starting address of Statistic response data. -* -* Returns - None. -************************************************************************/ -void StatisticsResponse(struct bcm_mini_adapter *Adapter, void *pvBuffer) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__); - Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %x", (unsigned int)Adapter->StatisticsPointer); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====", __func__); -} - -/********************************************************************** -* Function - LinkControlResponseMessage() -* -* Description - This function handles the Link response packets. -* -* Parameters - Adapter : Pointer to the Adapter structure. -* - pucBuffer: Starting address of Link response data. -* -* Returns - None. -***********************************************************************/ -void LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>"); - - if (*pucBuffer == LINK_UP_ACK) { - switch (*(pucBuffer+1)) { - case PHY_SYNC_ACHIVED: /* SYNCed UP */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED"); - - if (Adapter->LinkStatus == LINKUP_DONE) - beceem_protocol_reset(Adapter); - - Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; - Adapter->LinkStatus = PHY_SYNC_ACHIVED; - - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = NO_NETWORK_ENTRY; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - - LinkMessage(Adapter); - break; - - case LINKUP_DONE: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE"); - Adapter->LinkStatus = LINKUP_DONE; - Adapter->bPHSEnabled = *(pucBuffer+3); - Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Received In LinkUp Ack : %x\n", Adapter->bPHSEnabled); - - if ((false == Adapter->bShutStatus) && (false == Adapter->IdleMode)) { - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = NORMAL_OPERATION; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - } - LinkMessage(Adapter); - break; - - case WAIT_FOR_SYNC: - /* - * Driver to ignore the DREG_RECEIVED - * WiMAX Application should handle this Message - */ - /* Adapter->liTimeSinceLastNetEntry = 0; */ - Adapter->LinkUpStatus = 0; - Adapter->LinkStatus = 0; - Adapter->usBestEffortQueueIndex = INVALID_QUEUE_INDEX; - Adapter->bTriedToWakeUpFromlowPowerMode = false; - Adapter->IdleMode = false; - beceem_protocol_reset(Adapter); - - break; - case LINK_SHUTDOWN_REQ_FROM_FIRMWARE: - case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW: - { - HandleShutDownModeRequest(Adapter, pucBuffer); - } - break; - default: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x", *(pucBuffer + 1)); - break; - } - } else if (SET_MAC_ADDRESS_RESPONSE == *pucBuffer) { - PUCHAR puMacAddr = (pucBuffer + 1); - - Adapter->LinkStatus = SYNC_UP_REQUEST; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP"); - LinkMessage(Adapter); - memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====", __func__); -} - -void SendIdleModeResponse(struct bcm_mini_adapter *Adapter) -{ - int status = 0, NVMAccess = 0, lowPwrAbortMsg = 0; - struct timeval tv; - struct bcm_link_request stIdleResponse = {{0} }; - - memset(&tv, 0, sizeof(tv)); - stIdleResponse.Leader.Status = IDLE_MESSAGE; - stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH; - stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, " ============>"); - - /********************************* - *down_trylock - - * if [ semaphore is available ] - * acquire semaphone and return value 0 ; - * else - * return non-zero value ; - * - ***********************************/ - - NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync); - - - if ((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) && - (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) { - - if (!NVMAccess) - up(&Adapter->NVMRdmWrmLock); - - if (!lowPwrAbortMsg) - up(&Adapter->LowPowerModeSync); - - stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!"); - Adapter->bPreparingForLowPowerMode = false; - } else { - stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; /* 2; Idle ACK */ - Adapter->StatisticsPointer = 0; - - /* Wait for the LED to TURN OFF before sending ACK response */ - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - int iRetVal = 0; - - /* Wake the LED Thread with IDLEMODE_ENTER State */ - Adapter->DriverState = LOWPOWER_MODE_ENTER; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld", jiffies); - wake_up(&Adapter->LEDInfo.notify_led_event); - - /* Wait for 1 SEC for LED to OFF */ - iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); - - /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ - if (iRetVal <= 0) { - stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE; /* NACK- device access is going on. */ - Adapter->DriverState = NORMAL_OPERATION; - wake_up(&Adapter->LEDInfo.notify_led_event); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!"); - } - } - - if (stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "ACKING IDLE MODE !!!!!!!!!"); - down(&Adapter->rdmwrmsync); - Adapter->bPreparingForLowPowerMode = TRUE; - up(&Adapter->rdmwrmsync); - /* Killing all URBS. */ - if (Adapter->bDoSuspend == TRUE) - Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); - } else { - Adapter->bPreparingForLowPowerMode = false; - } - - if (!NVMAccess) - up(&Adapter->NVMRdmWrmLock); - - if (!lowPwrAbortMsg) - up(&Adapter->LowPowerModeSync); - } - - status = CopyBufferToControlPacket(Adapter, &stIdleResponse); - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "fail to send the Idle mode Request\n"); - Adapter->bPreparingForLowPowerMode = false; - StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); - } - do_gettimeofday(&tv); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec * 1000 + tv.tv_usec / 1000); -} - -/****************************************************************** -* Function - DumpPackInfo() -* -* Description - This function dumps the all Queue(PackInfo[]) details. -* -* Parameters - Adapter: Pointer to the Adapter structure. -* -* Returns - None. -*******************************************************************/ -void DumpPackInfo(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiLoopIndex = 0; - unsigned int uiIndex = 0; - unsigned int uiClsfrIndex = 0; - struct bcm_classifier_rule *pstClassifierEntry = NULL; - - for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex); - if (false == Adapter->PackInfo[uiLoopIndex].bValid) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid is false for %X index\n", uiLoopIndex); - continue; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " Dumping SF Rule Entry For SFID %lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, " ucDirection %X\n", Adapter->PackInfo[uiLoopIndex].ucDirection); - - if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv6 Service Flow\n"); - else - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Ipv4 Service Flow\n"); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SF Traffic Priority %X\n", Adapter->PackInfo[uiLoopIndex].u8TrafficPriority); - - for (uiClsfrIndex = 0; uiClsfrIndex < MAX_CLASSIFIERS; uiClsfrIndex++) { - pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex]; - if (!pstClassifierEntry->bUsed) - continue; - - if (pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID) - continue; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n", uiClsfrIndex, pstClassifierEntry->uiClassifierRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n", uiClsfrIndex, pstClassifierEntry->usVCID_Value); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n", uiClsfrIndex, pstClassifierEntry->bProtocolValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n", uiClsfrIndex, pstClassifierEntry->bTOSValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bDestIpValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n", uiClsfrIndex, pstClassifierEntry->bSrcIpValid); - - for (uiIndex = 0; uiIndex < MAX_PORT_RANGE; uiIndex++) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeLo:%X\n", pstClassifierEntry->usSrcPortRangeLo[uiIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusSrcPortRangeHi:%X\n", pstClassifierEntry->usSrcPortRangeHi[uiIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeLo:%X\n", pstClassifierEntry->usDestPortRangeLo[uiIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tusDestPortRangeHi:%X\n", pstClassifierEntry->usDestPortRangeHi[uiIndex]); - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPSourceAddressLength : 0x%x\n", pstClassifierEntry->ucIPSourceAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucIPDestinationAddressLength : 0x%x\n", pstClassifierEntry->ucIPDestinationAddressLength); - for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPSourceAddressLength; uiIndex++) { - if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpAddr :\n"); - DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulSrcIpMask :\n"); - DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpAddr:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulSrcIpMask:%lX\n", pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]); - } - } - - for (uiIndex = 0; uiIndex < pstClassifierEntry->ucIPDestinationAddressLength; uiIndex++) { - if (Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpAddr :\n"); - DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tIpv6 ulDestIpMask :\n"); - DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpAddr:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tulDestIpMask:%lX\n", pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]); - } - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tucProtocol:0x%X\n", pstClassifierEntry->ucProtocol[0]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\tu8ClassifierRulePriority:%X\n", pstClassifierEntry->u8ClassifierRulePriority); - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ulSFID:%lX\n", Adapter->PackInfo[uiLoopIndex].ulSFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "usVCID_Value:%X\n", Adapter->PackInfo[uiLoopIndex].usVCID_Value); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "PhsEnabled: 0x%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThreshold:%X\n", Adapter->PackInfo[uiLoopIndex].uiThreshold); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bValid:%X\n", Adapter->PackInfo[uiLoopIndex].bValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bActive:%X\n", Adapter->PackInfo[uiLoopIndex].bActive); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "u8QueueType:%X\n", Adapter->PackInfo[uiLoopIndex].u8QueueType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxBucketSize:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPerSFTxResourceCount:%X\n", atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount)); - /* DumpDebug(DUMP_INFO,("bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentBytesOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentPacketsOnHost:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiDroppedCountPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiSentPackets:%X\n", Adapter->PackInfo[uiLoopIndex].uiSentPackets); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentDrainRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiThisPeriodSentBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liDrainCalculated:%llX\n", Adapter->PackInfo[uiLoopIndex].liDrainCalculated); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiCurrentTokenCount:%X\n", Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "liLastUpdateTokenAt:%llX\n", Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxAllowedRate:%X\n", Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiPendedLast:%X\n", Adapter->PackInfo[uiLoopIndex].uiPendedLast); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "NumOfPacketsSent:%X\n", Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n", Adapter->PackInfo[uiLoopIndex].uiMaxLatency); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, - DBG_LVL_ALL, "ServiceClassName: %*ph\n", - 4, Adapter->PackInfo[uiLoopIndex]. - ucServiceClassName); -/* BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled); - * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes); - * BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes); - * DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount)); - */ - } - - for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aRxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aRxPktSizeHist[uiLoopIndex]); - - for (uiLoopIndex = 0; uiLoopIndex < MIBS_MAX_HIST_ENTRIES; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Adapter->aTxPktSizeHist[%x] = %x\n", uiLoopIndex, Adapter->aTxPktSizeHist[uiLoopIndex]); -} - -int reset_card_proc(struct bcm_mini_adapter *ps_adapter) -{ - int retval = STATUS_SUCCESS; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_interface_adapter *psIntfAdapter = NULL; - unsigned int value = 0, uiResetValue = 0; - int bytes; - - psIntfAdapter = ((struct bcm_interface_adapter *)(ps_adapter->pvInterfaceAdapter)); - ps_adapter->bDDRInitDone = false; - - if (ps_adapter->chip_id >= T3LPB) { - /* SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before */ - rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); - rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); - - /* making bit[6...5] same as was before f/w download. this setting force the h/w to */ - /* re-populated the SP RAM area with the string descriptor. */ - value = value | (ps_adapter->syscfgBefFwDld & 0x00000060); - wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); - } - - /* killing all submitted URBs. */ - psIntfAdapter->psAdapter->StopAllXaction = TRUE; - Bcm_kill_all_URBs(psIntfAdapter); - /* Reset the UMA-B Device */ - if (ps_adapter->chip_id >= T3LPB) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Resetting UMA-B\n"); - retval = usb_reset_device(psIntfAdapter->udev); - psIntfAdapter->psAdapter->StopAllXaction = false; - - if (retval != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval); - goto err_exit; - } - - if (ps_adapter->chip_id == BCS220_2 || - ps_adapter->chip_id == BCS220_2BC || - ps_adapter->chip_id == BCS250_BC || - ps_adapter->chip_id == BCS220_3) { - - bytes = rdmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); - if (bytes < 0) { - retval = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval); - goto err_exit; - } - /* setting 0th bit */ - value |= (1<<0); - retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); - goto err_exit; - } - } - } else { - bytes = rdmalt(ps_adapter, 0x0f007018, &value, sizeof(value)); - if (bytes < 0) { - retval = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "read failed with status :%d", retval); - goto err_exit; - } - value &= (~(1<<16)); - retval = wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); - goto err_exit; - } - - /* Toggling the GPIO 8, 9 */ - value = 0; - retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); - goto err_exit; - } - value = 0x300; - retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)); - if (retval < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "write failed with status :%d", retval); - goto err_exit; - } - mdelay(50); - } - - /* ps_adapter->downloadDDR = false; */ - if (ps_adapter->bFlashBoot) { - /* In flash boot mode MIPS state register has reverse polarity. - * So just or with setting bit 30. - * Make the MIPS in Reset state. - */ - rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); - uiResetValue |= (1<<30); - wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue)); - } - - if (ps_adapter->chip_id >= T3LPB) { - uiResetValue = 0; - /* - * WA for SYSConfig Issue. - * Read SYSCFG Twice to make it writable. - */ - rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); - if (uiResetValue & (1<<4)) { - uiResetValue = 0; - rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); /* 2nd read to make it writable. */ - uiResetValue &= (~(1<<4)); - wrmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue)); - } - } - uiResetValue = 0; - wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue)); - -err_exit: - psIntfAdapter->psAdapter->StopAllXaction = false; - return retval; -} - -int run_card_proc(struct bcm_mini_adapter *ps_adapter) -{ - int status = STATUS_SUCCESS; - int bytes; - - unsigned int value = 0; - { - bytes = rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)); - if (bytes < 0) { - status = bytes; - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__); - return status; - } - - if (ps_adapter->bFlashBoot) - value &= (~(1<<30)); - else - value |= (1<<30); - - if (wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "%s:%d\n", __func__, __LINE__); - return STATUS_FAILURE; - } - } - return status; -} - -int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter) -{ - int status; - unsigned int value = 0; - /* - * Create the threads first and then download the - * Firm/DDR Settings.. - */ - status = create_worker_threads(ps_adapter); - if (status < 0) - return status; - - status = bcm_parse_target_params(ps_adapter); - if (status) - return status; - - if (ps_adapter->chip_id >= T3LPB) { - rdmalt(ps_adapter, SYS_CFG, &value, sizeof(value)); - ps_adapter->syscfgBefFwDld = value; - - if ((value & 0x60) == 0) - ps_adapter->bFlashBoot = TRUE; - } - - reset_card_proc(ps_adapter); - - /* Initializing the NVM. */ - BcmInitNVM(ps_adapter); - status = ddr_init(ps_adapter); - if (status) { - pr_err(DRV_NAME "ddr_init Failed\n"); - return status; - } - - /* Download cfg file */ - status = buffDnldVerify(ps_adapter, - (PUCHAR)ps_adapter->pstargetparams, - sizeof(struct bcm_target_params), - CONFIG_BEGIN_ADDR); - if (status) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file"); - goto OUT; - } - - if (register_networkdev(ps_adapter)) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed."); - return -EIO; - } - - if (false == ps_adapter->AutoFirmDld) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n"); - /* If Auto f/w download is disable, register the control interface, */ - /* register the control interface after the mailbox. */ - if (register_control_device_interface(ps_adapter) < 0) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed."); - return -EIO; - } - return STATUS_SUCCESS; - } - - /* - * Do the LED Settings here. It will be used by the Firmware Download - * Thread. - */ - - /* - * 1. If the LED Settings fails, do not stop and do the Firmware download. - * 2. This init would happened only if the cfg file is present, else - * call from the ioctl context. - */ - - status = InitLedSettings(ps_adapter); - if (status) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "INIT LED FAILED\n"); - return status; - } - - if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - ps_adapter->DriverState = DRIVER_INIT; - wake_up(&ps_adapter->LEDInfo.notify_led_event); - } - - if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - ps_adapter->DriverState = FW_DOWNLOAD; - wake_up(&ps_adapter->LEDInfo.notify_led_event); - } - - value = 0; - wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); - wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); - - if (ps_adapter->eNVMType == NVM_FLASH) { - status = PropagateCalParamsFromFlashToMemory(ps_adapter); - if (status) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Propagation of Cal param failed .."); - goto OUT; - } - } - - /* Download Firmare */ - status = BcmFileDownload(ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR); - if (status != 0) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present...\n"); - goto OUT; - } - - status = run_card_proc(ps_adapter); - if (status) { - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n"); - goto OUT; - } - - ps_adapter->fw_download_done = TRUE; - mdelay(10); - -OUT: - if (ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - ps_adapter->DriverState = FW_DOWNLOAD_DONE; - wake_up(&ps_adapter->LEDInfo.notify_led_event); - } - - return status; -} - -static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter) -{ - struct file *flp = NULL; - char *buff; - int len = 0; - - buff = kmalloc(BUFFER_1K, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL); - if (Adapter->pstargetparams == NULL) { - kfree(buff); - return -ENOMEM; - } - - flp = open_firmware_file(Adapter, CFG_FILE); - if (!flp) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE\n", CFG_FILE); - kfree(buff); - kfree(Adapter->pstargetparams); - Adapter->pstargetparams = NULL; - return -ENOENT; - } - len = kernel_read(flp, 0, buff, BUFFER_1K); - filp_close(flp, NULL); - - if (len != sizeof(struct bcm_target_params)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n"); - kfree(buff); - kfree(Adapter->pstargetparams); - Adapter->pstargetparams = NULL; - return -ENOENT; - } - - /* Check for autolink in config params */ - /* - * Values in Adapter->pstargetparams are in network byte order - */ - memcpy(Adapter->pstargetparams, buff, sizeof(struct bcm_target_params)); - kfree(buff); - beceem_parse_target_struct(Adapter); - return STATUS_SUCCESS; -} - -void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0; - - if (ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE) { - pr_info(DRV_NAME ": AutoSyncup is Disabled\n"); - Adapter->AutoSyncup = false; - } else { - pr_info(DRV_NAME ": AutoSyncup is Enabled\n"); - Adapter->AutoSyncup = TRUE; - } - - if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE) { - pr_info(DRV_NAME ": Enabling autolink up"); - Adapter->AutoLinkUp = TRUE; - } else { - pr_info(DRV_NAME ": Disabling autolink up"); - Adapter->AutoLinkUp = false; - } - /* Setting the DDR Setting.. */ - Adapter->DDRSetting = (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >> 8)&0x0F; - Adapter->ulPowerSaveMode = (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F; - pr_info(DRV_NAME ": DDR Setting: %x\n", Adapter->DDRSetting); - pr_info(DRV_NAME ": Power Save Mode: %lx\n", Adapter->ulPowerSaveMode); - if (ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD) { - pr_info(DRV_NAME ": Enabling Auto Firmware Download\n"); - Adapter->AutoFirmDld = TRUE; - } else { - pr_info(DRV_NAME ": Disabling Auto Firmware Download\n"); - Adapter->AutoFirmDld = false; - } - uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6); - Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01; - pr_info(DRV_NAME ": MIPSConfig : 0x%X\n", Adapter->bMipsConfig); - /* used for backward compatibility. */ - Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01; - Adapter->PmuMode = (uiHostDrvrCfg6 >> 24) & 0x03; - pr_info(DRV_NAME ": PMU MODE: %x", Adapter->PmuMode); - - if ((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT) & (0x01)) { - Adapter->bDoSuspend = TRUE; - pr_info(DRV_NAME ": Making DoSuspend TRUE as per configFile"); - } - - uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag); - pr_info(DRV_NAME ": uiEEPROMFlag : 0x%X\n", uiEEPROMFlag); - Adapter->eNVMType = (enum bcm_nvm_type)((uiEEPROMFlag>>4)&0x3); - Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1; - Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4)); - Adapter->bSectorSizeOverride = (bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1; - - if (ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x01) - Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE; - - if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) - doPowerAutoCorrection(Adapter); -} - -static void doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter) -{ - unsigned int reporting_mode; - - reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x02; - psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1); - - if (reporting_mode) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "can't do suspen/resume as reporting mode is enable"); - psAdapter->bDoSuspend = false; - } - - if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB)) { - /* If reporting mode is enable, switch PMU to PMC */ - { - psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING; - psAdapter->bDoSuspend = false; - } - - /* clearing space bit[15..12] */ - psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12))); - /* placing the power save mode option */ - psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12)); - } else if (psAdapter->bIsAutoCorrectEnabled == false) { - /* remove the autocorrect disable bit set before dumping. */ - psAdapter->ulPowerSaveMode &= ~(1 << 3); - psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15)); - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode); - } -} - -static void convertEndian(unsigned char rwFlag, unsigned int *puiBuffer, unsigned int uiByteCount) -{ - unsigned int uiIndex = 0; - - if (RWM_WRITE == rwFlag) { - for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++) - puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]); - } else { - for (uiIndex = 0; uiIndex < (uiByteCount/sizeof(unsigned int)); uiIndex++) - puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]); - } -} - -int rdm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) -{ - return Adapter->interface_rdm(Adapter->pvInterfaceAdapter, - uiAddress, pucBuff, sSize); -} - -int wrm(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) -{ - int iRetVal; - - iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter, - uiAddress, pucBuff, sSize); - return iRetVal; -} - -int wrmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) -{ - convertEndian(RWM_WRITE, pucBuff, size); - return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size); -} - -int rdmalt(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) -{ - int uiRetVal = 0; - - uiRetVal = rdm(Adapter, uiAddress, (PUCHAR)pucBuff, size); - convertEndian(RWM_READ, (unsigned int *)pucBuff, size); - - return uiRetVal; -} - -int wrmWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, PCHAR pucBuff, size_t sSize) -{ - int status = STATUS_SUCCESS; - - down(&Adapter->rdmwrmsync); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - status = -EACCES; - goto exit; - } - - status = wrm(Adapter, uiAddress, pucBuff, sSize); -exit: - up(&Adapter->rdmwrmsync); - return status; -} - -int wrmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) -{ - int iRetVal = STATUS_SUCCESS; - - down(&Adapter->rdmwrmsync); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - iRetVal = -EACCES; - goto exit; - } - - iRetVal = wrmalt(Adapter, uiAddress, pucBuff, size); -exit: - up(&Adapter->rdmwrmsync); - return iRetVal; -} - -int rdmaltWithLock(struct bcm_mini_adapter *Adapter, unsigned int uiAddress, unsigned int *pucBuff, size_t size) -{ - int uiRetVal = STATUS_SUCCESS; - - down(&Adapter->rdmwrmsync); - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - uiRetVal = -EACCES; - goto exit; - } - - uiRetVal = rdmalt(Adapter, uiAddress, pucBuff, size); -exit: - up(&Adapter->rdmwrmsync); - return uiRetVal; -} - -static void HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter) -{ - int clear_abort_pattern = 0, Status = 0; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); - /* target has woken up From Shut Down */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n"); - Status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, (unsigned int *)&clear_abort_pattern, sizeof(clear_abort_pattern)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status); - return; - } - - if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) { - msleep(100); - InterfaceHandleShutdownModeWakeup(Adapter); - msleep(100); - } - - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - Adapter->DriverState = NO_NETWORK_ENTRY; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - - Adapter->bTriedToWakeUpFromlowPowerMode = false; - Adapter->bShutStatus = false; - wake_up(&Adapter->lowpower_mode_wait_queue); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); -} - -static void SendShutModeResponse(struct bcm_mini_adapter *Adapter) -{ - struct bcm_link_request stShutdownResponse; - unsigned int NVMAccess = 0, lowPwrAbortMsg = 0; - unsigned int Status = 0; - - memset(&stShutdownResponse, 0, sizeof(struct bcm_link_request)); - stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ; - stShutdownResponse.Leader.PLength = 8; /* 8 bytes; */ - stShutdownResponse.szData[0] = LINK_UP_ACK; - stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE; - - /********************************* - * down_trylock - - * if [ semaphore is available ] - * acquire semaphone and return value 0 ; - * else - * return non-zero value ; - * - ***********************************/ - - NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock); - lowPwrAbortMsg = down_trylock(&Adapter->LowPowerModeSync); - - if (NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) { - if (!NVMAccess) - up(&Adapter->NVMRdmWrmLock); - - if (!lowPwrAbortMsg) - up(&Adapter->LowPowerModeSync); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n"); - stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ - Adapter->bPreparingForLowPowerMode = false; - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n"); - stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER; /* ShutDown ACK */ - - /* Wait for the LED to TURN OFF before sending ACK response */ - if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) { - int iRetVal = 0; - - /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */ - Adapter->DriverState = LOWPOWER_MODE_ENTER; - wake_up(&Adapter->LEDInfo.notify_led_event); - - /* Wait for 1 SEC for LED to OFF */ - iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000)); - - /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */ - if (iRetVal <= 0) { - stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER; /* NACK- device access is going on. */ - Adapter->DriverState = NO_NETWORK_ENTRY; - wake_up(&Adapter->LEDInfo.notify_led_event); - } - } - - if (stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ACKING SHUTDOWN MODE !!!!!!!!!"); - down(&Adapter->rdmwrmsync); - Adapter->bPreparingForLowPowerMode = TRUE; - up(&Adapter->rdmwrmsync); - /* Killing all URBS. */ - if (Adapter->bDoSuspend == TRUE) - Bcm_kill_all_URBs((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); - } else { - Adapter->bPreparingForLowPowerMode = false; - } - - if (!NVMAccess) - up(&Adapter->NVMRdmWrmLock); - - if (!lowPwrAbortMsg) - up(&Adapter->LowPowerModeSync); - } - - Status = CopyBufferToControlPacket(Adapter, &stShutdownResponse); - if (Status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "fail to send the Idle mode Request\n"); - Adapter->bPreparingForLowPowerMode = false; - StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter)); - } -} - -static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer) -{ - unsigned int uiResetValue = 0; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n"); - - if (*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW) { - HandleShutDownModeWakeup(Adapter); - } else if (*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) { - /* Target wants to go to Shut Down Mode */ - /* InterfacePrepareForShutdown(Adapter); */ - if (Adapter->chip_id == BCS220_2 || - Adapter->chip_id == BCS220_2BC || - Adapter->chip_id == BCS250_BC || - Adapter->chip_id == BCS220_3) { - - rdmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); - uiResetValue |= (1<<17); - wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4); - } - - SendShutModeResponse(Adapter); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n"); - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n"); -} - -void ResetCounters(struct bcm_mini_adapter *Adapter) -{ - beceem_protocol_reset(Adapter); - Adapter->CurrNumRecvDescs = 0; - Adapter->PrevNumRecvDescs = 0; - Adapter->LinkUpStatus = 0; - Adapter->LinkStatus = 0; - atomic_set(&Adapter->cntrlpktCnt, 0); - atomic_set(&Adapter->TotalPacketCount, 0); - Adapter->fw_download_done = false; - Adapter->LinkStatus = 0; - Adapter->AutoLinkUp = false; - Adapter->IdleMode = false; - Adapter->bShutStatus = false; -} - -struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP) -{ - unsigned int uiIndex = 0; - - for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { - if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && - (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && - (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIP) && - !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment) - - return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry; - } - return NULL; -} - -void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo) -{ - unsigned int uiIndex = 0; - - for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { - if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) { - memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(struct bcm_fragmented_packet_info)); - break; - } - } -} - -void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp) -{ - unsigned int uiIndex = 0; - - for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) { - if ((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) && - (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) && - (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIp)) - - memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(struct bcm_fragmented_packet_info)); - } -} - -void update_per_cid_rx(struct bcm_mini_adapter *Adapter) -{ - unsigned int qindex = 0; - - if ((jiffies - Adapter->liDrainCalculated) < XSECONDS) - return; - - for (qindex = 0; qindex < HiPriority; qindex++) { - if (Adapter->PackInfo[qindex].ucDirection == 0) { - Adapter->PackInfo[qindex].uiCurrentRxRate = - (Adapter->PackInfo[qindex].uiCurrentRxRate + - Adapter->PackInfo[qindex].uiThisPeriodRxBytes) / 2; - - Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0; - } else { - Adapter->PackInfo[qindex].uiCurrentDrainRate = - (Adapter->PackInfo[qindex].uiCurrentDrainRate + - Adapter->PackInfo[qindex].uiThisPeriodSentBytes) / 2; - Adapter->PackInfo[qindex].uiThisPeriodSentBytes = 0; - } - } - Adapter->liDrainCalculated = jiffies; -} - -void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter) -{ - int iIndex = 0; - u32 uibuff[MAX_TARGET_DSX_BUFFERS]; - int bytes; - - if (!atomic_read(&Adapter->uiMBupdate)) - return; - - bytes = rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (unsigned int *)uibuff, sizeof(unsigned int) * MAX_TARGET_DSX_BUFFERS); - if (bytes < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm failed\n"); - return; - } - - for (iIndex = 0; iIndex < HiPriority; iIndex++) { - if (Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection) { - if (Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS) - atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]); - else - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x\n", Adapter->PackInfo[iIndex].usVCID_Value); - } - } - atomic_set(&Adapter->uiMBupdate, false); -} - -void flush_queue(struct bcm_mini_adapter *Adapter, unsigned int iQIndex) -{ - struct sk_buff *PacketToDrop = NULL; - struct net_device_stats *netstats = &Adapter->dev->stats; - - spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - - while (Adapter->PackInfo[iQIndex].FirstTxQueue && atomic_read(&Adapter->TotalPacketCount)) { - PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; - if (PacketToDrop && PacketToDrop->len) { - netstats->tx_dropped++; - DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, Adapter->PackInfo[iQIndex].LastTxQueue); - Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--; - Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len; - - /* Adding dropped statistics */ - Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len; - Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; - dev_kfree_skb(PacketToDrop); - atomic_dec(&Adapter->TotalPacketCount); - } - } - spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); -} - -static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter) -{ - int i; - - if (netif_msg_link(Adapter)) - pr_notice(PFX "%s: protocol reset\n", Adapter->dev->name); - - netif_carrier_off(Adapter->dev); - netif_stop_queue(Adapter->dev); - - Adapter->IdleMode = false; - Adapter->LinkUpStatus = false; - ClearTargetDSXBuffer(Adapter, 0, TRUE); - /* Delete All Classifier Rules */ - - for (i = 0; i < HiPriority; i++) - DeleteAllClassifiersForSF(Adapter, i); - - flush_all_queues(Adapter); - - if (Adapter->TimerActive == TRUE) - Adapter->TimerActive = false; - - memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(struct bcm_fragmented_packet_info) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES); - - for (i = 0; i < HiPriority; i++) { - /* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */ - /* It is same between MIBs and SF. */ - memset(&Adapter->PackInfo[i].stMibsExtServiceFlowTable, 0, sizeof(struct bcm_mibs_parameters)); - } -} diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h deleted file mode 100644 index cd78ee4ffa22..000000000000 --- a/drivers/staging/bcm/PHSDefines.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef BCM_PHS_DEFINES_H -#define BCM_PHS_DEFINES_H - -#define PHS_INVALID_TABLE_INDEX 0xffffffff -#define PHS_MEM_TAG "_SHP" - -/* PHS Defines */ -#define STATUS_PHS_COMPRESSED 0xa1 -#define STATUS_PHS_NOCOMPRESSION 0xa2 -#define APPLY_PHS 1 -#define MAX_NO_BIT 7 -#define ZERO_PHSI 0 -#define VERIFY 0 -#define SIZE_MULTIPLE_32 4 -#define UNCOMPRESSED_PACKET 0 -#define DYNAMIC 0 -#define SUPPRESS 0x80 -#define NO_CLASSIFIER_MATCH 0 -#define SEND_PACKET_UNCOMPRESSED 0 -#define PHSI_IS_ZERO 0 -#define PHSI_LEN 1 -#define ERROR_LEN 0 -#define PHS_BUFFER_SIZE 1532 -#define MAX_PHSRULE_PER_SF 20 -#define MAX_SERVICEFLOWS 17 - -/* PHS Error Defines */ -#define PHS_SUCCESS 0 -#define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800 -#define ERR_PHS_INVALID_PHS_RULE 0x801 -#define ERR_PHS_RULE_ALREADY_EXISTS 0x802 -#define ERR_SF_MATCH_FAIL 0x803 -#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804 -#define ERR_SFTABLE_FULL 0x805 -#define ERR_CLSASSIFIER_TABLE_FULL 0x806 -#define ERR_PHSRULE_MEMALLOC_FAIL 0x807 -#define ERR_CLSID_MATCH_FAIL 0x808 -#define ERR_PHSRULE_MATCH_FAIL 0x809 - -struct bcm_phs_rule { - u8 u8PHSI; - u8 u8PHSFLength; - u8 u8PHSF[MAX_PHS_LENGTHS]; - u8 u8PHSMLength; - u8 u8PHSM[MAX_PHS_LENGTHS]; - u8 u8PHSS; - u8 u8PHSV; - u8 u8RefCnt; - u8 bUnclassifiedPHSRule; - u8 u8Reserved[3]; - long PHSModifiedBytes; - unsigned long PHSModifiedNumPackets; - unsigned long PHSErrorNumPackets; -}; - -enum bcm_phs_classifier_context { - eActiveClassifierRuleContext, - eOldClassifierRuleContext -}; - -struct bcm_phs_classifier_entry { - u8 bUsed; - u16 uiClassifierRuleId; - u8 u8PHSI; - struct bcm_phs_rule *pstPhsRule; - u8 bUnclassifiedPHSRule; -}; - -struct bcm_phs_classifier_table { - u16 uiTotalClassifiers; - struct bcm_phs_classifier_entry stActivePhsRulesList[MAX_PHSRULE_PER_SF]; - struct bcm_phs_classifier_entry stOldPhsRulesList[MAX_PHSRULE_PER_SF]; - u16 uiOldestPhsRuleIndex; -}; - -struct bcm_phs_entry { - u8 bUsed; - u16 uiVcid; - struct bcm_phs_classifier_table *pstClassifierTable; -}; - -struct bcm_phs_table { - u16 uiTotalServiceFlows; - struct bcm_phs_entry stSFList[MAX_SERVICEFLOWS]; -}; - -struct bcm_phs_extension { - /* PHS Specific data */ - struct bcm_phs_table *pstServiceFlowPhsRulesTable; - void *CompressedTxBuffer; - void *UnCompressedRxBuffer; -}; - -#endif diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c deleted file mode 100644 index 262613436d1e..000000000000 --- a/drivers/staging/bcm/PHSModule.c +++ /dev/null @@ -1,1699 +0,0 @@ -#include "headers.h" - -static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid, - B_UINT16 uiClsId, - struct bcm_phs_table *psServiceFlowTable, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI); - -static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid, - B_UINT16 uiClsId, - struct bcm_phs_entry *pstServiceFlowEntry, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI); - -static UINT CreateClassifierPHSRule(B_UINT16 uiClsId, - struct bcm_phs_classifier_table *psaClassifiertable, - struct bcm_phs_rule *psPhsRule, - enum bcm_phs_classifier_context eClsContext, - B_UINT8 u8AssociatedPHSI); - -static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId, - struct bcm_phs_classifier_entry *pstClassifierEntry, - struct bcm_phs_classifier_table *psaClassifiertable, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI); - -static bool ValidatePHSRuleComplete(const struct bcm_phs_rule *psPhsRule); - -static bool DerefPhsRule(B_UINT16 uiClsId, - struct bcm_phs_classifier_table *psaClassifiertable, - struct bcm_phs_rule *pstPhsRule); - -static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable, - B_UINT32 uiClsid, - enum bcm_phs_classifier_context eClsContext, - struct bcm_phs_classifier_entry **ppstClassifierEntry); - -static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable, - B_UINT32 uiPHSI, - enum bcm_phs_classifier_context eClsContext, - struct bcm_phs_rule **ppstPhsRule); - -static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable); - -static int phs_compress(struct bcm_phs_rule *phs_members, - unsigned char *in_buf, - unsigned char *out_buf, - unsigned int *header_size, - UINT *new_header_size); - -static int verify_suppress_phsf(unsigned char *in_buffer, - unsigned char *out_buffer, - unsigned char *phsf, - unsigned char *phsm, - unsigned int phss, - unsigned int phsv, - UINT *new_header_size); - -static int phs_decompress(unsigned char *in_buf, - unsigned char *out_buf, - struct bcm_phs_rule *phs_rules, - UINT *header_size); - -static ULONG PhsCompress(void *pvContext, - B_UINT16 uiVcid, - B_UINT16 uiClsId, - void *pvInputBuffer, - void *pvOutputBuffer, - UINT *pOldHeaderSize, - UINT *pNewHeaderSize); - -static ULONG PhsDeCompress(void *pvContext, - B_UINT16 uiVcid, - void *pvInputBuffer, - void *pvOutputBuffer, - UINT *pInHeaderSize, - UINT *pOutHeaderSize); - -#define IN -#define OUT - -/* - * Function: PHSTransmit - * Description: This routine handle PHS(Payload Header Suppression for Tx path. - * It extracts a fragment of the NDIS_PACKET containing the header - * to be suppressed. It then suppresses the header by invoking PHS exported compress routine. - * The header data after suppression is copied back to the NDIS_PACKET. - * - * Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context - * IN Packet - NDIS packet containing data to be transmitted - * IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to - * identify PHS rule to be applied. - * B_UINT16 uiClassifierRuleID - Classifier Rule ID - * BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF. - * - * Return: STATUS_SUCCESS - If the send was successful. - * Other - If an error occurred. - */ - -int PHSTransmit(struct bcm_mini_adapter *Adapter, - struct sk_buff **pPacket, - USHORT Vcid, - B_UINT16 uiClassifierRuleID, - bool bHeaderSuppressionEnabled, - UINT *PacketLen, - UCHAR bEthCSSupport) -{ - /* PHS Sepcific */ - UINT unPHSPktHdrBytesCopied = 0; - UINT unPhsOldHdrSize = 0; - UINT unPHSNewPktHeaderLen = 0; - /* Pointer to PHS IN Hdr Buffer */ - PUCHAR pucPHSPktHdrInBuf = - Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf; - /* Pointer to PHS OUT Hdr Buffer */ - PUCHAR pucPHSPktHdrOutBuf = - Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf; - UINT usPacketType; - UINT BytesToRemove = 0; - bool bPHSI = 0; - LONG ulPhsStatus = 0; - UINT numBytesCompressed = 0; - struct sk_buff *newPacket = NULL; - struct sk_buff *Packet = *pPacket; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "In PHSTransmit"); - - if (!bEthCSSupport) - BytesToRemove = ETH_HLEN; - /* - * Accumulate the header upto the size we support suppression - * from NDIS packet - */ - - usPacketType = ((struct ethhdr *)(Packet->data))->h_proto; - - pucPHSPktHdrInBuf = Packet->data + BytesToRemove; - /* considering data after ethernet header */ - if ((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS) - unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove); - else - unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS; - - if ((unPHSPktHdrBytesCopied > 0) && - (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) { - - /* - * Step 2 Suppress Header using PHS and fill into intermediate - * ucaPHSPktHdrOutBuf. - * Suppress only if IP Header and PHS Enabled For the - * Service Flow - */ - if (((usPacketType == ETHERNET_FRAMETYPE_IPV4) || - (usPacketType == ETHERNET_FRAMETYPE_IPV6)) && - (bHeaderSuppressionEnabled)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, - DBG_LVL_ALL, - "\nTrying to PHS Compress Using Classifier rule 0x%X", - uiClassifierRuleID); - unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied; - ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext, - Vcid, - uiClassifierRuleID, - pucPHSPktHdrInBuf, - pucPHSPktHdrOutBuf, - &unPhsOldHdrSize, - &unPHSNewPktHeaderLen); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, - DBG_LVL_ALL, - "\nPHS Old header Size : %d New Header Size %d\n", - unPhsOldHdrSize, unPHSNewPktHeaderLen); - - if (unPHSNewPktHeaderLen == unPhsOldHdrSize) { - - if (ulPhsStatus == STATUS_PHS_COMPRESSED) - bPHSI = *pucPHSPktHdrOutBuf; - - ulPhsStatus = STATUS_PHS_NOCOMPRESSION; - } - - if (ulPhsStatus == STATUS_PHS_COMPRESSED) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - PHS_SEND, DBG_LVL_ALL, - "PHS Sending packet Compressed"); - - if (skb_cloned(Packet)) { - newPacket = - skb_copy(Packet, GFP_ATOMIC); - - if (newPacket == NULL) - return STATUS_FAILURE; - - dev_kfree_skb(Packet); - *pPacket = Packet = newPacket; - pucPHSPktHdrInBuf = - Packet->data + BytesToRemove; - } - - numBytesCompressed = unPhsOldHdrSize - - (unPHSNewPktHeaderLen + PHSI_LEN); - - memcpy(pucPHSPktHdrInBuf + numBytesCompressed, - pucPHSPktHdrOutBuf, - unPHSNewPktHeaderLen + PHSI_LEN); - memcpy(Packet->data + numBytesCompressed, - Packet->data, BytesToRemove); - skb_pull(Packet, numBytesCompressed); - - return STATUS_SUCCESS; - } else { - /* if one byte headroom is not available, - * increase it through skb_cow - */ - if (!(skb_headroom(Packet) > 0)) { - - if (skb_cow(Packet, 1)) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_PRINTK, - 0, 0, - "SKB Cow Failed\n"); - return STATUS_FAILURE; - } - } - skb_push(Packet, 1); - - /* - * CAUTION: The MAC Header is getting corrupted - * here for IP CS - can be saved by copying 14 - * Bytes. not needed .... hence corrupting it. - */ - *(Packet->data + BytesToRemove) = bPHSI; - return STATUS_SUCCESS; - } - } else { - - if (!bHeaderSuppressionEnabled) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - PHS_SEND, DBG_LVL_ALL, - "\nHeader Suppression Disabled For SF: No PHS\n"); - - return STATUS_SUCCESS; - } - } - - /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - * "PHSTransmit : Dumping data packet After PHS"); */ - return STATUS_SUCCESS; -} - -int PHSReceive(struct bcm_mini_adapter *Adapter, - USHORT usVcid, - struct sk_buff *packet, - UINT *punPacketLen, - UCHAR *pucEthernetHdr, - UINT bHeaderSuppressionEnabled) -{ - u32 nStandardPktHdrLen = 0; - u32 nTotalsuppressedPktHdrBytes = 0; - int ulPhsStatus = 0; - PUCHAR pucInBuff = NULL; - UINT TotalBytesAdded = 0; - - if (!bHeaderSuppressionEnabled) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, - DBG_LVL_ALL, - "\nPhs Disabled for incoming packet"); - return ulPhsStatus; - } - - pucInBuff = packet->data; - - /* Restore PHS suppressed header */ - nStandardPktHdrLen = packet->len; - ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext, - usVcid, - pucInBuff, - Adapter->ucaPHSPktRestoreBuf, - &nTotalsuppressedPktHdrBytes, - &nStandardPktHdrLen); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, - "\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x", - nTotalsuppressedPktHdrBytes, nStandardPktHdrLen); - - if (ulPhsStatus != STATUS_PHS_COMPRESSED) { - skb_pull(packet, 1); - return STATUS_SUCCESS; - } else { - TotalBytesAdded = nStandardPktHdrLen - - nTotalsuppressedPktHdrBytes - PHSI_LEN; - - if (TotalBytesAdded) { - if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded)) - skb_push(packet, TotalBytesAdded); - else { - if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_PRINTK, 0, 0, - "cow failed in receive\n"); - return STATUS_FAILURE; - } - - skb_push(packet, TotalBytesAdded); - } - } - - memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, - nStandardPktHdrLen); - } - - return STATUS_SUCCESS; -} - -void DumpFullPacket(UCHAR *pBuf, UINT nPktLen) -{ - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, - "Dumping Data Packet"); - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, - pBuf, nPktLen); -} - -/* - * Procedure: phs_init - * - * Description: This routine is responsible for allocating memory for classifier - * and PHS rules. - * - * Arguments: - * pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules - * and PHS Rules , RX, TX buffer etc - * - * Returns: - * TRUE(1) -If allocation of memory was successful. - * FALSE -If allocation of memory fails. - */ -int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, - struct bcm_mini_adapter *Adapter) -{ - int i; - struct bcm_phs_table *pstServiceFlowTable; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "\nPHS:phs_init function"); - - if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable) - return -EINVAL; - - pPhsdeviceExtension->pstServiceFlowPhsRulesTable = - kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL); - - if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, - "\nAllocation ServiceFlowPhsRulesTable failed"); - return -ENOMEM; - } - - pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable; - for (i = 0; i < MAX_SERVICEFLOWS; i++) { - struct bcm_phs_entry sServiceFlow = - pstServiceFlowTable->stSFList[i]; - sServiceFlow.pstClassifierTable = - kzalloc(sizeof(struct bcm_phs_classifier_table), - GFP_KERNEL); - if (!sServiceFlow.pstClassifierTable) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "\nAllocation failed"); - free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); - pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; - return -ENOMEM; - } - } - - pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); - if (pPhsdeviceExtension->CompressedTxBuffer == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "\nAllocation failed"); - free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); - pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; - return -ENOMEM; - } - - pPhsdeviceExtension->UnCompressedRxBuffer = - kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); - if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "\nAllocation failed"); - kfree(pPhsdeviceExtension->CompressedTxBuffer); - free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); - pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; - return -ENOMEM; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "\n phs_init Successful"); - return STATUS_SUCCESS; -} - -int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt) -{ - if (pPHSDeviceExt->pstServiceFlowPhsRulesTable) { - free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable); - pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL; - } - - kfree(pPHSDeviceExt->CompressedTxBuffer); - pPHSDeviceExt->CompressedTxBuffer = NULL; - - kfree(pPHSDeviceExt->UnCompressedRxBuffer); - pPHSDeviceExt->UnCompressedRxBuffer = NULL; - - return 0; -} - -/* - * PHS functions - * PhsUpdateClassifierRule - * - * Routine Description: - * Exported function to add or modify a PHS Rule. - * - * Arguments: - * IN void* pvContext - PHS Driver Specific Context - * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies - * IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. - * IN struct bcm_phs_rule *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. - * - * Return Value: - * - * 0 if successful, - * >0 Error. - */ -ULONG PhsUpdateClassifierRule(IN void *pvContext, - IN B_UINT16 uiVcid , - IN B_UINT16 uiClsId , - IN struct bcm_phs_rule *psPhsRule, - IN B_UINT8 u8AssociatedPHSI) -{ - ULONG lStatus = 0; - UINT nSFIndex = 0; - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_extension *pDeviceExtension = - (struct bcm_phs_extension *)pvContext; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "PHS With Corr2 Changes\n"); - - if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "Invalid Device Extension\n"); - return ERR_PHS_INVALID_DEVICE_EXETENSION; - } - - if (u8AssociatedPHSI == 0) - return ERR_PHS_INVALID_PHS_RULE; - - /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid, &pstServiceFlowEntry); - - if (nSFIndex == PHS_INVALID_TABLE_INDEX) { - /* This is a new SF. Create a mapping entry for this */ - lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId, - pDeviceExtension->pstServiceFlowPhsRulesTable, - psPhsRule, - u8AssociatedPHSI); - return lStatus; - } - - /* SF already Exists Add PHS Rule to existing SF */ - lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId, - pstServiceFlowEntry, - psPhsRule, - u8AssociatedPHSI); - - return lStatus; -} - -/* - * PhsDeletePHSRule - * - * Routine Description: - * Deletes the specified phs Rule within Vcid - * - * Arguments: - * IN void* pvContext - PHS Driver Specific Context - * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies - * IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted. - * - * Return Value: - * - * 0 if successful, - * >0 Error. - */ -ULONG PhsDeletePHSRule(IN void *pvContext, - IN B_UINT16 uiVcid, - IN B_UINT8 u8PHSI) -{ - UINT nSFIndex = 0, nClsidIndex = 0; - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; - struct bcm_phs_classifier_entry *curr_entry; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "======>\n"); - - if (pDeviceExtension) { - /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid, &pstServiceFlowEntry); - - if (nSFIndex == PHS_INVALID_TABLE_INDEX) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "SFID Match Failed\n"); - return ERR_SF_MATCH_FAIL; - } - - pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable; - if (pstClassifierRulesTable) { - for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) { - curr_entry = &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]; - if (curr_entry->bUsed && - curr_entry->pstPhsRule && - (curr_entry->pstPhsRule->u8PHSI == u8PHSI)) { - - if (curr_entry->pstPhsRule->u8RefCnt) - curr_entry->pstPhsRule->u8RefCnt--; - - if (0 == curr_entry->pstPhsRule->u8RefCnt) - kfree(curr_entry->pstPhsRule); - - memset(curr_entry, - 0, - sizeof(struct bcm_phs_classifier_entry)); - } - } - } - } - return 0; -} - -/* - * PhsDeleteClassifierRule - * - * Routine Description: - * Exported function to Delete a PHS Rule for the SFID,CLSID Pair. - * - * Arguments: - * IN void* pvContext - PHS Driver Specific Context - * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies - * IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. - * - * Return Value: - * - * 0 if successful, - * >0 Error. - */ -ULONG PhsDeleteClassifierRule(IN void *pvContext, - IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId) -{ - UINT nSFIndex = 0, nClsidIndex = 0; - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_extension *pDeviceExtension = - (struct bcm_phs_extension *)pvContext; - - if (!pDeviceExtension) - goto out; - - /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid, &pstServiceFlowEntry); - if (nSFIndex == PHS_INVALID_TABLE_INDEX) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "SFID Match Failed\n"); - return ERR_SF_MATCH_FAIL; - } - - nClsidIndex = - GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, - uiClsId, - eActiveClassifierRuleContext, - &pstClassifierEntry); - - if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && - (!pstClassifierEntry->bUnclassifiedPHSRule)) { - if (pstClassifierEntry->pstPhsRule) { - if (pstClassifierEntry->pstPhsRule->u8RefCnt) - pstClassifierEntry->pstPhsRule->u8RefCnt--; - - if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt) - kfree(pstClassifierEntry->pstPhsRule); - } - memset(pstClassifierEntry, 0, - sizeof(struct bcm_phs_classifier_entry)); - } - - nClsidIndex = - GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, - uiClsId, - eOldClassifierRuleContext, - &pstClassifierEntry); - - if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && - (!pstClassifierEntry->bUnclassifiedPHSRule)) { - kfree(pstClassifierEntry->pstPhsRule); - memset(pstClassifierEntry, 0, - sizeof(struct bcm_phs_classifier_entry)); - } - -out: - return 0; -} - -/* - * PhsDeleteSFRules - * - * Routine Description: - * Exported function to Delete a all PHS Rules for the SFID. - * - * Arguments: - * IN void* pvContext - PHS Driver Specific Context - * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted - * - * Return Value: - * - * 0 if successful, - * >0 Error. - */ -ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) -{ - UINT nSFIndex = 0, nClsidIndex = 0; - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_extension *pDeviceExtension = - (struct bcm_phs_extension *)pvContext; - struct bcm_phs_classifier_entry *curr_clsf_entry; - struct bcm_phs_classifier_entry *curr_rules_list; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "====>\n"); - - if (!pDeviceExtension) - goto out; - - /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid, &pstServiceFlowEntry); - if (nSFIndex == PHS_INVALID_TABLE_INDEX) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "SFID Match Failed\n"); - return ERR_SF_MATCH_FAIL; - } - - pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable; - if (pstClassifierRulesTable) { - for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) { - curr_clsf_entry = - &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]; - - curr_rules_list = - &pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]; - - if (curr_clsf_entry->pstPhsRule) { - - if (curr_clsf_entry->pstPhsRule->u8RefCnt) - curr_clsf_entry->pstPhsRule->u8RefCnt--; - - if (0 == curr_clsf_entry->pstPhsRule->u8RefCnt) - kfree(curr_clsf_entry->pstPhsRule); - - curr_clsf_entry->pstPhsRule = NULL; - } - memset(curr_clsf_entry, 0, - sizeof(struct bcm_phs_classifier_entry)); - if (curr_rules_list->pstPhsRule) { - - if (curr_rules_list->pstPhsRule->u8RefCnt) - curr_rules_list->pstPhsRule->u8RefCnt--; - - if (0 == curr_rules_list->pstPhsRule->u8RefCnt) - kfree(curr_rules_list->pstPhsRule); - - curr_rules_list->pstPhsRule = NULL; - } - memset(curr_rules_list, 0, - sizeof(struct bcm_phs_classifier_entry)); - } - } - pstServiceFlowEntry->bUsed = false; - pstServiceFlowEntry->uiVcid = 0; - -out: - return 0; -} - -/* - * PhsCompress - * - * Routine Description: - * Exported function to compress the data using PHS. - * - * Arguments: - * IN void* pvContext - PHS Driver Specific Context. - * IN B_UINT16 uiVcid - The Service Flow ID to which current - * packet header compression applies. - * IN UINT uiClsId - The Classifier ID to which current packet - * header compression applies. - * IN void *pvInputBuffer - The Input buffer containg packet header - * data - * IN void *pvOutputBuffer - The output buffer returned by this - * function after PHS - * IN UINT *pOldHeaderSize - The actual size of the header before PHS - * IN UINT *pNewHeaderSize - The new size of the header after applying - * PHS - * - * Return Value: - * - * 0 if successful, - * >0 Error. - */ -static ULONG PhsCompress(IN void *pvContext, - IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId, - IN void *pvInputBuffer, - OUT void *pvOutputBuffer, - OUT UINT *pOldHeaderSize, - OUT UINT *pNewHeaderSize) -{ - UINT nSFIndex = 0, nClsidIndex = 0; - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; - struct bcm_phs_rule *pstPhsRule = NULL; - ULONG lStatus = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_extension *pDeviceExtension = - (struct bcm_phs_extension *)pvContext; - - if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "Invalid Device Extension\n"); - lStatus = STATUS_PHS_NOCOMPRESSION; - return lStatus; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "Suppressing header\n"); - - /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid, &pstServiceFlowEntry); - if (nSFIndex == PHS_INVALID_TABLE_INDEX) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "SFID Match Failed\n"); - lStatus = STATUS_PHS_NOCOMPRESSION; - return lStatus; - } - - nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, - uiClsId, eActiveClassifierRuleContext, - &pstClassifierEntry); - - if (nClsidIndex == PHS_INVALID_TABLE_INDEX) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "No PHS Rule Defined For Classifier\n"); - lStatus = STATUS_PHS_NOCOMPRESSION; - return lStatus; - } - - /* get rule from SF id,Cls ID pair and proceed */ - pstPhsRule = pstClassifierEntry->pstPhsRule; - if (!ValidatePHSRuleComplete(pstPhsRule)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "PHS Rule Defined For Classifier But Not Complete\n"); - lStatus = STATUS_PHS_NOCOMPRESSION; - return lStatus; - } - - /* Compress Packet */ - lStatus = phs_compress(pstPhsRule, - (PUCHAR)pvInputBuffer, - (PUCHAR)pvOutputBuffer, - pOldHeaderSize, - pNewHeaderSize); - - if (lStatus == STATUS_PHS_COMPRESSED) { - pstPhsRule->PHSModifiedBytes += - *pOldHeaderSize - *pNewHeaderSize - 1; - pstPhsRule->PHSModifiedNumPackets++; - } else { - pstPhsRule->PHSErrorNumPackets++; - } - - return lStatus; -} - -/* - * PhsDeCompress - * - * Routine Description: - * Exported function to restore the packet header in Rx path. - * - * Arguments: - * IN void* pvContext - PHS Driver Specific Context. - * IN B_UINT16 uiVcid - The Service Flow ID to which current - * packet header restoration applies. - * IN void *pvInputBuffer - The Input buffer containg suppressed - * packet header data - * OUT void *pvOutputBuffer - The output buffer returned by this - * function after restoration - * OUT UINT *pHeaderSize - The packet header size after restoration - * is returned in this parameter. - * - * Return Value: - * - * 0 if successful, - * >0 Error. - */ -static ULONG PhsDeCompress(IN void *pvContext, - IN B_UINT16 uiVcid, - IN void *pvInputBuffer, - OUT void *pvOutputBuffer, - OUT UINT *pInHeaderSize, - OUT UINT *pOutHeaderSize) -{ - UINT nSFIndex = 0, nPhsRuleIndex = 0; - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_phs_rule *pstPhsRule = NULL; - UINT phsi; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_extension *pDeviceExtension = - (struct bcm_phs_extension *)pvContext; - - *pInHeaderSize = 0; - if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, - DBG_LVL_ALL, "Invalid Device Extension\n"); - return ERR_PHS_INVALID_DEVICE_EXETENSION; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, - "Restoring header\n"); - - phsi = *((unsigned char *)(pvInputBuffer)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, - "PHSI To Be Used For restore : %x\n", phsi); - if (phsi == UNCOMPRESSED_PACKET) - return STATUS_PHS_NOCOMPRESSION; - - /* Retrieve the SFID Entry Index for requested Service Flow */ - nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, - uiVcid, &pstServiceFlowEntry); - if (nSFIndex == PHS_INVALID_TABLE_INDEX) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, - DBG_LVL_ALL, - "SFID Match Failed During Lookup\n"); - return ERR_SF_MATCH_FAIL; - } - - nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, - phsi, - eActiveClassifierRuleContext, - &pstPhsRule); - if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) { - /* Phs Rule does not exist in active rules table. Lets try - * in the old rules table. */ - nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, - phsi, - eOldClassifierRuleContext, - &pstPhsRule); - if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) - return ERR_PHSRULE_MATCH_FAIL; - } - - *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer, - (PUCHAR)pvOutputBuffer, - pstPhsRule, - pOutHeaderSize); - - pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1; - - pstPhsRule->PHSModifiedNumPackets++; - return STATUS_PHS_COMPRESSED; -} - -/* - * Procedure: free_phs_serviceflow_rules - * - * Description: This routine is responsible for freeing memory allocated for - * PHS rules. - * - * Arguments: - * rules - ptr to S_SERVICEFLOW_TABLE structure. - * - * Returns: - * Does not return any value. - */ -static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable) -{ - int i, j; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - struct bcm_phs_classifier_entry *curr_act_rules_list; - struct bcm_phs_classifier_entry *curr_old_rules_list; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "=======>\n"); - - if (!psServiceFlowRulesTable) - goto out; - - for (i = 0; i < MAX_SERVICEFLOWS; i++) { - struct bcm_phs_entry stServiceFlowEntry = - psServiceFlowRulesTable->stSFList[i]; - struct bcm_phs_classifier_table *pstClassifierRulesTable = - stServiceFlowEntry.pstClassifierTable; - - if (pstClassifierRulesTable) { - for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { - curr_act_rules_list = - &pstClassifierRulesTable->stActivePhsRulesList[j]; - - curr_old_rules_list = - &pstClassifierRulesTable->stOldPhsRulesList[j]; - - if (curr_act_rules_list->pstPhsRule) { - - if (curr_act_rules_list->pstPhsRule->u8RefCnt) - curr_act_rules_list->pstPhsRule->u8RefCnt--; - - if (0 == curr_act_rules_list->pstPhsRule->u8RefCnt) - kfree(curr_act_rules_list->pstPhsRule); - - curr_act_rules_list->pstPhsRule = NULL; - } - - if (curr_old_rules_list->pstPhsRule) { - - if (curr_old_rules_list->pstPhsRule->u8RefCnt) - curr_old_rules_list->pstPhsRule->u8RefCnt--; - - if (0 == curr_old_rules_list->pstPhsRule->u8RefCnt) - kfree(curr_old_rules_list->pstPhsRule); - - curr_old_rules_list->pstPhsRule = NULL; - } - } - kfree(pstClassifierRulesTable); - stServiceFlowEntry.pstClassifierTable = - pstClassifierRulesTable = NULL; - } - } - -out: - - kfree(psServiceFlowRulesTable); - psServiceFlowRulesTable = NULL; -} - -static bool ValidatePHSRuleComplete(IN const struct bcm_phs_rule *psPhsRule) -{ - return (psPhsRule && - psPhsRule->u8PHSI && - psPhsRule->u8PHSS && - psPhsRule->u8PHSFLength); -} - -UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, - IN B_UINT16 uiVcid, - struct bcm_phs_entry **ppstServiceFlowEntry) -{ - int i; - struct bcm_phs_entry *curr_sf_list; - - for (i = 0; i < MAX_SERVICEFLOWS; i++) { - curr_sf_list = &psServiceFlowTable->stSFList[i]; - if (curr_sf_list->bUsed && (curr_sf_list->uiVcid == uiVcid)) { - *ppstServiceFlowEntry = curr_sf_list; - return i; - } - } - - *ppstServiceFlowEntry = NULL; - return PHS_INVALID_TABLE_INDEX; -} - -static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, - IN B_UINT32 uiClsid, - enum bcm_phs_classifier_context eClsContext, - OUT struct bcm_phs_classifier_entry **ppstClassifierEntry) -{ - int i; - struct bcm_phs_classifier_entry *psClassifierRules = NULL; - - for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { - - if (eClsContext == eActiveClassifierRuleContext) - psClassifierRules = - &pstClassifierTable->stActivePhsRulesList[i]; - else - psClassifierRules = - &pstClassifierTable->stOldPhsRulesList[i]; - - if (psClassifierRules->bUsed && - (psClassifierRules->uiClassifierRuleId == uiClsid)) { - *ppstClassifierEntry = psClassifierRules; - return i; - } - } - - *ppstClassifierEntry = NULL; - return PHS_INVALID_TABLE_INDEX; -} - -static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, - IN B_UINT32 uiPHSI, - enum bcm_phs_classifier_context eClsContext, - OUT struct bcm_phs_rule **ppstPhsRule) -{ - int i; - struct bcm_phs_classifier_entry *pstClassifierRule = NULL; - - for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { - if (eClsContext == eActiveClassifierRuleContext) - pstClassifierRule = - &pstClassifierTable->stActivePhsRulesList[i]; - else - pstClassifierRule = - &pstClassifierTable->stOldPhsRulesList[i]; - - if (pstClassifierRule->bUsed && - (pstClassifierRule->u8PHSI == uiPHSI)) { - *ppstPhsRule = pstClassifierRule->pstPhsRule; - return i; - } - } - - *ppstPhsRule = NULL; - return PHS_INVALID_TABLE_INDEX; -} - -static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId, - IN struct bcm_phs_table *psServiceFlowTable, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI) -{ - struct bcm_phs_classifier_table *psaClassifiertable = NULL; - UINT uiStatus = 0; - int iSfIndex; - bool bFreeEntryFound = false; - struct bcm_phs_entry *curr_list; - - /* Check for a free entry in SFID table */ - for (iSfIndex = 0; iSfIndex < MAX_SERVICEFLOWS; iSfIndex++) { - curr_list = &psServiceFlowTable->stSFList[iSfIndex]; - if (!curr_list->bUsed) { - bFreeEntryFound = TRUE; - break; - } - } - - if (!bFreeEntryFound) - return ERR_SFTABLE_FULL; - - psaClassifiertable = curr_list->pstClassifierTable; - uiStatus = CreateClassifierPHSRule(uiClsId, - psaClassifiertable, - psPhsRule, - eActiveClassifierRuleContext, - u8AssociatedPHSI); - if (uiStatus == PHS_SUCCESS) { - /* Add entry at free index to the SF */ - curr_list->bUsed = TRUE; - curr_list->uiVcid = uiVcid; - } - - return uiStatus; -} - -static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, - IN B_UINT16 uiClsId, - IN struct bcm_phs_entry *pstServiceFlowEntry, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI) -{ - struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; - UINT uiStatus = PHS_SUCCESS; - UINT nClassifierIndex = 0; - struct bcm_phs_classifier_table *psaClassifiertable = NULL; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "==>"); - - /* Check if the supplied Classifier already exists */ - nClassifierIndex = GetClassifierEntry( - pstServiceFlowEntry->pstClassifierTable, - uiClsId, - eActiveClassifierRuleContext, - &pstClassifierEntry); - - if (nClassifierIndex == PHS_INVALID_TABLE_INDEX) { - /* - * The Classifier doesn't exist. So its a new classifier being - * added. - * Add new entry to associate PHS Rule to the Classifier - */ - - uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, - psPhsRule, - eActiveClassifierRuleContext, - u8AssociatedPHSI); - return uiStatus; - } - - /* - * The Classifier exists.The PHS Rule for this classifier - * is being modified - */ - - if (pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI) { - if (pstClassifierEntry->pstPhsRule == NULL) - return ERR_PHS_INVALID_PHS_RULE; - - /* - * This rule already exists if any fields are changed for this - * PHS rule update them. - */ - /* If any part of PHSF is valid then we update PHSF */ - if (psPhsRule->u8PHSFLength) { - /* update PHSF */ - memcpy(pstClassifierEntry->pstPhsRule->u8PHSF, - psPhsRule->u8PHSF, - MAX_PHS_LENGTHS); - } - - if (psPhsRule->u8PHSFLength) { - /* update PHSFLen */ - pstClassifierEntry->pstPhsRule->u8PHSFLength = - psPhsRule->u8PHSFLength; - } - - if (psPhsRule->u8PHSMLength) { - /* update PHSM */ - memcpy(pstClassifierEntry->pstPhsRule->u8PHSM, - psPhsRule->u8PHSM, - MAX_PHS_LENGTHS); - } - - if (psPhsRule->u8PHSMLength) { - /* update PHSM Len */ - pstClassifierEntry->pstPhsRule->u8PHSMLength = - psPhsRule->u8PHSMLength; - } - - if (psPhsRule->u8PHSS) { - /* update PHSS */ - pstClassifierEntry->pstPhsRule->u8PHSS = - psPhsRule->u8PHSS; - } - - /* update PHSV */ - pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV; - } else { - /* A new rule is being set for this classifier. */ - uiStatus = UpdateClassifierPHSRule(uiClsId, - pstClassifierEntry, - psaClassifiertable, - psPhsRule, - u8AssociatedPHSI); - } - - return uiStatus; -} - -static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, - struct bcm_phs_classifier_table *psaClassifiertable, - struct bcm_phs_rule *psPhsRule, - enum bcm_phs_classifier_context eClsContext, - B_UINT8 u8AssociatedPHSI) -{ - UINT iClassifierIndex = 0; - bool bFreeEntryFound = false; - struct bcm_phs_classifier_entry *psClassifierRules = NULL; - UINT nStatus = PHS_SUCCESS; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, - "Inside CreateClassifierPHSRule"); - - if (psaClassifiertable == NULL) - return ERR_INVALID_CLASSIFIERTABLE_FOR_SF; - - if (eClsContext == eOldClassifierRuleContext) { - /* - * If An Old Entry for this classifier ID already exists in the - * old rules table replace it. - */ - - iClassifierIndex = GetClassifierEntry(psaClassifiertable, - uiClsId, - eClsContext, - &psClassifierRules); - - if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) { - /* - * The Classifier already exists in the old rules table - * Lets replace the old classifier with the new one. - */ - bFreeEntryFound = TRUE; - } - } - - if (!bFreeEntryFound) { - /* Continue to search for a free location to add the rule */ - for (iClassifierIndex = 0; iClassifierIndex < - MAX_PHSRULE_PER_SF; iClassifierIndex++) { - if (eClsContext == eActiveClassifierRuleContext) - psClassifierRules = &psaClassifiertable->stActivePhsRulesList[iClassifierIndex]; - else - psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; - - if (!psClassifierRules->bUsed) { - bFreeEntryFound = TRUE; - break; - } - } - } - - if (!bFreeEntryFound) { - - if (eClsContext == eActiveClassifierRuleContext) - return ERR_CLSASSIFIER_TABLE_FULL; - /* Lets replace the oldest rule if we are looking in - * old Rule table */ - if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF) - psaClassifiertable->uiOldestPhsRuleIndex = 0; - - iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex; - psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; - - psaClassifiertable->uiOldestPhsRuleIndex++; - } - - if (eClsContext == eOldClassifierRuleContext) { - - if (psClassifierRules->pstPhsRule == NULL) { - - psClassifierRules->pstPhsRule = - kmalloc(sizeof(struct bcm_phs_rule), - GFP_KERNEL); - - if (NULL == psClassifierRules->pstPhsRule) - return ERR_PHSRULE_MEMALLOC_FAIL; - } - - psClassifierRules->bUsed = TRUE; - psClassifierRules->uiClassifierRuleId = uiClsId; - psClassifierRules->u8PHSI = psPhsRule->u8PHSI; - psClassifierRules->bUnclassifiedPHSRule = - psPhsRule->bUnclassifiedPHSRule; - - /* Update The PHS rule */ - memcpy(psClassifierRules->pstPhsRule, psPhsRule, - sizeof(struct bcm_phs_rule)); - } else - nStatus = UpdateClassifierPHSRule(uiClsId, - psClassifierRules, - psaClassifiertable, - psPhsRule, - u8AssociatedPHSI); - - return nStatus; -} - -static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, - IN struct bcm_phs_classifier_entry *pstClassifierEntry, - struct bcm_phs_classifier_table *psaClassifiertable, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI) -{ - struct bcm_phs_rule *pstAddPhsRule = NULL; - UINT nPhsRuleIndex = 0; - bool bPHSRuleOrphaned = false; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - psPhsRule->u8RefCnt = 0; - - /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry */ - bPHSRuleOrphaned = DerefPhsRule(uiClsId, psaClassifiertable, - pstClassifierEntry->pstPhsRule); - - /* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in - * Classifier table for this SF */ - nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI, - eActiveClassifierRuleContext, - &pstAddPhsRule); - if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, - "\nAdding New PHSRuleEntry For Classifier"); - - if (psPhsRule->u8PHSI == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, "\nError PHSI is Zero\n"); - return ERR_PHS_INVALID_PHS_RULE; - } - - /* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for - * uiClsId */ - if (false == bPHSRuleOrphaned) { - - pstClassifierEntry->pstPhsRule = - kmalloc(sizeof(struct bcm_phs_rule), - GFP_KERNEL); - if (NULL == pstClassifierEntry->pstPhsRule) - return ERR_PHSRULE_MEMALLOC_FAIL; - } - memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, - sizeof(struct bcm_phs_rule)); - } else { - /* Step 2.b PHS Rule Exists Tie uiClsId with the existing - * PHS Rule */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, - DBG_LVL_ALL, - "\nTying Classifier to Existing PHS Rule"); - if (bPHSRuleOrphaned) { - kfree(pstClassifierEntry->pstPhsRule); - pstClassifierEntry->pstPhsRule = NULL; - } - pstClassifierEntry->pstPhsRule = pstAddPhsRule; - } - - pstClassifierEntry->bUsed = TRUE; - pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI; - pstClassifierEntry->uiClassifierRuleId = uiClsId; - pstClassifierEntry->pstPhsRule->u8RefCnt++; - pstClassifierEntry->bUnclassifiedPHSRule = - pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule; - - return PHS_SUCCESS; -} - -static bool DerefPhsRule(IN B_UINT16 uiClsId, - struct bcm_phs_classifier_table *psaClassifiertable, - struct bcm_phs_rule *pstPhsRule) -{ - if (pstPhsRule == NULL) - return false; - - if (pstPhsRule->u8RefCnt) - pstPhsRule->u8RefCnt--; - - return (0 == pstPhsRule->u8RefCnt); -} - -static void dbg_print_st_cls_entry(struct bcm_mini_adapter *ad, - struct bcm_phs_entry *st_serv_flow_entry, - struct bcm_phs_classifier_entry *st_cls_entry) -{ - int k; - - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X", st_serv_flow_entry->uiVcid); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X", st_cls_entry->uiClassifierRuleId); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X", st_cls_entry->u8PHSI); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n"); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X", st_cls_entry->pstPhsRule->u8PHSI); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ", st_cls_entry->pstPhsRule->u8PHSFLength); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : "); - - for (k = 0 ; k < st_cls_entry->pstPhsRule->u8PHSFLength; k++) - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ", st_cls_entry->pstPhsRule->u8PHSF[k]); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X", st_cls_entry->pstPhsRule->u8PHSMLength); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :"); - - for (k = 0; k < st_cls_entry->pstPhsRule->u8PHSMLength; k++) - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ", st_cls_entry->pstPhsRule->u8PHSM[k]); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ", st_cls_entry->pstPhsRule->u8PHSS); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X", st_cls_entry->pstPhsRule->u8PHSV); - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n"); -} - -static void phsrules_per_sf_dbg_print(struct bcm_mini_adapter *ad, - struct bcm_phs_entry *st_serv_flow_entry) -{ - int j, l; - struct bcm_phs_classifier_entry st_cls_entry; - - for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { - - for (l = 0; l < 2; l++) { - - if (l == 0) { - st_cls_entry = st_serv_flow_entry->pstClassifierTable->stActivePhsRulesList[j]; - if (st_cls_entry.bUsed) - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, - DUMP_INFO, - (DBG_LVL_ALL | DBG_NO_FUNC_PRINT), - "\n Active PHS Rule :\n"); - } else { - st_cls_entry = st_serv_flow_entry->pstClassifierTable->stOldPhsRulesList[j]; - if (st_cls_entry.bUsed) - BCM_DEBUG_PRINT(ad, - DBG_TYPE_OTHERS, - DUMP_INFO, - (DBG_LVL_ALL | DBG_NO_FUNC_PRINT), - "\n Old PHS Rule :\n"); - } - - if (st_cls_entry.bUsed) { - dbg_print_st_cls_entry(ad, - st_serv_flow_entry, - &st_cls_entry); - } - } - } -} - -void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) -{ - int i; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, - "\n Dumping PHS Rules :\n"); - - for (i = 0; i < MAX_SERVICEFLOWS; i++) { - - struct bcm_phs_entry stServFlowEntry = - pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i]; - - if (!stServFlowEntry.bUsed) - continue; - - phsrules_per_sf_dbg_print(Adapter, &stServFlowEntry); - } -} - -/* - * Procedure: phs_decompress - * - * Description: This routine restores the static fields within the packet. - * - * Arguments: - * in_buf - ptr to incoming packet buffer. - * out_buf - ptr to output buffer where the suppressed - * header is copied. - * decomp_phs_rules - ptr to PHS rule. - * header_size - ptr to field which holds the phss or - * phsf_length. - * - * Returns: - * size - The number of bytes of dynamic fields present with in the - * incoming packet header. - * 0 - If PHS rule is NULL.If PHSI is 0 indicateing packet as - * uncompressed. - */ -static int phs_decompress(unsigned char *in_buf, - unsigned char *out_buf, - struct bcm_phs_rule *decomp_phs_rules, - UINT *header_size) -{ - int phss, size = 0; - struct bcm_phs_rule *tmp_memb; - int bit, i = 0; - unsigned char *phsf, *phsm; - int in_buf_len = *header_size - 1; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - in_buf++; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, - "====>\n"); - *header_size = 0; - - if (decomp_phs_rules == NULL) - return 0; - - tmp_memb = decomp_phs_rules; - /* - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL, - * "\nDECOMP:In phs_decompress PHSI 1 %d",phsi)); - * header_size = tmp_memb->u8PHSFLength; - */ - phss = tmp_memb->u8PHSS; - phsf = tmp_memb->u8PHSF; - phsm = tmp_memb->u8PHSM; - - if (phss > MAX_PHS_LENGTHS) - phss = MAX_PHS_LENGTHS; - - /* - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL, - * "\nDECOMP: - * In phs_decompress PHSI %d phss %d index %d",phsi,phss,index)); - */ - while ((phss > 0) && (size < in_buf_len)) { - bit = ((*phsm << i) & SUPPRESS); - - if (bit == SUPPRESS) { - *out_buf = *phsf; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, - DBG_LVL_ALL, - "\nDECOMP:In phss %d phsf %d output %d", - phss, *phsf, *out_buf); - } else { - *out_buf = *in_buf; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, - DBG_LVL_ALL, - "\nDECOMP:In phss %d input %d output %d", - phss, *in_buf, *out_buf); - in_buf++; - size++; - } - out_buf++; - phsf++; - phss--; - i++; - *header_size = *header_size + 1; - - if (i > MAX_NO_BIT) { - i = 0; - phsm++; - } - } - - return size; -} - -/* - * Procedure: phs_compress - * - * Description: This routine suppresses the static fields within the packet. - * Before that it will verify the fields to be suppressed with the corresponding - * fields in the phsf. For verification it checks the phsv field of PHS rule. - * If set and verification succeeds it suppresses the field.If any one static - * field is found different none of the static fields are suppressed then the - * packet is sent as uncompressed packet with phsi=0. - * - * Arguments: - * phs_rule - ptr to PHS rule. - * in_buf - ptr to incoming packet buffer. - * out_buf - ptr to output buffer where the suppressed header is - * copied. - * header_size - ptr to field which holds the phss. - * - * Returns: - * size - The number of bytes copied into the output buffer i.e - * dynamic fields - * 0 - If PHS rule is NULL.If PHSV field is not set. If the - * verification fails. - */ -static int phs_compress(struct bcm_phs_rule *phs_rule, - unsigned char *in_buf, - unsigned char *out_buf, - UINT *header_size, - UINT *new_header_size) -{ - unsigned char *old_addr = out_buf; - int suppress = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (phs_rule == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "\nphs_compress(): phs_rule null!"); - *out_buf = ZERO_PHSI; - return STATUS_PHS_NOCOMPRESSION; - } - - if (phs_rule->u8PHSS <= *new_header_size) - *header_size = phs_rule->u8PHSS; - else - *header_size = *new_header_size; - - /* To copy PHSI */ - out_buf++; - suppress = verify_suppress_phsf(in_buf, out_buf, phs_rule->u8PHSF, - phs_rule->u8PHSM, phs_rule->u8PHSS, - phs_rule->u8PHSV, new_header_size); - - if (suppress == STATUS_PHS_COMPRESSED) { - *old_addr = (unsigned char)phs_rule->u8PHSI; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "\nCOMP:In phs_compress phsi %d", - phs_rule->u8PHSI); - } else { - *old_addr = ZERO_PHSI; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "\nCOMP:In phs_compress PHSV Verification failed"); - } - - return suppress; -} - -/* - * Procedure: verify_suppress_phsf - * - * Description: This routine verifies the fields of the packet and if all the - * static fields are equal it adds the phsi of that PHS rule.If any static - * field differs it woun't suppress any field. - * - * Arguments: - * rules_set - ptr to classifier_rules. - * in_buffer - ptr to incoming packet buffer. - * out_buffer - ptr to output buffer where the suppressed header is copied. - * phsf - ptr to phsf. - * phsm - ptr to phsm. - * phss - variable holding phss. - * - * Returns: - * size - The number of bytes copied into the output buffer i.e dynamic - * fields. - * 0 - Packet has failed the verification. - */ -static int verify_suppress_phsf(unsigned char *in_buffer, - unsigned char *out_buffer, - unsigned char *phsf, - unsigned char *phsm, - unsigned int phss, - unsigned int phsv, - UINT *new_header_size) -{ - unsigned int size = 0; - int bit, i = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "\nCOMP:In verify_phsf PHSM - 0x%X", *phsm); - - if (phss > (*new_header_size)) - phss = *new_header_size; - - while (phss > 0) { - bit = ((*phsm << i) & SUPPRESS); - if (bit == SUPPRESS) { - if (*in_buffer != *phsf) { - if (phsv == VERIFY) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - PHS_SEND, - DBG_LVL_ALL, - "\nCOMP:In verify_phsf failed for field %d buf %d phsf %d", - phss, - *in_buffer, - *phsf); - return STATUS_PHS_NOCOMPRESSION; - } - } else - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - PHS_SEND, - DBG_LVL_ALL, - "\nCOMP:In verify_phsf success for field %d buf %d phsf %d", - phss, - *in_buffer, - *phsf); - } else { - *out_buffer = *in_buffer; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - PHS_SEND, - DBG_LVL_ALL, - "\nCOMP:In copying_header input %d out %d", - *in_buffer, - *out_buffer); - out_buffer++; - size++; - } - - in_buffer++; - phsf++; - phss--; - i++; - - if (i > MAX_NO_BIT) { - i = 0; - phsm++; - } - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, - "\nCOMP:In verify_phsf success"); - *new_header_size = size; - return STATUS_PHS_COMPRESSED; -} diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h deleted file mode 100644 index d84d60ba48f9..000000000000 --- a/drivers/staging/bcm/PHSModule.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef BCM_MINIPORT_PHSMODULE_H -#define BCM_MINIPORT_PHSMODULE_H - -int PHSTransmit(struct bcm_mini_adapter *Adapter, - struct sk_buff **pPacket, - USHORT Vcid, - B_UINT16 uiClassifierRuleID, - bool bHeaderSuppressionEnabled, - PUINT PacketLen, - UCHAR bEthCSSupport); - -int PHSReceive(struct bcm_mini_adapter *Adapter, - USHORT usVcid, - struct sk_buff *packet, - UINT *punPacketLen, - UCHAR *pucEthernetHdr, - UINT - ); - - -void DumpDataPacketHeader(PUCHAR pPkt); - -void DumpFullPacket(UCHAR *pBuf, UINT nPktLen); - -void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension); - - -int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, - struct bcm_mini_adapter *Adapter); - -int PhsCleanup(struct bcm_phs_extension *pPHSDeviceExt); - -/* Utility Functions */ -ULONG PhsUpdateClassifierRule(void *pvContext, - B_UINT16 uiVcid, - B_UINT16 uiClsId, - struct bcm_phs_rule *psPhsRule, - B_UINT8 u8AssociatedPHSI); - -ULONG PhsDeletePHSRule(void *pvContext, B_UINT16 uiVcid, B_UINT8 u8PHSI); - -ULONG PhsDeleteClassifierRule(void *pvContext, - B_UINT16 uiVcid, - B_UINT16 uiClsId); - -ULONG PhsDeleteSFRules(void *pvContext, B_UINT16 uiVcid); - - -bool ValidatePHSRule(struct bcm_phs_rule *psPhsRule); - -UINT GetServiceFlowEntry(struct bcm_phs_table *psServiceFlowTable, - B_UINT16 uiVcid, - struct bcm_phs_entry **ppstServiceFlowEntry); - - -void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension); - - -#endif diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h deleted file mode 100644 index 9818128d9320..000000000000 --- a/drivers/staging/bcm/Protocol.h +++ /dev/null @@ -1,128 +0,0 @@ -/************************************ -* Protocol.h -*************************************/ -#ifndef __PROTOCOL_H__ -#define __PROTOCOL_H__ - -#define IPV4 4 -#define IPV6 6 - -struct ArpHeader { - struct arphdr arp; - unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ - unsigned char ar_sip[4]; /* sender IP address */ - unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ - unsigned char ar_tip[4]; /* target IP address */ -}; - -struct bcm_transport_header { - union { - struct udphdr uhdr; - struct tcphdr thdr; - }; -} __packed; - -enum bcm_ip_frame_type { - eNonIPPacket, - eIPv4Packet, - eIPv6Packet -}; - -enum bcm_eth_frame_type { - eEthUnsupportedFrame, - eEth802LLCFrame, - eEth802LLCSNAPFrame, - eEth802QVLANFrame, - eEthOtherFrame -}; - -struct bcm_eth_packet_info { - enum bcm_ip_frame_type eNwpktIPFrameType; - enum bcm_eth_frame_type eNwpktEthFrameType; - unsigned short usEtherType; - unsigned char ucDSAP; -}; - -struct bcm_eth_q_frame { - struct bcm_eth_header EThHdr; - unsigned short UserPriority:3; - unsigned short CFI:1; - unsigned short VLANID:12; - unsigned short EthType; -} __packed; - -struct bcm_eth_llc_frame { - struct bcm_eth_header EThHdr; - unsigned char DSAP; - unsigned char SSAP; - unsigned char Control; -} __packed; - -struct bcm_eth_llc_snap_frame { - struct bcm_eth_header EThHdr; - unsigned char DSAP; - unsigned char SSAP; - unsigned char Control; - unsigned char OUI[3]; - unsigned short usEtherType; -} __packed; - -struct bcm_ethernet2_frame { - struct bcm_eth_header EThHdr; -} __packed; - -#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) -#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) -#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) - -/* Per SF CS Specification Encodings */ -enum bcm_spec_encoding { - eCSSpecUnspecified = 0, - eCSPacketIPV4, - eCSPacketIPV6, - eCS802_3PacketEthernet, - eCS802_1QPacketVLAN, - eCSPacketIPV4Over802_3Ethernet, - eCSPacketIPV6Over802_3Ethernet, - eCSPacketIPV4Over802_1QVLAN, - eCSPacketIPV6Over802_1QVLAN, - eCSPacketUnsupported -}; - -#define IP6_HEADER_LEN 40 -#define IP_VERSION(byte) (((byte&0xF0)>>4)) - -#define MAC_ADDRESS_SIZE 6 -#define ETH_AND_IP_HEADER_LEN (14 + 20) -#define L4_SRC_PORT_LEN 2 -#define L4_DEST_PORT_LEN 2 -#define CTRL_PKT_LEN (8 + ETH_AND_IP_HEADER_LEN) - -#define ETH_ARP_FRAME 0x806 -#define ETH_IPV4_FRAME 0x800 -#define ETH_IPV6_FRAME 0x86DD -#define UDP 0x11 -#define TCP 0x06 - -#define ARP_OP_REQUEST 0x01 -#define ARP_OP_REPLY 0x02 -#define ARP_PKT_SIZE 60 - -/* This is the format for the TCP packet header */ -struct bcm_tcp_header { - unsigned short usSrcPort; - unsigned short usDestPort; - unsigned long ulSeqNumber; - unsigned long ulAckNumber; - unsigned char HeaderLength; - unsigned char ucFlags; - unsigned short usWindowsSize; - unsigned short usChkSum; - unsigned short usUrgetPtr; -}; - -#define TCP_HEADER_LEN sizeof(struct bcm_tcp_header) -#define TCP_ACK 0x10 /* Bit 4 in tcpflags field. */ -#define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4) - -#endif /* __PROTOCOL_H__ */ diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h deleted file mode 100644 index 1ddc8b2539f6..000000000000 --- a/drivers/staging/bcm/Prototypes.h +++ /dev/null @@ -1,217 +0,0 @@ -#ifndef _PROTOTYPES_H_ -#define _PROTOTYPES_H_ - -VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer); - -VOID StatisticsResponse(struct bcm_mini_adapter *Adapter, PVOID pvBuffer); - -VOID IdleModeResponse(struct bcm_mini_adapter *Adapter, PUINT puiBuffer); - -int control_packet_handler(struct bcm_mini_adapter *Adapter); - -VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex); - -VOID flush_all_queues(struct bcm_mini_adapter *Adapter); - -int register_control_device_interface(struct bcm_mini_adapter *ps_adapter); - -void unregister_control_device_interface(struct bcm_mini_adapter *Adapter); - -INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter,/**ucIPSourceAddressLength) - return TRUE; - for (ucLoopIndex = 0; - ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); - ucLoopIndex++) { - src_addr = &pstClassifierRule->stSrcIpAddress; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", - (UINT)src_addr->ulIpv4Mask[ucLoopIndex], - (UINT)ulSrcIP, - (UINT)src_addr->ulIpv6Addr[ucLoopIndex]); - - if ((src_addr->ulIpv4Mask[ucLoopIndex] & ulSrcIP) == - (src_addr->ulIpv4Addr[ucLoopIndex] & - src_addr->ulIpv4Mask[ucLoopIndex])) - return TRUE; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Src Ip Address Not Matched"); - return false; -} - - -/******************************************************************* -* Function - MatchDestIpAddress() -* -* Description - Checks whether the Destination IP address from the packet -* matches with that of Queue. -* -* Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ulDestIP : Destination IP address from the packet. -* -* Returns - TRUE(If address matches) else FAIL . -*********************************************************************/ -static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG ulDestIP) -{ - UCHAR ucLoopIndex = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - union u_ip_address *dest_addr = &pstClassifierRule->stDestIpAddress; - - ulDestIP = ntohl(ulDestIP); - if (0 == pstClassifierRule->ucIPDestinationAddressLength) - return TRUE; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Destination Ip Address 0x%x 0x%x 0x%x ", - (UINT)ulDestIP, - (UINT)dest_addr->ulIpv4Mask[ucLoopIndex], - (UINT)dest_addr->ulIpv4Addr[ucLoopIndex]); - - for (ucLoopIndex = 0; - ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); - ucLoopIndex++) { - if ((dest_addr->ulIpv4Mask[ucLoopIndex] & ulDestIP) == - (dest_addr->ulIpv4Addr[ucLoopIndex] & - dest_addr->ulIpv4Mask[ucLoopIndex])) - return TRUE; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Destination Ip Address Not Matched"); - return false; -} - - -/************************************************************************ -* Function - MatchTos() -* -* Description - Checks the TOS from the packet matches with that of queue. -* -* Parameters - pstClassifierRule : Pointer to the packet info structure. -* - ucTypeOfService: TOS from the packet. -* -* Returns - TRUE(If address matches) else FAIL. -**************************************************************************/ -static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule, - UCHAR ucTypeOfService) -{ - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (3 != pstClassifierRule->ucIPTypeOfServiceLength) - return TRUE; - - if (((pstClassifierRule->ucTosMask & ucTypeOfService) <= - pstClassifierRule->ucTosHigh) && - ((pstClassifierRule->ucTosMask & ucTypeOfService) >= - pstClassifierRule->ucTosLow)) - return TRUE; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Type Of Service Not Matched"); - return false; -} - - -/*************************************************************************** -* Function - MatchProtocol() -* -* Description - Checks the protocol from the packet matches with that of queue. -* -* Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ucProtocol : Protocol from the packet. -* -* Returns - TRUE(If address matches) else FAIL. -****************************************************************************/ -bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, - UCHAR ucProtocol) -{ - UCHAR ucLoopIndex = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (0 == pstClassifierRule->ucProtocolLength) - return TRUE; - for (ucLoopIndex = 0; - ucLoopIndex < pstClassifierRule->ucProtocolLength; - ucLoopIndex++) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Protocol:0x%X Classification Protocol:0x%X", - ucProtocol, - pstClassifierRule->ucProtocol[ucLoopIndex]); - if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol) - return TRUE; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Protocol Not Matched"); - return false; -} - - -/*********************************************************************** -* Function - MatchSrcPort() -* -* Description - Checks, Source port from the packet matches with that of queue. -* -* Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ushSrcPort : Source port from the packet. -* -* Returns - TRUE(If address matches) else FAIL. -***************************************************************************/ -bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, - USHORT ushSrcPort) -{ - UCHAR ucLoopIndex = 0; - - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - - if (0 == pstClassifierRule->ucSrcPortRangeLength) - return TRUE; - for (ucLoopIndex = 0; - ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; - ucLoopIndex++) { - if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && - ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) - return TRUE; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Src Port: %x Not Matched ", - ushSrcPort); - return false; -} - - -/*********************************************************************** -* Function - MatchDestPort() -* -* Description - Checks, Destination port from packet matches with that of queue. -* -* Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ushDestPort : Destination port from the packet. -* -* Returns - TRUE(If address matches) else FAIL. -***************************************************************************/ -bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, - USHORT ushDestPort) -{ - UCHAR ucLoopIndex = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (0 == pstClassifierRule->ucDestPortRangeLength) - return TRUE; - - for (ucLoopIndex = 0; - ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; - ucLoopIndex++) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Matching Port:0x%X 0x%X 0x%X", - ushDestPort, - pstClassifierRule->usDestPortRangeLo[ucLoopIndex], - pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); - - if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && - ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) - return TRUE; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Dest Port: %x Not Matched", - ushDestPort); - return false; -} -/** - * @ingroup tx_functions - * Compares IPV4 Ip address and port number - * @return Queue Index. -*/ -static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, - struct iphdr *iphd, - struct bcm_classifier_rule *pstClassifierRule) -{ - struct bcm_transport_header *xprt_hdr = NULL; - bool bClassificationSucceed = false; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "========>"); - - xprt_hdr = (struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr)); - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Trying to see Direction = %d %d", - pstClassifierRule->ucDirection, - pstClassifierRule->usVCID_Value); - - /* Checking classifier validity */ - if (!pstClassifierRule->bUsed || - pstClassifierRule->ucDirection == DOWNLINK_DIR) - goto out; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "is IPv6 check!"); - if (pstClassifierRule->bIpv6Protocol) - goto out; - - /* Checking IP header parameter */ - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Trying to match Source IP Address"); - if (!MatchSrcIpAddress(pstClassifierRule, iphd->saddr)) - goto out; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Source IP Address Matched"); - - if (!MatchDestIpAddress(pstClassifierRule, iphd->daddr)) - goto out; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Destination IP Address Matched"); - - if (!MatchTos(pstClassifierRule, iphd->tos)) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "TOS Match failed\n"); - goto out; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "TOS Matched"); - - if (!MatchProtocol(pstClassifierRule, iphd->protocol)) - goto out; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Protocol Matched"); - - /* - * if protocol is not TCP or UDP then no - * need of comparing source port and destination port - */ - if (iphd->protocol != TCP && iphd->protocol != UDP) { - bClassificationSucceed = TRUE; - goto out; - } - /* Checking Transport Layer Header field if present */ - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Source Port %04x", - (iphd->protocol == UDP) ? xprt_hdr->uhdr.source : xprt_hdr->thdr.source); - - if (!MatchSrcPort(pstClassifierRule, - ntohs((iphd->protocol == UDP) ? - xprt_hdr->uhdr.source : xprt_hdr->thdr.source))) - goto out; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Src Port Matched"); - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Destination Port %04x", - (iphd->protocol == UDP) ? xprt_hdr->uhdr.dest : - xprt_hdr->thdr.dest); - - if (!MatchDestPort(pstClassifierRule, - ntohs((iphd->protocol == UDP) ? - xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest))) - goto out; - bClassificationSucceed = TRUE; - -out: - if (TRUE == bClassificationSucceed) { - INT iMatchedSFQueueIndex = 0; - - iMatchedSFQueueIndex = - SearchSfid(Adapter, pstClassifierRule->ulSFID); - if (iMatchedSFQueueIndex >= NO_OF_QUEUES) - bClassificationSucceed = false; - else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) - bClassificationSucceed = false; - } - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "IpVersion4 <=========="); - - return bClassificationSucceed; -} - -VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter) -{ - UINT iIndex = 0; - - for (iIndex = 0; iIndex < HiPriority; iIndex++) { - if (!Adapter->PackInfo[iIndex].bValid) - continue; - - PruneQueue(Adapter, iIndex); - } -} - - -/** - * @ingroup tx_functions - * This function checks if the max queue size for a queue - * is less than number of bytes in the queue. If so - - * drops packets from the Head till the number of bytes is - * less than or equal to max queue size for the queue. - */ -static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) -{ - struct sk_buff *PacketToDrop = NULL; - struct net_device_stats *netstats; - struct bcm_packet_info *curr_pack_info = &Adapter->PackInfo[iIndex]; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - PRUNE_QUEUE, - DBG_LVL_ALL, - "=====> Index %d", - iIndex); - - if (iIndex == HiPriority) - return; - - if (!Adapter || (iIndex < 0) || (iIndex > HiPriority)) - return; - - /* To Store the netdevice statistic */ - netstats = &Adapter->dev->stats; - - spin_lock_bh(&curr_pack_info->SFQueueLock); - - while (1) { -/* while((UINT)curr_pack_info->uiCurrentPacketsOnHost > - SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { */ - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - PRUNE_QUEUE, - DBG_LVL_ALL, - "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", - curr_pack_info->uiCurrentBytesOnHost, - curr_pack_info->uiMaxBucketSize); - - PacketToDrop = curr_pack_info->FirstTxQueue; - - if (PacketToDrop == NULL) - break; - if ((curr_pack_info->uiCurrentPacketsOnHost < - SF_MAX_ALLOWED_PACKETS_TO_BACKUP) && - ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb) + - SKB_CB_LATENCY_OFFSET))/HZ) <= - curr_pack_info->uiMaxLatency)) - break; - - if (PacketToDrop) { - if (netif_msg_tx_err(Adapter)) - pr_info(PFX "%s: tx queue %d overlimit\n", - Adapter->dev->name, iIndex); - - netstats->tx_dropped++; - - DEQUEUEPACKET(curr_pack_info->FirstTxQueue, - curr_pack_info->LastTxQueue); - /* update current bytes and packets count */ - curr_pack_info->uiCurrentBytesOnHost -= - PacketToDrop->len; - curr_pack_info->uiCurrentPacketsOnHost--; - /* update dropped bytes and packets counts */ - curr_pack_info->uiDroppedCountBytes += PacketToDrop->len; - curr_pack_info->uiDroppedCountPackets++; - dev_kfree_skb(PacketToDrop); - - } - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - PRUNE_QUEUE, - DBG_LVL_ALL, - "Dropped Bytes:%x Dropped Packets:%x", - curr_pack_info->uiDroppedCountBytes, - curr_pack_info->uiDroppedCountPackets); - - atomic_dec(&Adapter->TotalPacketCount); - } - - spin_unlock_bh(&curr_pack_info->SFQueueLock); - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - PRUNE_QUEUE, - DBG_LVL_ALL, - "TotalPacketCount:%x", - atomic_read(&Adapter->TotalPacketCount)); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - PRUNE_QUEUE, - DBG_LVL_ALL, - "<====="); -} - -VOID flush_all_queues(struct bcm_mini_adapter *Adapter) -{ - INT iQIndex; - UINT uiTotalPacketLength; - struct sk_buff *PacketToDrop = NULL; - struct bcm_packet_info *curr_packet_info; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - DUMP_INFO, - DBG_LVL_ALL, - "=====>"); - - /* down(&Adapter->data_packet_queue_lock); */ - for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) { - struct net_device_stats *netstats = &Adapter->dev->stats; - - curr_packet_info = &Adapter->PackInfo[iQIndex]; - - spin_lock_bh(&curr_packet_info->SFQueueLock); - while (curr_packet_info->FirstTxQueue) { - PacketToDrop = curr_packet_info->FirstTxQueue; - if (PacketToDrop) { - uiTotalPacketLength = PacketToDrop->len; - netstats->tx_dropped++; - } else - uiTotalPacketLength = 0; - - DEQUEUEPACKET(curr_packet_info->FirstTxQueue, - curr_packet_info->LastTxQueue); - - /* Free the skb */ - dev_kfree_skb(PacketToDrop); - - /* update current bytes and packets count */ - curr_packet_info->uiCurrentBytesOnHost -= uiTotalPacketLength; - curr_packet_info->uiCurrentPacketsOnHost--; - - /* update dropped bytes and packets counts */ - curr_packet_info->uiDroppedCountBytes += uiTotalPacketLength; - curr_packet_info->uiDroppedCountPackets++; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - DUMP_INFO, - DBG_LVL_ALL, - "Dropped Bytes:%x Dropped Packets:%x", - curr_packet_info->uiDroppedCountBytes, - curr_packet_info->uiDroppedCountPackets); - atomic_dec(&Adapter->TotalPacketCount); - } - spin_unlock_bh(&curr_packet_info->SFQueueLock); - } - /* up(&Adapter->data_packet_queue_lock); */ - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, - DUMP_INFO, - DBG_LVL_ALL, - "<====="); -} - -USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff *skb) -{ - INT uiLoopIndex = 0; - struct bcm_classifier_rule *pstClassifierRule = NULL; - struct bcm_eth_packet_info stEthCsPktInfo; - PVOID pvEThPayload = NULL; - struct iphdr *pIpHeader = NULL; - INT uiSfIndex = 0; - USHORT usIndex = Adapter->usBestEffortQueueIndex; - bool bFragmentedPkt = false, bClassificationSucceed = false; - USHORT usCurrFragment = 0; - - struct bcm_tcp_header *pTcpHeader; - UCHAR IpHeaderLength; - UCHAR TcpHeaderLength; - - pvEThPayload = skb->data; - *((UINT32 *) (skb->cb) + SKB_CB_TCPACK_OFFSET) = 0; - EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo); - - switch (stEthCsPktInfo.eNwpktEthFrameType) { - case eEth802LLCFrame: - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ClassifyPacket : 802LLCFrame\n"); - pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame); - break; - case eEth802LLCSNAPFrame: - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ClassifyPacket : 802LLC SNAP Frame\n"); - pIpHeader = pvEThPayload + - sizeof(struct bcm_eth_llc_snap_frame); - break; - case eEth802QVLANFrame: - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ClassifyPacket : 802.1Q VLANFrame\n"); - pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame); - break; - case eEthOtherFrame: - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ClassifyPacket : ETH Other Frame\n"); - pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); - break; - default: - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ClassifyPacket : Unrecognized ETH Frame\n"); - pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); - break; - } - - if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) { - usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET); - if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) - bFragmentedPkt = TRUE; - - if (bFragmentedPkt) { - /* Fragmented Packet. Get Frag Classifier Entry. */ - pstClassifierRule = GetFragIPClsEntry(Adapter, - pIpHeader->id, - pIpHeader->saddr); - if (pstClassifierRule) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "It is next Fragmented pkt"); - bClassificationSucceed = TRUE; - } - if (!(ntohs(pIpHeader->frag_off) & IP_MF)) { - /* Fragmented Last packet . Remove Frag Classifier Entry */ - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "This is the last fragmented Pkt"); - DelFragIPClsEntry(Adapter, - pIpHeader->id, - pIpHeader->saddr); - } - } - } - - for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) { - if (bClassificationSucceed) - break; - /* - * Iterate through all classifiers which are already in order of priority - * to classify the packet until match found - */ - if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) { - bClassificationSucceed = false; - continue; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Adapter->PackInfo[%d].bvalid=True\n", - uiLoopIndex); - - if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) { - bClassificationSucceed = false; /* cannot be processed for classification. */ - continue; /* it is a down link connection */ - } - - pstClassifierRule = &Adapter->astClassifierTable[uiLoopIndex]; - - uiSfIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); - if (uiSfIndex >= NO_OF_QUEUES) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Queue Not Valid. SearchSfid for this classifier Failed\n"); - continue; - } - - if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { - - if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n"); - bClassificationSucceed = false; - continue; - } - - - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", - pstClassifierRule->uiClassifierRuleIndex, - Adapter->PackInfo[uiSfIndex].ulSFID); - bClassificationSucceed = EThCSClassifyPkt(Adapter, - skb, - &stEthCsPktInfo, - pstClassifierRule, - Adapter->PackInfo[uiSfIndex].bEthCSSupport); - - if (!bClassificationSucceed) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ClassifyPacket : Ethernet CS Classification Failed\n"); - continue; - } - } else { /* No ETH Supported on this SF */ - if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n"); - bClassificationSucceed = false; - continue; - } - } - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Proceeding to IP CS Clasification"); - - if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) { - - if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - " ClassifyPacket : Packet is Not an IP Packet\n"); - bClassificationSucceed = false; - continue; - } - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "Dump IP Header :\n"); - DumpFullPacket((PUCHAR)pIpHeader, 20); - - if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) - bClassificationSucceed = IpVersion4(Adapter, - pIpHeader, - pstClassifierRule); - else if (stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet) - bClassificationSucceed = IpVersion6(Adapter, - pIpHeader, - pstClassifierRule); - } - } - - if (bClassificationSucceed == TRUE) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "CF id : %d, SF ID is =%lu", - pstClassifierRule->uiClassifierRuleIndex, - pstClassifierRule->ulSFID); - - /* Store The matched Classifier in SKB */ - *((UINT32 *)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = - pstClassifierRule->uiClassifierRuleIndex; - if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && - (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= - skb->len)) { - IpHeaderLength = pIpHeader->ihl; - pTcpHeader = - (struct bcm_tcp_header *)(((PUCHAR)pIpHeader) + - (IpHeaderLength*4)); - TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); - - if ((pTcpHeader->ucFlags & TCP_ACK) && - (ntohs(pIpHeader->tot_len) == - (IpHeaderLength*4)+(TcpHeaderLength*4))) - *((UINT32 *) (skb->cb) + SKB_CB_TCPACK_OFFSET) = - TCP_ACK; - } - - usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "index is =%d", - usIndex); - - /* - * If this is the first fragment of a Fragmented pkt, - * add this CF. Only This CF should be used for all other - * fragment of this Pkt. - */ - if (bFragmentedPkt && (usCurrFragment == 0)) { - /* - * First Fragment of Fragmented Packet. - * Create Frag CLS Entry - */ - struct bcm_fragmented_packet_info stFragPktInfo; - - stFragPktInfo.bUsed = TRUE; - stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr; - stFragPktInfo.usIpIdentification = pIpHeader->id; - stFragPktInfo.pstMatchedClassifierEntry = - pstClassifierRule; - stFragPktInfo.bOutOfOrderFragment = false; - AddFragIPClsEntry(Adapter, &stFragPktInfo); - } - - - } - - return bClassificationSucceed ? usIndex : INVALID_QUEUE_INDEX; -} - -static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule, - PUCHAR Mac) -{ - UINT i = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (pstClassifierRule->ucEthCSSrcMACLen == 0) - return TRUE; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s\n", __func__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", - i, - Mac[i], - pstClassifierRule->au8EThCSSrcMAC[i], - pstClassifierRule->au8EThCSSrcMACMask[i]); - if ((pstClassifierRule->au8EThCSSrcMAC[i] & - pstClassifierRule->au8EThCSSrcMACMask[i]) != - (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) - return false; - } - return TRUE; -} - -static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule, - PUCHAR Mac) -{ - UINT i = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if (pstClassifierRule->ucEthCSDestMACLen == 0) - return TRUE; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s\n", - __func__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", - i, - Mac[i], - pstClassifierRule->au8EThCSDestMAC[i], - pstClassifierRule->au8EThCSDestMACMask[i]); - if ((pstClassifierRule->au8EThCSDestMAC[i] & - pstClassifierRule->au8EThCSDestMACMask[i]) != - (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) - return false; - } - return TRUE; -} - -static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, - struct sk_buff *skb, - struct bcm_eth_packet_info *pstEthCsPktInfo) -{ - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - if ((pstClassifierRule->ucEtherTypeLen == 0) || - (pstClassifierRule->au8EthCSEtherType[0] == 0)) - return TRUE; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s SrcEtherType:%x CLS EtherType[0]:%x\n", - __func__, - pstEthCsPktInfo->usEtherType, - pstClassifierRule->au8EthCSEtherType[0]); - if (pstClassifierRule->au8EthCSEtherType[0] == 1) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s CLS EtherType[1]:%x EtherType[2]:%x\n", - __func__, - pstClassifierRule->au8EthCSEtherType[1], - pstClassifierRule->au8EthCSEtherType[2]); - - if (memcmp(&pstEthCsPktInfo->usEtherType, - &pstClassifierRule->au8EthCSEtherType[1], - 2) == 0) - return TRUE; - else - return false; - } - - if (pstClassifierRule->au8EthCSEtherType[0] == 2) { - if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) - return false; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s EthCS DSAP:%x EtherType[2]:%x\n", - __func__, - pstEthCsPktInfo->ucDSAP, - pstClassifierRule->au8EthCSEtherType[2]); - if (pstEthCsPktInfo->ucDSAP == - pstClassifierRule->au8EthCSEtherType[2]) - return TRUE; - return false; - - } - - return false; - -} - -static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, - struct sk_buff *skb, - struct bcm_eth_packet_info *pstEthCsPktInfo) -{ - bool bClassificationSucceed = false; - USHORT usVLANID; - B_UINT8 uPriority = 0; - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s CLS UserPrio:%x CLS VLANID:%x\n", - __func__, - ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), - pstClassifierRule->usVLANID); - - /* - * In case FW didn't receive the TLV, - * the priority field should be ignored - */ - if (pstClassifierRule->usValidityBitMap & - (1<eNwpktEthFrameType != eEth802QVLANFrame) - return false; - - uPriority = (ntohs(*(USHORT *)(skb->data + - sizeof(struct bcm_eth_header))) & - 0xF000) >> 13; - - if ((uPriority >= pstClassifierRule->usUserPriority[0]) && - (uPriority <= - pstClassifierRule->usUserPriority[1])) - bClassificationSucceed = TRUE; - - if (!bClassificationSucceed) - return false; - } - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ETH CS 802.1 D User Priority Rule Matched\n"); - - bClassificationSucceed = false; - - if (pstClassifierRule->usValidityBitMap & - (1<eNwpktEthFrameType != eEth802QVLANFrame) - return false; - - usVLANID = ntohs(*(USHORT *)(skb->data + - sizeof(struct bcm_eth_header))) & 0xFFF; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "%s Pkt VLANID %x Priority: %d\n", - __func__, - usVLANID, - uPriority); - - if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) - bClassificationSucceed = TRUE; - - if (!bClassificationSucceed) - return false; - } - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ETH CS 802.1 Q VLAN ID Rule Matched\n"); - - return TRUE; -} - - -static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, - struct sk_buff *skb, - struct bcm_eth_packet_info *pstEthCsPktInfo, - struct bcm_classifier_rule *pstClassifierRule, - B_UINT8 EthCSCupport) -{ - bool bClassificationSucceed = false; - - bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule, - ((struct bcm_eth_header *)(skb->data))->au8SourceAddress); - if (!bClassificationSucceed) - return false; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ETH CS SrcMAC Matched\n"); - - bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule, - ((struct bcm_eth_header *)(skb->data))->au8DestinationAddress); - if (!bClassificationSucceed) - return false; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ETH CS DestMAC Matched\n"); - - /* classify on ETHType/802.2SAP TLV */ - bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule, - skb, - pstEthCsPktInfo); - if (!bClassificationSucceed) - return false; - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ETH CS EthType/802.2SAP Matched\n"); - - /* classify on 802.1VLAN Header Parameters */ - bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule, - skb, - pstEthCsPktInfo); - if (!bClassificationSucceed) - return false; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "ETH CS 802.1 VLAN Rules Matched\n"); - - return bClassificationSucceed; -} - -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, - PVOID pvEthPayload, - struct bcm_eth_packet_info *pstEthCsPktInfo) -{ - USHORT u16Etype = ntohs( - ((struct bcm_eth_header *)pvEthPayload)->u16Etype); - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "EthCSGetPktInfo : Eth Hdr Type : %X\n", - u16Etype); - if (u16Etype > 0x5dc) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "EthCSGetPktInfo : ETH2 Frame\n"); - /* ETH2 Frame */ - if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) { - /* 802.1Q VLAN Header */ - pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; - u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType; - /* ((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority */ - } else { - pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame; - u16Etype = ntohs(u16Etype); - } - } else { - /* 802.2 LLC */ - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "802.2 LLC Frame\n"); - pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; - pstEthCsPktInfo->ucDSAP = - ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; - if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { - /* SNAP Frame */ - pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; - u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; - } - } - if (u16Etype == ETHERNET_FRAMETYPE_IPV4) - pstEthCsPktInfo->eNwpktIPFrameType = eIPv4Packet; - else if (u16Etype == ETHERNET_FRAMETYPE_IPV6) - pstEthCsPktInfo->eNwpktIPFrameType = eIPv6Packet; - else - pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket; - - pstEthCsPktInfo->usEtherType = ((struct bcm_eth_header *)pvEthPayload)->u16Etype; - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "EthCsPktInfo->eNwpktIPFrameType : %x\n", - pstEthCsPktInfo->eNwpktIPFrameType); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "EthCsPktInfo->eNwpktEthFrameType : %x\n", - pstEthCsPktInfo->eNwpktEthFrameType); - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_TX, - IPV4_DBG, - DBG_LVL_ALL, - "EthCsPktInfo->usEtherType : %x\n", - pstEthCsPktInfo->usEtherType); -} - diff --git a/drivers/staging/bcm/Queue.h b/drivers/staging/bcm/Queue.h deleted file mode 100644 index 460c0aee67f6..000000000000 --- a/drivers/staging/bcm/Queue.h +++ /dev/null @@ -1,29 +0,0 @@ -/************************************* -* Queue.h -**************************************/ -#ifndef __QUEUE_H__ -#define __QUEUE_H__ - - - -#define ENQUEUEPACKET(_Head, _Tail, _Packet) \ -do { \ - if (!_Head) { \ - _Head = _Packet; \ - } \ - else { \ - (_Tail)->next = _Packet; \ - } \ - (_Packet)->next = NULL; \ - _Tail = _Packet; \ -} while (0) -#define DEQUEUEPACKET(Head, Tail) \ -do { \ - if (Head) { \ - if (!Head->next) { \ - Tail = NULL; \ - } \ - Head = Head->next; \ - } \ -} while (0) -#endif /* __QUEUE_H__ */ diff --git a/drivers/staging/bcm/TODO b/drivers/staging/bcm/TODO deleted file mode 100644 index 8467f45d08a6..000000000000 --- a/drivers/staging/bcm/TODO +++ /dev/null @@ -1,26 +0,0 @@ -This driver is barely functional in its current state. - -Kevin McKinney(klmckinney1@gmail.com) and Matthias Beyer(mail@beyermatthias.de) -are currently maintaining/cleaning up this driver. Please copy us on all -patches. More maintainers are aways welcomed. - -BIG: - - existing API is (/dev/tarang) should be replaced - Is it possible to use same API as Intel Wimax stack and - have same user level components. - - Qos and queue model is non-standard and inflexible. - Use existing TC Qos? - -TODO: - - support more than one board - eliminate global variables - - remove developer debug BCM_DEBUG() macros - add a limited number of messages through netif_msg() - - fix non-standard kernel style - - checkpatch warnings - - use request firmware - - fix use of file I/O to load config with better API - - merge some files together? - - cleanup/eliminate debug messages - - - diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c deleted file mode 100644 index 622a482e9826..000000000000 --- a/drivers/staging/bcm/Transmit.c +++ /dev/null @@ -1,271 +0,0 @@ -/** - * @file Transmit.c - * @defgroup tx_functions Transmission - * @section Queueing - * @dot - * digraph transmit1 { - * node[shape=box] - * edge[weight=5;color=red] - * - * bcm_transmit->GetPacketQueueIndex[label="IP Packet"] - * GetPacketQueueIndex->IpVersion4[label="IPV4"] - * GetPacketQueueIndex->IpVersion6[label="IPV6"] - * } - * - * @enddot - * - * @section De-Queueing - * @dot - * digraph transmit2 { - * node[shape=box] - * edge[weight=5;color=red] - * interrupt_service_thread->transmit_packets - * tx_pkt_hdler->transmit_packets - * transmit_packets->CheckAndSendPacketFromIndex - * transmit_packets->UpdateTokenCount - * CheckAndSendPacketFromIndex->PruneQueue - * CheckAndSendPacketFromIndex->IsPacketAllowedForFlow - * CheckAndSendPacketFromIndex->SendControlPacket[label="control pkt"] - * SendControlPacket->bcm_cmd53 - * CheckAndSendPacketFromIndex->SendPacketFromQueue[label="data pkt"] - * SendPacketFromQueue->SetupNextSend->bcm_cmd53 - * } - * @enddot - */ - -#include "headers.h" - -/** - * @ingroup ctrl_pkt_functions - * This function dispatches control packet to the h/w interface - * @return zero(success) or -ve value(failure) - */ -int SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket) -{ - struct bcm_leader *PLeader = (struct bcm_leader *)pControlPacket; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx"); - if (!pControlPacket || !Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, - "Got NULL Control Packet or Adapter"); - return STATUS_FAILURE; - } - if ((atomic_read(&Adapter->CurrNumFreeTxDesc) < - ((PLeader->PLength-1)/MAX_DEVICE_DESC_SIZE)+1)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, - "NO FREE DESCRIPTORS TO SEND CONTROL PACKET"); - return STATUS_FAILURE; - } - - /* Update the netdevice statistics */ - /* Dump Packet */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, - "Leader Status: %x", PLeader->Status); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, - "Leader VCID: %x", PLeader->Vcid); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, - "Leader Length: %x", PLeader->PLength); - if (Adapter->device_removed) - return 0; - - if (netif_msg_pktdata(Adapter)) - print_hex_dump(KERN_DEBUG, PFX "tx control: ", DUMP_PREFIX_NONE, - 16, 1, pControlPacket, - PLeader->PLength + LEADER_SIZE, 0); - - Adapter->interface_transmit(Adapter->pvInterfaceAdapter, - pControlPacket, - (PLeader->PLength + LEADER_SIZE)); - - atomic_dec(&Adapter->CurrNumFreeTxDesc); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, - "<========="); - return STATUS_SUCCESS; -} - -/** - * @ingroup tx_functions - * This function despatches the IP packets with the given vcid - * to the target via the host h/w interface. - * @return zero(success) or -ve value(failure) - */ -int SetupNextSend(struct bcm_mini_adapter *Adapter, - struct sk_buff *Packet, USHORT Vcid) -{ - int status = 0; - bool bHeaderSupressionEnabled = false; - B_UINT16 uiClassifierRuleID; - u16 QueueIndex = skb_get_queue_mapping(Packet); - struct bcm_packet_info *curr_packet_info = - &Adapter->PackInfo[QueueIndex]; - struct bcm_leader Leader = {0}; - - if (Packet->len > MAX_DEVICE_DESC_SIZE) { - status = STATUS_FAILURE; - goto errExit; - } - - /* Get the Classifier Rule ID */ - uiClassifierRuleID = *((UINT32 *) (Packet->cb) + - SKB_CB_CLASSIFICATION_OFFSET); - - bHeaderSupressionEnabled = curr_packet_info->bHeaderSuppressionEnabled & - Adapter->bPHSEnabled; - - if (Adapter->device_removed) { - status = STATUS_FAILURE; - goto errExit; - } - - status = PHSTransmit(Adapter, &Packet, Vcid, uiClassifierRuleID, - bHeaderSupressionEnabled, - (UINT *)&Packet->len, - curr_packet_info->bEthCSSupport); - - if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, - "PHS Transmit failed..\n"); - goto errExit; - } - - Leader.Vcid = Vcid; - - if (TCP_ACK == *((UINT32 *) (Packet->cb) + SKB_CB_TCPACK_OFFSET)) - Leader.Status = LEADER_STATUS_TCP_ACK; - else - Leader.Status = LEADER_STATUS; - - if (curr_packet_info->bEthCSSupport) { - Leader.PLength = Packet->len; - if (skb_headroom(Packet) < LEADER_SIZE) { - status = skb_cow(Packet, LEADER_SIZE); - if (status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, - DBG_LVL_ALL, - "bcm_transmit : Failed To Increase headRoom\n"); - goto errExit; - } - } - skb_push(Packet, LEADER_SIZE); - memcpy(Packet->data, &Leader, LEADER_SIZE); - } else { - Leader.PLength = Packet->len - ETH_HLEN; - memcpy((struct bcm_leader *)skb_pull(Packet, - (ETH_HLEN - LEADER_SIZE)), - &Leader, - LEADER_SIZE); - } - - status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter, - Packet->data, - (Leader.PLength + LEADER_SIZE)); - if (status) { - ++Adapter->dev->stats.tx_errors; - if (netif_msg_tx_err(Adapter)) - pr_info(PFX "%s: transmit error %d\n", - Adapter->dev->name, - status); - } else { - struct net_device_stats *netstats = &Adapter->dev->stats; - - curr_packet_info->uiTotalTxBytes += Leader.PLength; - - netstats->tx_bytes += Leader.PLength; - ++netstats->tx_packets; - - curr_packet_info->uiCurrentTokenCount -= Leader.PLength << 3; - curr_packet_info->uiSentBytes += (Packet->len); - curr_packet_info->uiSentPackets++; - curr_packet_info->NumOfPacketsSent++; - - atomic_dec(&curr_packet_info->uiPerSFTxResourceCount); - curr_packet_info->uiThisPeriodSentBytes += Leader.PLength; - } - - atomic_dec(&Adapter->CurrNumFreeTxDesc); - -errExit: - dev_kfree_skb(Packet); - return status; -} - -static int tx_pending(struct bcm_mini_adapter *Adapter) -{ - return (atomic_read(&Adapter->TxPktAvail) - && MINIMUM_PENDING_DESCRIPTORS < - atomic_read(&Adapter->CurrNumFreeTxDesc)) - || Adapter->device_removed || (1 == Adapter->downloadDDR); -} - -/** - * @ingroup tx_functions - * Transmit thread - */ -int tx_pkt_handler(struct bcm_mini_adapter *Adapter) -{ - int status = 0; - - while (!kthread_should_stop()) { - /* FIXME - the timeout looks like workaround - * for racey usage of TxPktAvail - */ - if (Adapter->LinkUpStatus) - wait_event_timeout(Adapter->tx_packet_wait_queue, - tx_pending(Adapter), - msecs_to_jiffies(10)); - else - wait_event_interruptible(Adapter->tx_packet_wait_queue, - tx_pending(Adapter)); - - if (Adapter->device_removed) - break; - - if (Adapter->downloadDDR == 1) { - Adapter->downloadDDR += 1; - status = download_ddr_settings(Adapter); - if (status) - pr_err(PFX "DDR DOWNLOAD FAILED! %d\n", status); - continue; - } - - /* Check end point for halt/stall. */ - if (Adapter->bEndPointHalted == TRUE) { - Bcm_clear_halt_of_endpoints(Adapter); - Adapter->bEndPointHalted = false; - StartInterruptUrb((struct bcm_interface_adapter *) - (Adapter->pvInterfaceAdapter)); - } - - if (Adapter->LinkUpStatus && !Adapter->IdleMode) { - if (atomic_read(&Adapter->TotalPacketCount)) - update_per_sf_desc_cnts(Adapter); - } - - if (atomic_read(&Adapter->CurrNumFreeTxDesc) && - Adapter->LinkStatus == SYNC_UP_REQUEST && - !Adapter->bSyncUpRequestSent) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, - DBG_LVL_ALL, "Calling LinkMessage"); - LinkMessage(Adapter); - } - - if ((Adapter->IdleMode || Adapter->bShutStatus) && - atomic_read(&Adapter->TotalPacketCount)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, - TX_PACKETS, DBG_LVL_ALL, - "Device in Low Power mode...waking up"); - Adapter->usIdleModePattern = ABORT_IDLE_MODE; - Adapter->bWakeUpDevice = TRUE; - wake_up(&Adapter->process_rx_cntrlpkt); - } - - transmit_packets(Adapter); - atomic_set(&Adapter->TxPktAvail, 0); - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, - "Exiting the tx thread..\n"); - Adapter->transmit_packet_thread = NULL; - return 0; -} diff --git a/drivers/staging/bcm/Typedefs.h b/drivers/staging/bcm/Typedefs.h deleted file mode 100644 index 90b3b25dd606..000000000000 --- a/drivers/staging/bcm/Typedefs.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************** -* Typedefs.h -****************************/ -#ifndef __TYPEDEFS_H__ -#define __TYPEDEFS_H__ -#define STATUS_SUCCESS 0 -#define STATUS_FAILURE -1 - - -#define TRUE 1 - - -typedef char CHAR; -typedef int INT; -typedef short SHORT; -typedef long LONG; -typedef void VOID; - -typedef unsigned char UCHAR; -typedef unsigned char B_UINT8; -typedef unsigned short USHORT; -typedef unsigned short B_UINT16; -typedef unsigned int UINT; -typedef unsigned int B_UINT32; -typedef unsigned long ULONG; -typedef unsigned long DWORD; - -typedef char *PCHAR; -typedef short *PSHORT; -typedef int *PINT; -typedef long *PLONG; -typedef void *PVOID; - -typedef unsigned char *PUCHAR; -typedef unsigned short *PUSHORT; -typedef unsigned int *PUINT; -typedef unsigned long *PULONG; -typedef unsigned long long ULONG64; -typedef unsigned long long LARGE_INTEGER; -typedef unsigned int UINT32; -#ifndef NULL -#define NULL 0 -#endif - - -#endif /* __TYPEDEFS_H__ */ - diff --git a/drivers/staging/bcm/cntrl_SignalingInterface.h b/drivers/staging/bcm/cntrl_SignalingInterface.h deleted file mode 100644 index 8683c2d4276e..000000000000 --- a/drivers/staging/bcm/cntrl_SignalingInterface.h +++ /dev/null @@ -1,311 +0,0 @@ -#ifndef CNTRL_SIGNALING_INTERFACE_ -#define CNTRL_SIGNALING_INTERFACE_ - -#define DSA_REQ 11 -#define DSA_RSP 12 -#define DSA_ACK 13 -#define DSC_REQ 14 -#define DSC_RSP 15 -#define DSC_ACK 16 -#define DSD_REQ 17 -#define DSD_RSP 18 -#define DSD_ACK 19 -#define MAX_CLASSIFIERS_IN_SF 4 - -#define MAX_STRING_LEN 20 -#define MAX_PHS_LENGTHS 255 -#define VENDOR_PHS_PARAM_LENGTH 10 -#define MAX_NUM_ACTIVE_BS 10 -#define AUTH_TOKEN_LENGTH 10 -#define NUM_HARQ_CHANNELS 16 /* Changed from 10 to 16 to accommodate all HARQ channels */ -#define VENDOR_CLASSIFIER_PARAM_LENGTH 1 /* Changed the size to 1 byte since we dnt use it */ -#define VENDOR_SPECIF_QOS_PARAM 1 -#define VENDOR_PHS_PARAM_LENGTH 10 -#define MBS_CONTENTS_ID_LENGTH 10 -#define GLOBAL_SF_CLASSNAME_LENGTH 6 - -#define TYPE_OF_SERVICE_LENGTH 3 -#define IP_MASKED_SRC_ADDRESS_LENGTH 32 -#define IP_MASKED_DEST_ADDRESS_LENGTH 32 -#define PROTOCOL_SRC_PORT_RANGE_LENGTH 4 -#define PROTOCOL_DEST_PORT_RANGE_LENGTH 4 -#define ETHERNET_DEST_MAC_ADDR_LENGTH 12 -#define ETHERNET_SRC_MAC_ADDR_LENGTH 12 -#define NUM_ETHERTYPE_BYTES 3 -#define NUM_IPV6_FLOWLABLE_BYTES 3 - -struct bcm_packet_class_rules { - /* 16bit UserPriority Of The Service Flow */ - u16 u16UserPriority; - /* 16bit VLANID Of The Service Flow */ - u16 u16VLANID; - /* 16bit Packet Classification RuleIndex Of The Service Flow */ - u16 u16PacketClassificationRuleIndex; - /* 8bit Classifier Rule Priority Of The Service Flow */ - u8 u8ClassifierRulePriority; - /* Length of IP TypeOfService field */ - u8 u8IPTypeOfServiceLength; - /* 3bytes IP TypeOfService */ - u8 u8IPTypeOfService[TYPE_OF_SERVICE_LENGTH]; - /* Protocol used in classification of Service Flow */ - u8 u8Protocol; - /* Length of IP Masked Source Address */ - u8 u8IPMaskedSourceAddressLength; - /* IP Masked Source Address used in classification for the Service Flow */ - u8 u8IPMaskedSourceAddress[IP_MASKED_SRC_ADDRESS_LENGTH]; - /* Length of IP Destination Address */ - u8 u8IPDestinationAddressLength; - /* IP Destination Address used in classification for the Service Flow */ - u8 u8IPDestinationAddress[IP_MASKED_DEST_ADDRESS_LENGTH]; - /* Length of Protocol Source Port Range */ - u8 u8ProtocolSourcePortRangeLength; - /* Protocol Source Port Range used in the Service Flow */ - u8 u8ProtocolSourcePortRange[PROTOCOL_SRC_PORT_RANGE_LENGTH]; - /* Length of Protocol Dest Port Range */ - u8 u8ProtocolDestPortRangeLength; - /* Protocol Dest Port Range used in the Service Flow */ - u8 u8ProtocolDestPortRange[PROTOCOL_DEST_PORT_RANGE_LENGTH]; - /* Length of Ethernet Destination MAC Address */ - u8 u8EthernetDestMacAddressLength; - /* Ethernet Destination MAC Address used in classification of the Service Flow */ - u8 u8EthernetDestMacAddress[ETHERNET_DEST_MAC_ADDR_LENGTH]; - /* Length of Ethernet Source MAC Address */ - u8 u8EthernetSourceMACAddressLength; - /* Ethernet Source MAC Address used in classification of the Service Flow */ - u8 u8EthernetSourceMACAddress[ETHERNET_SRC_MAC_ADDR_LENGTH]; - /* Length of Ethertype */ - u8 u8EthertypeLength; - /* 3bytes Ethertype Of The Service Flow */ - u8 u8Ethertype[NUM_ETHERTYPE_BYTES]; - /* 8bit Associated PHSI Of The Service Flow */ - u8 u8AssociatedPHSI; - /* Length of Vendor Specific Classifier Param length Of The Service Flow */ - u8 u8VendorSpecificClassifierParamLength; - /* Vendor Specific Classifier Param Of The Service Flow */ - u8 u8VendorSpecificClassifierParam[VENDOR_CLASSIFIER_PARAM_LENGTH]; - /* Length Of IPv6 Flow Lable of the Service Flow */ - u8 u8IPv6FlowLableLength; - /* IPv6 Flow Lable Of The Service Flow */ - u8 u8IPv6FlowLable[NUM_IPV6_FLOWLABLE_BYTES]; - /* Action associated with the classifier rule */ - u8 u8ClassifierActionRule; - u16 u16ValidityBitMap; -}; - -struct bcm_phs_rules { - /* 8bit PHS Index Of The Service Flow */ - u8 u8PHSI; - /* PHSF Length Of The Service Flow */ - u8 u8PHSFLength; - /* String of bytes containing header information to be suppressed by the sending CS and reconstructed by the receiving CS */ - u8 u8PHSF[MAX_PHS_LENGTHS]; - /* PHSM Length Of The Service Flow */ - u8 u8PHSMLength; - /* PHS Mask for the SF */ - u8 u8PHSM[MAX_PHS_LENGTHS]; - /* 8bit Total number of bytes to be suppressed for the Service Flow */ - u8 u8PHSS; - /* 8bit Indicates whether or not Packet Header contents need to be verified prior to suppression */ - u8 u8PHSV; - /* Vendor Specific PHS param Length Of The Service Flow */ - u8 u8VendorSpecificPHSParamsLength; - /* Vendor Specific PHS param Of The Service Flow */ - u8 u8VendorSpecificPHSParams[VENDOR_PHS_PARAM_LENGTH]; - u8 u8Padding[2]; -}; - -struct bcm_convergence_types { - /* 8bit Phs Classfier Action Of The Service Flow */ - u8 u8ClassfierDSCAction; - /* 8bit Phs DSC Action Of The Service Flow */ - u8 u8PhsDSCAction; - /* 16bit Padding */ - u8 u8Padding[2]; - /* Packet classification rules structure */ - struct bcm_packet_class_rules cCPacketClassificationRule; - /* Payload header suppression rules structure */ - struct bcm_phs_rules cPhsRule; -}; - -struct bcm_connect_mgr_params { - /* 32bitSFID Of The Service Flow */ - u32 u32SFID; - /* 32bit Maximum Sustained Traffic Rate of the Service Flow */ - u32 u32MaxSustainedTrafficRate; - /* 32bit Maximum Traffic Burst allowed for the Service Flow */ - u32 u32MaxTrafficBurst; - /* 32bit Minimum Reserved Traffic Rate of the Service Flow */ - u32 u32MinReservedTrafficRate; - /* 32bit Tolerated Jitter of the Service Flow */ - u32 u32ToleratedJitter; - /* 32bit Maximum Latency of the Service Flow */ - u32 u32MaximumLatency; - /* 16bitCID Of The Service Flow */ - u16 u16CID; - /* 16bit SAID on which the service flow being set up shall be mapped */ - u16 u16TargetSAID; - /* 16bit ARQ window size negotiated */ - u16 u16ARQWindowSize; - /* 16bit Total Tx delay incl sending, receiving & processing delays */ - u16 u16ARQRetryTxTimeOut; - /* 16bit Total Rx delay incl sending, receiving & processing delays */ - u16 u16ARQRetryRxTimeOut; - /* 16bit ARQ block lifetime */ - u16 u16ARQBlockLifeTime; - /* 16bit ARQ Sync loss timeout */ - u16 u16ARQSyncLossTimeOut; - /* 16bit ARQ Purge timeout */ - u16 u16ARQRxPurgeTimeOut; - /* TODO::Remove this once we move to a new CORR2 driver - * brief Size of an ARQ block - */ - u16 u16ARQBlockSize; - /* #endif */ - /* 16bit Nominal interval b/w consecutive SDU arrivals at MAC SAP */ - u16 u16SDUInterArrivalTime; - /* 16bit Specifies the time base for rate measurement */ - u16 u16TimeBase; - /* 16bit Interval b/w Successive Grant oppurtunities */ - u16 u16UnsolicitedGrantInterval; - /* 16bit Interval b/w Successive Polling grant oppurtunities */ - u16 u16UnsolicitedPollingInterval; - /* internal var to get the overhead */ - u16 u16MacOverhead; - /* MBS contents Identifier */ - u16 u16MBSContentsID[MBS_CONTENTS_ID_LENGTH]; - /* MBS contents Identifier length */ - u8 u8MBSContentsIDLength; - /* ServiceClassName Length Of The Service Flow */ - u8 u8ServiceClassNameLength; - /* 32bytes ServiceClassName Of The Service Flow */ - u8 u8ServiceClassName[32]; - /* 8bit Indicates whether or not MBS service is requested for this Serivce Flow */ - u8 u8MBSService; - /* 8bit QOS Parameter Set specifies proper application of QoS parameters to Provisioned, Admitted and Active sets */ - u8 u8QosParamSet; - /* 8bit Traffic Priority Of the Service Flow */ - u8 u8TrafficPriority; - /* 8bit Uplink Grant Scheduling Type of The Service Flow */ - u8 u8ServiceFlowSchedulingType; - /* 8bit Request transmission Policy of the Service Flow */ - u8 u8RequesttransmissionPolicy; - /* 8bit Specifies whether SDUs for this Service flow are of FixedLength or Variable length */ - u8 u8FixedLengthVSVariableLengthSDUIndicator; - /* 8bit Length of the SDU for a fixed length SDU service flow */ - u8 u8SDUSize; - /* 8bit Indicates whether or not ARQ is requested for this connection */ - u8 u8ARQEnable; - /* < 8bit Indicates whether or not data has tobe delivered in order to higher layer */ - u8 u8ARQDeliverInOrder; - /* 8bit Receiver ARQ ACK processing time */ - u8 u8RxARQAckProcessingTime; - /* 8bit Convergence Sublayer Specification Of The Service Flow */ - u8 u8CSSpecification; - /* 8 bit Type of data delivery service */ - u8 u8TypeOfDataDeliveryService; - /* 8bit Specifies whether a service flow may generate Paging */ - u8 u8PagingPreference; - /* 8bit Indicates the MBS Zone through which the connection or virtual connection is valid */ - u8 u8MBSZoneIdentifierassignment; - /* 8bit Specifies whether traffic on SF should generate MOB_TRF_IND to MS in sleep mode */ - u8 u8TrafficIndicationPreference; - /* 8bit Speciifes the length of predefined Global QoS parameter set encoding for this SF */ - u8 u8GlobalServicesClassNameLength; - /* 6 byte Speciifes the predefined Global QoS parameter set encoding for this SF */ - u8 u8GlobalServicesClassName[GLOBAL_SF_CLASSNAME_LENGTH]; - /* 8bit Indicates whether or not SN feedback is enabled for the conn */ - u8 u8SNFeedbackEnabled; - /* Indicates the size of the Fragment Sequence Number for the connection */ - u8 u8FSNSize; - /* 8bit Number of CIDs in active BS list */ - u8 u8CIDAllocation4activeBSsLength; - /* CIDs of BS in the active list */ - u8 u8CIDAllocation4activeBSs[MAX_NUM_ACTIVE_BS]; - /* Specifies if PDU extended subheader should be applied on every PDU on this conn */ - u8 u8PDUSNExtendedSubheader4HarqReordering; - /* 8bit Specifies whether the connection uses HARQ or not */ - u8 u8HARQServiceFlows; - /* Specifies the length of Authorization token */ - u8 u8AuthTokenLength; - /* Specifies the Authorization token */ - u8 u8AuthToken[AUTH_TOKEN_LENGTH]; - /* specifes Number of HARQ channels used to carry data length */ - u8 u8HarqChannelMappingLength; - /* specifes HARQ channels used to carry data */ - u8 u8HARQChannelMapping[NUM_HARQ_CHANNELS]; - /* 8bit Length of Vendor Specific QoS Params */ - u8 u8VendorSpecificQoSParamLength; - /* 1byte Vendor Specific QoS Param Of The Service Flow */ - u8 u8VendorSpecificQoSParam[VENDOR_SPECIF_QOS_PARAM]; - /* indicates total classifiers in the SF */ - u8 u8TotalClassifiers; /* < Total number of valid classifiers */ - u8 bValid; /* < Validity flag */ - u8 u8Padding; /* < Padding byte */ - /* - * Structure for Convergence SubLayer Types with a maximum of 4 classifiers - */ - struct bcm_convergence_types cConvergenceSLTypes[MAX_CLASSIFIERS_IN_SF]; -}; - -struct bcm_add_request { - u8 u8Type; /* < Type */ - u8 eConnectionDir; /* < Connection direction */ - /* brief 16 bit TID */ - u16 u16TID; /* < 16bit TID */ - /* brief 16bitCID */ - u16 u16CID; /* < 16bit CID */ - /* brief 16bitVCID */ - u16 u16VCID; /* < 16bit VCID */ - struct bcm_connect_mgr_params *psfParameterSet; /* < connection manager parameters */ -}; - -struct bcm_add_indication { - u8 u8Type; /* < Type */ - u8 eConnectionDir; /* < Connection Direction */ - /* brief 16 bit TID */ - u16 u16TID; /* < TID */ - /* brief 16bitCID */ - u16 u16CID; /* < 16bitCID */ - /* brief 16bitVCID */ - u16 u16VCID; /* < 16bitVCID */ - struct bcm_connect_mgr_params *psfAuthorizedSet; /* Authorized set of connection manager parameters */ - struct bcm_connect_mgr_params *psfAdmittedSet; /* Admitted set of connection manager parameters */ - struct bcm_connect_mgr_params *psfActiveSet; /* Activeset of connection manager parameters */ - u8 u8CC; /* -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Typedefs.h" -#include "Macros.h" -#include "HostMIBSInterface.h" -#include "cntrl_SignalingInterface.h" -#include "PHSDefines.h" -#include "led_control.h" -#include "Ioctl.h" -#include "nvm.h" -#include "target_params.h" -#include "Adapter.h" -#include "CmHost.h" -#include "DDRInit.h" -#include "Debug.h" -#include "IPv6ProtocolHdr.h" -#include "PHSModule.h" -#include "Protocol.h" -#include "Prototypes.h" -#include "Queue.h" -#include "vendorspecificextn.h" - -#include "InterfaceMacros.h" -#include "InterfaceAdapter.h" -#include "InterfaceIsr.h" -#include "InterfaceMisc.h" -#include "InterfaceRx.h" -#include "InterfaceTx.h" -#include "InterfaceIdleMode.h" -#include "InterfaceInit.h" - -#define DRV_NAME "beceem" -#define DEV_NAME "tarang" -#define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver" -#define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc" -#define DRV_VERSION "5.2.45" -#define PFX DRV_NAME " " - -extern struct class *bcm_class; - -#endif diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c deleted file mode 100644 index f9b08a5d8ce8..000000000000 --- a/drivers/staging/bcm/hostmibs.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * File Name: hostmibs.c - * - * Author: Beceem Communications Pvt. Ltd - * - * Abstract: This file contains the routines to copy the statistics used by - * the driver to the Host MIBS structure and giving the same to Application. - */ - -#include "headers.h" - -INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, - struct bcm_host_stats_mibs *pstHostMibs) -{ - struct bcm_phs_entry *pstServiceFlowEntry = NULL; - struct bcm_phs_rule *pstPhsRule = NULL; - struct bcm_phs_classifier_table *pstClassifierTable = NULL; - struct bcm_phs_classifier_entry *pstClassifierRule = NULL; - struct bcm_phs_extension *pDeviceExtension = &Adapter->stBCMPhsContext; - struct bcm_mibs_host_info *host_info; - UINT nClassifierIndex = 0; - UINT nPhsTableIndex = 0; - UINT nSfIndex = 0; - UINT uiIndex = 0; - - if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, - DBG_LVL_ALL, "Invalid Device Extension\n"); - return STATUS_FAILURE; - } - - /* Copy the classifier Table */ - for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; - nClassifierIndex++) { - if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE) - memcpy(&pstHostMibs->astClassifierTable[nClassifierIndex], - &Adapter->astClassifierTable[nClassifierIndex], - sizeof(struct bcm_mibs_classifier_rule)); - } - - /* Copy the SF Table */ - for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) { - if (Adapter->PackInfo[nSfIndex].bValid) { - memcpy(&pstHostMibs->astSFtable[nSfIndex], - &Adapter->PackInfo[nSfIndex], - sizeof(struct bcm_mibs_table)); - } else { - /* If index in not valid, - * don't process this for the PHS table. - * Go For the next entry. - */ - continue; - } - - /* Retrieve the SFID Entry Index for requested Service Flow */ - if (PHS_INVALID_TABLE_INDEX == - GetServiceFlowEntry(pDeviceExtension-> - pstServiceFlowPhsRulesTable, - Adapter->PackInfo[nSfIndex]. - usVCID_Value, &pstServiceFlowEntry)) - - continue; - - pstClassifierTable = pstServiceFlowEntry->pstClassifierTable; - - for (uiIndex = 0; uiIndex < MAX_PHSRULE_PER_SF; uiIndex++) { - pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[uiIndex]; - - if (pstClassifierRule->bUsed) { - pstPhsRule = pstClassifierRule->pstPhsRule; - - pstHostMibs->astPhsRulesTable[nPhsTableIndex]. - ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; - - memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, - &pstPhsRule->u8PHSI, - sizeof(struct bcm_phs_rule)); - nPhsTableIndex++; - - } - - } - - } - - /* Copy other Host Statistics parameters */ - host_info = &pstHostMibs->stHostInfo; - host_info->GoodTransmits = Adapter->dev->stats.tx_packets; - host_info->GoodReceives = Adapter->dev->stats.rx_packets; - host_info->CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc); - host_info->BEBucketSize = Adapter->BEBucketSize; - host_info->rtPSBucketSize = Adapter->rtPSBucketSize; - host_info->TimerActive = Adapter->TimerActive; - host_info->u32TotalDSD = Adapter->u32TotalDSD; - - memcpy(host_info->aTxPktSizeHist, Adapter->aTxPktSizeHist, - sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); - memcpy(host_info->aRxPktSizeHist, Adapter->aRxPktSizeHist, - sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); - - return STATUS_SUCCESS; -} - -VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, - struct bcm_tarang_data *pTarang) -{ - memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs), - &(pTarang->stDroppedAppCntrlMsgs), - sizeof(struct bcm_mibs_dropped_cntrl_msg)); -} - -VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, - struct bcm_connect_mgr_params *psfLocalSet, - UINT uiSearchRuleIndex) -{ - struct bcm_mibs_parameters *t = - &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; - - t->wmanIfSfid = psfLocalSet->u32SFID; - t->wmanIfCmnCpsMaxSustainedRate = - psfLocalSet->u32MaxSustainedTrafficRate; - t->wmanIfCmnCpsMaxTrafficBurst = psfLocalSet->u32MaxTrafficBurst; - t->wmanIfCmnCpsMinReservedRate = psfLocalSet->u32MinReservedTrafficRate; - t->wmanIfCmnCpsToleratedJitter = psfLocalSet->u32ToleratedJitter; - t->wmanIfCmnCpsMaxLatency = psfLocalSet->u32MaximumLatency; - t->wmanIfCmnCpsFixedVsVariableSduInd = - psfLocalSet->u8FixedLengthVSVariableLengthSDUIndicator; - t->wmanIfCmnCpsFixedVsVariableSduInd = - ntohl(t->wmanIfCmnCpsFixedVsVariableSduInd); - t->wmanIfCmnCpsSduSize = psfLocalSet->u8SDUSize; - t->wmanIfCmnCpsSduSize = ntohl(t->wmanIfCmnCpsSduSize); - t->wmanIfCmnCpsSfSchedulingType = - psfLocalSet->u8ServiceFlowSchedulingType; - t->wmanIfCmnCpsSfSchedulingType = - ntohl(t->wmanIfCmnCpsSfSchedulingType); - t->wmanIfCmnCpsArqEnable = psfLocalSet->u8ARQEnable; - t->wmanIfCmnCpsArqEnable = ntohl(t->wmanIfCmnCpsArqEnable); - t->wmanIfCmnCpsArqWindowSize = ntohs(psfLocalSet->u16ARQWindowSize); - t->wmanIfCmnCpsArqWindowSize = ntohl(t->wmanIfCmnCpsArqWindowSize); - t->wmanIfCmnCpsArqBlockLifetime = - ntohs(psfLocalSet->u16ARQBlockLifeTime); - t->wmanIfCmnCpsArqBlockLifetime = - ntohl(t->wmanIfCmnCpsArqBlockLifetime); - t->wmanIfCmnCpsArqSyncLossTimeout = - ntohs(psfLocalSet->u16ARQSyncLossTimeOut); - t->wmanIfCmnCpsArqSyncLossTimeout = - ntohl(t->wmanIfCmnCpsArqSyncLossTimeout); - t->wmanIfCmnCpsArqDeliverInOrder = psfLocalSet->u8ARQDeliverInOrder; - t->wmanIfCmnCpsArqDeliverInOrder = - ntohl(t->wmanIfCmnCpsArqDeliverInOrder); - t->wmanIfCmnCpsArqRxPurgeTimeout = - ntohs(psfLocalSet->u16ARQRxPurgeTimeOut); - t->wmanIfCmnCpsArqRxPurgeTimeout = - ntohl(t->wmanIfCmnCpsArqRxPurgeTimeout); - t->wmanIfCmnCpsArqBlockSize = ntohs(psfLocalSet->u16ARQBlockSize); - t->wmanIfCmnCpsArqBlockSize = ntohl(t->wmanIfCmnCpsArqBlockSize); - t->wmanIfCmnCpsReqTxPolicy = psfLocalSet->u8RequesttransmissionPolicy; - t->wmanIfCmnCpsReqTxPolicy = ntohl(t->wmanIfCmnCpsReqTxPolicy); - t->wmanIfCmnSfCsSpecification = psfLocalSet->u8CSSpecification; - t->wmanIfCmnSfCsSpecification = ntohl(t->wmanIfCmnSfCsSpecification); - t->wmanIfCmnCpsTargetSaid = ntohs(psfLocalSet->u16TargetSAID); - t->wmanIfCmnCpsTargetSaid = ntohl(t->wmanIfCmnCpsTargetSaid); - -} diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c deleted file mode 100644 index 181f17ff0a24..000000000000 --- a/drivers/staging/bcm/led_control.c +++ /dev/null @@ -1,951 +0,0 @@ -#include "headers.h" - -#define STATUS_IMAGE_CHECKSUM_MISMATCH -199 -#define EVENT_SIGNALED 1 - -static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size) -{ - B_UINT16 u16CheckSum = 0; - - while (u32Size--) { - u16CheckSum += (B_UINT8)~(*pu8Buffer); - pu8Buffer++; - } - return u16CheckSum; -} - -bool IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios) -{ - INT Status; - - Status = (Adapter->gpioBitMap & gpios) ^ gpios; - if (Status) - return false; - else - return TRUE; -} - -static INT LED_Blink(struct bcm_mini_adapter *Adapter, - UINT GPIO_Num, - UCHAR uiLedIndex, - ULONG timeout, - INT num_of_time, - enum bcm_led_events currdriverstate) -{ - int Status = STATUS_SUCCESS; - bool bInfinite = false; - - /* Check if num_of_time is -ve. If yes, blink led in infinite loop */ - if (num_of_time < 0) { - bInfinite = TRUE; - num_of_time = 1; - } - while (num_of_time) { - if (currdriverstate == Adapter->DriverState) - TURN_ON_LED(Adapter, GPIO_Num, uiLedIndex); - - /* Wait for timeout after setting on the LED */ - Status = wait_event_interruptible_timeout( - Adapter->LEDInfo.notify_led_event, - currdriverstate != Adapter->DriverState || - kthread_should_stop(), - msecs_to_jiffies(timeout)); - - if (kthread_should_stop()) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "Led thread got signal to exit..hence exiting"); - Adapter->LEDInfo.led_thread_running = - BCM_LED_THREAD_DISABLED; - TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex); - Status = EVENT_SIGNALED; - break; - } - if (Status) { - TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex); - Status = EVENT_SIGNALED; - break; - } - - TURN_OFF_LED(Adapter, GPIO_Num, uiLedIndex); - Status = wait_event_interruptible_timeout( - Adapter->LEDInfo.notify_led_event, - currdriverstate != Adapter->DriverState || - kthread_should_stop(), - msecs_to_jiffies(timeout)); - if (bInfinite == false) - num_of_time--; - } - return Status; -} - -static INT ScaleRateofTransfer(ULONG rate) -{ - if (rate <= 3) - return rate; - else if ((rate > 3) && (rate <= 100)) - return 5; - else if ((rate > 100) && (rate <= 200)) - return 6; - else if ((rate > 200) && (rate <= 300)) - return 7; - else if ((rate > 300) && (rate <= 400)) - return 8; - else if ((rate > 400) && (rate <= 500)) - return 9; - else if ((rate > 500) && (rate <= 600)) - return 10; - return MAX_NUM_OF_BLINKS; -} - -static INT blink_in_normal_bandwidth(struct bcm_mini_adapter *ad, - INT *time, - INT *time_tx, - INT *time_rx, - UCHAR GPIO_Num_tx, - UCHAR uiTxLedIndex, - UCHAR GPIO_Num_rx, - UCHAR uiRxLedIndex, - enum bcm_led_events currdriverstate, - ulong *timeout) -{ - /* - * Assign minimum number of blinks of - * either Tx or Rx. - */ - *time = (*time_tx > *time_rx ? *time_rx : *time_tx); - - if (*time > 0) { - /* Blink both Tx and Rx LEDs */ - if ((LED_Blink(ad, 1 << GPIO_Num_tx, uiTxLedIndex, *timeout, - *time, currdriverstate) == EVENT_SIGNALED) || - (LED_Blink(ad, 1 << GPIO_Num_rx, uiRxLedIndex, *timeout, - *time, currdriverstate) == EVENT_SIGNALED)) - return EVENT_SIGNALED; - } - - if (*time == *time_tx) { - /* Blink pending rate of Rx */ - if (LED_Blink(ad, (1 << GPIO_Num_rx), uiRxLedIndex, *timeout, - *time_rx - *time, - currdriverstate) == EVENT_SIGNALED) - return EVENT_SIGNALED; - - *time = *time_rx; - } else { - /* Blink pending rate of Tx */ - if (LED_Blink(ad, 1 << GPIO_Num_tx, uiTxLedIndex, *timeout, - *time_tx - *time, - currdriverstate) == EVENT_SIGNALED) - return EVENT_SIGNALED; - - *time = *time_tx; - } - - return 0; -} - -static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, - UCHAR GPIO_Num_tx, - UCHAR uiTxLedIndex, - UCHAR GPIO_Num_rx, - UCHAR uiRxLedIndex, - enum bcm_led_events currdriverstate) -{ - /* Initial values of TX and RX packets */ - ULONG64 Initial_num_of_packts_tx = 0, Initial_num_of_packts_rx = 0; - /* values of TX and RX packets after 1 sec */ - ULONG64 Final_num_of_packts_tx = 0, Final_num_of_packts_rx = 0; - /* Rate of transfer of Tx and Rx in 1 sec */ - ULONG64 rate_of_transfer_tx = 0, rate_of_transfer_rx = 0; - int Status = STATUS_SUCCESS; - INT num_of_time = 0, num_of_time_tx = 0, num_of_time_rx = 0; - UINT remDelay = 0; - /* UINT GPIO_num = DISABLE_GPIO_NUM; */ - ulong timeout = 0; - - /* Read initial value of packets sent/received */ - Initial_num_of_packts_tx = Adapter->dev->stats.tx_packets; - Initial_num_of_packts_rx = Adapter->dev->stats.rx_packets; - - /* Scale the rate of transfer to no of blinks. */ - num_of_time_tx = ScaleRateofTransfer((ULONG)rate_of_transfer_tx); - num_of_time_rx = ScaleRateofTransfer((ULONG)rate_of_transfer_rx); - - while ((Adapter->device_removed == false)) { - timeout = 50; - - if (EVENT_SIGNALED == blink_in_normal_bandwidth(Adapter, - &num_of_time, - &num_of_time_tx, - &num_of_time_rx, - GPIO_Num_tx, - uiTxLedIndex, - GPIO_Num_rx, - uiRxLedIndex, - currdriverstate, - &timeout)) - return EVENT_SIGNALED; - - - /* - * If Tx/Rx rate is less than maximum blinks per second, - * wait till delay completes to 1 second - */ - remDelay = MAX_NUM_OF_BLINKS - num_of_time; - if (remDelay > 0) { - timeout = 100 * remDelay; - Status = wait_event_interruptible_timeout( - Adapter->LEDInfo.notify_led_event, - currdriverstate != Adapter->DriverState - || kthread_should_stop(), - msecs_to_jiffies(timeout)); - - if (kthread_should_stop()) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - LED_DUMP_INFO, DBG_LVL_ALL, - "Led thread got signal to exit..hence exiting"); - Adapter->LEDInfo.led_thread_running = - BCM_LED_THREAD_DISABLED; - return EVENT_SIGNALED; - } - if (Status) - return EVENT_SIGNALED; - } - - /* Turn off both Tx and Rx LEDs before next second */ - TURN_OFF_LED(Adapter, 1 << GPIO_Num_tx, uiTxLedIndex); - TURN_OFF_LED(Adapter, 1 << GPIO_Num_rx, uiTxLedIndex); - - /* - * Read the Tx & Rx packets transmission after 1 second and - * calculate rate of transfer - */ - Final_num_of_packts_tx = Adapter->dev->stats.tx_packets; - Final_num_of_packts_rx = Adapter->dev->stats.rx_packets; - - rate_of_transfer_tx = Final_num_of_packts_tx - - Initial_num_of_packts_tx; - rate_of_transfer_rx = Final_num_of_packts_rx - - Initial_num_of_packts_rx; - - /* Read initial value of packets sent/received */ - Initial_num_of_packts_tx = Final_num_of_packts_tx; - Initial_num_of_packts_rx = Final_num_of_packts_rx; - - /* Scale the rate of transfer to no of blinks. */ - num_of_time_tx = - ScaleRateofTransfer((ULONG)rate_of_transfer_tx); - num_of_time_rx = - ScaleRateofTransfer((ULONG)rate_of_transfer_rx); - - } - return Status; -} - -/* - * ----------------------------------------------------------------------------- - * Procedure: ValidateDSDParamsChecksum - * - * Description: Reads DSD Params and validates checkusm. - * - * Arguments: - * Adapter - Pointer to Adapter structure. - * ulParamOffset - Start offset of the DSD parameter to be read and - * validated. - * usParamLen - Length of the DSD Parameter. - * - * Returns: - * - * ----------------------------------------------------------------------------- - */ -static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, - ULONG ulParamOffset, - USHORT usParamLen) -{ - INT Status = STATUS_SUCCESS; - PUCHAR puBuffer = NULL; - USHORT usChksmOrg = 0; - USHORT usChecksumCalculated = 0; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "LED Thread:ValidateDSDParamsChecksum: 0x%lx 0x%X", - ulParamOffset, usParamLen); - - puBuffer = kmalloc(usParamLen, GFP_KERNEL); - if (!puBuffer) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "LED Thread: ValidateDSDParamsChecksum Allocation failed"); - return -ENOMEM; - - } - - /* Read the DSD data from the parameter offset. */ - if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)puBuffer, - ulParamOffset, usParamLen)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed"); - Status = STATUS_IMAGE_CHECKSUM_MISMATCH; - goto exit; - } - - /* Calculate the checksum of the data read from the DSD parameter. */ - usChecksumCalculated = CFG_CalculateChecksum(puBuffer, usParamLen); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "LED Thread: usCheckSumCalculated = 0x%x\n", - usChecksumCalculated); - - /* - * End of the DSD parameter will have a TWO bytes checksum stored in it. - * Read it and compare with the calculated Checksum. - */ - if (STATUS_SUCCESS != BeceemNVMRead(Adapter, (PUINT)&usChksmOrg, - ulParamOffset+usParamLen, 2)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "LED Thread: ValidateDSDParamsChecksum BeceemNVMRead failed"); - Status = STATUS_IMAGE_CHECKSUM_MISMATCH; - goto exit; - } - usChksmOrg = ntohs(usChksmOrg); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "LED Thread: usChksmOrg = 0x%x", usChksmOrg); - - /* - * Compare the checksum calculated with the checksum read - * from DSD section - */ - if (usChecksumCalculated ^ usChksmOrg) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "LED Thread: ValidateDSDParamsChecksum: Checksums don't match"); - Status = STATUS_IMAGE_CHECKSUM_MISMATCH; - goto exit; - } - -exit: - kfree(puBuffer); - return Status; -} - - -/* - * ----------------------------------------------------------------------------- - * Procedure: ValidateHWParmStructure - * - * Description: Validates HW Parameters. - * - * Arguments: - * Adapter - Pointer to Adapter structure. - * ulHwParamOffset - Start offset of the HW parameter Section to be read - * and validated. - * - * Returns: - * - * ----------------------------------------------------------------------------- - */ -static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter, - ULONG ulHwParamOffset) -{ - - INT Status = STATUS_SUCCESS; - USHORT HwParamLen = 0; - /* - * Add DSD start offset to the hwParamOffset to get - * the actual address. - */ - ulHwParamOffset += DSD_START_OFFSET; - - /* Read the Length of HW_PARAM structure */ - BeceemNVMRead(Adapter, (PUINT)&HwParamLen, ulHwParamOffset, 2); - HwParamLen = ntohs(HwParamLen); - if (0 == HwParamLen || HwParamLen > Adapter->uiNVMDSDSize) - return STATUS_IMAGE_CHECKSUM_MISMATCH; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "LED Thread:HwParamLen = 0x%x", HwParamLen); - Status = ValidateDSDParamsChecksum(Adapter, ulHwParamOffset, - HwParamLen); - return Status; -} /* ValidateHWParmStructure() */ - -static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter, - UCHAR GPIO_Array[]) -{ - int Status = STATUS_SUCCESS; - - ULONG dwReadValue = 0; - USHORT usHwParamData = 0; - USHORT usEEPROMVersion = 0; - UCHAR ucIndex = 0; - UCHAR ucGPIOInfo[32] = {0}; - - BeceemNVMRead(Adapter, (PUINT)&usEEPROMVersion, - EEPROM_VERSION_OFFSET, 2); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "usEEPROMVersion: Minor:0x%X Major:0x%x", - usEEPROMVersion & 0xFF, - ((usEEPROMVersion >> 8) & 0xFF)); - - - if (((usEEPROMVersion>>8)&0xFF) < EEPROM_MAP5_MAJORVERSION) { - BeceemNVMRead(Adapter, (PUINT)&usHwParamData, - EEPROM_HW_PARAM_POINTER_ADDRESS, 2); - usHwParamData = ntohs(usHwParamData); - dwReadValue = usHwParamData; - } else { - /* - * Validate Compatibility section and then read HW param - * if compatibility section is valid. - */ - Status = ValidateDSDParamsChecksum(Adapter, - DSD_START_OFFSET, - COMPATIBILITY_SECTION_LENGTH_MAP5); - - if (Status != STATUS_SUCCESS) - return Status; - - BeceemNVMRead(Adapter, (PUINT)&dwReadValue, - EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5, 4); - dwReadValue = ntohl(dwReadValue); - } - - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "LED Thread: Start address of HW_PARAM structure = 0x%lx", - dwReadValue); - - /* - * Validate if the address read out is within the DSD. - * Adapter->uiNVMDSDSize gives whole DSD size inclusive of Autoinit. - * lower limit should be above DSD_START_OFFSET and - * upper limit should be below (Adapter->uiNVMDSDSize-DSD_START_OFFSET) - */ - if (dwReadValue < DSD_START_OFFSET || - dwReadValue > (Adapter->uiNVMDSDSize-DSD_START_OFFSET)) - return STATUS_IMAGE_CHECKSUM_MISMATCH; - - Status = ValidateHWParmStructure(Adapter, dwReadValue); - if (Status) - return Status; - - /* - * Add DSD_START_OFFSET to the offset read from the EEPROM. - * This will give the actual start HW Parameters start address. - * To read GPIO section, add GPIO offset further. - */ - - dwReadValue += DSD_START_OFFSET; - /* = start address of hw param section. */ - dwReadValue += GPIO_SECTION_START_OFFSET; - /* = GPIO start offset within HW Param section. */ - - /* - * Read the GPIO values for 32 GPIOs from EEPROM and map the function - * number to GPIO pin number to GPIO_Array - */ - BeceemNVMRead(Adapter, (UINT *)ucGPIOInfo, dwReadValue, 32); - for (ucIndex = 0; ucIndex < 32; ucIndex++) { - - switch (ucGPIOInfo[ucIndex]) { - case RED_LED: - GPIO_Array[RED_LED] = ucIndex; - Adapter->gpioBitMap |= (1 << ucIndex); - break; - case BLUE_LED: - GPIO_Array[BLUE_LED] = ucIndex; - Adapter->gpioBitMap |= (1 << ucIndex); - break; - case YELLOW_LED: - GPIO_Array[YELLOW_LED] = ucIndex; - Adapter->gpioBitMap |= (1 << ucIndex); - break; - case GREEN_LED: - GPIO_Array[GREEN_LED] = ucIndex; - Adapter->gpioBitMap |= (1 << ucIndex); - break; - default: - break; - } - - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "GPIO's bit map correspond to LED :0x%X", - Adapter->gpioBitMap); - return Status; -} - - -static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter, - bool *bEnableThread) -{ - int Status = STATUS_SUCCESS; - /* Array to store GPIO numbers from EEPROM */ - UCHAR GPIO_Array[NUM_OF_LEDS+1]; - UINT uiIndex = 0; - UINT uiNum_of_LED_Type = 0; - PUCHAR puCFGData = NULL; - UCHAR bData = 0; - struct bcm_led_state_info *curr_led_state; - - memset(GPIO_Array, DISABLE_GPIO_NUM, NUM_OF_LEDS+1); - - if (!Adapter->pstargetparams || IS_ERR(Adapter->pstargetparams)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, "Target Params not Avail.\n"); - return -ENOENT; - } - - /* Populate GPIO_Array with GPIO numbers for LED functions */ - /* Read the GPIO numbers from EEPROM */ - Status = ReadLEDInformationFromEEPROM(Adapter, GPIO_Array); - if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) { - *bEnableThread = false; - return STATUS_SUCCESS; - } else if (Status) { - *bEnableThread = false; - return Status; - } - - /* - * CONFIG file read successfully. Deallocate the memory of - * uiFileNameBufferSize - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, DBG_LVL_ALL, - "LED Thread: Config file read successfully\n"); - puCFGData = (PUCHAR) &Adapter->pstargetparams->HostDrvrConfig1; - - /* - * Offset for HostDrvConfig1, HostDrvConfig2, HostDrvConfig3 which - * will have the information of LED type, LED on state for different - * driver state and LED blink state. - */ - - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - bData = *puCFGData; - curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex]; - - /* - * Check Bit 8 for polarity. If it is set, - * polarity is reverse polarity - */ - if (bData & 0x80) { - curr_led_state->BitPolarity = 0; - /* unset the bit 8 */ - bData = bData & 0x7f; - } - - curr_led_state->LED_Type = bData; - if (bData <= NUM_OF_LEDS) - curr_led_state->GPIO_Num = GPIO_Array[bData]; - else - curr_led_state->GPIO_Num = DISABLE_GPIO_NUM; - - puCFGData++; - bData = *puCFGData; - curr_led_state->LED_On_State = bData; - puCFGData++; - bData = *puCFGData; - curr_led_state->LED_Blink_State = bData; - puCFGData++; - } - - /* - * Check if all the LED settings are disabled. If it is disabled, - * dont launch the LED control thread. - */ - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex]; - - if ((curr_led_state->LED_Type == DISABLE_GPIO_NUM) || - (curr_led_state->LED_Type == 0x7f) || - (curr_led_state->LED_Type == 0)) - uiNum_of_LED_Type++; - } - if (uiNum_of_LED_Type >= NUM_OF_LEDS) - *bEnableThread = false; - - return Status; -} - -/* - * ----------------------------------------------------------------------------- - * Procedure: LedGpioInit - * - * Description: Initializes LED GPIOs. Makes the LED GPIOs to OUTPUT mode - * and make the initial state to be OFF. - * - * Arguments: - * Adapter - Pointer to MINI_ADAPTER structure. - * - * Returns: VOID - * - * ----------------------------------------------------------------------------- - */ -static VOID LedGpioInit(struct bcm_mini_adapter *Adapter) -{ - UINT uiResetValue = 0; - UINT uiIndex = 0; - struct bcm_led_state_info *curr_led_state; - - /* Set all LED GPIO Mode to output mode */ - if (rdmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue, - sizeof(uiResetValue)) < 0) - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, "LED Thread: RDM Failed\n"); - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - curr_led_state = &Adapter->LEDInfo.LEDState[uiIndex]; - - if (curr_led_state->GPIO_Num != DISABLE_GPIO_NUM) - uiResetValue |= (1 << curr_led_state->GPIO_Num); - - TURN_OFF_LED(Adapter, 1 << curr_led_state->GPIO_Num, uiIndex); - - } - if (wrmalt(Adapter, GPIO_MODE_REGISTER, &uiResetValue, - sizeof(uiResetValue)) < 0) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, "LED Thread: WRM Failed\n"); - - Adapter->LEDInfo.bIdle_led_off = false; -} - -static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, - UCHAR *GPIO_num_tx, - UCHAR *GPIO_num_rx, - UCHAR *uiLedTxIndex, - UCHAR *uiLedRxIndex, - enum bcm_led_events currdriverstate) -{ - UINT uiIndex = 0; - struct bcm_led_state_info *led_state_info; - - *GPIO_num_tx = DISABLE_GPIO_NUM; - *GPIO_num_rx = DISABLE_GPIO_NUM; - - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - led_state_info = &Adapter->LEDInfo.LEDState[uiIndex]; - - if (((currdriverstate == NORMAL_OPERATION) || - (currdriverstate == IDLEMODE_EXIT) || - (currdriverstate == FW_DOWNLOAD)) && - (led_state_info->LED_Blink_State & currdriverstate) && - (led_state_info->GPIO_Num != DISABLE_GPIO_NUM)) { - if (*GPIO_num_tx == DISABLE_GPIO_NUM) { - *GPIO_num_tx = led_state_info->GPIO_Num; - *uiLedTxIndex = uiIndex; - } else { - *GPIO_num_rx = led_state_info->GPIO_Num; - *uiLedRxIndex = uiIndex; - } - } else { - if ((led_state_info->LED_On_State & currdriverstate) && - (led_state_info->GPIO_Num != DISABLE_GPIO_NUM)) { - *GPIO_num_tx = led_state_info->GPIO_Num; - *uiLedTxIndex = uiIndex; - } - } - } - return STATUS_SUCCESS; -} - -static void handle_adapter_driver_state(struct bcm_mini_adapter *ad, - enum bcm_led_events currdriverstate, - UCHAR GPIO_num, - UCHAR dummyGPIONum, - UCHAR uiLedIndex, - UCHAR dummyIndex, - ulong timeout, - UINT uiResetValue, - UINT uiIndex) -{ - switch (ad->DriverState) { - case DRIVER_INIT: - currdriverstate = DRIVER_INIT; - /* ad->DriverState; */ - BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum, - &uiLedIndex, &dummyIndex, - currdriverstate); - - if (GPIO_num != DISABLE_GPIO_NUM) - TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex); - - break; - case FW_DOWNLOAD: - /* - * BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, - * LED_DUMP_INFO, DBG_LVL_ALL, - * "LED Thread: FW_DN_DONE called\n"); - */ - currdriverstate = FW_DOWNLOAD; - BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum, - &uiLedIndex, &dummyIndex, - currdriverstate); - - if (GPIO_num != DISABLE_GPIO_NUM) { - timeout = 50; - LED_Blink(ad, 1 << GPIO_num, uiLedIndex, timeout, - -1, currdriverstate); - } - break; - case FW_DOWNLOAD_DONE: - currdriverstate = FW_DOWNLOAD_DONE; - BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum, - &uiLedIndex, &dummyIndex, currdriverstate); - if (GPIO_num != DISABLE_GPIO_NUM) - TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex); - break; - - case SHUTDOWN_EXIT: - /* - * no break, continue to NO_NETWORK_ENTRY - * state as well. - */ - case NO_NETWORK_ENTRY: - currdriverstate = NO_NETWORK_ENTRY; - BcmGetGPIOPinInfo(ad, &GPIO_num, &dummyGPIONum, - &uiLedIndex, &dummyGPIONum, currdriverstate); - if (GPIO_num != DISABLE_GPIO_NUM) - TURN_ON_LED(ad, 1 << GPIO_num, uiLedIndex); - break; - case NORMAL_OPERATION: - { - UCHAR GPIO_num_tx = DISABLE_GPIO_NUM; - UCHAR GPIO_num_rx = DISABLE_GPIO_NUM; - UCHAR uiLEDTx = 0; - UCHAR uiLEDRx = 0; - - currdriverstate = NORMAL_OPERATION; - ad->LEDInfo.bIdle_led_off = false; - - BcmGetGPIOPinInfo(ad, &GPIO_num_tx, &GPIO_num_rx, - &uiLEDTx, &uiLEDRx, currdriverstate); - if ((GPIO_num_tx == DISABLE_GPIO_NUM) && - (GPIO_num_rx == DISABLE_GPIO_NUM)) { - GPIO_num = DISABLE_GPIO_NUM; - } else { - /* - * If single LED is selected, use same - * for both Tx and Rx - */ - if (GPIO_num_tx == DISABLE_GPIO_NUM) { - GPIO_num_tx = GPIO_num_rx; - uiLEDTx = uiLEDRx; - } else if (GPIO_num_rx == DISABLE_GPIO_NUM) { - GPIO_num_rx = GPIO_num_tx; - uiLEDRx = uiLEDTx; - } - /* - * Blink the LED in proportionate - * to Tx and Rx transmissions. - */ - LED_Proportional_Blink(ad, - GPIO_num_tx, uiLEDTx, - GPIO_num_rx, uiLEDRx, - currdriverstate); - } - } - break; - case LOWPOWER_MODE_ENTER: - currdriverstate = LOWPOWER_MODE_ENTER; - if (DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING == - ad->ulPowerSaveMode) { - /* Turn OFF all the LED */ - uiResetValue = 0; - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num != DISABLE_GPIO_NUM) - TURN_OFF_LED(ad, - (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num), - uiIndex); - } - - } - /* Turn off LED And WAKE-UP for Sendinf IDLE mode ACK */ - ad->LEDInfo.bLedInitDone = false; - ad->LEDInfo.bIdle_led_off = TRUE; - wake_up(&ad->LEDInfo.idleModeSyncEvent); - GPIO_num = DISABLE_GPIO_NUM; - break; - case IDLEMODE_CONTINUE: - currdriverstate = IDLEMODE_CONTINUE; - GPIO_num = DISABLE_GPIO_NUM; - break; - case IDLEMODE_EXIT: - break; - case DRIVER_HALT: - currdriverstate = DRIVER_HALT; - GPIO_num = DISABLE_GPIO_NUM; - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num != - DISABLE_GPIO_NUM) - TURN_OFF_LED(ad, - (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num), - uiIndex); - } - /* ad->DriverState = DRIVER_INIT; */ - break; - case LED_THREAD_INACTIVE: - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, "InActivating LED thread..."); - currdriverstate = LED_THREAD_INACTIVE; - ad->LEDInfo.led_thread_running = - BCM_LED_THREAD_RUNNING_INACTIVELY; - ad->LEDInfo.bLedInitDone = false; - /* disable ALL LED */ - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) { - if (ad->LEDInfo.LEDState[uiIndex].GPIO_Num != - DISABLE_GPIO_NUM) - TURN_OFF_LED(ad, - (1 << ad->LEDInfo.LEDState[uiIndex].GPIO_Num), - uiIndex); - } - break; - case LED_THREAD_ACTIVE: - BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, "Activating LED thread again..."); - if (ad->LinkUpStatus == false) - ad->DriverState = NO_NETWORK_ENTRY; - else - ad->DriverState = NORMAL_OPERATION; - - ad->LEDInfo.led_thread_running = - BCM_LED_THREAD_RUNNING_ACTIVELY; - break; - /* return; */ - default: - break; - } -} - -static VOID LEDControlThread(struct bcm_mini_adapter *Adapter) -{ - UINT uiIndex = 0; - UCHAR GPIO_num = 0; - UCHAR uiLedIndex = 0; - UINT uiResetValue = 0; - enum bcm_led_events currdriverstate = 0; - ulong timeout = 0; - - INT Status = 0; - - UCHAR dummyGPIONum = 0; - UCHAR dummyIndex = 0; - - /* currdriverstate = Adapter->DriverState; */ - Adapter->LEDInfo.bIdleMode_tx_from_host = false; - - /* - * Wait till event is triggered - * - * wait_event(Adapter->LEDInfo.notify_led_event, - * currdriverstate!= Adapter->DriverState); - */ - - GPIO_num = DISABLE_GPIO_NUM; - - while (TRUE) { - /* Wait till event is triggered */ - if ((GPIO_num == DISABLE_GPIO_NUM) - || - ((currdriverstate != FW_DOWNLOAD) && - (currdriverstate != NORMAL_OPERATION) && - (currdriverstate != LOWPOWER_MODE_ENTER)) - || - (currdriverstate == LED_THREAD_INACTIVE)) - Status = wait_event_interruptible( - Adapter->LEDInfo.notify_led_event, - currdriverstate != Adapter->DriverState - || kthread_should_stop()); - - if (kthread_should_stop() || Adapter->device_removed) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "Led thread got signal to exit..hence exiting"); - Adapter->LEDInfo.led_thread_running = - BCM_LED_THREAD_DISABLED; - TURN_OFF_LED(Adapter, 1 << GPIO_num, uiLedIndex); - return; /* STATUS_FAILURE; */ - } - - if (GPIO_num != DISABLE_GPIO_NUM) - TURN_OFF_LED(Adapter, 1 << GPIO_num, uiLedIndex); - - if (Adapter->LEDInfo.bLedInitDone == false) { - LedGpioInit(Adapter); - Adapter->LEDInfo.bLedInitDone = TRUE; - } - - handle_adapter_driver_state(Adapter, - currdriverstate, - GPIO_num, - dummyGPIONum, - uiLedIndex, - dummyIndex, - timeout, - uiResetValue, - uiIndex - ); - } - Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED; -} - -int InitLedSettings(struct bcm_mini_adapter *Adapter) -{ - int Status = STATUS_SUCCESS; - bool bEnableThread = TRUE; - UCHAR uiIndex = 0; - - /* - * Initially set BitPolarity to normal polarity. The bit 8 of LED type - * is used to change the polarity of the LED. - */ - - for (uiIndex = 0; uiIndex < NUM_OF_LEDS; uiIndex++) - Adapter->LEDInfo.LEDState[uiIndex].BitPolarity = 1; - - /* - * Read the LED settings of CONFIG file and map it - * to GPIO numbers in EEPROM - */ - Status = ReadConfigFileStructure(Adapter, &bEnableThread); - if (STATUS_SUCCESS != Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "LED Thread: FAILED in ReadConfigFileStructure\n"); - return Status; - } - - if (Adapter->LEDInfo.led_thread_running) { - if (bEnableThread) { - ; - } else { - Adapter->DriverState = DRIVER_HALT; - wake_up(&Adapter->LEDInfo.notify_led_event); - Adapter->LEDInfo.led_thread_running = - BCM_LED_THREAD_DISABLED; - } - - } else if (bEnableThread) { - /* Create secondary thread to handle the LEDs */ - init_waitqueue_head(&Adapter->LEDInfo.notify_led_event); - init_waitqueue_head(&Adapter->LEDInfo.idleModeSyncEvent); - Adapter->LEDInfo.led_thread_running = - BCM_LED_THREAD_RUNNING_ACTIVELY; - Adapter->LEDInfo.bIdle_led_off = false; - Adapter->LEDInfo.led_cntrl_threadid = - kthread_run((int (*)(void *)) LEDControlThread, - Adapter, "led_control_thread"); - if (IS_ERR(Adapter->LEDInfo.led_cntrl_threadid)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LED_DUMP_INFO, - DBG_LVL_ALL, - "Not able to spawn Kernel Thread\n"); - Adapter->LEDInfo.led_thread_running = - BCM_LED_THREAD_DISABLED; - return PTR_ERR(Adapter->LEDInfo.led_cntrl_threadid); - } - } - return Status; -} diff --git a/drivers/staging/bcm/led_control.h b/drivers/staging/bcm/led_control.h deleted file mode 100644 index 1b24bf4658af..000000000000 --- a/drivers/staging/bcm/led_control.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _LED_CONTROL_H -#define _LED_CONTROL_H - -#define NUM_OF_LEDS 4 -#define DSD_START_OFFSET 0x0200 -#define EEPROM_VERSION_OFFSET 0x020E -#define EEPROM_HW_PARAM_POINTER_ADDRESS 0x0218 -#define EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5 0x0220 -#define GPIO_SECTION_START_OFFSET 0x03 -#define COMPATIBILITY_SECTION_LENGTH 42 -#define COMPATIBILITY_SECTION_LENGTH_MAP5 84 -#define EEPROM_MAP5_MAJORVERSION 5 -#define EEPROM_MAP5_MINORVERSION 0 -#define MAX_NUM_OF_BLINKS 10 -#define NUM_OF_GPIO_PINS 16 -#define DISABLE_GPIO_NUM 0xFF -#define EVENT_SIGNALED 1 -#define MAX_FILE_NAME_BUFFER_SIZE 100 - -#define TURN_ON_LED(ad, GPIO, index) do { \ - unsigned int gpio_val = GPIO; \ - (ad->LEDInfo.LEDState[index].BitPolarity == 1) ? \ - wrmaltWithLock(ad, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \ - wrmaltWithLock(ad, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \ - } while (0) - -#define TURN_OFF_LED(ad, GPIO, index) do { \ - unsigned int gpio_val = GPIO; \ - (ad->LEDInfo.LEDState[index].BitPolarity == 1) ? \ - wrmaltWithLock(ad, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \ - wrmaltWithLock(ad, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \ - } while (0) - -enum bcm_led_colors { - RED_LED = 1, - BLUE_LED = 2, - YELLOW_LED = 3, - GREEN_LED = 4 -}; - -enum bcm_led_events { - SHUTDOWN_EXIT = 0x00, - DRIVER_INIT = 0x1, - FW_DOWNLOAD = 0x2, - FW_DOWNLOAD_DONE = 0x4, - NO_NETWORK_ENTRY = 0x8, - NORMAL_OPERATION = 0x10, - LOWPOWER_MODE_ENTER = 0x20, - IDLEMODE_CONTINUE = 0x40, - IDLEMODE_EXIT = 0x80, - LED_THREAD_INACTIVE = 0x100, /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */ - LED_THREAD_ACTIVE = 0x200, /* Makes the LED Thread Active back. */ - DRIVER_HALT = 0xff -}; /* Enumerated values of different driver states */ - -/* - * Structure which stores the information of different LED types - * and corresponding LED state information of driver states - */ -struct bcm_led_state_info { - unsigned char LED_Type; /* specify GPIO number - use 0xFF if not used */ - unsigned char LED_On_State; /* Bits set or reset for different states */ - unsigned char LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */ - unsigned char GPIO_Num; - unsigned char BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */ -}; - -struct bcm_led_info { - struct bcm_led_state_info LEDState[NUM_OF_LEDS]; - bool bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target */ - bool bIdle_led_off; - wait_queue_head_t notify_led_event; - wait_queue_head_t idleModeSyncEvent; - struct task_struct *led_cntrl_threadid; - int led_thread_running; - bool bLedInitDone; -}; - -/* LED Thread state. */ -#define BCM_LED_THREAD_DISABLED 0 /* LED Thread is not running. */ -#define BCM_LED_THREAD_RUNNING_ACTIVELY 1 /* LED thread is running. */ -#define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /* LED thread has been put on hold */ - -#endif diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c deleted file mode 100644 index ce09473fbb1f..000000000000 --- a/drivers/staging/bcm/nvm.c +++ /dev/null @@ -1,4661 +0,0 @@ -#include "headers.h" - -#define DWORD unsigned int - -static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, - unsigned int offset); -static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter); -static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter); -static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter); -static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter); -static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, - unsigned int FlashSectorSizeSig, - unsigned int FlashSectorSize); - -static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter); -static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter); -static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter); -static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter); - -static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val eFlash2xSectionVal); - -static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, - unsigned int uiOffset); -static int IsSectionWritable(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val Section); -static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val section); - -static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val dsd); -static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val dsd); -static int ReadISOPriority(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val iso); -static int ReadISOSignature(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val iso); - -static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val eFlash2xSectionVal); -static int CorruptISOSig(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val eFlash2xSectionVal); -static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, - PUCHAR pBuff, - unsigned int uiSectAlignAddr); -static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, - PUINT pBuff, - enum bcm_flash2x_section_val eFlash2xSectionVal, - unsigned int uiOffset, - unsigned int uiNumBytes); -static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter); -static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter); - -static int BeceemFlashBulkRead( - struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes); - -static int BeceemFlashBulkWrite( - struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes, - bool bVerify); - -static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter); - -static int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, unsigned int dwAddress, unsigned int *pdwData, unsigned int dwNumData); - -/* Procedure: ReadEEPROMStatusRegister - * - * Description: Reads the standard EEPROM Status Register. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * Returns: - * OSAL_STATUS_CODE - */ -static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter) -{ - UCHAR uiData = 0; - DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY; - unsigned int uiStatus = 0; - unsigned int value = 0; - unsigned int value1 = 0; - - /* Read the EEPROM status register */ - value = EEPROM_READ_STATUS_REGISTER; - wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); - - while (dwRetries != 0) { - value = 0; - uiStatus = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); - if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting...."); - break; - } - - /* Wait for Avail bit to be set. */ - if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) { - /* Clear the Avail/Full bits - which ever is set. */ - value = uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - - value = 0; - rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); - uiData = (UCHAR)value; - - break; - } - - dwRetries--; - if (dwRetries == 0) { - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x3004 = %x 0x3008 = %x, retries = %d failed.\n", value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY); - return uiData; - } - if (!(dwRetries%RETRIES_PER_DELAY)) - udelay(1000); - uiStatus = 0; - } - return uiData; -} /* ReadEEPROMStatusRegister */ - -/* - * Procedure: ReadBeceemEEPROMBulk - * - * Description: This routine reads 16Byte data from EEPROM - * - * Arguments: - * Adapter - ptr to Adapter object instance - * dwAddress - EEPROM Offset to read the data from. - * pdwData - Pointer to double word where data needs to be stored in. // dwNumWords - Number of words. Valid values are 4 ONLY. - * - * Returns: - * OSAL_STATUS_CODE: - */ - -static int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, - DWORD dwAddress, - DWORD *pdwData, - DWORD dwNumWords) -{ - DWORD dwIndex = 0; - DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY; - unsigned int uiStatus = 0; - unsigned int value = 0; - unsigned int value1 = 0; - UCHAR *pvalue; - - /* Flush the read and cmd queue. */ - value = (EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH); - wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); - value = 0; - wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); - - /* Clear the Avail/Full bits. */ - value = (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - - value = dwAddress | ((dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ); - wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); - - while (dwRetries != 0) { - uiStatus = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); - if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got Removed.hence exiting from loop..."); - return -ENODEV; - } - - /* If we are reading 16 bytes we want to be sure that the queue - * is full before we read. In the other cases we are ok if the - * queue has data available - */ - if (dwNumWords == 4) { - if ((uiStatus & EEPROM_READ_DATA_FULL) != 0) { - /* Clear the Avail/Full bits - which ever is set. */ - value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL)); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - break; - } - } else if (dwNumWords == 1) { - if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) { - /* We just got Avail and we have to read 32bits so we - * need this sleep for Cardbus kind of devices. - */ - if (Adapter->chip_id == 0xBECE0210) - udelay(800); - - /* Clear the Avail/Full bits - which ever is set. */ - value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL)); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - break; - } - } - - uiStatus = 0; - - dwRetries--; - if (dwRetries == 0) { - value = 0; - value1 = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed.\n", - dwNumWords, value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY); - return STATUS_FAILURE; - } - - if (!(dwRetries%RETRIES_PER_DELAY)) - udelay(1000); - } - - for (dwIndex = 0; dwIndex < dwNumWords; dwIndex++) { - /* We get only a byte at a time - from LSB to MSB. We shift it into an integer. */ - pvalue = (PUCHAR)(pdwData + dwIndex); - - value = 0; - rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); - - pvalue[0] = value; - - value = 0; - rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); - - pvalue[1] = value; - - value = 0; - rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); - - pvalue[2] = value; - - value = 0; - rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); - - pvalue[3] = value; - } - - return STATUS_SUCCESS; -} /* ReadBeceemEEPROMBulk() */ - -/* - * Procedure: ReadBeceemEEPROM - * - * Description: This routine reads 4 data from EEPROM. It uses 1 or 2 page - * reads to do this operation. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiOffset - EEPROM Offset to read the data from. - * pBuffer - Pointer to word where data needs to be stored in. - * - * Returns: - * OSAL_STATUS_CODE: - */ - -int ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter, - DWORD uiOffset, - DWORD *pBuffer) -{ - unsigned int uiData[8] = {0}; - unsigned int uiByteOffset = 0; - unsigned int uiTempOffset = 0; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ====> "); - - uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE); - uiByteOffset = uiOffset - uiTempOffset; - - ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4); - - /* A word can overlap at most over 2 pages. In that case we read the - * next page too. - */ - if (uiByteOffset > 12) - ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); - - memcpy((PUCHAR)pBuffer, (((PUCHAR)&uiData[0]) + uiByteOffset), 4); - - return STATUS_SUCCESS; -} /* ReadBeceemEEPROM() */ - -int ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter) -{ - int Status; - unsigned char puMacAddr[6]; - - Status = BeceemNVMRead(Adapter, - (PUINT)&puMacAddr[0], - INIT_PARAMS_1_MACADDRESS_ADDRESS, - MAC_ADDRESS_SIZE); - - if (Status == STATUS_SUCCESS) - memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); - - return Status; -} - -/* - * Procedure: BeceemEEPROMBulkRead - * - * Description: Reads the EEPROM and returns the Data. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Buffer to store the data read from EEPROM - * uiOffset - Offset of EEPROM from where data should be read - * uiNumBytes - Number of bytes to be read from the EEPROM. - * - * Returns: - * OSAL_STATUS_SUCCESS - if EEPROM read is successful. - * - if failed. - */ - -int BeceemEEPROMBulkRead(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes) -{ - unsigned int uiData[4] = {0}; - /* unsigned int uiAddress = 0; */ - unsigned int uiBytesRemaining = uiNumBytes; - unsigned int uiIndex = 0; - unsigned int uiTempOffset = 0; - unsigned int uiExtraBytes = 0; - unsigned int uiFailureRetries = 0; - PUCHAR pcBuff = (PUCHAR)pBuffer; - - if (uiOffset % MAX_RW_SIZE && uiBytesRemaining) { - uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE); - uiExtraBytes = uiOffset - uiTempOffset; - ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4); - if (uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) { - memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), MAX_RW_SIZE - uiExtraBytes); - uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes); - uiIndex += (MAX_RW_SIZE - uiExtraBytes); - uiOffset += (MAX_RW_SIZE - uiExtraBytes); - } else { - memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), uiBytesRemaining); - uiIndex += uiBytesRemaining; - uiOffset += uiBytesRemaining; - uiBytesRemaining = 0; - } - } - - while (uiBytesRemaining && uiFailureRetries != 128) { - if (Adapter->device_removed) - return -1; - - if (uiBytesRemaining >= MAX_RW_SIZE) { - /* For the requests more than or equal to 16 bytes, use bulk - * read function to make the access faster. - * We read 4 Dwords of data - */ - if (ReadBeceemEEPROMBulk(Adapter, uiOffset, &uiData[0], 4) == 0) { - memcpy(pcBuff + uiIndex, &uiData[0], MAX_RW_SIZE); - uiOffset += MAX_RW_SIZE; - uiBytesRemaining -= MAX_RW_SIZE; - uiIndex += MAX_RW_SIZE; - } else { - uiFailureRetries++; - mdelay(3); /* sleep for a while before retry... */ - } - } else if (uiBytesRemaining >= 4) { - if (ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0]) == 0) { - memcpy(pcBuff + uiIndex, &uiData[0], 4); - uiOffset += 4; - uiBytesRemaining -= 4; - uiIndex += 4; - } else { - uiFailureRetries++; - mdelay(3); /* sleep for a while before retry... */ - } - } else { - /* Handle the reads less than 4 bytes... */ - PUCHAR pCharBuff = (PUCHAR)pBuffer; - - pCharBuff += uiIndex; - if (ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0]) == 0) { - memcpy(pCharBuff, &uiData[0], uiBytesRemaining); /* copy only bytes requested. */ - uiBytesRemaining = 0; - } else { - uiFailureRetries++; - mdelay(3); /* sleep for a while before retry... */ - } - } - } - - return 0; -} - -/* - * Procedure: BeceemFlashBulkRead - * - * Description: Reads the FLASH and returns the Data. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Buffer to store the data read from FLASH - * uiOffset - Offset of FLASH from where data should be read - * uiNumBytes - Number of bytes to be read from the FLASH. - * - * Returns: - * OSAL_STATUS_SUCCESS - if FLASH read is successful. - * - if failed. - */ - -static int BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes) -{ - unsigned int uiIndex = 0; - unsigned int uiBytesToRead = uiNumBytes; - int Status = 0; - unsigned int uiPartOffset = 0; - int bytes; - - if (Adapter->device_removed) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device Got Removed"); - return -ENODEV; - } - - /* Adding flash Base address - * uiOffset = uiOffset + GetFlashBaseAddr(Adapter); - */ - #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) - Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes); - return Status; - #endif - - Adapter->SelectedChip = RESET_CHIP_SELECT; - - if (uiOffset % MAX_RW_SIZE) { - BcmDoChipSelect(Adapter, uiOffset); - uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - - uiBytesToRead = MAX_RW_SIZE - (uiOffset % MAX_RW_SIZE); - uiBytesToRead = MIN(uiNumBytes, uiBytesToRead); - - bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead); - if (bytes < 0) { - Status = bytes; - Adapter->SelectedChip = RESET_CHIP_SELECT; - return Status; - } - - uiIndex += uiBytesToRead; - uiOffset += uiBytesToRead; - uiNumBytes -= uiBytesToRead; - } - - while (uiNumBytes) { - BcmDoChipSelect(Adapter, uiOffset); - uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - - uiBytesToRead = MIN(uiNumBytes, MAX_RW_SIZE); - - bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead); - if (bytes < 0) { - Status = bytes; - break; - } - - uiIndex += uiBytesToRead; - uiOffset += uiBytesToRead; - uiNumBytes -= uiBytesToRead; - } - Adapter->SelectedChip = RESET_CHIP_SELECT; - return Status; -} - -/* - * Procedure: BcmGetFlashSize - * - * Description: Finds the size of FLASH. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * unsigned int - size of the FLASH Storage. - * - */ - -static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter) -{ - if (IsFlash2x(Adapter)) - return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header); - else - return 32 * 1024; -} - -/* - * Procedure: BcmGetEEPROMSize - * - * Description: Finds the size of EEPROM. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * unsigned int - size of the EEPROM Storage. - * - */ - -static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiData = 0; - unsigned int uiIndex = 0; - - /* - * if EEPROM is present and already Calibrated,it will have - * 'BECM' string at 0th offset. - * To find the EEPROM size read the possible boundaries of the - * EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will - * result in wrap around. So when we get the End of the EEPROM we will - * get 'BECM' string which is indeed at offset 0. - */ - BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4); - if (uiData == BECM) { - for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) { - BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4); - if (uiData == BECM) - return uiIndex * 1024; - } - } else { - /* - * EEPROM may not be present or not programmed - */ - uiData = 0xBABEFACE; - if (BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&uiData, 0, 4, TRUE) == 0) { - uiData = 0; - for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) { - BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4); - if (uiData == 0xBABEFACE) - return uiIndex * 1024; - } - } - } - return 0; -} - -/* - * Procedure: FlashSectorErase - * - * Description: Finds the sector size of the FLASH. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * addr - sector start address - * numOfSectors - number of sectors to be erased. - * - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int FlashSectorErase(struct bcm_mini_adapter *Adapter, - unsigned int addr, - unsigned int numOfSectors) -{ - unsigned int iIndex = 0, iRetries = 0; - unsigned int uiStatus = 0; - unsigned int value; - int bytes; - - for (iIndex = 0; iIndex < numOfSectors; iIndex++) { - value = 0x06000000; - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - - value = (0xd8000000 | (addr & 0xFFFFFF)); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - iRetries = 0; - - do { - value = (FLASH_CMD_STATUS_REG_READ << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - - bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); - if (bytes < 0) { - uiStatus = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails"); - return uiStatus; - } - iRetries++; - /* After every try lets make the CPU free for 10 ms. generally time taken by the - * the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms - * won't hamper performance in any case. - */ - mdelay(10); - } while ((uiStatus & 0x1) && (iRetries < 400)); - - if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "iRetries crossing the limit of 80000\n"); - return STATUS_FAILURE; - } - - addr += Adapter->uiSectorSize; - } - return 0; -} -/* - * Procedure: flashByteWrite - * - * Description: Performs Byte by Byte write to flash - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiOffset - Offset of the flash where data needs to be written to. - * pData - Address of Data to be written. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int flashByteWrite(struct bcm_mini_adapter *Adapter, - unsigned int uiOffset, - PVOID pData) -{ - unsigned int uiStatus = 0; - int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */ - unsigned int value; - ULONG ulData = *(PUCHAR)pData; - int bytes; - /* - * need not write 0xFF because write requires an erase and erase will - * make whole sector 0xFF. - */ - - if (0xFF == ulData) - return STATUS_SUCCESS; - - /* DumpDebug(NVM_RW,("flashWrite ====>\n")); */ - value = (FLASH_CMD_WRITE_ENABLE << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails"); - return STATUS_FAILURE; - } - - if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails"); - return STATUS_FAILURE; - } - value = (0x02000000 | (uiOffset & 0xFFFFFF)); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - - /* __udelay(950); */ - - do { - value = (FLASH_CMD_STATUS_REG_READ << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - /* __udelay(1); */ - bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); - if (bytes < 0) { - uiStatus = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails"); - return uiStatus; - } - iRetries--; - if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - udelay(1000); - - } while ((uiStatus & 0x1) && (iRetries > 0)); - - if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE; - } - - return STATUS_SUCCESS; -} - -/* - * Procedure: flashWrite - * - * Description: Performs write to flash - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiOffset - Offset of the flash where data needs to be written to. - * pData - Address of Data to be written. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int flashWrite(struct bcm_mini_adapter *Adapter, - unsigned int uiOffset, - PVOID pData) -{ - /* unsigned int uiStatus = 0; - * int iRetries = 0; - * unsigned int uiReadBack = 0; - */ - unsigned int uiStatus = 0; - int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */ - unsigned int value; - unsigned int uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; - int bytes; - /* - * need not write 0xFFFFFFFF because write requires an erase and erase will - * make whole sector 0xFFFFFFFF. - */ - if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE)) - return 0; - - value = (FLASH_CMD_WRITE_ENABLE << 24); - - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - - if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails..."); - return STATUS_FAILURE; - } - - /* __udelay(950); */ - do { - value = (FLASH_CMD_STATUS_REG_READ << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - /* __udelay(1); */ - bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); - if (bytes < 0) { - uiStatus = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails"); - return uiStatus; - } - - iRetries--; - /* this will ensure that in there will be no changes in the current path. - * currently one rdm/wrm takes 125 us. - * Hence 125 *2 * FLASH_PER_RETRIES_DELAY > 3 ms(worst case delay) - * Hence current implementation cycle will intoduce no delay in current path - */ - if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - udelay(1000); - } while ((uiStatus & 0x1) && (iRetries > 0)); - - if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE; - } - - return STATUS_SUCCESS; -} - -/*----------------------------------------------------------------------------- - * Procedure: flashByteWriteStatus - * - * Description: Performs byte by byte write to flash with write done status check - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiOffset - Offset of the flash where data needs to be written to. - * pData - Address of the Data to be written. - * Returns: - * OSAL_STATUS_CODE - * - */ -static int flashByteWriteStatus(struct bcm_mini_adapter *Adapter, - unsigned int uiOffset, - PVOID pData) -{ - unsigned int uiStatus = 0; - int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */ - ULONG ulData = *(PUCHAR)pData; - unsigned int value; - int bytes; - - /* - * need not write 0xFFFFFFFF because write requires an erase and erase will - * make whole sector 0xFFFFFFFF. - */ - - if (0xFF == ulData) - return STATUS_SUCCESS; - - /* DumpDebug(NVM_RW,("flashWrite ====>\n")); */ - - value = (FLASH_CMD_WRITE_ENABLE << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails"); - return STATUS_SUCCESS; - } - if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails"); - return STATUS_FAILURE; - } - value = (0x02000000 | (uiOffset & 0xFFFFFF)); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - - /* msleep(1); */ - - do { - value = (FLASH_CMD_STATUS_REG_READ << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - /* __udelay(1); */ - bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); - if (bytes < 0) { - uiStatus = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails"); - return uiStatus; - } - - iRetries--; - if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - udelay(1000); - - } while ((uiStatus & 0x1) && (iRetries > 0)); - - if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE; - } - - return STATUS_SUCCESS; -} -/* - * Procedure: flashWriteStatus - * - * Description: Performs write to flash with write done status check - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiOffset - Offset of the flash where data needs to be written to. - * pData - Address of the Data to be written. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int flashWriteStatus(struct bcm_mini_adapter *Adapter, - unsigned int uiOffset, - PVOID pData) -{ - unsigned int uiStatus = 0; - int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */ - /* unsigned int uiReadBack = 0; */ - unsigned int value; - unsigned int uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; - int bytes; - - /* - * need not write 0xFFFFFFFF because write requires an erase and erase will - * make whole sector 0xFFFFFFFF. - */ - if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE)) - return 0; - - value = (FLASH_CMD_WRITE_ENABLE << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - - if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails..."); - return STATUS_FAILURE; - } - /* __udelay(1); */ - - do { - value = (FLASH_CMD_STATUS_REG_READ << 24); - if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); - return STATUS_FAILURE; - } - /* __udelay(1); */ - bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); - if (bytes < 0) { - uiStatus = bytes; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails"); - return uiStatus; - } - iRetries--; - /* this will ensure that in there will be no changes in the current path. - * currently one rdm/wrm takes 125 us. - * Hence 125 *2 * FLASH_PER_RETRIES_DELAY >3 ms(worst case delay) - * Hence current implementation cycle will intoduce no delay in current path - */ - if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - udelay(1000); - - } while ((uiStatus & 0x1) && (iRetries > 0)); - - if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE; - } - - return STATUS_SUCCESS; -} - -/* - * Procedure: BcmRestoreBlockProtectStatus - * - * Description: Restores the original block protection status. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * ulWriteStatus -Original status - * Returns: - * - * - */ - -static VOID BcmRestoreBlockProtectStatus(struct bcm_mini_adapter *Adapter, ULONG ulWriteStatus) -{ - unsigned int value; - - value = (FLASH_CMD_WRITE_ENABLE << 24); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - - udelay(20); - value = (FLASH_CMD_STATUS_REG_WRITE << 24) | (ulWriteStatus << 16); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - udelay(20); -} - -/* - * Procedure: BcmFlashUnProtectBlock - * - * Description: UnProtects appropriate blocks for writing. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiOffset - Offset of the flash where data needs to be written to. This should be Sector aligned. - * Returns: - * ULONG - Status value before UnProtect. - * - */ - -static ULONG BcmFlashUnProtectBlock(struct bcm_mini_adapter *Adapter, unsigned int uiOffset, unsigned int uiLength) -{ - ULONG ulStatus = 0; - ULONG ulWriteStatus = 0; - unsigned int value; - - uiOffset = uiOffset&0x000FFFFF; - /* - * Implemented only for 1MB Flash parts. - */ - if (FLASH_PART_SST25VF080B == Adapter->ulFlashID) { - /* - * Get Current BP status. - */ - value = (FLASH_CMD_STATUS_REG_READ << 24); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - udelay(10); - /* - * Read status will be WWXXYYZZ. We have to take only WW. - */ - rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulStatus, sizeof(ulStatus)); - ulStatus >>= 24; - ulWriteStatus = ulStatus; - /* - * Bits [5-2] give current block level protection status. - * Bit5: BP3 - DONT CARE - * BP2-BP0: 0 - NO PROTECTION, 1 - UPPER 1/16, 2 - UPPER 1/8, 3 - UPPER 1/4 - * 4 - UPPER 1/2. 5 to 7 - ALL BLOCKS - */ - - if (ulStatus) { - if ((uiOffset+uiLength) <= 0x80000) { - /* - * Offset comes in lower half of 1MB. Protect the upper half. - * Clear BP1 and BP0 and set BP2. - */ - ulWriteStatus |= (0x4<<2); - ulWriteStatus &= ~(0x3<<2); - } else if ((uiOffset + uiLength) <= 0xC0000) { - /* - * Offset comes below Upper 1/4. Upper 1/4 can be protected. - * Clear BP2 and set BP1 and BP0. - */ - ulWriteStatus |= (0x3<<2); - ulWriteStatus &= ~(0x1<<4); - } else if ((uiOffset + uiLength) <= 0xE0000) { - /* - * Offset comes below Upper 1/8. Upper 1/8 can be protected. - * Clear BP2 and BP0 and set BP1 - */ - ulWriteStatus |= (0x1<<3); - ulWriteStatus &= ~(0x5<<2); - } else if ((uiOffset + uiLength) <= 0xF0000) { - /* - * Offset comes below Upper 1/16. Only upper 1/16 can be protected. - * Set BP0 and Clear BP2,BP1. - */ - ulWriteStatus |= (0x1<<2); - ulWriteStatus &= ~(0x3<<3); - } else { - /* - * Unblock all. - * Clear BP2,BP1 and BP0. - */ - ulWriteStatus &= ~(0x7<<2); - } - - value = (FLASH_CMD_WRITE_ENABLE << 24); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - udelay(20); - value = (FLASH_CMD_STATUS_REG_WRITE << 24) | (ulWriteStatus << 16); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - udelay(20); - } - } - return ulStatus; -} - -static int bulk_read_complete_sector(struct bcm_mini_adapter *ad, - UCHAR read_bk[], - PCHAR tmpbuff, - unsigned int offset, - unsigned int partoff) -{ - unsigned int i; - int j; - int bulk_read_stat; - FP_FLASH_WRITE_STATUS writef = - ad->fpFlashWriteWithStatusCheck; - - for (i = 0; i < ad->uiSectorSize; i += MAX_RW_SIZE) { - bulk_read_stat = BeceemFlashBulkRead(ad, - (PUINT)read_bk, - offset + i, - MAX_RW_SIZE); - - if (bulk_read_stat != STATUS_SUCCESS) - continue; - - if (ad->ulFlashWriteSize == 1) { - for (j = 0; j < 16; j++) { - if ((read_bk[j] != tmpbuff[i + j]) && - (STATUS_SUCCESS != (*writef)(ad, partoff + i + j, &tmpbuff[i + j]))) { - return STATUS_FAILURE; - } - } - } else { - if ((memcmp(read_bk, &tmpbuff[i], MAX_RW_SIZE)) && - (STATUS_SUCCESS != (*writef)(ad, partoff + i, &tmpbuff[i]))) { - return STATUS_FAILURE; - } - } - } - - return STATUS_SUCCESS; -} - -/* - * Procedure: BeceemFlashBulkWrite - * - * Description: Performs write to the flash - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Data to be written. - * uiOffset - Offset of the flash where data needs to be written to. - * uiNumBytes - Number of bytes to be written. - * bVerify - read verify flag. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int BeceemFlashBulkWrite(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes, - bool bVerify) -{ - PCHAR pTempBuff = NULL; - PUCHAR pcBuffer = (PUCHAR)pBuffer; - unsigned int uiIndex = 0; - unsigned int uiOffsetFromSectStart = 0; - unsigned int uiSectAlignAddr = 0; - unsigned int uiCurrSectOffsetAddr = 0; - unsigned int uiSectBoundary = 0; - unsigned int uiNumSectTobeRead = 0; - UCHAR ucReadBk[16] = {0}; - ULONG ulStatus = 0; - int Status = STATUS_SUCCESS; - unsigned int uiTemp = 0; - unsigned int index = 0; - unsigned int uiPartOffset = 0; - - #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) - Status = bcmflash_raw_write((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes); - return Status; - #endif - - uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1); - - /* Adding flash Base address - * uiOffset = uiOffset + GetFlashBaseAddr(Adapter); - */ - - uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); - uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); - uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; - - pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL); - if (!pTempBuff) - goto BeceemFlashBulkWrite_EXIT; - /* - * check if the data to be written is overlapped across sectors - */ - if (uiOffset+uiNumBytes < uiSectBoundary) { - uiNumSectTobeRead = 1; - } else { - /* Number of sectors = Last sector start address/First sector start address */ - uiNumSectTobeRead = (uiCurrSectOffsetAddr + uiNumBytes) / Adapter->uiSectorSize; - if ((uiCurrSectOffsetAddr + uiNumBytes)%Adapter->uiSectorSize) - uiNumSectTobeRead++; - } - /* Check whether Requested sector is writable or not in case of flash2x write. But if write call is - * for DSD calibration, allow it without checking of sector permission - */ - - if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == false)) { - index = 0; - uiTemp = uiNumSectTobeRead; - while (uiTemp) { - if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%X> is not writable", - (uiOffsetFromSectStart + index * Adapter->uiSectorSize)); - Status = SECTOR_IS_NOT_WRITABLE; - goto BeceemFlashBulkWrite_EXIT; - } - uiTemp = uiTemp - 1; - index = index + 1; - } - } - Adapter->SelectedChip = RESET_CHIP_SELECT; - while (uiNumSectTobeRead) { - /* do_gettimeofday(&tv1); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nTime In start of write :%ld ms\n",(tv1.tv_sec *1000 + tv1.tv_usec /1000)); - */ - uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - - BcmDoChipSelect(Adapter, uiSectAlignAddr); - - if (0 != BeceemFlashBulkRead(Adapter, - (PUINT)pTempBuff, - uiOffsetFromSectStart, - Adapter->uiSectorSize)) { - Status = -1; - goto BeceemFlashBulkWrite_EXIT; - } - - /* do_gettimeofday(&tr); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Read :%ld ms\n", (tr.tv_sec *1000 + tr.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000)); - */ - ulStatus = BcmFlashUnProtectBlock(Adapter, uiSectAlignAddr, Adapter->uiSectorSize); - - if (uiNumSectTobeRead > 1) { - memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)); - pcBuffer += ((uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr))); - uiNumBytes -= (uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)); - } else { - memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiNumBytes); - } - - if (IsFlash2x(Adapter)) - SaveHeaderIfPresent(Adapter, (PUCHAR)pTempBuff, uiOffsetFromSectStart); - - FlashSectorErase(Adapter, uiPartOffset, 1); - /* do_gettimeofday(&te); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Erase :%ld ms\n", (te.tv_sec *1000 + te.tv_usec/1000) - (tr.tv_sec *1000 + tr.tv_usec/1000)); - */ - for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += Adapter->ulFlashWriteSize) { - if (Adapter->device_removed) { - Status = -1; - goto BeceemFlashBulkWrite_EXIT; - } - - if (STATUS_SUCCESS != (*Adapter->fpFlashWrite)(Adapter, uiPartOffset + uiIndex, (&pTempBuff[uiIndex]))) { - Status = -1; - goto BeceemFlashBulkWrite_EXIT; - } - } - - /* do_gettimeofday(&tw); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash :%ld ms\n", (tw.tv_sec *1000 + tw.tv_usec/1000) - (te.tv_sec *1000 + te.tv_usec/1000)); - */ - - if (STATUS_FAILURE == bulk_read_complete_sector(Adapter, - ucReadBk, - pTempBuff, - uiOffsetFromSectStart, - uiPartOffset)) { - Status = STATUS_FAILURE; - goto BeceemFlashBulkWrite_EXIT; - } - - /* do_gettimeofday(&twv); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash verification :%ld ms\n", (twv.tv_sec *1000 + twv.tv_usec/1000) - (tw.tv_sec *1000 + tw.tv_usec/1000)); - */ - if (ulStatus) { - BcmRestoreBlockProtectStatus(Adapter, ulStatus); - ulStatus = 0; - } - - uiCurrSectOffsetAddr = 0; - uiSectAlignAddr = uiSectBoundary; - uiSectBoundary += Adapter->uiSectorSize; - uiOffsetFromSectStart += Adapter->uiSectorSize; - uiNumSectTobeRead--; - } - /* do_gettimeofday(&tv2); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Time after Write :%ld ms\n",(tv2.tv_sec *1000 + tv2.tv_usec/1000)); - * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by in Write is :%ld ms\n", (tv2.tv_sec *1000 + tv2.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000)); - * - * Cleanup. - */ -BeceemFlashBulkWrite_EXIT: - if (ulStatus) - BcmRestoreBlockProtectStatus(Adapter, ulStatus); - - kfree(pTempBuff); - - Adapter->SelectedChip = RESET_CHIP_SELECT; - return Status; -} - -/* - * Procedure: BeceemFlashBulkWriteStatus - * - * Description: Writes to Flash. Checks the SPI status after each write. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Data to be written. - * uiOffset - Offset of the flash where data needs to be written to. - * uiNumBytes - Number of bytes to be written. - * bVerify - read verify flag. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int BeceemFlashBulkWriteStatus(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes, - bool bVerify) -{ - PCHAR pTempBuff = NULL; - PUCHAR pcBuffer = (PUCHAR)pBuffer; - unsigned int uiIndex = 0; - unsigned int uiOffsetFromSectStart = 0; - unsigned int uiSectAlignAddr = 0; - unsigned int uiCurrSectOffsetAddr = 0; - unsigned int uiSectBoundary = 0; - unsigned int uiNumSectTobeRead = 0; - UCHAR ucReadBk[16] = {0}; - ULONG ulStatus = 0; - unsigned int Status = STATUS_SUCCESS; - unsigned int uiTemp = 0; - unsigned int index = 0; - unsigned int uiPartOffset = 0; - - uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1); - - /* uiOffset += Adapter->ulFlashCalStart; - * Adding flash Base address - * uiOffset = uiOffset + GetFlashBaseAddr(Adapter); - */ - uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); - uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1); - uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize; - - pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL); - if (!pTempBuff) - goto BeceemFlashBulkWriteStatus_EXIT; - - /* - * check if the data to be written is overlapped across sectors - */ - if (uiOffset+uiNumBytes < uiSectBoundary) { - uiNumSectTobeRead = 1; - } else { - /* Number of sectors = Last sector start address/First sector start address */ - uiNumSectTobeRead = (uiCurrSectOffsetAddr + uiNumBytes) / Adapter->uiSectorSize; - if ((uiCurrSectOffsetAddr + uiNumBytes)%Adapter->uiSectorSize) - uiNumSectTobeRead++; - } - - if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == false)) { - index = 0; - uiTemp = uiNumSectTobeRead; - while (uiTemp) { - if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%x> is not writable", - (uiOffsetFromSectStart + index * Adapter->uiSectorSize)); - Status = SECTOR_IS_NOT_WRITABLE; - goto BeceemFlashBulkWriteStatus_EXIT; - } - uiTemp = uiTemp - 1; - index = index + 1; - } - } - - Adapter->SelectedChip = RESET_CHIP_SELECT; - while (uiNumSectTobeRead) { - uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - - BcmDoChipSelect(Adapter, uiSectAlignAddr); - if (0 != BeceemFlashBulkRead(Adapter, - (PUINT)pTempBuff, - uiOffsetFromSectStart, - Adapter->uiSectorSize)) { - Status = -1; - goto BeceemFlashBulkWriteStatus_EXIT; - } - - ulStatus = BcmFlashUnProtectBlock(Adapter, uiOffsetFromSectStart, Adapter->uiSectorSize); - - if (uiNumSectTobeRead > 1) { - memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)); - pcBuffer += ((uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr))); - uiNumBytes -= (uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)); - } else { - memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiNumBytes); - } - - if (IsFlash2x(Adapter)) - SaveHeaderIfPresent(Adapter, (PUCHAR)pTempBuff, uiOffsetFromSectStart); - - FlashSectorErase(Adapter, uiPartOffset, 1); - - for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += Adapter->ulFlashWriteSize) { - if (Adapter->device_removed) { - Status = -1; - goto BeceemFlashBulkWriteStatus_EXIT; - } - - if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset+uiIndex, &pTempBuff[uiIndex])) { - Status = -1; - goto BeceemFlashBulkWriteStatus_EXIT; - } - } - - if (bVerify) { - for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += MAX_RW_SIZE) { - if (STATUS_SUCCESS == BeceemFlashBulkRead(Adapter, (PUINT)ucReadBk, uiOffsetFromSectStart + uiIndex, MAX_RW_SIZE)) { - if (memcmp(ucReadBk, &pTempBuff[uiIndex], MAX_RW_SIZE)) { - Status = STATUS_FAILURE; - goto BeceemFlashBulkWriteStatus_EXIT; - } - } - } - } - - if (ulStatus) { - BcmRestoreBlockProtectStatus(Adapter, ulStatus); - ulStatus = 0; - } - - uiCurrSectOffsetAddr = 0; - uiSectAlignAddr = uiSectBoundary; - uiSectBoundary += Adapter->uiSectorSize; - uiOffsetFromSectStart += Adapter->uiSectorSize; - uiNumSectTobeRead--; - } -/* - * Cleanup. - */ -BeceemFlashBulkWriteStatus_EXIT: - if (ulStatus) - BcmRestoreBlockProtectStatus(Adapter, ulStatus); - - kfree(pTempBuff); - Adapter->SelectedChip = RESET_CHIP_SELECT; - return Status; -} - -/* - * Procedure: PropagateCalParamsFromFlashToMemory - * - * Description: Dumps the calibration section of EEPROM to DDR. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * Returns: - * OSAL_STATUS_CODE - * - */ - -int PropagateCalParamsFromFlashToMemory(struct bcm_mini_adapter *Adapter) -{ - PCHAR pBuff, pPtr; - unsigned int uiEepromSize = 0; - unsigned int uiBytesToCopy = 0; - /* unsigned int uiIndex = 0; */ - unsigned int uiCalStartAddr = EEPROM_CALPARAM_START; - unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC; - unsigned int value; - int Status = 0; - - /* - * Write the signature first. This will ensure firmware does not access EEPROM. - */ - value = 0xbeadbead; - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); - value = 0xbeadbead; - wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); - - if (0 != BeceemNVMRead(Adapter, &uiEepromSize, EEPROM_SIZE_OFFSET, 4)) - return -1; - - uiEepromSize = ntohl(uiEepromSize); - uiEepromSize >>= 16; - - /* - * subtract the auto init section size - */ - uiEepromSize -= EEPROM_CALPARAM_START; - - if (uiEepromSize > 1024 * 1024) - return -1; - - pBuff = kmalloc(uiEepromSize, GFP_KERNEL); - if (pBuff == NULL) - return -ENOMEM; - - if (0 != BeceemNVMRead(Adapter, (PUINT)pBuff, uiCalStartAddr, uiEepromSize)) { - kfree(pBuff); - return -1; - } - - pPtr = pBuff; - - uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize); - - while (uiBytesToCopy) { - Status = wrm(Adapter, uiMemoryLoc, (PCHAR)pPtr, uiBytesToCopy); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm failed with status :%d", Status); - break; - } - - pPtr += uiBytesToCopy; - uiEepromSize -= uiBytesToCopy; - uiMemoryLoc += uiBytesToCopy; - uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize); - } - - kfree(pBuff); - return Status; -} - -/* - * Procedure: BeceemEEPROMReadBackandVerify - * - * Description: Read back the data written and verifies. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Data to be written. - * uiOffset - Offset of the flash where data needs to be written to. - * uiNumBytes - Number of bytes to be written. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int BeceemEEPROMReadBackandVerify(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes) -{ - unsigned int uiRdbk = 0; - unsigned int uiIndex = 0; - unsigned int uiData = 0; - unsigned int auiData[4] = {0}; - - while (uiNumBytes) { - if (Adapter->device_removed) - return -1; - - if (uiNumBytes >= MAX_RW_SIZE) { - /* for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. */ - BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE); - - if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE)) { - /* re-write */ - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, MAX_RW_SIZE, false); - mdelay(3); - BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE); - - if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE)) - return -1; - } - uiOffset += MAX_RW_SIZE; - uiNumBytes -= MAX_RW_SIZE; - uiIndex += 4; - } else if (uiNumBytes >= 4) { - BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4); - if (uiData != pBuffer[uiIndex]) { - /* re-write */ - BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, 4, false); - mdelay(3); - BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4); - if (uiData != pBuffer[uiIndex]) - return -1; - } - uiOffset += 4; - uiNumBytes -= 4; - uiIndex++; - } else { - /* Handle the reads less than 4 bytes... */ - uiData = 0; - memcpy(&uiData, ((PUCHAR)pBuffer) + (uiIndex * sizeof(unsigned int)), uiNumBytes); - BeceemEEPROMBulkRead(Adapter, &uiRdbk, uiOffset, 4); - - if (memcmp(&uiData, &uiRdbk, uiNumBytes)) - return -1; - - uiNumBytes = 0; - } - } - - return 0; -} - -static VOID BcmSwapWord(unsigned int *ptr1) -{ - unsigned int tempval = (unsigned int)*ptr1; - char *ptr2 = (char *)&tempval; - char *ptr = (char *)ptr1; - - ptr[0] = ptr2[3]; - ptr[1] = ptr2[2]; - ptr[2] = ptr2[1]; - ptr[3] = ptr2[0]; -} - -/* - * Procedure: BeceemEEPROMWritePage - * - * Description: Performs page write (16bytes) to the EEPROM - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiData - Data to be written. - * uiOffset - Offset of the EEPROM where data needs to be written to. - * Returns: - * OSAL_STATUS_CODE - * - */ - -static int BeceemEEPROMWritePage(struct bcm_mini_adapter *Adapter, unsigned int uiData[], unsigned int uiOffset) -{ - unsigned int uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY; - unsigned int uiStatus = 0; - UCHAR uiEpromStatus = 0; - unsigned int value = 0; - - /* Flush the Write/Read/Cmd queues. */ - value = (EEPROM_WRITE_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH | EEPROM_READ_QUEUE_FLUSH); - wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); - value = 0; - wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); - - /* Clear the Empty/Avail/Full bits. After this it has been confirmed - * that the bit was cleared by reading back the register. See NOTE below. - * We also clear the Read queues as we do a EEPROM status register read - * later. - */ - value = (EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL | EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - - /* Enable write */ - value = EEPROM_WRITE_ENABLE; - wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); - - /* We can write back to back 8bits * 16 into the queue and as we have - * checked for the queue to be empty we can write in a burst. - */ - - value = uiData[0]; - BcmSwapWord(&value); - wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); - - value = uiData[1]; - BcmSwapWord(&value); - wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); - - value = uiData[2]; - BcmSwapWord(&value); - wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); - - value = uiData[3]; - BcmSwapWord(&value); - wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4); - - /* NOTE : After this write, on readback of EEPROM_SPI_Q_STATUS1_REG - * shows that we see 7 for the EEPROM data write. Which means that - * queue got full, also space is available as well as the queue is empty. - * This may happen in sequence. - */ - value = EEPROM_16_BYTE_PAGE_WRITE | uiOffset; - wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); - - /* Ideally we should loop here without tries and eventually succeed. - * What we are checking if the previous write has completed, and this - * may take time. We should wait till the Empty bit is set. - */ - uiStatus = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); - while ((uiStatus & EEPROM_WRITE_QUEUE_EMPTY) == 0) { - uiRetries--; - if (uiRetries == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, %d retries failed.\n", uiStatus, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY); - return STATUS_FAILURE; - } - - if (!(uiRetries%RETRIES_PER_DELAY)) - udelay(1000); - - uiStatus = 0; - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); - if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem got removed hence exiting from loop...."); - return -ENODEV; - } - } - - if (uiRetries != 0) { - /* Clear the ones that are set - either, Empty/Full/Avail bits */ - value = (uiStatus & (EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL)); - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - } - - /* Here we should check if the EEPROM status register is correct before - * proceeding. Bit 0 in the EEPROM Status register should be 0 before - * we proceed further. A 1 at Bit 0 indicates that the EEPROM is busy - * with the previous write. Note also that issuing this read finally - * means the previous write to the EEPROM has completed. - */ - uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY; - uiEpromStatus = 0; - while (uiRetries != 0) { - uiEpromStatus = ReadEEPROMStatusRegister(Adapter); - if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting from loop..."); - return -ENODEV; - } - if ((EEPROM_STATUS_REG_WRITE_BUSY & uiEpromStatus) == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM status register = %x tries = %d\n", uiEpromStatus, (MAX_EEPROM_RETRIES * RETRIES_PER_DELAY - uiRetries)); - return STATUS_SUCCESS; - } - uiRetries--; - if (uiRetries == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, for EEPROM status read %d retries failed.\n", uiEpromStatus, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY); - return STATUS_FAILURE; - } - uiEpromStatus = 0; - if (!(uiRetries%RETRIES_PER_DELAY)) - udelay(1000); - } - - return STATUS_SUCCESS; -} /* BeceemEEPROMWritePage */ - -/* - * Procedure: BeceemEEPROMBulkWrite - * - * Description: Performs write to the EEPROM - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Data to be written. - * uiOffset - Offset of the EEPROM where data needs to be written to. - * uiNumBytes - Number of bytes to be written. - * bVerify - read verify flag. - * Returns: - * OSAL_STATUS_CODE - * - */ - -int BeceemEEPROMBulkWrite(struct bcm_mini_adapter *Adapter, - PUCHAR pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes, - bool bVerify) -{ - unsigned int uiBytesToCopy = uiNumBytes; - /* unsigned int uiRdbk = 0; */ - unsigned int uiData[4] = {0}; - unsigned int uiIndex = 0; - unsigned int uiTempOffset = 0; - unsigned int uiExtraBytes = 0; - /* PUINT puiBuffer = (PUINT)pBuffer; - * int value; - */ - - if (uiOffset % MAX_RW_SIZE && uiBytesToCopy) { - uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE); - uiExtraBytes = uiOffset - uiTempOffset; - - BeceemEEPROMBulkRead(Adapter, &uiData[0], uiTempOffset, MAX_RW_SIZE); - - if (uiBytesToCopy >= (16 - uiExtraBytes)) { - memcpy((((PUCHAR)&uiData[0]) + uiExtraBytes), pBuffer, MAX_RW_SIZE - uiExtraBytes); - - if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiTempOffset)) - return STATUS_FAILURE; - - uiBytesToCopy -= (MAX_RW_SIZE - uiExtraBytes); - uiIndex += (MAX_RW_SIZE - uiExtraBytes); - uiOffset += (MAX_RW_SIZE - uiExtraBytes); - } else { - memcpy((((PUCHAR)&uiData[0]) + uiExtraBytes), pBuffer, uiBytesToCopy); - - if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiTempOffset)) - return STATUS_FAILURE; - - uiIndex += uiBytesToCopy; - uiOffset += uiBytesToCopy; - uiBytesToCopy = 0; - } - } - - while (uiBytesToCopy) { - if (Adapter->device_removed) - return -1; - - if (uiBytesToCopy >= MAX_RW_SIZE) { - if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, (PUINT) &pBuffer[uiIndex], uiOffset)) - return STATUS_FAILURE; - - uiIndex += MAX_RW_SIZE; - uiOffset += MAX_RW_SIZE; - uiBytesToCopy -= MAX_RW_SIZE; - } else { - /* - * To program non 16byte aligned data, read 16byte and then update. - */ - BeceemEEPROMBulkRead(Adapter, &uiData[0], uiOffset, 16); - memcpy(&uiData[0], pBuffer + uiIndex, uiBytesToCopy); - - if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiOffset)) - return STATUS_FAILURE; - - uiBytesToCopy = 0; - } - } - - return 0; -} - -/* - * Procedure: BeceemNVMRead - * - * Description: Reads n number of bytes from NVM. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Buffer to store the data read from NVM - * uiOffset - Offset of NVM from where data should be read - * uiNumBytes - Number of bytes to be read from the NVM. - * - * Returns: - * OSAL_STATUS_SUCCESS - if NVM read is successful. - * - if failed. - */ - -int BeceemNVMRead(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes) -{ - int Status = 0; - - #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) - unsigned int uiTemp = 0, value; - #endif - - if (Adapter->eNVMType == NVM_FLASH) { - if (Adapter->bFlashRawRead == false) { - if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD)) - return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes); - - uiOffset = uiOffset + Adapter->ulFlashCalStart; - } - - #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) - Status = bcmflash_raw_read((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes); - #else - rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - value = 0; - wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); - Status = BeceemFlashBulkRead(Adapter, - pBuffer, - uiOffset, - uiNumBytes); - wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - #endif - } else if (Adapter->eNVMType == NVM_EEPROM) { - Status = BeceemEEPROMBulkRead(Adapter, - pBuffer, - uiOffset, - uiNumBytes); - } else { - Status = -1; - } - - return Status; -} - -/* - * Procedure: BeceemNVMWrite - * - * Description: Writes n number of bytes to NVM. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pBuffer - Buffer contains the data to be written. - * uiOffset - Offset of NVM where data to be written to. - * uiNumBytes - Number of bytes to be written.. - * - * Returns: - * OSAL_STATUS_SUCCESS - if NVM write is successful. - * - if failed. - */ - -int BeceemNVMWrite(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - unsigned int uiOffset, - unsigned int uiNumBytes, - bool bVerify) -{ - int Status = 0; - unsigned int uiTemp = 0; - unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC; - unsigned int uiIndex = 0; - - #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) - unsigned int value; - #endif - - unsigned int uiFlashOffset = 0; - - if (Adapter->eNVMType == NVM_FLASH) { - if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD)) - Status = vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes, bVerify); - else { - uiFlashOffset = uiOffset + Adapter->ulFlashCalStart; - - #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) - Status = bcmflash_raw_write((uiFlashOffset / FLASH_PART_SIZE), (uiFlashOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes); - #else - rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - value = 0; - wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); - - if (Adapter->bStatusWrite == TRUE) - Status = BeceemFlashBulkWriteStatus(Adapter, - pBuffer, - uiFlashOffset, - uiNumBytes , - bVerify); - else - - Status = BeceemFlashBulkWrite(Adapter, - pBuffer, - uiFlashOffset, - uiNumBytes, - bVerify); - #endif - } - - if (uiOffset >= EEPROM_CALPARAM_START) { - uiMemoryLoc += (uiOffset - EEPROM_CALPARAM_START); - while (uiNumBytes) { - if (uiNumBytes > BUFFER_4K) { - wrm(Adapter, (uiMemoryLoc+uiIndex), (PCHAR)(pBuffer + (uiIndex / 4)), BUFFER_4K); - uiNumBytes -= BUFFER_4K; - uiIndex += BUFFER_4K; - } else { - wrm(Adapter, uiMemoryLoc+uiIndex, (PCHAR)(pBuffer + (uiIndex / 4)), uiNumBytes); - uiNumBytes = 0; - break; - } - } - } else { - if ((uiOffset + uiNumBytes) > EEPROM_CALPARAM_START) { - ULONG ulBytesTobeSkipped = 0; - PUCHAR pcBuffer = (PUCHAR)pBuffer; /* char pointer to take care of odd byte cases. */ - - uiNumBytes -= (EEPROM_CALPARAM_START - uiOffset); - ulBytesTobeSkipped += (EEPROM_CALPARAM_START - uiOffset); - uiOffset += (EEPROM_CALPARAM_START - uiOffset); - while (uiNumBytes) { - if (uiNumBytes > BUFFER_4K) { - wrm(Adapter, uiMemoryLoc + uiIndex, (PCHAR)&pcBuffer[ulBytesTobeSkipped + uiIndex], BUFFER_4K); - uiNumBytes -= BUFFER_4K; - uiIndex += BUFFER_4K; - } else { - wrm(Adapter, uiMemoryLoc + uiIndex, (PCHAR)&pcBuffer[ulBytesTobeSkipped + uiIndex], uiNumBytes); - uiNumBytes = 0; - break; - } - } - } - } - /* restore the values. */ - wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - } else if (Adapter->eNVMType == NVM_EEPROM) { - Status = BeceemEEPROMBulkWrite(Adapter, - (PUCHAR)pBuffer, - uiOffset, - uiNumBytes, - bVerify); - if (bVerify) - Status = BeceemEEPROMReadBackandVerify(Adapter, (PUINT)pBuffer, uiOffset, uiNumBytes); - } else { - Status = -1; - } - return Status; -} - -/* - * Procedure: BcmUpdateSectorSize - * - * Description: Updates the sector size to FLASH. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * uiSectorSize - sector size - * - * Returns: - * OSAL_STATUS_SUCCESS - if NVM write is successful. - * - if failed. - */ - -int BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, unsigned int uiSectorSize) -{ - int Status = -1; - struct bcm_flash_cs_info sFlashCsInfo = {0}; - unsigned int uiTemp = 0; - unsigned int uiSectorSig = 0; - unsigned int uiCurrentSectorSize = 0; - unsigned int value; - - rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - value = 0; - wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); - - /* - * Before updating the sector size in the reserved area, check if already present. - */ - BeceemFlashBulkRead(Adapter, (PUINT)&sFlashCsInfo, Adapter->ulFlashControlSectionStart, sizeof(sFlashCsInfo)); - uiSectorSig = ntohl(sFlashCsInfo.FlashSectorSizeSig); - uiCurrentSectorSize = ntohl(sFlashCsInfo.FlashSectorSize); - - if (uiSectorSig == FLASH_SECTOR_SIZE_SIG) { - if ((uiCurrentSectorSize <= MAX_SECTOR_SIZE) && (uiCurrentSectorSize >= MIN_SECTOR_SIZE)) { - if (uiSectorSize == uiCurrentSectorSize) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Provided sector size is same as programmed in Flash"); - Status = STATUS_SUCCESS; - goto Restore; - } - } - } - - if ((uiSectorSize <= MAX_SECTOR_SIZE) && (uiSectorSize >= MIN_SECTOR_SIZE)) { - sFlashCsInfo.FlashSectorSize = htonl(uiSectorSize); - sFlashCsInfo.FlashSectorSizeSig = htonl(FLASH_SECTOR_SIZE_SIG); - - Status = BeceemFlashBulkWrite(Adapter, - (PUINT)&sFlashCsInfo, - Adapter->ulFlashControlSectionStart, - sizeof(sFlashCsInfo), - TRUE); - } - -Restore: - /* restore the values. */ - wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - - return Status; -} - -/* - * Procedure: BcmGetFlashSectorSize - * - * Description: Finds the sector size of the FLASH. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * unsigned int - sector size. - * - */ - -static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsigned int FlashSectorSizeSig, unsigned int FlashSectorSize) -{ - unsigned int uiSectorSize = 0; - unsigned int uiSectorSig = 0; - - if (Adapter->bSectorSizeOverride && - (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE && - Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)) { - Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG; - } else { - uiSectorSig = FlashSectorSizeSig; - - if (uiSectorSig == FLASH_SECTOR_SIZE_SIG) { - uiSectorSize = FlashSectorSize; - /* - * If the sector size stored in the FLASH makes sense then use it. - */ - if (uiSectorSize <= MAX_SECTOR_SIZE && uiSectorSize >= MIN_SECTOR_SIZE) { - Adapter->uiSectorSize = uiSectorSize; - } else if (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE && - Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE) { - /* No valid size in FLASH, check if Config file has it. */ - Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG; - } else { - /* Init to Default, if none of the above works. */ - Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE; - } - } else { - if (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE && - Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE) - Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG; - else - Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE; - } - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector size :%x\n", Adapter->uiSectorSize); - - return Adapter->uiSectorSize; -} - -/* - * Procedure: BcmInitEEPROMQueues - * - * Description: Initialization of EEPROM queues. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * - */ - -static int BcmInitEEPROMQueues(struct bcm_mini_adapter *Adapter) -{ - unsigned int value = 0; - /* CHIP Bug : Clear the Avail bits on the Read queue. The default - * value on this register is supposed to be 0x00001102. - * But we get 0x00001122. - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Fixing reset value on 0x0f003004 register\n"); - value = EEPROM_READ_DATA_AVAIL; - wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - - /* Flush the all the EEPROM queues. */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Flushing the queues\n"); - value = EEPROM_ALL_QUEUE_FLUSH; - wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); - - value = 0; - wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); - - /* Read the EEPROM Status Register. Just to see, no real purpose. */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "EEPROM Status register value = %x\n", ReadEEPROMStatusRegister(Adapter)); - - return STATUS_SUCCESS; -} /* BcmInitEEPROMQueues() */ - -/* - * Procedure: BcmInitNVM - * - * Description: Initialization of NVM, EEPROM size,FLASH size, sector size etc. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * - */ - -int BcmInitNVM(struct bcm_mini_adapter *ps_adapter) -{ - BcmValidateNvmType(ps_adapter); - BcmInitEEPROMQueues(ps_adapter); - - if (ps_adapter->eNVMType == NVM_AUTODETECT) { - ps_adapter->eNVMType = BcmGetNvmType(ps_adapter); - if (ps_adapter->eNVMType == NVM_UNKNOWN) - BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "NVM Type is unknown!!\n"); - } else if (ps_adapter->eNVMType == NVM_FLASH) { - BcmGetFlashCSInfo(ps_adapter); - } - - BcmGetNvmSize(ps_adapter); - - return STATUS_SUCCESS; -} - -/* BcmGetNvmSize : set the EEPROM or flash size in Adapter. - * - * Input Parameter: - * Adapter data structure - * Return Value : - * 0. means success; - */ - -static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter) -{ - if (Adapter->eNVMType == NVM_EEPROM) - Adapter->uiNVMDSDSize = BcmGetEEPROMSize(Adapter); - else if (Adapter->eNVMType == NVM_FLASH) - Adapter->uiNVMDSDSize = BcmGetFlashSize(Adapter); - - return 0; -} - -/* - * Procedure: BcmValidateNvm - * - * Description: Validates the NVM Type option selected against the device - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * - */ - -static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter) -{ - /* - * if forcing the FLASH through CFG file, we should ensure device really has a FLASH. - * Accessing the FLASH address without the FLASH being present can cause hang/freeze etc. - * So if NVM_FLASH is selected for older chipsets, change it to AUTODETECT where EEPROM is 1st choice. - */ - - if (Adapter->eNVMType == NVM_FLASH && - Adapter->chip_id < 0xBECE3300) - Adapter->eNVMType = NVM_AUTODETECT; -} - -/* - * Procedure: BcmReadFlashRDID - * - * Description: Reads ID from Serial Flash - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * Flash ID - */ - -static ULONG BcmReadFlashRDID(struct bcm_mini_adapter *Adapter) -{ - ULONG ulRDID = 0; - unsigned int value; - - /* - * Read ID Instruction. - */ - value = (FLASH_CMD_READ_ID << 24); - wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); - - /* Delay */ - udelay(10); - - /* - * Read SPI READQ REG. The output will be WWXXYYZZ. - * The ID is 3Bytes long and is WWXXYY. ZZ needs to be Ignored. - */ - rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulRDID, sizeof(ulRDID)); - - return ulRDID >> 8; -} - -int BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter) -{ - if (!psAdapter) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL"); - return -EINVAL; - } - psAdapter->psFlashCSInfo = kzalloc(sizeof(struct bcm_flash_cs_info), GFP_KERNEL); - if (psAdapter->psFlashCSInfo == NULL) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 1.x"); - return -ENOMEM; - } - - psAdapter->psFlash2xCSInfo = kzalloc(sizeof(struct bcm_flash2x_cs_info), GFP_KERNEL); - if (!psAdapter->psFlash2xCSInfo) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 2.x"); - kfree(psAdapter->psFlashCSInfo); - return -ENOMEM; - } - - psAdapter->psFlash2xVendorInfo = kzalloc(sizeof(struct bcm_flash2x_vendor_info), GFP_KERNEL); - if (!psAdapter->psFlash2xVendorInfo) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate Vendor Info Memory for Flash 2.x"); - kfree(psAdapter->psFlashCSInfo); - kfree(psAdapter->psFlash2xCSInfo); - return -ENOMEM; - } - - return STATUS_SUCCESS; -} - -int BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter) -{ - if (!psAdapter) { - BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL"); - return -EINVAL; - } - kfree(psAdapter->psFlashCSInfo); - kfree(psAdapter->psFlash2xCSInfo); - kfree(psAdapter->psFlash2xVendorInfo); - return STATUS_SUCCESS; -} - -static int BcmDumpFlash2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo, struct bcm_mini_adapter *Adapter) -{ - unsigned int Index = 0; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "**********************FLASH2X CS Structure *******************"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x", (psFlash2xCSInfo->MagicNumber)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Major Version :%d", MAJOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Minor Version :%d", MINOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ISOImageMajorVersion:0x%x", (psFlash2xCSInfo->ISOImageVersion)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSIFirmwareMajorVersion :0x%x", (psFlash2xCSInfo->SCSIFirmwareVersion)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart1ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForScsiFirmware :0x%x", (psFlash2xCSInfo->OffsetFromZeroForScsiFirmware)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SizeOfScsiFirmware :0x%x", (psFlash2xCSInfo->SizeOfScsiFirmware)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart2ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDStart)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDEnd)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAStart)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAEnd)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionStart)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionData :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionData)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CDLessInactivityTimeout :0x%x", (psFlash2xCSInfo->CDLessInactivityTimeout)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "NewImageSignature :0x%x", (psFlash2xCSInfo->NewImageSignature)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSizeSig :0x%x", (psFlash2xCSInfo->FlashSectorSizeSig)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSize :0x%x", (psFlash2xCSInfo->FlashSectorSize)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashWriteSupportSize :0x%x", (psFlash2xCSInfo->FlashWriteSupportSize)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "TotalFlashSize :0x%X", (psFlash2xCSInfo->TotalFlashSize)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashBaseAddr :0x%x", (psFlash2xCSInfo->FlashBaseAddr)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashPartMaxSize :0x%x", (psFlash2xCSInfo->FlashPartMaxSize)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "IsCDLessDeviceBootSig :0x%x", (psFlash2xCSInfo->IsCDLessDeviceBootSig)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "MassStorageTimeout :0x%x", (psFlash2xCSInfo->MassStorageTimeout)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromDSDStartForDSDHeader :0x%x", (psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2Start)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2End)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector Access Bit Map is Defined as :"); - - for (Index = 0; Index < (FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)); Index++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectorAccessBitMap[%d] :0x%x", Index, - (psFlash2xCSInfo->SectorAccessBitMap[Index])); - - return STATUS_SUCCESS; -} - -static int ConvertEndianOf2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo) -{ - unsigned int Index = 0; - - psFlash2xCSInfo->MagicNumber = ntohl(psFlash2xCSInfo->MagicNumber); - psFlash2xCSInfo->FlashLayoutVersion = ntohl(psFlash2xCSInfo->FlashLayoutVersion); - /* psFlash2xCSInfo->FlashLayoutMinorVersion = ntohs(psFlash2xCSInfo->FlashLayoutMinorVersion); */ - psFlash2xCSInfo->ISOImageVersion = ntohl(psFlash2xCSInfo->ISOImageVersion); - psFlash2xCSInfo->SCSIFirmwareVersion = ntohl(psFlash2xCSInfo->SCSIFirmwareVersion); - psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage); - psFlash2xCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlash2xCSInfo->OffsetFromZeroForScsiFirmware); - psFlash2xCSInfo->SizeOfScsiFirmware = ntohl(psFlash2xCSInfo->SizeOfScsiFirmware); - psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage); - psFlash2xCSInfo->OffsetFromZeroForDSDStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDStart); - psFlash2xCSInfo->OffsetFromZeroForDSDEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDEnd); - psFlash2xCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSAStart); - psFlash2xCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSAEnd); - psFlash2xCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForControlSectionStart); - psFlash2xCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlash2xCSInfo->OffsetFromZeroForControlSectionData); - psFlash2xCSInfo->CDLessInactivityTimeout = ntohl(psFlash2xCSInfo->CDLessInactivityTimeout); - psFlash2xCSInfo->NewImageSignature = ntohl(psFlash2xCSInfo->NewImageSignature); - psFlash2xCSInfo->FlashSectorSizeSig = ntohl(psFlash2xCSInfo->FlashSectorSizeSig); - psFlash2xCSInfo->FlashSectorSize = ntohl(psFlash2xCSInfo->FlashSectorSize); - psFlash2xCSInfo->FlashWriteSupportSize = ntohl(psFlash2xCSInfo->FlashWriteSupportSize); - psFlash2xCSInfo->TotalFlashSize = ntohl(psFlash2xCSInfo->TotalFlashSize); - psFlash2xCSInfo->FlashBaseAddr = ntohl(psFlash2xCSInfo->FlashBaseAddr); - psFlash2xCSInfo->FlashPartMaxSize = ntohl(psFlash2xCSInfo->FlashPartMaxSize); - psFlash2xCSInfo->IsCDLessDeviceBootSig = ntohl(psFlash2xCSInfo->IsCDLessDeviceBootSig); - psFlash2xCSInfo->MassStorageTimeout = ntohl(psFlash2xCSInfo->MassStorageTimeout); - psFlash2xCSInfo->OffsetISOImage1Part1Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part1Start); - psFlash2xCSInfo->OffsetISOImage1Part1End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part1End); - psFlash2xCSInfo->OffsetISOImage1Part2Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part2Start); - psFlash2xCSInfo->OffsetISOImage1Part2End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part2End); - psFlash2xCSInfo->OffsetISOImage1Part3Start = ntohl(psFlash2xCSInfo->OffsetISOImage1Part3Start); - psFlash2xCSInfo->OffsetISOImage1Part3End = ntohl(psFlash2xCSInfo->OffsetISOImage1Part3End); - psFlash2xCSInfo->OffsetISOImage2Part1Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part1Start); - psFlash2xCSInfo->OffsetISOImage2Part1End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part1End); - psFlash2xCSInfo->OffsetISOImage2Part2Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part2Start); - psFlash2xCSInfo->OffsetISOImage2Part2End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part2End); - psFlash2xCSInfo->OffsetISOImage2Part3Start = ntohl(psFlash2xCSInfo->OffsetISOImage2Part3Start); - psFlash2xCSInfo->OffsetISOImage2Part3End = ntohl(psFlash2xCSInfo->OffsetISOImage2Part3End); - psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader = ntohl(psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader); - psFlash2xCSInfo->OffsetFromZeroForDSD1Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD1Start); - psFlash2xCSInfo->OffsetFromZeroForDSD1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD1End); - psFlash2xCSInfo->OffsetFromZeroForDSD2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD2Start); - psFlash2xCSInfo->OffsetFromZeroForDSD2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSD2End); - psFlash2xCSInfo->OffsetFromZeroForVSA1Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1Start); - psFlash2xCSInfo->OffsetFromZeroForVSA1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1End); - psFlash2xCSInfo->OffsetFromZeroForVSA2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2Start); - psFlash2xCSInfo->OffsetFromZeroForVSA2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2End); - - for (Index = 0; Index < (FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)); Index++) - psFlash2xCSInfo->SectorAccessBitMap[Index] = ntohl(psFlash2xCSInfo->SectorAccessBitMap[Index]); - - return STATUS_SUCCESS; -} - -static int ConvertEndianOfCSStructure(struct bcm_flash_cs_info *psFlashCSInfo) -{ - /* unsigned int Index = 0; */ - psFlashCSInfo->MagicNumber = ntohl(psFlashCSInfo->MagicNumber); - psFlashCSInfo->FlashLayoutVersion = ntohl(psFlashCSInfo->FlashLayoutVersion); - psFlashCSInfo->ISOImageVersion = ntohl(psFlashCSInfo->ISOImageVersion); - /* won't convert according to old assumption */ - psFlashCSInfo->SCSIFirmwareVersion = (psFlashCSInfo->SCSIFirmwareVersion); - psFlashCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart1ISOImage); - psFlashCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlashCSInfo->OffsetFromZeroForScsiFirmware); - psFlashCSInfo->SizeOfScsiFirmware = ntohl(psFlashCSInfo->SizeOfScsiFirmware); - psFlashCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart2ISOImage); - psFlashCSInfo->OffsetFromZeroForCalibrationStart = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationStart); - psFlashCSInfo->OffsetFromZeroForCalibrationEnd = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationEnd); - psFlashCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlashCSInfo->OffsetFromZeroForVSAStart); - psFlashCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlashCSInfo->OffsetFromZeroForVSAEnd); - psFlashCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionStart); - psFlashCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionData); - psFlashCSInfo->CDLessInactivityTimeout = ntohl(psFlashCSInfo->CDLessInactivityTimeout); - psFlashCSInfo->NewImageSignature = ntohl(psFlashCSInfo->NewImageSignature); - psFlashCSInfo->FlashSectorSizeSig = ntohl(psFlashCSInfo->FlashSectorSizeSig); - psFlashCSInfo->FlashSectorSize = ntohl(psFlashCSInfo->FlashSectorSize); - psFlashCSInfo->FlashWriteSupportSize = ntohl(psFlashCSInfo->FlashWriteSupportSize); - psFlashCSInfo->TotalFlashSize = ntohl(psFlashCSInfo->TotalFlashSize); - psFlashCSInfo->FlashBaseAddr = ntohl(psFlashCSInfo->FlashBaseAddr); - psFlashCSInfo->FlashPartMaxSize = ntohl(psFlashCSInfo->FlashPartMaxSize); - psFlashCSInfo->IsCDLessDeviceBootSig = ntohl(psFlashCSInfo->IsCDLessDeviceBootSig); - psFlashCSInfo->MassStorageTimeout = ntohl(psFlashCSInfo->MassStorageTimeout); - - return STATUS_SUCCESS; -} - -static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section) -{ - return (Adapter->uiVendorExtnFlag && - (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) && - (Adapter->psFlash2xVendorInfo->VendorSection[section].OffsetFromZeroForSectionStart != UNINIT_PTR_IN_CS)); -} - -static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter) -{ - B_UINT32 i = 0; - unsigned int uiSizeSection = 0; - - Adapter->uiVendorExtnFlag = false; - - for (i = 0; i < TOTAL_SECTIONS; i++) - Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart = UNINIT_PTR_IN_CS; - - if (STATUS_SUCCESS != vendorextnGetSectionInfo(Adapter, Adapter->psFlash2xVendorInfo)) - return; - - i = 0; - while (i < TOTAL_SECTIONS) { - if (!(Adapter->psFlash2xVendorInfo->VendorSection[i].AccessFlags & FLASH2X_SECTION_PRESENT)) { - i++; - continue; - } - - Adapter->uiVendorExtnFlag = TRUE; - uiSizeSection = (Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionEnd - - Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart); - - switch (i) { - case DSD0: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && - (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) - Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS; - else - Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = UNINIT_PTR_IN_CS; - break; - - case DSD1: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && - (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) - Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS; - else - Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = UNINIT_PTR_IN_CS; - break; - - case DSD2: - if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header))) && - (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)) - Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS; - else - Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = UNINIT_PTR_IN_CS; - break; - case VSA0: - if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart) - Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = VENDOR_PTR_IN_CS; - else - Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = UNINIT_PTR_IN_CS; - break; - - case VSA1: - if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart) - Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = VENDOR_PTR_IN_CS; - else - Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = UNINIT_PTR_IN_CS; - break; - case VSA2: - if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart) - Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = VENDOR_PTR_IN_CS; - else - Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = UNINIT_PTR_IN_CS; - break; - - default: - break; - } - i++; - } -} - -/* - * Procedure: BcmGetFlashCSInfo - * - * Description: Reads control structure and gets Cal section addresses. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * - */ - -static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter) -{ - /* struct bcm_flash_cs_info sFlashCsInfo = {0}; */ - - #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) - unsigned int value; - #endif - - unsigned int uiFlashLayoutMajorVersion; - - Adapter->uiFlashLayoutMinorVersion = 0; - Adapter->uiFlashLayoutMajorVersion = 0; - Adapter->ulFlashControlSectionStart = FLASH_CS_INFO_START_ADDR; - - Adapter->uiFlashBaseAdd = 0; - Adapter->ulFlashCalStart = 0; - memset(Adapter->psFlashCSInfo, 0 , sizeof(struct bcm_flash_cs_info)); - memset(Adapter->psFlash2xCSInfo, 0 , sizeof(struct bcm_flash2x_cs_info)); - - if (!Adapter->bDDRInitDone) { - value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; - wrmalt(Adapter, 0xAF00A080, &value, sizeof(value)); - } - - /* Reading first 8 Bytes to get the Flash Layout - * MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes) - */ - BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, 8); - - Adapter->psFlashCSInfo->FlashLayoutVersion = ntohl(Adapter->psFlashCSInfo->FlashLayoutVersion); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Version :%X", (Adapter->psFlashCSInfo->FlashLayoutVersion)); - /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Minor Version :%d\n", ntohs(sFlashCsInfo.FlashLayoutMinorVersion)); */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x\n", ntohl(Adapter->psFlashCSInfo->MagicNumber)); - - if (FLASH_CONTROL_STRUCT_SIGNATURE == ntohl(Adapter->psFlashCSInfo->MagicNumber)) { - uiFlashLayoutMajorVersion = MAJOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion)); - Adapter->uiFlashLayoutMinorVersion = MINOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion)); - } else { - Adapter->uiFlashLayoutMinorVersion = 0; - uiFlashLayoutMajorVersion = 0; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion); - - if (uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER) { - BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash_cs_info)); - ConvertEndianOfCSStructure(Adapter->psFlashCSInfo); - Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart); - - if (!((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))) - Adapter->ulFlashControlSectionStart = Adapter->psFlashCSInfo->OffsetFromZeroForControlSectionStart; - - if ((FLASH_CONTROL_STRUCT_SIGNATURE == (Adapter->psFlashCSInfo->MagicNumber)) && - (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlashCSInfo->SCSIFirmwareVersion)) && - (FLASH_SECTOR_SIZE_SIG == (Adapter->psFlashCSInfo->FlashSectorSizeSig)) && - (BYTE_WRITE_SUPPORT == (Adapter->psFlashCSInfo->FlashWriteSupportSize))) { - Adapter->ulFlashWriteSize = (Adapter->psFlashCSInfo->FlashWriteSupportSize); - Adapter->fpFlashWrite = flashByteWrite; - Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus; - } else { - Adapter->ulFlashWriteSize = MAX_RW_SIZE; - Adapter->fpFlashWrite = flashWrite; - Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus; - } - - BcmGetFlashSectorSize(Adapter, (Adapter->psFlashCSInfo->FlashSectorSizeSig), - (Adapter->psFlashCSInfo->FlashSectorSize)); - Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF; - } else { - if (BcmFlash2xBulkRead(Adapter, (PUINT)Adapter->psFlash2xCSInfo, NO_SECTION_VAL, - Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash2x_cs_info))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure\n"); - return STATUS_FAILURE; - } - - ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo); - BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo, Adapter); - if ((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) && - (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) && - (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) && - (BYTE_WRITE_SUPPORT == Adapter->psFlash2xCSInfo->FlashWriteSupportSize)) { - Adapter->ulFlashWriteSize = Adapter->psFlash2xCSInfo->FlashWriteSupportSize; - Adapter->fpFlashWrite = flashByteWrite; - Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus; - } else { - Adapter->ulFlashWriteSize = MAX_RW_SIZE; - Adapter->fpFlashWrite = flashWrite; - Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus; - } - - BcmGetFlashSectorSize(Adapter, Adapter->psFlash2xCSInfo->FlashSectorSizeSig, - Adapter->psFlash2xCSInfo->FlashSectorSize); - - UpdateVendorInfo(Adapter); - - BcmGetActiveDSD(Adapter); - BcmGetActiveISO(Adapter); - Adapter->uiFlashBaseAdd = Adapter->psFlash2xCSInfo->FlashBaseAddr & 0xFCFFFFFF; - Adapter->ulFlashControlSectionStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart; - } - /* - * Concerns: what if CS sector size does not match with this sector size ??? - * what is the indication of AccessBitMap in CS in flash 2.x ???? - */ - Adapter->ulFlashID = BcmReadFlashRDID(Adapter); - Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion; - - return STATUS_SUCCESS; -} - -/* - * Procedure: BcmGetNvmType - * - * Description: Finds the type of NVM used. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * - * Returns: - * NVM_TYPE - * - */ - -static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiData = 0; - - BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4); - if (uiData == BECM) - return NVM_EEPROM; - - /* - * Read control struct and get cal addresses before accessing the flash - */ - BcmGetFlashCSInfo(Adapter); - - BeceemFlashBulkRead(Adapter, &uiData, 0x0 + Adapter->ulFlashCalStart, 4); - if (uiData == BECM) - return NVM_FLASH; - - /* - * even if there is no valid signature on EEPROM/FLASH find out if they really exist. - * if exist select it. - */ - if (BcmGetEEPROMSize(Adapter)) - return NVM_EEPROM; - - /* TBD for Flash. */ - return NVM_UNKNOWN; -} - -/* - * BcmGetSectionValStartOffset - this will calculate the section's starting offset if section val is given - * @Adapter : Drivers Private Data structure - * @eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val - * - * Return value:- - * On success it return the start offset of the provided section val - * On Failure -returns STATUS_FAILURE - */ - -int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal) -{ - /* - * Considering all the section for which end offset can be calculated or directly given - * in CS Structure. if matching case does not exist, return STATUS_FAILURE indicating section - * endoffset can't be calculated or given in CS Structure. - */ - - int SectStartOffset = 0; - - SectStartOffset = INVALID_OFFSET; - - if (IsSectionExistInVendorInfo(Adapter, eFlashSectionVal)) - return Adapter->psFlash2xVendorInfo->VendorSection[eFlashSectionVal].OffsetFromZeroForSectionStart; - - switch (eFlashSectionVal) { - case ISO_IMAGE1: - if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == false)) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start); - break; - case ISO_IMAGE2: - if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == false)) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start); - break; - case DSD0: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart); - break; - case DSD1: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start); - break; - case DSD2: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start); - break; - case VSA0: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart); - break; - case VSA1: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start); - break; - case VSA2: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start); - break; - case SCSI: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware); - break; - case CONTROL_SECTION: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart); - break; - case ISO_IMAGE1_PART2: - if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start); - break; - case ISO_IMAGE1_PART3: - if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start); - break; - case ISO_IMAGE2_PART2: - if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start); - break; - case ISO_IMAGE2_PART3: - if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start != UNINIT_PTR_IN_CS) - SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start); - break; - default: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x"); - SectStartOffset = INVALID_OFFSET; - } - - return SectStartOffset; -} - -/* - * BcmGetSectionValEndOffset - this will calculate the section's Ending offset if section val is given - * @Adapter : Drivers Private Data structure - * @eFlashSectionVal : Flash secion value defined in enum bcm_flash2x_section_val - * - * Return value:- - * On success it return the end offset of the provided section val - * On Failure -returns STATUS_FAILURE - */ - -static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) -{ - int SectEndOffset = 0; - - SectEndOffset = INVALID_OFFSET; - if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal)) - return Adapter->psFlash2xVendorInfo->VendorSection[eFlash2xSectionVal].OffsetFromZeroForSectionEnd; - - switch (eFlash2xSectionVal) { - case ISO_IMAGE1: - if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == false)) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End); - break; - case ISO_IMAGE2: - if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == false)) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End); - break; - case DSD0: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd); - break; - case DSD1: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End); - break; - case DSD2: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End); - break; - case VSA0: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd); - break; - case VSA1: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End); - break; - case VSA2: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End); - break; - case SCSI: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS) - SectEndOffset = ((Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) + - (Adapter->psFlash2xCSInfo->SizeOfScsiFirmware)); - break; - case CONTROL_SECTION: - /* Not Clear So Putting failure. confirm and fix it. */ - SectEndOffset = STATUS_FAILURE; - break; - case ISO_IMAGE1_PART2: - if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End); - break; - case ISO_IMAGE1_PART3: - if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End); - break; - case ISO_IMAGE2_PART2: - if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End); - break; - case ISO_IMAGE2_PART3: - if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End != UNINIT_PTR_IN_CS) - SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End); - break; - default: - SectEndOffset = INVALID_OFFSET; - } - - return SectEndOffset; -} - -/* - * BcmFlash2xBulkRead:- Read API for Flash Map 2.x . - * @Adapter :Driver Private Data Structure - * @pBuffer : Buffer where data has to be put after reading - * @eFlashSectionVal :Flash Section Val defined in enum bcm_flash2x_section_val - * @uiOffsetWithinSectionVal :- Offset with in provided section - * @uiNumBytes : Number of Bytes for Read - * - * Return value:- - * return true on success and STATUS_FAILURE on fail. - */ - -int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - enum bcm_flash2x_section_val eFlash2xSectionVal, - unsigned int uiOffsetWithinSectionVal, - unsigned int uiNumBytes) -{ - int Status = STATUS_SUCCESS; - int SectionStartOffset = 0; - unsigned int uiAbsoluteOffset = 0; - unsigned int uiTemp = 0, value = 0; - - if (!Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL"); - return -EINVAL; - } - if (Adapter->device_removed) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device has been removed"); - return -ENODEV; - } - - /* NO_SECTION_VAL means absolute offset is given. */ - if (eFlash2xSectionVal == NO_SECTION_VAL) - SectionStartOffset = 0; - else - SectionStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); - - if (SectionStartOffset == STATUS_FAILURE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exist in Flash 2.x Map ", eFlash2xSectionVal); - return -EINVAL; - } - - if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal)) - return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectionVal, uiOffsetWithinSectionVal, uiNumBytes); - - /* calculating the absolute offset from FLASH; */ - uiAbsoluteOffset = uiOffsetWithinSectionVal + SectionStartOffset; - rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - value = 0; - wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); - Status = BeceemFlashBulkRead(Adapter, pBuffer, uiAbsoluteOffset, uiNumBytes); - wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Read Failed with Status :%d", Status); - return Status; - } - - return Status; -} - -/* - * BcmFlash2xBulkWrite :-API for Writing on the Flash Map 2.x. - * @Adapter :Driver Private Data Structure - * @pBuffer : Buffer From where data has to taken for writing - * @eFlashSectionVal :Flash Section Val defined in enum bcm_flash2x_section_val - * @uiOffsetWithinSectionVal :- Offset with in provided section - * @uiNumBytes : Number of Bytes for Write - * - * Return value:- - * return true on success and STATUS_FAILURE on fail. - * - */ - -int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - enum bcm_flash2x_section_val eFlash2xSectVal, - unsigned int uiOffset, - unsigned int uiNumBytes, - unsigned int bVerify) -{ - int Status = STATUS_SUCCESS; - unsigned int FlashSectValStartOffset = 0; - unsigned int uiTemp = 0, value = 0; - - if (!Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL"); - return -EINVAL; - } - - if (Adapter->device_removed) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device has been removed"); - return -ENODEV; - } - - /* NO_SECTION_VAL means absolute offset is given. */ - if (eFlash2xSectVal == NO_SECTION_VAL) - FlashSectValStartOffset = 0; - else - FlashSectValStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectVal); - - if (FlashSectValStartOffset == STATUS_FAILURE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exist in Flash Map 2.x", eFlash2xSectVal); - return -EINVAL; - } - - if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectVal)) - return vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectVal, uiOffset, uiNumBytes, bVerify); - - /* calculating the absolute offset from FLASH; */ - uiOffset = uiOffset + FlashSectValStartOffset; - - rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - value = 0; - wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); - - Status = BeceemFlashBulkWrite(Adapter, pBuffer, uiOffset, uiNumBytes, bVerify); - - wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write failed with Status :%d", Status); - return Status; - } - - return Status; -} - -/* - * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR - * @Adapter :-Drivers private Data Structure - * - * Return Value:- - * Return STATUS_SUCESS if get success in setting the right DSD else negative error code - * - */ - -static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter) -{ - enum bcm_flash2x_section_val uiHighestPriDSD = 0; - - uiHighestPriDSD = getHighestPriDSD(Adapter); - Adapter->eActiveDSD = uiHighestPriDSD; - - if (DSD0 == uiHighestPriDSD) - Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart; - if (DSD1 == uiHighestPriDSD) - Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start; - if (DSD2 == uiHighestPriDSD) - Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start; - if (Adapter->eActiveDSD) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active DSD :%d", Adapter->eActiveDSD); - if (Adapter->eActiveDSD == 0) { - /* if No DSD gets Active, Make Active the DSD with WR permission */ - if (IsSectionWritable(Adapter, DSD2)) { - Adapter->eActiveDSD = DSD2; - Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start; - } else if (IsSectionWritable(Adapter, DSD1)) { - Adapter->eActiveDSD = DSD1; - Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start; - } else if (IsSectionWritable(Adapter, DSD0)) { - Adapter->eActiveDSD = DSD0; - Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart; - } - } - - return STATUS_SUCCESS; -} - -/* - * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue - * @Adapter : Driver private Data Structure - * - * Return Value:- - * Sucsess:- STATUS_SUCESS - * Failure- : negative erro code - * - */ - -static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter) -{ - int HighestPriISO = 0; - - HighestPriISO = getHighestPriISO(Adapter); - - Adapter->eActiveISO = HighestPriISO; - if (Adapter->eActiveISO == ISO_IMAGE2) - Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start); - else if (Adapter->eActiveISO == ISO_IMAGE1) - Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start); - - if (Adapter->eActiveISO) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active ISO :%x", Adapter->eActiveISO); - - return STATUS_SUCCESS; -} - -/* - * IsOffsetWritable :- it will tell the access permission of the sector having passed offset - * @Adapter : Drivers Private Data Structure - * @uiOffset : Offset provided in the Flash - * - * Return Value:- - * Success:-TRUE , offset is writable - * Failure:-false, offset is RO - * - */ - -static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset) -{ - unsigned int uiSectorNum = 0; - unsigned int uiWordOfSectorPermission = 0; - unsigned int uiBitofSectorePermission = 0; - B_UINT32 permissionBits = 0; - - uiSectorNum = uiOffset/Adapter->uiSectorSize; - - /* calculating the word having this Sector Access permission from SectorAccessBitMap Array */ - uiWordOfSectorPermission = Adapter->psFlash2xCSInfo->SectorAccessBitMap[uiSectorNum / 16]; - - /* calculating the bit index inside the word for this sector */ - uiBitofSectorePermission = 2 * (15 - uiSectorNum % 16); - - /* Setting Access permission */ - permissionBits = uiWordOfSectorPermission & (0x3 << uiBitofSectorePermission); - permissionBits = (permissionBits >> uiBitofSectorePermission) & 0x3; - if (permissionBits == SECTOR_READWRITE_PERMISSION) - return TRUE; - else - return false; -} - -static int BcmDumpFlash2xSectionBitMap(struct bcm_flash2x_bitmap *psFlash2xBitMap) -{ - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "***************Flash 2.x Section Bitmap***************"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO_IMAGE1 :0X%x", psFlash2xBitMap->ISO_IMAGE1); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO_IMAGE2 :0X%x", psFlash2xBitMap->ISO_IMAGE2); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD0 :0X%x", psFlash2xBitMap->DSD0); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD1 :0X%x", psFlash2xBitMap->DSD1); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD2 :0X%x", psFlash2xBitMap->DSD2); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA0 :0X%x", psFlash2xBitMap->VSA0); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA1 :0X%x", psFlash2xBitMap->VSA1); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA2 :0X%x", psFlash2xBitMap->VSA2); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSI :0X%x", psFlash2xBitMap->SCSI); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CONTROL_SECTION :0X%x", psFlash2xBitMap->CONTROL_SECTION); - - return STATUS_SUCCESS; -} - -/* - * BcmGetFlash2xSectionalBitMap :- It will provide the bit map of all the section present in Flash - * 8bit has been assigned to every section. - * bit[0] :Section present or not - * bit[1] :section is valid or not - * bit[2] : Secton is read only or has write permission too. - * bit[3] : Active Section - - * bit[7...4] = Reserved . - * - * @Adapter:-Driver private Data Structure - * - * Return value:- - * Success:- STATUS_SUCESS - * Failure:- negative error code - */ - -int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap) -{ - struct bcm_flash2x_cs_info *psFlash2xCSInfo = Adapter->psFlash2xCSInfo; - enum bcm_flash2x_section_val uiHighestPriDSD = 0; - enum bcm_flash2x_section_val uiHighestPriISO = 0; - bool SetActiveDSDDone = false; - bool SetActiveISODone = false; - - /* For 1.x map all the section except DSD0 will be shown as not present - * This part will be used by calibration tool to detect the number of DSD present in Flash. - */ - if (IsFlash2x(Adapter) == false) { - psFlash2xBitMap->ISO_IMAGE2 = 0; - psFlash2xBitMap->ISO_IMAGE1 = 0; - psFlash2xBitMap->DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT; /* 0xF; 0000(Reseved)1(Active)0(RW)1(valid)1(present) */ - psFlash2xBitMap->DSD1 = 0; - psFlash2xBitMap->DSD2 = 0; - psFlash2xBitMap->VSA0 = 0; - psFlash2xBitMap->VSA1 = 0; - psFlash2xBitMap->VSA2 = 0; - psFlash2xBitMap->CONTROL_SECTION = 0; - psFlash2xBitMap->SCSI = 0; - psFlash2xBitMap->Reserved0 = 0; - psFlash2xBitMap->Reserved1 = 0; - psFlash2xBitMap->Reserved2 = 0; - - return STATUS_SUCCESS; - } - - uiHighestPriDSD = getHighestPriDSD(Adapter); - uiHighestPriISO = getHighestPriISO(Adapter); - - /* - * IS0 IMAGE 2 - */ - if ((psFlash2xCSInfo->OffsetISOImage2Part1Start) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->ISO_IMAGE2 = psFlash2xBitMap->ISO_IMAGE2 | FLASH2X_SECTION_PRESENT; - - if (ReadISOSignature(Adapter, ISO_IMAGE2) == ISO_IMAGE_MAGIC_NUMBER) - psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_VALID; - - /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, ISO_IMAGE2) == false) - psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_RO; - - if (SetActiveISODone == false && uiHighestPriISO == ISO_IMAGE2) { - psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_ACT; - SetActiveISODone = TRUE; - } - } - - /* - * IS0 IMAGE 1 - */ - if ((psFlash2xCSInfo->OffsetISOImage1Part1Start) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->ISO_IMAGE1 = psFlash2xBitMap->ISO_IMAGE1 | FLASH2X_SECTION_PRESENT; - - if (ReadISOSignature(Adapter, ISO_IMAGE1) == ISO_IMAGE_MAGIC_NUMBER) - psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_VALID; - - /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, ISO_IMAGE1) == false) - psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_RO; - - if (SetActiveISODone == false && uiHighestPriISO == ISO_IMAGE1) { - psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_ACT; - SetActiveISODone = TRUE; - } - } - - /* - * DSD2 - */ - if ((psFlash2xCSInfo->OffsetFromZeroForDSD2Start) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->DSD2 = psFlash2xBitMap->DSD2 | FLASH2X_SECTION_PRESENT; - - if (ReadDSDSignature(Adapter, DSD2) == DSD_IMAGE_MAGIC_NUMBER) - psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_VALID; - - /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, DSD2) == false) { - psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_RO; - } else { - /* Means section is writable */ - if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD2)) { - psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_ACT; - SetActiveDSDDone = TRUE; - } - } - } - - /* - * DSD 1 - */ - if ((psFlash2xCSInfo->OffsetFromZeroForDSD1Start) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->DSD1 = psFlash2xBitMap->DSD1 | FLASH2X_SECTION_PRESENT; - - if (ReadDSDSignature(Adapter, DSD1) == DSD_IMAGE_MAGIC_NUMBER) - psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_VALID; - - /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, DSD1) == false) { - psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_RO; - } else { - /* Means section is writable */ - if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD1)) { - psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_ACT; - SetActiveDSDDone = TRUE; - } - } - } - - /* - * For DSD 0 - */ - if ((psFlash2xCSInfo->OffsetFromZeroForDSDStart) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->DSD0 = psFlash2xBitMap->DSD0 | FLASH2X_SECTION_PRESENT; - - if (ReadDSDSignature(Adapter, DSD0) == DSD_IMAGE_MAGIC_NUMBER) - psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_VALID; - - /* Setting Access permission */ - if (IsSectionWritable(Adapter, DSD0) == false) { - psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_RO; - } else { - /* Means section is writable */ - if ((SetActiveDSDDone == false) && (uiHighestPriDSD == DSD0)) { - psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_ACT; - SetActiveDSDDone = TRUE; - } - } - } - - /* - * VSA 0 - */ - if ((psFlash2xCSInfo->OffsetFromZeroForVSAStart) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->VSA0 = psFlash2xBitMap->VSA0 | FLASH2X_SECTION_PRESENT; - - /* Setting the Access Bit. Map is not defined hece setting it always valid */ - psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_VALID; - - /* Calculation for extrating the Access permission */ - if (IsSectionWritable(Adapter, VSA0) == false) - psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_RO; - - /* By Default section is Active */ - psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_ACT; - } - - /* - * VSA 1 - */ - if ((psFlash2xCSInfo->OffsetFromZeroForVSA1Start) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->VSA1 = psFlash2xBitMap->VSA1 | FLASH2X_SECTION_PRESENT; - - /* Setting the Access Bit. Map is not defined hece setting it always valid */ - psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_VALID; - - /* Checking For Access permission */ - if (IsSectionWritable(Adapter, VSA1) == false) - psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_RO; - - /* By Default section is Active */ - psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_ACT; - } - - /* - * VSA 2 - */ - if ((psFlash2xCSInfo->OffsetFromZeroForVSA2Start) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->VSA2 = psFlash2xBitMap->VSA2 | FLASH2X_SECTION_PRESENT; - - /* Setting the Access Bit. Map is not defined hece setting it always valid */ - psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_VALID; - - /* Checking For Access permission */ - if (IsSectionWritable(Adapter, VSA2) == false) - psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_RO; - - /* By Default section is Active */ - psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_ACT; - } - - /* - * SCSI Section - */ - if ((psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->SCSI = psFlash2xBitMap->SCSI | FLASH2X_SECTION_PRESENT; - - /* Setting the Access Bit. Map is not defined hece setting it always valid */ - psFlash2xBitMap->SCSI |= FLASH2X_SECTION_VALID; - - /* Checking For Access permission */ - if (IsSectionWritable(Adapter, SCSI) == false) - psFlash2xBitMap->SCSI |= FLASH2X_SECTION_RO; - - /* By Default section is Active */ - psFlash2xBitMap->SCSI |= FLASH2X_SECTION_ACT; - } - - /* - * Control Section - */ - if ((psFlash2xCSInfo->OffsetFromZeroForControlSectionStart) != UNINIT_PTR_IN_CS) { - /* Setting the 0th Bit representing the Section is present or not. */ - psFlash2xBitMap->CONTROL_SECTION = psFlash2xBitMap->CONTROL_SECTION | (FLASH2X_SECTION_PRESENT); - - /* Setting the Access Bit. Map is not defined hece setting it always valid */ - psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_VALID; - - /* Checking For Access permission */ - if (IsSectionWritable(Adapter, CONTROL_SECTION) == false) - psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_RO; - - /* By Default section is Active */ - psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_ACT; - } - - /* - * For Reserved Sections - */ - psFlash2xBitMap->Reserved0 = 0; - psFlash2xBitMap->Reserved0 = 0; - psFlash2xBitMap->Reserved0 = 0; - BcmDumpFlash2xSectionBitMap(psFlash2xBitMap); - - return STATUS_SUCCESS; -} - -/* - * BcmSetActiveSection :- Set Active section is used to make priority field highest over other - * section of same type. - * - * @Adapater :- Bcm Driver Private Data Structure - * @eFlash2xSectionVal :- Flash section val whose priority has to be made highest. - * - * Return Value:- Make the priorit highest else return erorr code - * - */ - -int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectVal) -{ - unsigned int SectImagePriority = 0; - int Status = STATUS_SUCCESS; - - /* struct bcm_dsd_header sDSD = {0}; - * struct bcm_iso_header sISO = {0}; - */ - int HighestPriDSD = 0; - int HighestPriISO = 0; - - Status = IsSectionWritable(Adapter, eFlash2xSectVal); - if (Status != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section <%d> is not writable", eFlash2xSectVal); - return STATUS_FAILURE; - } - - Adapter->bHeaderChangeAllowed = TRUE; - switch (eFlash2xSectVal) { - case ISO_IMAGE1: - case ISO_IMAGE2: - if (ReadISOSignature(Adapter, eFlash2xSectVal) == ISO_IMAGE_MAGIC_NUMBER) { - HighestPriISO = getHighestPriISO(Adapter); - - if (HighestPriISO == eFlash2xSectVal) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given ISO<%x> already has highest priority", eFlash2xSectVal); - Status = STATUS_SUCCESS; - break; - } - - SectImagePriority = ReadISOPriority(Adapter, HighestPriISO) + 1; - - if ((SectImagePriority == 0) && IsSectionWritable(Adapter, HighestPriISO)) { - /* This is a SPECIAL Case which will only happen if the current highest priority ISO has priority value = 0x7FFFFFFF. - * We will write 1 to the current Highest priority ISO And then shall increase the priority of the requested ISO - * by user - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n", eFlash2xSectVal); - SectImagePriority = htonl(0x1); - Status = BcmFlash2xBulkWrite(Adapter, - &SectImagePriority, - HighestPriISO, - 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), - SIGNATURE_SIZE, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); - Status = STATUS_FAILURE; - break; - } - - HighestPriISO = getHighestPriISO(Adapter); - - if (HighestPriISO == eFlash2xSectVal) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given ISO<%x> already has highest priority", eFlash2xSectVal); - Status = STATUS_SUCCESS; - break; - } - - SectImagePriority = 2; - } - - SectImagePriority = htonl(SectImagePriority); - - Status = BcmFlash2xBulkWrite(Adapter, - &SectImagePriority, - eFlash2xSectVal, - 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), - SIGNATURE_SIZE, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); - break; - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority"); - Status = STATUS_FAILURE; - break; - } - break; - case DSD0: - case DSD1: - case DSD2: - if (ReadDSDSignature(Adapter, eFlash2xSectVal) == DSD_IMAGE_MAGIC_NUMBER) { - HighestPriDSD = getHighestPriDSD(Adapter); - if (HighestPriDSD == eFlash2xSectVal) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given DSD<%x> already has highest priority", eFlash2xSectVal); - Status = STATUS_SUCCESS; - break; - } - - SectImagePriority = ReadDSDPriority(Adapter, HighestPriDSD) + 1; - if (SectImagePriority == 0) { - /* This is a SPECIAL Case which will only happen if the current highest priority DSD has priority value = 0x7FFFFFFF. - * We will write 1 to the current Highest priority DSD And then shall increase the priority of the requested DSD - * by user - */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n", eFlash2xSectVal); - SectImagePriority = htonl(0x1); - - Status = BcmFlash2xBulkWrite(Adapter, - &SectImagePriority, - HighestPriDSD, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), - SIGNATURE_SIZE, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); - break; - } - - HighestPriDSD = getHighestPriDSD(Adapter); - - if (HighestPriDSD == eFlash2xSectVal) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal); - Status = STATUS_SUCCESS; - break; - } - - SectImagePriority = htonl(0x2); - Status = BcmFlash2xBulkWrite(Adapter, - &SectImagePriority, - HighestPriDSD, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), - SIGNATURE_SIZE, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); - break; - } - - HighestPriDSD = getHighestPriDSD(Adapter); - if (HighestPriDSD == eFlash2xSectVal) { - Status = STATUS_SUCCESS; - break; - } - - SectImagePriority = 3; - } - SectImagePriority = htonl(SectImagePriority); - Status = BcmFlash2xBulkWrite(Adapter, - &SectImagePriority, - eFlash2xSectVal, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), - SIGNATURE_SIZE, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly"); - Status = STATUS_FAILURE; - break; - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority"); - Status = STATUS_FAILURE; - break; - } - break; - case VSA0: - case VSA1: - case VSA2: - /* Has to be decided */ - break; - default: - Status = STATUS_FAILURE; - break; - } - - Adapter->bHeaderChangeAllowed = false; - return Status; -} - -/* - * BcmCopyISO - Used only for copying the ISO section - * @Adapater :- Bcm Driver Private Data Structure - * @sCopySectStrut :- Section copy structure - * - * Return value:- SUCCESS if copies successfully else negative error code - * - */ - -int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section sCopySectStrut) -{ - PCHAR Buff = NULL; - enum bcm_flash2x_section_val eISOReadPart = 0, eISOWritePart = 0; - unsigned int uiReadOffsetWithinPart = 0, uiWriteOffsetWithinPart = 0; - unsigned int uiTotalDataToCopy = 0; - bool IsThisHeaderSector = false; - unsigned int sigOffset = 0; - unsigned int ISOLength = 0; - unsigned int Status = STATUS_SUCCESS; - unsigned int SigBuff[MAX_RW_SIZE]; - unsigned int i = 0; - - if (ReadISOSignature(Adapter, sCopySectStrut.SrcSection) != ISO_IMAGE_MAGIC_NUMBER) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature"); - return STATUS_FAILURE; - } - - Status = BcmFlash2xBulkRead(Adapter, &ISOLength, - sCopySectStrut.SrcSection, - 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageSize), - 4); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n"); - return Status; - } - - ISOLength = htonl(ISOLength); - if (ISOLength % Adapter->uiSectorSize) - ISOLength = Adapter->uiSectorSize * (1 + ISOLength/Adapter->uiSectorSize); - - sigOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber); - - Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL); - - if (!Buff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for section size"); - return -ENOMEM; - } - - if (sCopySectStrut.SrcSection == ISO_IMAGE1 && sCopySectStrut.DstSection == ISO_IMAGE2) { - eISOReadPart = ISO_IMAGE1; - eISOWritePart = ISO_IMAGE2; - uiReadOffsetWithinPart = 0; - uiWriteOffsetWithinPart = 0; - - uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start); - - if (uiTotalDataToCopy < ISOLength) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature"); - Status = STATUS_FAILURE; - goto out; - } - - uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start); - - if (uiTotalDataToCopy < ISOLength) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Dest ISO Section does not have enough section size"); - Status = STATUS_FAILURE; - goto out; - } - - uiTotalDataToCopy = ISOLength; - - CorruptISOSig(Adapter, ISO_IMAGE2); - while (uiTotalDataToCopy) { - if (uiTotalDataToCopy == Adapter->uiSectorSize) { - /* Setting for write of first sector. First sector is assumed to be written in last */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Writing the signature sector"); - eISOReadPart = ISO_IMAGE1; - uiReadOffsetWithinPart = 0; - eISOWritePart = ISO_IMAGE2; - uiWriteOffsetWithinPart = 0; - IsThisHeaderSector = TRUE; - } else { - uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize; - uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize; - - if ((eISOReadPart == ISO_IMAGE1) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) { - eISOReadPart = ISO_IMAGE1_PART2; - uiReadOffsetWithinPart = 0; - } - - if ((eISOReadPart == ISO_IMAGE1_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) { - eISOReadPart = ISO_IMAGE1_PART3; - uiReadOffsetWithinPart = 0; - } - - if ((eISOWritePart == ISO_IMAGE2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) { - eISOWritePart = ISO_IMAGE2_PART2; - uiWriteOffsetWithinPart = 0; - } - - if ((eISOWritePart == ISO_IMAGE2_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) { - eISOWritePart = ISO_IMAGE2_PART3; - uiWriteOffsetWithinPart = 0; - } - } - - Status = BcmFlash2xBulkRead(Adapter, - (PUINT)Buff, - eISOReadPart, - uiReadOffsetWithinPart, - Adapter->uiSectorSize); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart); - break; - } - - if (IsThisHeaderSector == TRUE) { - /* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */ - memcpy(SigBuff, Buff + sigOffset, sizeof(SigBuff)); - - for (i = 0; i < MAX_RW_SIZE; i++) - *(Buff + sigOffset + i) = 0xFF; - } - Adapter->bHeaderChangeAllowed = TRUE; - Status = BcmFlash2xBulkWrite(Adapter, - (PUINT)Buff, - eISOWritePart, - uiWriteOffsetWithinPart, - Adapter->uiSectorSize, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart); - break; - } - - Adapter->bHeaderChangeAllowed = false; - if (IsThisHeaderSector == TRUE) { - WriteToFlashWithoutSectorErase(Adapter, - SigBuff, - eISOWritePart, - sigOffset, - MAX_RW_SIZE); - IsThisHeaderSector = false; - } - /* subtracting the written Data */ - uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize; - } - } - - if (sCopySectStrut.SrcSection == ISO_IMAGE2 && sCopySectStrut.DstSection == ISO_IMAGE1) { - eISOReadPart = ISO_IMAGE2; - eISOWritePart = ISO_IMAGE1; - uiReadOffsetWithinPart = 0; - uiWriteOffsetWithinPart = 0; - - uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start); - - if (uiTotalDataToCopy < ISOLength) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature"); - Status = STATUS_FAILURE; - goto out; - } - - uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start) + - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) - - (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start); - - if (uiTotalDataToCopy < ISOLength) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Dest ISO Section does not have enough section size"); - Status = STATUS_FAILURE; - goto out; - } - - uiTotalDataToCopy = ISOLength; - - CorruptISOSig(Adapter, ISO_IMAGE1); - - while (uiTotalDataToCopy) { - if (uiTotalDataToCopy == Adapter->uiSectorSize) { - /* Setting for write of first sector. First sector is assumed to be written in last */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Writing the signature sector"); - eISOReadPart = ISO_IMAGE2; - uiReadOffsetWithinPart = 0; - eISOWritePart = ISO_IMAGE1; - uiWriteOffsetWithinPart = 0; - IsThisHeaderSector = TRUE; - } else { - uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize; - uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize; - - if ((eISOReadPart == ISO_IMAGE2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) { - eISOReadPart = ISO_IMAGE2_PART2; - uiReadOffsetWithinPart = 0; - } - - if ((eISOReadPart == ISO_IMAGE2_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) { - eISOReadPart = ISO_IMAGE2_PART3; - uiReadOffsetWithinPart = 0; - } - - if ((eISOWritePart == ISO_IMAGE1) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) { - eISOWritePart = ISO_IMAGE1_PART2; - uiWriteOffsetWithinPart = 0; - } - - if ((eISOWritePart == ISO_IMAGE1_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) { - eISOWritePart = ISO_IMAGE1_PART3; - uiWriteOffsetWithinPart = 0; - } - } - - Status = BcmFlash2xBulkRead(Adapter, - (PUINT)Buff, - eISOReadPart, - uiReadOffsetWithinPart, - Adapter->uiSectorSize); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart); - break; - } - - if (IsThisHeaderSector == TRUE) { - /* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */ - memcpy(SigBuff, Buff + sigOffset, sizeof(SigBuff)); - - for (i = 0; i < MAX_RW_SIZE; i++) - *(Buff + sigOffset + i) = 0xFF; - } - Adapter->bHeaderChangeAllowed = TRUE; - Status = BcmFlash2xBulkWrite(Adapter, - (PUINT)Buff, - eISOWritePart, - uiWriteOffsetWithinPart, - Adapter->uiSectorSize, - TRUE); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart); - break; - } - - Adapter->bHeaderChangeAllowed = false; - if (IsThisHeaderSector == TRUE) { - WriteToFlashWithoutSectorErase(Adapter, - SigBuff, - eISOWritePart, - sigOffset, - MAX_RW_SIZE); - - IsThisHeaderSector = false; - } - - /* subtracting the written Data */ - uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize; - } - } -out: - kfree(Buff); - - return Status; -} - -/* - * BcmFlash2xCorruptSig : this API is used to corrupt the written sig in Bcm Header present in flash section. - * It will corrupt the sig, if Section is writable, by making first bytes as zero. - * @Adapater :- Bcm Driver Private Data Structure - * @eFlash2xSectionVal :- Flash section val which has header - * - * Return Value :- - * Success :- If Section is present and writable, corrupt the sig and return STATUS_SUCCESS - * Failure :-Return negative error code - */ - -int BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) -{ - int Status = STATUS_SUCCESS; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Value :%x\n", eFlash2xSectionVal); - - if ((eFlash2xSectionVal == DSD0) || (eFlash2xSectionVal == DSD1) || (eFlash2xSectionVal == DSD2)) { - Status = CorruptDSDSig(Adapter, eFlash2xSectionVal); - } else if (eFlash2xSectionVal == ISO_IMAGE1 || eFlash2xSectionVal == ISO_IMAGE2) { - Status = CorruptISOSig(Adapter, eFlash2xSectionVal); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given Section <%d>does not have Header", eFlash2xSectionVal); - return STATUS_SUCCESS; - } - return Status; -} - -/* - *BcmFlash2xWriteSig :-this API is used to Write the sig if requested Section has - * header and Write Permission. - * @Adapater :- Bcm Driver Private Data Structure - * @eFlashSectionVal :- Flash section val which has header - * - * Return Value :- - * Success :- If Section is present and writable write the sig and return STATUS_SUCCESS - * Failure :-Return negative error code - */ - -int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlashSectionVal) -{ - unsigned int uiSignature = 0; - unsigned int uiOffset = 0; - - /* struct bcm_dsd_header dsdHeader = {0}; */ - if (Adapter->bSigCorrupted == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is not corrupted by driver, hence not restoring\n"); - return STATUS_SUCCESS; - } - - if (Adapter->bAllDSDWriteAllow == false) { - if (IsSectionWritable(Adapter, eFlashSectionVal) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Write signature"); - return SECTOR_IS_NOT_WRITABLE; - } - } - - if ((eFlashSectionVal == DSD0) || (eFlashSectionVal == DSD1) || (eFlashSectionVal == DSD2)) { - uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER); - uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader; - - uiOffset += FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber); - - if ((ReadDSDSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Corrupted Pattern is not there. Hence won't write sig"); - return STATUS_FAILURE; - } - } else if ((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) { - uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER); - /* uiOffset = 0; */ - uiOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber); - if ((ReadISOSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Currupted Pattern is not there. Hence won't write sig"); - return STATUS_FAILURE; - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GIVEN SECTION< %d > IS NOT VALID FOR SIG WRITE...", eFlashSectionVal); - return STATUS_FAILURE; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature"); - - Adapter->bHeaderChangeAllowed = TRUE; - Adapter->bSigCorrupted = false; - BcmFlash2xBulkWrite(Adapter, &uiSignature, eFlashSectionVal, uiOffset, SIGNATURE_SIZE, TRUE); - Adapter->bHeaderChangeAllowed = false; - - return STATUS_SUCCESS; -} - -/* - * validateFlash2xReadWrite :- This API is used to validate the user request for Read/Write. - * if requested Bytes goes beyond the Requested section, it reports error. - * @Adapater :- Bcm Driver Private Data Structure - * @psFlash2xReadWrite :-Flash2x Read/write structure pointer - * - * Return values:-Return TRUE is request is valid else false. - */ - -int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_readwrite *psFlash2xReadWrite) -{ - unsigned int uiNumOfBytes = 0; - unsigned int uiSectStartOffset = 0; - unsigned int uiSectEndOffset = 0; - - uiNumOfBytes = psFlash2xReadWrite->numOfBytes; - - if (IsSectionExistInFlash(Adapter, psFlash2xReadWrite->Section) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%x> does not exist in Flash", psFlash2xReadWrite->Section); - return false; - } - uiSectStartOffset = BcmGetSectionValStartOffset(Adapter, psFlash2xReadWrite->Section); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Start offset :%x ,section :%d\n", uiSectStartOffset, psFlash2xReadWrite->Section); - if ((psFlash2xReadWrite->Section == ISO_IMAGE1) || (psFlash2xReadWrite->Section == ISO_IMAGE2)) { - if (psFlash2xReadWrite->Section == ISO_IMAGE1) { - uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1) - - BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) + - BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1_PART2) - - BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1_PART2) + - BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1_PART3) - - BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1_PART3); - } else if (psFlash2xReadWrite->Section == ISO_IMAGE2) { - uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2) - - BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2) + - BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2_PART2) - - BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2_PART2) + - BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2_PART3) - - BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2_PART3); - } - - /* since this uiSectEndoffset is the size of iso Image. hence for calculating the virtual endoffset - * it should be added in startoffset. so that check done in last of this function can be valued. - */ - uiSectEndOffset = uiSectStartOffset + uiSectEndOffset; - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Total size of the ISO Image :%x", uiSectEndOffset); - } else - uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, psFlash2xReadWrite->Section); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x\n", uiSectEndOffset); - - /* psFlash2xReadWrite->offset and uiNumOfBytes are user controlled and can lead to integer overflows */ - if (psFlash2xReadWrite->offset > uiSectEndOffset) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request...."); - return false; - } - if (uiNumOfBytes > uiSectEndOffset) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request...."); - return false; - } - /* Checking the boundary condition */ - if ((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset) - return TRUE; - else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request...."); - return false; - } -} - -/* - * IsFlash2x :- check for Flash 2.x - * Adapater :- Bcm Driver Private Data Structure - * - * Return value:- - * return TRUE if flah2.x of hgher version else return false. - */ - -int IsFlash2x(struct bcm_mini_adapter *Adapter) -{ - if (Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER) - return TRUE; - else - return false; -} - -/* - * GetFlashBaseAddr :- Calculate the Flash Base address - * @Adapater :- Bcm Driver Private Data Structure - * - * Return Value:- - * Success :- Base Address of the Flash - */ - -static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter) -{ - unsigned int uiBaseAddr = 0; - - if (Adapter->bDDRInitDone) { - /* - * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr - * In case of Raw Read... use the default value - */ - if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == false) && - !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))) - uiBaseAddr = Adapter->uiFlashBaseAdd; - else - uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT; - } else { - /* - * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr - * In case of Raw Read... use the default value - */ - if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == false) && - !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))) - uiBaseAddr = Adapter->uiFlashBaseAdd | FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; - else - uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; - } - - return uiBaseAddr; -} - -/* - * BcmCopySection :- This API is used to copy the One section in another. Both section should - * be contiuous and of same size. Hence this Will not be applicabe to copy ISO. - * - * @Adapater :- Bcm Driver Private Data Structure - * @SrcSection :- Source section From where data has to be copied - * @DstSection :- Destination section to which data has to be copied - * @offset :- Offset from/to where data has to be copied from one section to another. - * @numOfBytes :- number of byes that has to be copyed from one section to another at given offset. - * in case of numofBytes equal zero complete section will be copied. - * Return Values- - * Success : Return STATUS_SUCCESS - * Faillure :- return negative error code - */ - -int BcmCopySection(struct bcm_mini_adapter *Adapter, - enum bcm_flash2x_section_val SrcSection, - enum bcm_flash2x_section_val DstSection, - unsigned int offset, - unsigned int numOfBytes) -{ - unsigned int BuffSize = 0; - unsigned int BytesToBeCopied = 0; - PUCHAR pBuff = NULL; - int Status = STATUS_SUCCESS; - - if (SrcSection == DstSection) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source and Destination should be different ...try again"); - return -EINVAL; - } - - if ((SrcSection != DSD0) && (SrcSection != DSD1) && (SrcSection != DSD2)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source should be DSD subsection"); - return -EINVAL; - } - - if ((DstSection != DSD0) && (DstSection != DSD1) && (DstSection != DSD2)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destination should be DSD subsection"); - return -EINVAL; - } - - /* if offset zero means have to copy complete secton */ - if (numOfBytes == 0) { - numOfBytes = BcmGetSectionValEndOffset(Adapter, SrcSection) - - BcmGetSectionValStartOffset(Adapter, SrcSection); - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Section Size :0x%x", numOfBytes); - } - - if ((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter, SrcSection) - - BcmGetSectionValStartOffset(Adapter, SrcSection)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " Input parameters going beyond the section offS: %x numB: %x of Source Section\n", - offset, numOfBytes); - return -EINVAL; - } - - if ((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter, DstSection) - - BcmGetSectionValStartOffset(Adapter, DstSection)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Input parameters going beyond the section offS: %x numB: %x of Destination Section\n", - offset, numOfBytes); - return -EINVAL; - } - - if (numOfBytes > Adapter->uiSectorSize) - BuffSize = Adapter->uiSectorSize; - else - BuffSize = numOfBytes; - - pBuff = kzalloc(BuffSize, GFP_KERNEL); - if (!pBuff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed.. "); - return -ENOMEM; - } - - BytesToBeCopied = Adapter->uiSectorSize; - if (offset % Adapter->uiSectorSize) - BytesToBeCopied = Adapter->uiSectorSize - (offset % Adapter->uiSectorSize); - if (BytesToBeCopied > numOfBytes) - BytesToBeCopied = numOfBytes; - - Adapter->bHeaderChangeAllowed = TRUE; - - do { - Status = BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, SrcSection , offset, BytesToBeCopied); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed at offset :%d for NOB :%d", SrcSection, BytesToBeCopied); - break; - } - Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pBuff, DstSection, offset, BytesToBeCopied, false); - if (Status) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed at offset :%d for NOB :%d", DstSection, BytesToBeCopied); - break; - } - offset = offset + BytesToBeCopied; - numOfBytes = numOfBytes - BytesToBeCopied; - if (numOfBytes) { - if (numOfBytes > Adapter->uiSectorSize) - BytesToBeCopied = Adapter->uiSectorSize; - else - BytesToBeCopied = numOfBytes; - } - } while (numOfBytes > 0); - - kfree(pBuff); - Adapter->bHeaderChangeAllowed = false; - - return Status; -} - -/* - * SaveHeaderIfPresent :- This API is use to Protect the Header in case of Header Sector write - * @Adapater :- Bcm Driver Private Data Structure - * @pBuff :- Data buffer that has to be written in sector having the header map. - * @uiOffset :- Flash offset that has to be written. - * - * Return value :- - * Success :- On success return STATUS_SUCCESS - * Faillure :- Return negative error code - */ - -static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiOffset) -{ - unsigned int offsetToProtect = 0, HeaderSizeToProtect = 0; - bool bHasHeader = false; - PUCHAR pTempBuff = NULL; - unsigned int uiSectAlignAddr = 0; - unsigned int sig = 0; - - /* making the offset sector aligned */ - uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); - - if ((uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD2) - Adapter->uiSectorSize) || - (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD1) - Adapter->uiSectorSize) || - (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD0) - Adapter->uiSectorSize)) { - /* offset from the sector boundary having the header map */ - offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize; - HeaderSizeToProtect = sizeof(struct bcm_dsd_header); - bHasHeader = TRUE; - } - - if (uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) || - uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2)) { - offsetToProtect = 0; - HeaderSizeToProtect = sizeof(struct bcm_iso_header); - bHasHeader = TRUE; - } - /* If Header is present overwrite passed buffer with this */ - if (bHasHeader && (Adapter->bHeaderChangeAllowed == false)) { - pTempBuff = kzalloc(HeaderSizeToProtect, GFP_KERNEL); - if (!pTempBuff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed"); - return -ENOMEM; - } - /* Read header */ - BeceemFlashBulkRead(Adapter, (PUINT)pTempBuff, (uiSectAlignAddr + offsetToProtect), HeaderSizeToProtect); - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pTempBuff, HeaderSizeToProtect); - /* Replace Buffer content with Header */ - memcpy(pBuff + offsetToProtect, pTempBuff, HeaderSizeToProtect); - - kfree(pTempBuff); - } - if (bHasHeader && Adapter->bSigCorrupted) { - sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))); - sig = ntohl(sig); - if ((sig & 0xFF000000) != CORRUPTED_PATTERN) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Desired pattern is not at sig offset. Hence won't restore"); - Adapter->bSigCorrupted = false; - return STATUS_SUCCESS; - } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Corrupted sig is :%X", sig); - *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature in Header Write only"); - Adapter->bSigCorrupted = false; - } - - return STATUS_SUCCESS; -} - -/* - * BcmDoChipSelect : This will selcet the appropriate chip for writing. - * @Adapater :- Bcm Driver Private Data Structure - * - * OutPut:- - * Select the Appropriate chip and retrn status Success - */ -static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset) -{ - unsigned int FlashConfig = 0; - int ChipNum = 0; - unsigned int GPIOConfig = 0; - unsigned int PartNum = 0; - - ChipNum = offset / FLASH_PART_SIZE; - - /* - * Chip Select mapping to enable flash0. - * To select flash 0, we have to OR with (0<<12). - * ORing 0 will have no impact so not doing that part. - * In future if Chip select value changes from 0 to non zero, - * That needs be taken care with backward comaptibility. No worries for now. - */ - - /* - * SelectedChip Variable is the selection that the host is 100% Sure the same as what the register will hold. This can be ONLY ensured - * if the Chip doesn't goes to low power mode while the flash operation is in progress (NVMRdmWrmLock is taken) - * Before every new Flash Write operation, we reset the variable. This is to ensure that after any wake-up from - * power down modes (Idle mode/shutdown mode), the values in the register will be different. - */ - - if (Adapter->SelectedChip == ChipNum) - return STATUS_SUCCESS; - - /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Selected Chip :%x", ChipNum); */ - Adapter->SelectedChip = ChipNum; - - /* bit[13..12] will select the appropriate chip */ - rdmalt(Adapter, FLASH_CONFIG_REG, &FlashConfig, 4); - rdmalt(Adapter, FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4); - { - switch (ChipNum) { - case 0: - PartNum = 0; - break; - case 1: - PartNum = 3; - GPIOConfig |= (0x4 << CHIP_SELECT_BIT12); - break; - case 2: - PartNum = 1; - GPIOConfig |= (0x1 << CHIP_SELECT_BIT12); - break; - case 3: - PartNum = 2; - GPIOConfig |= (0x2 << CHIP_SELECT_BIT12); - break; - } - } - /* In case the bits already written in the FLASH_CONFIG_REG is same as what the user desired, - * nothing to do... can return immediately. - * ASSUMPTION: FLASH_GPIO_CONFIG_REG will be in sync with FLASH_CONFIG_REG. - * Even if the chip goes to low power mode, it should wake with values in each register in sync with each other. - * These values are not written by host other than during CHIP_SELECT. - */ - if (PartNum == ((FlashConfig >> CHIP_SELECT_BIT12) & 0x3)) - return STATUS_SUCCESS; - - /* clearing the bit[13..12] */ - FlashConfig &= 0xFFFFCFFF; - FlashConfig = (FlashConfig | (PartNum<psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber), - SIGNATURE_SIZE); - - uiDSDsig = ntohl(uiDSDsig); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD SIG :%x", uiDSDsig); - - return uiDSDsig; -} - -static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd) -{ - /* unsigned int priOffsetInMap = 0 ; */ - unsigned int uiDSDPri = STATUS_FAILURE; - /* struct bcm_dsd_header dsdHeader = {0}; - * priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader; - */ - if (IsSectionWritable(Adapter, dsd)) { - if (ReadDSDSignature(Adapter, dsd) == DSD_IMAGE_MAGIC_NUMBER) { - BcmFlash2xBulkRead(Adapter, - &uiDSDPri, - dsd, - Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority), - 4); - - uiDSDPri = ntohl(uiDSDPri); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD<%x> Priority :%x", dsd, uiDSDPri); - } - } - - return uiDSDPri; -} - -static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter) -{ - int DSDHighestPri = STATUS_FAILURE; - int DsdPri = 0; - enum bcm_flash2x_section_val HighestPriDSD = 0; - - if (IsSectionWritable(Adapter, DSD2)) { - DSDHighestPri = ReadDSDPriority(Adapter, DSD2); - HighestPriDSD = DSD2; - } - - if (IsSectionWritable(Adapter, DSD1)) { - DsdPri = ReadDSDPriority(Adapter, DSD1); - if (DSDHighestPri < DsdPri) { - DSDHighestPri = DsdPri; - HighestPriDSD = DSD1; - } - } - - if (IsSectionWritable(Adapter, DSD0)) { - DsdPri = ReadDSDPriority(Adapter, DSD0); - if (DSDHighestPri < DsdPri) { - DSDHighestPri = DsdPri; - HighestPriDSD = DSD0; - } - } - if (HighestPriDSD) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Highest DSD :%x , and its Pri :%x", HighestPriDSD, DSDHighestPri); - - return HighestPriDSD; -} - -static int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) -{ - unsigned int uiISOsig = 0; - /* unsigned int sigoffsetInMap = 0; - * struct bcm_iso_header ISOHeader = {0}; - * sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader; - */ - if (iso != ISO_IMAGE1 && iso != ISO_IMAGE2) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "passed section value is not for ISOs"); - return STATUS_FAILURE; - } - BcmFlash2xBulkRead(Adapter, - &uiISOsig, - iso, - 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber), - SIGNATURE_SIZE); - - uiISOsig = ntohl(uiISOsig); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO SIG :%x", uiISOsig); - - return uiISOsig; -} - -static int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso) -{ - unsigned int ISOPri = STATUS_FAILURE; - - if (IsSectionWritable(Adapter, iso)) { - if (ReadISOSignature(Adapter, iso) == ISO_IMAGE_MAGIC_NUMBER) { - BcmFlash2xBulkRead(Adapter, - &ISOPri, - iso, - 0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority), - 4); - - ISOPri = ntohl(ISOPri); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO<%x> Priority :%x", iso, ISOPri); - } - } - - return ISOPri; -} - -static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter) -{ - int ISOHighestPri = STATUS_FAILURE; - int ISOPri = 0; - enum bcm_flash2x_section_val HighestPriISO = NO_SECTION_VAL; - - if (IsSectionWritable(Adapter, ISO_IMAGE2)) { - ISOHighestPri = ReadISOPriority(Adapter, ISO_IMAGE2); - HighestPriISO = ISO_IMAGE2; - } - - if (IsSectionWritable(Adapter, ISO_IMAGE1)) { - ISOPri = ReadISOPriority(Adapter, ISO_IMAGE1); - if (ISOHighestPri < ISOPri) { - ISOHighestPri = ISOPri; - HighestPriISO = ISO_IMAGE1; - } - } - if (HighestPriISO) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Highest ISO :%x and its Pri :%x", HighestPriISO, ISOHighestPri); - - return HighestPriISO; -} - -static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, - PUINT pBuff, - enum bcm_flash2x_section_val eFlash2xSectionVal, - unsigned int uiOffset, - unsigned int uiNumBytes) -{ - #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS) - unsigned int uiTemp = 0, value = 0; - unsigned int i = 0; - unsigned int uiPartOffset = 0; - #endif - unsigned int uiStartOffset = 0; - /* Adding section start address */ - int Status = STATUS_SUCCESS; - PUCHAR pcBuff = (PUCHAR)pBuff; - - if (uiNumBytes % Adapter->ulFlashWriteSize) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Writing without Sector Erase for non-FlashWriteSize number of bytes 0x%x\n", uiNumBytes); - return STATUS_FAILURE; - } - - uiStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); - - if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal)) - return vendorextnWriteSectionWithoutErase(Adapter, pcBuff, eFlash2xSectionVal, uiOffset, uiNumBytes); - - uiOffset = uiOffset + uiStartOffset; - - #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) - Status = bcmflash_raw_writenoerase((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), pcBuff, uiNumBytes); - #else - rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - value = 0; - wrmalt(Adapter, 0x0f000C80, &value, sizeof(value)); - - Adapter->SelectedChip = RESET_CHIP_SELECT; - BcmDoChipSelect(Adapter, uiOffset); - uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - - for (i = 0; i < uiNumBytes; i += Adapter->ulFlashWriteSize) { - if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) - Status = flashByteWrite(Adapter, uiPartOffset, pcBuff); - else - Status = flashWrite(Adapter, uiPartOffset, pcBuff); - - if (Status != STATUS_SUCCESS) - break; - - pcBuff = pcBuff + Adapter->ulFlashWriteSize; - uiPartOffset = uiPartOffset + Adapter->ulFlashWriteSize; - } - wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp)); - Adapter->SelectedChip = RESET_CHIP_SELECT; - #endif - - return Status; -} - -bool IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section) -{ - bool SectionPresent = false; - - switch (section) { - case ISO_IMAGE1: - if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == false)) - SectionPresent = TRUE; - break; - case ISO_IMAGE2: - if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) && - (IsNonCDLessDevice(Adapter) == false)) - SectionPresent = TRUE; - break; - case DSD0: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case DSD1: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case DSD2: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case VSA0: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case VSA1: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case VSA2: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case SCSI: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - case CONTROL_SECTION: - if (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS) - SectionPresent = TRUE; - break; - default: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x"); - SectionPresent = false; - } - - return SectionPresent; -} - -static int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section) -{ - int offset = STATUS_FAILURE; - int Status = false; - - if (IsSectionExistInFlash(Adapter, Section) == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section <%d> does not exist", Section); - return false; - } - - offset = BcmGetSectionValStartOffset(Adapter, Section); - if (offset == INVALID_OFFSET) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%d> does not exist", Section); - return false; - } - - if (IsSectionExistInVendorInfo(Adapter, Section)) - return !(Adapter->psFlash2xVendorInfo->VendorSection[Section].AccessFlags & FLASH2X_SECTION_RO); - - Status = IsOffsetWritable(Adapter, offset); - return Status; -} - -static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) -{ - PUCHAR pBuff = NULL; - unsigned int sig = 0; - unsigned int uiOffset = 0; - unsigned int BlockStatus = 0; - unsigned int uiSectAlignAddr = 0; - - Adapter->bSigCorrupted = false; - if (Adapter->bAllDSDWriteAllow == false) { - if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature"); - return SECTOR_IS_NOT_WRITABLE; - } - } - - pBuff = kzalloc(MAX_RW_SIZE, GFP_KERNEL); - if (!pBuff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey"); - return -ENOMEM; - } - - uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header); - uiOffset -= MAX_RW_SIZE; - - BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE); - - sig = *((PUINT)(pBuff + 12)); - sig = ntohl(sig); - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pBuff, MAX_RW_SIZE); - /* Now corrupting the sig by corrupting 4th last Byte. */ - *(pBuff + 12) = 0; - - if (sig == DSD_IMAGE_MAGIC_NUMBER) { - Adapter->bSigCorrupted = TRUE; - if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) { - uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1); - BlockStatus = BcmFlashUnProtectBlock(Adapter, uiSectAlignAddr, Adapter->uiSectorSize); - - WriteToFlashWithoutSectorErase(Adapter, (PUINT)(pBuff + 12), eFlash2xSectionVal, - (uiOffset + 12), BYTE_WRITE_SUPPORT); - if (BlockStatus) { - BcmRestoreBlockProtectStatus(Adapter, BlockStatus); - BlockStatus = 0; - } - } else { - WriteToFlashWithoutSectorErase(Adapter, (PUINT)pBuff, eFlash2xSectionVal, - uiOffset, MAX_RW_SIZE); - } - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "BCM Signature is not present in header"); - kfree(pBuff); - - return STATUS_FAILURE; - } - - kfree(pBuff); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Corrupted the signature"); - - return STATUS_SUCCESS; -} - -static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal) -{ - PUCHAR pBuff = NULL; - unsigned int sig = 0; - unsigned int uiOffset = 0; - - Adapter->bSigCorrupted = false; - - if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature"); - return SECTOR_IS_NOT_WRITABLE; - } - - pBuff = kzalloc(MAX_RW_SIZE, GFP_KERNEL); - if (!pBuff) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey"); - return -ENOMEM; - } - - uiOffset = 0; - - BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE); - - sig = *((PUINT)pBuff); - sig = ntohl(sig); - - /* corrupt signature */ - *pBuff = 0; - - if (sig == ISO_IMAGE_MAGIC_NUMBER) { - Adapter->bSigCorrupted = TRUE; - WriteToFlashWithoutSectorErase(Adapter, (PUINT)pBuff, eFlash2xSectionVal, - uiOffset, Adapter->ulFlashWriteSize); - } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "BCM Signature is not present in header"); - kfree(pBuff); - - return STATUS_FAILURE; - } - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Corrupted the signature"); - BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pBuff, MAX_RW_SIZE); - - kfree(pBuff); - return STATUS_SUCCESS; -} - -bool IsNonCDLessDevice(struct bcm_mini_adapter *Adapter) -{ - if (Adapter->psFlash2xCSInfo->IsCDLessDeviceBootSig == NON_CDLESS_DEVICE_BOOT_SIG) - return TRUE; - else - return false; -} diff --git a/drivers/staging/bcm/nvm.h b/drivers/staging/bcm/nvm.h deleted file mode 100644 index e765cca5d966..000000000000 --- a/drivers/staging/bcm/nvm.h +++ /dev/null @@ -1,286 +0,0 @@ -/*************************************************************************************** - * - * Copyright (c) Beceem Communications Inc. - * - * Module Name: - * NVM.h - * - * Abstract: - * This file has the prototypes,preprocessors and definitions various NVM libraries. - * - * - * Revision History: - * Who When What - * -------- -------- ---------------------------------------------- - * Name Date Created/reviewed/modified - * - * Notes: - * - ****************************************************************************************/ - -#ifndef _NVM_H_ -#define _NVM_H_ - -struct bcm_flash_cs_info { - u32 MagicNumber; - /* let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h" */ - u32 FlashLayoutVersion; - u32 ISOImageVersion; - u32 SCSIFirmwareVersion; - u32 OffsetFromZeroForPart1ISOImage; - u32 OffsetFromZeroForScsiFirmware; - u32 SizeOfScsiFirmware; - u32 OffsetFromZeroForPart2ISOImage; - u32 OffsetFromZeroForCalibrationStart; - u32 OffsetFromZeroForCalibrationEnd; - u32 OffsetFromZeroForVSAStart; - u32 OffsetFromZeroForVSAEnd; - u32 OffsetFromZeroForControlSectionStart; - u32 OffsetFromZeroForControlSectionData; - u32 CDLessInactivityTimeout; - u32 NewImageSignature; - u32 FlashSectorSizeSig; - u32 FlashSectorSize; - u32 FlashWriteSupportSize; - u32 TotalFlashSize; - u32 FlashBaseAddr; - u32 FlashPartMaxSize; - u32 IsCDLessDeviceBootSig; - /* MSC Timeout after reset to switch from MSC to NW Mode */ - u32 MassStorageTimeout; -}; - -#define FLASH2X_TOTAL_SIZE (64 * 1024 * 1024) -#define DEFAULT_SECTOR_SIZE (64 * 1024) - -struct bcm_flash2x_cs_info { - /* magic number as 0xBECE-F1A5 - F1A5 for "flas-h" */ - u32 MagicNumber; - u32 FlashLayoutVersion; - u32 ISOImageVersion; - u32 SCSIFirmwareVersion; - u32 OffsetFromZeroForPart1ISOImage; - u32 OffsetFromZeroForScsiFirmware; - u32 SizeOfScsiFirmware; - u32 OffsetFromZeroForPart2ISOImage; - u32 OffsetFromZeroForDSDStart; - u32 OffsetFromZeroForDSDEnd; - u32 OffsetFromZeroForVSAStart; - u32 OffsetFromZeroForVSAEnd; - u32 OffsetFromZeroForControlSectionStart; - u32 OffsetFromZeroForControlSectionData; - /* NO Data Activity timeout to switch from MSC to NW Mode */ - u32 CDLessInactivityTimeout; - u32 NewImageSignature; - u32 FlashSectorSizeSig; - u32 FlashSectorSize; - u32 FlashWriteSupportSize; - u32 TotalFlashSize; - u32 FlashBaseAddr; - u32 FlashPartMaxSize; - u32 IsCDLessDeviceBootSig; - /* MSC Timeout after reset to switch from MSC to NW Mode */ - u32 MassStorageTimeout; - /* Flash Map 2.0 Field */ - u32 OffsetISOImage1Part1Start; - u32 OffsetISOImage1Part1End; - u32 OffsetISOImage1Part2Start; - u32 OffsetISOImage1Part2End; - u32 OffsetISOImage1Part3Start; - u32 OffsetISOImage1Part3End; - u32 OffsetISOImage2Part1Start; - u32 OffsetISOImage2Part1End; - u32 OffsetISOImage2Part2Start; - u32 OffsetISOImage2Part2End; - u32 OffsetISOImage2Part3Start; - u32 OffsetISOImage2Part3End; - /* DSD Header offset from start of DSD */ - u32 OffsetFromDSDStartForDSDHeader; - u32 OffsetFromZeroForDSD1Start; - u32 OffsetFromZeroForDSD1End; - u32 OffsetFromZeroForDSD2Start; - u32 OffsetFromZeroForDSD2End; - u32 OffsetFromZeroForVSA1Start; - u32 OffsetFromZeroForVSA1End; - u32 OffsetFromZeroForVSA2Start; - u32 OffsetFromZeroForVSA2End; - /* - * ACCESS_BITS_PER_SECTOR 2 - * ACCESS_RW 0 - * ACCESS_RO 1 - * ACCESS_RESVD 2 - * ACCESS_RESVD 3 - */ - u32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)]; - /* All expansions to the control data structure should add here */ -}; - -struct bcm_vendor_section_info { - u32 OffsetFromZeroForSectionStart; - u32 OffsetFromZeroForSectionEnd; - u32 AccessFlags; - u32 Reserved[16]; -}; - -struct bcm_flash2x_vendor_info { - struct bcm_vendor_section_info VendorSection[TOTAL_SECTIONS]; - u32 Reserved[16]; -}; - -struct bcm_dsd_header { - u32 DSDImageSize; - u32 DSDImageCRC; - u32 DSDImagePriority; - /* We should not consider right now. Reading reserve is worthless. */ - u32 Reserved[252]; /* Resvd for DSD Header */ - u32 DSDImageMagicNumber; -}; - -struct bcm_iso_header { - u32 ISOImageMagicNumber; - u32 ISOImageSize; - u32 ISOImageCRC; - u32 ISOImagePriority; - /* We should not consider right now. Reading reserve is worthless. */ - u32 Reserved[60]; /* Resvd for ISO Header extension */ -}; - -#define EEPROM_BEGIN_CIS (0) -#define EEPROM_BEGIN_NON_CIS (0x200) -#define EEPROM_END (0x2000) -#define INIT_PARAMS_SIGNATURE (0x95a7a597) -#define MAX_INIT_PARAMS_LENGTH (2048) -#define MAC_ADDRESS_OFFSET 0x200 - -#define INIT_PARAMS_1_SIGNATURE_ADDRESS EEPROM_BEGIN_NON_CIS -#define INIT_PARAMS_1_DATA_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+16) -#define INIT_PARAMS_1_MACADDRESS_ADDRESS (MAC_ADDRESS_OFFSET) -#define INIT_PARAMS_1_LENGTH_ADDRESS (INIT_PARAMS_1_SIGNATURE_ADDRESS+4) - -#define INIT_PARAMS_2_SIGNATURE_ADDRESS (EEPROM_BEGIN_NON_CIS + 2048 + 16) -#define INIT_PARAMS_2_DATA_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 16) -#define INIT_PARAMS_2_MACADDRESS_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 8) -#define INIT_PARAMS_2_LENGTH_ADDRESS (INIT_PARAMS_2_SIGNATURE_ADDRESS + 4) - -#define EEPROM_SPI_DEV_CONFIG_REG 0x0F003000 -#define EEPROM_SPI_Q_STATUS1_REG 0x0F003004 -#define EEPROM_SPI_Q_STATUS1_MASK_REG 0x0F00300C - -#define EEPROM_SPI_Q_STATUS_REG 0x0F003008 -#define EEPROM_CMDQ_SPI_REG 0x0F003018 -#define EEPROM_WRITE_DATAQ_REG 0x0F00301C -#define EEPROM_READ_DATAQ_REG 0x0F003020 -#define SPI_FLUSH_REG 0x0F00304C - -#define EEPROM_WRITE_ENABLE 0x06000000 -#define EEPROM_READ_STATUS_REGISTER 0x05000000 -#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 -#define EEPROM_WRITE_QUEUE_EMPTY 0x00001000 -#define EEPROM_WRITE_QUEUE_AVAIL 0x00002000 -#define EEPROM_WRITE_QUEUE_FULL 0x00004000 -#define EEPROM_16_BYTE_PAGE_READ 0xFB000000 -#define EEPROM_4_BYTE_PAGE_READ 0x3B000000 - -#define EEPROM_CMD_QUEUE_FLUSH 0x00000001 -#define EEPROM_WRITE_QUEUE_FLUSH 0x00000002 -#define EEPROM_READ_QUEUE_FLUSH 0x00000004 -#define EEPROM_ETH_QUEUE_FLUSH 0x00000008 -#define EEPROM_ALL_QUEUE_FLUSH 0x0000000f -#define EEPROM_READ_ENABLE 0x06000000 -#define EEPROM_16_BYTE_PAGE_WRITE 0xFA000000 -#define EEPROM_READ_DATA_FULL 0x00000010 -#define EEPROM_READ_DATA_AVAIL 0x00000020 -#define EEPROM_READ_QUEUE_EMPTY 0x00000002 -#define EEPROM_CMD_QUEUE_EMPTY 0x00000100 -#define EEPROM_CMD_QUEUE_AVAIL 0x00000200 -#define EEPROM_CMD_QUEUE_FULL 0x00000400 - -/* Most EEPROM status register bit 0 indicates if the EEPROM is busy - * with a write if set 1. See the details of the EEPROM Status Register - * in the EEPROM data sheet. - */ -#define EEPROM_STATUS_REG_WRITE_BUSY 0x00000001 - -/* We will have 1 mSec for every RETRIES_PER_DELAY count and have a max attempts of MAX_EEPROM_RETRIES - * This will give us 80 mSec minimum of delay = 80mSecs - */ -#define MAX_EEPROM_RETRIES 80 -#define RETRIES_PER_DELAY 64 -#define MAX_RW_SIZE 0x10 -#define MAX_READ_SIZE 0x10 -#define MAX_SECTOR_SIZE (512 * 1024) -#define MIN_SECTOR_SIZE (1024) -#define FLASH_SECTOR_SIZE_OFFSET 0xEFFFC -#define FLASH_SECTOR_SIZE_SIG_OFFSET 0xEFFF8 -#define FLASH_SECTOR_SIZE_SIG 0xCAFEBABE -#define FLASH_CS_INFO_START_ADDR 0xFF0000 -#define FLASH_CONTROL_STRUCT_SIGNATURE 0xBECEF1A5 -#define SCSI_FIRMWARE_MAJOR_VERSION 0x1 -#define SCSI_FIRMWARE_MINOR_VERSION 0x5 -#define BYTE_WRITE_SUPPORT 0x1 -#define FLASH_AUTO_INIT_BASE_ADDR 0xF00000 -#define FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT 0x1C000000 -#define FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT 0x1F000000 -#define FLASH_CONTIGIOUS_START_ADDR_BCS350 0x08000000 -#define FLASH_CONTIGIOUS_END_ADDR_BCS350 0x08FFFFFF -#define FLASH_SIZE_ADDR 0xFFFFEC -#define FLASH_SPI_CMDQ_REG 0xAF003040 -#define FLASH_SPI_WRITEQ_REG 0xAF003044 -#define FLASH_SPI_READQ_REG 0xAF003048 -#define FLASH_CONFIG_REG 0xAF003050 -#define FLASH_GPIO_CONFIG_REG 0xAF000030 -#define FLASH_CMD_WRITE_ENABLE 0x06 -#define FLASH_CMD_READ_ENABLE 0x03 -#define FLASH_CMD_RESET_WRITE_ENABLE 0x04 -#define FLASH_CMD_STATUS_REG_READ 0x05 -#define FLASH_CMD_STATUS_REG_WRITE 0x01 -#define FLASH_CMD_READ_ID 0x9F -#define PAD_SELECT_REGISTER 0xAF000410 -#define FLASH_PART_SST25VF080B 0xBF258E -#define EEPROM_CAL_DATA_INTERNAL_LOC 0xbFB00008 -#define EEPROM_CALPARAM_START 0x200 -#define EEPROM_SIZE_OFFSET 524 - -/* As Read/Write time vaires from 1.5 to 3.0 ms. - * so After Ignoring the rdm/wrm time(that is dependent on many factor like interface etc.), - * here time calculated meets the worst case delay, 3.0 ms - */ -#define MAX_FLASH_RETRIES 4 -#define FLASH_PER_RETRIES_DELAY 16 -#define EEPROM_MAX_CAL_AREA_SIZE 0xF0000 -#define BECM ntohl(0x4245434d) -#define FLASH_2X_MAJOR_NUMBER 0x2 -#define DSD_IMAGE_MAGIC_NUMBER 0xBECE0D5D -#define ISO_IMAGE_MAGIC_NUMBER 0xBECE0150 -#define NON_CDLESS_DEVICE_BOOT_SIG 0xBECEB007 - -#define MINOR_VERSION(x) ((x >> 16) & 0xFFFF) -#define MAJOR_VERSION(x) (x & 0xFFFF) - -#define CORRUPTED_PATTERN 0x0 -#define UNINIT_PTR_IN_CS 0xBBBBDDDD -#define VENDOR_PTR_IN_CS 0xAAAACCCC -#define FLASH2X_SECTION_PRESENT (1 << 0) -#define FLASH2X_SECTION_VALID (1 << 1) -#define FLASH2X_SECTION_RO (1 << 2) -#define FLASH2X_SECTION_ACT (1 << 3) -#define SECTOR_IS_NOT_WRITABLE STATUS_FAILURE -#define INVALID_OFFSET STATUS_FAILURE -#define INVALID_SECTION STATUS_FAILURE -#define SECTOR_1K 1024 -#define SECTOR_64K (64 * SECTOR_1K) -#define SECTOR_128K (2 * SECTOR_64K) -#define SECTOR_256k (2 * SECTOR_128K) -#define SECTOR_512K (2 * SECTOR_256k) -#define FLASH_PART_SIZE (16 * 1024 * 1024) -#define RESET_CHIP_SELECT -1 -#define CHIP_SELECT_BIT12 12 -#define SECTOR_READWRITE_PERMISSION 0 -#define SECTOR_READONLY 1 -#define SIGNATURE_SIZE 4 -#define DEFAULT_BUFF_SIZE 0x10000 - -#define FIELD_OFFSET_IN_HEADER(HeaderPointer, Field) ((u8 *)&((HeaderPointer)(NULL))->Field - (u8 *)(NULL)) - -#endif - diff --git a/drivers/staging/bcm/sort.c b/drivers/staging/bcm/sort.c deleted file mode 100644 index ca0b17991512..000000000000 --- a/drivers/staging/bcm/sort.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "headers.h" -#include - -/* - * File Name: sort.c - * - * Author: Beceem Communications Pvt. Ltd - * - * Abstract: This file contains the routines sorting the classification rules. - * - * Copyright (c) 2007 Beceem Communications Pvt. Ltd - */ - -static int compare_packet_info(void const *a, void const *b) -{ - struct bcm_packet_info const *pa = a; - struct bcm_packet_info const *pb = b; - - if (!pa->bValid || !pb->bValid) - return 0; - - return pa->u8TrafficPriority - pb->u8TrafficPriority; -} - -VOID SortPackInfo(struct bcm_mini_adapter *Adapter) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, "<======="); - - sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(struct bcm_packet_info), - compare_packet_info, NULL); -} - -static int compare_classifiers(void const *a, void const *b) -{ - struct bcm_classifier_rule const *pa = a; - struct bcm_classifier_rule const *pb = b; - - if (!pa->bUsed || !pb->bUsed) - return 0; - - return pa->u8ClassifierRulePriority - pb->u8ClassifierRulePriority; -} - -VOID SortClassifiers(struct bcm_mini_adapter *Adapter) -{ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, - DBG_LVL_ALL, "<======="); - - sort(Adapter->astClassifierTable, MAX_CLASSIFIERS, - sizeof(struct bcm_classifier_rule), compare_classifiers, NULL); -} diff --git a/drivers/staging/bcm/target_params.h b/drivers/staging/bcm/target_params.h deleted file mode 100644 index dc45f9ab854d..000000000000 --- a/drivers/staging/bcm/target_params.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef TARGET_PARAMS_H -#define TARGET_PARAMS_H - -struct bcm_target_params { - u32 m_u32CfgVersion; - u32 m_u32CenterFrequency; - u32 m_u32BandAScan; - u32 m_u32BandBScan; - u32 m_u32BandCScan; - u32 m_u32ErtpsOptions; - u32 m_u32PHSEnable; - u32 m_u32HoEnable; - u32 m_u32HoReserved1; - u32 m_u32HoReserved2; - u32 m_u32MimoEnable; - u32 m_u32SecurityEnable; - u32 m_u32PowerSavingModesEnable; /* bit 1: 1 Idlemode enable; bit2: 1 Sleepmode Enable */ - /* PowerSaving Mode Options: - * bit 0 = 1: CPE mode - to keep pcmcia if alive; - * bit 1 = 1: CINR reporting in Idlemode Msg - * bit 2 = 1: Default PSC Enable in sleepmode - */ - u32 m_u32PowerSavingModeOptions; - u32 m_u32ArqEnable; - /* From Version #3, the HARQ section renamed as general */ - u32 m_u32HarqEnable; - u32 m_u32EEPROMFlag; - /* BINARY TYPE - 4th MSByte: Interface Type - 3rd MSByte: Vendor Type - 2nd MSByte - * Unused - LSByte - */ - u32 m_u32Customize; - u32 m_u32ConfigBW; /* In Hz */ - u32 m_u32ShutDownInitThresholdTimer; - u32 m_u32RadioParameter; - u32 m_u32PhyParameter1; - u32 m_u32PhyParameter2; - u32 m_u32PhyParameter3; - u32 m_u32TestOptions; /* in eval mode only; lower 16bits = basic cid for testing; then bit 16 is test cqich,bit 17 test init rang; bit 18 test periodic rang and bit 19 is test harq ack/nack */ - u32 m_u32MaxMACDataperDLFrame; - u32 m_u32MaxMACDataperULFrame; - u32 m_u32Corr2MacFlags; - u32 HostDrvrConfig1; - u32 HostDrvrConfig2; - u32 HostDrvrConfig3; - u32 HostDrvrConfig4; - u32 HostDrvrConfig5; - u32 HostDrvrConfig6; - u32 m_u32SegmentedPUSCenable; - /* removed SHUT down related 'unused' params from here to sync 4.x and 5.x CFG files.. - * BAMC Related Parameters - * Bit 0-15 Band AMC signaling configuration: Bit 1 = 1 – Enable Band AMC signaling. - * bit 16-31 Band AMC Data configuration: Bit 16 = 1 – Band AMC 2x3 support. - */ - u32 m_u32BandAMCEnable; -}; - -#endif diff --git a/drivers/staging/bcm/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c deleted file mode 100644 index 1d9bef6e4273..000000000000 --- a/drivers/staging/bcm/vendorspecificextn.c +++ /dev/null @@ -1,145 +0,0 @@ -#include "headers.h" -/* - * Procedure: vendorextnGetSectionInfo - * - * Description: Finds the type of NVM used. - * - * Arguments: - * Adapter - ptr to Adapter object instance - * pNVMType - ptr to NVM type. - * Returns: - * STATUS_SUCCESS/STATUS_FAILURE - * - */ -INT vendorextnGetSectionInfo(PVOID pContext, - struct bcm_flash2x_vendor_info *pVendorInfo) -{ - return STATUS_FAILURE; -} - -/* - * Procedure: vendorextnInit - * - * Description: Initializing the vendor extension NVM interface - * - * Arguments: - * Adapter - Pointer to MINI Adapter Structure - * Returns: - * STATUS_SUCCESS/STATUS_FAILURE - * - * - */ -INT vendorextnInit(struct bcm_mini_adapter *Adapter) -{ - return STATUS_SUCCESS; -} - -/* - * Procedure: vendorextnExit - * - * Description: Free the resource associated with vendor extension NVM interface - * - * Arguments: - * - * Returns: - * STATUS_SUCCESS/STATUS_FAILURE - * - * - */ -INT vendorextnExit(struct bcm_mini_adapter *Adapter) -{ - return STATUS_SUCCESS; -} - -/* - * Procedure: vendorextnIoctl - * - * Description: execute the vendor extension specific ioctl - * - * Arguments: - * Adapter -Beceem private Adapter Structure - * cmd -vendor extension specific Ioctl commad - * arg -input parameter sent by vendor - * - * Returns: - * CONTINUE_COMMON_PATH in case it is not meant to be processed - * by vendor ioctls - * STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value - */ - -INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg) -{ - return CONTINUE_COMMON_PATH; -} - - - -/* - * Procedure: vendorextnReadSection - * - * Description: Reads from a section of NVM - * - * Arguments: - * pContext - ptr to Adapter object instance - * pBuffer - Read the data from Vendor Area to this buffer - * SectionVal - Value of type of Section - * Offset - Read from the Offset of the Vendor Section. - * numOfBytes - Read numOfBytes from the Vendor section to Buffer - * - * Returns: - * STATUS_SUCCESS/STATUS_FAILURE - */ - -INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, - enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes) -{ - return STATUS_FAILURE; -} - - - -/* - * Procedure: vendorextnWriteSection - * - * Description: Write to a Section of NVM - * - * Arguments: - * pContext - ptr to Adapter object instance - * pBuffer - Write the data provided in the buffer - * SectionVal - Value of type of Section - * Offset - Writes to the Offset of the Vendor Section. - * numOfBytes - Write num Bytes after reading from pBuffer. - * bVerify - the Buffer Written should be verified. - * - * Returns: - * STATUS_SUCCESS/STATUS_FAILURE - */ -INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, - enum bcm_flash2x_section_val SectionVal, UINT offset, - UINT numOfBytes, bool bVerify) -{ - return STATUS_FAILURE; -} - - - -/* - * Procedure: vendorextnWriteSectionWithoutErase - * - * Description: Write to a Section of NVM without erasing the sector - * - * Arguments: - * pContext - ptr to Adapter object instance - * pBuffer - Write the data provided in the buffer - * SectionVal - Value of type of Section - * Offset - Writes to the Offset of the Vendor Section. - * numOfBytes - Write num Bytes after reading from pBuffer. - * - * Returns: - * STATUS_SUCCESS/STATUS_FAILURE - */ -INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, - enum bcm_flash2x_section_val SectionVal, UINT offset, UINT numOfBytes) -{ - return STATUS_FAILURE; -} diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h deleted file mode 100644 index ff57f0570451..000000000000 --- a/drivers/staging/bcm/vendorspecificextn.h +++ /dev/null @@ -1,18 +0,0 @@ - -#ifndef __VENDOR_EXTN_NVM_H__ -#define __VENDOR_EXTN_NVM_H__ - -#define CONTINUE_COMMON_PATH 0xFFFF - -INT vendorextnGetSectionInfo(PVOID pContext, struct bcm_flash2x_vendor_info *pVendorInfo); -INT vendorextnExit(struct bcm_mini_adapter *Adapter); -INT vendorextnInit(struct bcm_mini_adapter *Adapter); -INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg); -INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, - UINT offset, UINT numOfBytes); -INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, - UINT offset, UINT numOfBytes, bool bVerify); -INT vendorextnWriteSectionWithoutErase(PVOID pContext, PUCHAR pBuffer, enum bcm_flash2x_section_val SectionVal, - UINT offset, UINT numOfBytes); - -#endif /* */ -- cgit v1.2.3-59-g8ed1b From 777783e0abae3cab7555bb182776f9ffaa35631a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 16 Oct 2014 14:40:38 +0200 Subject: staging: android: binder: move to the "real" part of the kernel The Android binder code has been "stable" for many years now. No matter what comes in the future, we are going to have to support this API, so might as well move it to the "real" part of the kernel as there's no real work that needs to be done to the existing code. Signed-off-by: Greg Kroah-Hartman --- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/android/Kconfig | 37 + drivers/android/Makefile | 3 + drivers/android/binder.c | 3673 ++++++++++++++++++++++++++++++++ drivers/android/binder.h | 30 + drivers/android/binder_trace.h | 329 +++ drivers/staging/android/Kconfig | 30 - drivers/staging/android/Makefile | 1 - drivers/staging/android/binder.c | 3673 -------------------------------- drivers/staging/android/binder.h | 30 - drivers/staging/android/binder_trace.h | 329 --- drivers/staging/android/uapi/binder.h | 351 --- include/uapi/linux/Kbuild | 1 + include/uapi/linux/android/Kbuild | 2 + include/uapi/linux/android/binder.h | 351 +++ 16 files changed, 4429 insertions(+), 4414 deletions(-) create mode 100644 drivers/android/Kconfig create mode 100644 drivers/android/Makefile create mode 100644 drivers/android/binder.c create mode 100644 drivers/android/binder.h create mode 100644 drivers/android/binder_trace.h delete mode 100644 drivers/staging/android/binder.c delete mode 100644 drivers/staging/android/binder.h delete mode 100644 drivers/staging/android/binder_trace.h delete mode 100644 drivers/staging/android/uapi/binder.h create mode 100644 include/uapi/linux/android/Kbuild create mode 100644 include/uapi/linux/android/binder.h diff --git a/drivers/Kconfig b/drivers/Kconfig index 1a693d3f9d51..569ff7886dc3 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -182,4 +182,6 @@ source "drivers/ras/Kconfig" source "drivers/thunderbolt/Kconfig" +source "drivers/android/Kconfig" + endmenu diff --git a/drivers/Makefile b/drivers/Makefile index ebee55537a05..60d19820a4d4 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -161,3 +161,4 @@ obj-$(CONFIG_POWERCAP) += powercap/ obj-$(CONFIG_MCB) += mcb/ obj-$(CONFIG_RAS) += ras/ obj-$(CONFIG_THUNDERBOLT) += thunderbolt/ +obj-$(CONFIG_ANDROID) += android/ diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig new file mode 100644 index 000000000000..bdfc6c6f4f5a --- /dev/null +++ b/drivers/android/Kconfig @@ -0,0 +1,37 @@ +menu "Android" + +config ANDROID + bool "Android Drivers" + ---help--- + Enable support for various drivers needed on the Android platform + +if ANDROID + +config ANDROID_BINDER_IPC + bool "Android Binder IPC Driver" + depends on MMU + default n + ---help--- + Binder is used in Android for both communication between processes, + and remote method invocation. + + This means one Android process can call a method/routine in another + Android process, using Binder to identify, invoke and pass arguments + between said processes. + +config ANDROID_BINDER_IPC_32BIT + bool + 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. + + 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. + +endif # if ANDROID + +endmenu diff --git a/drivers/android/Makefile b/drivers/android/Makefile new file mode 100644 index 000000000000..3b7e4b072c58 --- /dev/null +++ b/drivers/android/Makefile @@ -0,0 +1,3 @@ +ccflags-y += -I$(src) # needed for trace events + +obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o diff --git a/drivers/android/binder.c b/drivers/android/binder.c new file mode 100644 index 000000000000..c69c40d69d5c --- /dev/null +++ b/drivers/android/binder.c @@ -0,0 +1,3673 @@ +/* binder.c + * + * Android IPC Subsystem + * + * Copyright (C) 2007-2008 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. + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "binder.h" +#include "binder_trace.h" + +static DEFINE_MUTEX(binder_main_lock); +static DEFINE_MUTEX(binder_deferred_lock); +static DEFINE_MUTEX(binder_mmap_lock); + +static HLIST_HEAD(binder_procs); +static HLIST_HEAD(binder_deferred_list); +static HLIST_HEAD(binder_dead_nodes); + +static struct dentry *binder_debugfs_dir_entry_root; +static struct dentry *binder_debugfs_dir_entry_proc; +static struct binder_node *binder_context_mgr_node; +static kuid_t binder_context_mgr_uid = INVALID_UID; +static int binder_last_id; +static struct workqueue_struct *binder_deferred_workqueue; + +#define BINDER_DEBUG_ENTRY(name) \ +static int binder_##name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, binder_##name##_show, inode->i_private); \ +} \ +\ +static const struct file_operations binder_##name##_fops = { \ + .owner = THIS_MODULE, \ + .open = binder_##name##_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +static int binder_proc_show(struct seq_file *m, void *unused); +BINDER_DEBUG_ENTRY(proc); + +/* This is only defined in include/asm-arm/sizes.h */ +#ifndef SZ_1K +#define SZ_1K 0x400 +#endif + +#ifndef SZ_4M +#define SZ_4M 0x400000 +#endif + +#define FORBIDDEN_MMAP_FLAGS (VM_WRITE) + +#define BINDER_SMALL_BUF_SIZE (PAGE_SIZE * 64) + +enum { + BINDER_DEBUG_USER_ERROR = 1U << 0, + BINDER_DEBUG_FAILED_TRANSACTION = 1U << 1, + BINDER_DEBUG_DEAD_TRANSACTION = 1U << 2, + BINDER_DEBUG_OPEN_CLOSE = 1U << 3, + BINDER_DEBUG_DEAD_BINDER = 1U << 4, + BINDER_DEBUG_DEATH_NOTIFICATION = 1U << 5, + BINDER_DEBUG_READ_WRITE = 1U << 6, + BINDER_DEBUG_USER_REFS = 1U << 7, + BINDER_DEBUG_THREADS = 1U << 8, + BINDER_DEBUG_TRANSACTION = 1U << 9, + BINDER_DEBUG_TRANSACTION_COMPLETE = 1U << 10, + BINDER_DEBUG_FREE_BUFFER = 1U << 11, + BINDER_DEBUG_INTERNAL_REFS = 1U << 12, + BINDER_DEBUG_BUFFER_ALLOC = 1U << 13, + BINDER_DEBUG_PRIORITY_CAP = 1U << 14, + BINDER_DEBUG_BUFFER_ALLOC_ASYNC = 1U << 15, +}; +static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR | + BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION; +module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO); + +static bool binder_debug_no_lock; +module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO); + +static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait); +static int binder_stop_on_user_error; + +static int binder_set_stop_on_user_error(const char *val, + struct kernel_param *kp) +{ + int ret; + + ret = param_set_int(val, kp); + if (binder_stop_on_user_error < 2) + wake_up(&binder_user_error_wait); + return ret; +} +module_param_call(stop_on_user_error, binder_set_stop_on_user_error, + param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO); + +#define binder_debug(mask, x...) \ + do { \ + if (binder_debug_mask & mask) \ + pr_info(x); \ + } while (0) + +#define binder_user_error(x...) \ + do { \ + if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \ + pr_info(x); \ + if (binder_stop_on_user_error) \ + binder_stop_on_user_error = 2; \ + } while (0) + +enum binder_stat_types { + BINDER_STAT_PROC, + BINDER_STAT_THREAD, + BINDER_STAT_NODE, + BINDER_STAT_REF, + BINDER_STAT_DEATH, + BINDER_STAT_TRANSACTION, + BINDER_STAT_TRANSACTION_COMPLETE, + BINDER_STAT_COUNT +}; + +struct binder_stats { + int br[_IOC_NR(BR_FAILED_REPLY) + 1]; + int bc[_IOC_NR(BC_DEAD_BINDER_DONE) + 1]; + int obj_created[BINDER_STAT_COUNT]; + int obj_deleted[BINDER_STAT_COUNT]; +}; + +static struct binder_stats binder_stats; + +static inline void binder_stats_deleted(enum binder_stat_types type) +{ + binder_stats.obj_deleted[type]++; +} + +static inline void binder_stats_created(enum binder_stat_types type) +{ + binder_stats.obj_created[type]++; +} + +struct binder_transaction_log_entry { + int debug_id; + int call_type; + int from_proc; + int from_thread; + int target_handle; + int to_proc; + int to_thread; + int to_node; + int data_size; + int offsets_size; +}; +struct binder_transaction_log { + int next; + int full; + struct binder_transaction_log_entry entry[32]; +}; +static struct binder_transaction_log binder_transaction_log; +static struct binder_transaction_log binder_transaction_log_failed; + +static struct binder_transaction_log_entry *binder_transaction_log_add( + struct binder_transaction_log *log) +{ + struct binder_transaction_log_entry *e; + + e = &log->entry[log->next]; + memset(e, 0, sizeof(*e)); + log->next++; + if (log->next == ARRAY_SIZE(log->entry)) { + log->next = 0; + log->full = 1; + } + return e; +} + +struct binder_work { + struct list_head entry; + enum { + BINDER_WORK_TRANSACTION = 1, + BINDER_WORK_TRANSACTION_COMPLETE, + BINDER_WORK_NODE, + BINDER_WORK_DEAD_BINDER, + BINDER_WORK_DEAD_BINDER_AND_CLEAR, + BINDER_WORK_CLEAR_DEATH_NOTIFICATION, + } type; +}; + +struct binder_node { + int debug_id; + struct binder_work work; + union { + struct rb_node rb_node; + struct hlist_node dead_node; + }; + struct binder_proc *proc; + struct hlist_head refs; + int internal_strong_refs; + int local_weak_refs; + int local_strong_refs; + binder_uintptr_t ptr; + binder_uintptr_t cookie; + unsigned has_strong_ref:1; + unsigned pending_strong_ref:1; + unsigned has_weak_ref:1; + unsigned pending_weak_ref:1; + unsigned has_async_transaction:1; + unsigned accept_fds:1; + unsigned min_priority:8; + struct list_head async_todo; +}; + +struct binder_ref_death { + struct binder_work work; + binder_uintptr_t cookie; +}; + +struct binder_ref { + /* Lookups needed: */ + /* node + proc => ref (transaction) */ + /* desc + proc => ref (transaction, inc/dec ref) */ + /* node => refs + procs (proc exit) */ + int debug_id; + struct rb_node rb_node_desc; + struct rb_node rb_node_node; + struct hlist_node node_entry; + struct binder_proc *proc; + struct binder_node *node; + uint32_t desc; + int strong; + int weak; + struct binder_ref_death *death; +}; + +struct binder_buffer { + struct list_head entry; /* free and allocated entries by address */ + struct rb_node rb_node; /* free entry by size or allocated entry */ + /* by address */ + unsigned free:1; + unsigned allow_user_free:1; + unsigned async_transaction:1; + unsigned debug_id:29; + + struct binder_transaction *transaction; + + struct binder_node *target_node; + size_t data_size; + size_t offsets_size; + uint8_t data[0]; +}; + +enum binder_deferred_state { + BINDER_DEFERRED_PUT_FILES = 0x01, + BINDER_DEFERRED_FLUSH = 0x02, + BINDER_DEFERRED_RELEASE = 0x04, +}; + +struct binder_proc { + struct hlist_node proc_node; + struct rb_root threads; + struct rb_root nodes; + struct rb_root refs_by_desc; + struct rb_root refs_by_node; + int pid; + struct vm_area_struct *vma; + struct mm_struct *vma_vm_mm; + struct task_struct *tsk; + struct files_struct *files; + struct hlist_node deferred_work_node; + int deferred_work; + void *buffer; + ptrdiff_t user_buffer_offset; + + struct list_head buffers; + struct rb_root free_buffers; + struct rb_root allocated_buffers; + size_t free_async_space; + + struct page **pages; + size_t buffer_size; + uint32_t buffer_free; + struct list_head todo; + wait_queue_head_t wait; + struct binder_stats stats; + struct list_head delivered_death; + int max_threads; + int requested_threads; + int requested_threads_started; + int ready_threads; + long default_priority; + struct dentry *debugfs_entry; +}; + +enum { + BINDER_LOOPER_STATE_REGISTERED = 0x01, + BINDER_LOOPER_STATE_ENTERED = 0x02, + BINDER_LOOPER_STATE_EXITED = 0x04, + BINDER_LOOPER_STATE_INVALID = 0x08, + BINDER_LOOPER_STATE_WAITING = 0x10, + BINDER_LOOPER_STATE_NEED_RETURN = 0x20 +}; + +struct binder_thread { + struct binder_proc *proc; + struct rb_node rb_node; + int pid; + int looper; + struct binder_transaction *transaction_stack; + struct list_head todo; + uint32_t return_error; /* Write failed, return error code in read buf */ + uint32_t return_error2; /* Write failed, return error code in read */ + /* buffer. Used when sending a reply to a dead process that */ + /* we are also waiting on */ + wait_queue_head_t wait; + struct binder_stats stats; +}; + +struct binder_transaction { + int debug_id; + struct binder_work work; + struct binder_thread *from; + struct binder_transaction *from_parent; + struct binder_proc *to_proc; + struct binder_thread *to_thread; + struct binder_transaction *to_parent; + unsigned need_reply:1; + /* unsigned is_dead:1; */ /* not used at the moment */ + + struct binder_buffer *buffer; + unsigned int code; + unsigned int flags; + long priority; + long saved_priority; + kuid_t sender_euid; +}; + +static void +binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer); + +static int task_get_unused_fd_flags(struct binder_proc *proc, int flags) +{ + struct files_struct *files = proc->files; + unsigned long rlim_cur; + unsigned long irqs; + + if (files == NULL) + return -ESRCH; + + if (!lock_task_sighand(proc->tsk, &irqs)) + return -EMFILE; + + rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE); + unlock_task_sighand(proc->tsk, &irqs); + + return __alloc_fd(files, 0, rlim_cur, flags); +} + +/* + * copied from fd_install + */ +static void task_fd_install( + struct binder_proc *proc, unsigned int fd, struct file *file) +{ + if (proc->files) + __fd_install(proc->files, fd, file); +} + +/* + * copied from sys_close + */ +static long task_close_fd(struct binder_proc *proc, unsigned int fd) +{ + int retval; + + if (proc->files == NULL) + return -ESRCH; + + retval = __close_fd(proc->files, fd); + /* can't restart close syscall because file table entry was cleared */ + if (unlikely(retval == -ERESTARTSYS || + retval == -ERESTARTNOINTR || + retval == -ERESTARTNOHAND || + retval == -ERESTART_RESTARTBLOCK)) + retval = -EINTR; + + return retval; +} + +static inline void binder_lock(const char *tag) +{ + trace_binder_lock(tag); + mutex_lock(&binder_main_lock); + trace_binder_locked(tag); +} + +static inline void binder_unlock(const char *tag) +{ + trace_binder_unlock(tag); + mutex_unlock(&binder_main_lock); +} + +static void binder_set_nice(long nice) +{ + long min_nice; + + if (can_nice(current, nice)) { + set_user_nice(current, nice); + return; + } + min_nice = rlimit_to_nice(current->signal->rlim[RLIMIT_NICE].rlim_cur); + binder_debug(BINDER_DEBUG_PRIORITY_CAP, + "%d: nice value %ld not allowed use %ld instead\n", + current->pid, nice, min_nice); + set_user_nice(current, min_nice); + if (min_nice <= MAX_NICE) + return; + binder_user_error("%d RLIMIT_NICE not set\n", current->pid); +} + +static size_t binder_buffer_size(struct binder_proc *proc, + struct binder_buffer *buffer) +{ + if (list_is_last(&buffer->entry, &proc->buffers)) + return proc->buffer + proc->buffer_size - (void *)buffer->data; + return (size_t)list_entry(buffer->entry.next, + struct binder_buffer, entry) - (size_t)buffer->data; +} + +static void binder_insert_free_buffer(struct binder_proc *proc, + struct binder_buffer *new_buffer) +{ + struct rb_node **p = &proc->free_buffers.rb_node; + struct rb_node *parent = NULL; + struct binder_buffer *buffer; + size_t buffer_size; + size_t new_buffer_size; + + BUG_ON(!new_buffer->free); + + new_buffer_size = binder_buffer_size(proc, new_buffer); + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: add free buffer, size %zd, at %p\n", + proc->pid, new_buffer_size, new_buffer); + + while (*p) { + parent = *p; + buffer = rb_entry(parent, struct binder_buffer, rb_node); + BUG_ON(!buffer->free); + + buffer_size = binder_buffer_size(proc, buffer); + + if (new_buffer_size < buffer_size) + p = &parent->rb_left; + else + p = &parent->rb_right; + } + rb_link_node(&new_buffer->rb_node, parent, p); + rb_insert_color(&new_buffer->rb_node, &proc->free_buffers); +} + +static void binder_insert_allocated_buffer(struct binder_proc *proc, + struct binder_buffer *new_buffer) +{ + struct rb_node **p = &proc->allocated_buffers.rb_node; + struct rb_node *parent = NULL; + struct binder_buffer *buffer; + + BUG_ON(new_buffer->free); + + while (*p) { + parent = *p; + buffer = rb_entry(parent, struct binder_buffer, rb_node); + BUG_ON(buffer->free); + + if (new_buffer < buffer) + p = &parent->rb_left; + else if (new_buffer > buffer) + p = &parent->rb_right; + else + BUG(); + } + rb_link_node(&new_buffer->rb_node, parent, p); + rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers); +} + +static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc, + uintptr_t user_ptr) +{ + struct rb_node *n = proc->allocated_buffers.rb_node; + struct binder_buffer *buffer; + struct binder_buffer *kern_ptr; + + 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); + BUG_ON(buffer->free); + + if (kern_ptr < buffer) + n = n->rb_left; + else if (kern_ptr > buffer) + n = n->rb_right; + else + return buffer; + } + return NULL; +} + +static int binder_update_page_range(struct binder_proc *proc, int allocate, + void *start, void *end, + struct vm_area_struct *vma) +{ + void *page_addr; + unsigned long user_page_addr; + struct vm_struct tmp_area; + struct page **page; + struct mm_struct *mm; + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: %s pages %p-%p\n", proc->pid, + allocate ? "allocate" : "free", start, end); + + if (end <= start) + return 0; + + trace_binder_update_page_range(proc, allocate, start, end); + + if (vma) + mm = NULL; + else + mm = get_task_mm(proc->tsk); + + if (mm) { + down_write(&mm->mmap_sem); + vma = proc->vma; + if (vma && mm != proc->vma_vm_mm) { + pr_err("%d: vma mm and task mm mismatch\n", + proc->pid); + vma = NULL; + } + } + + if (allocate == 0) + goto free_range; + + if (vma == NULL) { + pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n", + proc->pid); + goto err_no_vma; + } + + for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) { + int ret; + + page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; + + BUG_ON(*page); + *page = alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO); + if (*page == NULL) { + pr_err("%d: binder_alloc_buf failed for page at %p\n", + proc->pid, page_addr); + goto err_alloc_page_failed; + } + tmp_area.addr = page_addr; + tmp_area.size = PAGE_SIZE + PAGE_SIZE /* guard page? */; + ret = map_vm_area(&tmp_area, PAGE_KERNEL, page); + if (ret) { + pr_err("%d: binder_alloc_buf failed to map page at %p in kernel\n", + proc->pid, page_addr); + goto err_map_kernel_failed; + } + user_page_addr = + (uintptr_t)page_addr + proc->user_buffer_offset; + ret = vm_insert_page(vma, user_page_addr, page[0]); + if (ret) { + pr_err("%d: binder_alloc_buf failed to map page at %lx in userspace\n", + proc->pid, user_page_addr); + goto err_vm_insert_page_failed; + } + /* vm_insert_page does not seem to increment the refcount */ + } + if (mm) { + up_write(&mm->mmap_sem); + mmput(mm); + } + return 0; + +free_range: + for (page_addr = end - PAGE_SIZE; page_addr >= start; + page_addr -= PAGE_SIZE) { + page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; + if (vma) + zap_page_range(vma, (uintptr_t)page_addr + + proc->user_buffer_offset, PAGE_SIZE, NULL); +err_vm_insert_page_failed: + unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE); +err_map_kernel_failed: + __free_page(*page); + *page = NULL; +err_alloc_page_failed: + ; + } +err_no_vma: + if (mm) { + up_write(&mm->mmap_sem); + mmput(mm); + } + return -ENOMEM; +} + +static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc, + size_t data_size, + size_t offsets_size, int is_async) +{ + struct rb_node *n = proc->free_buffers.rb_node; + struct binder_buffer *buffer; + size_t buffer_size; + struct rb_node *best_fit = NULL; + void *has_page_addr; + void *end_page_addr; + size_t size; + + if (proc->vma == NULL) { + pr_err("%d: binder_alloc_buf, no vma\n", + proc->pid); + return NULL; + } + + size = ALIGN(data_size, sizeof(void *)) + + ALIGN(offsets_size, sizeof(void *)); + + if (size < data_size || size < offsets_size) { + binder_user_error("%d: got transaction with invalid size %zd-%zd\n", + proc->pid, data_size, offsets_size); + return NULL; + } + + if (is_async && + proc->free_async_space < size + sizeof(struct binder_buffer)) { + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: binder_alloc_buf size %zd failed, no async space left\n", + proc->pid, size); + return NULL; + } + + while (n) { + buffer = rb_entry(n, struct binder_buffer, rb_node); + BUG_ON(!buffer->free); + buffer_size = binder_buffer_size(proc, buffer); + + if (size < buffer_size) { + best_fit = n; + n = n->rb_left; + } else if (size > buffer_size) + n = n->rb_right; + else { + best_fit = n; + break; + } + } + if (best_fit == NULL) { + pr_err("%d: binder_alloc_buf size %zd failed, no address space\n", + proc->pid, size); + return NULL; + } + if (n == NULL) { + buffer = rb_entry(best_fit, struct binder_buffer, rb_node); + buffer_size = binder_buffer_size(proc, buffer); + } + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: binder_alloc_buf size %zd got buffer %p size %zd\n", + proc->pid, size, buffer, buffer_size); + + has_page_addr = + (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK); + if (n == NULL) { + if (size + sizeof(struct binder_buffer) + 4 >= buffer_size) + buffer_size = size; /* no room for other buffers */ + else + buffer_size = size + sizeof(struct binder_buffer); + } + end_page_addr = + (void *)PAGE_ALIGN((uintptr_t)buffer->data + buffer_size); + if (end_page_addr > has_page_addr) + end_page_addr = has_page_addr; + if (binder_update_page_range(proc, 1, + (void *)PAGE_ALIGN((uintptr_t)buffer->data), end_page_addr, NULL)) + return NULL; + + rb_erase(best_fit, &proc->free_buffers); + buffer->free = 0; + binder_insert_allocated_buffer(proc, buffer); + if (buffer_size != size) { + struct binder_buffer *new_buffer = (void *)buffer->data + size; + + list_add(&new_buffer->entry, &buffer->entry); + new_buffer->free = 1; + binder_insert_free_buffer(proc, new_buffer); + } + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: binder_alloc_buf size %zd got %p\n", + proc->pid, size, buffer); + buffer->data_size = data_size; + buffer->offsets_size = offsets_size; + buffer->async_transaction = is_async; + if (is_async) { + proc->free_async_space -= size + sizeof(struct binder_buffer); + binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, + "%d: binder_alloc_buf size %zd async free %zd\n", + proc->pid, size, proc->free_async_space); + } + + return buffer; +} + +static void *buffer_start_page(struct binder_buffer *buffer) +{ + return (void *)((uintptr_t)buffer & PAGE_MASK); +} + +static void *buffer_end_page(struct binder_buffer *buffer) +{ + return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK); +} + +static void binder_delete_free_buffer(struct binder_proc *proc, + struct binder_buffer *buffer) +{ + struct binder_buffer *prev, *next = NULL; + int free_page_end = 1; + int free_page_start = 1; + + BUG_ON(proc->buffers.next == &buffer->entry); + prev = list_entry(buffer->entry.prev, struct binder_buffer, entry); + BUG_ON(!prev->free); + if (buffer_end_page(prev) == buffer_start_page(buffer)) { + free_page_start = 0; + if (buffer_end_page(prev) == buffer_end_page(buffer)) + free_page_end = 0; + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: merge free, buffer %p share page with %p\n", + proc->pid, buffer, prev); + } + + if (!list_is_last(&buffer->entry, &proc->buffers)) { + next = list_entry(buffer->entry.next, + struct binder_buffer, entry); + if (buffer_start_page(next) == buffer_end_page(buffer)) { + free_page_end = 0; + if (buffer_start_page(next) == + buffer_start_page(buffer)) + free_page_start = 0; + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: merge free, buffer %p share page with %p\n", + proc->pid, buffer, prev); + } + } + list_del(&buffer->entry); + if (free_page_start || free_page_end) { + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: merge free, buffer %p do not share page%s%s with %p or %p\n", + proc->pid, buffer, free_page_start ? "" : " end", + free_page_end ? "" : " start", prev, next); + binder_update_page_range(proc, 0, free_page_start ? + buffer_start_page(buffer) : buffer_end_page(buffer), + (free_page_end ? buffer_end_page(buffer) : + buffer_start_page(buffer)) + PAGE_SIZE, NULL); + } +} + +static void binder_free_buf(struct binder_proc *proc, + struct binder_buffer *buffer) +{ + size_t size, buffer_size; + + buffer_size = binder_buffer_size(proc, buffer); + + size = ALIGN(buffer->data_size, sizeof(void *)) + + ALIGN(buffer->offsets_size, sizeof(void *)); + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%d: binder_free_buf %p size %zd buffer_size %zd\n", + proc->pid, buffer, size, buffer_size); + + BUG_ON(buffer->free); + BUG_ON(size > buffer_size); + BUG_ON(buffer->transaction != NULL); + BUG_ON((void *)buffer < proc->buffer); + BUG_ON((void *)buffer > proc->buffer + proc->buffer_size); + + if (buffer->async_transaction) { + proc->free_async_space += size + sizeof(struct binder_buffer); + + binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, + "%d: binder_free_buf size %zd async free %zd\n", + proc->pid, size, proc->free_async_space); + } + + binder_update_page_range(proc, 0, + (void *)PAGE_ALIGN((uintptr_t)buffer->data), + (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK), + NULL); + rb_erase(&buffer->rb_node, &proc->allocated_buffers); + buffer->free = 1; + if (!list_is_last(&buffer->entry, &proc->buffers)) { + struct binder_buffer *next = list_entry(buffer->entry.next, + struct binder_buffer, entry); + + if (next->free) { + rb_erase(&next->rb_node, &proc->free_buffers); + binder_delete_free_buffer(proc, next); + } + } + if (proc->buffers.next != &buffer->entry) { + struct binder_buffer *prev = list_entry(buffer->entry.prev, + struct binder_buffer, entry); + + if (prev->free) { + binder_delete_free_buffer(proc, buffer); + rb_erase(&prev->rb_node, &proc->free_buffers); + buffer = prev; + } + } + binder_insert_free_buffer(proc, buffer); +} + +static struct binder_node *binder_get_node(struct binder_proc *proc, + binder_uintptr_t ptr) +{ + struct rb_node *n = proc->nodes.rb_node; + struct binder_node *node; + + while (n) { + node = rb_entry(n, struct binder_node, rb_node); + + if (ptr < node->ptr) + n = n->rb_left; + else if (ptr > node->ptr) + n = n->rb_right; + else + return node; + } + return NULL; +} + +static struct binder_node *binder_new_node(struct binder_proc *proc, + binder_uintptr_t ptr, + binder_uintptr_t cookie) +{ + struct rb_node **p = &proc->nodes.rb_node; + struct rb_node *parent = NULL; + struct binder_node *node; + + while (*p) { + parent = *p; + node = rb_entry(parent, struct binder_node, rb_node); + + if (ptr < node->ptr) + p = &(*p)->rb_left; + else if (ptr > node->ptr) + p = &(*p)->rb_right; + else + return NULL; + } + + node = kzalloc(sizeof(*node), GFP_KERNEL); + if (node == NULL) + return NULL; + binder_stats_created(BINDER_STAT_NODE); + rb_link_node(&node->rb_node, parent, p); + rb_insert_color(&node->rb_node, &proc->nodes); + node->debug_id = ++binder_last_id; + node->proc = proc; + node->ptr = ptr; + node->cookie = cookie; + node->work.type = BINDER_WORK_NODE; + INIT_LIST_HEAD(&node->work.entry); + INIT_LIST_HEAD(&node->async_todo); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "%d:%d node %d u%016llx c%016llx created\n", + proc->pid, current->pid, node->debug_id, + (u64)node->ptr, (u64)node->cookie); + return node; +} + +static int binder_inc_node(struct binder_node *node, int strong, int internal, + struct list_head *target_list) +{ + if (strong) { + if (internal) { + if (target_list == NULL && + node->internal_strong_refs == 0 && + !(node == binder_context_mgr_node && + node->has_strong_ref)) { + pr_err("invalid inc strong node for %d\n", + node->debug_id); + return -EINVAL; + } + node->internal_strong_refs++; + } else + node->local_strong_refs++; + if (!node->has_strong_ref && target_list) { + list_del_init(&node->work.entry); + list_add_tail(&node->work.entry, target_list); + } + } else { + if (!internal) + node->local_weak_refs++; + if (!node->has_weak_ref && list_empty(&node->work.entry)) { + if (target_list == NULL) { + pr_err("invalid inc weak node for %d\n", + node->debug_id); + return -EINVAL; + } + list_add_tail(&node->work.entry, target_list); + } + } + return 0; +} + +static int binder_dec_node(struct binder_node *node, int strong, int internal) +{ + if (strong) { + if (internal) + node->internal_strong_refs--; + else + node->local_strong_refs--; + if (node->local_strong_refs || node->internal_strong_refs) + return 0; + } else { + if (!internal) + node->local_weak_refs--; + if (node->local_weak_refs || !hlist_empty(&node->refs)) + return 0; + } + if (node->proc && (node->has_strong_ref || node->has_weak_ref)) { + if (list_empty(&node->work.entry)) { + list_add_tail(&node->work.entry, &node->proc->todo); + wake_up_interruptible(&node->proc->wait); + } + } else { + if (hlist_empty(&node->refs) && !node->local_strong_refs && + !node->local_weak_refs) { + list_del_init(&node->work.entry); + if (node->proc) { + rb_erase(&node->rb_node, &node->proc->nodes); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "refless node %d deleted\n", + node->debug_id); + } else { + hlist_del(&node->dead_node); + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "dead node %d deleted\n", + node->debug_id); + } + kfree(node); + binder_stats_deleted(BINDER_STAT_NODE); + } + } + + return 0; +} + + +static struct binder_ref *binder_get_ref(struct binder_proc *proc, + uint32_t desc) +{ + struct rb_node *n = proc->refs_by_desc.rb_node; + struct binder_ref *ref; + + while (n) { + ref = rb_entry(n, struct binder_ref, rb_node_desc); + + if (desc < ref->desc) + n = n->rb_left; + else if (desc > ref->desc) + n = n->rb_right; + else + return ref; + } + return NULL; +} + +static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc, + struct binder_node *node) +{ + struct rb_node *n; + struct rb_node **p = &proc->refs_by_node.rb_node; + struct rb_node *parent = NULL; + struct binder_ref *ref, *new_ref; + + while (*p) { + parent = *p; + ref = rb_entry(parent, struct binder_ref, rb_node_node); + + if (node < ref->node) + p = &(*p)->rb_left; + else if (node > ref->node) + p = &(*p)->rb_right; + else + return ref; + } + new_ref = kzalloc(sizeof(*ref), GFP_KERNEL); + if (new_ref == NULL) + return NULL; + binder_stats_created(BINDER_STAT_REF); + new_ref->debug_id = ++binder_last_id; + new_ref->proc = proc; + new_ref->node = node; + rb_link_node(&new_ref->rb_node_node, parent, p); + rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); + + new_ref->desc = (node == binder_context_mgr_node) ? 0 : 1; + for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { + ref = rb_entry(n, struct binder_ref, rb_node_desc); + if (ref->desc > new_ref->desc) + break; + new_ref->desc = ref->desc + 1; + } + + p = &proc->refs_by_desc.rb_node; + while (*p) { + parent = *p; + ref = rb_entry(parent, struct binder_ref, rb_node_desc); + + if (new_ref->desc < ref->desc) + p = &(*p)->rb_left; + else if (new_ref->desc > ref->desc) + p = &(*p)->rb_right; + else + BUG(); + } + rb_link_node(&new_ref->rb_node_desc, parent, p); + rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); + if (node) { + hlist_add_head(&new_ref->node_entry, &node->refs); + + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "%d new ref %d desc %d for node %d\n", + proc->pid, new_ref->debug_id, new_ref->desc, + node->debug_id); + } else { + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "%d new ref %d desc %d for dead node\n", + proc->pid, new_ref->debug_id, new_ref->desc); + } + return new_ref; +} + +static void binder_delete_ref(struct binder_ref *ref) +{ + binder_debug(BINDER_DEBUG_INTERNAL_REFS, + "%d delete ref %d desc %d for node %d\n", + ref->proc->pid, ref->debug_id, ref->desc, + ref->node->debug_id); + + rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); + rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); + if (ref->strong) + binder_dec_node(ref->node, 1, 1); + hlist_del(&ref->node_entry); + binder_dec_node(ref->node, 0, 1); + if (ref->death) { + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "%d delete ref %d desc %d has death notification\n", + ref->proc->pid, ref->debug_id, ref->desc); + list_del(&ref->death->work.entry); + kfree(ref->death); + binder_stats_deleted(BINDER_STAT_DEATH); + } + kfree(ref); + binder_stats_deleted(BINDER_STAT_REF); +} + +static int binder_inc_ref(struct binder_ref *ref, int strong, + struct list_head *target_list) +{ + int ret; + + if (strong) { + if (ref->strong == 0) { + ret = binder_inc_node(ref->node, 1, 1, target_list); + if (ret) + return ret; + } + ref->strong++; + } else { + if (ref->weak == 0) { + ret = binder_inc_node(ref->node, 0, 1, target_list); + if (ret) + return ret; + } + ref->weak++; + } + return 0; +} + + +static int binder_dec_ref(struct binder_ref *ref, int strong) +{ + if (strong) { + if (ref->strong == 0) { + binder_user_error("%d invalid dec strong, ref %d desc %d s %d w %d\n", + ref->proc->pid, ref->debug_id, + ref->desc, ref->strong, ref->weak); + return -EINVAL; + } + ref->strong--; + if (ref->strong == 0) { + int ret; + + ret = binder_dec_node(ref->node, strong, 1); + if (ret) + return ret; + } + } else { + if (ref->weak == 0) { + binder_user_error("%d invalid dec weak, ref %d desc %d s %d w %d\n", + ref->proc->pid, ref->debug_id, + ref->desc, ref->strong, ref->weak); + return -EINVAL; + } + ref->weak--; + } + if (ref->strong == 0 && ref->weak == 0) + binder_delete_ref(ref); + return 0; +} + +static void binder_pop_transaction(struct binder_thread *target_thread, + struct binder_transaction *t) +{ + if (target_thread) { + BUG_ON(target_thread->transaction_stack != t); + BUG_ON(target_thread->transaction_stack->from != target_thread); + target_thread->transaction_stack = + target_thread->transaction_stack->from_parent; + t->from = NULL; + } + t->need_reply = 0; + if (t->buffer) + t->buffer->transaction = NULL; + kfree(t); + binder_stats_deleted(BINDER_STAT_TRANSACTION); +} + +static void binder_send_failed_reply(struct binder_transaction *t, + uint32_t error_code) +{ + struct binder_thread *target_thread; + struct binder_transaction *next; + + BUG_ON(t->flags & TF_ONE_WAY); + while (1) { + target_thread = t->from; + if (target_thread) { + if (target_thread->return_error != BR_OK && + target_thread->return_error2 == BR_OK) { + target_thread->return_error2 = + target_thread->return_error; + target_thread->return_error = BR_OK; + } + if (target_thread->return_error == BR_OK) { + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "send failed reply for transaction %d to %d:%d\n", + t->debug_id, + target_thread->proc->pid, + target_thread->pid); + + binder_pop_transaction(target_thread, t); + target_thread->return_error = error_code; + wake_up_interruptible(&target_thread->wait); + } else { + pr_err("reply failed, target thread, %d:%d, has error code %d already\n", + target_thread->proc->pid, + target_thread->pid, + target_thread->return_error); + } + return; + } + next = t->from_parent; + + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "send failed reply for transaction %d, target dead\n", + t->debug_id); + + binder_pop_transaction(target_thread, t); + if (next == NULL) { + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "reply failed, no target thread at root\n"); + return; + } + t = next; + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "reply failed, no target thread -- retry %d\n", + t->debug_id); + } +} + +static void binder_transaction_buffer_release(struct binder_proc *proc, + struct binder_buffer *buffer, + binder_size_t *failed_at) +{ + binder_size_t *offp, *off_end; + int debug_id = buffer->debug_id; + + binder_debug(BINDER_DEBUG_TRANSACTION, + "%d buffer release %d, size %zd-%zd, failed at %p\n", + proc->pid, buffer->debug_id, + buffer->data_size, buffer->offsets_size, failed_at); + + if (buffer->target_node) + binder_dec_node(buffer->target_node, 1, 0); + + offp = (binder_size_t *)(buffer->data + + ALIGN(buffer->data_size, sizeof(void *))); + if (failed_at) + off_end = failed_at; + else + off_end = (void *)offp + buffer->offsets_size; + for (; offp < off_end; offp++) { + struct flat_binder_object *fp; + + if (*offp > buffer->data_size - sizeof(*fp) || + buffer->data_size < sizeof(*fp) || + !IS_ALIGNED(*offp, sizeof(u32))) { + 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); + switch (fp->type) { + case BINDER_TYPE_BINDER: + case BINDER_TYPE_WEAK_BINDER: { + struct binder_node *node = binder_get_node(proc, fp->binder); + + if (node == NULL) { + pr_err("transaction release %d bad node %016llx\n", + debug_id, (u64)fp->binder); + break; + } + binder_debug(BINDER_DEBUG_TRANSACTION, + " 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: + case BINDER_TYPE_WEAK_HANDLE: { + struct binder_ref *ref = binder_get_ref(proc, fp->handle); + + if (ref == NULL) { + pr_err("transaction release %d bad handle %d\n", + debug_id, fp->handle); + break; + } + binder_debug(BINDER_DEBUG_TRANSACTION, + " ref %d desc %d (node %d)\n", + ref->debug_id, ref->desc, ref->node->debug_id); + binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE); + } break; + + case BINDER_TYPE_FD: + binder_debug(BINDER_DEBUG_TRANSACTION, + " fd %d\n", fp->handle); + if (failed_at) + task_close_fd(proc, fp->handle); + break; + + default: + pr_err("transaction release %d bad object type %x\n", + debug_id, fp->type); + break; + } + } +} + +static void binder_transaction(struct binder_proc *proc, + struct binder_thread *thread, + struct binder_transaction_data *tr, int reply) +{ + struct binder_transaction *t; + struct binder_work *tcomplete; + binder_size_t *offp, *off_end; + struct binder_proc *target_proc; + struct binder_thread *target_thread = NULL; + struct binder_node *target_node = NULL; + struct list_head *target_list; + wait_queue_head_t *target_wait; + struct binder_transaction *in_reply_to = NULL; + struct binder_transaction_log_entry *e; + uint32_t return_error; + + e = binder_transaction_log_add(&binder_transaction_log); + e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY); + e->from_proc = proc->pid; + e->from_thread = thread->pid; + e->target_handle = tr->target.handle; + e->data_size = tr->data_size; + e->offsets_size = tr->offsets_size; + + if (reply) { + in_reply_to = thread->transaction_stack; + if (in_reply_to == NULL) { + binder_user_error("%d:%d got reply transaction with no transaction stack\n", + proc->pid, thread->pid); + return_error = BR_FAILED_REPLY; + goto err_empty_call_stack; + } + binder_set_nice(in_reply_to->saved_priority); + if (in_reply_to->to_thread != thread) { + binder_user_error("%d:%d got reply transaction with bad transaction stack, transaction %d has target %d:%d\n", + proc->pid, thread->pid, in_reply_to->debug_id, + in_reply_to->to_proc ? + in_reply_to->to_proc->pid : 0, + in_reply_to->to_thread ? + in_reply_to->to_thread->pid : 0); + return_error = BR_FAILED_REPLY; + in_reply_to = NULL; + goto err_bad_call_stack; + } + thread->transaction_stack = in_reply_to->to_parent; + target_thread = in_reply_to->from; + if (target_thread == NULL) { + return_error = BR_DEAD_REPLY; + goto err_dead_binder; + } + if (target_thread->transaction_stack != in_reply_to) { + binder_user_error("%d:%d got reply transaction with bad target transaction stack %d, expected %d\n", + proc->pid, thread->pid, + target_thread->transaction_stack ? + target_thread->transaction_stack->debug_id : 0, + in_reply_to->debug_id); + return_error = BR_FAILED_REPLY; + in_reply_to = NULL; + target_thread = NULL; + goto err_dead_binder; + } + target_proc = target_thread->proc; + } else { + if (tr->target.handle) { + struct binder_ref *ref; + + ref = binder_get_ref(proc, tr->target.handle); + if (ref == NULL) { + binder_user_error("%d:%d got transaction to invalid handle\n", + proc->pid, thread->pid); + return_error = BR_FAILED_REPLY; + goto err_invalid_target_handle; + } + target_node = ref->node; + } else { + target_node = binder_context_mgr_node; + if (target_node == NULL) { + return_error = BR_DEAD_REPLY; + goto err_no_context_mgr_node; + } + } + e->to_node = target_node->debug_id; + target_proc = target_node->proc; + if (target_proc == NULL) { + return_error = BR_DEAD_REPLY; + goto err_dead_binder; + } + if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { + struct binder_transaction *tmp; + + tmp = thread->transaction_stack; + if (tmp->to_thread != thread) { + binder_user_error("%d:%d got new transaction with bad transaction stack, transaction %d has target %d:%d\n", + proc->pid, thread->pid, tmp->debug_id, + tmp->to_proc ? tmp->to_proc->pid : 0, + tmp->to_thread ? + tmp->to_thread->pid : 0); + return_error = BR_FAILED_REPLY; + goto err_bad_call_stack; + } + while (tmp) { + if (tmp->from && tmp->from->proc == target_proc) + target_thread = tmp->from; + tmp = tmp->from_parent; + } + } + } + if (target_thread) { + e->to_thread = target_thread->pid; + target_list = &target_thread->todo; + target_wait = &target_thread->wait; + } else { + target_list = &target_proc->todo; + target_wait = &target_proc->wait; + } + e->to_proc = target_proc->pid; + + /* TODO: reuse incoming transaction for reply */ + t = kzalloc(sizeof(*t), GFP_KERNEL); + if (t == NULL) { + return_error = BR_FAILED_REPLY; + goto err_alloc_t_failed; + } + binder_stats_created(BINDER_STAT_TRANSACTION); + + tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL); + if (tcomplete == NULL) { + return_error = BR_FAILED_REPLY; + goto err_alloc_tcomplete_failed; + } + binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE); + + t->debug_id = ++binder_last_id; + e->debug_id = t->debug_id; + + if (reply) + binder_debug(BINDER_DEBUG_TRANSACTION, + "%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, + (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 %016llx-%016llx size %lld-%lld\n", + proc->pid, thread->pid, t->debug_id, + target_proc->pid, target_node->debug_id, + (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; + else + t->from = NULL; + t->sender_euid = task_euid(proc->tsk); + t->to_proc = target_proc; + t->to_thread = target_thread; + t->code = tr->code; + t->flags = tr->flags; + t->priority = task_nice(current); + + trace_binder_transaction(reply, t, target_node); + + t->buffer = binder_alloc_buf(target_proc, tr->data_size, + tr->offsets_size, !reply && (t->flags & TF_ONE_WAY)); + if (t->buffer == NULL) { + return_error = BR_FAILED_REPLY; + goto err_binder_alloc_buf_failed; + } + t->buffer->allow_user_free = 0; + t->buffer->debug_id = t->debug_id; + t->buffer->transaction = t; + t->buffer->target_node = target_node; + trace_binder_transaction_alloc_buf(t->buffer); + if (target_node) + binder_inc_node(target_node, 1, 0, NULL); + + offp = (binder_size_t *)(t->buffer->data + + ALIGN(tr->data_size, sizeof(void *))); + + 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, (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(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; + } + off_end = (void *)offp + tr->offsets_size; + for (; offp < off_end; offp++) { + struct flat_binder_object *fp; + + if (*offp > t->buffer->data_size - sizeof(*fp) || + t->buffer->data_size < sizeof(*fp) || + !IS_ALIGNED(*offp, sizeof(u32))) { + 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; + } + fp = (struct flat_binder_object *)(t->buffer->data + *offp); + switch (fp->type) { + case BINDER_TYPE_BINDER: + case BINDER_TYPE_WEAK_BINDER: { + struct binder_ref *ref; + struct binder_node *node = binder_get_node(proc, fp->binder); + + if (node == NULL) { + node = binder_new_node(proc, fp->binder, fp->cookie); + if (node == NULL) { + return_error = BR_FAILED_REPLY; + goto err_binder_new_node_failed; + } + node->min_priority = fp->flags & FLAT_BINDER_FLAG_PRIORITY_MASK; + node->accept_fds = !!(fp->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS); + } + if (fp->cookie != node->cookie) { + binder_user_error("%d:%d sending u%016llx node %d, cookie mismatch %016llx != %016llx\n", + proc->pid, thread->pid, + (u64)fp->binder, node->debug_id, + (u64)fp->cookie, (u64)node->cookie); + return_error = BR_FAILED_REPLY; + goto err_binder_get_ref_for_node_failed; + } + ref = binder_get_ref_for_node(target_proc, node); + if (ref == NULL) { + return_error = BR_FAILED_REPLY; + goto err_binder_get_ref_for_node_failed; + } + if (fp->type == BINDER_TYPE_BINDER) + fp->type = BINDER_TYPE_HANDLE; + else + fp->type = BINDER_TYPE_WEAK_HANDLE; + fp->handle = ref->desc; + binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, + &thread->todo); + + trace_binder_transaction_node_to_ref(t, node, ref); + binder_debug(BINDER_DEBUG_TRANSACTION, + " 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: { + struct binder_ref *ref = binder_get_ref(proc, fp->handle); + + if (ref == NULL) { + binder_user_error("%d:%d got transaction with invalid handle, %d\n", + proc->pid, + thread->pid, fp->handle); + return_error = BR_FAILED_REPLY; + goto err_binder_get_ref_failed; + } + if (ref->node->proc == target_proc) { + if (fp->type == BINDER_TYPE_HANDLE) + fp->type = BINDER_TYPE_BINDER; + else + fp->type = BINDER_TYPE_WEAK_BINDER; + fp->binder = ref->node->ptr; + fp->cookie = ref->node->cookie; + 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%016llx\n", + ref->debug_id, ref->desc, ref->node->debug_id, + (u64)ref->node->ptr); + } else { + struct binder_ref *new_ref; + + new_ref = binder_get_ref_for_node(target_proc, ref->node); + if (new_ref == NULL) { + return_error = BR_FAILED_REPLY; + goto err_binder_get_ref_for_node_failed; + } + fp->handle = new_ref->desc; + binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL); + trace_binder_transaction_ref_to_ref(t, ref, + new_ref); + binder_debug(BINDER_DEBUG_TRANSACTION, + " ref %d desc %d -> ref %d desc %d (node %d)\n", + ref->debug_id, ref->desc, new_ref->debug_id, + new_ref->desc, ref->node->debug_id); + } + } break; + + case BINDER_TYPE_FD: { + int target_fd; + struct file *file; + + if (reply) { + if (!(in_reply_to->flags & TF_ACCEPT_FDS)) { + binder_user_error("%d:%d got reply with fd, %d, but target does not allow fds\n", + proc->pid, thread->pid, fp->handle); + return_error = BR_FAILED_REPLY; + goto err_fd_not_allowed; + } + } else if (!target_node->accept_fds) { + binder_user_error("%d:%d got transaction with fd, %d, but target does not allow fds\n", + proc->pid, thread->pid, fp->handle); + return_error = BR_FAILED_REPLY; + goto err_fd_not_allowed; + } + + file = fget(fp->handle); + if (file == NULL) { + binder_user_error("%d:%d got transaction with invalid fd, %d\n", + proc->pid, thread->pid, fp->handle); + return_error = BR_FAILED_REPLY; + goto err_fget_failed; + } + target_fd = task_get_unused_fd_flags(target_proc, O_CLOEXEC); + if (target_fd < 0) { + fput(file); + return_error = BR_FAILED_REPLY; + goto err_get_unused_fd_failed; + } + task_fd_install(target_proc, target_fd, file); + trace_binder_transaction_fd(t, fp->handle, target_fd); + binder_debug(BINDER_DEBUG_TRANSACTION, + " fd %d -> %d\n", fp->handle, target_fd); + /* TODO: fput? */ + fp->handle = target_fd; + } break; + + default: + binder_user_error("%d:%d got transaction with invalid object type, %x\n", + proc->pid, thread->pid, fp->type); + return_error = BR_FAILED_REPLY; + goto err_bad_object_type; + } + } + if (reply) { + BUG_ON(t->buffer->async_transaction != 0); + binder_pop_transaction(target_thread, in_reply_to); + } else if (!(t->flags & TF_ONE_WAY)) { + BUG_ON(t->buffer->async_transaction != 0); + t->need_reply = 1; + t->from_parent = thread->transaction_stack; + thread->transaction_stack = t; + } else { + BUG_ON(target_node == NULL); + BUG_ON(t->buffer->async_transaction != 1); + if (target_node->has_async_transaction) { + target_list = &target_node->async_todo; + target_wait = NULL; + } else + target_node->has_async_transaction = 1; + } + t->work.type = BINDER_WORK_TRANSACTION; + list_add_tail(&t->work.entry, target_list); + tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE; + list_add_tail(&tcomplete->entry, &thread->todo); + if (target_wait) + wake_up_interruptible(target_wait); + return; + +err_get_unused_fd_failed: +err_fget_failed: +err_fd_not_allowed: +err_binder_get_ref_for_node_failed: +err_binder_get_ref_failed: +err_binder_new_node_failed: +err_bad_object_type: +err_bad_offset: +err_copy_data_failed: + trace_binder_transaction_failed_buffer_release(t->buffer); + binder_transaction_buffer_release(target_proc, t->buffer, offp); + t->buffer->transaction = NULL; + binder_free_buf(target_proc, t->buffer); +err_binder_alloc_buf_failed: + kfree(tcomplete); + binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); +err_alloc_tcomplete_failed: + kfree(t); + binder_stats_deleted(BINDER_STAT_TRANSACTION); +err_alloc_t_failed: +err_bad_call_stack: +err_empty_call_stack: +err_dead_binder: +err_invalid_target_handle: +err_no_context_mgr_node: + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "%d:%d transaction failed %d, size %lld-%lld\n", + proc->pid, thread->pid, return_error, + (u64)tr->data_size, (u64)tr->offsets_size); + + { + struct binder_transaction_log_entry *fe; + + fe = binder_transaction_log_add(&binder_transaction_log_failed); + *fe = *e; + } + + BUG_ON(thread->return_error != BR_OK); + if (in_reply_to) { + thread->return_error = BR_TRANSACTION_COMPLETE; + binder_send_failed_reply(in_reply_to, return_error); + } else + thread->return_error = return_error; +} + +static int binder_thread_write(struct binder_proc *proc, + struct binder_thread *thread, + 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; + + while (ptr < end && thread->return_error == BR_OK) { + if (get_user(cmd, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + trace_binder_command(cmd); + if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) { + binder_stats.bc[_IOC_NR(cmd)]++; + proc->stats.bc[_IOC_NR(cmd)]++; + thread->stats.bc[_IOC_NR(cmd)]++; + } + switch (cmd) { + case BC_INCREFS: + case BC_ACQUIRE: + case BC_RELEASE: + case BC_DECREFS: { + uint32_t target; + struct binder_ref *ref; + const char *debug_string; + + if (get_user(target, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + if (target == 0 && binder_context_mgr_node && + (cmd == BC_INCREFS || cmd == BC_ACQUIRE)) { + ref = binder_get_ref_for_node(proc, + binder_context_mgr_node); + if (ref->desc != target) { + binder_user_error("%d:%d tried to acquire reference to desc 0, got %d instead\n", + proc->pid, thread->pid, + ref->desc); + } + } else + ref = binder_get_ref(proc, target); + if (ref == NULL) { + binder_user_error("%d:%d refcount change on invalid ref %d\n", + proc->pid, thread->pid, target); + break; + } + switch (cmd) { + case BC_INCREFS: + debug_string = "IncRefs"; + binder_inc_ref(ref, 0, NULL); + break; + case BC_ACQUIRE: + debug_string = "Acquire"; + binder_inc_ref(ref, 1, NULL); + break; + case BC_RELEASE: + debug_string = "Release"; + binder_dec_ref(ref, 1); + break; + case BC_DECREFS: + default: + debug_string = "DecRefs"; + binder_dec_ref(ref, 0); + break; + } + binder_debug(BINDER_DEBUG_USER_REFS, + "%d:%d %s ref %d desc %d s %d w %d for node %d\n", + proc->pid, thread->pid, debug_string, ref->debug_id, + ref->desc, ref->strong, ref->weak, ref->node->debug_id); + break; + } + case BC_INCREFS_DONE: + case BC_ACQUIRE_DONE: { + binder_uintptr_t node_ptr; + binder_uintptr_t cookie; + struct binder_node *node; + + if (get_user(node_ptr, (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + if (get_user(cookie, (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + node = binder_get_node(proc, node_ptr); + if (node == NULL) { + 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", + (u64)node_ptr); + break; + } + if (cookie != node->cookie) { + 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", + (u64)node_ptr, node->debug_id, + (u64)cookie, (u64)node->cookie); + break; + } + if (cmd == BC_ACQUIRE_DONE) { + if (node->pending_strong_ref == 0) { + binder_user_error("%d:%d BC_ACQUIRE_DONE node %d has no pending acquire request\n", + proc->pid, thread->pid, + node->debug_id); + break; + } + node->pending_strong_ref = 0; + } else { + if (node->pending_weak_ref == 0) { + binder_user_error("%d:%d BC_INCREFS_DONE node %d has no pending increfs request\n", + proc->pid, thread->pid, + node->debug_id); + break; + } + node->pending_weak_ref = 0; + } + binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0); + binder_debug(BINDER_DEBUG_USER_REFS, + "%d:%d %s node %d ls %d lw %d\n", + proc->pid, thread->pid, + cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", + node->debug_id, node->local_strong_refs, node->local_weak_refs); + break; + } + case BC_ATTEMPT_ACQUIRE: + pr_err("BC_ATTEMPT_ACQUIRE not supported\n"); + return -EINVAL; + case BC_ACQUIRE_RESULT: + pr_err("BC_ACQUIRE_RESULT not supported\n"); + return -EINVAL; + + case BC_FREE_BUFFER: { + binder_uintptr_t data_ptr; + struct binder_buffer *buffer; + + if (get_user(data_ptr, (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + + buffer = binder_buffer_lookup(proc, data_ptr); + if (buffer == NULL) { + 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%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%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) { + buffer->transaction->buffer = NULL; + buffer->transaction = NULL; + } + if (buffer->async_transaction && buffer->target_node) { + BUG_ON(!buffer->target_node->has_async_transaction); + if (list_empty(&buffer->target_node->async_todo)) + buffer->target_node->has_async_transaction = 0; + else + list_move_tail(buffer->target_node->async_todo.next, &thread->todo); + } + trace_binder_transaction_buffer_release(buffer); + binder_transaction_buffer_release(proc, buffer, NULL); + binder_free_buf(proc, buffer); + break; + } + + case BC_TRANSACTION: + case BC_REPLY: { + struct binder_transaction_data tr; + + if (copy_from_user(&tr, ptr, sizeof(tr))) + return -EFAULT; + ptr += sizeof(tr); + binder_transaction(proc, thread, &tr, cmd == BC_REPLY); + break; + } + + case BC_REGISTER_LOOPER: + binder_debug(BINDER_DEBUG_THREADS, + "%d:%d BC_REGISTER_LOOPER\n", + proc->pid, thread->pid); + if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { + thread->looper |= BINDER_LOOPER_STATE_INVALID; + binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called after BC_ENTER_LOOPER\n", + proc->pid, thread->pid); + } else if (proc->requested_threads == 0) { + thread->looper |= BINDER_LOOPER_STATE_INVALID; + binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called without request\n", + proc->pid, thread->pid); + } else { + proc->requested_threads--; + proc->requested_threads_started++; + } + thread->looper |= BINDER_LOOPER_STATE_REGISTERED; + break; + case BC_ENTER_LOOPER: + binder_debug(BINDER_DEBUG_THREADS, + "%d:%d BC_ENTER_LOOPER\n", + proc->pid, thread->pid); + if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { + thread->looper |= BINDER_LOOPER_STATE_INVALID; + binder_user_error("%d:%d ERROR: BC_ENTER_LOOPER called after BC_REGISTER_LOOPER\n", + proc->pid, thread->pid); + } + thread->looper |= BINDER_LOOPER_STATE_ENTERED; + break; + case BC_EXIT_LOOPER: + binder_debug(BINDER_DEBUG_THREADS, + "%d:%d BC_EXIT_LOOPER\n", + proc->pid, thread->pid); + thread->looper |= BINDER_LOOPER_STATE_EXITED; + break; + + case BC_REQUEST_DEATH_NOTIFICATION: + case BC_CLEAR_DEATH_NOTIFICATION: { + uint32_t target; + 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, (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + ref = binder_get_ref(proc, target); + if (ref == NULL) { + binder_user_error("%d:%d %s invalid ref %d\n", + proc->pid, thread->pid, + cmd == BC_REQUEST_DEATH_NOTIFICATION ? + "BC_REQUEST_DEATH_NOTIFICATION" : + "BC_CLEAR_DEATH_NOTIFICATION", + target); + break; + } + + binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, + "%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", + (u64)cookie, ref->debug_id, ref->desc, + ref->strong, ref->weak, ref->node->debug_id); + + if (cmd == BC_REQUEST_DEATH_NOTIFICATION) { + if (ref->death) { + binder_user_error("%d:%d BC_REQUEST_DEATH_NOTIFICATION death notification already set\n", + proc->pid, thread->pid); + break; + } + death = kzalloc(sizeof(*death), GFP_KERNEL); + if (death == NULL) { + thread->return_error = BR_ERROR; + binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, + "%d:%d BC_REQUEST_DEATH_NOTIFICATION failed\n", + proc->pid, thread->pid); + break; + } + binder_stats_created(BINDER_STAT_DEATH); + INIT_LIST_HEAD(&death->work.entry); + death->cookie = cookie; + ref->death = death; + if (ref->node->proc == NULL) { + ref->death->work.type = BINDER_WORK_DEAD_BINDER; + if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { + list_add_tail(&ref->death->work.entry, &thread->todo); + } else { + list_add_tail(&ref->death->work.entry, &proc->todo); + wake_up_interruptible(&proc->wait); + } + } + } else { + if (ref->death == NULL) { + binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification not active\n", + proc->pid, thread->pid); + break; + } + death = ref->death; + if (death->cookie != cookie) { + binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification cookie mismatch %016llx != %016llx\n", + proc->pid, thread->pid, + (u64)death->cookie, + (u64)cookie); + break; + } + ref->death = NULL; + if (list_empty(&death->work.entry)) { + death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION; + if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { + list_add_tail(&death->work.entry, &thread->todo); + } else { + list_add_tail(&death->work.entry, &proc->todo); + wake_up_interruptible(&proc->wait); + } + } else { + BUG_ON(death->work.type != BINDER_WORK_DEAD_BINDER); + death->work.type = BINDER_WORK_DEAD_BINDER_AND_CLEAR; + } + } + } break; + case BC_DEAD_BINDER_DONE: { + struct binder_work *w; + binder_uintptr_t cookie; + struct binder_ref_death *death = NULL; + + if (get_user(cookie, (binder_uintptr_t __user *)ptr)) + return -EFAULT; + + ptr += sizeof(void *); + list_for_each_entry(w, &proc->delivered_death, entry) { + struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work); + + if (tmp_death->cookie == cookie) { + death = tmp_death; + break; + } + } + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "%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 %016llx not found\n", + proc->pid, thread->pid, (u64)cookie); + break; + } + + list_del_init(&death->work.entry); + if (death->work.type == BINDER_WORK_DEAD_BINDER_AND_CLEAR) { + death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION; + if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { + list_add_tail(&death->work.entry, &thread->todo); + } else { + list_add_tail(&death->work.entry, &proc->todo); + wake_up_interruptible(&proc->wait); + } + } + } break; + + default: + pr_err("%d:%d unknown command %d\n", + proc->pid, thread->pid, cmd); + return -EINVAL; + } + *consumed = ptr - buffer; + } + return 0; +} + +static void binder_stat_br(struct binder_proc *proc, + struct binder_thread *thread, uint32_t cmd) +{ + trace_binder_return(cmd); + if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) { + binder_stats.br[_IOC_NR(cmd)]++; + proc->stats.br[_IOC_NR(cmd)]++; + thread->stats.br[_IOC_NR(cmd)]++; + } +} + +static int binder_has_proc_work(struct binder_proc *proc, + struct binder_thread *thread) +{ + return !list_empty(&proc->todo) || + (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); +} + +static int binder_has_thread_work(struct binder_thread *thread) +{ + return !list_empty(&thread->todo) || thread->return_error != BR_OK || + (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); +} + +static int binder_thread_read(struct binder_proc *proc, + struct binder_thread *thread, + 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; + + int ret = 0; + int wait_for_proc_work; + + if (*consumed == 0) { + if (put_user(BR_NOOP, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + } + +retry: + wait_for_proc_work = thread->transaction_stack == NULL && + list_empty(&thread->todo); + + if (thread->return_error != BR_OK && ptr < end) { + if (thread->return_error2 != BR_OK) { + if (put_user(thread->return_error2, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + binder_stat_br(proc, thread, thread->return_error2); + if (ptr == end) + goto done; + thread->return_error2 = BR_OK; + } + if (put_user(thread->return_error, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + binder_stat_br(proc, thread, thread->return_error); + thread->return_error = BR_OK; + goto done; + } + + + thread->looper |= BINDER_LOOPER_STATE_WAITING; + if (wait_for_proc_work) + proc->ready_threads++; + + binder_unlock(__func__); + + trace_binder_wait_for_work(wait_for_proc_work, + !!thread->transaction_stack, + !list_empty(&thread->todo)); + if (wait_for_proc_work) { + if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED | + BINDER_LOOPER_STATE_ENTERED))) { + binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n", + proc->pid, thread->pid, thread->looper); + wait_event_interruptible(binder_user_error_wait, + binder_stop_on_user_error < 2); + } + binder_set_nice(proc->default_priority); + if (non_block) { + if (!binder_has_proc_work(proc, thread)) + ret = -EAGAIN; + } else + ret = wait_event_freezable_exclusive(proc->wait, binder_has_proc_work(proc, thread)); + } else { + if (non_block) { + if (!binder_has_thread_work(thread)) + ret = -EAGAIN; + } else + ret = wait_event_freezable(thread->wait, binder_has_thread_work(thread)); + } + + binder_lock(__func__); + + if (wait_for_proc_work) + proc->ready_threads--; + thread->looper &= ~BINDER_LOOPER_STATE_WAITING; + + if (ret) + return ret; + + while (1) { + uint32_t cmd; + struct binder_transaction_data tr; + struct binder_work *w; + struct binder_transaction *t = NULL; + + if (!list_empty(&thread->todo)) { + w = list_first_entry(&thread->todo, struct binder_work, + entry); + } else if (!list_empty(&proc->todo) && wait_for_proc_work) { + w = list_first_entry(&proc->todo, struct binder_work, + entry); + } else { + /* no data added */ + if (ptr - buffer == 4 && + !(thread->looper & BINDER_LOOPER_STATE_NEED_RETURN)) + goto retry; + break; + } + + if (end - ptr < sizeof(tr) + 4) + break; + + switch (w->type) { + case BINDER_WORK_TRANSACTION: { + t = container_of(w, struct binder_transaction, work); + } break; + case BINDER_WORK_TRANSACTION_COMPLETE: { + cmd = BR_TRANSACTION_COMPLETE; + if (put_user(cmd, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + + binder_stat_br(proc, thread, cmd); + binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE, + "%d:%d BR_TRANSACTION_COMPLETE\n", + proc->pid, thread->pid); + + list_del(&w->entry); + kfree(w); + binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); + } break; + case BINDER_WORK_NODE: { + struct binder_node *node = container_of(w, struct binder_node, work); + uint32_t cmd = BR_NOOP; + const char *cmd_name; + int strong = node->internal_strong_refs || node->local_strong_refs; + int weak = !hlist_empty(&node->refs) || node->local_weak_refs || strong; + + if (weak && !node->has_weak_ref) { + cmd = BR_INCREFS; + cmd_name = "BR_INCREFS"; + node->has_weak_ref = 1; + node->pending_weak_ref = 1; + node->local_weak_refs++; + } else if (strong && !node->has_strong_ref) { + cmd = BR_ACQUIRE; + cmd_name = "BR_ACQUIRE"; + node->has_strong_ref = 1; + node->pending_strong_ref = 1; + node->local_strong_refs++; + } else if (!strong && node->has_strong_ref) { + cmd = BR_RELEASE; + cmd_name = "BR_RELEASE"; + node->has_strong_ref = 0; + } else if (!weak && node->has_weak_ref) { + cmd = BR_DECREFS; + cmd_name = "BR_DECREFS"; + node->has_weak_ref = 0; + } + if (cmd != BR_NOOP) { + if (put_user(cmd, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + if (put_user(node->ptr, + (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + if (put_user(node->cookie, + (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + + binder_stat_br(proc, thread, cmd); + binder_debug(BINDER_DEBUG_USER_REFS, + "%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%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%016llx c%016llx state unchanged\n", + proc->pid, thread->pid, + node->debug_id, + (u64)node->ptr, + (u64)node->cookie); + } + } + } break; + case BINDER_WORK_DEAD_BINDER: + case BINDER_WORK_DEAD_BINDER_AND_CLEAR: + case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: { + struct binder_ref_death *death; + uint32_t cmd; + + death = container_of(w, struct binder_ref_death, work); + if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) + cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE; + else + cmd = BR_DEAD_BINDER; + if (put_user(cmd, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + if (put_user(death->cookie, + (binder_uintptr_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(binder_uintptr_t); + binder_stat_br(proc, thread, cmd); + binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, + "%d:%d %s %016llx\n", + proc->pid, thread->pid, + cmd == BR_DEAD_BINDER ? + "BR_DEAD_BINDER" : + "BR_CLEAR_DEATH_NOTIFICATION_DONE", + (u64)death->cookie); + + if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) { + list_del(&w->entry); + kfree(death); + binder_stats_deleted(BINDER_STAT_DEATH); + } else + list_move(&w->entry, &proc->delivered_death); + if (cmd == BR_DEAD_BINDER) + goto done; /* DEAD_BINDER notifications can cause transactions */ + } break; + } + + if (!t) + continue; + + BUG_ON(t->buffer == NULL); + if (t->buffer->target_node) { + struct binder_node *target_node = t->buffer->target_node; + + tr.target.ptr = target_node->ptr; + tr.cookie = target_node->cookie; + t->saved_priority = task_nice(current); + if (t->priority < target_node->min_priority && + !(t->flags & TF_ONE_WAY)) + binder_set_nice(t->priority); + else if (!(t->flags & TF_ONE_WAY) || + t->saved_priority > target_node->min_priority) + binder_set_nice(target_node->min_priority); + cmd = BR_TRANSACTION; + } else { + tr.target.ptr = 0; + tr.cookie = 0; + cmd = BR_REPLY; + } + tr.code = t->code; + tr.flags = t->flags; + tr.sender_euid = from_kuid(current_user_ns(), t->sender_euid); + + if (t->from) { + struct task_struct *sender = t->from->proc->tsk; + + tr.sender_pid = task_tgid_nr_ns(sender, + task_active_pid_ns(current)); + } else { + tr.sender_pid = 0; + } + + tr.data_size = t->buffer->data_size; + tr.offsets_size = t->buffer->offsets_size; + 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 *)); + + if (put_user(cmd, (uint32_t __user *)ptr)) + return -EFAULT; + ptr += sizeof(uint32_t); + if (copy_to_user(ptr, &tr, sizeof(tr))) + return -EFAULT; + ptr += sizeof(tr); + + 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 %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, + (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets); + + list_del(&t->work.entry); + t->buffer->allow_user_free = 1; + if (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) { + t->to_parent = thread->transaction_stack; + t->to_thread = thread; + thread->transaction_stack = t; + } else { + t->buffer->transaction = NULL; + kfree(t); + binder_stats_deleted(BINDER_STAT_TRANSACTION); + } + break; + } + +done: + + *consumed = ptr - buffer; + if (proc->requested_threads + proc->ready_threads == 0 && + proc->requested_threads_started < proc->max_threads && + (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | + BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */ + /*spawn a new thread if we leave this out */) { + proc->requested_threads++; + binder_debug(BINDER_DEBUG_THREADS, + "%d:%d BR_SPAWN_LOOPER\n", + proc->pid, thread->pid); + if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer)) + return -EFAULT; + binder_stat_br(proc, thread, BR_SPAWN_LOOPER); + } + return 0; +} + +static void binder_release_work(struct list_head *list) +{ + struct binder_work *w; + + while (!list_empty(list)) { + w = list_first_entry(list, struct binder_work, entry); + list_del_init(&w->entry); + switch (w->type) { + case BINDER_WORK_TRANSACTION: { + struct binder_transaction *t; + + t = container_of(w, struct binder_transaction, work); + if (t->buffer->target_node && + !(t->flags & TF_ONE_WAY)) { + binder_send_failed_reply(t, BR_DEAD_REPLY); + } else { + binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, + "undelivered transaction %d\n", + t->debug_id); + t->buffer->transaction = NULL; + kfree(t); + binder_stats_deleted(BINDER_STAT_TRANSACTION); + } + } break; + case BINDER_WORK_TRANSACTION_COMPLETE: { + binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, + "undelivered TRANSACTION_COMPLETE\n"); + kfree(w); + binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); + } break; + case BINDER_WORK_DEAD_BINDER_AND_CLEAR: + case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: { + struct binder_ref_death *death; + + death = container_of(w, struct binder_ref_death, work); + binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, + "undelivered death notification, %016llx\n", + (u64)death->cookie); + kfree(death); + binder_stats_deleted(BINDER_STAT_DEATH); + } break; + default: + pr_err("unexpected work type, %d, not freed\n", + w->type); + break; + } + } + +} + +static struct binder_thread *binder_get_thread(struct binder_proc *proc) +{ + struct binder_thread *thread = NULL; + struct rb_node *parent = NULL; + struct rb_node **p = &proc->threads.rb_node; + + while (*p) { + parent = *p; + thread = rb_entry(parent, struct binder_thread, rb_node); + + if (current->pid < thread->pid) + p = &(*p)->rb_left; + else if (current->pid > thread->pid) + p = &(*p)->rb_right; + else + break; + } + if (*p == NULL) { + thread = kzalloc(sizeof(*thread), GFP_KERNEL); + if (thread == NULL) + return NULL; + binder_stats_created(BINDER_STAT_THREAD); + thread->proc = proc; + thread->pid = current->pid; + init_waitqueue_head(&thread->wait); + INIT_LIST_HEAD(&thread->todo); + rb_link_node(&thread->rb_node, parent, p); + rb_insert_color(&thread->rb_node, &proc->threads); + thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; + thread->return_error = BR_OK; + thread->return_error2 = BR_OK; + } + return thread; +} + +static int binder_free_thread(struct binder_proc *proc, + struct binder_thread *thread) +{ + struct binder_transaction *t; + struct binder_transaction *send_reply = NULL; + int active_transactions = 0; + + rb_erase(&thread->rb_node, &proc->threads); + t = thread->transaction_stack; + if (t && t->to_thread == thread) + send_reply = t; + while (t) { + active_transactions++; + binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, + "release %d:%d transaction %d %s, still active\n", + proc->pid, thread->pid, + t->debug_id, + (t->to_thread == thread) ? "in" : "out"); + + if (t->to_thread == thread) { + t->to_proc = NULL; + t->to_thread = NULL; + if (t->buffer) { + t->buffer->transaction = NULL; + t->buffer = NULL; + } + t = t->to_parent; + } else if (t->from == thread) { + t->from = NULL; + t = t->from_parent; + } else + BUG(); + } + if (send_reply) + binder_send_failed_reply(send_reply, BR_DEAD_REPLY); + binder_release_work(&thread->todo); + kfree(thread); + binder_stats_deleted(BINDER_STAT_THREAD); + return active_transactions; +} + +static unsigned int binder_poll(struct file *filp, + struct poll_table_struct *wait) +{ + struct binder_proc *proc = filp->private_data; + struct binder_thread *thread = NULL; + int wait_for_proc_work; + + binder_lock(__func__); + + thread = binder_get_thread(proc); + + wait_for_proc_work = thread->transaction_stack == NULL && + list_empty(&thread->todo) && thread->return_error == BR_OK; + + binder_unlock(__func__); + + if (wait_for_proc_work) { + if (binder_has_proc_work(proc, thread)) + return POLLIN; + poll_wait(filp, &proc->wait, wait); + if (binder_has_proc_work(proc, thread)) + return POLLIN; + } else { + if (binder_has_thread_work(thread)) + return POLLIN; + poll_wait(filp, &thread->wait, wait); + if (binder_has_thread_work(thread)) + return POLLIN; + } + return 0; +} + +static int binder_ioctl_write_read(struct file *filp, + unsigned int cmd, unsigned long arg, + struct binder_thread *thread) +{ + int ret = 0; + struct binder_proc *proc = filp->private_data; + unsigned int size = _IOC_SIZE(cmd); + void __user *ubuf = (void __user *)arg; + struct binder_write_read bwr; + + if (size != sizeof(struct binder_write_read)) { + ret = -EINVAL; + goto out; + } + if (copy_from_user(&bwr, ubuf, sizeof(bwr))) { + ret = -EFAULT; + goto out; + } + binder_debug(BINDER_DEBUG_READ_WRITE, + "%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, + bwr.write_buffer, + bwr.write_size, + &bwr.write_consumed); + trace_binder_write_done(ret); + if (ret < 0) { + bwr.read_consumed = 0; + if (copy_to_user(ubuf, &bwr, sizeof(bwr))) + ret = -EFAULT; + goto out; + } + } + if (bwr.read_size > 0) { + 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); + if (ret < 0) { + if (copy_to_user(ubuf, &bwr, sizeof(bwr))) + ret = -EFAULT; + goto out; + } + } + binder_debug(BINDER_DEBUG_READ_WRITE, + "%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 out; + } +out: + return ret; +} + +static int binder_ioctl_set_ctx_mgr(struct file *filp) +{ + int ret = 0; + struct binder_proc *proc = filp->private_data; + kuid_t curr_euid = current_euid(); + + if (binder_context_mgr_node != NULL) { + pr_err("BINDER_SET_CONTEXT_MGR already set\n"); + ret = -EBUSY; + goto out; + } + if (uid_valid(binder_context_mgr_uid)) { + if (!uid_eq(binder_context_mgr_uid, curr_euid)) { + pr_err("BINDER_SET_CONTEXT_MGR bad uid %d != %d\n", + from_kuid(&init_user_ns, curr_euid), + from_kuid(&init_user_ns, + binder_context_mgr_uid)); + ret = -EPERM; + goto out; + } + } else { + binder_context_mgr_uid = curr_euid; + } + binder_context_mgr_node = binder_new_node(proc, 0, 0); + if (binder_context_mgr_node == NULL) { + ret = -ENOMEM; + goto out; + } + binder_context_mgr_node->local_weak_refs++; + binder_context_mgr_node->local_strong_refs++; + binder_context_mgr_node->has_strong_ref = 1; + binder_context_mgr_node->has_weak_ref = 1; +out: + return ret; +} + +static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + int ret; + struct binder_proc *proc = filp->private_data; + struct binder_thread *thread; + unsigned int size = _IOC_SIZE(cmd); + void __user *ubuf = (void __user *)arg; + + /*pr_info("binder_ioctl: %d:%d %x %lx\n", + proc->pid, current->pid, cmd, arg);*/ + + trace_binder_ioctl(cmd, arg); + + ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); + if (ret) + goto err_unlocked; + + binder_lock(__func__); + thread = binder_get_thread(proc); + if (thread == NULL) { + ret = -ENOMEM; + goto err; + } + + switch (cmd) { + case BINDER_WRITE_READ: + ret = binder_ioctl_write_read(filp, cmd, arg, thread); + if (ret) + goto err; + break; + case BINDER_SET_MAX_THREADS: + if (copy_from_user(&proc->max_threads, ubuf, sizeof(proc->max_threads))) { + ret = -EINVAL; + goto err; + } + break; + case BINDER_SET_CONTEXT_MGR: + ret = binder_ioctl_set_ctx_mgr(filp); + if (ret) + goto err; + break; + case BINDER_THREAD_EXIT: + binder_debug(BINDER_DEBUG_THREADS, "%d:%d exit\n", + proc->pid, thread->pid); + binder_free_thread(proc, thread); + thread = NULL; + break; + case BINDER_VERSION: { + struct binder_version __user *ver = ubuf; + + if (size != sizeof(struct binder_version)) { + ret = -EINVAL; + goto err; + } + if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, + &ver->protocol_version)) { + ret = -EINVAL; + goto err; + } + break; + } + default: + ret = -EINVAL; + goto err; + } + ret = 0; +err: + if (thread) + thread->looper &= ~BINDER_LOOPER_STATE_NEED_RETURN; + binder_unlock(__func__); + wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); + if (ret && ret != -ERESTARTSYS) + pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); +err_unlocked: + trace_binder_ioctl_done(ret); + return ret; +} + +static void binder_vma_open(struct vm_area_struct *vma) +{ + struct binder_proc *proc = vma->vm_private_data; + + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "%d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", + proc->pid, vma->vm_start, vma->vm_end, + (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, + (unsigned long)pgprot_val(vma->vm_page_prot)); +} + +static void binder_vma_close(struct vm_area_struct *vma) +{ + struct binder_proc *proc = vma->vm_private_data; + + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "%d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", + proc->pid, vma->vm_start, vma->vm_end, + (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, + (unsigned long)pgprot_val(vma->vm_page_prot)); + proc->vma = NULL; + proc->vma_vm_mm = NULL; + binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES); +} + +static int binder_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) +{ + return VM_FAULT_SIGBUS; +} + +static struct vm_operations_struct binder_vm_ops = { + .open = binder_vma_open, + .close = binder_vma_close, + .fault = binder_vm_fault, +}; + +static int binder_mmap(struct file *filp, struct vm_area_struct *vma) +{ + int ret; + struct vm_struct *area; + struct binder_proc *proc = filp->private_data; + const char *failure_string; + struct binder_buffer *buffer; + + if (proc->tsk != current) + return -EINVAL; + + if ((vma->vm_end - vma->vm_start) > SZ_4M) + vma->vm_end = vma->vm_start + SZ_4M; + + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", + proc->pid, vma->vm_start, vma->vm_end, + (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, + (unsigned long)pgprot_val(vma->vm_page_prot)); + + if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) { + ret = -EPERM; + failure_string = "bad vm_flags"; + goto err_bad_arg; + } + vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE; + + mutex_lock(&binder_mmap_lock); + if (proc->buffer) { + ret = -EBUSY; + failure_string = "already mapped"; + goto err_already_mapped; + } + + area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP); + if (area == NULL) { + ret = -ENOMEM; + failure_string = "get_vm_area"; + goto err_get_vm_area_failed; + } + proc->buffer = area->addr; + proc->user_buffer_offset = vma->vm_start - (uintptr_t)proc->buffer; + mutex_unlock(&binder_mmap_lock); + +#ifdef CONFIG_CPU_CACHE_VIPT + if (cache_is_vipt_aliasing()) { + while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) { + pr_info("binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer); + vma->vm_start += PAGE_SIZE; + } + } +#endif + proc->pages = kzalloc(sizeof(proc->pages[0]) * ((vma->vm_end - vma->vm_start) / PAGE_SIZE), GFP_KERNEL); + if (proc->pages == NULL) { + ret = -ENOMEM; + failure_string = "alloc page array"; + goto err_alloc_pages_failed; + } + proc->buffer_size = vma->vm_end - vma->vm_start; + + vma->vm_ops = &binder_vm_ops; + vma->vm_private_data = proc; + + if (binder_update_page_range(proc, 1, proc->buffer, proc->buffer + PAGE_SIZE, vma)) { + ret = -ENOMEM; + failure_string = "alloc small buf"; + goto err_alloc_small_buf_failed; + } + buffer = proc->buffer; + INIT_LIST_HEAD(&proc->buffers); + list_add(&buffer->entry, &proc->buffers); + buffer->free = 1; + binder_insert_free_buffer(proc, buffer); + proc->free_async_space = proc->buffer_size / 2; + barrier(); + proc->files = get_files_struct(current); + proc->vma = vma; + proc->vma_vm_mm = vma->vm_mm; + + /*pr_info("binder_mmap: %d %lx-%lx maps %p\n", + proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/ + return 0; + +err_alloc_small_buf_failed: + kfree(proc->pages); + proc->pages = NULL; +err_alloc_pages_failed: + mutex_lock(&binder_mmap_lock); + vfree(proc->buffer); + proc->buffer = NULL; +err_get_vm_area_failed: +err_already_mapped: + mutex_unlock(&binder_mmap_lock); +err_bad_arg: + pr_err("binder_mmap: %d %lx-%lx %s failed %d\n", + proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); + return ret; +} + +static int binder_open(struct inode *nodp, struct file *filp) +{ + struct binder_proc *proc; + + binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n", + current->group_leader->pid, current->pid); + + proc = kzalloc(sizeof(*proc), GFP_KERNEL); + if (proc == NULL) + return -ENOMEM; + get_task_struct(current); + proc->tsk = current; + INIT_LIST_HEAD(&proc->todo); + init_waitqueue_head(&proc->wait); + proc->default_priority = task_nice(current); + + binder_lock(__func__); + + binder_stats_created(BINDER_STAT_PROC); + hlist_add_head(&proc->proc_node, &binder_procs); + proc->pid = current->group_leader->pid; + INIT_LIST_HEAD(&proc->delivered_death); + filp->private_data = proc; + + binder_unlock(__func__); + + if (binder_debugfs_dir_entry_proc) { + char strbuf[11]; + + snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); + proc->debugfs_entry = debugfs_create_file(strbuf, S_IRUGO, + binder_debugfs_dir_entry_proc, proc, &binder_proc_fops); + } + + return 0; +} + +static int binder_flush(struct file *filp, fl_owner_t id) +{ + struct binder_proc *proc = filp->private_data; + + binder_defer_work(proc, BINDER_DEFERRED_FLUSH); + + return 0; +} + +static void binder_deferred_flush(struct binder_proc *proc) +{ + struct rb_node *n; + int wake_count = 0; + + for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { + struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); + + thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; + if (thread->looper & BINDER_LOOPER_STATE_WAITING) { + wake_up_interruptible(&thread->wait); + wake_count++; + } + } + wake_up_interruptible_all(&proc->wait); + + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "binder_flush: %d woke %d threads\n", proc->pid, + wake_count); +} + +static int binder_release(struct inode *nodp, struct file *filp) +{ + struct binder_proc *proc = filp->private_data; + + debugfs_remove(proc->debugfs_entry); + binder_defer_work(proc, BINDER_DEFERRED_RELEASE); + + return 0; +} + +static int binder_node_release(struct binder_node *node, int refs) +{ + struct binder_ref *ref; + int death = 0; + + list_del_init(&node->work.entry); + binder_release_work(&node->async_todo); + + if (hlist_empty(&node->refs)) { + kfree(node); + binder_stats_deleted(BINDER_STAT_NODE); + + return refs; + } + + node->proc = NULL; + node->local_strong_refs = 0; + node->local_weak_refs = 0; + hlist_add_head(&node->dead_node, &binder_dead_nodes); + + hlist_for_each_entry(ref, &node->refs, node_entry) { + refs++; + + if (!ref->death) + continue; + + death++; + + if (list_empty(&ref->death->work.entry)) { + ref->death->work.type = BINDER_WORK_DEAD_BINDER; + list_add_tail(&ref->death->work.entry, + &ref->proc->todo); + wake_up_interruptible(&ref->proc->wait); + } else + BUG(); + } + + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "node %d now dead, refs %d, death %d\n", + node->debug_id, refs, death); + + return refs; +} + +static void binder_deferred_release(struct binder_proc *proc) +{ + struct binder_transaction *t; + struct rb_node *n; + int threads, nodes, incoming_refs, outgoing_refs, buffers, + active_transactions, page_count; + + BUG_ON(proc->vma); + BUG_ON(proc->files); + + hlist_del(&proc->proc_node); + + if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) { + binder_debug(BINDER_DEBUG_DEAD_BINDER, + "%s: %d context_mgr_node gone\n", + __func__, proc->pid); + binder_context_mgr_node = NULL; + } + + threads = 0; + active_transactions = 0; + while ((n = rb_first(&proc->threads))) { + struct binder_thread *thread; + + thread = rb_entry(n, struct binder_thread, rb_node); + threads++; + active_transactions += binder_free_thread(proc, thread); + } + + nodes = 0; + incoming_refs = 0; + while ((n = rb_first(&proc->nodes))) { + struct binder_node *node; + + node = rb_entry(n, struct binder_node, rb_node); + nodes++; + rb_erase(&node->rb_node, &proc->nodes); + incoming_refs = binder_node_release(node, incoming_refs); + } + + outgoing_refs = 0; + while ((n = rb_first(&proc->refs_by_desc))) { + struct binder_ref *ref; + + ref = rb_entry(n, struct binder_ref, rb_node_desc); + outgoing_refs++; + binder_delete_ref(ref); + } + + binder_release_work(&proc->todo); + binder_release_work(&proc->delivered_death); + + buffers = 0; + while ((n = rb_first(&proc->allocated_buffers))) { + struct binder_buffer *buffer; + + buffer = rb_entry(n, struct binder_buffer, rb_node); + + t = buffer->transaction; + if (t) { + t->buffer = NULL; + buffer->transaction = NULL; + pr_err("release proc %d, transaction %d, not freed\n", + proc->pid, t->debug_id); + /*BUG();*/ + } + + binder_free_buf(proc, buffer); + buffers++; + } + + binder_stats_deleted(BINDER_STAT_PROC); + + page_count = 0; + if (proc->pages) { + int i; + + for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) { + void *page_addr; + + if (!proc->pages[i]) + continue; + + page_addr = proc->buffer + i * PAGE_SIZE; + binder_debug(BINDER_DEBUG_BUFFER_ALLOC, + "%s: %d: page %d at %p not freed\n", + __func__, proc->pid, i, page_addr); + unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE); + __free_page(proc->pages[i]); + page_count++; + } + kfree(proc->pages); + vfree(proc->buffer); + } + + put_task_struct(proc->tsk); + + binder_debug(BINDER_DEBUG_OPEN_CLOSE, + "%s: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n", + __func__, proc->pid, threads, nodes, incoming_refs, + outgoing_refs, active_transactions, buffers, page_count); + + kfree(proc); +} + +static void binder_deferred_func(struct work_struct *work) +{ + struct binder_proc *proc; + struct files_struct *files; + + int defer; + + do { + binder_lock(__func__); + mutex_lock(&binder_deferred_lock); + if (!hlist_empty(&binder_deferred_list)) { + proc = hlist_entry(binder_deferred_list.first, + struct binder_proc, deferred_work_node); + hlist_del_init(&proc->deferred_work_node); + defer = proc->deferred_work; + proc->deferred_work = 0; + } else { + proc = NULL; + defer = 0; + } + mutex_unlock(&binder_deferred_lock); + + files = NULL; + if (defer & BINDER_DEFERRED_PUT_FILES) { + files = proc->files; + if (files) + proc->files = NULL; + } + + if (defer & BINDER_DEFERRED_FLUSH) + binder_deferred_flush(proc); + + if (defer & BINDER_DEFERRED_RELEASE) + binder_deferred_release(proc); /* frees proc */ + + binder_unlock(__func__); + if (files) + put_files_struct(files); + } while (proc); +} +static DECLARE_WORK(binder_deferred_work, binder_deferred_func); + +static void +binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) +{ + mutex_lock(&binder_deferred_lock); + proc->deferred_work |= defer; + if (hlist_unhashed(&proc->deferred_work_node)) { + hlist_add_head(&proc->deferred_work_node, + &binder_deferred_list); + queue_work(binder_deferred_workqueue, &binder_deferred_work); + } + mutex_unlock(&binder_deferred_lock); +} + +static void print_binder_transaction(struct seq_file *m, const char *prefix, + struct binder_transaction *t) +{ + seq_printf(m, + "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d", + prefix, t->debug_id, t, + t->from ? t->from->proc->pid : 0, + t->from ? t->from->pid : 0, + t->to_proc ? t->to_proc->pid : 0, + t->to_thread ? t->to_thread->pid : 0, + t->code, t->flags, t->priority, t->need_reply); + if (t->buffer == NULL) { + seq_puts(m, " buffer free\n"); + return; + } + if (t->buffer->target_node) + seq_printf(m, " node %d", + t->buffer->target_node->debug_id); + seq_printf(m, " size %zd:%zd data %p\n", + t->buffer->data_size, t->buffer->offsets_size, + t->buffer->data); +} + +static void print_binder_buffer(struct seq_file *m, const char *prefix, + struct binder_buffer *buffer) +{ + seq_printf(m, "%s %d: %p size %zd:%zd %s\n", + prefix, buffer->debug_id, buffer->data, + buffer->data_size, buffer->offsets_size, + buffer->transaction ? "active" : "delivered"); +} + +static void print_binder_work(struct seq_file *m, const char *prefix, + const char *transaction_prefix, + struct binder_work *w) +{ + struct binder_node *node; + struct binder_transaction *t; + + switch (w->type) { + case BINDER_WORK_TRANSACTION: + t = container_of(w, struct binder_transaction, work); + print_binder_transaction(m, transaction_prefix, t); + break; + case BINDER_WORK_TRANSACTION_COMPLETE: + seq_printf(m, "%stransaction complete\n", prefix); + break; + case BINDER_WORK_NODE: + node = container_of(w, struct binder_node, work); + 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); + break; + case BINDER_WORK_DEAD_BINDER_AND_CLEAR: + seq_printf(m, "%shas cleared dead binder\n", prefix); + break; + case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: + seq_printf(m, "%shas cleared death notification\n", prefix); + break; + default: + seq_printf(m, "%sunknown work: type %d\n", prefix, w->type); + break; + } +} + +static void print_binder_thread(struct seq_file *m, + struct binder_thread *thread, + int print_always) +{ + struct binder_transaction *t; + struct binder_work *w; + size_t start_pos = m->count; + size_t header_pos; + + seq_printf(m, " thread %d: l %02x\n", thread->pid, thread->looper); + header_pos = m->count; + t = thread->transaction_stack; + while (t) { + if (t->from == thread) { + print_binder_transaction(m, + " outgoing transaction", t); + t = t->from_parent; + } else if (t->to_thread == thread) { + print_binder_transaction(m, + " incoming transaction", t); + t = t->to_parent; + } else { + print_binder_transaction(m, " bad transaction", t); + t = NULL; + } + } + list_for_each_entry(w, &thread->todo, entry) { + print_binder_work(m, " ", " pending transaction", w); + } + if (!print_always && m->count == header_pos) + m->count = start_pos; +} + +static void print_binder_node(struct seq_file *m, struct binder_node *node) +{ + struct binder_ref *ref; + struct binder_work *w; + int count; + + count = 0; + hlist_for_each_entry(ref, &node->refs, node_entry) + count++; + + 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); + if (count) { + seq_puts(m, " proc"); + hlist_for_each_entry(ref, &node->refs, node_entry) + seq_printf(m, " %d", ref->proc->pid); + } + seq_puts(m, "\n"); + list_for_each_entry(w, &node->async_todo, entry) + print_binder_work(m, " ", + " pending async transaction", w); +} + +static void print_binder_ref(struct seq_file *m, struct binder_ref *ref) +{ + seq_printf(m, " ref %d: desc %d %snode %d s %d w %d d %p\n", + ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ", + ref->node->debug_id, ref->strong, ref->weak, ref->death); +} + +static void print_binder_proc(struct seq_file *m, + struct binder_proc *proc, int print_all) +{ + struct binder_work *w; + struct rb_node *n; + size_t start_pos = m->count; + size_t header_pos; + + seq_printf(m, "proc %d\n", proc->pid); + header_pos = m->count; + + for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) + print_binder_thread(m, rb_entry(n, struct binder_thread, + rb_node), print_all); + for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { + struct binder_node *node = rb_entry(n, struct binder_node, + rb_node); + if (print_all || node->has_async_transaction) + print_binder_node(m, node); + } + if (print_all) { + for (n = rb_first(&proc->refs_by_desc); + n != NULL; + n = rb_next(n)) + print_binder_ref(m, rb_entry(n, struct binder_ref, + rb_node_desc)); + } + for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n)) + print_binder_buffer(m, " buffer", + rb_entry(n, struct binder_buffer, rb_node)); + list_for_each_entry(w, &proc->todo, entry) + print_binder_work(m, " ", " pending transaction", w); + list_for_each_entry(w, &proc->delivered_death, entry) { + seq_puts(m, " has delivered dead binder\n"); + break; + } + if (!print_all && m->count == header_pos) + m->count = start_pos; +} + +static const char * const binder_return_strings[] = { + "BR_ERROR", + "BR_OK", + "BR_TRANSACTION", + "BR_REPLY", + "BR_ACQUIRE_RESULT", + "BR_DEAD_REPLY", + "BR_TRANSACTION_COMPLETE", + "BR_INCREFS", + "BR_ACQUIRE", + "BR_RELEASE", + "BR_DECREFS", + "BR_ATTEMPT_ACQUIRE", + "BR_NOOP", + "BR_SPAWN_LOOPER", + "BR_FINISHED", + "BR_DEAD_BINDER", + "BR_CLEAR_DEATH_NOTIFICATION_DONE", + "BR_FAILED_REPLY" +}; + +static const char * const binder_command_strings[] = { + "BC_TRANSACTION", + "BC_REPLY", + "BC_ACQUIRE_RESULT", + "BC_FREE_BUFFER", + "BC_INCREFS", + "BC_ACQUIRE", + "BC_RELEASE", + "BC_DECREFS", + "BC_INCREFS_DONE", + "BC_ACQUIRE_DONE", + "BC_ATTEMPT_ACQUIRE", + "BC_REGISTER_LOOPER", + "BC_ENTER_LOOPER", + "BC_EXIT_LOOPER", + "BC_REQUEST_DEATH_NOTIFICATION", + "BC_CLEAR_DEATH_NOTIFICATION", + "BC_DEAD_BINDER_DONE" +}; + +static const char * const binder_objstat_strings[] = { + "proc", + "thread", + "node", + "ref", + "death", + "transaction", + "transaction_complete" +}; + +static void print_binder_stats(struct seq_file *m, const char *prefix, + struct binder_stats *stats) +{ + int i; + + BUILD_BUG_ON(ARRAY_SIZE(stats->bc) != + ARRAY_SIZE(binder_command_strings)); + for (i = 0; i < ARRAY_SIZE(stats->bc); i++) { + if (stats->bc[i]) + seq_printf(m, "%s%s: %d\n", prefix, + binder_command_strings[i], stats->bc[i]); + } + + BUILD_BUG_ON(ARRAY_SIZE(stats->br) != + ARRAY_SIZE(binder_return_strings)); + for (i = 0; i < ARRAY_SIZE(stats->br); i++) { + if (stats->br[i]) + seq_printf(m, "%s%s: %d\n", prefix, + binder_return_strings[i], stats->br[i]); + } + + BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != + ARRAY_SIZE(binder_objstat_strings)); + BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != + ARRAY_SIZE(stats->obj_deleted)); + for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) { + if (stats->obj_created[i] || stats->obj_deleted[i]) + seq_printf(m, "%s%s: active %d total %d\n", prefix, + binder_objstat_strings[i], + stats->obj_created[i] - stats->obj_deleted[i], + stats->obj_created[i]); + } +} + +static void print_binder_proc_stats(struct seq_file *m, + struct binder_proc *proc) +{ + struct binder_work *w; + struct rb_node *n; + int count, strong, weak; + + seq_printf(m, "proc %d\n", proc->pid); + count = 0; + for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) + count++; + seq_printf(m, " threads: %d\n", count); + seq_printf(m, " requested threads: %d+%d/%d\n" + " ready threads %d\n" + " free async space %zd\n", proc->requested_threads, + proc->requested_threads_started, proc->max_threads, + proc->ready_threads, proc->free_async_space); + count = 0; + for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) + count++; + seq_printf(m, " nodes: %d\n", count); + count = 0; + strong = 0; + weak = 0; + for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { + struct binder_ref *ref = rb_entry(n, struct binder_ref, + rb_node_desc); + count++; + strong += ref->strong; + weak += ref->weak; + } + seq_printf(m, " refs: %d s %d w %d\n", count, strong, weak); + + count = 0; + for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n)) + count++; + seq_printf(m, " buffers: %d\n", count); + + count = 0; + list_for_each_entry(w, &proc->todo, entry) { + switch (w->type) { + case BINDER_WORK_TRANSACTION: + count++; + break; + default: + break; + } + } + seq_printf(m, " pending transactions: %d\n", count); + + print_binder_stats(m, " ", &proc->stats); +} + + +static int binder_state_show(struct seq_file *m, void *unused) +{ + struct binder_proc *proc; + struct binder_node *node; + int do_lock = !binder_debug_no_lock; + + if (do_lock) + binder_lock(__func__); + + seq_puts(m, "binder state:\n"); + + if (!hlist_empty(&binder_dead_nodes)) + seq_puts(m, "dead nodes:\n"); + hlist_for_each_entry(node, &binder_dead_nodes, dead_node) + print_binder_node(m, node); + + hlist_for_each_entry(proc, &binder_procs, proc_node) + print_binder_proc(m, proc, 1); + if (do_lock) + binder_unlock(__func__); + return 0; +} + +static int binder_stats_show(struct seq_file *m, void *unused) +{ + struct binder_proc *proc; + int do_lock = !binder_debug_no_lock; + + if (do_lock) + binder_lock(__func__); + + seq_puts(m, "binder stats:\n"); + + print_binder_stats(m, "", &binder_stats); + + hlist_for_each_entry(proc, &binder_procs, proc_node) + print_binder_proc_stats(m, proc); + if (do_lock) + binder_unlock(__func__); + return 0; +} + +static int binder_transactions_show(struct seq_file *m, void *unused) +{ + struct binder_proc *proc; + int do_lock = !binder_debug_no_lock; + + if (do_lock) + binder_lock(__func__); + + seq_puts(m, "binder transactions:\n"); + hlist_for_each_entry(proc, &binder_procs, proc_node) + print_binder_proc(m, proc, 0); + if (do_lock) + binder_unlock(__func__); + return 0; +} + +static int binder_proc_show(struct seq_file *m, void *unused) +{ + struct binder_proc *proc = m->private; + int do_lock = !binder_debug_no_lock; + + if (do_lock) + binder_lock(__func__); + seq_puts(m, "binder proc state:\n"); + print_binder_proc(m, proc, 1); + if (do_lock) + binder_unlock(__func__); + return 0; +} + +static void print_binder_transaction_log_entry(struct seq_file *m, + struct binder_transaction_log_entry *e) +{ + seq_printf(m, + "%d: %s from %d:%d to %d:%d node %d handle %d size %d:%d\n", + e->debug_id, (e->call_type == 2) ? "reply" : + ((e->call_type == 1) ? "async" : "call "), e->from_proc, + e->from_thread, e->to_proc, e->to_thread, e->to_node, + e->target_handle, e->data_size, e->offsets_size); +} + +static int binder_transaction_log_show(struct seq_file *m, void *unused) +{ + struct binder_transaction_log *log = m->private; + int i; + + if (log->full) { + for (i = log->next; i < ARRAY_SIZE(log->entry); i++) + print_binder_transaction_log_entry(m, &log->entry[i]); + } + for (i = 0; i < log->next; i++) + print_binder_transaction_log_entry(m, &log->entry[i]); + return 0; +} + +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, + .release = binder_release, +}; + +static struct miscdevice binder_miscdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = "binder", + .fops = &binder_fops +}; + +BINDER_DEBUG_ENTRY(state); +BINDER_DEBUG_ENTRY(stats); +BINDER_DEBUG_ENTRY(transactions); +BINDER_DEBUG_ENTRY(transaction_log); + +static int __init binder_init(void) +{ + int ret; + + binder_deferred_workqueue = create_singlethread_workqueue("binder"); + if (!binder_deferred_workqueue) + return -ENOMEM; + + binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL); + if (binder_debugfs_dir_entry_root) + binder_debugfs_dir_entry_proc = debugfs_create_dir("proc", + binder_debugfs_dir_entry_root); + ret = misc_register(&binder_miscdev); + if (binder_debugfs_dir_entry_root) { + debugfs_create_file("state", + S_IRUGO, + binder_debugfs_dir_entry_root, + NULL, + &binder_state_fops); + debugfs_create_file("stats", + S_IRUGO, + binder_debugfs_dir_entry_root, + NULL, + &binder_stats_fops); + debugfs_create_file("transactions", + S_IRUGO, + binder_debugfs_dir_entry_root, + NULL, + &binder_transactions_fops); + debugfs_create_file("transaction_log", + S_IRUGO, + binder_debugfs_dir_entry_root, + &binder_transaction_log, + &binder_transaction_log_fops); + debugfs_create_file("failed_transaction_log", + S_IRUGO, + binder_debugfs_dir_entry_root, + &binder_transaction_log_failed, + &binder_transaction_log_fops); + } + return ret; +} + +device_initcall(binder_init); + +#define CREATE_TRACE_POINTS +#include "binder_trace.h" + +MODULE_LICENSE("GPL v2"); diff --git a/drivers/android/binder.h b/drivers/android/binder.h new file mode 100644 index 000000000000..5dc6a66b0665 --- /dev/null +++ b/drivers/android/binder.h @@ -0,0 +1,30 @@ +/* + * 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 _LINUX_BINDER_H +#define _LINUX_BINDER_H + +#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT +#define BINDER_IPC_32BIT 1 +#endif + +#include + +#endif /* _LINUX_BINDER_H */ + diff --git a/drivers/android/binder_trace.h b/drivers/android/binder_trace.h new file mode 100644 index 000000000000..7f20f3dc8369 --- /dev/null +++ b/drivers/android/binder_trace.h @@ -0,0 +1,329 @@ +/* + * 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. + * + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM binder + +#if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _BINDER_TRACE_H + +#include + +struct binder_buffer; +struct binder_node; +struct binder_proc; +struct binder_ref; +struct binder_thread; +struct binder_transaction; + +TRACE_EVENT(binder_ioctl, + TP_PROTO(unsigned int cmd, unsigned long arg), + TP_ARGS(cmd, arg), + + TP_STRUCT__entry( + __field(unsigned int, cmd) + __field(unsigned long, arg) + ), + TP_fast_assign( + __entry->cmd = cmd; + __entry->arg = arg; + ), + TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg) +); + +DECLARE_EVENT_CLASS(binder_lock_class, + TP_PROTO(const char *tag), + TP_ARGS(tag), + TP_STRUCT__entry( + __field(const char *, tag) + ), + TP_fast_assign( + __entry->tag = tag; + ), + TP_printk("tag=%s", __entry->tag) +); + +#define DEFINE_BINDER_LOCK_EVENT(name) \ +DEFINE_EVENT(binder_lock_class, name, \ + TP_PROTO(const char *func), \ + TP_ARGS(func)) + +DEFINE_BINDER_LOCK_EVENT(binder_lock); +DEFINE_BINDER_LOCK_EVENT(binder_locked); +DEFINE_BINDER_LOCK_EVENT(binder_unlock); + +DECLARE_EVENT_CLASS(binder_function_return_class, + TP_PROTO(int ret), + TP_ARGS(ret), + TP_STRUCT__entry( + __field(int, ret) + ), + TP_fast_assign( + __entry->ret = ret; + ), + TP_printk("ret=%d", __entry->ret) +); + +#define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \ +DEFINE_EVENT(binder_function_return_class, name, \ + TP_PROTO(int ret), \ + TP_ARGS(ret)) + +DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done); +DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done); +DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done); + +TRACE_EVENT(binder_wait_for_work, + TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), + TP_ARGS(proc_work, transaction_stack, thread_todo), + + TP_STRUCT__entry( + __field(bool, proc_work) + __field(bool, transaction_stack) + __field(bool, thread_todo) + ), + TP_fast_assign( + __entry->proc_work = proc_work; + __entry->transaction_stack = transaction_stack; + __entry->thread_todo = thread_todo; + ), + TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d", + __entry->proc_work, __entry->transaction_stack, + __entry->thread_todo) +); + +TRACE_EVENT(binder_transaction, + TP_PROTO(bool reply, struct binder_transaction *t, + struct binder_node *target_node), + TP_ARGS(reply, t, target_node), + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, target_node) + __field(int, to_proc) + __field(int, to_thread) + __field(int, reply) + __field(unsigned int, code) + __field(unsigned int, flags) + ), + TP_fast_assign( + __entry->debug_id = t->debug_id; + __entry->target_node = target_node ? target_node->debug_id : 0; + __entry->to_proc = t->to_proc->pid; + __entry->to_thread = t->to_thread ? t->to_thread->pid : 0; + __entry->reply = reply; + __entry->code = t->code; + __entry->flags = t->flags; + ), + TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x", + __entry->debug_id, __entry->target_node, + __entry->to_proc, __entry->to_thread, + __entry->reply, __entry->flags, __entry->code) +); + +TRACE_EVENT(binder_transaction_received, + TP_PROTO(struct binder_transaction *t), + TP_ARGS(t), + + TP_STRUCT__entry( + __field(int, debug_id) + ), + TP_fast_assign( + __entry->debug_id = t->debug_id; + ), + TP_printk("transaction=%d", __entry->debug_id) +); + +TRACE_EVENT(binder_transaction_node_to_ref, + TP_PROTO(struct binder_transaction *t, struct binder_node *node, + struct binder_ref *ref), + TP_ARGS(t, node, ref), + + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, node_debug_id) + __field(binder_uintptr_t, node_ptr) + __field(int, ref_debug_id) + __field(uint32_t, ref_desc) + ), + TP_fast_assign( + __entry->debug_id = t->debug_id; + __entry->node_debug_id = node->debug_id; + __entry->node_ptr = node->ptr; + __entry->ref_debug_id = ref->debug_id; + __entry->ref_desc = ref->desc; + ), + 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) +); + +TRACE_EVENT(binder_transaction_ref_to_node, + TP_PROTO(struct binder_transaction *t, struct binder_ref *ref), + TP_ARGS(t, ref), + + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, ref_debug_id) + __field(uint32_t, ref_desc) + __field(int, node_debug_id) + __field(binder_uintptr_t, node_ptr) + ), + TP_fast_assign( + __entry->debug_id = t->debug_id; + __entry->ref_debug_id = ref->debug_id; + __entry->ref_desc = ref->desc; + __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%016llx", + __entry->debug_id, __entry->node_debug_id, + __entry->ref_debug_id, __entry->ref_desc, + (u64)__entry->node_ptr) +); + +TRACE_EVENT(binder_transaction_ref_to_ref, + TP_PROTO(struct binder_transaction *t, struct binder_ref *src_ref, + struct binder_ref *dest_ref), + TP_ARGS(t, src_ref, dest_ref), + + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, node_debug_id) + __field(int, src_ref_debug_id) + __field(uint32_t, src_ref_desc) + __field(int, dest_ref_debug_id) + __field(uint32_t, dest_ref_desc) + ), + TP_fast_assign( + __entry->debug_id = t->debug_id; + __entry->node_debug_id = src_ref->node->debug_id; + __entry->src_ref_debug_id = src_ref->debug_id; + __entry->src_ref_desc = src_ref->desc; + __entry->dest_ref_debug_id = dest_ref->debug_id; + __entry->dest_ref_desc = dest_ref->desc; + ), + TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d", + __entry->debug_id, __entry->node_debug_id, + __entry->src_ref_debug_id, __entry->src_ref_desc, + __entry->dest_ref_debug_id, __entry->dest_ref_desc) +); + +TRACE_EVENT(binder_transaction_fd, + TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd), + TP_ARGS(t, src_fd, dest_fd), + + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, src_fd) + __field(int, dest_fd) + ), + TP_fast_assign( + __entry->debug_id = t->debug_id; + __entry->src_fd = src_fd; + __entry->dest_fd = dest_fd; + ), + TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d", + __entry->debug_id, __entry->src_fd, __entry->dest_fd) +); + +DECLARE_EVENT_CLASS(binder_buffer_class, + TP_PROTO(struct binder_buffer *buf), + TP_ARGS(buf), + TP_STRUCT__entry( + __field(int, debug_id) + __field(size_t, data_size) + __field(size_t, offsets_size) + ), + TP_fast_assign( + __entry->debug_id = buf->debug_id; + __entry->data_size = buf->data_size; + __entry->offsets_size = buf->offsets_size; + ), + TP_printk("transaction=%d data_size=%zd offsets_size=%zd", + __entry->debug_id, __entry->data_size, __entry->offsets_size) +); + +DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, + TP_PROTO(struct binder_buffer *buffer), + TP_ARGS(buffer)); + +DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, + TP_PROTO(struct binder_buffer *buffer), + TP_ARGS(buffer)); + +DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, + TP_PROTO(struct binder_buffer *buffer), + TP_ARGS(buffer)); + +TRACE_EVENT(binder_update_page_range, + TP_PROTO(struct binder_proc *proc, bool allocate, + void *start, void *end), + TP_ARGS(proc, allocate, start, end), + TP_STRUCT__entry( + __field(int, proc) + __field(bool, allocate) + __field(size_t, offset) + __field(size_t, size) + ), + TP_fast_assign( + __entry->proc = proc->pid; + __entry->allocate = allocate; + __entry->offset = start - proc->buffer; + __entry->size = end - start; + ), + TP_printk("proc=%d allocate=%d offset=%zu size=%zu", + __entry->proc, __entry->allocate, + __entry->offset, __entry->size) +); + +TRACE_EVENT(binder_command, + TP_PROTO(uint32_t cmd), + TP_ARGS(cmd), + TP_STRUCT__entry( + __field(uint32_t, cmd) + ), + TP_fast_assign( + __entry->cmd = cmd; + ), + TP_printk("cmd=0x%x %s", + __entry->cmd, + _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? + binder_command_strings[_IOC_NR(__entry->cmd)] : + "unknown") +); + +TRACE_EVENT(binder_return, + TP_PROTO(uint32_t cmd), + TP_ARGS(cmd), + TP_STRUCT__entry( + __field(uint32_t, cmd) + ), + TP_fast_assign( + __entry->cmd = cmd; + ), + TP_printk("cmd=0x%x %s", + __entry->cmd, + _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? + binder_return_strings[_IOC_NR(__entry->cmd)] : + "unknown") +); + +#endif /* _BINDER_TRACE_H */ + +#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE binder_trace +#include diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 7a0e28852965..7e012f37792b 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -1,37 +1,7 @@ menu "Android" -config ANDROID - bool "Android Drivers" - ---help--- - Enable support for various drivers needed on the Android platform - if ANDROID -config ANDROID_BINDER_IPC - bool "Android Binder IPC Driver" - depends on MMU - default n - ---help--- - Binder is used in Android for both communication between processes, - and remote method invocation. - - This means one Android process can call a method/routine in another - Android process, using Binder to identify, invoke and pass arguments - between said processes. - -config ANDROID_BINDER_IPC_32BIT - bool - 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. - - 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/Makefile b/drivers/staging/android/Makefile index 517ad5ffa429..479b2b86f8c8 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -2,7 +2,6 @@ ccflags-y += -I$(src) # needed for trace events obj-y += ion/ -obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOGGER) += logger.o obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c deleted file mode 100644 index c69c40d69d5c..000000000000 --- a/drivers/staging/android/binder.c +++ /dev/null @@ -1,3673 +0,0 @@ -/* binder.c - * - * Android IPC Subsystem - * - * Copyright (C) 2007-2008 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. - * - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "binder.h" -#include "binder_trace.h" - -static DEFINE_MUTEX(binder_main_lock); -static DEFINE_MUTEX(binder_deferred_lock); -static DEFINE_MUTEX(binder_mmap_lock); - -static HLIST_HEAD(binder_procs); -static HLIST_HEAD(binder_deferred_list); -static HLIST_HEAD(binder_dead_nodes); - -static struct dentry *binder_debugfs_dir_entry_root; -static struct dentry *binder_debugfs_dir_entry_proc; -static struct binder_node *binder_context_mgr_node; -static kuid_t binder_context_mgr_uid = INVALID_UID; -static int binder_last_id; -static struct workqueue_struct *binder_deferred_workqueue; - -#define BINDER_DEBUG_ENTRY(name) \ -static int binder_##name##_open(struct inode *inode, struct file *file) \ -{ \ - return single_open(file, binder_##name##_show, inode->i_private); \ -} \ -\ -static const struct file_operations binder_##name##_fops = { \ - .owner = THIS_MODULE, \ - .open = binder_##name##_open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ -} - -static int binder_proc_show(struct seq_file *m, void *unused); -BINDER_DEBUG_ENTRY(proc); - -/* This is only defined in include/asm-arm/sizes.h */ -#ifndef SZ_1K -#define SZ_1K 0x400 -#endif - -#ifndef SZ_4M -#define SZ_4M 0x400000 -#endif - -#define FORBIDDEN_MMAP_FLAGS (VM_WRITE) - -#define BINDER_SMALL_BUF_SIZE (PAGE_SIZE * 64) - -enum { - BINDER_DEBUG_USER_ERROR = 1U << 0, - BINDER_DEBUG_FAILED_TRANSACTION = 1U << 1, - BINDER_DEBUG_DEAD_TRANSACTION = 1U << 2, - BINDER_DEBUG_OPEN_CLOSE = 1U << 3, - BINDER_DEBUG_DEAD_BINDER = 1U << 4, - BINDER_DEBUG_DEATH_NOTIFICATION = 1U << 5, - BINDER_DEBUG_READ_WRITE = 1U << 6, - BINDER_DEBUG_USER_REFS = 1U << 7, - BINDER_DEBUG_THREADS = 1U << 8, - BINDER_DEBUG_TRANSACTION = 1U << 9, - BINDER_DEBUG_TRANSACTION_COMPLETE = 1U << 10, - BINDER_DEBUG_FREE_BUFFER = 1U << 11, - BINDER_DEBUG_INTERNAL_REFS = 1U << 12, - BINDER_DEBUG_BUFFER_ALLOC = 1U << 13, - BINDER_DEBUG_PRIORITY_CAP = 1U << 14, - BINDER_DEBUG_BUFFER_ALLOC_ASYNC = 1U << 15, -}; -static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR | - BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION; -module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO); - -static bool binder_debug_no_lock; -module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO); - -static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait); -static int binder_stop_on_user_error; - -static int binder_set_stop_on_user_error(const char *val, - struct kernel_param *kp) -{ - int ret; - - ret = param_set_int(val, kp); - if (binder_stop_on_user_error < 2) - wake_up(&binder_user_error_wait); - return ret; -} -module_param_call(stop_on_user_error, binder_set_stop_on_user_error, - param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO); - -#define binder_debug(mask, x...) \ - do { \ - if (binder_debug_mask & mask) \ - pr_info(x); \ - } while (0) - -#define binder_user_error(x...) \ - do { \ - if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \ - pr_info(x); \ - if (binder_stop_on_user_error) \ - binder_stop_on_user_error = 2; \ - } while (0) - -enum binder_stat_types { - BINDER_STAT_PROC, - BINDER_STAT_THREAD, - BINDER_STAT_NODE, - BINDER_STAT_REF, - BINDER_STAT_DEATH, - BINDER_STAT_TRANSACTION, - BINDER_STAT_TRANSACTION_COMPLETE, - BINDER_STAT_COUNT -}; - -struct binder_stats { - int br[_IOC_NR(BR_FAILED_REPLY) + 1]; - int bc[_IOC_NR(BC_DEAD_BINDER_DONE) + 1]; - int obj_created[BINDER_STAT_COUNT]; - int obj_deleted[BINDER_STAT_COUNT]; -}; - -static struct binder_stats binder_stats; - -static inline void binder_stats_deleted(enum binder_stat_types type) -{ - binder_stats.obj_deleted[type]++; -} - -static inline void binder_stats_created(enum binder_stat_types type) -{ - binder_stats.obj_created[type]++; -} - -struct binder_transaction_log_entry { - int debug_id; - int call_type; - int from_proc; - int from_thread; - int target_handle; - int to_proc; - int to_thread; - int to_node; - int data_size; - int offsets_size; -}; -struct binder_transaction_log { - int next; - int full; - struct binder_transaction_log_entry entry[32]; -}; -static struct binder_transaction_log binder_transaction_log; -static struct binder_transaction_log binder_transaction_log_failed; - -static struct binder_transaction_log_entry *binder_transaction_log_add( - struct binder_transaction_log *log) -{ - struct binder_transaction_log_entry *e; - - e = &log->entry[log->next]; - memset(e, 0, sizeof(*e)); - log->next++; - if (log->next == ARRAY_SIZE(log->entry)) { - log->next = 0; - log->full = 1; - } - return e; -} - -struct binder_work { - struct list_head entry; - enum { - BINDER_WORK_TRANSACTION = 1, - BINDER_WORK_TRANSACTION_COMPLETE, - BINDER_WORK_NODE, - BINDER_WORK_DEAD_BINDER, - BINDER_WORK_DEAD_BINDER_AND_CLEAR, - BINDER_WORK_CLEAR_DEATH_NOTIFICATION, - } type; -}; - -struct binder_node { - int debug_id; - struct binder_work work; - union { - struct rb_node rb_node; - struct hlist_node dead_node; - }; - struct binder_proc *proc; - struct hlist_head refs; - int internal_strong_refs; - int local_weak_refs; - int local_strong_refs; - binder_uintptr_t ptr; - binder_uintptr_t cookie; - unsigned has_strong_ref:1; - unsigned pending_strong_ref:1; - unsigned has_weak_ref:1; - unsigned pending_weak_ref:1; - unsigned has_async_transaction:1; - unsigned accept_fds:1; - unsigned min_priority:8; - struct list_head async_todo; -}; - -struct binder_ref_death { - struct binder_work work; - binder_uintptr_t cookie; -}; - -struct binder_ref { - /* Lookups needed: */ - /* node + proc => ref (transaction) */ - /* desc + proc => ref (transaction, inc/dec ref) */ - /* node => refs + procs (proc exit) */ - int debug_id; - struct rb_node rb_node_desc; - struct rb_node rb_node_node; - struct hlist_node node_entry; - struct binder_proc *proc; - struct binder_node *node; - uint32_t desc; - int strong; - int weak; - struct binder_ref_death *death; -}; - -struct binder_buffer { - struct list_head entry; /* free and allocated entries by address */ - struct rb_node rb_node; /* free entry by size or allocated entry */ - /* by address */ - unsigned free:1; - unsigned allow_user_free:1; - unsigned async_transaction:1; - unsigned debug_id:29; - - struct binder_transaction *transaction; - - struct binder_node *target_node; - size_t data_size; - size_t offsets_size; - uint8_t data[0]; -}; - -enum binder_deferred_state { - BINDER_DEFERRED_PUT_FILES = 0x01, - BINDER_DEFERRED_FLUSH = 0x02, - BINDER_DEFERRED_RELEASE = 0x04, -}; - -struct binder_proc { - struct hlist_node proc_node; - struct rb_root threads; - struct rb_root nodes; - struct rb_root refs_by_desc; - struct rb_root refs_by_node; - int pid; - struct vm_area_struct *vma; - struct mm_struct *vma_vm_mm; - struct task_struct *tsk; - struct files_struct *files; - struct hlist_node deferred_work_node; - int deferred_work; - void *buffer; - ptrdiff_t user_buffer_offset; - - struct list_head buffers; - struct rb_root free_buffers; - struct rb_root allocated_buffers; - size_t free_async_space; - - struct page **pages; - size_t buffer_size; - uint32_t buffer_free; - struct list_head todo; - wait_queue_head_t wait; - struct binder_stats stats; - struct list_head delivered_death; - int max_threads; - int requested_threads; - int requested_threads_started; - int ready_threads; - long default_priority; - struct dentry *debugfs_entry; -}; - -enum { - BINDER_LOOPER_STATE_REGISTERED = 0x01, - BINDER_LOOPER_STATE_ENTERED = 0x02, - BINDER_LOOPER_STATE_EXITED = 0x04, - BINDER_LOOPER_STATE_INVALID = 0x08, - BINDER_LOOPER_STATE_WAITING = 0x10, - BINDER_LOOPER_STATE_NEED_RETURN = 0x20 -}; - -struct binder_thread { - struct binder_proc *proc; - struct rb_node rb_node; - int pid; - int looper; - struct binder_transaction *transaction_stack; - struct list_head todo; - uint32_t return_error; /* Write failed, return error code in read buf */ - uint32_t return_error2; /* Write failed, return error code in read */ - /* buffer. Used when sending a reply to a dead process that */ - /* we are also waiting on */ - wait_queue_head_t wait; - struct binder_stats stats; -}; - -struct binder_transaction { - int debug_id; - struct binder_work work; - struct binder_thread *from; - struct binder_transaction *from_parent; - struct binder_proc *to_proc; - struct binder_thread *to_thread; - struct binder_transaction *to_parent; - unsigned need_reply:1; - /* unsigned is_dead:1; */ /* not used at the moment */ - - struct binder_buffer *buffer; - unsigned int code; - unsigned int flags; - long priority; - long saved_priority; - kuid_t sender_euid; -}; - -static void -binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer); - -static int task_get_unused_fd_flags(struct binder_proc *proc, int flags) -{ - struct files_struct *files = proc->files; - unsigned long rlim_cur; - unsigned long irqs; - - if (files == NULL) - return -ESRCH; - - if (!lock_task_sighand(proc->tsk, &irqs)) - return -EMFILE; - - rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE); - unlock_task_sighand(proc->tsk, &irqs); - - return __alloc_fd(files, 0, rlim_cur, flags); -} - -/* - * copied from fd_install - */ -static void task_fd_install( - struct binder_proc *proc, unsigned int fd, struct file *file) -{ - if (proc->files) - __fd_install(proc->files, fd, file); -} - -/* - * copied from sys_close - */ -static long task_close_fd(struct binder_proc *proc, unsigned int fd) -{ - int retval; - - if (proc->files == NULL) - return -ESRCH; - - retval = __close_fd(proc->files, fd); - /* can't restart close syscall because file table entry was cleared */ - if (unlikely(retval == -ERESTARTSYS || - retval == -ERESTARTNOINTR || - retval == -ERESTARTNOHAND || - retval == -ERESTART_RESTARTBLOCK)) - retval = -EINTR; - - return retval; -} - -static inline void binder_lock(const char *tag) -{ - trace_binder_lock(tag); - mutex_lock(&binder_main_lock); - trace_binder_locked(tag); -} - -static inline void binder_unlock(const char *tag) -{ - trace_binder_unlock(tag); - mutex_unlock(&binder_main_lock); -} - -static void binder_set_nice(long nice) -{ - long min_nice; - - if (can_nice(current, nice)) { - set_user_nice(current, nice); - return; - } - min_nice = rlimit_to_nice(current->signal->rlim[RLIMIT_NICE].rlim_cur); - binder_debug(BINDER_DEBUG_PRIORITY_CAP, - "%d: nice value %ld not allowed use %ld instead\n", - current->pid, nice, min_nice); - set_user_nice(current, min_nice); - if (min_nice <= MAX_NICE) - return; - binder_user_error("%d RLIMIT_NICE not set\n", current->pid); -} - -static size_t binder_buffer_size(struct binder_proc *proc, - struct binder_buffer *buffer) -{ - if (list_is_last(&buffer->entry, &proc->buffers)) - return proc->buffer + proc->buffer_size - (void *)buffer->data; - return (size_t)list_entry(buffer->entry.next, - struct binder_buffer, entry) - (size_t)buffer->data; -} - -static void binder_insert_free_buffer(struct binder_proc *proc, - struct binder_buffer *new_buffer) -{ - struct rb_node **p = &proc->free_buffers.rb_node; - struct rb_node *parent = NULL; - struct binder_buffer *buffer; - size_t buffer_size; - size_t new_buffer_size; - - BUG_ON(!new_buffer->free); - - new_buffer_size = binder_buffer_size(proc, new_buffer); - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: add free buffer, size %zd, at %p\n", - proc->pid, new_buffer_size, new_buffer); - - while (*p) { - parent = *p; - buffer = rb_entry(parent, struct binder_buffer, rb_node); - BUG_ON(!buffer->free); - - buffer_size = binder_buffer_size(proc, buffer); - - if (new_buffer_size < buffer_size) - p = &parent->rb_left; - else - p = &parent->rb_right; - } - rb_link_node(&new_buffer->rb_node, parent, p); - rb_insert_color(&new_buffer->rb_node, &proc->free_buffers); -} - -static void binder_insert_allocated_buffer(struct binder_proc *proc, - struct binder_buffer *new_buffer) -{ - struct rb_node **p = &proc->allocated_buffers.rb_node; - struct rb_node *parent = NULL; - struct binder_buffer *buffer; - - BUG_ON(new_buffer->free); - - while (*p) { - parent = *p; - buffer = rb_entry(parent, struct binder_buffer, rb_node); - BUG_ON(buffer->free); - - if (new_buffer < buffer) - p = &parent->rb_left; - else if (new_buffer > buffer) - p = &parent->rb_right; - else - BUG(); - } - rb_link_node(&new_buffer->rb_node, parent, p); - rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers); -} - -static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc, - uintptr_t user_ptr) -{ - struct rb_node *n = proc->allocated_buffers.rb_node; - struct binder_buffer *buffer; - struct binder_buffer *kern_ptr; - - 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); - BUG_ON(buffer->free); - - if (kern_ptr < buffer) - n = n->rb_left; - else if (kern_ptr > buffer) - n = n->rb_right; - else - return buffer; - } - return NULL; -} - -static int binder_update_page_range(struct binder_proc *proc, int allocate, - void *start, void *end, - struct vm_area_struct *vma) -{ - void *page_addr; - unsigned long user_page_addr; - struct vm_struct tmp_area; - struct page **page; - struct mm_struct *mm; - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: %s pages %p-%p\n", proc->pid, - allocate ? "allocate" : "free", start, end); - - if (end <= start) - return 0; - - trace_binder_update_page_range(proc, allocate, start, end); - - if (vma) - mm = NULL; - else - mm = get_task_mm(proc->tsk); - - if (mm) { - down_write(&mm->mmap_sem); - vma = proc->vma; - if (vma && mm != proc->vma_vm_mm) { - pr_err("%d: vma mm and task mm mismatch\n", - proc->pid); - vma = NULL; - } - } - - if (allocate == 0) - goto free_range; - - if (vma == NULL) { - pr_err("%d: binder_alloc_buf failed to map pages in userspace, no vma\n", - proc->pid); - goto err_no_vma; - } - - for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) { - int ret; - - page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; - - BUG_ON(*page); - *page = alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO); - if (*page == NULL) { - pr_err("%d: binder_alloc_buf failed for page at %p\n", - proc->pid, page_addr); - goto err_alloc_page_failed; - } - tmp_area.addr = page_addr; - tmp_area.size = PAGE_SIZE + PAGE_SIZE /* guard page? */; - ret = map_vm_area(&tmp_area, PAGE_KERNEL, page); - if (ret) { - pr_err("%d: binder_alloc_buf failed to map page at %p in kernel\n", - proc->pid, page_addr); - goto err_map_kernel_failed; - } - user_page_addr = - (uintptr_t)page_addr + proc->user_buffer_offset; - ret = vm_insert_page(vma, user_page_addr, page[0]); - if (ret) { - pr_err("%d: binder_alloc_buf failed to map page at %lx in userspace\n", - proc->pid, user_page_addr); - goto err_vm_insert_page_failed; - } - /* vm_insert_page does not seem to increment the refcount */ - } - if (mm) { - up_write(&mm->mmap_sem); - mmput(mm); - } - return 0; - -free_range: - for (page_addr = end - PAGE_SIZE; page_addr >= start; - page_addr -= PAGE_SIZE) { - page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; - if (vma) - zap_page_range(vma, (uintptr_t)page_addr + - proc->user_buffer_offset, PAGE_SIZE, NULL); -err_vm_insert_page_failed: - unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE); -err_map_kernel_failed: - __free_page(*page); - *page = NULL; -err_alloc_page_failed: - ; - } -err_no_vma: - if (mm) { - up_write(&mm->mmap_sem); - mmput(mm); - } - return -ENOMEM; -} - -static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc, - size_t data_size, - size_t offsets_size, int is_async) -{ - struct rb_node *n = proc->free_buffers.rb_node; - struct binder_buffer *buffer; - size_t buffer_size; - struct rb_node *best_fit = NULL; - void *has_page_addr; - void *end_page_addr; - size_t size; - - if (proc->vma == NULL) { - pr_err("%d: binder_alloc_buf, no vma\n", - proc->pid); - return NULL; - } - - size = ALIGN(data_size, sizeof(void *)) + - ALIGN(offsets_size, sizeof(void *)); - - if (size < data_size || size < offsets_size) { - binder_user_error("%d: got transaction with invalid size %zd-%zd\n", - proc->pid, data_size, offsets_size); - return NULL; - } - - if (is_async && - proc->free_async_space < size + sizeof(struct binder_buffer)) { - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: binder_alloc_buf size %zd failed, no async space left\n", - proc->pid, size); - return NULL; - } - - while (n) { - buffer = rb_entry(n, struct binder_buffer, rb_node); - BUG_ON(!buffer->free); - buffer_size = binder_buffer_size(proc, buffer); - - if (size < buffer_size) { - best_fit = n; - n = n->rb_left; - } else if (size > buffer_size) - n = n->rb_right; - else { - best_fit = n; - break; - } - } - if (best_fit == NULL) { - pr_err("%d: binder_alloc_buf size %zd failed, no address space\n", - proc->pid, size); - return NULL; - } - if (n == NULL) { - buffer = rb_entry(best_fit, struct binder_buffer, rb_node); - buffer_size = binder_buffer_size(proc, buffer); - } - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: binder_alloc_buf size %zd got buffer %p size %zd\n", - proc->pid, size, buffer, buffer_size); - - has_page_addr = - (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK); - if (n == NULL) { - if (size + sizeof(struct binder_buffer) + 4 >= buffer_size) - buffer_size = size; /* no room for other buffers */ - else - buffer_size = size + sizeof(struct binder_buffer); - } - end_page_addr = - (void *)PAGE_ALIGN((uintptr_t)buffer->data + buffer_size); - if (end_page_addr > has_page_addr) - end_page_addr = has_page_addr; - if (binder_update_page_range(proc, 1, - (void *)PAGE_ALIGN((uintptr_t)buffer->data), end_page_addr, NULL)) - return NULL; - - rb_erase(best_fit, &proc->free_buffers); - buffer->free = 0; - binder_insert_allocated_buffer(proc, buffer); - if (buffer_size != size) { - struct binder_buffer *new_buffer = (void *)buffer->data + size; - - list_add(&new_buffer->entry, &buffer->entry); - new_buffer->free = 1; - binder_insert_free_buffer(proc, new_buffer); - } - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: binder_alloc_buf size %zd got %p\n", - proc->pid, size, buffer); - buffer->data_size = data_size; - buffer->offsets_size = offsets_size; - buffer->async_transaction = is_async; - if (is_async) { - proc->free_async_space -= size + sizeof(struct binder_buffer); - binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, - "%d: binder_alloc_buf size %zd async free %zd\n", - proc->pid, size, proc->free_async_space); - } - - return buffer; -} - -static void *buffer_start_page(struct binder_buffer *buffer) -{ - return (void *)((uintptr_t)buffer & PAGE_MASK); -} - -static void *buffer_end_page(struct binder_buffer *buffer) -{ - return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK); -} - -static void binder_delete_free_buffer(struct binder_proc *proc, - struct binder_buffer *buffer) -{ - struct binder_buffer *prev, *next = NULL; - int free_page_end = 1; - int free_page_start = 1; - - BUG_ON(proc->buffers.next == &buffer->entry); - prev = list_entry(buffer->entry.prev, struct binder_buffer, entry); - BUG_ON(!prev->free); - if (buffer_end_page(prev) == buffer_start_page(buffer)) { - free_page_start = 0; - if (buffer_end_page(prev) == buffer_end_page(buffer)) - free_page_end = 0; - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: merge free, buffer %p share page with %p\n", - proc->pid, buffer, prev); - } - - if (!list_is_last(&buffer->entry, &proc->buffers)) { - next = list_entry(buffer->entry.next, - struct binder_buffer, entry); - if (buffer_start_page(next) == buffer_end_page(buffer)) { - free_page_end = 0; - if (buffer_start_page(next) == - buffer_start_page(buffer)) - free_page_start = 0; - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: merge free, buffer %p share page with %p\n", - proc->pid, buffer, prev); - } - } - list_del(&buffer->entry); - if (free_page_start || free_page_end) { - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: merge free, buffer %p do not share page%s%s with %p or %p\n", - proc->pid, buffer, free_page_start ? "" : " end", - free_page_end ? "" : " start", prev, next); - binder_update_page_range(proc, 0, free_page_start ? - buffer_start_page(buffer) : buffer_end_page(buffer), - (free_page_end ? buffer_end_page(buffer) : - buffer_start_page(buffer)) + PAGE_SIZE, NULL); - } -} - -static void binder_free_buf(struct binder_proc *proc, - struct binder_buffer *buffer) -{ - size_t size, buffer_size; - - buffer_size = binder_buffer_size(proc, buffer); - - size = ALIGN(buffer->data_size, sizeof(void *)) + - ALIGN(buffer->offsets_size, sizeof(void *)); - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%d: binder_free_buf %p size %zd buffer_size %zd\n", - proc->pid, buffer, size, buffer_size); - - BUG_ON(buffer->free); - BUG_ON(size > buffer_size); - BUG_ON(buffer->transaction != NULL); - BUG_ON((void *)buffer < proc->buffer); - BUG_ON((void *)buffer > proc->buffer + proc->buffer_size); - - if (buffer->async_transaction) { - proc->free_async_space += size + sizeof(struct binder_buffer); - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, - "%d: binder_free_buf size %zd async free %zd\n", - proc->pid, size, proc->free_async_space); - } - - binder_update_page_range(proc, 0, - (void *)PAGE_ALIGN((uintptr_t)buffer->data), - (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK), - NULL); - rb_erase(&buffer->rb_node, &proc->allocated_buffers); - buffer->free = 1; - if (!list_is_last(&buffer->entry, &proc->buffers)) { - struct binder_buffer *next = list_entry(buffer->entry.next, - struct binder_buffer, entry); - - if (next->free) { - rb_erase(&next->rb_node, &proc->free_buffers); - binder_delete_free_buffer(proc, next); - } - } - if (proc->buffers.next != &buffer->entry) { - struct binder_buffer *prev = list_entry(buffer->entry.prev, - struct binder_buffer, entry); - - if (prev->free) { - binder_delete_free_buffer(proc, buffer); - rb_erase(&prev->rb_node, &proc->free_buffers); - buffer = prev; - } - } - binder_insert_free_buffer(proc, buffer); -} - -static struct binder_node *binder_get_node(struct binder_proc *proc, - binder_uintptr_t ptr) -{ - struct rb_node *n = proc->nodes.rb_node; - struct binder_node *node; - - while (n) { - node = rb_entry(n, struct binder_node, rb_node); - - if (ptr < node->ptr) - n = n->rb_left; - else if (ptr > node->ptr) - n = n->rb_right; - else - return node; - } - return NULL; -} - -static struct binder_node *binder_new_node(struct binder_proc *proc, - binder_uintptr_t ptr, - binder_uintptr_t cookie) -{ - struct rb_node **p = &proc->nodes.rb_node; - struct rb_node *parent = NULL; - struct binder_node *node; - - while (*p) { - parent = *p; - node = rb_entry(parent, struct binder_node, rb_node); - - if (ptr < node->ptr) - p = &(*p)->rb_left; - else if (ptr > node->ptr) - p = &(*p)->rb_right; - else - return NULL; - } - - node = kzalloc(sizeof(*node), GFP_KERNEL); - if (node == NULL) - return NULL; - binder_stats_created(BINDER_STAT_NODE); - rb_link_node(&node->rb_node, parent, p); - rb_insert_color(&node->rb_node, &proc->nodes); - node->debug_id = ++binder_last_id; - node->proc = proc; - node->ptr = ptr; - node->cookie = cookie; - node->work.type = BINDER_WORK_NODE; - INIT_LIST_HEAD(&node->work.entry); - INIT_LIST_HEAD(&node->async_todo); - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d:%d node %d u%016llx c%016llx created\n", - proc->pid, current->pid, node->debug_id, - (u64)node->ptr, (u64)node->cookie); - return node; -} - -static int binder_inc_node(struct binder_node *node, int strong, int internal, - struct list_head *target_list) -{ - if (strong) { - if (internal) { - if (target_list == NULL && - node->internal_strong_refs == 0 && - !(node == binder_context_mgr_node && - node->has_strong_ref)) { - pr_err("invalid inc strong node for %d\n", - node->debug_id); - return -EINVAL; - } - node->internal_strong_refs++; - } else - node->local_strong_refs++; - if (!node->has_strong_ref && target_list) { - list_del_init(&node->work.entry); - list_add_tail(&node->work.entry, target_list); - } - } else { - if (!internal) - node->local_weak_refs++; - if (!node->has_weak_ref && list_empty(&node->work.entry)) { - if (target_list == NULL) { - pr_err("invalid inc weak node for %d\n", - node->debug_id); - return -EINVAL; - } - list_add_tail(&node->work.entry, target_list); - } - } - return 0; -} - -static int binder_dec_node(struct binder_node *node, int strong, int internal) -{ - if (strong) { - if (internal) - node->internal_strong_refs--; - else - node->local_strong_refs--; - if (node->local_strong_refs || node->internal_strong_refs) - return 0; - } else { - if (!internal) - node->local_weak_refs--; - if (node->local_weak_refs || !hlist_empty(&node->refs)) - return 0; - } - if (node->proc && (node->has_strong_ref || node->has_weak_ref)) { - if (list_empty(&node->work.entry)) { - list_add_tail(&node->work.entry, &node->proc->todo); - wake_up_interruptible(&node->proc->wait); - } - } else { - if (hlist_empty(&node->refs) && !node->local_strong_refs && - !node->local_weak_refs) { - list_del_init(&node->work.entry); - if (node->proc) { - rb_erase(&node->rb_node, &node->proc->nodes); - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "refless node %d deleted\n", - node->debug_id); - } else { - hlist_del(&node->dead_node); - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "dead node %d deleted\n", - node->debug_id); - } - kfree(node); - binder_stats_deleted(BINDER_STAT_NODE); - } - } - - return 0; -} - - -static struct binder_ref *binder_get_ref(struct binder_proc *proc, - uint32_t desc) -{ - struct rb_node *n = proc->refs_by_desc.rb_node; - struct binder_ref *ref; - - while (n) { - ref = rb_entry(n, struct binder_ref, rb_node_desc); - - if (desc < ref->desc) - n = n->rb_left; - else if (desc > ref->desc) - n = n->rb_right; - else - return ref; - } - return NULL; -} - -static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc, - struct binder_node *node) -{ - struct rb_node *n; - struct rb_node **p = &proc->refs_by_node.rb_node; - struct rb_node *parent = NULL; - struct binder_ref *ref, *new_ref; - - while (*p) { - parent = *p; - ref = rb_entry(parent, struct binder_ref, rb_node_node); - - if (node < ref->node) - p = &(*p)->rb_left; - else if (node > ref->node) - p = &(*p)->rb_right; - else - return ref; - } - new_ref = kzalloc(sizeof(*ref), GFP_KERNEL); - if (new_ref == NULL) - return NULL; - binder_stats_created(BINDER_STAT_REF); - new_ref->debug_id = ++binder_last_id; - new_ref->proc = proc; - new_ref->node = node; - rb_link_node(&new_ref->rb_node_node, parent, p); - rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); - - new_ref->desc = (node == binder_context_mgr_node) ? 0 : 1; - for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { - ref = rb_entry(n, struct binder_ref, rb_node_desc); - if (ref->desc > new_ref->desc) - break; - new_ref->desc = ref->desc + 1; - } - - p = &proc->refs_by_desc.rb_node; - while (*p) { - parent = *p; - ref = rb_entry(parent, struct binder_ref, rb_node_desc); - - if (new_ref->desc < ref->desc) - p = &(*p)->rb_left; - else if (new_ref->desc > ref->desc) - p = &(*p)->rb_right; - else - BUG(); - } - rb_link_node(&new_ref->rb_node_desc, parent, p); - rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); - if (node) { - hlist_add_head(&new_ref->node_entry, &node->refs); - - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d new ref %d desc %d for node %d\n", - proc->pid, new_ref->debug_id, new_ref->desc, - node->debug_id); - } else { - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d new ref %d desc %d for dead node\n", - proc->pid, new_ref->debug_id, new_ref->desc); - } - return new_ref; -} - -static void binder_delete_ref(struct binder_ref *ref) -{ - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "%d delete ref %d desc %d for node %d\n", - ref->proc->pid, ref->debug_id, ref->desc, - ref->node->debug_id); - - rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); - rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); - if (ref->strong) - binder_dec_node(ref->node, 1, 1); - hlist_del(&ref->node_entry); - binder_dec_node(ref->node, 0, 1); - if (ref->death) { - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "%d delete ref %d desc %d has death notification\n", - ref->proc->pid, ref->debug_id, ref->desc); - list_del(&ref->death->work.entry); - kfree(ref->death); - binder_stats_deleted(BINDER_STAT_DEATH); - } - kfree(ref); - binder_stats_deleted(BINDER_STAT_REF); -} - -static int binder_inc_ref(struct binder_ref *ref, int strong, - struct list_head *target_list) -{ - int ret; - - if (strong) { - if (ref->strong == 0) { - ret = binder_inc_node(ref->node, 1, 1, target_list); - if (ret) - return ret; - } - ref->strong++; - } else { - if (ref->weak == 0) { - ret = binder_inc_node(ref->node, 0, 1, target_list); - if (ret) - return ret; - } - ref->weak++; - } - return 0; -} - - -static int binder_dec_ref(struct binder_ref *ref, int strong) -{ - if (strong) { - if (ref->strong == 0) { - binder_user_error("%d invalid dec strong, ref %d desc %d s %d w %d\n", - ref->proc->pid, ref->debug_id, - ref->desc, ref->strong, ref->weak); - return -EINVAL; - } - ref->strong--; - if (ref->strong == 0) { - int ret; - - ret = binder_dec_node(ref->node, strong, 1); - if (ret) - return ret; - } - } else { - if (ref->weak == 0) { - binder_user_error("%d invalid dec weak, ref %d desc %d s %d w %d\n", - ref->proc->pid, ref->debug_id, - ref->desc, ref->strong, ref->weak); - return -EINVAL; - } - ref->weak--; - } - if (ref->strong == 0 && ref->weak == 0) - binder_delete_ref(ref); - return 0; -} - -static void binder_pop_transaction(struct binder_thread *target_thread, - struct binder_transaction *t) -{ - if (target_thread) { - BUG_ON(target_thread->transaction_stack != t); - BUG_ON(target_thread->transaction_stack->from != target_thread); - target_thread->transaction_stack = - target_thread->transaction_stack->from_parent; - t->from = NULL; - } - t->need_reply = 0; - if (t->buffer) - t->buffer->transaction = NULL; - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); -} - -static void binder_send_failed_reply(struct binder_transaction *t, - uint32_t error_code) -{ - struct binder_thread *target_thread; - struct binder_transaction *next; - - BUG_ON(t->flags & TF_ONE_WAY); - while (1) { - target_thread = t->from; - if (target_thread) { - if (target_thread->return_error != BR_OK && - target_thread->return_error2 == BR_OK) { - target_thread->return_error2 = - target_thread->return_error; - target_thread->return_error = BR_OK; - } - if (target_thread->return_error == BR_OK) { - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "send failed reply for transaction %d to %d:%d\n", - t->debug_id, - target_thread->proc->pid, - target_thread->pid); - - binder_pop_transaction(target_thread, t); - target_thread->return_error = error_code; - wake_up_interruptible(&target_thread->wait); - } else { - pr_err("reply failed, target thread, %d:%d, has error code %d already\n", - target_thread->proc->pid, - target_thread->pid, - target_thread->return_error); - } - return; - } - next = t->from_parent; - - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "send failed reply for transaction %d, target dead\n", - t->debug_id); - - binder_pop_transaction(target_thread, t); - if (next == NULL) { - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "reply failed, no target thread at root\n"); - return; - } - t = next; - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "reply failed, no target thread -- retry %d\n", - t->debug_id); - } -} - -static void binder_transaction_buffer_release(struct binder_proc *proc, - struct binder_buffer *buffer, - binder_size_t *failed_at) -{ - binder_size_t *offp, *off_end; - int debug_id = buffer->debug_id; - - binder_debug(BINDER_DEBUG_TRANSACTION, - "%d buffer release %d, size %zd-%zd, failed at %p\n", - proc->pid, buffer->debug_id, - buffer->data_size, buffer->offsets_size, failed_at); - - if (buffer->target_node) - binder_dec_node(buffer->target_node, 1, 0); - - offp = (binder_size_t *)(buffer->data + - ALIGN(buffer->data_size, sizeof(void *))); - if (failed_at) - off_end = failed_at; - else - off_end = (void *)offp + buffer->offsets_size; - for (; offp < off_end; offp++) { - struct flat_binder_object *fp; - - if (*offp > buffer->data_size - sizeof(*fp) || - buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(u32))) { - 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); - switch (fp->type) { - case BINDER_TYPE_BINDER: - case BINDER_TYPE_WEAK_BINDER: { - struct binder_node *node = binder_get_node(proc, fp->binder); - - if (node == NULL) { - pr_err("transaction release %d bad node %016llx\n", - debug_id, (u64)fp->binder); - break; - } - binder_debug(BINDER_DEBUG_TRANSACTION, - " 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: - case BINDER_TYPE_WEAK_HANDLE: { - struct binder_ref *ref = binder_get_ref(proc, fp->handle); - - if (ref == NULL) { - pr_err("transaction release %d bad handle %d\n", - debug_id, fp->handle); - break; - } - binder_debug(BINDER_DEBUG_TRANSACTION, - " ref %d desc %d (node %d)\n", - ref->debug_id, ref->desc, ref->node->debug_id); - binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE); - } break; - - case BINDER_TYPE_FD: - binder_debug(BINDER_DEBUG_TRANSACTION, - " fd %d\n", fp->handle); - if (failed_at) - task_close_fd(proc, fp->handle); - break; - - default: - pr_err("transaction release %d bad object type %x\n", - debug_id, fp->type); - break; - } - } -} - -static void binder_transaction(struct binder_proc *proc, - struct binder_thread *thread, - struct binder_transaction_data *tr, int reply) -{ - struct binder_transaction *t; - struct binder_work *tcomplete; - binder_size_t *offp, *off_end; - struct binder_proc *target_proc; - struct binder_thread *target_thread = NULL; - struct binder_node *target_node = NULL; - struct list_head *target_list; - wait_queue_head_t *target_wait; - struct binder_transaction *in_reply_to = NULL; - struct binder_transaction_log_entry *e; - uint32_t return_error; - - e = binder_transaction_log_add(&binder_transaction_log); - e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY); - e->from_proc = proc->pid; - e->from_thread = thread->pid; - e->target_handle = tr->target.handle; - e->data_size = tr->data_size; - e->offsets_size = tr->offsets_size; - - if (reply) { - in_reply_to = thread->transaction_stack; - if (in_reply_to == NULL) { - binder_user_error("%d:%d got reply transaction with no transaction stack\n", - proc->pid, thread->pid); - return_error = BR_FAILED_REPLY; - goto err_empty_call_stack; - } - binder_set_nice(in_reply_to->saved_priority); - if (in_reply_to->to_thread != thread) { - binder_user_error("%d:%d got reply transaction with bad transaction stack, transaction %d has target %d:%d\n", - proc->pid, thread->pid, in_reply_to->debug_id, - in_reply_to->to_proc ? - in_reply_to->to_proc->pid : 0, - in_reply_to->to_thread ? - in_reply_to->to_thread->pid : 0); - return_error = BR_FAILED_REPLY; - in_reply_to = NULL; - goto err_bad_call_stack; - } - thread->transaction_stack = in_reply_to->to_parent; - target_thread = in_reply_to->from; - if (target_thread == NULL) { - return_error = BR_DEAD_REPLY; - goto err_dead_binder; - } - if (target_thread->transaction_stack != in_reply_to) { - binder_user_error("%d:%d got reply transaction with bad target transaction stack %d, expected %d\n", - proc->pid, thread->pid, - target_thread->transaction_stack ? - target_thread->transaction_stack->debug_id : 0, - in_reply_to->debug_id); - return_error = BR_FAILED_REPLY; - in_reply_to = NULL; - target_thread = NULL; - goto err_dead_binder; - } - target_proc = target_thread->proc; - } else { - if (tr->target.handle) { - struct binder_ref *ref; - - ref = binder_get_ref(proc, tr->target.handle); - if (ref == NULL) { - binder_user_error("%d:%d got transaction to invalid handle\n", - proc->pid, thread->pid); - return_error = BR_FAILED_REPLY; - goto err_invalid_target_handle; - } - target_node = ref->node; - } else { - target_node = binder_context_mgr_node; - if (target_node == NULL) { - return_error = BR_DEAD_REPLY; - goto err_no_context_mgr_node; - } - } - e->to_node = target_node->debug_id; - target_proc = target_node->proc; - if (target_proc == NULL) { - return_error = BR_DEAD_REPLY; - goto err_dead_binder; - } - if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { - struct binder_transaction *tmp; - - tmp = thread->transaction_stack; - if (tmp->to_thread != thread) { - binder_user_error("%d:%d got new transaction with bad transaction stack, transaction %d has target %d:%d\n", - proc->pid, thread->pid, tmp->debug_id, - tmp->to_proc ? tmp->to_proc->pid : 0, - tmp->to_thread ? - tmp->to_thread->pid : 0); - return_error = BR_FAILED_REPLY; - goto err_bad_call_stack; - } - while (tmp) { - if (tmp->from && tmp->from->proc == target_proc) - target_thread = tmp->from; - tmp = tmp->from_parent; - } - } - } - if (target_thread) { - e->to_thread = target_thread->pid; - target_list = &target_thread->todo; - target_wait = &target_thread->wait; - } else { - target_list = &target_proc->todo; - target_wait = &target_proc->wait; - } - e->to_proc = target_proc->pid; - - /* TODO: reuse incoming transaction for reply */ - t = kzalloc(sizeof(*t), GFP_KERNEL); - if (t == NULL) { - return_error = BR_FAILED_REPLY; - goto err_alloc_t_failed; - } - binder_stats_created(BINDER_STAT_TRANSACTION); - - tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL); - if (tcomplete == NULL) { - return_error = BR_FAILED_REPLY; - goto err_alloc_tcomplete_failed; - } - binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE); - - t->debug_id = ++binder_last_id; - e->debug_id = t->debug_id; - - if (reply) - binder_debug(BINDER_DEBUG_TRANSACTION, - "%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, - (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 %016llx-%016llx size %lld-%lld\n", - proc->pid, thread->pid, t->debug_id, - target_proc->pid, target_node->debug_id, - (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; - else - t->from = NULL; - t->sender_euid = task_euid(proc->tsk); - t->to_proc = target_proc; - t->to_thread = target_thread; - t->code = tr->code; - t->flags = tr->flags; - t->priority = task_nice(current); - - trace_binder_transaction(reply, t, target_node); - - t->buffer = binder_alloc_buf(target_proc, tr->data_size, - tr->offsets_size, !reply && (t->flags & TF_ONE_WAY)); - if (t->buffer == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_alloc_buf_failed; - } - t->buffer->allow_user_free = 0; - t->buffer->debug_id = t->debug_id; - t->buffer->transaction = t; - t->buffer->target_node = target_node; - trace_binder_transaction_alloc_buf(t->buffer); - if (target_node) - binder_inc_node(target_node, 1, 0, NULL); - - offp = (binder_size_t *)(t->buffer->data + - ALIGN(tr->data_size, sizeof(void *))); - - 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, (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(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; - } - off_end = (void *)offp + tr->offsets_size; - for (; offp < off_end; offp++) { - struct flat_binder_object *fp; - - if (*offp > t->buffer->data_size - sizeof(*fp) || - t->buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(u32))) { - 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; - } - fp = (struct flat_binder_object *)(t->buffer->data + *offp); - switch (fp->type) { - case BINDER_TYPE_BINDER: - case BINDER_TYPE_WEAK_BINDER: { - struct binder_ref *ref; - struct binder_node *node = binder_get_node(proc, fp->binder); - - if (node == NULL) { - node = binder_new_node(proc, fp->binder, fp->cookie); - if (node == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_new_node_failed; - } - node->min_priority = fp->flags & FLAT_BINDER_FLAG_PRIORITY_MASK; - node->accept_fds = !!(fp->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS); - } - if (fp->cookie != node->cookie) { - binder_user_error("%d:%d sending u%016llx node %d, cookie mismatch %016llx != %016llx\n", - proc->pid, thread->pid, - (u64)fp->binder, node->debug_id, - (u64)fp->cookie, (u64)node->cookie); - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_for_node_failed; - } - ref = binder_get_ref_for_node(target_proc, node); - if (ref == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_for_node_failed; - } - if (fp->type == BINDER_TYPE_BINDER) - fp->type = BINDER_TYPE_HANDLE; - else - fp->type = BINDER_TYPE_WEAK_HANDLE; - fp->handle = ref->desc; - binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, - &thread->todo); - - trace_binder_transaction_node_to_ref(t, node, ref); - binder_debug(BINDER_DEBUG_TRANSACTION, - " 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: { - struct binder_ref *ref = binder_get_ref(proc, fp->handle); - - if (ref == NULL) { - binder_user_error("%d:%d got transaction with invalid handle, %d\n", - proc->pid, - thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_failed; - } - if (ref->node->proc == target_proc) { - if (fp->type == BINDER_TYPE_HANDLE) - fp->type = BINDER_TYPE_BINDER; - else - fp->type = BINDER_TYPE_WEAK_BINDER; - fp->binder = ref->node->ptr; - fp->cookie = ref->node->cookie; - 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%016llx\n", - ref->debug_id, ref->desc, ref->node->debug_id, - (u64)ref->node->ptr); - } else { - struct binder_ref *new_ref; - - new_ref = binder_get_ref_for_node(target_proc, ref->node); - if (new_ref == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_for_node_failed; - } - fp->handle = new_ref->desc; - binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL); - trace_binder_transaction_ref_to_ref(t, ref, - new_ref); - binder_debug(BINDER_DEBUG_TRANSACTION, - " ref %d desc %d -> ref %d desc %d (node %d)\n", - ref->debug_id, ref->desc, new_ref->debug_id, - new_ref->desc, ref->node->debug_id); - } - } break; - - case BINDER_TYPE_FD: { - int target_fd; - struct file *file; - - if (reply) { - if (!(in_reply_to->flags & TF_ACCEPT_FDS)) { - binder_user_error("%d:%d got reply with fd, %d, but target does not allow fds\n", - proc->pid, thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_fd_not_allowed; - } - } else if (!target_node->accept_fds) { - binder_user_error("%d:%d got transaction with fd, %d, but target does not allow fds\n", - proc->pid, thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_fd_not_allowed; - } - - file = fget(fp->handle); - if (file == NULL) { - binder_user_error("%d:%d got transaction with invalid fd, %d\n", - proc->pid, thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_fget_failed; - } - target_fd = task_get_unused_fd_flags(target_proc, O_CLOEXEC); - if (target_fd < 0) { - fput(file); - return_error = BR_FAILED_REPLY; - goto err_get_unused_fd_failed; - } - task_fd_install(target_proc, target_fd, file); - trace_binder_transaction_fd(t, fp->handle, target_fd); - binder_debug(BINDER_DEBUG_TRANSACTION, - " fd %d -> %d\n", fp->handle, target_fd); - /* TODO: fput? */ - fp->handle = target_fd; - } break; - - default: - binder_user_error("%d:%d got transaction with invalid object type, %x\n", - proc->pid, thread->pid, fp->type); - return_error = BR_FAILED_REPLY; - goto err_bad_object_type; - } - } - if (reply) { - BUG_ON(t->buffer->async_transaction != 0); - binder_pop_transaction(target_thread, in_reply_to); - } else if (!(t->flags & TF_ONE_WAY)) { - BUG_ON(t->buffer->async_transaction != 0); - t->need_reply = 1; - t->from_parent = thread->transaction_stack; - thread->transaction_stack = t; - } else { - BUG_ON(target_node == NULL); - BUG_ON(t->buffer->async_transaction != 1); - if (target_node->has_async_transaction) { - target_list = &target_node->async_todo; - target_wait = NULL; - } else - target_node->has_async_transaction = 1; - } - t->work.type = BINDER_WORK_TRANSACTION; - list_add_tail(&t->work.entry, target_list); - tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE; - list_add_tail(&tcomplete->entry, &thread->todo); - if (target_wait) - wake_up_interruptible(target_wait); - return; - -err_get_unused_fd_failed: -err_fget_failed: -err_fd_not_allowed: -err_binder_get_ref_for_node_failed: -err_binder_get_ref_failed: -err_binder_new_node_failed: -err_bad_object_type: -err_bad_offset: -err_copy_data_failed: - trace_binder_transaction_failed_buffer_release(t->buffer); - binder_transaction_buffer_release(target_proc, t->buffer, offp); - t->buffer->transaction = NULL; - binder_free_buf(target_proc, t->buffer); -err_binder_alloc_buf_failed: - kfree(tcomplete); - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); -err_alloc_tcomplete_failed: - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); -err_alloc_t_failed: -err_bad_call_stack: -err_empty_call_stack: -err_dead_binder: -err_invalid_target_handle: -err_no_context_mgr_node: - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "%d:%d transaction failed %d, size %lld-%lld\n", - proc->pid, thread->pid, return_error, - (u64)tr->data_size, (u64)tr->offsets_size); - - { - struct binder_transaction_log_entry *fe; - - fe = binder_transaction_log_add(&binder_transaction_log_failed); - *fe = *e; - } - - BUG_ON(thread->return_error != BR_OK); - if (in_reply_to) { - thread->return_error = BR_TRANSACTION_COMPLETE; - binder_send_failed_reply(in_reply_to, return_error); - } else - thread->return_error = return_error; -} - -static int binder_thread_write(struct binder_proc *proc, - struct binder_thread *thread, - 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; - - while (ptr < end && thread->return_error == BR_OK) { - if (get_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - trace_binder_command(cmd); - if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) { - binder_stats.bc[_IOC_NR(cmd)]++; - proc->stats.bc[_IOC_NR(cmd)]++; - thread->stats.bc[_IOC_NR(cmd)]++; - } - switch (cmd) { - case BC_INCREFS: - case BC_ACQUIRE: - case BC_RELEASE: - case BC_DECREFS: { - uint32_t target; - struct binder_ref *ref; - const char *debug_string; - - if (get_user(target, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (target == 0 && binder_context_mgr_node && - (cmd == BC_INCREFS || cmd == BC_ACQUIRE)) { - ref = binder_get_ref_for_node(proc, - binder_context_mgr_node); - if (ref->desc != target) { - binder_user_error("%d:%d tried to acquire reference to desc 0, got %d instead\n", - proc->pid, thread->pid, - ref->desc); - } - } else - ref = binder_get_ref(proc, target); - if (ref == NULL) { - binder_user_error("%d:%d refcount change on invalid ref %d\n", - proc->pid, thread->pid, target); - break; - } - switch (cmd) { - case BC_INCREFS: - debug_string = "IncRefs"; - binder_inc_ref(ref, 0, NULL); - break; - case BC_ACQUIRE: - debug_string = "Acquire"; - binder_inc_ref(ref, 1, NULL); - break; - case BC_RELEASE: - debug_string = "Release"; - binder_dec_ref(ref, 1); - break; - case BC_DECREFS: - default: - debug_string = "DecRefs"; - binder_dec_ref(ref, 0); - break; - } - binder_debug(BINDER_DEBUG_USER_REFS, - "%d:%d %s ref %d desc %d s %d w %d for node %d\n", - proc->pid, thread->pid, debug_string, ref->debug_id, - ref->desc, ref->strong, ref->weak, ref->node->debug_id); - break; - } - case BC_INCREFS_DONE: - case BC_ACQUIRE_DONE: { - binder_uintptr_t node_ptr; - binder_uintptr_t cookie; - struct binder_node *node; - - if (get_user(node_ptr, (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - if (get_user(cookie, (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - node = binder_get_node(proc, node_ptr); - if (node == NULL) { - 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", - (u64)node_ptr); - break; - } - if (cookie != node->cookie) { - 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", - (u64)node_ptr, node->debug_id, - (u64)cookie, (u64)node->cookie); - break; - } - if (cmd == BC_ACQUIRE_DONE) { - if (node->pending_strong_ref == 0) { - binder_user_error("%d:%d BC_ACQUIRE_DONE node %d has no pending acquire request\n", - proc->pid, thread->pid, - node->debug_id); - break; - } - node->pending_strong_ref = 0; - } else { - if (node->pending_weak_ref == 0) { - binder_user_error("%d:%d BC_INCREFS_DONE node %d has no pending increfs request\n", - proc->pid, thread->pid, - node->debug_id); - break; - } - node->pending_weak_ref = 0; - } - binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0); - binder_debug(BINDER_DEBUG_USER_REFS, - "%d:%d %s node %d ls %d lw %d\n", - proc->pid, thread->pid, - cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", - node->debug_id, node->local_strong_refs, node->local_weak_refs); - break; - } - case BC_ATTEMPT_ACQUIRE: - pr_err("BC_ATTEMPT_ACQUIRE not supported\n"); - return -EINVAL; - case BC_ACQUIRE_RESULT: - pr_err("BC_ACQUIRE_RESULT not supported\n"); - return -EINVAL; - - case BC_FREE_BUFFER: { - binder_uintptr_t data_ptr; - struct binder_buffer *buffer; - - if (get_user(data_ptr, (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - - buffer = binder_buffer_lookup(proc, data_ptr); - if (buffer == NULL) { - 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%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%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) { - buffer->transaction->buffer = NULL; - buffer->transaction = NULL; - } - if (buffer->async_transaction && buffer->target_node) { - BUG_ON(!buffer->target_node->has_async_transaction); - if (list_empty(&buffer->target_node->async_todo)) - buffer->target_node->has_async_transaction = 0; - else - list_move_tail(buffer->target_node->async_todo.next, &thread->todo); - } - trace_binder_transaction_buffer_release(buffer); - binder_transaction_buffer_release(proc, buffer, NULL); - binder_free_buf(proc, buffer); - break; - } - - case BC_TRANSACTION: - case BC_REPLY: { - struct binder_transaction_data tr; - - if (copy_from_user(&tr, ptr, sizeof(tr))) - return -EFAULT; - ptr += sizeof(tr); - binder_transaction(proc, thread, &tr, cmd == BC_REPLY); - break; - } - - case BC_REGISTER_LOOPER: - binder_debug(BINDER_DEBUG_THREADS, - "%d:%d BC_REGISTER_LOOPER\n", - proc->pid, thread->pid); - if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { - thread->looper |= BINDER_LOOPER_STATE_INVALID; - binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called after BC_ENTER_LOOPER\n", - proc->pid, thread->pid); - } else if (proc->requested_threads == 0) { - thread->looper |= BINDER_LOOPER_STATE_INVALID; - binder_user_error("%d:%d ERROR: BC_REGISTER_LOOPER called without request\n", - proc->pid, thread->pid); - } else { - proc->requested_threads--; - proc->requested_threads_started++; - } - thread->looper |= BINDER_LOOPER_STATE_REGISTERED; - break; - case BC_ENTER_LOOPER: - binder_debug(BINDER_DEBUG_THREADS, - "%d:%d BC_ENTER_LOOPER\n", - proc->pid, thread->pid); - if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { - thread->looper |= BINDER_LOOPER_STATE_INVALID; - binder_user_error("%d:%d ERROR: BC_ENTER_LOOPER called after BC_REGISTER_LOOPER\n", - proc->pid, thread->pid); - } - thread->looper |= BINDER_LOOPER_STATE_ENTERED; - break; - case BC_EXIT_LOOPER: - binder_debug(BINDER_DEBUG_THREADS, - "%d:%d BC_EXIT_LOOPER\n", - proc->pid, thread->pid); - thread->looper |= BINDER_LOOPER_STATE_EXITED; - break; - - case BC_REQUEST_DEATH_NOTIFICATION: - case BC_CLEAR_DEATH_NOTIFICATION: { - uint32_t target; - 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, (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - ref = binder_get_ref(proc, target); - if (ref == NULL) { - binder_user_error("%d:%d %s invalid ref %d\n", - proc->pid, thread->pid, - cmd == BC_REQUEST_DEATH_NOTIFICATION ? - "BC_REQUEST_DEATH_NOTIFICATION" : - "BC_CLEAR_DEATH_NOTIFICATION", - target); - break; - } - - binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, - "%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", - (u64)cookie, ref->debug_id, ref->desc, - ref->strong, ref->weak, ref->node->debug_id); - - if (cmd == BC_REQUEST_DEATH_NOTIFICATION) { - if (ref->death) { - binder_user_error("%d:%d BC_REQUEST_DEATH_NOTIFICATION death notification already set\n", - proc->pid, thread->pid); - break; - } - death = kzalloc(sizeof(*death), GFP_KERNEL); - if (death == NULL) { - thread->return_error = BR_ERROR; - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "%d:%d BC_REQUEST_DEATH_NOTIFICATION failed\n", - proc->pid, thread->pid); - break; - } - binder_stats_created(BINDER_STAT_DEATH); - INIT_LIST_HEAD(&death->work.entry); - death->cookie = cookie; - ref->death = death; - if (ref->node->proc == NULL) { - ref->death->work.type = BINDER_WORK_DEAD_BINDER; - if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { - list_add_tail(&ref->death->work.entry, &thread->todo); - } else { - list_add_tail(&ref->death->work.entry, &proc->todo); - wake_up_interruptible(&proc->wait); - } - } - } else { - if (ref->death == NULL) { - binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification not active\n", - proc->pid, thread->pid); - break; - } - death = ref->death; - if (death->cookie != cookie) { - binder_user_error("%d:%d BC_CLEAR_DEATH_NOTIFICATION death notification cookie mismatch %016llx != %016llx\n", - proc->pid, thread->pid, - (u64)death->cookie, - (u64)cookie); - break; - } - ref->death = NULL; - if (list_empty(&death->work.entry)) { - death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION; - if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { - list_add_tail(&death->work.entry, &thread->todo); - } else { - list_add_tail(&death->work.entry, &proc->todo); - wake_up_interruptible(&proc->wait); - } - } else { - BUG_ON(death->work.type != BINDER_WORK_DEAD_BINDER); - death->work.type = BINDER_WORK_DEAD_BINDER_AND_CLEAR; - } - } - } break; - case BC_DEAD_BINDER_DONE: { - struct binder_work *w; - binder_uintptr_t cookie; - struct binder_ref_death *death = NULL; - - if (get_user(cookie, (binder_uintptr_t __user *)ptr)) - return -EFAULT; - - ptr += sizeof(void *); - list_for_each_entry(w, &proc->delivered_death, entry) { - struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work); - - if (tmp_death->cookie == cookie) { - death = tmp_death; - break; - } - } - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "%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 %016llx not found\n", - proc->pid, thread->pid, (u64)cookie); - break; - } - - list_del_init(&death->work.entry); - if (death->work.type == BINDER_WORK_DEAD_BINDER_AND_CLEAR) { - death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION; - if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { - list_add_tail(&death->work.entry, &thread->todo); - } else { - list_add_tail(&death->work.entry, &proc->todo); - wake_up_interruptible(&proc->wait); - } - } - } break; - - default: - pr_err("%d:%d unknown command %d\n", - proc->pid, thread->pid, cmd); - return -EINVAL; - } - *consumed = ptr - buffer; - } - return 0; -} - -static void binder_stat_br(struct binder_proc *proc, - struct binder_thread *thread, uint32_t cmd) -{ - trace_binder_return(cmd); - if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) { - binder_stats.br[_IOC_NR(cmd)]++; - proc->stats.br[_IOC_NR(cmd)]++; - thread->stats.br[_IOC_NR(cmd)]++; - } -} - -static int binder_has_proc_work(struct binder_proc *proc, - struct binder_thread *thread) -{ - return !list_empty(&proc->todo) || - (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); -} - -static int binder_has_thread_work(struct binder_thread *thread) -{ - return !list_empty(&thread->todo) || thread->return_error != BR_OK || - (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); -} - -static int binder_thread_read(struct binder_proc *proc, - struct binder_thread *thread, - 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; - - int ret = 0; - int wait_for_proc_work; - - if (*consumed == 0) { - if (put_user(BR_NOOP, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - } - -retry: - wait_for_proc_work = thread->transaction_stack == NULL && - list_empty(&thread->todo); - - if (thread->return_error != BR_OK && ptr < end) { - if (thread->return_error2 != BR_OK) { - if (put_user(thread->return_error2, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - binder_stat_br(proc, thread, thread->return_error2); - if (ptr == end) - goto done; - thread->return_error2 = BR_OK; - } - if (put_user(thread->return_error, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - binder_stat_br(proc, thread, thread->return_error); - thread->return_error = BR_OK; - goto done; - } - - - thread->looper |= BINDER_LOOPER_STATE_WAITING; - if (wait_for_proc_work) - proc->ready_threads++; - - binder_unlock(__func__); - - trace_binder_wait_for_work(wait_for_proc_work, - !!thread->transaction_stack, - !list_empty(&thread->todo)); - if (wait_for_proc_work) { - if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED | - BINDER_LOOPER_STATE_ENTERED))) { - binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n", - proc->pid, thread->pid, thread->looper); - wait_event_interruptible(binder_user_error_wait, - binder_stop_on_user_error < 2); - } - binder_set_nice(proc->default_priority); - if (non_block) { - if (!binder_has_proc_work(proc, thread)) - ret = -EAGAIN; - } else - ret = wait_event_freezable_exclusive(proc->wait, binder_has_proc_work(proc, thread)); - } else { - if (non_block) { - if (!binder_has_thread_work(thread)) - ret = -EAGAIN; - } else - ret = wait_event_freezable(thread->wait, binder_has_thread_work(thread)); - } - - binder_lock(__func__); - - if (wait_for_proc_work) - proc->ready_threads--; - thread->looper &= ~BINDER_LOOPER_STATE_WAITING; - - if (ret) - return ret; - - while (1) { - uint32_t cmd; - struct binder_transaction_data tr; - struct binder_work *w; - struct binder_transaction *t = NULL; - - if (!list_empty(&thread->todo)) { - w = list_first_entry(&thread->todo, struct binder_work, - entry); - } else if (!list_empty(&proc->todo) && wait_for_proc_work) { - w = list_first_entry(&proc->todo, struct binder_work, - entry); - } else { - /* no data added */ - if (ptr - buffer == 4 && - !(thread->looper & BINDER_LOOPER_STATE_NEED_RETURN)) - goto retry; - break; - } - - if (end - ptr < sizeof(tr) + 4) - break; - - switch (w->type) { - case BINDER_WORK_TRANSACTION: { - t = container_of(w, struct binder_transaction, work); - } break; - case BINDER_WORK_TRANSACTION_COMPLETE: { - cmd = BR_TRANSACTION_COMPLETE; - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - - binder_stat_br(proc, thread, cmd); - binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE, - "%d:%d BR_TRANSACTION_COMPLETE\n", - proc->pid, thread->pid); - - list_del(&w->entry); - kfree(w); - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); - } break; - case BINDER_WORK_NODE: { - struct binder_node *node = container_of(w, struct binder_node, work); - uint32_t cmd = BR_NOOP; - const char *cmd_name; - int strong = node->internal_strong_refs || node->local_strong_refs; - int weak = !hlist_empty(&node->refs) || node->local_weak_refs || strong; - - if (weak && !node->has_weak_ref) { - cmd = BR_INCREFS; - cmd_name = "BR_INCREFS"; - node->has_weak_ref = 1; - node->pending_weak_ref = 1; - node->local_weak_refs++; - } else if (strong && !node->has_strong_ref) { - cmd = BR_ACQUIRE; - cmd_name = "BR_ACQUIRE"; - node->has_strong_ref = 1; - node->pending_strong_ref = 1; - node->local_strong_refs++; - } else if (!strong && node->has_strong_ref) { - cmd = BR_RELEASE; - cmd_name = "BR_RELEASE"; - node->has_strong_ref = 0; - } else if (!weak && node->has_weak_ref) { - cmd = BR_DECREFS; - cmd_name = "BR_DECREFS"; - node->has_weak_ref = 0; - } - if (cmd != BR_NOOP) { - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (put_user(node->ptr, - (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - if (put_user(node->cookie, - (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - - binder_stat_br(proc, thread, cmd); - binder_debug(BINDER_DEBUG_USER_REFS, - "%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%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%016llx c%016llx state unchanged\n", - proc->pid, thread->pid, - node->debug_id, - (u64)node->ptr, - (u64)node->cookie); - } - } - } break; - case BINDER_WORK_DEAD_BINDER: - case BINDER_WORK_DEAD_BINDER_AND_CLEAR: - case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: { - struct binder_ref_death *death; - uint32_t cmd; - - death = container_of(w, struct binder_ref_death, work); - if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) - cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE; - else - cmd = BR_DEAD_BINDER; - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (put_user(death->cookie, - (binder_uintptr_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(binder_uintptr_t); - binder_stat_br(proc, thread, cmd); - binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, - "%d:%d %s %016llx\n", - proc->pid, thread->pid, - cmd == BR_DEAD_BINDER ? - "BR_DEAD_BINDER" : - "BR_CLEAR_DEATH_NOTIFICATION_DONE", - (u64)death->cookie); - - if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) { - list_del(&w->entry); - kfree(death); - binder_stats_deleted(BINDER_STAT_DEATH); - } else - list_move(&w->entry, &proc->delivered_death); - if (cmd == BR_DEAD_BINDER) - goto done; /* DEAD_BINDER notifications can cause transactions */ - } break; - } - - if (!t) - continue; - - BUG_ON(t->buffer == NULL); - if (t->buffer->target_node) { - struct binder_node *target_node = t->buffer->target_node; - - tr.target.ptr = target_node->ptr; - tr.cookie = target_node->cookie; - t->saved_priority = task_nice(current); - if (t->priority < target_node->min_priority && - !(t->flags & TF_ONE_WAY)) - binder_set_nice(t->priority); - else if (!(t->flags & TF_ONE_WAY) || - t->saved_priority > target_node->min_priority) - binder_set_nice(target_node->min_priority); - cmd = BR_TRANSACTION; - } else { - tr.target.ptr = 0; - tr.cookie = 0; - cmd = BR_REPLY; - } - tr.code = t->code; - tr.flags = t->flags; - tr.sender_euid = from_kuid(current_user_ns(), t->sender_euid); - - if (t->from) { - struct task_struct *sender = t->from->proc->tsk; - - tr.sender_pid = task_tgid_nr_ns(sender, - task_active_pid_ns(current)); - } else { - tr.sender_pid = 0; - } - - tr.data_size = t->buffer->data_size; - tr.offsets_size = t->buffer->offsets_size; - 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 *)); - - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (copy_to_user(ptr, &tr, sizeof(tr))) - return -EFAULT; - ptr += sizeof(tr); - - 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 %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, - (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets); - - list_del(&t->work.entry); - t->buffer->allow_user_free = 1; - if (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) { - t->to_parent = thread->transaction_stack; - t->to_thread = thread; - thread->transaction_stack = t; - } else { - t->buffer->transaction = NULL; - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); - } - break; - } - -done: - - *consumed = ptr - buffer; - if (proc->requested_threads + proc->ready_threads == 0 && - proc->requested_threads_started < proc->max_threads && - (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | - BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */ - /*spawn a new thread if we leave this out */) { - proc->requested_threads++; - binder_debug(BINDER_DEBUG_THREADS, - "%d:%d BR_SPAWN_LOOPER\n", - proc->pid, thread->pid); - if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer)) - return -EFAULT; - binder_stat_br(proc, thread, BR_SPAWN_LOOPER); - } - return 0; -} - -static void binder_release_work(struct list_head *list) -{ - struct binder_work *w; - - while (!list_empty(list)) { - w = list_first_entry(list, struct binder_work, entry); - list_del_init(&w->entry); - switch (w->type) { - case BINDER_WORK_TRANSACTION: { - struct binder_transaction *t; - - t = container_of(w, struct binder_transaction, work); - if (t->buffer->target_node && - !(t->flags & TF_ONE_WAY)) { - binder_send_failed_reply(t, BR_DEAD_REPLY); - } else { - binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, - "undelivered transaction %d\n", - t->debug_id); - t->buffer->transaction = NULL; - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); - } - } break; - case BINDER_WORK_TRANSACTION_COMPLETE: { - binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, - "undelivered TRANSACTION_COMPLETE\n"); - kfree(w); - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); - } break; - case BINDER_WORK_DEAD_BINDER_AND_CLEAR: - case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: { - struct binder_ref_death *death; - - death = container_of(w, struct binder_ref_death, work); - binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, - "undelivered death notification, %016llx\n", - (u64)death->cookie); - kfree(death); - binder_stats_deleted(BINDER_STAT_DEATH); - } break; - default: - pr_err("unexpected work type, %d, not freed\n", - w->type); - break; - } - } - -} - -static struct binder_thread *binder_get_thread(struct binder_proc *proc) -{ - struct binder_thread *thread = NULL; - struct rb_node *parent = NULL; - struct rb_node **p = &proc->threads.rb_node; - - while (*p) { - parent = *p; - thread = rb_entry(parent, struct binder_thread, rb_node); - - if (current->pid < thread->pid) - p = &(*p)->rb_left; - else if (current->pid > thread->pid) - p = &(*p)->rb_right; - else - break; - } - if (*p == NULL) { - thread = kzalloc(sizeof(*thread), GFP_KERNEL); - if (thread == NULL) - return NULL; - binder_stats_created(BINDER_STAT_THREAD); - thread->proc = proc; - thread->pid = current->pid; - init_waitqueue_head(&thread->wait); - INIT_LIST_HEAD(&thread->todo); - rb_link_node(&thread->rb_node, parent, p); - rb_insert_color(&thread->rb_node, &proc->threads); - thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; - thread->return_error = BR_OK; - thread->return_error2 = BR_OK; - } - return thread; -} - -static int binder_free_thread(struct binder_proc *proc, - struct binder_thread *thread) -{ - struct binder_transaction *t; - struct binder_transaction *send_reply = NULL; - int active_transactions = 0; - - rb_erase(&thread->rb_node, &proc->threads); - t = thread->transaction_stack; - if (t && t->to_thread == thread) - send_reply = t; - while (t) { - active_transactions++; - binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, - "release %d:%d transaction %d %s, still active\n", - proc->pid, thread->pid, - t->debug_id, - (t->to_thread == thread) ? "in" : "out"); - - if (t->to_thread == thread) { - t->to_proc = NULL; - t->to_thread = NULL; - if (t->buffer) { - t->buffer->transaction = NULL; - t->buffer = NULL; - } - t = t->to_parent; - } else if (t->from == thread) { - t->from = NULL; - t = t->from_parent; - } else - BUG(); - } - if (send_reply) - binder_send_failed_reply(send_reply, BR_DEAD_REPLY); - binder_release_work(&thread->todo); - kfree(thread); - binder_stats_deleted(BINDER_STAT_THREAD); - return active_transactions; -} - -static unsigned int binder_poll(struct file *filp, - struct poll_table_struct *wait) -{ - struct binder_proc *proc = filp->private_data; - struct binder_thread *thread = NULL; - int wait_for_proc_work; - - binder_lock(__func__); - - thread = binder_get_thread(proc); - - wait_for_proc_work = thread->transaction_stack == NULL && - list_empty(&thread->todo) && thread->return_error == BR_OK; - - binder_unlock(__func__); - - if (wait_for_proc_work) { - if (binder_has_proc_work(proc, thread)) - return POLLIN; - poll_wait(filp, &proc->wait, wait); - if (binder_has_proc_work(proc, thread)) - return POLLIN; - } else { - if (binder_has_thread_work(thread)) - return POLLIN; - poll_wait(filp, &thread->wait, wait); - if (binder_has_thread_work(thread)) - return POLLIN; - } - return 0; -} - -static int binder_ioctl_write_read(struct file *filp, - unsigned int cmd, unsigned long arg, - struct binder_thread *thread) -{ - int ret = 0; - struct binder_proc *proc = filp->private_data; - unsigned int size = _IOC_SIZE(cmd); - void __user *ubuf = (void __user *)arg; - struct binder_write_read bwr; - - if (size != sizeof(struct binder_write_read)) { - ret = -EINVAL; - goto out; - } - if (copy_from_user(&bwr, ubuf, sizeof(bwr))) { - ret = -EFAULT; - goto out; - } - binder_debug(BINDER_DEBUG_READ_WRITE, - "%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, - bwr.write_buffer, - bwr.write_size, - &bwr.write_consumed); - trace_binder_write_done(ret); - if (ret < 0) { - bwr.read_consumed = 0; - if (copy_to_user(ubuf, &bwr, sizeof(bwr))) - ret = -EFAULT; - goto out; - } - } - if (bwr.read_size > 0) { - 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); - if (ret < 0) { - if (copy_to_user(ubuf, &bwr, sizeof(bwr))) - ret = -EFAULT; - goto out; - } - } - binder_debug(BINDER_DEBUG_READ_WRITE, - "%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 out; - } -out: - return ret; -} - -static int binder_ioctl_set_ctx_mgr(struct file *filp) -{ - int ret = 0; - struct binder_proc *proc = filp->private_data; - kuid_t curr_euid = current_euid(); - - if (binder_context_mgr_node != NULL) { - pr_err("BINDER_SET_CONTEXT_MGR already set\n"); - ret = -EBUSY; - goto out; - } - if (uid_valid(binder_context_mgr_uid)) { - if (!uid_eq(binder_context_mgr_uid, curr_euid)) { - pr_err("BINDER_SET_CONTEXT_MGR bad uid %d != %d\n", - from_kuid(&init_user_ns, curr_euid), - from_kuid(&init_user_ns, - binder_context_mgr_uid)); - ret = -EPERM; - goto out; - } - } else { - binder_context_mgr_uid = curr_euid; - } - binder_context_mgr_node = binder_new_node(proc, 0, 0); - if (binder_context_mgr_node == NULL) { - ret = -ENOMEM; - goto out; - } - binder_context_mgr_node->local_weak_refs++; - binder_context_mgr_node->local_strong_refs++; - binder_context_mgr_node->has_strong_ref = 1; - binder_context_mgr_node->has_weak_ref = 1; -out: - return ret; -} - -static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - int ret; - struct binder_proc *proc = filp->private_data; - struct binder_thread *thread; - unsigned int size = _IOC_SIZE(cmd); - void __user *ubuf = (void __user *)arg; - - /*pr_info("binder_ioctl: %d:%d %x %lx\n", - proc->pid, current->pid, cmd, arg);*/ - - trace_binder_ioctl(cmd, arg); - - ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); - if (ret) - goto err_unlocked; - - binder_lock(__func__); - thread = binder_get_thread(proc); - if (thread == NULL) { - ret = -ENOMEM; - goto err; - } - - switch (cmd) { - case BINDER_WRITE_READ: - ret = binder_ioctl_write_read(filp, cmd, arg, thread); - if (ret) - goto err; - break; - case BINDER_SET_MAX_THREADS: - if (copy_from_user(&proc->max_threads, ubuf, sizeof(proc->max_threads))) { - ret = -EINVAL; - goto err; - } - break; - case BINDER_SET_CONTEXT_MGR: - ret = binder_ioctl_set_ctx_mgr(filp); - if (ret) - goto err; - break; - case BINDER_THREAD_EXIT: - binder_debug(BINDER_DEBUG_THREADS, "%d:%d exit\n", - proc->pid, thread->pid); - binder_free_thread(proc, thread); - thread = NULL; - break; - case BINDER_VERSION: { - struct binder_version __user *ver = ubuf; - - if (size != sizeof(struct binder_version)) { - ret = -EINVAL; - goto err; - } - if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, - &ver->protocol_version)) { - ret = -EINVAL; - goto err; - } - break; - } - default: - ret = -EINVAL; - goto err; - } - ret = 0; -err: - if (thread) - thread->looper &= ~BINDER_LOOPER_STATE_NEED_RETURN; - binder_unlock(__func__); - wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); - if (ret && ret != -ERESTARTSYS) - pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); -err_unlocked: - trace_binder_ioctl_done(ret); - return ret; -} - -static void binder_vma_open(struct vm_area_struct *vma) -{ - struct binder_proc *proc = vma->vm_private_data; - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "%d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); -} - -static void binder_vma_close(struct vm_area_struct *vma) -{ - struct binder_proc *proc = vma->vm_private_data; - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "%d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); - proc->vma = NULL; - proc->vma_vm_mm = NULL; - binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES); -} - -static int binder_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) -{ - return VM_FAULT_SIGBUS; -} - -static struct vm_operations_struct binder_vm_ops = { - .open = binder_vma_open, - .close = binder_vma_close, - .fault = binder_vm_fault, -}; - -static int binder_mmap(struct file *filp, struct vm_area_struct *vma) -{ - int ret; - struct vm_struct *area; - struct binder_proc *proc = filp->private_data; - const char *failure_string; - struct binder_buffer *buffer; - - if (proc->tsk != current) - return -EINVAL; - - if ((vma->vm_end - vma->vm_start) > SZ_4M) - vma->vm_end = vma->vm_start + SZ_4M; - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); - - if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) { - ret = -EPERM; - failure_string = "bad vm_flags"; - goto err_bad_arg; - } - vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE; - - mutex_lock(&binder_mmap_lock); - if (proc->buffer) { - ret = -EBUSY; - failure_string = "already mapped"; - goto err_already_mapped; - } - - area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP); - if (area == NULL) { - ret = -ENOMEM; - failure_string = "get_vm_area"; - goto err_get_vm_area_failed; - } - proc->buffer = area->addr; - proc->user_buffer_offset = vma->vm_start - (uintptr_t)proc->buffer; - mutex_unlock(&binder_mmap_lock); - -#ifdef CONFIG_CPU_CACHE_VIPT - if (cache_is_vipt_aliasing()) { - while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) { - pr_info("binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer); - vma->vm_start += PAGE_SIZE; - } - } -#endif - proc->pages = kzalloc(sizeof(proc->pages[0]) * ((vma->vm_end - vma->vm_start) / PAGE_SIZE), GFP_KERNEL); - if (proc->pages == NULL) { - ret = -ENOMEM; - failure_string = "alloc page array"; - goto err_alloc_pages_failed; - } - proc->buffer_size = vma->vm_end - vma->vm_start; - - vma->vm_ops = &binder_vm_ops; - vma->vm_private_data = proc; - - if (binder_update_page_range(proc, 1, proc->buffer, proc->buffer + PAGE_SIZE, vma)) { - ret = -ENOMEM; - failure_string = "alloc small buf"; - goto err_alloc_small_buf_failed; - } - buffer = proc->buffer; - INIT_LIST_HEAD(&proc->buffers); - list_add(&buffer->entry, &proc->buffers); - buffer->free = 1; - binder_insert_free_buffer(proc, buffer); - proc->free_async_space = proc->buffer_size / 2; - barrier(); - proc->files = get_files_struct(current); - proc->vma = vma; - proc->vma_vm_mm = vma->vm_mm; - - /*pr_info("binder_mmap: %d %lx-%lx maps %p\n", - proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/ - return 0; - -err_alloc_small_buf_failed: - kfree(proc->pages); - proc->pages = NULL; -err_alloc_pages_failed: - mutex_lock(&binder_mmap_lock); - vfree(proc->buffer); - proc->buffer = NULL; -err_get_vm_area_failed: -err_already_mapped: - mutex_unlock(&binder_mmap_lock); -err_bad_arg: - pr_err("binder_mmap: %d %lx-%lx %s failed %d\n", - proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); - return ret; -} - -static int binder_open(struct inode *nodp, struct file *filp) -{ - struct binder_proc *proc; - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n", - current->group_leader->pid, current->pid); - - proc = kzalloc(sizeof(*proc), GFP_KERNEL); - if (proc == NULL) - return -ENOMEM; - get_task_struct(current); - proc->tsk = current; - INIT_LIST_HEAD(&proc->todo); - init_waitqueue_head(&proc->wait); - proc->default_priority = task_nice(current); - - binder_lock(__func__); - - binder_stats_created(BINDER_STAT_PROC); - hlist_add_head(&proc->proc_node, &binder_procs); - proc->pid = current->group_leader->pid; - INIT_LIST_HEAD(&proc->delivered_death); - filp->private_data = proc; - - binder_unlock(__func__); - - if (binder_debugfs_dir_entry_proc) { - char strbuf[11]; - - snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); - proc->debugfs_entry = debugfs_create_file(strbuf, S_IRUGO, - binder_debugfs_dir_entry_proc, proc, &binder_proc_fops); - } - - return 0; -} - -static int binder_flush(struct file *filp, fl_owner_t id) -{ - struct binder_proc *proc = filp->private_data; - - binder_defer_work(proc, BINDER_DEFERRED_FLUSH); - - return 0; -} - -static void binder_deferred_flush(struct binder_proc *proc) -{ - struct rb_node *n; - int wake_count = 0; - - for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { - struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); - - thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; - if (thread->looper & BINDER_LOOPER_STATE_WAITING) { - wake_up_interruptible(&thread->wait); - wake_count++; - } - } - wake_up_interruptible_all(&proc->wait); - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder_flush: %d woke %d threads\n", proc->pid, - wake_count); -} - -static int binder_release(struct inode *nodp, struct file *filp) -{ - struct binder_proc *proc = filp->private_data; - - debugfs_remove(proc->debugfs_entry); - binder_defer_work(proc, BINDER_DEFERRED_RELEASE); - - return 0; -} - -static int binder_node_release(struct binder_node *node, int refs) -{ - struct binder_ref *ref; - int death = 0; - - list_del_init(&node->work.entry); - binder_release_work(&node->async_todo); - - if (hlist_empty(&node->refs)) { - kfree(node); - binder_stats_deleted(BINDER_STAT_NODE); - - return refs; - } - - node->proc = NULL; - node->local_strong_refs = 0; - node->local_weak_refs = 0; - hlist_add_head(&node->dead_node, &binder_dead_nodes); - - hlist_for_each_entry(ref, &node->refs, node_entry) { - refs++; - - if (!ref->death) - continue; - - death++; - - if (list_empty(&ref->death->work.entry)) { - ref->death->work.type = BINDER_WORK_DEAD_BINDER; - list_add_tail(&ref->death->work.entry, - &ref->proc->todo); - wake_up_interruptible(&ref->proc->wait); - } else - BUG(); - } - - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "node %d now dead, refs %d, death %d\n", - node->debug_id, refs, death); - - return refs; -} - -static void binder_deferred_release(struct binder_proc *proc) -{ - struct binder_transaction *t; - struct rb_node *n; - int threads, nodes, incoming_refs, outgoing_refs, buffers, - active_transactions, page_count; - - BUG_ON(proc->vma); - BUG_ON(proc->files); - - hlist_del(&proc->proc_node); - - if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) { - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "%s: %d context_mgr_node gone\n", - __func__, proc->pid); - binder_context_mgr_node = NULL; - } - - threads = 0; - active_transactions = 0; - while ((n = rb_first(&proc->threads))) { - struct binder_thread *thread; - - thread = rb_entry(n, struct binder_thread, rb_node); - threads++; - active_transactions += binder_free_thread(proc, thread); - } - - nodes = 0; - incoming_refs = 0; - while ((n = rb_first(&proc->nodes))) { - struct binder_node *node; - - node = rb_entry(n, struct binder_node, rb_node); - nodes++; - rb_erase(&node->rb_node, &proc->nodes); - incoming_refs = binder_node_release(node, incoming_refs); - } - - outgoing_refs = 0; - while ((n = rb_first(&proc->refs_by_desc))) { - struct binder_ref *ref; - - ref = rb_entry(n, struct binder_ref, rb_node_desc); - outgoing_refs++; - binder_delete_ref(ref); - } - - binder_release_work(&proc->todo); - binder_release_work(&proc->delivered_death); - - buffers = 0; - while ((n = rb_first(&proc->allocated_buffers))) { - struct binder_buffer *buffer; - - buffer = rb_entry(n, struct binder_buffer, rb_node); - - t = buffer->transaction; - if (t) { - t->buffer = NULL; - buffer->transaction = NULL; - pr_err("release proc %d, transaction %d, not freed\n", - proc->pid, t->debug_id); - /*BUG();*/ - } - - binder_free_buf(proc, buffer); - buffers++; - } - - binder_stats_deleted(BINDER_STAT_PROC); - - page_count = 0; - if (proc->pages) { - int i; - - for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) { - void *page_addr; - - if (!proc->pages[i]) - continue; - - page_addr = proc->buffer + i * PAGE_SIZE; - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "%s: %d: page %d at %p not freed\n", - __func__, proc->pid, i, page_addr); - unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE); - __free_page(proc->pages[i]); - page_count++; - } - kfree(proc->pages); - vfree(proc->buffer); - } - - put_task_struct(proc->tsk); - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "%s: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n", - __func__, proc->pid, threads, nodes, incoming_refs, - outgoing_refs, active_transactions, buffers, page_count); - - kfree(proc); -} - -static void binder_deferred_func(struct work_struct *work) -{ - struct binder_proc *proc; - struct files_struct *files; - - int defer; - - do { - binder_lock(__func__); - mutex_lock(&binder_deferred_lock); - if (!hlist_empty(&binder_deferred_list)) { - proc = hlist_entry(binder_deferred_list.first, - struct binder_proc, deferred_work_node); - hlist_del_init(&proc->deferred_work_node); - defer = proc->deferred_work; - proc->deferred_work = 0; - } else { - proc = NULL; - defer = 0; - } - mutex_unlock(&binder_deferred_lock); - - files = NULL; - if (defer & BINDER_DEFERRED_PUT_FILES) { - files = proc->files; - if (files) - proc->files = NULL; - } - - if (defer & BINDER_DEFERRED_FLUSH) - binder_deferred_flush(proc); - - if (defer & BINDER_DEFERRED_RELEASE) - binder_deferred_release(proc); /* frees proc */ - - binder_unlock(__func__); - if (files) - put_files_struct(files); - } while (proc); -} -static DECLARE_WORK(binder_deferred_work, binder_deferred_func); - -static void -binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) -{ - mutex_lock(&binder_deferred_lock); - proc->deferred_work |= defer; - if (hlist_unhashed(&proc->deferred_work_node)) { - hlist_add_head(&proc->deferred_work_node, - &binder_deferred_list); - queue_work(binder_deferred_workqueue, &binder_deferred_work); - } - mutex_unlock(&binder_deferred_lock); -} - -static void print_binder_transaction(struct seq_file *m, const char *prefix, - struct binder_transaction *t) -{ - seq_printf(m, - "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d", - prefix, t->debug_id, t, - t->from ? t->from->proc->pid : 0, - t->from ? t->from->pid : 0, - t->to_proc ? t->to_proc->pid : 0, - t->to_thread ? t->to_thread->pid : 0, - t->code, t->flags, t->priority, t->need_reply); - if (t->buffer == NULL) { - seq_puts(m, " buffer free\n"); - return; - } - if (t->buffer->target_node) - seq_printf(m, " node %d", - t->buffer->target_node->debug_id); - seq_printf(m, " size %zd:%zd data %p\n", - t->buffer->data_size, t->buffer->offsets_size, - t->buffer->data); -} - -static void print_binder_buffer(struct seq_file *m, const char *prefix, - struct binder_buffer *buffer) -{ - seq_printf(m, "%s %d: %p size %zd:%zd %s\n", - prefix, buffer->debug_id, buffer->data, - buffer->data_size, buffer->offsets_size, - buffer->transaction ? "active" : "delivered"); -} - -static void print_binder_work(struct seq_file *m, const char *prefix, - const char *transaction_prefix, - struct binder_work *w) -{ - struct binder_node *node; - struct binder_transaction *t; - - switch (w->type) { - case BINDER_WORK_TRANSACTION: - t = container_of(w, struct binder_transaction, work); - print_binder_transaction(m, transaction_prefix, t); - break; - case BINDER_WORK_TRANSACTION_COMPLETE: - seq_printf(m, "%stransaction complete\n", prefix); - break; - case BINDER_WORK_NODE: - node = container_of(w, struct binder_node, work); - 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); - break; - case BINDER_WORK_DEAD_BINDER_AND_CLEAR: - seq_printf(m, "%shas cleared dead binder\n", prefix); - break; - case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: - seq_printf(m, "%shas cleared death notification\n", prefix); - break; - default: - seq_printf(m, "%sunknown work: type %d\n", prefix, w->type); - break; - } -} - -static void print_binder_thread(struct seq_file *m, - struct binder_thread *thread, - int print_always) -{ - struct binder_transaction *t; - struct binder_work *w; - size_t start_pos = m->count; - size_t header_pos; - - seq_printf(m, " thread %d: l %02x\n", thread->pid, thread->looper); - header_pos = m->count; - t = thread->transaction_stack; - while (t) { - if (t->from == thread) { - print_binder_transaction(m, - " outgoing transaction", t); - t = t->from_parent; - } else if (t->to_thread == thread) { - print_binder_transaction(m, - " incoming transaction", t); - t = t->to_parent; - } else { - print_binder_transaction(m, " bad transaction", t); - t = NULL; - } - } - list_for_each_entry(w, &thread->todo, entry) { - print_binder_work(m, " ", " pending transaction", w); - } - if (!print_always && m->count == header_pos) - m->count = start_pos; -} - -static void print_binder_node(struct seq_file *m, struct binder_node *node) -{ - struct binder_ref *ref; - struct binder_work *w; - int count; - - count = 0; - hlist_for_each_entry(ref, &node->refs, node_entry) - count++; - - 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); - if (count) { - seq_puts(m, " proc"); - hlist_for_each_entry(ref, &node->refs, node_entry) - seq_printf(m, " %d", ref->proc->pid); - } - seq_puts(m, "\n"); - list_for_each_entry(w, &node->async_todo, entry) - print_binder_work(m, " ", - " pending async transaction", w); -} - -static void print_binder_ref(struct seq_file *m, struct binder_ref *ref) -{ - seq_printf(m, " ref %d: desc %d %snode %d s %d w %d d %p\n", - ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ", - ref->node->debug_id, ref->strong, ref->weak, ref->death); -} - -static void print_binder_proc(struct seq_file *m, - struct binder_proc *proc, int print_all) -{ - struct binder_work *w; - struct rb_node *n; - size_t start_pos = m->count; - size_t header_pos; - - seq_printf(m, "proc %d\n", proc->pid); - header_pos = m->count; - - for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) - print_binder_thread(m, rb_entry(n, struct binder_thread, - rb_node), print_all); - for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { - struct binder_node *node = rb_entry(n, struct binder_node, - rb_node); - if (print_all || node->has_async_transaction) - print_binder_node(m, node); - } - if (print_all) { - for (n = rb_first(&proc->refs_by_desc); - n != NULL; - n = rb_next(n)) - print_binder_ref(m, rb_entry(n, struct binder_ref, - rb_node_desc)); - } - for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n)) - print_binder_buffer(m, " buffer", - rb_entry(n, struct binder_buffer, rb_node)); - list_for_each_entry(w, &proc->todo, entry) - print_binder_work(m, " ", " pending transaction", w); - list_for_each_entry(w, &proc->delivered_death, entry) { - seq_puts(m, " has delivered dead binder\n"); - break; - } - if (!print_all && m->count == header_pos) - m->count = start_pos; -} - -static const char * const binder_return_strings[] = { - "BR_ERROR", - "BR_OK", - "BR_TRANSACTION", - "BR_REPLY", - "BR_ACQUIRE_RESULT", - "BR_DEAD_REPLY", - "BR_TRANSACTION_COMPLETE", - "BR_INCREFS", - "BR_ACQUIRE", - "BR_RELEASE", - "BR_DECREFS", - "BR_ATTEMPT_ACQUIRE", - "BR_NOOP", - "BR_SPAWN_LOOPER", - "BR_FINISHED", - "BR_DEAD_BINDER", - "BR_CLEAR_DEATH_NOTIFICATION_DONE", - "BR_FAILED_REPLY" -}; - -static const char * const binder_command_strings[] = { - "BC_TRANSACTION", - "BC_REPLY", - "BC_ACQUIRE_RESULT", - "BC_FREE_BUFFER", - "BC_INCREFS", - "BC_ACQUIRE", - "BC_RELEASE", - "BC_DECREFS", - "BC_INCREFS_DONE", - "BC_ACQUIRE_DONE", - "BC_ATTEMPT_ACQUIRE", - "BC_REGISTER_LOOPER", - "BC_ENTER_LOOPER", - "BC_EXIT_LOOPER", - "BC_REQUEST_DEATH_NOTIFICATION", - "BC_CLEAR_DEATH_NOTIFICATION", - "BC_DEAD_BINDER_DONE" -}; - -static const char * const binder_objstat_strings[] = { - "proc", - "thread", - "node", - "ref", - "death", - "transaction", - "transaction_complete" -}; - -static void print_binder_stats(struct seq_file *m, const char *prefix, - struct binder_stats *stats) -{ - int i; - - BUILD_BUG_ON(ARRAY_SIZE(stats->bc) != - ARRAY_SIZE(binder_command_strings)); - for (i = 0; i < ARRAY_SIZE(stats->bc); i++) { - if (stats->bc[i]) - seq_printf(m, "%s%s: %d\n", prefix, - binder_command_strings[i], stats->bc[i]); - } - - BUILD_BUG_ON(ARRAY_SIZE(stats->br) != - ARRAY_SIZE(binder_return_strings)); - for (i = 0; i < ARRAY_SIZE(stats->br); i++) { - if (stats->br[i]) - seq_printf(m, "%s%s: %d\n", prefix, - binder_return_strings[i], stats->br[i]); - } - - BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != - ARRAY_SIZE(binder_objstat_strings)); - BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != - ARRAY_SIZE(stats->obj_deleted)); - for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) { - if (stats->obj_created[i] || stats->obj_deleted[i]) - seq_printf(m, "%s%s: active %d total %d\n", prefix, - binder_objstat_strings[i], - stats->obj_created[i] - stats->obj_deleted[i], - stats->obj_created[i]); - } -} - -static void print_binder_proc_stats(struct seq_file *m, - struct binder_proc *proc) -{ - struct binder_work *w; - struct rb_node *n; - int count, strong, weak; - - seq_printf(m, "proc %d\n", proc->pid); - count = 0; - for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) - count++; - seq_printf(m, " threads: %d\n", count); - seq_printf(m, " requested threads: %d+%d/%d\n" - " ready threads %d\n" - " free async space %zd\n", proc->requested_threads, - proc->requested_threads_started, proc->max_threads, - proc->ready_threads, proc->free_async_space); - count = 0; - for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) - count++; - seq_printf(m, " nodes: %d\n", count); - count = 0; - strong = 0; - weak = 0; - for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { - struct binder_ref *ref = rb_entry(n, struct binder_ref, - rb_node_desc); - count++; - strong += ref->strong; - weak += ref->weak; - } - seq_printf(m, " refs: %d s %d w %d\n", count, strong, weak); - - count = 0; - for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n)) - count++; - seq_printf(m, " buffers: %d\n", count); - - count = 0; - list_for_each_entry(w, &proc->todo, entry) { - switch (w->type) { - case BINDER_WORK_TRANSACTION: - count++; - break; - default: - break; - } - } - seq_printf(m, " pending transactions: %d\n", count); - - print_binder_stats(m, " ", &proc->stats); -} - - -static int binder_state_show(struct seq_file *m, void *unused) -{ - struct binder_proc *proc; - struct binder_node *node; - int do_lock = !binder_debug_no_lock; - - if (do_lock) - binder_lock(__func__); - - seq_puts(m, "binder state:\n"); - - if (!hlist_empty(&binder_dead_nodes)) - seq_puts(m, "dead nodes:\n"); - hlist_for_each_entry(node, &binder_dead_nodes, dead_node) - print_binder_node(m, node); - - hlist_for_each_entry(proc, &binder_procs, proc_node) - print_binder_proc(m, proc, 1); - if (do_lock) - binder_unlock(__func__); - return 0; -} - -static int binder_stats_show(struct seq_file *m, void *unused) -{ - struct binder_proc *proc; - int do_lock = !binder_debug_no_lock; - - if (do_lock) - binder_lock(__func__); - - seq_puts(m, "binder stats:\n"); - - print_binder_stats(m, "", &binder_stats); - - hlist_for_each_entry(proc, &binder_procs, proc_node) - print_binder_proc_stats(m, proc); - if (do_lock) - binder_unlock(__func__); - return 0; -} - -static int binder_transactions_show(struct seq_file *m, void *unused) -{ - struct binder_proc *proc; - int do_lock = !binder_debug_no_lock; - - if (do_lock) - binder_lock(__func__); - - seq_puts(m, "binder transactions:\n"); - hlist_for_each_entry(proc, &binder_procs, proc_node) - print_binder_proc(m, proc, 0); - if (do_lock) - binder_unlock(__func__); - return 0; -} - -static int binder_proc_show(struct seq_file *m, void *unused) -{ - struct binder_proc *proc = m->private; - int do_lock = !binder_debug_no_lock; - - if (do_lock) - binder_lock(__func__); - seq_puts(m, "binder proc state:\n"); - print_binder_proc(m, proc, 1); - if (do_lock) - binder_unlock(__func__); - return 0; -} - -static void print_binder_transaction_log_entry(struct seq_file *m, - struct binder_transaction_log_entry *e) -{ - seq_printf(m, - "%d: %s from %d:%d to %d:%d node %d handle %d size %d:%d\n", - e->debug_id, (e->call_type == 2) ? "reply" : - ((e->call_type == 1) ? "async" : "call "), e->from_proc, - e->from_thread, e->to_proc, e->to_thread, e->to_node, - e->target_handle, e->data_size, e->offsets_size); -} - -static int binder_transaction_log_show(struct seq_file *m, void *unused) -{ - struct binder_transaction_log *log = m->private; - int i; - - if (log->full) { - for (i = log->next; i < ARRAY_SIZE(log->entry); i++) - print_binder_transaction_log_entry(m, &log->entry[i]); - } - for (i = 0; i < log->next; i++) - print_binder_transaction_log_entry(m, &log->entry[i]); - return 0; -} - -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, - .release = binder_release, -}; - -static struct miscdevice binder_miscdev = { - .minor = MISC_DYNAMIC_MINOR, - .name = "binder", - .fops = &binder_fops -}; - -BINDER_DEBUG_ENTRY(state); -BINDER_DEBUG_ENTRY(stats); -BINDER_DEBUG_ENTRY(transactions); -BINDER_DEBUG_ENTRY(transaction_log); - -static int __init binder_init(void) -{ - int ret; - - binder_deferred_workqueue = create_singlethread_workqueue("binder"); - if (!binder_deferred_workqueue) - return -ENOMEM; - - binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL); - if (binder_debugfs_dir_entry_root) - binder_debugfs_dir_entry_proc = debugfs_create_dir("proc", - binder_debugfs_dir_entry_root); - ret = misc_register(&binder_miscdev); - if (binder_debugfs_dir_entry_root) { - debugfs_create_file("state", - S_IRUGO, - binder_debugfs_dir_entry_root, - NULL, - &binder_state_fops); - debugfs_create_file("stats", - S_IRUGO, - binder_debugfs_dir_entry_root, - NULL, - &binder_stats_fops); - debugfs_create_file("transactions", - S_IRUGO, - binder_debugfs_dir_entry_root, - NULL, - &binder_transactions_fops); - debugfs_create_file("transaction_log", - S_IRUGO, - binder_debugfs_dir_entry_root, - &binder_transaction_log, - &binder_transaction_log_fops); - debugfs_create_file("failed_transaction_log", - S_IRUGO, - binder_debugfs_dir_entry_root, - &binder_transaction_log_failed, - &binder_transaction_log_fops); - } - return ret; -} - -device_initcall(binder_init); - -#define CREATE_TRACE_POINTS -#include "binder_trace.h" - -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h deleted file mode 100644 index eb0834656dfe..000000000000 --- a/drivers/staging/android/binder.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 _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 deleted file mode 100644 index 7f20f3dc8369..000000000000 --- a/drivers/staging/android/binder_trace.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - * 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. - * - */ - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM binder - -#if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) -#define _BINDER_TRACE_H - -#include - -struct binder_buffer; -struct binder_node; -struct binder_proc; -struct binder_ref; -struct binder_thread; -struct binder_transaction; - -TRACE_EVENT(binder_ioctl, - TP_PROTO(unsigned int cmd, unsigned long arg), - TP_ARGS(cmd, arg), - - TP_STRUCT__entry( - __field(unsigned int, cmd) - __field(unsigned long, arg) - ), - TP_fast_assign( - __entry->cmd = cmd; - __entry->arg = arg; - ), - TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg) -); - -DECLARE_EVENT_CLASS(binder_lock_class, - TP_PROTO(const char *tag), - TP_ARGS(tag), - TP_STRUCT__entry( - __field(const char *, tag) - ), - TP_fast_assign( - __entry->tag = tag; - ), - TP_printk("tag=%s", __entry->tag) -); - -#define DEFINE_BINDER_LOCK_EVENT(name) \ -DEFINE_EVENT(binder_lock_class, name, \ - TP_PROTO(const char *func), \ - TP_ARGS(func)) - -DEFINE_BINDER_LOCK_EVENT(binder_lock); -DEFINE_BINDER_LOCK_EVENT(binder_locked); -DEFINE_BINDER_LOCK_EVENT(binder_unlock); - -DECLARE_EVENT_CLASS(binder_function_return_class, - TP_PROTO(int ret), - TP_ARGS(ret), - TP_STRUCT__entry( - __field(int, ret) - ), - TP_fast_assign( - __entry->ret = ret; - ), - TP_printk("ret=%d", __entry->ret) -); - -#define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \ -DEFINE_EVENT(binder_function_return_class, name, \ - TP_PROTO(int ret), \ - TP_ARGS(ret)) - -DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done); -DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done); -DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done); - -TRACE_EVENT(binder_wait_for_work, - TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), - TP_ARGS(proc_work, transaction_stack, thread_todo), - - TP_STRUCT__entry( - __field(bool, proc_work) - __field(bool, transaction_stack) - __field(bool, thread_todo) - ), - TP_fast_assign( - __entry->proc_work = proc_work; - __entry->transaction_stack = transaction_stack; - __entry->thread_todo = thread_todo; - ), - TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d", - __entry->proc_work, __entry->transaction_stack, - __entry->thread_todo) -); - -TRACE_EVENT(binder_transaction, - TP_PROTO(bool reply, struct binder_transaction *t, - struct binder_node *target_node), - TP_ARGS(reply, t, target_node), - TP_STRUCT__entry( - __field(int, debug_id) - __field(int, target_node) - __field(int, to_proc) - __field(int, to_thread) - __field(int, reply) - __field(unsigned int, code) - __field(unsigned int, flags) - ), - TP_fast_assign( - __entry->debug_id = t->debug_id; - __entry->target_node = target_node ? target_node->debug_id : 0; - __entry->to_proc = t->to_proc->pid; - __entry->to_thread = t->to_thread ? t->to_thread->pid : 0; - __entry->reply = reply; - __entry->code = t->code; - __entry->flags = t->flags; - ), - TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x", - __entry->debug_id, __entry->target_node, - __entry->to_proc, __entry->to_thread, - __entry->reply, __entry->flags, __entry->code) -); - -TRACE_EVENT(binder_transaction_received, - TP_PROTO(struct binder_transaction *t), - TP_ARGS(t), - - TP_STRUCT__entry( - __field(int, debug_id) - ), - TP_fast_assign( - __entry->debug_id = t->debug_id; - ), - TP_printk("transaction=%d", __entry->debug_id) -); - -TRACE_EVENT(binder_transaction_node_to_ref, - TP_PROTO(struct binder_transaction *t, struct binder_node *node, - struct binder_ref *ref), - TP_ARGS(t, node, ref), - - TP_STRUCT__entry( - __field(int, debug_id) - __field(int, node_debug_id) - __field(binder_uintptr_t, node_ptr) - __field(int, ref_debug_id) - __field(uint32_t, ref_desc) - ), - TP_fast_assign( - __entry->debug_id = t->debug_id; - __entry->node_debug_id = node->debug_id; - __entry->node_ptr = node->ptr; - __entry->ref_debug_id = ref->debug_id; - __entry->ref_desc = ref->desc; - ), - 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) -); - -TRACE_EVENT(binder_transaction_ref_to_node, - TP_PROTO(struct binder_transaction *t, struct binder_ref *ref), - TP_ARGS(t, ref), - - TP_STRUCT__entry( - __field(int, debug_id) - __field(int, ref_debug_id) - __field(uint32_t, ref_desc) - __field(int, node_debug_id) - __field(binder_uintptr_t, node_ptr) - ), - TP_fast_assign( - __entry->debug_id = t->debug_id; - __entry->ref_debug_id = ref->debug_id; - __entry->ref_desc = ref->desc; - __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%016llx", - __entry->debug_id, __entry->node_debug_id, - __entry->ref_debug_id, __entry->ref_desc, - (u64)__entry->node_ptr) -); - -TRACE_EVENT(binder_transaction_ref_to_ref, - TP_PROTO(struct binder_transaction *t, struct binder_ref *src_ref, - struct binder_ref *dest_ref), - TP_ARGS(t, src_ref, dest_ref), - - TP_STRUCT__entry( - __field(int, debug_id) - __field(int, node_debug_id) - __field(int, src_ref_debug_id) - __field(uint32_t, src_ref_desc) - __field(int, dest_ref_debug_id) - __field(uint32_t, dest_ref_desc) - ), - TP_fast_assign( - __entry->debug_id = t->debug_id; - __entry->node_debug_id = src_ref->node->debug_id; - __entry->src_ref_debug_id = src_ref->debug_id; - __entry->src_ref_desc = src_ref->desc; - __entry->dest_ref_debug_id = dest_ref->debug_id; - __entry->dest_ref_desc = dest_ref->desc; - ), - TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d", - __entry->debug_id, __entry->node_debug_id, - __entry->src_ref_debug_id, __entry->src_ref_desc, - __entry->dest_ref_debug_id, __entry->dest_ref_desc) -); - -TRACE_EVENT(binder_transaction_fd, - TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd), - TP_ARGS(t, src_fd, dest_fd), - - TP_STRUCT__entry( - __field(int, debug_id) - __field(int, src_fd) - __field(int, dest_fd) - ), - TP_fast_assign( - __entry->debug_id = t->debug_id; - __entry->src_fd = src_fd; - __entry->dest_fd = dest_fd; - ), - TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d", - __entry->debug_id, __entry->src_fd, __entry->dest_fd) -); - -DECLARE_EVENT_CLASS(binder_buffer_class, - TP_PROTO(struct binder_buffer *buf), - TP_ARGS(buf), - TP_STRUCT__entry( - __field(int, debug_id) - __field(size_t, data_size) - __field(size_t, offsets_size) - ), - TP_fast_assign( - __entry->debug_id = buf->debug_id; - __entry->data_size = buf->data_size; - __entry->offsets_size = buf->offsets_size; - ), - TP_printk("transaction=%d data_size=%zd offsets_size=%zd", - __entry->debug_id, __entry->data_size, __entry->offsets_size) -); - -DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, - TP_PROTO(struct binder_buffer *buffer), - TP_ARGS(buffer)); - -DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, - TP_PROTO(struct binder_buffer *buffer), - TP_ARGS(buffer)); - -DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, - TP_PROTO(struct binder_buffer *buffer), - TP_ARGS(buffer)); - -TRACE_EVENT(binder_update_page_range, - TP_PROTO(struct binder_proc *proc, bool allocate, - void *start, void *end), - TP_ARGS(proc, allocate, start, end), - TP_STRUCT__entry( - __field(int, proc) - __field(bool, allocate) - __field(size_t, offset) - __field(size_t, size) - ), - TP_fast_assign( - __entry->proc = proc->pid; - __entry->allocate = allocate; - __entry->offset = start - proc->buffer; - __entry->size = end - start; - ), - TP_printk("proc=%d allocate=%d offset=%zu size=%zu", - __entry->proc, __entry->allocate, - __entry->offset, __entry->size) -); - -TRACE_EVENT(binder_command, - TP_PROTO(uint32_t cmd), - TP_ARGS(cmd), - TP_STRUCT__entry( - __field(uint32_t, cmd) - ), - TP_fast_assign( - __entry->cmd = cmd; - ), - TP_printk("cmd=0x%x %s", - __entry->cmd, - _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? - binder_command_strings[_IOC_NR(__entry->cmd)] : - "unknown") -); - -TRACE_EVENT(binder_return, - TP_PROTO(uint32_t cmd), - TP_ARGS(cmd), - TP_STRUCT__entry( - __field(uint32_t, cmd) - ), - TP_fast_assign( - __entry->cmd = cmd; - ), - TP_printk("cmd=0x%x %s", - __entry->cmd, - _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? - binder_return_strings[_IOC_NR(__entry->cmd)] : - "unknown") -); - -#endif /* _BINDER_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE binder_trace -#include diff --git a/drivers/staging/android/uapi/binder.h b/drivers/staging/android/uapi/binder.h deleted file mode 100644 index dba4cef3a8d3..000000000000 --- a/drivers/staging/android/uapi/binder.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * 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, -}; - -#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 - * 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 { - binder_uintptr_t binder; /* local object */ - __u32 handle; /* remote object */ - }; - - /* extra data associated with local object */ - binder_uintptr_t 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 { - 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. */ -struct binder_version { - /* driver protocol version -- increment with incompatible change */ - __s32 protocol_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) -#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 { - /* target descriptor of command transaction */ - __u32 handle; - /* target descriptor of return transaction */ - binder_uintptr_t ptr; - } target; - 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; - 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 - * the data buffer. - */ - union { - struct { - /* transaction data */ - binder_uintptr_t buffer; - /* offsets from buffer to flat_binder_object structs */ - binder_uintptr_t offsets; - } ptr; - __u8 buf[8]; - } data; -}; - -struct binder_ptr_cookie { - binder_uintptr_t ptr; - binder_uintptr_t cookie; -}; - -struct binder_handle_cookie { - __u32 handle; - binder_uintptr_t cookie; -} __packed; - -struct binder_pri_desc { - __s32 priority; - __u32 desc; -}; - -struct binder_pri_ptr_cookie { - __s32 priority; - binder_uintptr_t ptr; - binder_uintptr_t 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, binder_uintptr_t), - /* - * void *: cookie - */ - BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), - /* - * 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, binder_uintptr_t), - /* - * 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_handle_cookie), - /* - * int: handle - * void *: cookie - */ - - BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, - struct binder_handle_cookie), - /* - * int: handle - * void *: cookie - */ - - BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), - /* - * void *: cookie - */ -}; - -#endif /* _UAPI_LINUX_BINDER_H */ - diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index 6cad97485bad..5f17fa7bc153 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -1,4 +1,5 @@ # UAPI Header export list +header-y += android/ header-y += byteorder/ header-y += can/ header-y += caif/ diff --git a/include/uapi/linux/android/Kbuild b/include/uapi/linux/android/Kbuild new file mode 100644 index 000000000000..ca011eec252a --- /dev/null +++ b/include/uapi/linux/android/Kbuild @@ -0,0 +1,2 @@ +# UAPI Header export list +header-y += binder.h diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h new file mode 100644 index 000000000000..dba4cef3a8d3 --- /dev/null +++ b/include/uapi/linux/android/binder.h @@ -0,0 +1,351 @@ +/* + * 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, +}; + +#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 + * 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 { + binder_uintptr_t binder; /* local object */ + __u32 handle; /* remote object */ + }; + + /* extra data associated with local object */ + binder_uintptr_t 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 { + 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. */ +struct binder_version { + /* driver protocol version -- increment with incompatible change */ + __s32 protocol_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) +#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 { + /* target descriptor of command transaction */ + __u32 handle; + /* target descriptor of return transaction */ + binder_uintptr_t ptr; + } target; + 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; + 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 + * the data buffer. + */ + union { + struct { + /* transaction data */ + binder_uintptr_t buffer; + /* offsets from buffer to flat_binder_object structs */ + binder_uintptr_t offsets; + } ptr; + __u8 buf[8]; + } data; +}; + +struct binder_ptr_cookie { + binder_uintptr_t ptr; + binder_uintptr_t cookie; +}; + +struct binder_handle_cookie { + __u32 handle; + binder_uintptr_t cookie; +} __packed; + +struct binder_pri_desc { + __s32 priority; + __u32 desc; +}; + +struct binder_pri_ptr_cookie { + __s32 priority; + binder_uintptr_t ptr; + binder_uintptr_t 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, binder_uintptr_t), + /* + * void *: cookie + */ + BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), + /* + * 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, binder_uintptr_t), + /* + * 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_handle_cookie), + /* + * int: handle + * void *: cookie + */ + + BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, + struct binder_handle_cookie), + /* + * int: handle + * void *: cookie + */ + + BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), + /* + * void *: cookie + */ +}; + +#endif /* _UAPI_LINUX_BINDER_H */ + -- cgit v1.2.3-59-g8ed1b From bc2d62a01b336983b8abd1cb2337f305352f29ef Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 16 Oct 2014 15:22:30 +0200 Subject: android: uapi: binder.h add types.h to .h file to pass the checker scripts, and provide a proper uapi .h file. Signed-off-by: Greg Kroah-Hartman --- include/uapi/linux/android/binder.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h index dba4cef3a8d3..41420e341e75 100644 --- a/include/uapi/linux/android/binder.h +++ b/include/uapi/linux/android/binder.h @@ -20,6 +20,7 @@ #ifndef _UAPI_LINUX_BINDER_H #define _UAPI_LINUX_BINDER_H +#include #include #define B_PACK_CHARS(c1, c2, c3, c4) \ -- cgit v1.2.3-59-g8ed1b From 9246a4a98a01bafc017118bb2512d394d040fcbe Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 16 Oct 2014 15:26:51 +0200 Subject: android: binder: remove binder.h binder.h isn't needed to just include a uapi file and set a single define, so move it into binder.c to save a few lines of code. Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder.c | 6 +++++- drivers/android/binder.h | 30 ------------------------------ 2 files changed, 5 insertions(+), 31 deletions(-) delete mode 100644 drivers/android/binder.h diff --git a/drivers/android/binder.c b/drivers/android/binder.c index c69c40d69d5c..8c43521d3f11 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -38,7 +38,11 @@ #include #include -#include "binder.h" +#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT +#define BINDER_IPC_32BIT 1 +#endif + +#include #include "binder_trace.h" static DEFINE_MUTEX(binder_main_lock); diff --git a/drivers/android/binder.h b/drivers/android/binder.h deleted file mode 100644 index 5dc6a66b0665..000000000000 --- a/drivers/android/binder.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 _LINUX_BINDER_H -#define _LINUX_BINDER_H - -#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT -#define BINDER_IPC_32BIT 1 -#endif - -#include - -#endif /* _LINUX_BINDER_H */ - -- cgit v1.2.3-59-g8ed1b From 6ffb16475c99b59a5db1a127f1b82084840c0779 Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Tue, 30 Sep 2014 22:22:47 -0500 Subject: staging: skein: Whitespace cleanup Pretties up multiline #defines and many other whitespace issues Signed-off-by: Eric Rost Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_block.c | 585 +++++++++++++++++++----------------- 1 file changed, 315 insertions(+), 270 deletions(-) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 616364faf92e..71c14f58efdc 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -26,15 +26,18 @@ #define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ #endif -#define BLK_BITS (WCNT*64) /* some useful definitions for code here */ +#define BLK_BITS (WCNT * 64) /* some useful definitions for code here */ #define KW_TWK_BASE (0) #define KW_KEY_BASE (3) #define ks (kw + KW_KEY_BASE) #define ts (kw + KW_TWK_BASE) #ifdef SKEIN_DEBUG -#define debug_save_tweak(ctx) { \ - ctx->h.tweak[0] = ts[0]; ctx->h.tweak[1] = ts[1]; } +#define debug_save_tweak(ctx) \ +{ \ + ctx->h.tweak[0] = ts[0]; \ + ctx->h.tweak[1] = ts[1]; \ +} #else #define debug_save_tweak(ctx) #endif @@ -43,15 +46,15 @@ #if !(SKEIN_USE_ASM & 256) void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) - { /* do it in C */ +{ /* do it in C */ enum { WCNT = SKEIN_256_STATE_WORDS }; #undef RCNT -#define RCNT (SKEIN_256_ROUNDS_TOTAL/8) +#define RCNT (SKEIN_256_ROUNDS_TOTAL / 8) #ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_256 (((SKEIN_LOOP)/100)%10) +#define SKEIN_UNROLL_256 (((SKEIN_LOOP) / 100) % 10) #else #define SKEIN_UNROLL_256 (0) #endif @@ -96,7 +99,8 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, debug_save_tweak(ctx); skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); - X0 = w[0] + ks[0]; /* do the first full key injection */ + /* do the first full key injection */ + X0 = w[0] + ks[0]; X1 = w[1] + ks[1] + ts[0]; X2 = w[2] + ks[2] + ts[1]; X3 = w[3] + ks[3]; @@ -109,29 +113,34 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, /* run the rounds */ -#define ROUND256(p0, p1, p2, p3, ROT, r_num) \ -do { \ - X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ +#define ROUND256(p0, p1, p2, p3, ROT, r_num) \ +do { \ + X##p0 += X##p1; \ + X##p1 = rotl_64(X##p1, ROT##_0); \ + X##p1 ^= X##p0; \ + X##p2 += X##p3; \ + X##p3 = rotl_64(X##p3, ROT##_1); \ + X##p3 ^= X##p2; \ } while (0) #if SKEIN_UNROLL_256 == 0 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \ -do { \ - ROUND256(p0, p1, p2, p3, ROT, r_num); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ +do { \ + ROUND256(p0, p1, p2, p3, ROT, r_num); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) -#define I256(R) \ -do { \ - /* inject the key schedule value */ \ - X0 += ks[((R)+1) % 5]; \ - X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ - X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ - X3 += ks[((R)+4) % 5] + (R)+1; \ +#define I256(R) \ +do { \ + /* inject the key schedule value */ \ + X0 += ks[((R) + 1) % 5]; \ + X1 += ks[((R) + 2) % 5] + ts[((R) + 1) % 3]; \ + X2 += ks[((R) + 3) % 5] + ts[((R) + 2) % 3]; \ + X3 += ks[((R) + 4) % 5] + (R) + 1; \ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) -#else /* looping version */ +#else +/* looping version */ #define R256(p0, p1, p2, p3, ROT, r_num) \ do { \ ROUND256(p0, p1, p2, p3, ROT, r_num); \ @@ -141,85 +150,85 @@ do { \ #define I256(R) \ do { \ /* inject the key schedule value */ \ - X0 += ks[r+(R)+0]; \ - X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ - X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ - X3 += ks[r+(R)+3] + r+(R); \ - /* rotate key schedule */ \ - ks[r + (R) + 4] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ + X0 += ks[r + (R) + 0]; \ + X1 += ks[r + (R) + 1] + ts[r + (R) + 0]; \ + X2 += ks[r + (R) + 2] + ts[r + (R) + 1]; \ + X3 += ks[r + (R) + 3] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 4] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) #endif { -#define R256_8_ROUNDS(R) \ -do { \ +#define R256_8_ROUNDS(R) \ +do { \ R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \ R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4); \ - I256(2 * (R)); \ + I256(2 * (R)); \ R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5); \ R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \ R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \ R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \ - I256(2 * (R) + 1); \ + I256(2 * (R) + 1); \ } while (0) R256_8_ROUNDS(0); -#define R256_UNROLL_R(NN) \ - ((SKEIN_UNROLL_256 == 0 && \ - SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || \ - (SKEIN_UNROLL_256 > (NN))) +#define R256_UNROLL_R(NN) \ + ((SKEIN_UNROLL_256 == 0 && \ + SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \ + (SKEIN_UNROLL_256 > (NN))) - #if R256_UNROLL_R(1) +#if R256_UNROLL_R(1) R256_8_ROUNDS(1); - #endif - #if R256_UNROLL_R(2) +#endif +#if R256_UNROLL_R(2) R256_8_ROUNDS(2); - #endif - #if R256_UNROLL_R(3) +#endif +#if R256_UNROLL_R(3) R256_8_ROUNDS(3); - #endif - #if R256_UNROLL_R(4) +#endif +#if R256_UNROLL_R(4) R256_8_ROUNDS(4); - #endif - #if R256_UNROLL_R(5) +#endif +#if R256_UNROLL_R(5) R256_8_ROUNDS(5); - #endif - #if R256_UNROLL_R(6) +#endif +#if R256_UNROLL_R(6) R256_8_ROUNDS(6); - #endif - #if R256_UNROLL_R(7) +#endif +#if R256_UNROLL_R(7) R256_8_ROUNDS(7); - #endif - #if R256_UNROLL_R(8) +#endif +#if R256_UNROLL_R(8) R256_8_ROUNDS(8); - #endif - #if R256_UNROLL_R(9) +#endif +#if R256_UNROLL_R(9) R256_8_ROUNDS(9); - #endif - #if R256_UNROLL_R(10) +#endif +#if R256_UNROLL_R(10) R256_8_ROUNDS(10); - #endif - #if R256_UNROLL_R(11) +#endif +#if R256_UNROLL_R(11) R256_8_ROUNDS(11); - #endif - #if R256_UNROLL_R(12) +#endif +#if R256_UNROLL_R(12) R256_8_ROUNDS(12); - #endif - #if R256_UNROLL_R(13) +#endif +#if R256_UNROLL_R(13) R256_8_ROUNDS(13); - #endif - #if R256_UNROLL_R(14) +#endif +#if R256_UNROLL_R(14) R256_8_ROUNDS(14); - #endif - #if (SKEIN_UNROLL_256 > 14) +#endif +#if (SKEIN_UNROLL_256 > 14) #error "need more unrolling in skein_256_process_block" - #endif +#endif } /* do the final "feedforward" xor, update context chaining */ ctx->x[0] = X0 ^ w[0]; @@ -312,7 +321,8 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, debug_save_tweak(ctx); skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); - X0 = w[0] + ks[0]; /* do the first full key injection */ + /* do the first full key injection */ + X0 = w[0] + ks[0]; X1 = w[1] + ks[1]; X2 = w[2] + ks[2]; X3 = w[3] + ks[3]; @@ -327,62 +337,70 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, X_ptr); /* run the rounds */ #define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ -do { \ - X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = rotl_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ +do { \ + X##p0 += X##p1; \ + X##p1 = rotl_64(X##p1, ROT##_0); \ + X##p1 ^= X##p0; \ + X##p2 += X##p3; \ + X##p3 = rotl_64(X##p3, ROT##_1); \ + X##p3 ^= X##p2; \ + X##p4 += X##p5; \ + X##p5 = rotl_64(X##p5, ROT##_2); \ + X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); \ + X##p7 ^= X##p6; \ } while (0) #if SKEIN_UNROLL_512 == 0 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ -do { \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ +do { \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ + skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) -#define I512(R) \ -do { \ - /* inject the key schedule value */ \ - X0 += ks[((R) + 1) % 9]; \ - X1 += ks[((R) + 2) % 9]; \ - X2 += ks[((R) + 3) % 9]; \ - X3 += ks[((R) + 4) % 9]; \ - X4 += ks[((R) + 5) % 9]; \ - X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ - X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ - X7 += ks[((R) + 8) % 9] + (R) + 1; \ +#define I512(R) \ +do { \ + /* inject the key schedule value */ \ + X0 += ks[((R) + 1) % 9]; \ + X1 += ks[((R) + 2) % 9]; \ + X2 += ks[((R) + 3) % 9]; \ + X3 += ks[((R) + 4) % 9]; \ + X4 += ks[((R) + 5) % 9]; \ + X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ + X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ + X7 += ks[((R) + 8) % 9] + (R) + 1; \ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) + #else /* looping version */ -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ -do { \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ +do { \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) -#define I512(R) \ -do { \ - /* inject the key schedule value */ \ - X0 += ks[r + (R) + 0]; \ - X1 += ks[r + (R) + 1]; \ - X2 += ks[r + (R) + 2]; \ - X3 += ks[r + (R) + 3]; \ - X4 += ks[r + (R) + 4]; \ - X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ - X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ - X7 += ks[r + (R) + 7] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 8] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ +#define I512(R) \ +do { \ + /* inject the key schedule value */ \ + X0 += ks[r + (R) + 0]; \ + X1 += ks[r + (R) + 1]; \ + X2 += ks[r + (R) + 2]; \ + X3 += ks[r + (R) + 3]; \ + X4 += ks[r + (R) + 4]; \ + X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ + X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ + X7 += ks[r + (R) + 7] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 8] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) #endif /* end of looped code definitions */ { -#define R512_8_ROUNDS(R) /* do 8 full rounds */ \ -do { \ +#define R512_8_ROUNDS(R) /* do 8 full rounds */ \ +do { \ R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ @@ -392,61 +410,61 @@ do { \ R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ - I512(2 * (R) + 1); /* and key injection */ \ + I512(2 * (R) + 1); /* and key injection */ \ } while (0) R512_8_ROUNDS(0); -#define R512_UNROLL_R(NN) \ - ((SKEIN_UNROLL_512 == 0 && \ - SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ - (SKEIN_UNROLL_512 > (NN))) +#define R512_UNROLL_R(NN) \ + ((SKEIN_UNROLL_512 == 0 && \ + SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_512 > (NN))) - #if R512_UNROLL_R(1) +#if R512_UNROLL_R(1) R512_8_ROUNDS(1); - #endif - #if R512_UNROLL_R(2) +#endif +#if R512_UNROLL_R(2) R512_8_ROUNDS(2); - #endif - #if R512_UNROLL_R(3) +#endif +#if R512_UNROLL_R(3) R512_8_ROUNDS(3); - #endif - #if R512_UNROLL_R(4) +#endif +#if R512_UNROLL_R(4) R512_8_ROUNDS(4); - #endif - #if R512_UNROLL_R(5) +#endif +#if R512_UNROLL_R(5) R512_8_ROUNDS(5); - #endif - #if R512_UNROLL_R(6) +#endif +#if R512_UNROLL_R(6) R512_8_ROUNDS(6); - #endif - #if R512_UNROLL_R(7) +#endif +#if R512_UNROLL_R(7) R512_8_ROUNDS(7); - #endif - #if R512_UNROLL_R(8) +#endif +#if R512_UNROLL_R(8) R512_8_ROUNDS(8); - #endif - #if R512_UNROLL_R(9) +#endif +#if R512_UNROLL_R(9) R512_8_ROUNDS(9); - #endif - #if R512_UNROLL_R(10) +#endif +#if R512_UNROLL_R(10) R512_8_ROUNDS(10); - #endif - #if R512_UNROLL_R(11) +#endif +#if R512_UNROLL_R(11) R512_8_ROUNDS(11); - #endif - #if R512_UNROLL_R(12) +#endif +#if R512_UNROLL_R(12) R512_8_ROUNDS(12); - #endif - #if R512_UNROLL_R(13) +#endif +#if R512_UNROLL_R(13) R512_8_ROUNDS(13); - #endif - #if R512_UNROLL_R(14) +#endif +#if R512_UNROLL_R(14) R512_8_ROUNDS(14); - #endif - #if (SKEIN_UNROLL_512 > 14) +#endif +#if (SKEIN_UNROLL_512 > 14) #error "need more unrolling in skein_512_process_block" - #endif +#endif } /* do the final "feedforward" xor, update context chaining */ @@ -513,11 +531,21 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, #ifdef SKEIN_DEBUG const u64 *X_ptr[16]; /* use for debugging (help cc put Xn in regs) */ - X_ptr[0] = &X00; X_ptr[1] = &X01; X_ptr[2] = &X02; - X_ptr[3] = &X03; X_ptr[4] = &X04; X_ptr[5] = &X05; - X_ptr[6] = &X06; X_ptr[7] = &X07; X_ptr[8] = &X08; - X_ptr[9] = &X09; X_ptr[10] = &X10; X_ptr[11] = &X11; - X_ptr[12] = &X12; X_ptr[13] = &X13; X_ptr[14] = &X14; + X_ptr[0] = &X00; + X_ptr[1] = &X01; + X_ptr[2] = &X02; + X_ptr[3] = &X03; + X_ptr[4] = &X04; + X_ptr[5] = &X05; + X_ptr[6] = &X06; + X_ptr[7] = &X07; + X_ptr[8] = &X08; + X_ptr[9] = &X09; + X_ptr[10] = &X10; + X_ptr[11] = &X11; + X_ptr[12] = &X12; + X_ptr[13] = &X13; + X_ptr[14] = &X14; X_ptr[15] = &X15; #endif @@ -548,192 +576,209 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, ks[13] = ctx->x[13]; ks[14] = ctx->x[14]; ks[15] = ctx->x[15]; - ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ - ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ - ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ + ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ + ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ + ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY; - ts[2] = ts[0] ^ ts[1]; + ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); - X00 = w[0] + ks[0]; /* do the first full key injection */ - X01 = w[1] + ks[1]; - X02 = w[2] + ks[2]; - X03 = w[3] + ks[3]; - X04 = w[4] + ks[4]; - X05 = w[5] + ks[5]; - X06 = w[6] + ks[6]; - X07 = w[7] + ks[7]; - X08 = w[8] + ks[8]; - X09 = w[9] + ks[9]; - X10 = w[10] + ks[10]; - X11 = w[11] + ks[11]; - X12 = w[12] + ks[12]; - X13 = w[13] + ks[13] + ts[0]; - X14 = w[14] + ks[14] + ts[1]; - X15 = w[15] + ks[15]; + /* do the first full key injection */ + X00 = w[0] + ks[0]; + X01 = w[1] + ks[1]; + X02 = w[2] + ks[2]; + X03 = w[3] + ks[3]; + X04 = w[4] + ks[4]; + X05 = w[5] + ks[5]; + X06 = w[6] + ks[6]; + X07 = w[7] + ks[7]; + X08 = w[8] + ks[8]; + X09 = w[9] + ks[9]; + X10 = w[10] + ks[10]; + X11 = w[11] + ks[11]; + X12 = w[12] + ks[12]; + X13 = w[13] + ks[13] + ts[0]; + X14 = w[14] + ks[14] + ts[1]; + X15 = w[15] + ks[15]; skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, X_ptr); #define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, r_num) \ -do { \ - X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = rotl_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ - X##p8 += X##p9; X##p9 = rotl_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ - X##pA += X##pB; X##pB = rotl_64(X##pB, ROT##_5); X##pB ^= X##pA; \ - X##pC += X##pD; X##pD = rotl_64(X##pD, ROT##_6); X##pD ^= X##pC; \ - X##pE += X##pF; X##pF = rotl_64(X##pF, ROT##_7); X##pF ^= X##pE; \ + pF, ROT, r_num) \ +do { \ + X##p0 += X##p1; \ + X##p1 = rotl_64(X##p1, ROT##_0); \ + X##p1 ^= X##p0; \ + X##p2 += X##p3; \ + X##p3 = rotl_64(X##p3, ROT##_1); \ + X##p3 ^= X##p2; \ + X##p4 += X##p5; \ + X##p5 = rotl_64(X##p5, ROT##_2); \ + X##p5 ^= X##p4; \ + X##p6 += X##p7; \ + X##p7 = rotl_64(X##p7, ROT##_3); \ + X##p7 ^= X##p6; \ + X##p8 += X##p9; \ + X##p9 = rotl_64(X##p9, ROT##_4); \ + X##p9 ^= X##p8; \ + X##pA += X##pB; \ + X##pB = rotl_64(X##pB, ROT##_5); \ + X##pB ^= X##pA; \ + X##pC += X##pD; \ + X##pD = rotl_64(X##pD, ROT##_6); \ + X##pD ^= X##pC; \ + X##pE += X##pF; \ + X##pF = rotl_64(X##pF, ROT##_7); \ + X##pF ^= X##pE; \ } while (0) #if SKEIN_UNROLL_1024 == 0 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ - ROT, rn) \ -do { \ + ROT, rn) \ +do { \ ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ + pF, ROT, rn); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ } while (0) -#define I1024(R) \ -do { \ - /* inject the key schedule value */ \ - X00 += ks[((R) + 1) % 17]; \ - X01 += ks[((R) + 2) % 17]; \ - X02 += ks[((R) + 3) % 17]; \ - X03 += ks[((R) + 4) % 17]; \ - X04 += ks[((R) + 5) % 17]; \ - X05 += ks[((R) + 6) % 17]; \ - X06 += ks[((R) + 7) % 17]; \ - X07 += ks[((R) + 8) % 17]; \ - X08 += ks[((R) + 9) % 17]; \ - X09 += ks[((R) + 10) % 17]; \ - X10 += ks[((R) + 11) % 17]; \ - X11 += ks[((R) + 12) % 17]; \ - X12 += ks[((R) + 13) % 17]; \ - X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ - X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ - X15 += ks[((R) + 16) % 17] + (R) + 1; \ +#define I1024(R) \ +do { \ + /* inject the key schedule value */ \ + X00 += ks[((R) + 1) % 17]; \ + X01 += ks[((R) + 2) % 17]; \ + X02 += ks[((R) + 3) % 17]; \ + X03 += ks[((R) + 4) % 17]; \ + X04 += ks[((R) + 5) % 17]; \ + X05 += ks[((R) + 6) % 17]; \ + X06 += ks[((R) + 7) % 17]; \ + X07 += ks[((R) + 8) % 17]; \ + X08 += ks[((R) + 9) % 17]; \ + X09 += ks[((R) + 10) % 17]; \ + X10 += ks[((R) + 11) % 17]; \ + X11 += ks[((R) + 12) % 17]; \ + X12 += ks[((R) + 13) % 17]; \ + X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ + X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ + X15 += ks[((R) + 16) % 17] + (R) + 1; \ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ - ROT, rn) \ -do { \ + ROT, rn) \ +do { \ ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ + pF, ROT, rn); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ } while (0) -#define I1024(R) \ -do { \ - /* inject the key schedule value */ \ - X00 += ks[r + (R) + 0]; \ - X01 += ks[r + (R) + 1]; \ - X02 += ks[r + (R) + 2]; \ - X03 += ks[r + (R) + 3]; \ - X04 += ks[r + (R) + 4]; \ - X05 += ks[r + (R) + 5]; \ - X06 += ks[r + (R) + 6]; \ - X07 += ks[r + (R) + 7]; \ - X08 += ks[r + (R) + 8]; \ - X09 += ks[r + (R) + 9]; \ - X10 += ks[r + (R) + 10]; \ - X11 += ks[r + (R) + 11]; \ - X12 += ks[r + (R) + 12]; \ - X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ - X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ - X15 += ks[r + (R) + 15] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 16] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ +#define I1024(R) \ +do { \ + /* inject the key schedule value */ \ + X00 += ks[r + (R) + 0]; \ + X01 += ks[r + (R) + 1]; \ + X02 += ks[r + (R) + 2]; \ + X03 += ks[r + (R) + 3]; \ + X04 += ks[r + (R) + 4]; \ + X05 += ks[r + (R) + 5]; \ + X06 += ks[r + (R) + 6]; \ + X07 += ks[r + (R) + 7]; \ + X08 += ks[r + (R) + 8]; \ + X09 += ks[r + (R) + 9]; \ + X10 += ks[r + (R) + 10]; \ + X11 += ks[r + (R) + 11]; \ + X12 += ks[r + (R) + 12]; \ + X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ + X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ + X15 += ks[r + (R) + 15] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 16] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ skein_show_r_ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) #endif { -#define R1024_8_ROUNDS(R) \ -do { \ +#define R1024_8_ROUNDS(R) \ +do { \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ - R1024_0, 8*(R) + 1); \ + R1024_0, 8*(R) + 1); \ R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ - R1024_1, 8*(R) + 2); \ + R1024_1, 8*(R) + 2); \ R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ - R1024_2, 8*(R) + 3); \ + R1024_2, 8*(R) + 3); \ R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ - R1024_3, 8*(R) + 4); \ - I1024(2*(R)); \ + R1024_3, 8*(R) + 4); \ + I1024(2*(R)); \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ - R1024_4, 8*(R) + 5); \ + R1024_4, 8*(R) + 5); \ R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ - R1024_5, 8*(R) + 6); \ + R1024_5, 8*(R) + 6); \ R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ - R1024_6, 8*(R) + 7); \ + R1024_6, 8*(R) + 7); \ R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ - R1024_7, 8*(R) + 8); \ - I1024(2*(R)+1); \ + R1024_7, 8*(R) + 8); \ + I1024(2*(R)+1); \ } while (0) R1024_8_ROUNDS(0); -#define R1024_UNROLL_R(NN) \ - ((SKEIN_UNROLL_1024 == 0 && \ - SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \ - (SKEIN_UNROLL_1024 > (NN))) +#define R1024_UNROLL_R(NN) \ + ((SKEIN_UNROLL_1024 == 0 && \ + SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_1024 > (NN))) - #if R1024_UNROLL_R(1) +#if R1024_UNROLL_R(1) R1024_8_ROUNDS(1); - #endif - #if R1024_UNROLL_R(2) +#endif +#if R1024_UNROLL_R(2) R1024_8_ROUNDS(2); - #endif - #if R1024_UNROLL_R(3) +#endif +#if R1024_UNROLL_R(3) R1024_8_ROUNDS(3); - #endif - #if R1024_UNROLL_R(4) +#endif +#if R1024_UNROLL_R(4) R1024_8_ROUNDS(4); - #endif - #if R1024_UNROLL_R(5) +#endif +#if R1024_UNROLL_R(5) R1024_8_ROUNDS(5); - #endif - #if R1024_UNROLL_R(6) +#endif +#if R1024_UNROLL_R(6) R1024_8_ROUNDS(6); - #endif - #if R1024_UNROLL_R(7) +#endif +#if R1024_UNROLL_R(7) R1024_8_ROUNDS(7); - #endif - #if R1024_UNROLL_R(8) +#endif +#if R1024_UNROLL_R(8) R1024_8_ROUNDS(8); - #endif - #if R1024_UNROLL_R(9) +#endif +#if R1024_UNROLL_R(9) R1024_8_ROUNDS(9); - #endif - #if R1024_UNROLL_R(10) +#endif +#if R1024_UNROLL_R(10) R1024_8_ROUNDS(10); - #endif - #if R1024_UNROLL_R(11) +#endif +#if R1024_UNROLL_R(11) R1024_8_ROUNDS(11); - #endif - #if R1024_UNROLL_R(12) +#endif +#if R1024_UNROLL_R(12) R1024_8_ROUNDS(12); - #endif - #if R1024_UNROLL_R(13) +#endif +#if R1024_UNROLL_R(13) R1024_8_ROUNDS(13); - #endif - #if R1024_UNROLL_R(14) +#endif +#if R1024_UNROLL_R(14) R1024_8_ROUNDS(14); - #endif +#endif #if (SKEIN_UNROLL_1024 > 14) #error "need more unrolling in Skein_1024_Process_Block" - #endif + #endif } /* do the final "feedforward" xor, update context chaining */ -- cgit v1.2.3-59-g8ed1b From 468d958d2478c5dca4eb08c34cdb5c2a1436ad79 Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Tue, 30 Sep 2014 22:23:23 -0500 Subject: staging: skein: File Reorg Reorganizes file to remove #defines from middle of functions. Also removes #if'd loop declarations and adds ternary if driven loops. Signed-off-by: Eric Rost Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_block.c | 680 +++++++++++++++++++----------------- 1 file changed, 351 insertions(+), 329 deletions(-) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 71c14f58efdc..88bc718ae5b6 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -42,17 +42,9 @@ #define debug_save_tweak(ctx) #endif -/***************************** SKEIN_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ /* do it in C */ - enum { - WCNT = SKEIN_256_STATE_WORDS - }; #undef RCNT #define RCNT (SKEIN_256_ROUNDS_TOTAL / 8) - #ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_256 (((SKEIN_LOOP) / 100) % 10) #else @@ -63,56 +55,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, #if (RCNT % SKEIN_UNROLL_256) #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ #endif - size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/ -#else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ -#endif - u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ - u64 w[WCNT]; /* local copy of input block */ -#ifdef SKEIN_DEBUG - const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */ - - X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; #endif - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.tweak[0]; - ts[1] = ctx->h.tweak[1]; - do { - /* - * this implementation only supports 2**64 input bytes - * (no carry out here) - */ - ts[0] += byte_cnt_add; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->x[0]; - ks[1] = ctx->x[1]; - ks[2] = ctx->x[2]; - ks[3] = ctx->x[3]; - ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, WCNT); - debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); - - /* do the first full key injection */ - X0 = w[0] + ks[0]; - X1 = w[1] + ks[1] + ts[0]; - X2 = w[2] + ks[2] + ts[1]; - X3 = w[3] + ks[3]; - - /* show starting state values */ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - x_ptr); - - blk_ptr += SKEIN_256_BLOCK_BYTES; - - /* run the rounds */ - #define ROUND256(p0, p1, p2, p3, ROT, r_num) \ do { \ X##p0 += X##p1; \ @@ -159,10 +102,7 @@ do { \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) - - for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) #endif - { #define R256_8_ROUNDS(R) \ do { \ R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ @@ -177,57 +117,362 @@ do { \ I256(2 * (R) + 1); \ } while (0) - R256_8_ROUNDS(0); +#define R256_UNROLL_R(NN) \ + ((SKEIN_UNROLL_256 == 0 && \ + SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \ + (SKEIN_UNROLL_256 > (NN))) + +#if (SKEIN_UNROLL_256 > 14) +#error "need more unrolling in skein_256_process_block" +#endif +#endif + +#if !(SKEIN_USE_ASM & 512) +#undef RCNT +#define RCNT (SKEIN_512_ROUNDS_TOTAL/8) + +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) +#else +#define SKEIN_UNROLL_512 (0) +#endif + +#if SKEIN_UNROLL_512 +#if (RCNT % SKEIN_UNROLL_512) +#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ +#endif +#endif +#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ +do { \ + X##p0 += X##p1; \ + X##p1 = rotl_64(X##p1, ROT##_0); \ + X##p1 ^= X##p0; \ + X##p2 += X##p3; \ + X##p3 = rotl_64(X##p3, ROT##_1); \ + X##p3 ^= X##p2; \ + X##p4 += X##p5; \ + X##p5 = rotl_64(X##p5, ROT##_2); \ + X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); \ + X##p7 ^= X##p6; \ +} while (0) + +#if SKEIN_UNROLL_512 == 0 +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ +do { \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ + skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ +} while (0) + +#define I512(R) \ +do { \ + /* inject the key schedule value */ \ + X0 += ks[((R) + 1) % 9]; \ + X1 += ks[((R) + 2) % 9]; \ + X2 += ks[((R) + 3) % 9]; \ + X3 += ks[((R) + 4) % 9]; \ + X4 += ks[((R) + 5) % 9]; \ + X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ + X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ + X7 += ks[((R) + 8) % 9] + (R) + 1; \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ +} while (0) + +#else /* looping version */ +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ +do { \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ +} while (0) + +#define I512(R) \ +do { \ + /* inject the key schedule value */ \ + X0 += ks[r + (R) + 0]; \ + X1 += ks[r + (R) + 1]; \ + X2 += ks[r + (R) + 2]; \ + X3 += ks[r + (R) + 3]; \ + X4 += ks[r + (R) + 4]; \ + X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ + X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ + X7 += ks[r + (R) + 7] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 8] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ +} while (0) +#endif /* end of looped code definitions */ +#define R512_8_ROUNDS(R) /* do 8 full rounds */ \ +do { \ + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ + I512(2 * (R)); \ + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ + I512(2 * (R) + 1); /* and key injection */ \ +} while (0) +#define R512_UNROLL_R(NN) \ + ((SKEIN_UNROLL_512 == 0 && \ + SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_512 > (NN))) + +#if (SKEIN_UNROLL_512 > 14) +#error "need more unrolling in skein_512_process_block" +#endif +#endif + +#if !(SKEIN_USE_ASM & 1024) +#undef RCNT +#define RCNT (SKEIN_1024_ROUNDS_TOTAL/8) +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10) +#else +#define SKEIN_UNROLL_1024 (0) +#endif + +#if (SKEIN_UNROLL_1024 != 0) +#if (RCNT % SKEIN_UNROLL_1024) +#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ +#endif +#endif +#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, r_num) \ +do { \ + X##p0 += X##p1; \ + X##p1 = rotl_64(X##p1, ROT##_0); \ + X##p1 ^= X##p0; \ + X##p2 += X##p3; \ + X##p3 = rotl_64(X##p3, ROT##_1); \ + X##p3 ^= X##p2; \ + X##p4 += X##p5; \ + X##p5 = rotl_64(X##p5, ROT##_2); \ + X##p5 ^= X##p4; \ + X##p6 += X##p7; \ + X##p7 = rotl_64(X##p7, ROT##_3); \ + X##p7 ^= X##p6; \ + X##p8 += X##p9; \ + X##p9 = rotl_64(X##p9, ROT##_4); \ + X##p9 ^= X##p8; \ + X##pA += X##pB; \ + X##pB = rotl_64(X##pB, ROT##_5); \ + X##pB ^= X##pA; \ + X##pC += X##pD; \ + X##pD = rotl_64(X##pD, ROT##_6); \ + X##pD ^= X##pC; \ + X##pE += X##pF; \ + X##pF = rotl_64(X##pF, ROT##_7); \ + X##pF ^= X##pE; \ +} while (0) + +#if SKEIN_UNROLL_1024 == 0 +#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ + ROT, rn) \ +do { \ + ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rn); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ +} while (0) + +#define I1024(R) \ +do { \ + /* inject the key schedule value */ \ + X00 += ks[((R) + 1) % 17]; \ + X01 += ks[((R) + 2) % 17]; \ + X02 += ks[((R) + 3) % 17]; \ + X03 += ks[((R) + 4) % 17]; \ + X04 += ks[((R) + 5) % 17]; \ + X05 += ks[((R) + 6) % 17]; \ + X06 += ks[((R) + 7) % 17]; \ + X07 += ks[((R) + 8) % 17]; \ + X08 += ks[((R) + 9) % 17]; \ + X09 += ks[((R) + 10) % 17]; \ + X10 += ks[((R) + 11) % 17]; \ + X11 += ks[((R) + 12) % 17]; \ + X12 += ks[((R) + 13) % 17]; \ + X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ + X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ + X15 += ks[((R) + 16) % 17] + (R) + 1; \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ +} while (0) +#else /* looping version */ +#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ + ROT, rn) \ +do { \ + ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rn); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ +} while (0) + +#define I1024(R) \ +do { \ + /* inject the key schedule value */ \ + X00 += ks[r + (R) + 0]; \ + X01 += ks[r + (R) + 1]; \ + X02 += ks[r + (R) + 2]; \ + X03 += ks[r + (R) + 3]; \ + X04 += ks[r + (R) + 4]; \ + X05 += ks[r + (R) + 5]; \ + X06 += ks[r + (R) + 6]; \ + X07 += ks[r + (R) + 7]; \ + X08 += ks[r + (R) + 8]; \ + X09 += ks[r + (R) + 9]; \ + X10 += ks[r + (R) + 10]; \ + X11 += ks[r + (R) + 11]; \ + X12 += ks[r + (R) + 12]; \ + X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ + X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ + X15 += ks[r + (R) + 15] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 16] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + skein_show_r_ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ +} while (0) + +#endif +#define R1024_8_ROUNDS(R) \ +do { \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ + R1024_0, 8*(R) + 1); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ + R1024_1, 8*(R) + 2); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ + R1024_2, 8*(R) + 3); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ + R1024_3, 8*(R) + 4); \ + I1024(2*(R)); \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ + R1024_4, 8*(R) + 5); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ + R1024_5, 8*(R) + 6); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ + R1024_6, 8*(R) + 7); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ + R1024_7, 8*(R) + 8); \ + I1024(2*(R)+1); \ +} while (0) + +#define R1024_UNROLL_R(NN) \ + ((SKEIN_UNROLL_1024 == 0 && \ + SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_1024 > (NN))) + +#if (SKEIN_UNROLL_1024 > 14) +#error "need more unrolling in Skein_1024_Process_Block" +#endif +#endif + +/***************************** SKEIN_256 ******************************/ +#if !(SKEIN_USE_ASM & 256) +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) +{ /* do it in C */ + enum { + WCNT = SKEIN_256_STATE_WORDS + }; + size_t r; +#if SKEIN_UNROLL_256 + /* key schedule: chaining vars + tweak + "rot"*/ + u64 kw[WCNT+4+RCNT*2]; +#else + /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; +#endif + u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ + u64 w[WCNT]; /* local copy of input block */ +#ifdef SKEIN_DEBUG + const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */ + + X_ptr[0] = &X0; + X_ptr[1] = &X1; + X_ptr[2] = &X2; + X_ptr[3] = &X3; +#endif + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + ts[0] = ctx->h.tweak[0]; + ts[1] = ctx->h.tweak[1]; + do { + /* + * this implementation only supports 2**64 input bytes + * (no carry out here) + */ + ts[0] += byte_cnt_add; /* update processed length */ + + /* precompute the key schedule for this block */ + ks[0] = ctx->x[0]; + ks[1] = ctx->x[1]; + ks[2] = ctx->x[2]; + ks[3] = ctx->x[3]; + ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; + + ts[2] = ts[0] ^ ts[1]; + + /* get input block in little-endian format */ + skein_get64_lsb_first(w, blk_ptr, WCNT); + debug_save_tweak(ctx); + skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); + + /* do the first full key injection */ + X0 = w[0] + ks[0]; + X1 = w[1] + ks[1] + ts[0]; + X2 = w[2] + ks[2] + ts[1]; + X3 = w[3] + ks[3]; -#define R256_UNROLL_R(NN) \ - ((SKEIN_UNROLL_256 == 0 && \ - SKEIN_256_ROUNDS_TOTAL / 8 > (NN)) || \ - (SKEIN_UNROLL_256 > (NN))) + /* show starting state values */ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + x_ptr); + + blk_ptr += SKEIN_256_BLOCK_BYTES; + /* run the rounds */ + for (r = 1; + r < (SKEIN_UNROLL_256 ? 2 * RCNT : 2); + r += (SKEIN_UNROLL_256 ? 2 * SKEIN_UNROLL_256 : 1)) { + R256_8_ROUNDS(0); #if R256_UNROLL_R(1) - R256_8_ROUNDS(1); + R256_8_ROUNDS(1); #endif #if R256_UNROLL_R(2) - R256_8_ROUNDS(2); + R256_8_ROUNDS(2); #endif #if R256_UNROLL_R(3) - R256_8_ROUNDS(3); + R256_8_ROUNDS(3); #endif #if R256_UNROLL_R(4) - R256_8_ROUNDS(4); + R256_8_ROUNDS(4); #endif #if R256_UNROLL_R(5) - R256_8_ROUNDS(5); + R256_8_ROUNDS(5); #endif #if R256_UNROLL_R(6) - R256_8_ROUNDS(6); + R256_8_ROUNDS(6); #endif #if R256_UNROLL_R(7) - R256_8_ROUNDS(7); + R256_8_ROUNDS(7); #endif #if R256_UNROLL_R(8) - R256_8_ROUNDS(8); + R256_8_ROUNDS(8); #endif #if R256_UNROLL_R(9) - R256_8_ROUNDS(9); + R256_8_ROUNDS(9); #endif #if R256_UNROLL_R(10) - R256_8_ROUNDS(10); + R256_8_ROUNDS(10); #endif #if R256_UNROLL_R(11) - R256_8_ROUNDS(11); + R256_8_ROUNDS(11); #endif #if R256_UNROLL_R(12) - R256_8_ROUNDS(12); + R256_8_ROUNDS(12); #endif #if R256_UNROLL_R(13) - R256_8_ROUNDS(13); + R256_8_ROUNDS(13); #endif #if R256_UNROLL_R(14) - R256_8_ROUNDS(14); -#endif -#if (SKEIN_UNROLL_256 > 14) -#error "need more unrolling in skein_256_process_block" + R256_8_ROUNDS(14); #endif } /* do the final "feedforward" xor, update context chaining */ @@ -265,20 +510,8 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, enum { WCNT = SKEIN_512_STATE_WORDS }; -#undef RCNT -#define RCNT (SKEIN_512_ROUNDS_TOTAL/8) - -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) -#else -#define SKEIN_UNROLL_512 (0) -#endif - -#if SKEIN_UNROLL_512 -#if (RCNT % SKEIN_UNROLL_512) -#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ -#endif size_t r; +#if SKEIN_UNROLL_512 u64 kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot"*/ #else u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ @@ -288,8 +521,14 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, #ifdef SKEIN_DEBUG const u64 *X_ptr[8]; /* use for debugging (help cc put Xn in regs) */ - X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; - X_ptr[4] = &X4; X_ptr[5] = &X5; X_ptr[6] = &X6; X_ptr[7] = &X7; + X_ptr[0] = &X0; + X_ptr[1] = &X1; + X_ptr[2] = &X2; + X_ptr[3] = &X3; + X_ptr[4] = &X4; + X_ptr[5] = &X5; + X_ptr[6] = &X6; + X_ptr[7] = &X7; #endif skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ @@ -322,104 +561,26 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); /* do the first full key injection */ - X0 = w[0] + ks[0]; - X1 = w[1] + ks[1]; - X2 = w[2] + ks[2]; - X3 = w[3] + ks[3]; - X4 = w[4] + ks[4]; - X5 = w[5] + ks[5] + ts[0]; - X6 = w[6] + ks[6] + ts[1]; - X7 = w[7] + ks[7]; + X0 = w[0] + ks[0]; + X1 = w[1] + ks[1]; + X2 = w[2] + ks[2]; + X3 = w[3] + ks[3]; + X4 = w[4] + ks[4]; + X5 = w[5] + ks[5] + ts[0]; + X6 = w[6] + ks[6] + ts[1]; + X7 = w[7] + ks[7]; blk_ptr += SKEIN_512_BLOCK_BYTES; skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, X_ptr); /* run the rounds */ -#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ -do { \ - X##p0 += X##p1; \ - X##p1 = rotl_64(X##p1, ROT##_0); \ - X##p1 ^= X##p0; \ - X##p2 += X##p3; \ - X##p3 = rotl_64(X##p3, ROT##_1); \ - X##p3 ^= X##p2; \ - X##p4 += X##p5; \ - X##p5 = rotl_64(X##p5, ROT##_2); \ - X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); \ - X##p7 ^= X##p6; \ -} while (0) - -#if SKEIN_UNROLL_512 == 0 -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ -do { \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ -} while (0) - -#define I512(R) \ -do { \ - /* inject the key schedule value */ \ - X0 += ks[((R) + 1) % 9]; \ - X1 += ks[((R) + 2) % 9]; \ - X2 += ks[((R) + 3) % 9]; \ - X3 += ks[((R) + 4) % 9]; \ - X4 += ks[((R) + 5) % 9]; \ - X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ - X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ - X7 += ks[((R) + 8) % 9] + (R) + 1; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ -} while (0) - -#else /* looping version */ -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ -do { \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ -} while (0) - -#define I512(R) \ -do { \ - /* inject the key schedule value */ \ - X0 += ks[r + (R) + 0]; \ - X1 += ks[r + (R) + 1]; \ - X2 += ks[r + (R) + 2]; \ - X3 += ks[r + (R) + 3]; \ - X4 += ks[r + (R) + 4]; \ - X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ - X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ - X7 += ks[r + (R) + 7] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 8] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ -} while (0) - - for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) -#endif /* end of looped code definitions */ - { -#define R512_8_ROUNDS(R) /* do 8 full rounds */ \ -do { \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ - I512(2 * (R)); \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ - I512(2 * (R) + 1); /* and key injection */ \ -} while (0) + for (r = 1; + r < (SKEIN_UNROLL_512 ? 2 * RCNT : 2); + r += (SKEIN_UNROLL_512 ? 2 * SKEIN_UNROLL_512 : 1)) { R512_8_ROUNDS(0); -#define R512_UNROLL_R(NN) \ - ((SKEIN_UNROLL_512 == 0 && \ - SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ - (SKEIN_UNROLL_512 > (NN))) - #if R512_UNROLL_R(1) R512_8_ROUNDS(1); #endif @@ -461,9 +622,6 @@ do { \ #endif #if R512_UNROLL_R(14) R512_8_ROUNDS(14); -#endif -#if (SKEIN_UNROLL_512 > 14) -#error "need more unrolling in skein_512_process_block" #endif } @@ -505,20 +663,8 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, enum { WCNT = SKEIN_1024_STATE_WORDS }; -#undef RCNT -#define RCNT (SKEIN_1024_ROUNDS_TOTAL/8) - -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10) -#else -#define SKEIN_UNROLL_1024 (0) -#endif - -#if (SKEIN_UNROLL_1024 != 0) -#if (RCNT % SKEIN_UNROLL_1024) -#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ -#endif size_t r; +#if (SKEIN_UNROLL_1024 != 0) u64 kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot" */ #else u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ @@ -609,131 +755,10 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, X_ptr); -#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, r_num) \ -do { \ - X##p0 += X##p1; \ - X##p1 = rotl_64(X##p1, ROT##_0); \ - X##p1 ^= X##p0; \ - X##p2 += X##p3; \ - X##p3 = rotl_64(X##p3, ROT##_1); \ - X##p3 ^= X##p2; \ - X##p4 += X##p5; \ - X##p5 = rotl_64(X##p5, ROT##_2); \ - X##p5 ^= X##p4; \ - X##p6 += X##p7; \ - X##p7 = rotl_64(X##p7, ROT##_3); \ - X##p7 ^= X##p6; \ - X##p8 += X##p9; \ - X##p9 = rotl_64(X##p9, ROT##_4); \ - X##p9 ^= X##p8; \ - X##pA += X##pB; \ - X##pB = rotl_64(X##pB, ROT##_5); \ - X##pB ^= X##pA; \ - X##pC += X##pD; \ - X##pD = rotl_64(X##pD, ROT##_6); \ - X##pD ^= X##pC; \ - X##pE += X##pF; \ - X##pF = rotl_64(X##pF, ROT##_7); \ - X##pF ^= X##pE; \ -} while (0) - -#if SKEIN_UNROLL_1024 == 0 -#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ - ROT, rn) \ -do { \ - ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ -} while (0) - -#define I1024(R) \ -do { \ - /* inject the key schedule value */ \ - X00 += ks[((R) + 1) % 17]; \ - X01 += ks[((R) + 2) % 17]; \ - X02 += ks[((R) + 3) % 17]; \ - X03 += ks[((R) + 4) % 17]; \ - X04 += ks[((R) + 5) % 17]; \ - X05 += ks[((R) + 6) % 17]; \ - X06 += ks[((R) + 7) % 17]; \ - X07 += ks[((R) + 8) % 17]; \ - X08 += ks[((R) + 9) % 17]; \ - X09 += ks[((R) + 10) % 17]; \ - X10 += ks[((R) + 11) % 17]; \ - X11 += ks[((R) + 12) % 17]; \ - X12 += ks[((R) + 13) % 17]; \ - X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ - X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ - X15 += ks[((R) + 16) % 17] + (R) + 1; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ -} while (0) -#else /* looping version */ -#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ - ROT, rn) \ -do { \ - ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ -} while (0) - -#define I1024(R) \ -do { \ - /* inject the key schedule value */ \ - X00 += ks[r + (R) + 0]; \ - X01 += ks[r + (R) + 1]; \ - X02 += ks[r + (R) + 2]; \ - X03 += ks[r + (R) + 3]; \ - X04 += ks[r + (R) + 4]; \ - X05 += ks[r + (R) + 5]; \ - X06 += ks[r + (R) + 6]; \ - X07 += ks[r + (R) + 7]; \ - X08 += ks[r + (R) + 8]; \ - X09 += ks[r + (R) + 9]; \ - X10 += ks[r + (R) + 10]; \ - X11 += ks[r + (R) + 11]; \ - X12 += ks[r + (R) + 12]; \ - X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ - X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ - X15 += ks[r + (R) + 15] + r + (R); \ - /* rotate key schedule */ \ - ks[r + (R) + 16] = ks[r + (R) - 1]; \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - skein_show_r_ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ -} while (0) - - for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) -#endif - { -#define R1024_8_ROUNDS(R) \ -do { \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ - R1024_0, 8*(R) + 1); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ - R1024_1, 8*(R) + 2); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ - R1024_2, 8*(R) + 3); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ - R1024_3, 8*(R) + 4); \ - I1024(2*(R)); \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ - R1024_4, 8*(R) + 5); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ - R1024_5, 8*(R) + 6); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ - R1024_6, 8*(R) + 7); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ - R1024_7, 8*(R) + 8); \ - I1024(2*(R)+1); \ -} while (0) - + for (r = 1; + r < (SKEIN_UNROLL_1024 ? 2 * RCNT : 2); + r += (SKEIN_UNROLL_1024 ? 2 * SKEIN_UNROLL_1024 : 1)) { R1024_8_ROUNDS(0); - -#define R1024_UNROLL_R(NN) \ - ((SKEIN_UNROLL_1024 == 0 && \ - SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \ - (SKEIN_UNROLL_1024 > (NN))) - #if R1024_UNROLL_R(1) R1024_8_ROUNDS(1); #endif @@ -776,9 +801,6 @@ do { \ #if R1024_UNROLL_R(14) R1024_8_ROUNDS(14); #endif -#if (SKEIN_UNROLL_1024 > 14) -#error "need more unrolling in Skein_1024_Process_Block" - #endif } /* do the final "feedforward" xor, update context chaining */ -- cgit v1.2.3-59-g8ed1b From 8552befa3086589876032d5e1ce5797ae2bb684b Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 2 Oct 2014 22:25:22 -0300 Subject: iio: adc: vf610: Propagate the real error when platform_get_irq() fails There is no need to pass a 'fake' return value when platform_get_irq() fails. Propagate the real error instead. While at it, only consider negative numbers returned by platform_get_irq() as error. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/vf610_adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index d47fff003b78..8ec353c01d98 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -593,9 +593,9 @@ static int vf610_adc_probe(struct platform_device *pdev) return PTR_ERR(info->regs); irq = platform_get_irq(pdev, 0); - if (irq <= 0) { + if (irq < 0) { dev_err(&pdev->dev, "no irq resource?\n"); - return -EINVAL; + return irq; } ret = devm_request_irq(info->dev, irq, -- cgit v1.2.3-59-g8ed1b From c22e15f352066e8ee4d662f4a721c2fd10590f81 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Mon, 13 Oct 2014 14:53:00 +0100 Subject: iio: add ABI documentation for scaled pressure Signed-off-by: Vlad Dogaru Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 1ac9ac20f530..5a7fc666b07e 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -200,6 +200,13 @@ Description: Raw pressure measurement from channel Y. Units after application of scale and offset are kilopascal. +What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_input +What: /sys/bus/iio/devices/iio:deviceX/in_pressure_input +KernelVersion: 3.8 +Contact: linux-iio@vger.kernel.org +Description: + Scaled pressure measurement from channel Y, in kilopascal. + What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_raw KernelVersion: 3.14 Contact: linux-iio@vger.kernel.org -- cgit v1.2.3-59-g8ed1b From d5c94568cc1d11dffee349468ae996e420381453 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Tue, 21 Oct 2014 11:09:58 +0300 Subject: iio: add bmp280 pressure and temperature driver Minimal implementation, can read temperature and data using direct mode. Datasheet available at Signed-off-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 11 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/bmp280.c | 455 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 467 insertions(+) create mode 100644 drivers/iio/pressure/bmp280.c diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 15afbc919521..a3be53792072 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -5,6 +5,17 @@ menu "Pressure sensors" +config BMP280 + tristate "Bosch Sensortec BMP280 pressure sensor driver" + depends on I2C + select REGMAP_I2C + help + Say yes here to build support for Bosch Sensortec BMP280 + pressure and temperature sensor. + + To compile this driver as a module, choose M here: the module + will be called bmp280. + config HID_SENSOR_PRESS depends on HID_SENSOR_HUB select IIO_BUFFER diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 90a37e85cf21..88011f2ae00e 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_BMP280) += bmp280.o obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o obj-$(CONFIG_MPL115) += mpl115.o obj-$(CONFIG_MPL3115) += mpl3115.o diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c new file mode 100644 index 000000000000..fb91cb35b331 --- /dev/null +++ b/drivers/iio/pressure/bmp280.c @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Driver for Bosch Sensortec BMP280 digital pressure sensor. + * + * 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. + * + */ + +#define pr_fmt(fmt) "bmp280: " fmt + +#include +#include +#include +#include +#include +#include + +#define BMP280_REG_TEMP_XLSB 0xFC +#define BMP280_REG_TEMP_LSB 0xFB +#define BMP280_REG_TEMP_MSB 0xFA +#define BMP280_REG_PRESS_XLSB 0xF9 +#define BMP280_REG_PRESS_LSB 0xF8 +#define BMP280_REG_PRESS_MSB 0xF7 + +#define BMP280_REG_CONFIG 0xF5 +#define BMP280_REG_CTRL_MEAS 0xF4 +#define BMP280_REG_STATUS 0xF3 +#define BMP280_REG_RESET 0xE0 +#define BMP280_REG_ID 0xD0 + +#define BMP280_REG_COMP_TEMP_START 0x88 +#define BMP280_COMP_TEMP_REG_COUNT 6 + +#define BMP280_REG_COMP_PRESS_START 0x8E +#define BMP280_COMP_PRESS_REG_COUNT 18 + +#define BMP280_FILTER_MASK (BIT(4) | BIT(3) | BIT(2)) +#define BMP280_FILTER_OFF 0 +#define BMP280_FILTER_2X BIT(2) +#define BMP280_FILTER_4X BIT(3) +#define BMP280_FILTER_8X (BIT(3) | BIT(2)) +#define BMP280_FILTER_16X BIT(4) + +#define BMP280_OSRS_TEMP_MASK (BIT(7) | BIT(6) | BIT(5)) +#define BMP280_OSRS_TEMP_SKIP 0 +#define BMP280_OSRS_TEMP_1X BIT(5) +#define BMP280_OSRS_TEMP_2X BIT(6) +#define BMP280_OSRS_TEMP_4X (BIT(6) | BIT(5)) +#define BMP280_OSRS_TEMP_8X BIT(7) +#define BMP280_OSRS_TEMP_16X (BIT(7) | BIT(5)) + +#define BMP280_OSRS_PRESS_MASK (BIT(4) | BIT(3) | BIT(2)) +#define BMP280_OSRS_PRESS_SKIP 0 +#define BMP280_OSRS_PRESS_1X BIT(2) +#define BMP280_OSRS_PRESS_2X BIT(3) +#define BMP280_OSRS_PRESS_4X (BIT(3) | BIT(2)) +#define BMP280_OSRS_PRESS_8X BIT(4) +#define BMP280_OSRS_PRESS_16X (BIT(4) | BIT(2)) + +#define BMP280_MODE_MASK (BIT(1) | BIT(0)) +#define BMP280_MODE_SLEEP 0 +#define BMP280_MODE_FORCED BIT(0) +#define BMP280_MODE_NORMAL (BIT(1) | BIT(0)) + +#define BMP280_CHIP_ID 0x58 +#define BMP280_SOFT_RESET_VAL 0xB6 + +struct bmp280_data { + struct i2c_client *client; + struct mutex lock; + struct regmap *regmap; + + /* + * Carryover value from temperature conversion, used in pressure + * calculation. + */ + s32 t_fine; +}; + +/* Compensation parameters. */ +struct bmp280_comp_temp { + u16 dig_t1; + s16 dig_t2, dig_t3; +}; + +struct bmp280_comp_press { + u16 dig_p1; + s16 dig_p2, dig_p3, dig_p4, dig_p5, dig_p6, dig_p7, dig_p8, dig_p9; +}; + +static const struct iio_chan_spec bmp280_channels[] = { + { + .type = IIO_PRESSURE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + }, + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + }, +}; + +static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMP280_REG_CONFIG: + case BMP280_REG_CTRL_MEAS: + case BMP280_REG_RESET: + return true; + default: + return false; + }; +} + +static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMP280_REG_TEMP_XLSB: + case BMP280_REG_TEMP_LSB: + case BMP280_REG_TEMP_MSB: + case BMP280_REG_PRESS_XLSB: + case BMP280_REG_PRESS_LSB: + case BMP280_REG_PRESS_MSB: + case BMP280_REG_STATUS: + return true; + default: + return false; + } +} + +static const struct regmap_config bmp280_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = BMP280_REG_TEMP_XLSB, + .cache_type = REGCACHE_RBTREE, + + .writeable_reg = bmp280_is_writeable_reg, + .volatile_reg = bmp280_is_volatile_reg, +}; + +static int bmp280_read_compensation_temp(struct bmp280_data *data, + struct bmp280_comp_temp *comp) +{ + int ret; + __le16 buf[BMP280_COMP_TEMP_REG_COUNT / 2]; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START, + buf, BMP280_COMP_TEMP_REG_COUNT); + if (ret < 0) { + dev_err(&data->client->dev, + "failed to read temperature calibration parameters\n"); + return ret; + } + + comp->dig_t1 = (u16) le16_to_cpu(buf[0]); + comp->dig_t2 = (s16) le16_to_cpu(buf[1]); + comp->dig_t3 = (s16) le16_to_cpu(buf[2]); + + return 0; +} + +static int bmp280_read_compensation_press(struct bmp280_data *data, + struct bmp280_comp_press *comp) +{ + int ret; + __le16 buf[BMP280_COMP_PRESS_REG_COUNT / 2]; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_PRESS_START, + buf, BMP280_COMP_PRESS_REG_COUNT); + if (ret < 0) { + dev_err(&data->client->dev, + "failed to read pressure calibration parameters\n"); + return ret; + } + + comp->dig_p1 = (s16) le16_to_cpu(buf[0]); + comp->dig_p2 = (u16) le16_to_cpu(buf[1]); + comp->dig_p3 = (u16) le16_to_cpu(buf[2]); + comp->dig_p4 = (u16) le16_to_cpu(buf[3]); + comp->dig_p5 = (u16) le16_to_cpu(buf[4]); + comp->dig_p6 = (u16) le16_to_cpu(buf[5]); + comp->dig_p7 = (u16) le16_to_cpu(buf[6]); + comp->dig_p8 = (u16) le16_to_cpu(buf[7]); + comp->dig_p9 = (u16) le16_to_cpu(buf[8]); + + return 0; +} + +/* + * Returns temperature in DegC, resolution is 0.01 DegC. Output value of + * "5123" equals 51.23 DegC. t_fine carries fine temperature as global + * value. + * + * Taken from datasheet, Section 3.11.3, "Compensation formula". + */ +static s32 bmp280_compensate_temp(struct bmp280_data *data, + struct bmp280_comp_temp *comp, + s32 adc_temp) +{ + s32 var1, var2, t; + + var1 = (((adc_temp >> 3) - ((s32) comp->dig_t1 << 1)) * + ((s32) comp->dig_t2)) >> 11; + var2 = (((((adc_temp >> 4) - ((s32) comp->dig_t1)) * + ((adc_temp >> 4) - ((s32) comp->dig_t1))) >> 12) * + ((s32) comp->dig_t3)) >> 14; + + data->t_fine = var1 + var2; + t = (data->t_fine * 5 + 128) >> 8; + + return t; +} + +/* + * Returns pressure in Pa as unsigned 32 bit integer in Q24.8 format (24 + * integer bits and 8 fractional bits). Output value of "24674867" + * represents 24674867/256 = 96386.2 Pa = 963.862 hPa + * + * Taken from datasheet, Section 3.11.3, "Compensation formula". + */ +static u32 bmp280_compensate_press(struct bmp280_data *data, + struct bmp280_comp_press *comp, + s32 adc_press) +{ + s64 var1, var2, p; + + var1 = ((s64) data->t_fine) - 128000; + var2 = var1 * var1 * (s64) comp->dig_p6; + var2 = var2 + ((var1 * (s64) comp->dig_p5) << 17); + var2 = var2 + (((s64) comp->dig_p4) << 35); + var1 = ((var1 * var1 * (s64) comp->dig_p3) >> 8) + + ((var1 * (s64) comp->dig_p2) << 12); + var1 = (((((s64) 1) << 47) + var1)) * ((s64) comp->dig_p1) >> 33; + + if (var1 == 0) + return 0; + + p = ((((s64) 1048576 - adc_press) << 31) - var2) * 3125; + do_div(p, var1); + var1 = (((s64) comp->dig_p9) * (p >> 13) * (p >> 13)) >> 25; + var2 = (((s64) comp->dig_p8) * p) >> 19; + p = ((p + var1 + var2) >> 8) + (((s64) comp->dig_p7) << 4); + + return (u32) p; +} + +static int bmp280_read_temp(struct bmp280_data *data, + int *val) +{ + int ret; + __be32 tmp = 0; + s32 adc_temp, comp_temp; + struct bmp280_comp_temp comp; + + ret = bmp280_read_compensation_temp(data, &comp); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB, + (u8 *) &tmp, 3); + if (ret < 0) { + dev_err(&data->client->dev, "failed to read temperature\n"); + return ret; + } + + adc_temp = be32_to_cpu(tmp) >> 12; + comp_temp = bmp280_compensate_temp(data, &comp, adc_temp); + + /* + * val might be NULL if we're called by the read_press routine, + * who only cares about the carry over t_fine value. + */ + if (val) { + *val = comp_temp * 10; + return IIO_VAL_INT; + } + + return 0; +} + +static int bmp280_read_press(struct bmp280_data *data, + int *val, int *val2) +{ + int ret; + __be32 tmp = 0; + s32 adc_press; + u32 comp_press; + struct bmp280_comp_press comp; + + ret = bmp280_read_compensation_press(data, &comp); + if (ret < 0) + return ret; + + /* Read and compensate temperature so we get a reading of t_fine. */ + ret = bmp280_read_temp(data, NULL); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, + (u8 *) &tmp, 3); + if (ret < 0) { + dev_err(&data->client->dev, "failed to read pressure\n"); + return ret; + } + + adc_press = be32_to_cpu(tmp) >> 12; + comp_press = bmp280_compensate_press(data, &comp, adc_press); + + *val = comp_press / 256000; + *val2 = comp_press * 1000000 / 256000; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int bmp280_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + int ret; + struct bmp280_data *data = iio_priv(indio_dev); + + mutex_lock(&data->lock); + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + switch (chan->type) { + case IIO_PRESSURE: + ret = bmp280_read_press(data, val, val2); + break; + case IIO_TEMP: + ret = bmp280_read_temp(data, val); + break; + default: + ret = -EINVAL; + break; + } + break; + default: + ret = -EINVAL; + break; + } + + mutex_unlock(&data->lock); + + return ret; +} + +static const struct iio_info bmp280_info = { + .driver_module = THIS_MODULE, + .read_raw = &bmp280_read_raw, +}; + +static int bmp280_chip_init(struct bmp280_data *data) +{ + int ret; + + ret = regmap_update_bits(data->regmap, BMP280_REG_CTRL_MEAS, + BMP280_OSRS_TEMP_MASK | + BMP280_OSRS_PRESS_MASK | + BMP280_MODE_MASK, + BMP280_OSRS_TEMP_2X | + BMP280_OSRS_PRESS_16X | + BMP280_MODE_NORMAL); + if (ret < 0) { + dev_err(&data->client->dev, + "failed to write config register\n"); + return ret; + } + + ret = regmap_update_bits(data->regmap, BMP280_REG_CONFIG, + BMP280_FILTER_MASK, + BMP280_FILTER_4X); + if (ret < 0) { + dev_err(&data->client->dev, + "failed to write config register\n"); + return ret; + } + + return ret; +} + +static int bmp280_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct iio_dev *indio_dev; + struct bmp280_data *data; + unsigned int chip_id; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + i2c_set_clientdata(client, indio_dev); + data = iio_priv(indio_dev); + mutex_init(&data->lock); + data->client = client; + + indio_dev->dev.parent = &client->dev; + indio_dev->name = id->name; + indio_dev->channels = bmp280_channels; + indio_dev->num_channels = ARRAY_SIZE(bmp280_channels); + indio_dev->info = &bmp280_info; + indio_dev->modes = INDIO_DIRECT_MODE; + + data->regmap = devm_regmap_init_i2c(client, &bmp280_regmap_config); + if (IS_ERR(data->regmap)) { + dev_err(&client->dev, "failed to allocate register map\n"); + return PTR_ERR(data->regmap); + } + + ret = regmap_read(data->regmap, BMP280_REG_ID, &chip_id); + if (ret < 0) + return ret; + if (chip_id != BMP280_CHIP_ID) { + dev_err(&client->dev, "bad chip id. expected %x got %x\n", + BMP280_CHIP_ID, chip_id); + return -EINVAL; + } + + ret = bmp280_chip_init(data); + if (ret < 0) + return ret; + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct acpi_device_id bmp280_acpi_match[] = { + {"BMP0280", 0}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, bmp280_acpi_match); + +static const struct i2c_device_id bmp280_id[] = { + {"bmp280", 0}, + { }, +}; +MODULE_DEVICE_TABLE(i2c, bmp280_id); + +static struct i2c_driver bmp280_driver = { + .driver = { + .name = "bmp280", + .acpi_match_table = ACPI_PTR(bmp280_acpi_match), + }, + .probe = bmp280_probe, + .id_table = bmp280_id, +}; +module_i2c_driver(bmp280_driver); + +MODULE_AUTHOR("Vlad Dogaru "); +MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP280 pressure and temperature sensor"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3-59-g8ed1b From 0a9858689017544743708b332c6b7a54df10b6fe Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Wed, 22 Oct 2014 15:30:40 +0200 Subject: staging: vt6655: wcmd.c: fix print priority warning This patch fixes the following warning generated by checkpatch.pl for the file wcmd.c WARNING: printk() should include KERN_ facility level printk was replaced by netdev_err since providing printk with the facility level KERN_ERR generated the printing priority warning. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wcmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 985e1b99362d..7302196eda03 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -665,7 +665,8 @@ vCommandTimer( add_timer(&pDevice->sTimerTxData); } else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) { - printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n"); + netdev_err(pDevice->dev, + "WLAN_ASSOCIATE_WAIT:Association Fail???\n"); } else if (pDevice->byLinkWaitCount <= 4) { //mike add:wait another 2 sec if associated_frame delay! pDevice->byLinkWaitCount++; pr_debug("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); -- cgit v1.2.3-59-g8ed1b From 36beff6e20740e055c11ec87d9f41ea54a842db5 Mon Sep 17 00:00:00 2001 From: Somya Anand Date: Wed, 22 Oct 2014 17:24:03 +0530 Subject: Staging: dgnc: Remove unused sniff code The output written by dgnc_sniff_nowait_nolock() is never used anywhere since commit 35cf90459312f ("staging: dgnc: removes proc code") deleted the code that used to copy it to user space. dgnc_sniff_nowait_nolock() uses 'timeval' to create header timestamps for the data dump. 32-bit systems using 'struct timeval' will break in the year 2038, This patch removes dgnc_sniff_nowait_nolock() and all ch_sniff_* members of struct channel_t defined in "dgnc_driver.h". It also removes their usage from the driver files and hence y2038 issue is also resolved. Signed-off-by: Somya Anand Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 4 -- drivers/staging/dgnc/dgnc_driver.h | 14 ---- drivers/staging/dgnc/dgnc_neo.c | 3 - drivers/staging/dgnc/dgnc_tty.c | 127 ------------------------------------- drivers/staging/dgnc/dgnc_tty.h | 2 - 5 files changed, 150 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index c1c4bb9b0354..360fe258946d 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -918,8 +918,6 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch) ch->ch_equeue[head] = linestatus & (UART_LSR_BI | UART_LSR_PE | UART_LSR_FE); ch->ch_rqueue[head] = readb(&ch->ch_cls_uart->txrx); - dgnc_sniff_nowait_nolock(ch, "UART READ", - ch->ch_rqueue + head, 1); qleft--; @@ -1086,8 +1084,6 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch) ch->ch_tun.un_flags |= (UN_EMPTY); } writeb(ch->ch_wqueue[ch->ch_w_tail], &ch->ch_cls_uart->txrx); - dgnc_sniff_nowait_nolock(ch, "UART WRITE", - ch->ch_wqueue + ch->ch_w_tail, 1); ch->ch_w_tail++; ch->ch_w_tail &= WQUEUEMASK; ch->ch_txcount++; diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index d5de3e2f2945..695c3c6d3233 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -123,8 +123,6 @@ #define _POSIX_VDISABLE '\0' #endif -#define SNIFF_MAX 65536 /* Sniff buffer size (2^n) */ -#define SNIFF_MASK (SNIFF_MAX - 1) /* Sniff wrap mask */ /* * All the possible states the driver can be while being loaded. @@ -331,13 +329,6 @@ struct un_t { #define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */ #define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */ -/* - * Definitions for ch_sniff_flags - */ -#define SNIFF_OPEN 0x1 -#define SNIFF_WAIT_DATA 0x2 -#define SNIFF_WAIT_SPACE 0x4 - /* Our Read/Error/Write queue sizes */ #define RQUEUEMASK 0x1FFF /* 8 K - 1 */ @@ -431,11 +422,6 @@ struct channel_t { struct proc_dir_entry *proc_entry_pointer; struct dgnc_proc_entry *dgnc_channel_table; - uint ch_sniff_in; - uint ch_sniff_out; - char *ch_sniff_buf; /* Sniff buffer for proc */ - ulong ch_sniff_flags; /* Channel flags */ - wait_queue_head_t ch_sniff_wait; }; /* diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 27a525ead878..cc6136418071 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -1217,7 +1217,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) /* Copy data from uart to the queue */ memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, n); - dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, n); /* * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed @@ -1303,7 +1302,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1); ch->ch_equeue[head] = (unsigned char) linestatus; - dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, 1); /* Ditch any remaining linestatus value. */ linestatus = 0; @@ -1556,7 +1554,6 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) } memcpy_toio(&ch->ch_neo_uart->txrxburst, ch->ch_wqueue + tail, s); - dgnc_sniff_nowait_nolock(ch, "UART WRITE", ch->ch_wqueue + tail, s); /* Add and flip queue if needed */ tail = (tail + s) & WQUEUEMASK; diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index b0fcbe7bdfe4..8384e3d770f1 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -49,7 +49,6 @@ #include /* For udelay */ #include /* For copy_from_user/copy_to_user */ #include - #include "dgnc_driver.h" #include "dgnc_tty.h" #include "dgnc_types.h" @@ -374,7 +373,6 @@ int dgnc_tty_init(struct dgnc_board *brd) init_waitqueue_head(&ch->ch_flags_wait); init_waitqueue_head(&ch->ch_tun.un_flags_wait); init_waitqueue_head(&ch->ch_pun.un_flags_wait); - init_waitqueue_head(&ch->ch_sniff_wait); { struct device *classp; @@ -449,127 +447,6 @@ void dgnc_tty_uninit(struct dgnc_board *brd) #define TMPBUFLEN (1024) -/* - * dgnc_sniff - Dump data out to the "sniff" buffer if the - * proc sniff file is opened... - */ -void dgnc_sniff_nowait_nolock(struct channel_t *ch, unsigned char *text, unsigned char *buf, int len) -{ - struct timeval tv; - int n; - int r; - int nbuf; - int i; - int tmpbuflen; - char *tmpbuf; - char *p; - int too_much_data; - - tmpbuf = kzalloc(TMPBUFLEN, GFP_ATOMIC); - if (!tmpbuf) - return; - p = tmpbuf; - - /* Leave if sniff not open */ - if (!(ch->ch_sniff_flags & SNIFF_OPEN)) - goto exit; - - 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) - goto exit; - - /* - * 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); - -exit: - kfree(tmpbuf); -} - - /*======================================================================= * * dgnc_wmove - Write data to transmit queue. @@ -784,8 +661,6 @@ void dgnc_input(struct channel_t *ch) tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); } - dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); - tail += s; n -= s; /* Flip queue if needed */ @@ -1981,7 +1856,6 @@ static int dgnc_tty_write(struct tty_struct *tty, if (n >= remain) { n -= remain; memcpy(ch->ch_wqueue + head, buf, remain); - dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain); head = 0; buf += remain; } @@ -1992,7 +1866,6 @@ static int dgnc_tty_write(struct tty_struct *tty, */ remain = n; memcpy(ch->ch_wqueue + head, buf, remain); - dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain); head += remain; } diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h index 58eef257c2ec..3975f0407143 100644 --- a/drivers/staging/dgnc/dgnc_tty.h +++ b/drivers/staging/dgnc/dgnc_tty.h @@ -37,6 +37,4 @@ void dgnc_carrier(struct channel_t *ch); void dgnc_wakeup_writes(struct channel_t *ch); void dgnc_check_queue_flow_control(struct channel_t *ch); -void dgnc_sniff_nowait_nolock(struct channel_t *ch, unsigned char *text, unsigned char *buf, int nbuf); - #endif -- cgit v1.2.3-59-g8ed1b From 0a6e2170dfcd2b17ae32ad91993edf2b77014137 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Wed, 22 Oct 2014 16:50:17 +0300 Subject: staging: iio: iio_event_monitor: Add support for missing IIO modifiers This patch adds the missing IIO modifiers in event_is_known function and iio_modifier_names vector. Additionally, it removes duplicate name entries of IIO_MOD_LIGHT_BOTH and IIO_MOD_LIGHT_IR in iio_modifier_names. Signed-off-by: Roberta Dobrescu Reviewed-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- .../staging/iio/Documentation/iio_event_monitor.c | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c index 569d6f8face5..940ed2399e73 100644 --- a/drivers/staging/iio/Documentation/iio_event_monitor.c +++ b/drivers/staging/iio/Documentation/iio_event_monitor.c @@ -69,16 +69,29 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_X] = "x", [IIO_MOD_Y] = "y", [IIO_MOD_Z] = "z", + [IIO_MOD_X_AND_Y] = "x&y", + [IIO_MOD_X_AND_Z] = "x&z", + [IIO_MOD_Y_AND_Z] = "y&z", + [IIO_MOD_X_AND_Y_AND_Z] = "x&y&z", + [IIO_MOD_X_OR_Y] = "x|y", + [IIO_MOD_X_OR_Z] = "x|z", + [IIO_MOD_Y_OR_Z] = "y|z", + [IIO_MOD_X_OR_Y_OR_Z] = "x|y|z", [IIO_MOD_LIGHT_BOTH] = "both", [IIO_MOD_LIGHT_IR] = "ir", [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)", [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2", - [IIO_MOD_LIGHT_BOTH] = "both", - [IIO_MOD_LIGHT_IR] = "ir", [IIO_MOD_LIGHT_CLEAR] = "clear", [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION] = "quaternion", + [IIO_MOD_TEMP_AMBIENT] = "ambient", + [IIO_MOD_TEMP_OBJECT] = "object", + [IIO_MOD_NORTH_MAGN] = "from_north_magnetic", + [IIO_MOD_NORTH_TRUE] = "from_north_true", + [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", + [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", }; static bool event_is_known(struct iio_event_data *event) @@ -118,6 +131,14 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_X: case IIO_MOD_Y: case IIO_MOD_Z: + case IIO_MOD_X_AND_Y: + case IIO_MOD_X_AND_Z: + case IIO_MOD_Y_AND_Z: + case IIO_MOD_X_AND_Y_AND_Z: + case IIO_MOD_X_OR_Y: + case IIO_MOD_X_OR_Z: + case IIO_MOD_Y_OR_Z: + case IIO_MOD_X_OR_Y_OR_Z: case IIO_MOD_LIGHT_BOTH: case IIO_MOD_LIGHT_IR: case IIO_MOD_ROOT_SUM_SQUARED_X_Y: @@ -126,6 +147,13 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_LIGHT_RED: case IIO_MOD_LIGHT_GREEN: case IIO_MOD_LIGHT_BLUE: + case IIO_MOD_QUATERNION: + case IIO_MOD_TEMP_AMBIENT: + case IIO_MOD_TEMP_OBJECT: + case IIO_MOD_NORTH_MAGN: + case IIO_MOD_NORTH_TRUE: + case IIO_MOD_NORTH_MAGN_TILT_COMP: + case IIO_MOD_NORTH_TRUE_TILT_COMP: break; default: return false; -- cgit v1.2.3-59-g8ed1b From 0951252522bfdb71f35bc4ea99c0739bb883c4ca Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Mon, 20 Oct 2014 10:40:22 +0530 Subject: Staging: lustre: lnet: Make functions static This patch makes functions proc_lnet_routes, proc_lnet_routers, proc_lnet_peers and proc_lnet_nis static in file router_proc.c as they are used only in this file. This problem is detected by sparse. Signed-off-by: Vaishali Thakkar Reviewed-by: Josh Triplett Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/router_proc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 6e8f7e2bbcfc..d9645f6bce49 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -164,8 +164,8 @@ static int proc_lnet_stats(struct ctl_table *table, int write, __proc_lnet_stats); } -int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +static int proc_lnet_routes(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpsiz = 256; char *tmpstr; @@ -290,8 +290,8 @@ int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, return rc; } -int proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +static int proc_lnet_routers(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int rc = 0; char *tmpstr; @@ -425,8 +425,8 @@ int proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, return rc; } -int proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +static int proc_lnet_peers(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { const int tmpsiz = 256; struct lnet_peer_table *ptable; @@ -657,8 +657,8 @@ static int proc_lnet_buffers(struct ctl_table *table, int write, __proc_lnet_buffers); } -int proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) +static int proc_lnet_nis(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int tmpsiz = 128 * LNET_CPT_NUMBER; int rc = 0; -- cgit v1.2.3-59-g8ed1b From 38d676da615ac1a0b37572ac31ac8c7573f7dcfd Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Mon, 20 Oct 2014 13:58:35 +0530 Subject: Staging: lustre: Remove typedef ldlm_ns_hash_def_t The linux kernel coding style guidelines suggest not using typedefs for structure types. This patch gets rid of the typedef for ldlm_ns_hash_def_t. Also, the name of the struct is changed to drop the _t, to make the name look less typedef-like. This is done using Coccinelle. Semantic patch used to detect this case is as follows: @tn1@ type td; @@ typedef struct { ... } td; @script:python tf@ td << tn1.td; tdres; @@ coccinelle.tdres = td; @@ type tn1.td; identifier tf.tdres; @@ -typedef struct + tdres { ... } -td ; @@ type tn1.td; identifier tf.tdres; @@ -td + struct tdres Signed-off-by: Vaishali Thakkar Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index a785b7a7d1b3..8b20a838b7f2 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -501,7 +501,7 @@ cfs_hash_ops_t ldlm_ns_fid_hash_ops = { .hs_put = ldlm_res_hop_put }; -typedef struct { +struct ldlm_ns_hash_def { ldlm_ns_type_t nsd_type; /** hash bucket bits */ unsigned nsd_bkt_bits; @@ -509,9 +509,9 @@ typedef struct { unsigned nsd_all_bits; /** hash operations */ cfs_hash_ops_t *nsd_hops; -} ldlm_ns_hash_def_t; +}; -ldlm_ns_hash_def_t ldlm_ns_hash_defs[] = { +struct ldlm_ns_hash_def ldlm_ns_hash_defs[] = { { .nsd_type = LDLM_NS_TYPE_MDC, .nsd_bkt_bits = 11, @@ -563,7 +563,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, { struct ldlm_namespace *ns = NULL; struct ldlm_ns_bucket *nsb; - ldlm_ns_hash_def_t *nsd; + struct ldlm_ns_hash_def *nsd; struct cfs_hash_bd bd; int idx; int rc; -- cgit v1.2.3-59-g8ed1b From abb368abf76059e07967808ef5da9f32d2b760ae Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Mon, 20 Oct 2014 19:52:03 +0800 Subject: staging: lustre: lustre: obdecho: expand the GOTO macro in echo_client.c The GOTO macro is not standard in Linux. The following Coccinelle semantic patch was used to expand the GOTO macro. @@ identifier lbl; identifier rc; constant c; @@ - GOTO(lbl,\(rc\|c\)); + goto lbl; @@ identifier lbl; expression rc; @@ - GOTO(lbl,rc); + rc; + goto lbl; Signed-off-by: Jiayi Ye Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/obdecho/echo_client.c | 137 +++++++++++++-------- 1 file changed, 84 insertions(+), 53 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 98e4290919d0..a6ad87557512 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -698,14 +698,16 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, int cleanup = 0; OBD_ALLOC_PTR(ed); - if (ed == NULL) - GOTO(out, rc = -ENOMEM); + if (ed == NULL) { + rc = -ENOMEM; + goto out; + } cleanup = 1; cd = &ed->ed_cl; rc = cl_device_init(cd, t); if (rc) - GOTO(out, rc); + goto out; cd->cd_lu_dev.ld_ops = &echo_device_lu_ops; cd->cd_ops = &echo_device_cl_ops; @@ -719,24 +721,26 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, if (tgt == NULL) { CERROR("Can not find tgt device %s\n", lustre_cfg_string(cfg, 1)); - GOTO(out, rc = -ENODEV); + rc = -ENODEV; + goto out; } next = tgt->obd_lu_dev; if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) { CERROR("echo MDT client must be run on server\n"); - GOTO(out, rc = -EOPNOTSUPP); + rc = -EOPNOTSUPP; + goto out; } rc = echo_site_init(env, ed); if (rc) - GOTO(out, rc); + goto out; cleanup = 3; rc = echo_client_setup(env, obd, cfg); if (rc) - GOTO(out, rc); + goto out; ed->ed_ec = &obd->u.echo_client; cleanup = 4; @@ -749,15 +753,17 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, tgt_type_name = tgt->obd_type->typ_name; if (next != NULL) { LASSERT(next != NULL); - if (next->ld_site != NULL) - GOTO(out, rc = -EBUSY); + if (next->ld_site != NULL) { + rc = -EBUSY; + goto out; + } next->ld_site = &ed->ed_site->cs_lu; rc = next->ld_type->ldt_ops->ldto_device_init(env, next, next->ld_type->ldt_name, NULL); if (rc) - GOTO(out, rc); + goto out; /* Tricky case, I have to determine the obd type since * CLIO uses the different parameters to initialize @@ -968,15 +974,19 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, fid = &info->eti_fid; rc = ostid_to_fid(fid, &lsm->lsm_oi, 0); - if (rc != 0) - GOTO(out, eco = ERR_PTR(rc)); + if (rc != 0) { + eco = ERR_PTR(rc); + goto out; + } /* In the function below, .hs_keycmp resolves to * lu_obj_hop_keycmp() */ /* coverity[overrun-buffer-val] */ obj = cl_object_find(env, echo_dev2cl(d), fid, &conf->eoc_cl); - if (IS_ERR(obj)) - GOTO(out, eco = (void *)obj); + if (IS_ERR(obj)) { + eco = (void *)obj; + goto out; + } eco = cl2echo_obj(obj); if (eco->eo_deleted) { @@ -1076,7 +1086,7 @@ static int cl_echo_enqueue(struct echo_object *eco, u64 start, u64 end, io->ci_ignore_layout = 1; result = cl_io_init(env, io, CIT_MISC, echo_obj2cl(eco)); if (result < 0) - GOTO(out, result); + goto out; LASSERT(result == 0); result = cl_echo_enqueue0(env, eco, start, end, mode, cookie, 0); @@ -1182,7 +1192,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, io->ci_ignore_layout = 1; rc = cl_io_init(env, io, CIT_MISC, obj); if (rc < 0) - GOTO(out, rc); + goto out; LASSERT(rc == 0); @@ -1191,7 +1201,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, rw == READ ? LCK_PR : LCK_PW, &lh.cookie, CEF_NEVER); if (rc < 0) - GOTO(error_lock, rc); + goto error_lock; for (i = 0; i < npages; i++) { LASSERT(pages[i]); @@ -1318,7 +1328,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, rc = echo_alloc_memmd(ed, &lsm); if (rc < 0) { CERROR("Cannot allocate md: rc = %d\n", rc); - GOTO(failed, rc); + goto failed; } if (ulsm != NULL) { @@ -1326,7 +1336,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, rc = echo_copyin_lsm (ed, lsm, ulsm, ulsm_nob); if (rc != 0) - GOTO(failed, rc); + goto failed; if (lsm->lsm_stripe_count == 0) lsm->lsm_stripe_count = ec->ec_nstripes; @@ -1363,7 +1373,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, rc = obd_create(env, ec->ec_exp, oa, &lsm, oti); if (rc != 0) { CERROR("Cannot create objects: rc = %d\n", rc); - GOTO(failed, rc); + goto failed; } created = 1; } @@ -1373,8 +1383,10 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, oa->o_valid |= OBD_MD_FLID; eco = cl_echo_object_find(ed, &lsm); - if (IS_ERR(eco)) - GOTO(failed, rc = PTR_ERR(eco)); + if (IS_ERR(eco)) { + rc = PTR_ERR(eco); + goto failed; + } cl_echo_object_put(eco); CDEBUG(D_INFO, "oa oid "DOSTID"\n", POSTID(&oa->o_oi)); @@ -1642,8 +1654,10 @@ static int echo_client_prep_commit(const struct lu_env *env, OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local)); OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote)); - if (lnb == NULL || rnb == NULL) - GOTO(out, ret = -ENOMEM); + if (lnb == NULL || rnb == NULL) { + ret = -ENOMEM; + goto out; + } if (rw == OBD_BRW_WRITE && async) brw_flags |= OBD_BRW_ASYNC; @@ -1671,7 +1685,7 @@ static int echo_client_prep_commit(const struct lu_env *env, ret = obd_preprw(env, rw, exp, oa, 1, &ioo, rnb, &lpages, lnb, oti, NULL); if (ret != 0) - GOTO(out, ret); + goto out; LASSERT(lpages == npages); for (i = 0; i < lpages; i++) { @@ -1704,7 +1718,7 @@ static int echo_client_prep_commit(const struct lu_env *env, ret = obd_commitrw(env, rw, exp, oa, 1, &ioo, rnb, npages, lnb, oti, ret); if (ret != 0) - GOTO(out, ret); + goto out; /* Reset oti otherwise it would confuse ldiskfs. */ memset(oti, 0, sizeof(*oti)); @@ -1862,21 +1876,27 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, return -ENOMEM; rc = lu_env_init(env, LCT_DT_THREAD); - if (rc) - GOTO(out, rc = -ENOMEM); + if (rc) { + rc = -ENOMEM; + goto out; + } switch (cmd) { case OBD_IOC_CREATE: /* may create echo object */ - if (!capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); + if (!capable(CFS_CAP_SYS_ADMIN)) { + rc = -EPERM; + goto out; + } rc = echo_create_object(env, ed, 1, oa, data->ioc_pbuf1, data->ioc_plen1, &dummy_oti); - GOTO(out, rc); + goto out; case OBD_IOC_DESTROY: - if (!capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); + if (!capable(CFS_CAP_SYS_ADMIN)) { + rc = -EPERM; + goto out; + } rc = echo_get_object(&eco, ed, oa); if (rc == 0) { @@ -1886,7 +1906,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, eco->eo_deleted = 1; echo_put_object(eco); } - GOTO(out, rc); + goto out; case OBD_IOC_GETATTR: rc = echo_get_object(&eco, ed, oa); @@ -1897,11 +1917,13 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = obd_getattr(env, ec->ec_exp, &oinfo); echo_put_object(eco); } - GOTO(out, rc); + goto out; case OBD_IOC_SETATTR: - if (!capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); + if (!capable(CFS_CAP_SYS_ADMIN)) { + rc = -EPERM; + goto out; + } rc = echo_get_object(&eco, ed, oa); if (rc == 0) { @@ -1912,17 +1934,19 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = obd_setattr(env, ec->ec_exp, &oinfo, NULL); echo_put_object(eco); } - GOTO(out, rc); + goto out; case OBD_IOC_BRW_WRITE: - if (!capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); + if (!capable(CFS_CAP_SYS_ADMIN)) { + rc = -EPERM; + goto out; + } rw = OBD_BRW_WRITE; /* fall through */ case OBD_IOC_BRW_READ: rc = echo_client_brw_ioctl(env, rw, exp, data, &dummy_oti); - GOTO(out, rc); + goto out; case ECHO_IOC_GET_STRIPE: rc = echo_get_object(&eco, ed, oa); @@ -1931,11 +1955,13 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, data->ioc_plen1); echo_put_object(eco); } - GOTO(out, rc); + goto out; case ECHO_IOC_SET_STRIPE: - if (!capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); + if (!capable(CFS_CAP_SYS_ADMIN)) { + rc = -EPERM; + goto out; + } if (data->ioc_pbuf1 == NULL) { /* unset */ rc = echo_get_object(&eco, ed, oa); @@ -1948,25 +1974,28 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, data->ioc_pbuf1, data->ioc_plen1, &dummy_oti); } - GOTO (out, rc); + goto out; case ECHO_IOC_ENQUEUE: - if (!capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); + if (!capable(CFS_CAP_SYS_ADMIN)) { + rc = -EPERM; + goto out; + } rc = echo_client_enqueue(exp, oa, data->ioc_conn1, /* lock mode */ data->ioc_offset, data->ioc_count);/*extent*/ - GOTO (out, rc); + goto out; case ECHO_IOC_CANCEL: rc = echo_client_cancel(exp, oa); - GOTO (out, rc); + goto out; default: CERROR ("echo_ioctl(): unrecognised ioctl %#x\n", cmd); - GOTO (out, rc = -ENOTTY); + rc = -ENOTTY; + goto out; } out: @@ -2084,11 +2113,13 @@ static int echo_client_disconnect(struct obd_export *exp) { int rc; - if (exp == NULL) - GOTO(out, rc = -EINVAL); + if (exp == NULL) { + rc = -EINVAL; + goto out; + } rc = class_disconnect(exp); - GOTO(out, rc); + goto out; out: return rc; } -- cgit v1.2.3-59-g8ed1b From 57303e76c2251abf7d67f1afde30f861a93a49ff Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Tue, 21 Oct 2014 22:13:21 -0700 Subject: staging: lustre: Fix checkpatch.pl spacing-related errors This patch fixes misc. spacing errors reported by checkpatch.pl for lustre/llite/file.c Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index f1f75c7edee0..a5acc98a1c99 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -247,7 +247,7 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode) return 0; } - och=*och_p; + och = *och_p; *och_p = NULL; mutex_unlock(&lli->lli_och_mutex); @@ -297,7 +297,8 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode, __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK; struct lustre_handle lockh; struct inode *inode = file->f_dentry->d_inode; - ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}}; + ldlm_policy_data_t policy = { + .l_inodebits = {MDS_INODELOCK_OPEN} }; mutex_lock(&lli->lli_och_mutex); if (fd->fd_omode & FMODE_WRITE) { @@ -2866,7 +2867,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, struct lustre_handle *lockh, __u64 flags, ldlm_mode_t mode) { - ldlm_policy_data_t policy = { .l_inodebits = {bits}}; + ldlm_policy_data_t policy = { .l_inodebits = {bits} }; struct lu_fid *fid; ldlm_mode_t rc; -- cgit v1.2.3-59-g8ed1b From 0fa3b9d3542a76f192e4789352e5f8fafe8bc655 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Wed, 22 Oct 2014 11:29:26 -0700 Subject: staging: lustre: llite: Use kcalloc not kzalloc with mult This patch fixes the following checkpatch.pl warnings: WARNING: Prefer kcalloc over kzalloc with multiply 166: FILE: drivers/staging/lustre/lustre/llite/dir.c:166: page_pool = kzalloc(sizeof(page) * max_pages, GFP_NOFS); 796: FILE: drivers/staging/lustre/lustre/llite/lloop.c:796: loop_dev = kzalloc(max_loop * sizeof(*loop_dev), GFP_KERNEL); 800: FILE: drivers/staging/lustre/lustre/llite/lloop.c:800: disks = kzalloc(max_loop * sizeof(*disks), GFP_KERNEL); Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 2 +- drivers/staging/lustre/lustre/llite/lloop.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 9e8bfdcfe5a4..a07e0fe06207 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -163,7 +163,7 @@ static int ll_dir_filler(void *_hash, struct page *page0) LASSERT(max_pages > 0 && max_pages <= MD_MAX_BRW_PAGES); - page_pool = kzalloc(sizeof(page) * max_pages, GFP_NOFS); + page_pool = kcalloc(max_pages, sizeof(page), GFP_NOFS); if (page_pool) { page_pool[0] = page0; } else { diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 264e5ec3fed6..e0f39fec2787 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -793,11 +793,11 @@ static int __init lloop_init(void) if (ll_iocontrol_magic == NULL) goto out_mem1; - loop_dev = kzalloc(max_loop * sizeof(*loop_dev), GFP_KERNEL); + loop_dev = kcalloc(max_loop, sizeof(*loop_dev), GFP_KERNEL); if (!loop_dev) goto out_mem1; - disks = kzalloc(max_loop * sizeof(*disks), GFP_KERNEL); + disks = kcalloc(max_loop, sizeof(*disks), GFP_KERNEL); if (!disks) goto out_mem2; -- cgit v1.2.3-59-g8ed1b From 588bf52aa3a81c8f7171925c2e0e5bb79e4db4ee Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Wed, 22 Oct 2014 12:16:04 -0700 Subject: Staging: lustre: llite: Remove C99 '//' comments This patch fixes the following checkpatch.pl errors: ERROR: do not use C99 // comments 538: FILE: drivers/staging/lustre/lustre/llite/rw26.c:538: // .orig_aops.readpages = ll_readpages, 816: FILE: drivers/staging/lustre/lustre/llite/lproc_llite.c:816: //{ "mntpt_path", ll_rd_path, 0, 0 }, 826: FILE: drivers/staging/lustre/lustre/llite/lproc_llite.c:826: //{ "filegroups", lprocfs_rd_filegroups, 0, 0 }, Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++-- drivers/staging/lustre/lustre/llite/rw26.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 3b3df9f03422..f175c59dc166 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -813,7 +813,7 @@ LPROC_SEQ_FOPS(ll_xattr_cache); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "uuid", &ll_sb_uuid_fops, NULL, 0 }, - //{ "mntpt_path", ll_rd_path, 0, 0 }, + /* { "mntpt_path", ll_rd_path, 0, 0 }, */ { "fstype", &ll_fstype_fops, NULL, 0 }, { "site", &ll_site_stats_fops, NULL, 0 }, { "blocksize", &ll_blksize_fops, NULL, 0 }, @@ -823,7 +823,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "filestotal", &ll_filestotal_fops, NULL, 0 }, { "filesfree", &ll_filesfree_fops, NULL, 0 }, { "client_type", &ll_client_type_fops, NULL, 0 }, - //{ "filegroups", lprocfs_rd_filegroups, 0, 0 }, + /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL }, { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops, NULL }, diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index eac2131e6b85..14441b4df9b5 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -535,7 +535,7 @@ const struct address_space_operations ll_aops = { #else const struct address_space_operations_ext ll_aops = { .orig_aops.readpage = ll_readpage, -// .orig_aops.readpages = ll_readpages, +/* .orig_aops.readpages = ll_readpages, */ .orig_aops.direct_IO = ll_direct_IO_26, .orig_aops.writepage = ll_writepage, .orig_aops.writepages = ll_writepages, -- cgit v1.2.3-59-g8ed1b From 907cd2485b828deea069b100b6852ea0e54829da Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Wed, 22 Oct 2014 12:28:49 -0700 Subject: Staging: lustre: llite: Use () around long macro This patch fixes the following checkpatch.pl error: "Macros with complex values should be enclosed in parentheses." Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/rw26.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 14441b4df9b5..2f21304046aa 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -183,7 +183,7 @@ static int ll_set_page_dirty(struct page *vmpage) return __set_page_dirty_nobuffers(vmpage); } -#define MAX_DIRECTIO_SIZE 2*1024*1024*1024UL +#define MAX_DIRECTIO_SIZE (2*1024*1024*1024UL) static inline int ll_get_user_pages(int rw, unsigned long user_addr, size_t size, struct page ***pages, -- cgit v1.2.3-59-g8ed1b From 464289d876ba6774972ecb277dad4b104e565fbe Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Wed, 22 Oct 2014 13:21:40 -0700 Subject: Staging: lustre: libcfs: Fix switch-case indent This patch fixes the following checkpatch error:j ERROR: switch and case should be at the same indent 105: FILE: drivers/staging/lustre/lustre/libcfs/fail.c:105: Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/fail.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c index e73ca3df9734..92444b0fe2a3 100644 --- a/drivers/staging/lustre/lustre/libcfs/fail.c +++ b/drivers/staging/lustre/lustre/libcfs/fail.c @@ -103,18 +103,18 @@ int __cfs_fail_check_set(__u32 id, __u32 value, int set) } switch (set) { - case CFS_FAIL_LOC_NOSET: - case CFS_FAIL_LOC_VALUE: - break; - case CFS_FAIL_LOC_ORSET: - cfs_fail_loc |= value & ~(CFS_FAILED | CFS_FAIL_ONCE); - break; - case CFS_FAIL_LOC_RESET: - cfs_fail_loc = value; - break; - default: - LASSERTF(0, "called with bad set %u\n", set); - break; + case CFS_FAIL_LOC_NOSET: + case CFS_FAIL_LOC_VALUE: + break; + case CFS_FAIL_LOC_ORSET: + cfs_fail_loc |= value & ~(CFS_FAILED | CFS_FAIL_ONCE); + break; + case CFS_FAIL_LOC_RESET: + cfs_fail_loc = value; + break; + default: + LASSERTF(0, "called with bad set %u\n", set); + break; } return 1; -- cgit v1.2.3-59-g8ed1b From 2a80f844158b9b5327a159dc9c0fa6b676d2bd9d Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Wed, 22 Oct 2014 13:39:11 -0700 Subject: Staging: lustre: llite: Declare ptr args correctly This patch fixes the following checkpatch errors: ERROR: "foo * bar" should be "foo *bar" 951: FILE: drivers/staging/lustre/lustre/llite/namei.c:951: static void ll_get_child_fid(struct inode * dir, struct qstr *name, 1193: FILE: drivers/staging/lustre/lustre/llite/namei.c:1193: static int ll_unlink(struct inode * dir, struct dentry *dentry) Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 7a68c1e027e0..2971a26370be 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -948,7 +948,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, /* Try to find the child dentry by its name. If found, put the result fid into @fid. */ -static void ll_get_child_fid(struct inode * dir, struct qstr *name, +static void ll_get_child_fid(struct inode *dir, struct qstr *name, struct lu_fid *fid) { struct dentry *parent, *child; @@ -1190,7 +1190,7 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode, old_encode_dev(rdev), dchild); } -static int ll_unlink(struct inode * dir, struct dentry *dentry) +static int ll_unlink(struct inode *dir, struct dentry *dentry) { return ll_unlink_generic(dir, NULL, dentry, &dentry->d_name); } -- cgit v1.2.3-59-g8ed1b From c8cb5f2c780a6003fcf76eb3ac1675fbb090ecd8 Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Mon, 20 Oct 2014 14:04:55 +0800 Subject: staging: rtl8188eu: core: fixed msleep < 20ms can sleep for up to 20ms warning in rtw_efuse.c This patch fixes following checkpatch.pl warning: WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt Signed-off-by: Jiayi Ye Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 7006088d1ad0..e037c43c2837 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -250,7 +250,7 @@ static void efuse_read_phymap_from_txpktbuf( while (!(reg_0x143 = usb_read8(adapter, REG_TXPKTBUF_DBG)) && (passing_time = rtw_get_passing_time_ms(start)) < 1000) { DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, usb_read8(adapter, 0x106)); - msleep(1); + usleep_range(1000, 2000); } lo32 = usb_read32(adapter, REG_PKTBUF_DBG_DATA_L); -- cgit v1.2.3-59-g8ed1b From b312fb06b50b2aed3e75527fa74bc475dfb57cd6 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 21 Oct 2014 09:48:01 +0530 Subject: staging: rtl8188eu: os_dep: Remove useless cast on kzalloc Casting rhe return value which is a void pointer is redundant. The conversion from void pointer to any other pointer type is guaranteed by the C programming language, as mentioned in Documentation/CodingStyle, Chap 14. Removed the cast on kzalloc return value. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/osdep_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 8af4a8d24cce..abcb3a8589ef 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -51,7 +51,7 @@ void *rtw_malloc2d(int h, int w, int size) { int j; - void **a = (void **)kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL); + void **a = kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL); if (a == NULL) { pr_info("%s: alloc memory fail!\n", __func__); return NULL; -- cgit v1.2.3-59-g8ed1b From 705515cdcdf972ad9df4d1a9874d0e94a3cad517 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 21 Oct 2014 09:48:20 +0530 Subject: staging: rtl8188eu: os_dep: Replaced kzalloc and memcpy with kmemdup Replaced calls to kzalloc followed by memcpy with a single call to kmemdup. Patch found using coccicheck. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index d598fec4abbf..d8605be07a71 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -512,14 +512,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } if (ielen) { - buf = kzalloc(ielen, GFP_KERNEL); + buf = kmemdup(pie, ielen, GFP_KERNEL); if (buf == NULL) { ret = -ENOMEM; goto exit; } - memcpy(buf, pie, ielen); - /* dump */ { int i; -- cgit v1.2.3-59-g8ed1b From 93164c03ae7144bc4d9593a962a9169e9675dc3f Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 20 Oct 2014 10:24:49 +0530 Subject: staging: ft1000: Remove parentheses from return arguments The sematic patch used for this is: // @@ identifier i; constant c; @@ return - ( \(i\|-i\|i(...)\|c\) - ) ; // Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 0f347ab0d300..5899c4eca41f 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -365,7 +365,7 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) /* DEBUG("ft1000_poll_dev called\n"); */ if (ft1000_flarion_cnt == 0) { DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n"); - return (-EBADF); + return -EBADF; } /* Search for matching file object */ @@ -379,7 +379,7 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) /* Could not find application info block */ if (i == MAX_NUM_APP) { DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); - return (-EACCES); + return -EACCES; } if (list_empty(&dev->app_info[i].app_sqlist) == 0) { @@ -433,7 +433,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, if (ft1000_flarion_cnt == 0) { DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n"); - return (-EBADF); + return -EBADF; } /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ @@ -541,15 +541,15 @@ static long ft1000_ioctl(struct file *file, unsigned int command, if (ft1000_flarion_cnt == 0) { - return (-EBADF); + return -EBADF; } if (ft1000dev->DrvMsgPend) { - return (-ENOTTY); + return -ENOTTY; } if (ft1000dev->fProvComplete == 0) { - return (-EACCES); + return -EACCES; } ft1000dev->fAppMsgPend = 1; @@ -678,7 +678,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ if (ft1000_flarion_cnt == 0) { - return (-EBADF); + return -EBADF; } /* Search for matching file object */ @@ -762,7 +762,7 @@ static int ft1000_release(struct inode *inode, struct file *file) if (ft1000_flarion_cnt == 0) { ft1000dev->appcnt--; - return (-EBADF); + return -EBADF; } /* Search for matching file object */ -- cgit v1.2.3-59-g8ed1b From 817c66c4f50d7b0abb3e33117777d8890ac70040 Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Mon, 20 Oct 2014 19:13:56 +0800 Subject: staging: ft1000: ft1000-pcmcia: removed unused variable in ft1000_hw.c Variable whose value is initialized but never used is unnecessary. The following Coccinelle semantic patch removed the unused variable. @e@ identifier i; position p; type T; @@ extern T i@p; @@ type T; identifier i; constant C; position p != e.p; @@ - T i@p; <+... when != i - i = C; ...+> Signed-off-by: Jiayi Ye Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 9574775ba3b5..a9bcb9e1af78 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -1270,7 +1270,6 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) u16 nxtph; u16 total_len; int i = 0; - int cnt; unsigned long flags; doorbell = ft1000_read_reg(dev, FT1000_REG_DOORBELL); @@ -1336,7 +1335,6 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) total_len); if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) { total_len += nxtph; - cnt = 0; /* * ft1000_read_reg will return a value that needs to be byteswap * in order to get DSP_QID_OFFSET. -- cgit v1.2.3-59-g8ed1b From 17fbab1ee9a3e5d2a070450a0c76a3434278bc96 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 22 Oct 2014 11:23:57 +0530 Subject: staging: android: Assign bool to true high is a bool type variable. bool variable should be assigned true, false not 1 or 0. This patch assigns high to true, replacing 1. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_page_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index 5864f3dfcbc6..4b88f11e52d3 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -120,7 +120,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, bool high; if (current_is_kswapd()) - high = 1; + high = true; else high = !!(gfp_mask & __GFP_HIGHMEM); -- cgit v1.2.3-59-g8ed1b From 2c1bfc3be0fc525d95ff5983bf8ea3f2aff24d1b Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Mon, 20 Oct 2014 16:58:10 +0530 Subject: staging: media: lirc: Delete unused function tv2int The function tv2int is used to convert timeval to int. 32-bit systems using 'struct timeval' will break in the year 2038, so we have to replace that code with more appropriate types. This patch changes the lirc_imon.c file of media: lirc driver. tv2int function is static and not used anywhere in this file too, so it is removed. I also build tested it. Signed-off-by: Tapasweni Pathak Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_imon.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index 7aca44f28c5a..e4cfbe34e56d 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -572,29 +572,6 @@ static void submit_data(struct imon_context *context) wake_up(&context->driver->rbuf->wait_poll); } -static inline int tv2int(const struct timeval *a, const struct timeval *b) -{ - int usecs = 0; - int sec = 0; - - if (b->tv_usec > a->tv_usec) { - usecs = 1000000; - sec--; - } - - usecs += a->tv_usec - b->tv_usec; - - sec += a->tv_sec - b->tv_sec; - sec *= 1000; - usecs /= 1000; - sec += usecs; - - if (sec < 0) - sec = 1000; - - return sec; -} - /** * Process the incoming packet */ -- cgit v1.2.3-59-g8ed1b From a5a89d7a84fa3198e2e39b29325a65c211a0397c Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 21 Oct 2014 09:48:58 +0530 Subject: staging: emxx_udc: Remove null check before kfree This patch was generated by the following semantic patch: // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 1ae0013fb118..77e4aee74fa1 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2722,8 +2722,7 @@ static void nbu2ss_ep_free_request( if (_req != NULL) { req = container_of(_req, struct nbu2ss_req, req); - if (req != NULL) - kfree(req); + kfree(req); } } -- cgit v1.2.3-59-g8ed1b From 029bf13814d46d66aecd18c20f0e0c278696c5dc Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Wed, 22 Oct 2014 11:35:21 +0530 Subject: staging: rtl8723au: Remove unnecessary else if Removed the unnecessary else if condition as it has only one comment inside it and do not have an FIXME or TODO comment near to it too. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index c567df6c6321..2f01714bc9e2 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -850,7 +850,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index, dot11PrivacyAlgrthm; } } - } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { /* adhoc mode */ } } -- cgit v1.2.3-59-g8ed1b From 8d02c02253457a1facf077d8d67aa350ac317878 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Tue, 21 Oct 2014 09:50:03 +0530 Subject: staging: unisys: visorutil: Remove null check before kfree This patch was generated by the following semantic patch: // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/procobjecttree.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c index c476036f7382..195772d22c9e 100644 --- a/drivers/staging/unisys/visorutil/procobjecttree.c +++ b/drivers/staging/unisys/visorutil/procobjecttree.c @@ -320,19 +320,18 @@ void visor_proc_DestroyObject(MYPROCOBJECT *obj) kfree(obj->procDirProperties); obj->procDirProperties = NULL; } - if (obj->procDirPropertyContexts != NULL) { - kfree(obj->procDirPropertyContexts); - obj->procDirPropertyContexts = NULL; - } + + kfree(obj->procDirPropertyContexts); + obj->procDirPropertyContexts = NULL; + if (obj->procDir != NULL) { if (obj->name != NULL) remove_proc_entry(obj->name, type->procDir); obj->procDir = NULL; } - if (obj->name != NULL) { - kfree(obj->name); - obj->name = NULL; - } + + kfree(obj->name); + obj->name = NULL; kfree(obj); } EXPORT_SYMBOL_GPL(visor_proc_DestroyObject); -- cgit v1.2.3-59-g8ed1b From 1002a240ed72f0535f01ca88e0341ccf7c4e0b54 Mon Sep 17 00:00:00 2001 From: Aybuke Ozdemir Date: Tue, 21 Oct 2014 01:39:34 +0300 Subject: staging: media: omap24xx: Use min_t instead of min MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch focuses on fixing the following warning generated by checkpatch.pl for the file tcm825x.c: WARNİNG: min() should probably be min_t(u32, tgt_xclk, TCM825X_XCLK_MAX) The changes were applied using the following coccinelle rule: @@ expression e1, e2; typedef u32; @@ -tgt_xclk = min(e1, (u32)e2); +tgt_xclk = min_t(u32, e1, e2); Signed-off-by: Aybuke Ozdemir Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/omap24xx/tcm825x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/omap24xx/tcm825x.c b/drivers/staging/media/omap24xx/tcm825x.c index 9d9ecf1fc4ae..6a1f47995a17 100644 --- a/drivers/staging/media/omap24xx/tcm825x.c +++ b/drivers/staging/media/omap24xx/tcm825x.c @@ -751,7 +751,7 @@ static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) (2457 * tgt_fps) / MAX_FPS; tgt_xclk *= 10000; - tgt_xclk = min(tgt_xclk, (u32)TCM825X_XCLK_MAX); + tgt_xclk = min_t(u32, tgt_xclk, TCM825X_XCLK_MAX); tgt_xclk = max(tgt_xclk, (u32)TCM825X_XCLK_MIN); p->u.bt656.clock_curr = tgt_xclk; -- cgit v1.2.3-59-g8ed1b From cb6c1ee3057ebb717fd4439711b3cb5354d5085f Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Tue, 21 Oct 2014 02:47:29 +0300 Subject: staging: wlan-ng: Fix restricted __be16 degrades to integer skb->protocol variable type is __be16 and in if condition it is comparing with ETH_P_80211_RAW constant variable which is not __be16 type. Using be16_to_cpu() function, value of skb->protocol converted native processor format. This bug was found by sparse. Signed-off-by: Ebru Akagunduz Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 2dd9bf8a6e18..a9c1e0bafa62 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -358,7 +358,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, * and return success . * TODO: we need a saner way to handle this */ - if (skb->protocol != ETH_P_80211_RAW) { + if (be16_to_cpu(skb->protocol) != ETH_P_80211_RAW) { netif_start_queue(wlandev->netdev); netdev_notice(netdev, "Tx attempt prior to association, frame dropped.\n"); netdev->stats.tx_dropped++; @@ -369,7 +369,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, } /* Check for raw transmits */ - if (skb->protocol == ETH_P_80211_RAW) { + if (be16_to_cpu(skb->protocol) == ETH_P_80211_RAW) { if (!capable(CAP_NET_ADMIN)) { result = 1; goto failed; -- cgit v1.2.3-59-g8ed1b From b0ef3ed48eb8c1982c9d8b8063d856c83d116764 Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Mon, 20 Oct 2014 15:01:08 +0800 Subject: staging: rts5208: fix case of bitwise operator on zero in ms.c If a variable has value 0, then there is no point in combining it with other things with |, as for any x, 0 | x is just x. The following semantic patch finds this problem. @@ expression x,e,e1; statement S; @@ if (x == 0) { <... when != x = e1 when != while(...) S when != for(...;...;...) S ( * x |= e | * x | e ) ...> } Signed-off-by: Jiayi Ye Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/ms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index 228e48339b9e..b4612fb615f6 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -2599,9 +2599,9 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, if (count > sector_cnt) { if (mode_2k) - ms_card->seq_mode |= MODE_2K_SEQ; + ms_card->seq_mode = MODE_2K_SEQ; else - ms_card->seq_mode |= MODE_512_SEQ; + ms_card->seq_mode = MODE_512_SEQ; } } else { count = sector_cnt; -- cgit v1.2.3-59-g8ed1b From 46ee98a206c1fa6fc394791fb6188a47820a80b5 Mon Sep 17 00:00:00 2001 From: Vlad Dogaru Date: Thu, 23 Oct 2014 15:52:00 +0100 Subject: bmp280: use correct routine for division The proper way to divide two signed 64-bit values is to use div64_s64. Signed-off-by: Vlad Dogaru Reported-by: kbuild test robot Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index fb91cb35b331..ce29ff91bce7 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -239,7 +239,7 @@ static u32 bmp280_compensate_press(struct bmp280_data *data, return 0; p = ((((s64) 1048576 - adc_press) << 31) - var2) * 3125; - do_div(p, var1); + p = div64_s64(p, var1); var1 = (((s64) comp->dig_p9) * (p >> 13) * (p >> 13)) >> 25; var2 = (((s64) comp->dig_p8) * p) >> 19; p = ((p + var1 + var2) >> 8) + (((s64) comp->dig_p7) << 4); -- cgit v1.2.3-59-g8ed1b From 4d5ce6bb11abee638052d8682263008fea57e068 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Thu, 23 Oct 2014 12:44:00 +0100 Subject: iio: Add ABI documentation for offset and scaled humidity This patch adds ABI documentation entries for in_humidityrelative_offset and in_humidityrelative_scale, since there is at least one user for these, Si7005 humidity and temperature sensor driver. Signed-off-by: Roberta Dobrescu Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 5a7fc666b07e..d9dd70f591ab 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -238,6 +238,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset What: /sys/bus/iio/devices/iio:deviceX/in_pressure_offset +What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_offset KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: @@ -273,6 +274,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_rot_from_north_magnetic_tilt_comp_sca What: /sys/bus/iio/devices/iio:deviceX/in_rot_from_north_true_tilt_comp_scale What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_scale What: /sys/bus/iio/devices/iio:deviceX/in_pressure_scale +What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_scale KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: -- cgit v1.2.3-59-g8ed1b From ed56330df215b014c45940cceb97590d283b865f Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Fri, 24 Oct 2014 22:41:00 +0100 Subject: iio: Add ABI documentation for RGBC intensity hardware gain factor This patch adds documentation for RGBC in_intensity_*_hardwaregain. There is at least one user for these, ADJD-S311-CR999 digital color sensor driver. Signed-off-by: Roberta Dobrescu Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index d9dd70f591ab..ea7e7abbbdf4 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -337,6 +337,10 @@ Description: are listed in this attribute. What /sys/bus/iio/devices/iio:deviceX/out_voltageY_hardwaregain +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_red_hardwaregain +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_green_hardwaregain +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_blue_hardwaregain +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_clear_hardwaregain KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: -- cgit v1.2.3-59-g8ed1b From a9bef750135cc261bfceff6840a30a3f357df8da Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Wed, 22 Oct 2014 16:50:17 +0300 Subject: staging: iio: iio_event_monitor: Add support for missing IIO modifiers This patch adds the missing IIO modifiers in event_is_known function and iio_modifier_names vector. Additionally, it removes duplicate name entries of IIO_MOD_LIGHT_BOTH and IIO_MOD_LIGHT_IR in iio_modifier_names. Signed-off-by: Roberta Dobrescu Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- .../staging/iio/Documentation/iio_event_monitor.c | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c index 569d6f8face5..940ed2399e73 100644 --- a/drivers/staging/iio/Documentation/iio_event_monitor.c +++ b/drivers/staging/iio/Documentation/iio_event_monitor.c @@ -69,16 +69,29 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_X] = "x", [IIO_MOD_Y] = "y", [IIO_MOD_Z] = "z", + [IIO_MOD_X_AND_Y] = "x&y", + [IIO_MOD_X_AND_Z] = "x&z", + [IIO_MOD_Y_AND_Z] = "y&z", + [IIO_MOD_X_AND_Y_AND_Z] = "x&y&z", + [IIO_MOD_X_OR_Y] = "x|y", + [IIO_MOD_X_OR_Z] = "x|z", + [IIO_MOD_Y_OR_Z] = "y|z", + [IIO_MOD_X_OR_Y_OR_Z] = "x|y|z", [IIO_MOD_LIGHT_BOTH] = "both", [IIO_MOD_LIGHT_IR] = "ir", [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)", [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2", - [IIO_MOD_LIGHT_BOTH] = "both", - [IIO_MOD_LIGHT_IR] = "ir", [IIO_MOD_LIGHT_CLEAR] = "clear", [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION] = "quaternion", + [IIO_MOD_TEMP_AMBIENT] = "ambient", + [IIO_MOD_TEMP_OBJECT] = "object", + [IIO_MOD_NORTH_MAGN] = "from_north_magnetic", + [IIO_MOD_NORTH_TRUE] = "from_north_true", + [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", + [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", }; static bool event_is_known(struct iio_event_data *event) @@ -118,6 +131,14 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_X: case IIO_MOD_Y: case IIO_MOD_Z: + case IIO_MOD_X_AND_Y: + case IIO_MOD_X_AND_Z: + case IIO_MOD_Y_AND_Z: + case IIO_MOD_X_AND_Y_AND_Z: + case IIO_MOD_X_OR_Y: + case IIO_MOD_X_OR_Z: + case IIO_MOD_Y_OR_Z: + case IIO_MOD_X_OR_Y_OR_Z: case IIO_MOD_LIGHT_BOTH: case IIO_MOD_LIGHT_IR: case IIO_MOD_ROOT_SUM_SQUARED_X_Y: @@ -126,6 +147,13 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_LIGHT_RED: case IIO_MOD_LIGHT_GREEN: case IIO_MOD_LIGHT_BLUE: + case IIO_MOD_QUATERNION: + case IIO_MOD_TEMP_AMBIENT: + case IIO_MOD_TEMP_OBJECT: + case IIO_MOD_NORTH_MAGN: + case IIO_MOD_NORTH_TRUE: + case IIO_MOD_NORTH_MAGN_TILT_COMP: + case IIO_MOD_NORTH_TRUE_TILT_COMP: break; default: return false; -- cgit v1.2.3-59-g8ed1b From acd8256723f286b7217801fbed24503f8565b91e Mon Sep 17 00:00:00 2001 From: "Ivan T. Ivanov" Date: Wed, 22 Oct 2014 18:29:43 +0300 Subject: iio: inkern: Add of_xlate function to struct iio_info When #iio-cells is greater than '0', the driver could provide a custom of_xlate function that reads the *args* and returns the appropriate index in registered IIO channels array. Add simple translation function, suitable for the most 1:1 mapped channels in IIO chips, and use it when driver did not provide custom implementation. Signed-off-by: Ivan T. Ivanov Reviewed-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 33 ++++++++++++++++++++++++++++----- include/linux/iio/iio.h | 8 ++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index c7497009d60a..0cc505d98686 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -100,6 +100,28 @@ static int iio_dev_node_match(struct device *dev, void *data) return dev->of_node == data && dev->type == &iio_device_type; } +/** + * __of_iio_simple_xlate - translate iiospec to the IIO channel index + * @indio_dev: pointer to the iio_dev structure + * @iiospec: IIO specifier as found in the device tree + * + * This is simple translation function, suitable for the most 1:1 mapped + * channels in IIO chips. This function performs only one sanity check: + * whether IIO index is less than num_channels (that is specified in the + * iio_dev). + */ +static int __of_iio_simple_xlate(struct iio_dev *indio_dev, + const struct of_phandle_args *iiospec) +{ + if (!iiospec->args_count) + return 0; + + if (iiospec->args[0] >= indio_dev->num_channels) + return -EINVAL; + + return iiospec->args[0]; +} + static int __of_iio_channel_get(struct iio_channel *channel, struct device_node *np, int index) { @@ -122,18 +144,19 @@ static int __of_iio_channel_get(struct iio_channel *channel, indio_dev = dev_to_iio_dev(idev); channel->indio_dev = indio_dev; - index = iiospec.args_count ? iiospec.args[0] : 0; - if (index >= indio_dev->num_channels) { - err = -EINVAL; + if (indio_dev->info->of_xlate) + index = indio_dev->info->of_xlate(indio_dev, &iiospec); + else + index = __of_iio_simple_xlate(indio_dev, &iiospec); + if (index < 0) goto err_put; - } channel->channel = &indio_dev->channels[index]; return 0; err_put: iio_device_put(indio_dev); - return err; + return index; } static struct iio_channel *of_iio_channel_get(struct device_node *np, int index) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 15dc6bc2bdd2..3642ce7ef512 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -13,6 +13,7 @@ #include #include #include +#include /* IIO TODO LIST */ /* * Provide means of adjusting timer accuracy. @@ -326,6 +327,11 @@ struct iio_dev; * @update_scan_mode: function to configure device and scan buffer when * channels have changed * @debugfs_reg_access: function to read or write register value of device + * @of_xlate: function pointer to obtain channel specifier index. + * When #iio-cells is greater than '0', the driver could + * provide a custom of_xlate function that reads the + * *args* and returns the appropriate index in registered + * IIO channels array. **/ struct iio_info { struct module *driver_module; @@ -385,6 +391,8 @@ struct iio_info { int (*debugfs_reg_access)(struct iio_dev *indio_dev, unsigned reg, unsigned writeval, unsigned *readval); + int (*of_xlate)(struct iio_dev *indio_dev, + const struct of_phandle_args *iiospec); }; /** -- cgit v1.2.3-59-g8ed1b From 345b48307d6961183be77748fc0ae5dd660c91a8 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sat, 25 Oct 2014 20:09:11 +0200 Subject: iio:humidity:si7020: cleanup read_raw and probe When reading temperature or humidity values, a shift of two bits to the right needs to be applied, and only for the humidity channel a mask of the lower 12 bits needs to be applied. This reduces code repetition. During probe, i2c_set_clientdata() was used, although its counterpart was not, so drop it. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/si7020.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c index e336af713f20..69e49f58a455 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c @@ -56,10 +56,9 @@ static int si7020_read_raw(struct iio_dev *indio_dev, SI7020CMD_RH_HOLD); if (ret < 0) return ret; - if (chan->type == IIO_TEMP) - *val = ret >> 2; - else - *val = (ret & 0x3FFF) >> 2; + *val = ret >> 2; + if (chan->type == IIO_HUMIDITYRELATIVE) + *val &= GENMASK(11, 0); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: if (chan->type == IIO_TEMP) @@ -133,7 +132,6 @@ static int si7020_probe(struct i2c_client *client, data = iio_priv(indio_dev); *data = client; - i2c_set_clientdata(client, indio_dev); indio_dev->dev.parent = &client->dev; indio_dev->name = dev_name(&client->dev); -- cgit v1.2.3-59-g8ed1b From e0922e5e3ccb78aa0152e93dfbd1755ac39c8582 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sat, 25 Oct 2014 20:09:06 +0200 Subject: iio:humidity:si7020: fix pointer to i2c client In si7020_read_raw() the pointer to the i2c client was obtained as second level pointer, although a simple pointer is appropriate. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/si7020.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c index 69e49f58a455..b54164677b89 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c @@ -45,12 +45,12 @@ static int si7020_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { - struct i2c_client **client = iio_priv(indio_dev); + struct i2c_client *client = iio_priv(indio_dev); int ret; switch (mask) { case IIO_CHAN_INFO_RAW: - ret = i2c_smbus_read_word_data(*client, + ret = i2c_smbus_read_word_data(client, chan->type == IIO_TEMP ? SI7020CMD_TEMP_HOLD : SI7020CMD_RH_HOLD); -- cgit v1.2.3-59-g8ed1b From ce0694841ea61607afcbdb5a67bb0b00328357ef Mon Sep 17 00:00:00 2001 From: "Ivan T. Ivanov" Date: Wed, 22 Oct 2014 17:13:33 +0300 Subject: iio: iadc: Qualcomm SPMI PMIC current ADC driver The current ADC is peripheral of Qualcomm SPMI PMIC chips. It has 16 bits resolution and register space inside PMIC accessible across SPMI bus. The driver registers itself through IIO interface. Signed-off-by: Ivan T. Ivanov Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/qcom,spmi-iadc.txt | 46 ++ drivers/iio/adc/Kconfig | 14 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/qcom-spmi-iadc.c | 595 +++++++++++++++++++++ 4 files changed, 656 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt create mode 100644 drivers/iio/adc/qcom-spmi-iadc.c diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt new file mode 100644 index 000000000000..4e36d6e2f7b6 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt @@ -0,0 +1,46 @@ +Qualcomm's SPMI PMIC current ADC + +QPNP PMIC current ADC (IADC) provides interface to clients to read current. +A 16 bit ADC is used for current measurements. IADC can measure the current +through an external resistor (channel 1) or internal (built-in) resistor +(channel 0). When using an external resistor it is to be described by +qcom,external-resistor-micro-ohms property. + +IADC node: + +- compatible: + Usage: required + Value type: + Definition: Should contain "qcom,spmi-iadc". + +- reg: + Usage: required + Value type: + Definition: IADC base address and length in the SPMI PMIC register map + +- interrupts: + Usage: optional + Value type: + Definition: End of ADC conversion. + +- qcom,external-resistor-micro-ohms: + Usage: optional + Value type: + Definition: Sense resister value in micro Ohm. + If not defined value of 10000 micro Ohms will be used. + +Example: + /* IADC node */ + pmic_iadc: iadc@3600 { + compatible = "qcom,spmi-iadc"; + reg = <0x3600 0x100>; + interrupts = <0x0 0x36 0x0 IRQ_TYPE_EDGE_RISING>; + qcom,external-resistor-micro-ohms = <10000>; + #io-channel-cells = <1>; + }; + + /* IIO client node */ + bat { + io-channels = <&pmic_iadc 0>; + io-channel-names = "iadc"; + }; diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 88bdc8f612e2..d0924f3cfa25 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -206,6 +206,20 @@ config NAU7802 To compile this driver as a module, choose M here: the module will be called nau7802. +config QCOM_SPMI_IADC + tristate "Qualcomm SPMI PMIC current ADC" + depends on SPMI + select REGMAP_SPMI + help + This is the IIO Current ADC driver for Qualcomm QPNP IADC Chip. + + The driver supports single mode operation to read from one of two + channels (external or internal). Hardware have additional + channels internally used for gain and offset calibration. + + To compile this driver as a module, choose M here: the module will + be called qcom-spmi-iadc. + config ROCKCHIP_SARADC tristate "Rockchip SARADC driver" depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index cb88a6a23b8f..c06718b9d8ce 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o obj-$(CONFIG_NAU7802) += nau7802.o +obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o obj-$(CONFIG_TI_ADC128S052) += ti-adc128s052.o diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c new file mode 100644 index 000000000000..b9666f2f5e51 --- /dev/null +++ b/drivers/iio/adc/qcom-spmi-iadc.c @@ -0,0 +1,595 @@ +/* + * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* IADC register and bit definition */ +#define IADC_REVISION2 0x1 +#define IADC_REVISION2_SUPPORTED_IADC 1 + +#define IADC_PERPH_TYPE 0x4 +#define IADC_PERPH_TYPE_ADC 8 + +#define IADC_PERPH_SUBTYPE 0x5 +#define IADC_PERPH_SUBTYPE_IADC 3 + +#define IADC_STATUS1 0x8 +#define IADC_STATUS1_OP_MODE 4 +#define IADC_STATUS1_REQ_STS BIT(1) +#define IADC_STATUS1_EOC BIT(0) +#define IADC_STATUS1_REQ_STS_EOC_MASK 0x3 + +#define IADC_MODE_CTL 0x40 +#define IADC_OP_MODE_SHIFT 3 +#define IADC_OP_MODE_NORMAL 0 +#define IADC_TRIM_EN BIT(0) + +#define IADC_EN_CTL1 0x46 +#define IADC_EN_CTL1_SET BIT(7) + +#define IADC_CH_SEL_CTL 0x48 + +#define IADC_DIG_PARAM 0x50 +#define IADC_DIG_DEC_RATIO_SEL_SHIFT 2 + +#define IADC_HW_SETTLE_DELAY 0x51 + +#define IADC_CONV_REQ 0x52 +#define IADC_CONV_REQ_SET BIT(7) + +#define IADC_FAST_AVG_CTL 0x5a +#define IADC_FAST_AVG_EN 0x5b +#define IADC_FAST_AVG_EN_SET BIT(7) + +#define IADC_PERH_RESET_CTL3 0xda +#define IADC_FOLLOW_WARM_RB BIT(2) + +#define IADC_DATA 0x60 /* 16 bits */ + +#define IADC_SEC_ACCESS 0xd0 +#define IADC_SEC_ACCESS_DATA 0xa5 + +#define IADC_NOMINAL_RSENSE 0xf4 +#define IADC_NOMINAL_RSENSE_SIGN_MASK BIT(7) + +#define IADC_REF_GAIN_MICRO_VOLTS 17857 + +#define IADC_INT_RSENSE_DEVIATION 15625 /* nano Ohms per bit */ + +#define IADC_INT_RSENSE_IDEAL_VALUE 10000 /* micro Ohms */ +#define IADC_INT_RSENSE_DEFAULT_VALUE 7800 /* micro Ohms */ +#define IADC_INT_RSENSE_DEFAULT_GF 9000 /* micro Ohms */ +#define IADC_INT_RSENSE_DEFAULT_SMIC 9700 /* micro Ohms */ + +#define IADC_CONV_TIME_MIN_US 2000 +#define IADC_CONV_TIME_MAX_US 2100 + +#define IADC_DEF_PRESCALING 0 /* 1:1 */ +#define IADC_DEF_DECIMATION 0 /* 512 */ +#define IADC_DEF_HW_SETTLE_TIME 0 /* 0 us */ +#define IADC_DEF_AVG_SAMPLES 0 /* 1 sample */ + +/* IADC channel list */ +#define IADC_INT_RSENSE 0 +#define IADC_EXT_RSENSE 1 +#define IADC_GAIN_17P857MV 3 +#define IADC_EXT_OFFSET_CSP_CSN 5 +#define IADC_INT_OFFSET_CSP2_CSN2 6 + +/** + * struct iadc_chip - IADC Current ADC device structure. + * @regmap: regmap for register read/write. + * @dev: This device pointer. + * @base: base offset for the ADC peripheral. + * @rsense: Values of the internal and external sense resister in micro Ohms. + * @poll_eoc: Poll for end of conversion instead of waiting for IRQ. + * @offset: Raw offset values for the internal and external channels. + * @gain: Raw gain of the channels. + * @lock: ADC lock for access to the peripheral. + * @complete: ADC notification after end of conversion interrupt is received. + */ +struct iadc_chip { + struct regmap *regmap; + struct device *dev; + u16 base; + bool poll_eoc; + u32 rsense[2]; + u16 offset[2]; + u16 gain; + struct mutex lock; + struct completion complete; +}; + +static int iadc_read(struct iadc_chip *iadc, u16 offset, u8 *data) +{ + unsigned int val; + int ret; + + ret = regmap_read(iadc->regmap, iadc->base + offset, &val); + if (ret < 0) + return ret; + + *data = val; + return 0; +} + +static int iadc_write(struct iadc_chip *iadc, u16 offset, u8 data) +{ + return regmap_write(iadc->regmap, iadc->base + offset, data); +} + +static int iadc_reset(struct iadc_chip *iadc) +{ + u8 data; + int ret; + + ret = iadc_write(iadc, IADC_SEC_ACCESS, IADC_SEC_ACCESS_DATA); + if (ret < 0) + return ret; + + ret = iadc_read(iadc, IADC_PERH_RESET_CTL3, &data); + if (ret < 0) + return ret; + + ret = iadc_write(iadc, IADC_SEC_ACCESS, IADC_SEC_ACCESS_DATA); + if (ret < 0) + return ret; + + data |= IADC_FOLLOW_WARM_RB; + + return iadc_write(iadc, IADC_PERH_RESET_CTL3, data); +} + +static int iadc_set_state(struct iadc_chip *iadc, bool state) +{ + return iadc_write(iadc, IADC_EN_CTL1, state ? IADC_EN_CTL1_SET : 0); +} + +static void iadc_status_show(struct iadc_chip *iadc) +{ + u8 mode, sta1, chan, dig, en, req; + int ret; + + ret = iadc_read(iadc, IADC_MODE_CTL, &mode); + if (ret < 0) + return; + + ret = iadc_read(iadc, IADC_DIG_PARAM, &dig); + if (ret < 0) + return; + + ret = iadc_read(iadc, IADC_CH_SEL_CTL, &chan); + if (ret < 0) + return; + + ret = iadc_read(iadc, IADC_CONV_REQ, &req); + if (ret < 0) + return; + + ret = iadc_read(iadc, IADC_STATUS1, &sta1); + if (ret < 0) + return; + + ret = iadc_read(iadc, IADC_EN_CTL1, &en); + if (ret < 0) + return; + + dev_err(iadc->dev, + "mode:%02x en:%02x chan:%02x dig:%02x req:%02x sta1:%02x\n", + mode, en, chan, dig, req, sta1); +} + +static int iadc_configure(struct iadc_chip *iadc, int channel) +{ + u8 decim, mode; + int ret; + + /* Mode selection */ + mode = (IADC_OP_MODE_NORMAL << IADC_OP_MODE_SHIFT) | IADC_TRIM_EN; + ret = iadc_write(iadc, IADC_MODE_CTL, mode); + if (ret < 0) + return ret; + + /* Channel selection */ + ret = iadc_write(iadc, IADC_CH_SEL_CTL, channel); + if (ret < 0) + return ret; + + /* Digital parameter setup */ + decim = IADC_DEF_DECIMATION << IADC_DIG_DEC_RATIO_SEL_SHIFT; + ret = iadc_write(iadc, IADC_DIG_PARAM, decim); + if (ret < 0) + return ret; + + /* HW settle time delay */ + ret = iadc_write(iadc, IADC_HW_SETTLE_DELAY, IADC_DEF_HW_SETTLE_TIME); + if (ret < 0) + return ret; + + ret = iadc_write(iadc, IADC_FAST_AVG_CTL, IADC_DEF_AVG_SAMPLES); + if (ret < 0) + return ret; + + if (IADC_DEF_AVG_SAMPLES) + ret = iadc_write(iadc, IADC_FAST_AVG_EN, IADC_FAST_AVG_EN_SET); + else + ret = iadc_write(iadc, IADC_FAST_AVG_EN, 0); + + if (ret < 0) + return ret; + + if (!iadc->poll_eoc) + reinit_completion(&iadc->complete); + + ret = iadc_set_state(iadc, true); + if (ret < 0) + return ret; + + /* Request conversion */ + return iadc_write(iadc, IADC_CONV_REQ, IADC_CONV_REQ_SET); +} + +static int iadc_poll_wait_eoc(struct iadc_chip *iadc, unsigned int interval_us) +{ + unsigned int count, retry; + int ret; + u8 sta1; + + retry = interval_us / IADC_CONV_TIME_MIN_US; + + for (count = 0; count < retry; count++) { + ret = iadc_read(iadc, IADC_STATUS1, &sta1); + if (ret < 0) + return ret; + + sta1 &= IADC_STATUS1_REQ_STS_EOC_MASK; + if (sta1 == IADC_STATUS1_EOC) + return 0; + + usleep_range(IADC_CONV_TIME_MIN_US, IADC_CONV_TIME_MAX_US); + } + + iadc_status_show(iadc); + + return -ETIMEDOUT; +} + +static int iadc_read_result(struct iadc_chip *iadc, u16 *data) +{ + return regmap_bulk_read(iadc->regmap, iadc->base + IADC_DATA, data, 2); +} + +static int iadc_do_conversion(struct iadc_chip *iadc, int chan, u16 *data) +{ + unsigned int wait; + int ret; + + ret = iadc_configure(iadc, chan); + if (ret < 0) + goto exit; + + wait = BIT(IADC_DEF_AVG_SAMPLES) * IADC_CONV_TIME_MIN_US * 2; + + if (iadc->poll_eoc) { + ret = iadc_poll_wait_eoc(iadc, wait); + } else { + ret = wait_for_completion_timeout(&iadc->complete, wait); + if (!ret) + ret = -ETIMEDOUT; + else + /* double check conversion status */ + ret = iadc_poll_wait_eoc(iadc, IADC_CONV_TIME_MIN_US); + } + + if (!ret) + ret = iadc_read_result(iadc, data); +exit: + iadc_set_state(iadc, false); + if (ret < 0) + dev_err(iadc->dev, "conversion failed\n"); + + return ret; +} + +static int iadc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct iadc_chip *iadc = iio_priv(indio_dev); + s32 isense_ua, vsense_uv; + u16 adc_raw, vsense_raw; + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&iadc->lock); + ret = iadc_do_conversion(iadc, chan->channel, &adc_raw); + mutex_unlock(&iadc->lock); + if (ret < 0) + return ret; + + vsense_raw = adc_raw - iadc->offset[chan->channel]; + + vsense_uv = vsense_raw * IADC_REF_GAIN_MICRO_VOLTS; + vsense_uv /= (s32)iadc->gain - iadc->offset[chan->channel]; + + isense_ua = vsense_uv / iadc->rsense[chan->channel]; + + dev_dbg(iadc->dev, "off %d gain %d adc %d %duV I %duA\n", + iadc->offset[chan->channel], iadc->gain, + adc_raw, vsense_uv, isense_ua); + + *val = isense_ua; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = 1000; + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} + +static const struct iio_info iadc_info = { + .read_raw = iadc_read_raw, + .driver_module = THIS_MODULE, +}; + +static irqreturn_t iadc_isr(int irq, void *dev_id) +{ + struct iadc_chip *iadc = dev_id; + + complete(&iadc->complete); + + return IRQ_HANDLED; +} + +static int iadc_update_offset(struct iadc_chip *iadc) +{ + int ret; + + ret = iadc_do_conversion(iadc, IADC_GAIN_17P857MV, &iadc->gain); + if (ret < 0) + return ret; + + ret = iadc_do_conversion(iadc, IADC_INT_OFFSET_CSP2_CSN2, + &iadc->offset[IADC_INT_RSENSE]); + if (ret < 0) + return ret; + + if (iadc->gain == iadc->offset[IADC_INT_RSENSE]) { + dev_err(iadc->dev, "error: internal offset == gain %d\n", + iadc->gain); + return -EINVAL; + } + + ret = iadc_do_conversion(iadc, IADC_EXT_OFFSET_CSP_CSN, + &iadc->offset[IADC_EXT_RSENSE]); + if (ret < 0) + return ret; + + if (iadc->gain == iadc->offset[IADC_EXT_RSENSE]) { + dev_err(iadc->dev, "error: external offset == gain %d\n", + iadc->gain); + return -EINVAL; + } + + return 0; +} + +static int iadc_version_check(struct iadc_chip *iadc) +{ + u8 val; + int ret; + + ret = iadc_read(iadc, IADC_PERPH_TYPE, &val); + if (ret < 0) + return ret; + + if (val < IADC_PERPH_TYPE_ADC) { + dev_err(iadc->dev, "%d is not ADC\n", val); + return -EINVAL; + } + + ret = iadc_read(iadc, IADC_PERPH_SUBTYPE, &val); + if (ret < 0) + return ret; + + if (val < IADC_PERPH_SUBTYPE_IADC) { + dev_err(iadc->dev, "%d is not IADC\n", val); + return -EINVAL; + } + + ret = iadc_read(iadc, IADC_REVISION2, &val); + if (ret < 0) + return ret; + + if (val < IADC_REVISION2_SUPPORTED_IADC) { + dev_err(iadc->dev, "revision %d not supported\n", val); + return -EINVAL; + } + + return 0; +} + +static int iadc_rsense_read(struct iadc_chip *iadc, struct device_node *node) +{ + int ret, sign, int_sense; + u8 deviation; + + ret = of_property_read_u32(node, "qcom,external-resistor-micro-ohms", + &iadc->rsense[IADC_EXT_RSENSE]); + if (ret < 0) + iadc->rsense[IADC_EXT_RSENSE] = IADC_INT_RSENSE_IDEAL_VALUE; + + if (!iadc->rsense[IADC_EXT_RSENSE]) { + dev_err(iadc->dev, "external resistor can't be zero Ohms"); + return -EINVAL; + } + + ret = iadc_read(iadc, IADC_NOMINAL_RSENSE, &deviation); + if (ret < 0) + return ret; + + /* + * Deviation value stored is an offset from 10 mili Ohms, bit 7 is + * the sign, the remaining bits have an LSB of 15625 nano Ohms. + */ + sign = (deviation & IADC_NOMINAL_RSENSE_SIGN_MASK) ? -1 : 1; + + deviation &= ~IADC_NOMINAL_RSENSE_SIGN_MASK; + + /* Scale it to nono Ohms */ + int_sense = IADC_INT_RSENSE_IDEAL_VALUE * 1000; + int_sense += sign * deviation * IADC_INT_RSENSE_DEVIATION; + int_sense /= 1000; /* micro Ohms */ + + iadc->rsense[IADC_INT_RSENSE] = int_sense; + return 0; +} + +static const struct iio_chan_spec iadc_channels[] = { + { + .type = IIO_CURRENT, + .datasheet_name = "INTERNAL_RSENSE", + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .indexed = 1, + }, + { + .type = IIO_CURRENT, + .datasheet_name = "EXTERNAL_RSENSE", + .channel = 1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .indexed = 1, + }, +}; + +static int iadc_probe(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct iio_dev *indio_dev; + struct iadc_chip *iadc; + int ret, irq_eoc; + u32 res; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*iadc)); + if (!indio_dev) + return -ENOMEM; + + iadc = iio_priv(indio_dev); + iadc->dev = dev; + + iadc->regmap = dev_get_regmap(dev->parent, NULL); + if (!iadc->regmap) + return -ENODEV; + + init_completion(&iadc->complete); + mutex_init(&iadc->lock); + + ret = of_property_read_u32(node, "reg", &res); + if (ret < 0) + return -ENODEV; + + iadc->base = res; + + ret = iadc_version_check(iadc); + if (ret < 0) + return -ENODEV; + + ret = iadc_rsense_read(iadc, node); + if (ret < 0) + return -ENODEV; + + dev_dbg(iadc->dev, "sense resistors %d and %d micro Ohm\n", + iadc->rsense[IADC_INT_RSENSE], + iadc->rsense[IADC_EXT_RSENSE]); + + irq_eoc = platform_get_irq(pdev, 0); + if (irq_eoc == -EPROBE_DEFER) + return irq_eoc; + + if (irq_eoc < 0) + iadc->poll_eoc = true; + + ret = iadc_reset(iadc); + if (ret < 0) { + dev_err(dev, "reset failed\n"); + return ret; + } + + if (!iadc->poll_eoc) { + ret = devm_request_irq(dev, irq_eoc, iadc_isr, 0, + "spmi-iadc", iadc); + if (!ret) + enable_irq_wake(irq_eoc); + else + return ret; + } else { + device_init_wakeup(iadc->dev, 1); + } + + ret = iadc_update_offset(iadc); + if (ret < 0) { + dev_err(dev, "failed offset calibration\n"); + return ret; + } + + indio_dev->dev.parent = dev; + indio_dev->dev.of_node = node; + indio_dev->name = pdev->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &iadc_info; + indio_dev->channels = iadc_channels; + indio_dev->num_channels = ARRAY_SIZE(iadc_channels); + + return devm_iio_device_register(dev, indio_dev); +} + +static const struct of_device_id iadc_match_table[] = { + { .compatible = "qcom,spmi-iadc" }, + { } +}; + +MODULE_DEVICE_TABLE(of, iadc_match_table); + +static struct platform_driver iadc_driver = { + .driver = { + .name = "qcom-spmi-iadc", + .of_match_table = iadc_match_table, + }, + .probe = iadc_probe, +}; + +module_platform_driver(iadc_driver); + +MODULE_ALIAS("platform:qcom-spmi-iadc"); +MODULE_DESCRIPTION("Qualcomm SPMI PMIC current ADC driver"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Ivan T. Ivanov "); -- cgit v1.2.3-59-g8ed1b From dd28153b2a8ca216350a9f42de58cf3a966cba30 Mon Sep 17 00:00:00 2001 From: Somya Anand Date: Thu, 23 Oct 2014 21:28:37 +0200 Subject: Staging: comedi: replace timeval with ktime_t 'struct timeval last' is used for recording last time interrupt. 'struct timeval now' is used for calculating elapsed time. 32-bit systems using 'struct timeval' will break in the year 2038, so we have to replace that code with more appropriate types. This patch changes the comedi driver to use ktime_t. Since this code doesn't communicate the time values to the outside (user space, file system, network).Thus ktime_get() is a better than using do_gettimeofday() as it uses monotonic clock. ktime_to_us() returns an 's64', and using the '%' operator on that requires doing a 64-bit division which needs an expensive library function call the specific value of usec_current does not actually matter although it might matter that it's not always the same which will start with the offset from the lower 32 bit of the microsecond. Therefore: devpriv->usec_current = (ktime_to_us(devpriv->last) % USEC_PER_SEC) % devpriv->usec_period; is replaced by devpriv->usec_current = ((u32)ktime_to_us(devpriv->last)) % devpriv->usec_period; Signed-off-by: Somya Anand Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 8845075cd3cc..4d4358ce1710 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -52,13 +52,14 @@ zero volts). #include "comedi_fc.h" #include +#include #define N_CHANS 8 /* Data unique to this driver */ struct waveform_private { struct timer_list timer; - struct timeval last; /* time last timer interrupt occurred */ + ktime_t last; /* time last timer interrupt occurred */ unsigned int uvolt_amplitude; /* waveform amplitude in microvolts */ unsigned long usec_period; /* waveform period in microseconds */ unsigned long usec_current; /* current time (mod waveform period) */ @@ -171,14 +172,12 @@ static void waveform_ai_interrupt(unsigned long arg) /* all times in microsec */ unsigned long elapsed_time; unsigned int num_scans; - struct timeval now; + ktime_t now; bool stopping = false; - do_gettimeofday(&now); + now = ktime_get(); - elapsed_time = - 1000000 * (now.tv_sec - devpriv->last.tv_sec) + now.tv_usec - - devpriv->last.tv_usec; + elapsed_time = ktime_to_us(ktime_sub(now, devpriv->last)); devpriv->last = now; num_scans = (devpriv->usec_remainder + elapsed_time) / devpriv->scan_period; @@ -317,8 +316,9 @@ static int waveform_ai_cmd(struct comedi_device *dev, else /* TRIG_TIMER */ devpriv->convert_period = cmd->convert_arg / nano_per_micro; - do_gettimeofday(&devpriv->last); - devpriv->usec_current = devpriv->last.tv_usec % devpriv->usec_period; + devpriv->last = ktime_get(); + devpriv->usec_current = + ((u32)ktime_to_us(devpriv->last)) % devpriv->usec_period; devpriv->usec_remainder = 0; devpriv->timer.expires = jiffies + 1; -- cgit v1.2.3-59-g8ed1b From d2b778712e3aa5258fabbb96ed05bcb073a1ce2e Mon Sep 17 00:00:00 2001 From: Somya Anand Date: Thu, 23 Oct 2014 21:28:38 +0200 Subject: Staging: android: Replace timeval with ktime_t in timed_gpio.c 'struct timeval t' is used to return remaining time in milliseconds. 32-bit systems using 'struct timeval' will break in the year 2038, so we have to replace that code with more appropriate types. This patch changes the android driver to use ktime_t. Signed-off-by: Somya Anand Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/timed_gpio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c index 8fa4758517c0..12d55148bafc 100644 --- a/drivers/staging/android/timed_gpio.c +++ b/drivers/staging/android/timed_gpio.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "timed_output.h" #include "timed_gpio.h" @@ -46,16 +47,16 @@ static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer) static int gpio_get_time(struct timed_output_dev *dev) { struct timed_gpio_data *data; - struct timeval t; + ktime_t t; data = container_of(dev, struct timed_gpio_data, dev); if (!hrtimer_active(&data->timer)) return 0; - t = ktime_to_timeval(hrtimer_get_remaining(&data->timer)); + t = hrtimer_get_remaining(&data->timer); - return t.tv_sec * 1000 + t.tv_usec / 1000; + return ktime_to_ms(t); } static void gpio_enable(struct timed_output_dev *dev, int value) -- cgit v1.2.3-59-g8ed1b From e31a0e62803c64cab5e150b94c31364a1ce1d0fd Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Thu, 23 Oct 2014 13:27:46 +0530 Subject: Staging: vme: devices: Use kasprintf This patch uses kasprintf which combines kmalloc and sprintf. kasprintf also takes care of the size calculation. This is done using Coccinelle. Semantic patch used is as follows: @@ expression a,flag; expression list args; statement S; @@ a = - \(kmalloc\|kzalloc\)(...,flag) + kasprintf (flag,args) <... when != a if (a == NULL || ...) S ...> - sprintf(a,args); Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_pio2_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vme/devices/vme_pio2_gpio.c b/drivers/staging/vme/devices/vme_pio2_gpio.c index c64776f71809..da34d5529f51 100644 --- a/drivers/staging/vme/devices/vme_pio2_gpio.c +++ b/drivers/staging/vme/devices/vme_pio2_gpio.c @@ -191,11 +191,11 @@ int pio2_gpio_init(struct pio2_card *card) int retval = 0; char *label; - label = kmalloc(PIO2_NUM_CHANNELS, GFP_KERNEL); + label = kasprintf(GFP_KERNEL, + "%s@%s", driver_name, dev_name(&card->vdev->dev)); if (label == NULL) return -ENOMEM; - sprintf(label, "%s@%s", driver_name, dev_name(&card->vdev->dev)); card->gc.label = label; card->gc.ngpio = PIO2_NUM_CHANNELS; -- cgit v1.2.3-59-g8ed1b From 438c582602b9e0b421bd356f3f2cdc77fe45eb5b Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Thu, 23 Oct 2014 16:10:16 +0300 Subject: staging: slicoss: Use inplace convert with __be32 * This patch fixes "cast to restricted __be32" sparse warning. remove temporary value assignment and use inplace __be32 conversion for ntohl function which is can get big endian format Signed-off-by: Ebru Akagunduz Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index f48eeb168e0b..71bc4edae322 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -596,8 +596,7 @@ static void slic_mac_address_config(struct adapter *adapter) u32 value2; __iomem struct slic_regs *slic_regs = adapter->slic_regs; - value = *(u32 *) &adapter->currmacaddr[2]; - value = ntohl(value); + value = ntohl(*(__be32 *) &adapter->currmacaddr[2]); slic_reg32_write(&slic_regs->slic_wraddral, value, FLUSH); slic_reg32_write(&slic_regs->slic_wraddrbl, value, FLUSH); -- cgit v1.2.3-59-g8ed1b From b3dd8957c23a9e2eed612469d02a6e418b585e6b Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Fri, 24 Oct 2014 21:46:00 +0530 Subject: staging: lustre: lustre: llite: Use kstrdup Use kstrdup when the goal of an allocation is copy a string into the allocated region. Patch found by coccicheck. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/xattr_cache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 627cbe242f22..e2badf17d95e 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -126,9 +126,7 @@ static int ll_xattr_cache_add(struct list_head *cache, return -ENOMEM; } - xattr->xe_namelen = strlen(xattr_name) + 1; - - xattr->xe_name = kzalloc(xattr->xe_namelen, GFP_NOFS); + xattr->xe_name = kstrdup(xattr_name, GFP_NOFS); if (!xattr->xe_name) { CDEBUG(D_CACHE, "failed to alloc xattr name %u\n", xattr->xe_namelen); @@ -141,7 +139,6 @@ static int ll_xattr_cache_add(struct list_head *cache, goto err_value; } - memcpy(xattr->xe_name, xattr_name, xattr->xe_namelen); memcpy(xattr->xe_value, xattr_val, xattr_val_len); xattr->xe_vallen = xattr_val_len; list_add(&xattr->xe_list, cache); -- cgit v1.2.3-59-g8ed1b From fe4c6a38b8379baf0bf7fe676c62e39c060d735b Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Thu, 23 Oct 2014 23:18:53 +0530 Subject: staging: xgifb: Removed an unnecessary assignment statement Used coccinelle patch @@ expression data; identifier f; @@ -data = +return f(...); -return (data); Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_util.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/xgifb/vb_util.c b/drivers/staging/xgifb/vb_util.c index 1b452f8b6274..be3437ca339e 100644 --- a/drivers/staging/xgifb/vb_util.c +++ b/drivers/staging/xgifb/vb_util.c @@ -9,11 +9,8 @@ void xgifb_reg_set(unsigned long port, u8 index, u8 data) u8 xgifb_reg_get(unsigned long port, u8 index) { - u8 data; - outb(index, port); - data = inb(port + 1); - return data; + return inb(port + 1); } void xgifb_reg_and_or(unsigned long port, u8 index, -- cgit v1.2.3-59-g8ed1b From 861374fcf3e88e290b026fbddf7b5b27898df4b6 Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Thu, 23 Oct 2014 22:52:33 +0530 Subject: staging: vt6655: Replace C99 // comments by /* */ Replaced C99 // comments by /* */ in wroute.c Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wroute.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c index d1171fa3446e..6606a1c239ee 100644 --- a/drivers/staging/vt6655/wroute.c +++ b/drivers/staging/vt6655/wroute.c @@ -94,7 +94,7 @@ bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, if (pDevice->bEncryptionEnable == true) { bNeedEncryption = true; - // get group key + /* get group key */ pbyBSSID = pDevice->abyBroadcastAddr; if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { @@ -159,7 +159,7 @@ bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, &cbHeaderSize); if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { - // Disable PS + /* Disable PS */ MACbPSWakeup(pDevice->PortOffset); } @@ -167,7 +167,7 @@ bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, pLastTD = pHeadTD; for (ii = 0; ii < uMACfragNum; ii++) { - // Poll Transmit the adapter + /* Poll Transmit the adapter */ wmb(); pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC; wmb(); -- cgit v1.2.3-59-g8ed1b From 7424a0609063826a60a933ace872a1e747dfeede Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Thu, 23 Oct 2014 22:05:10 +0800 Subject: staging: rtl8188eu: core: fix null dereference on exit path in rtw_mlme.c If adapter is null, null dereference may occur. This patch fixes it. The following Coccinelle semantic patch was used to find the case. @@ expression E, E1; identifier f; statement S1,S2,S3; @@ * if (E == NULL) { ... when != if (E == NULL) S1 else S2 when != E = E1 * E->f ... when any return ...; } else S3 Signed-off-by: Jiayi Ye Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 149c271e966d..bbebe67a77db 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1437,7 +1437,7 @@ void rtw_dynamic_check_timer_handlder(void *function_context) struct registry_priv *pregistrypriv = &adapter->registrypriv; if (!adapter) - goto exit; + return; if (!adapter->hw_init_completed) goto exit; if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved)) -- cgit v1.2.3-59-g8ed1b From 334c826858691d306285183822e954063a116035 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Fri, 24 Oct 2014 21:44:26 +0530 Subject: staging: rtl8192u: Remove unnecessary if Remove the if condition, as the code inside the if condition is commented and does not have any FIXME or TODO comment. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_wx.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 28f60d2dbe5b..361d2d0c3df1 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -171,7 +171,6 @@ static int r8192_wx_set_crcmon(struct net_device *dev, struct r8192_priv *priv = ieee80211_priv(dev); int *parms = (int *)extra; int enable = (parms[0] > 0); - short prev = priv->crcmon; down(&priv->wx_sem); @@ -183,11 +182,6 @@ static int r8192_wx_set_crcmon(struct net_device *dev, DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); - if (prev != priv->crcmon && priv->up) { - /* rtl8180_down(dev); */ - /* rtl8180_up(dev); */ - } - up(&priv->wx_sem); return 0; -- cgit v1.2.3-59-g8ed1b From eca6a8872a047069969a7f7ad420d819e4847be9 Mon Sep 17 00:00:00 2001 From: Aybuke Ozdemir Date: Thu, 23 Oct 2014 17:12:19 +0300 Subject: staging: media: lirc: Use pr_* instead of printk This patch focuses on fixing the following warning generated by checkpatch.pl for the file lirc_sasem.c: WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... WARNING: Prefer [subsystem eg: netdev]_cont([subsystem]dev, ... then dev_cont(dev, ... then pr_cont(... to printk(KERN_CONT ... Signed-off-by: Aybuke Ozdemir Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_sasem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index c20ef56202bf..05969fb451ca 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -583,10 +583,10 @@ static void incoming_packet(struct sasem_context *context, } if (debug) { - printk(KERN_INFO "Incoming data: "); + pr_info("Incoming data: "); for (i = 0; i < 8; ++i) - printk(KERN_CONT "%02x ", buf[i]); - printk(KERN_CONT "\n"); + pr_cont("%02x ", buf[i]); + pr_cont("\n"); } /* -- cgit v1.2.3-59-g8ed1b From f237216ebfd4c263b448df2f6e09ff6786221f03 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Thu, 23 Oct 2014 20:16:51 -0700 Subject: Staging: rtl8723au: core: Dont have { on new line This patch fixes the following checkpatch errors: ERROR: that open brace { should be on the previous line ERROR: else should follow close brace '}' Exceptions: { is left on a new line to itself when fixing this error makes the line longer than 80 characters. Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 140 ++++++++----------------- drivers/staging/rtl8723au/core/rtw_cmd.c | 6 +- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 3 +- drivers/staging/rtl8723au/core/rtw_led.c | 80 +++++--------- 4 files changed, 71 insertions(+), 158 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 75ae2492699a..6a336cd2eb4d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -231,12 +231,10 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) psta->expire_to--; } - if (psta->expire_to <= 0) - { + if (psta->expire_to <= 0) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - if (padapter->registrypriv.wifi_spec == 1) - { + if (padapter->registrypriv.wifi_spec == 1) { psta->expire_to = pstapriv->expire_to; continue; } @@ -308,15 +306,12 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 50); psta->keep_alive_trycnt++; - if (ret == _SUCCESS) - { + if (ret == _SUCCESS) { DBG_8723A("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr)); psta->expire_to = pstapriv->expire_to; psta->keep_alive_trycnt = 0; continue; - } - else if (psta->keep_alive_trycnt <= 3) - { + } else if (psta->keep_alive_trycnt <= 3) { DBG_8723A("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt); psta->expire_to = 1; continue; @@ -363,8 +358,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l return; /* b/g mode ra_bitmap */ - for (i = 0; i < sizeof(psta->bssrateset); i++) - { + for (i = 0; i < sizeof(psta->bssrateset); i++) { if (psta->bssrateset[i]) tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); } @@ -406,8 +400,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l raid = networktype_to_raid23a(sta_band); init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f; - if (psta->aid < NUM_STA) - { + if (psta->aid < NUM_STA) { u8 arg = 0; arg = psta->mac_id&0x1f; @@ -436,11 +429,8 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l psta->raid = raid; psta->init_rate = init_rate; - } - else - { + } else DBG_8723A("station aid %d exceed the max number\n", psta->aid); - } } static void update_bmc_sta(struct rtw_adapter *padapter) @@ -453,8 +443,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter) struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network; struct sta_info *psta = rtw_get_bcmc_stainfo23a(padapter); - if (psta) - { + if (psta) { psta->aid = 0;/* default set to 0 */ psta->mac_id = psta->aid + 1; @@ -474,8 +463,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter) psta->bssratelen = supportRateNum; /* b/g mode ra_bitmap */ - for (i = 0; i < supportRateNum; i++) - { + for (i = 0; i < supportRateNum; i++) { if (psta->bssrateset[i]) tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); } @@ -522,11 +510,8 @@ static void update_bmc_sta(struct rtw_adapter *padapter) psta->state = _FW_LINKED; spin_unlock_bh(&psta->lock); - } - else - { + } else DBG_8723A("add_RATid23a_bmc_sta error!\n"); - } } /* notes: */ @@ -561,8 +546,7 @@ void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info /* ERP */ VCS_update23a(padapter, psta); /* HT related cap */ - if (phtpriv_sta->ht_option) - { + if (phtpriv_sta->ht_option) { /* check if sta supports rx ampdu */ phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; @@ -580,9 +564,7 @@ void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info psta->qos_option = true; - } - else - { + } else { phtpriv_sta->ampdu_enable = false; phtpriv_sta->sgi = false; @@ -1258,8 +1240,7 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) spin_lock_bh(&pmlmepriv->bcn_update_lock); - switch (ie_id) - { + switch (ie_id) { case 0xFF: /* 8: TimeStamp, 2: Beacon Interval 2:Capability */ update_bcn_fixed_ie(padapter); @@ -1386,8 +1367,7 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter) void associated_clients_update23a(struct rtw_adapter *padapter, u8 updated) { /* update associated stations cap. */ - if (updated == true) - { + if (updated == true) { struct list_head *phead, *plist, *ptmp; struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1413,34 +1393,27 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) - { - if (!psta->no_short_preamble_set) - { + if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { + if (!psta->no_short_preamble_set) { psta->no_short_preamble_set = 1; pmlmepriv->num_sta_no_short_preamble++; if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_preamble == 1)) - { + (pmlmepriv->num_sta_no_short_preamble == 1)) { beacon_updated = true; update_beacon23a(padapter, 0xFF, NULL, true); } } - } - else - { - if (psta->no_short_preamble_set) - { + } else { + if (psta->no_short_preamble_set) { psta->no_short_preamble_set = 0; pmlmepriv->num_sta_no_short_preamble--; if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_preamble == 0)) - { + (pmlmepriv->num_sta_no_short_preamble == 0)) { beacon_updated = true; update_beacon23a(padapter, 0xFF, NULL, true); } @@ -1448,32 +1421,25 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info } } - if (psta->flags & WLAN_STA_NONERP) - { - if (!psta->nonerp_set) - { + if (psta->flags & WLAN_STA_NONERP) { + if (!psta->nonerp_set) { psta->nonerp_set = 1; pmlmepriv->num_sta_non_erp++; - if (pmlmepriv->num_sta_non_erp == 1) - { + if (pmlmepriv->num_sta_non_erp == 1) { beacon_updated = true; update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); } } - } - else - { - if (psta->nonerp_set) - { + } else { + if (psta->nonerp_set) { psta->nonerp_set = 0; pmlmepriv->num_sta_non_erp--; - if (pmlmepriv->num_sta_non_erp == 0) - { + if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); } @@ -1481,42 +1447,34 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info } - if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) - { - if (!psta->no_short_slot_time_set) - { + if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) { + if (!psta->no_short_slot_time_set) { psta->no_short_slot_time_set = 1; pmlmepriv->num_sta_no_short_slot_time++; if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_slot_time == 1)) - { + (pmlmepriv->num_sta_no_short_slot_time == 1)) { beacon_updated = true; update_beacon23a(padapter, 0xFF, NULL, true); } } - } - else - { - if (psta->no_short_slot_time_set) - { + } else { + if (psta->no_short_slot_time_set) { psta->no_short_slot_time_set = 0; pmlmepriv->num_sta_no_short_slot_time--; if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_slot_time == 0)) - { + (pmlmepriv->num_sta_no_short_slot_time == 0)) { beacon_updated = true; update_beacon23a(padapter, 0xFF, NULL, true); } } } - if (psta->flags & WLAN_STA_HT) - { + if (psta->flags & WLAN_STA_HT) { u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); DBG_8723A("HT: STA " MAC_FMT " HT Capabilities " @@ -1549,9 +1507,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info pmlmepriv->num_sta_ht_20mhz); } - } - else - { + } else { if (!psta->no_ht_set) { psta->no_ht_set = 1; pmlmepriv->num_sta_no_ht++; @@ -1564,8 +1520,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info } } - if (rtw_ht_operation_update(padapter) > 0) - { + if (rtw_ht_operation_update(padapter) > 0) { update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); } @@ -1589,8 +1544,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info psta->no_short_preamble_set = 0; pmlmepriv->num_sta_no_short_preamble--; if (pmlmeext->cur_wireless_mode > WIRELESS_11B - && pmlmepriv->num_sta_no_short_preamble == 0) - { + && pmlmepriv->num_sta_no_short_preamble == 0) { beacon_updated = true; update_beacon23a(padapter, 0xFF, NULL, true); } @@ -1599,8 +1553,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info if (psta->nonerp_set) { psta->nonerp_set = 0; pmlmepriv->num_sta_non_erp--; - if (pmlmepriv->num_sta_non_erp == 0) - { + if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); @@ -1611,8 +1564,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info psta->no_short_slot_time_set = 0; pmlmepriv->num_sta_no_short_slot_time--; if (pmlmeext->cur_wireless_mode > WIRELESS_11B - && pmlmepriv->num_sta_no_short_slot_time == 0) - { + && pmlmepriv->num_sta_no_short_slot_time == 0) { beacon_updated = true; update_beacon23a(padapter, 0xFF, NULL, true); } @@ -1633,8 +1585,7 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info pmlmepriv->num_sta_ht_20mhz--; } - if (rtw_ht_operation_update(padapter) > 0) - { + if (rtw_ht_operation_update(padapter) > 0) { update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); } @@ -1654,8 +1605,7 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti if (!psta) return beacon_updated; - if (active == true) - { + if (active == true) { /* tear down Rx AMPDU */ send_delba23a(padapter, 0, psta->hwaddr);/* recipient */ @@ -1783,13 +1733,10 @@ void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->qos_option = 0; /* update 802.11n ht cap. */ - if (WLAN_STA_HT&flags) - { + if (WLAN_STA_HT&flags) { psta->htpriv.ht_option = true; psta->qos_option = 1; - } - else - { + } else { psta->htpriv.ht_option = false; } @@ -1802,8 +1749,7 @@ void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta) /* called >= TSR LEVEL for USB or SDIO Interface*/ void ap_sta_info_defer_update23a(struct rtw_adapter *padapter, struct sta_info *psta) { - if (psta->state & _FW_LINKED) - { + if (psta->state & _FW_LINKED) { /* add ratid */ add_RATid23a(padapter, psta, 0);/* DM_RATR_STA_INIT */ } diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index d2d7edf38fc6..65a3cd1d8f48 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1020,8 +1020,7 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) return; - switch (lps_ctrl_type) - { + switch (lps_ctrl_type) { case LPS_CTRL_SCAN: rtl8723a_BT_wifiscan_notify(padapter, true); if (!rtl8723a_BT_using_antenna_1(padapter)) { @@ -1308,8 +1307,7 @@ int rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf; - switch (pdrvextra_cmd->ec_id) - { + switch (pdrvextra_cmd->ec_id) { case DYNAMIC_CHK_WK_CID: dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index c78d6eb0ef89..bbbcfc8257da 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -302,8 +302,7 @@ void rtw_set_supported_rate23a(u8 *SupportedRates, uint mode) memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); - switch (mode) - { + switch (mode) { case WIRELESS_11B: memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); break; diff --git a/drivers/staging/rtl8723au/core/rtw_led.c b/drivers/staging/rtl8723au/core/rtw_led.c index c66e727a2bca..92ab1f8ded96 100644 --- a/drivers/staging/rtl8723au/core/rtw_led.c +++ b/drivers/staging/rtl8723au/core/rtw_led.c @@ -424,29 +424,23 @@ static void SwLedBlink3(struct led_8723a *pLed) u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn23a(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { + } else { if (pLed->CurrLedState != LED_BLINK_WPS_STOP) SwLedOff23a(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } - switch (pLed->CurrLedState) - { + switch (pLed->CurrLedState) { case LED_BLINK_SCAN: pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - { + if (pLed->BlinkTimes == 0) { bStopBlinking = true; } - if (bStopBlinking) - { + if (bStopBlinking) { if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff23a(padapter, pLed); @@ -467,15 +461,11 @@ static void SwLedBlink3(struct led_8723a *pLed) RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedScanBlinkInProgress = false; - } - else - { + } else { if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff23a(padapter, pLed); - } - else - { + } else { if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else @@ -488,12 +478,10 @@ static void SwLedBlink3(struct led_8723a *pLed) case LED_BLINK_TXRX: pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - { + if (pLed->BlinkTimes == 0) { bStopBlinking = true; } - if (bStopBlinking) - { + if (bStopBlinking) { if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff23a(padapter, pLed); @@ -516,15 +504,11 @@ static void SwLedBlink3(struct led_8723a *pLed) RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedBlinkInProgress = false; - } - else - { + } else { if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff23a(padapter, pLed); - } - else - { + } else { if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else @@ -545,8 +529,7 @@ static void SwLedBlink3(struct led_8723a *pLed) break; case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { pLed->BlinkingLedState = RTW_LED_OFF; mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA)); @@ -555,8 +538,7 @@ static void SwLedBlink3(struct led_8723a *pLed) bStopBlinking = true; } - if (bStopBlinking) - { + if (bStopBlinking) { if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff23a(padapter, pLed); @@ -586,8 +568,7 @@ static void SwLedBlink4(struct led_8723a *pLed) unsigned long delay = 0; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn23a(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); } else { @@ -602,8 +583,7 @@ static void SwLedBlink4(struct led_8723a *pLed) SwLedOff23a(padapter, pLed1); } - switch (pLed->CurrLedState) - { + switch (pLed->CurrLedState) { case LED_BLINK_SLOWLY: if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; @@ -752,8 +732,7 @@ static void SwLedBlink5(struct led_8723a *pLed) RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } - switch (pLed->CurrLedState) - { + switch (pLed->CurrLedState) { case LED_BLINK_SCAN: pLed->BlinkTimes--; if (pLed->BlinkTimes == 0) { @@ -855,8 +834,7 @@ SwLedControlMode1(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) long delay = -1; - switch (LedAction) - { + switch (LedAction) { case LED_CTL_POWER_ON: case LED_CTL_START_TO_LINK: case LED_CTL_NO_LINK: @@ -1185,8 +1163,7 @@ SwLedControlMode2(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) break; case LED_CTL_START_TO_LINK: case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) - { + if (!IS_LED_BLINKING(pLed)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; delay = 0; @@ -1230,8 +1207,7 @@ SwLedControlMode3(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) struct led_8723a *pLed = &ledpriv->SwLed0; long delay = -1; - switch (LedAction) - { + switch (LedAction) { case LED_CTL_SITE_SURVEY: if (pmlmepriv->LinkDetectInfo.bBusyTraffic) ; @@ -1345,8 +1321,7 @@ SwLedControlMode3(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) case LED_CTL_START_TO_LINK: case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) - { + if (!IS_LED_BLINKING(pLed)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; delay = 0; @@ -1392,8 +1367,7 @@ SwLedControlMode4(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) struct led_8723a *pLed = &ledpriv->SwLed0; struct led_8723a *pLed1 = &ledpriv->SwLed1; - switch (LedAction) - { + switch (LedAction) { case LED_CTL_START_TO_LINK: if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; @@ -1550,8 +1524,7 @@ SwLedControlMode4(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) } pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - { + if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL)); @@ -1697,8 +1670,7 @@ SwLedControlMode5(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct led_8723a *pLed = &ledpriv->SwLed0; - switch (LedAction) - { + switch (LedAction) { case LED_CTL_POWER_ON: case LED_CTL_NO_LINK: case LED_CTL_LINK: /* solid blue */ @@ -1712,10 +1684,8 @@ SwLedControlMode5(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) if (pmlmepriv->LinkDetectInfo.bBusyTraffic && check_fwstate(pmlmepriv, _FW_LINKED)) ; - else if (pLed->bLedScanBlinkInProgress == false) - { - if (pLed->bLedBlinkInProgress == true) - { + else if (pLed->bLedScanBlinkInProgress == false) { + if (pLed->bLedBlinkInProgress == true) { del_timer_sync(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } -- cgit v1.2.3-59-g8ed1b From 5db8bee627aadf5f666234f551a3528ccf3b5b31 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Thu, 23 Oct 2014 20:17:20 -0700 Subject: Staging: rtl8723au: core: Dont have { on new line This patch fixes the following checkpatch errors: ERROR: that open brace { should be on the previous line ERROR: else should follow close brace '}' Exceptions: { is left on a new line to itself when fixing this error makes the line longer than 80 characters. Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 43 ++++++----------- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 3 +- drivers/staging/rtl8723au/core/rtw_recv.c | 9 ++-- drivers/staging/rtl8723au/core/rtw_security.c | 66 +++++++++------------------ 4 files changed, 39 insertions(+), 82 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e4f4934e357d..86f5217afe93 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -681,8 +681,7 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, } #ifdef CONFIG_8723AU_AP_MODE - switch (stype) - { + switch (stype) { case IEEE80211_STYPE_AUTH: if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) ptable->func = &OnAuth23a; @@ -2337,8 +2336,7 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) __func__, hidden_ssid_mode, ssid_ie, ssid_len_ori); */ if (ssid_ie && ssid_len_ori > 0) { - switch (hidden_ssid_mode) - { + switch (hidden_ssid_mode) { case 1: next_ie = ssid_ie + 2 + ssid_len_ori; remain_len = 0; @@ -4363,9 +4361,7 @@ static void start_create_ibss(struct rtw_adapter *padapter) report_join_res23a(padapter, 1); pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; } - } - else - { + } else { DBG_8723A("%s: invalid cap:%x\n", __func__, caps); return; } @@ -4423,9 +4419,7 @@ static void start_clnt_join(struct rtw_adapter *padapter) pmlmeinfo->state = MSR_ADHOC; report_join_res23a(padapter, 1); - } - else - { + } else { /* DBG_8723A("marc: invalid cap:%x\n", caps); */ return; } @@ -4489,16 +4483,12 @@ int receive_disconnect23a(struct rtw_adapter *padapter, DBG_8723A("%s\n", __func__); - if ((pmlmeinfo->state&0x03) == MSR_INFRA) - { - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) - { + if ((pmlmeinfo->state&0x03) == MSR_INFRA) { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { pmlmeinfo->state = MSR_NOLINK; report_del_sta_event23a(padapter, MacAddr, reason); - } - else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) - { + } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) { pmlmeinfo->state = MSR_NOLINK; report_join_res23a(padapter, -2); } @@ -5004,8 +4994,7 @@ void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta) VCS_update23a(padapter, psta); /* HT */ - if (pmlmepriv->htpriv.ht_option) - { + if (pmlmepriv->htpriv.ht_option) { psta->htpriv.ht_option = true; psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; @@ -5015,9 +5004,7 @@ void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->qos_option = true; - } - else - { + } else { psta->htpriv.ht_option = false; psta->htpriv.ampdu_enable = false; @@ -5059,12 +5046,10 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, goto exit_mlmeext_joinbss_event_callback23a; } - if ((pmlmeinfo->state&0x03) == MSR_ADHOC) - { + if ((pmlmeinfo->state&0x03) == MSR_ADHOC) { /* for bc/mc */ psta_bmc = rtw_get_bcmc_stainfo23a(padapter); - if (psta_bmc) - { + if (psta_bmc) { pmlmeinfo->FW_sta_info[psta_bmc->mac_id].psta = psta_bmc; update_bmc_sta_support_rate23a(padapter, psta_bmc->mac_id); Update_RA_Entry23a(padapter, psta_bmc); @@ -5095,8 +5080,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); psta = rtw_get_stainfo23a(pstapriv, cur_network->MacAddress); - if (psta) /* only for infra. mode */ - { + if (psta) { /* only for infra. mode */ pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; /* DBG_8723A("set_sta_rate23a\n"); */ @@ -5132,8 +5116,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, if ((pmlmeinfo->state & 0x03) == MSR_ADHOC) { /* adhoc master or sta_count>1 */ - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) - { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { /* nothing to do */ } else { /* adhoc client */ /* correcting TSF */ diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 32f1ab515f91..1eae885c1170 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -338,8 +338,7 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms) start_time = jiffies; end_time = start_time + msecs_to_jiffies(delay_ms); - while (1) - { + while (1) { bAwake = rtl8723a_get_fwlps_rf_on(padapter); if (bAwake == true) break; diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 4dca863657ec..0c0896f3a16b 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1410,8 +1410,7 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt =%d\n", pattrib->encrypt)); - switch (pattrib->encrypt) - { + switch (pattrib->encrypt) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: pattrib->iv_len = IEEE80211_WEP_IV_LEN; @@ -1510,8 +1509,7 @@ static int validate_recv_frame(struct rtw_adapter *adapter, if (unlikely(bDumpRxPkt == 1)) dump_rx_pkt(skb, type, bDumpRxPkt); - switch (type) - { + switch (type) { case IEEE80211_FTYPE_MGMT: retval = validate_recv_mgnt_frame(adapter, precv_frame); if (retval == _FAIL) { @@ -2182,8 +2180,7 @@ int process_recv_indicatepkts(struct rtw_adapter *padapter, return retval; } } - } else /* B/G mode */ - { + } else { /* B/G mode */ retval = wlanhdr_to_ethhdr(prframe); if (retval != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index 60e944554ec5..715a47414bdd 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -44,8 +44,7 @@ static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) state[counter] = (u8)counter; keyindex = 0; stateindex = 0; - for (counter = 0; counter < 256; counter++) - { + for (counter = 0; counter < 256; counter++) { t = state[counter]; stateindex = (stateindex + key[keyindex] + t) & 0xff; u = state[stateindex]; @@ -113,8 +112,7 @@ static void crc32_init(void) c = 0x12340000; - for (i = 0; i < 256; ++i) - { + for (i = 0; i < 256; ++i) { k = crc32_reverseBit((u8)i); for (c = ((u32)k) << 24, j = 8; j > 0; --j) { c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); @@ -269,8 +267,7 @@ static u32 secmicgetuint32(u8 *p) s32 i; u32 res = 0; - for (i = 0; i<4; i++) - { + for (i = 0; i<4; i++) { res |= ((u32)(*p++)) << (8*i); } @@ -282,8 +279,7 @@ static void secmicputuint32(u8 *p, u32 val) { long i; - for (i = 0; i<4; i++) - { + for (i = 0; i<4; i++) { *p++ = (u8) (val & 0xff); val >>= 8; } @@ -319,8 +315,7 @@ void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b) pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); pmicdata->nBytesInM++; /* Process the word if it is full. */ - if (pmicdata->nBytesInM >= 4) - { + if (pmicdata->nBytesInM >= 4) { pmicdata->L ^= pmicdata->M; pmicdata->R ^= ROL32(pmicdata->L, 17); pmicdata->L += pmicdata->R; @@ -341,8 +336,7 @@ void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbytes) { /* This is simple */ - while(nbytes > 0) - { + while(nbytes > 0) { rtw_secmicappend23abyte23a(pmicdata, *src++); nbytes--; } @@ -359,8 +353,7 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst) rtw_secmicappend23abyte23a(pmicdata, 0); rtw_secmicappend23abyte23a(pmicdata, 0); /* and then zeroes until the length is a multiple of 4 */ - while(pmicdata->nBytesInM != 0) - { + while(pmicdata->nBytesInM != 0) { rtw_secmicappend23abyte23a(pmicdata, 0); } /* The appendByte function has already computed the result. */ @@ -529,8 +522,8 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) /* Now compute an unbalanced Feistel cipher with 80-bit block */ /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ - for (i = 0; i < PHASE1_LOOP_CNT ;i++) - { /* Each add operation here is mod 2**16 */ + for (i = 0; i < PHASE1_LOOP_CNT ;i++) { + /* Each add operation here is mod 2**16 */ p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); @@ -600,8 +593,7 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ - for (i = 0;i<6;i++) - { + for (i = 0;i<6;i++) { rc4key[4+2*i] = Lo8(PPK[i]); rc4key[5+2*i] = Hi8(PPK[i]); } @@ -647,8 +639,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, if (stainfo!= NULL) { - if (!(stainfo->state &_FW_LINKED)) - { + if (!(stainfo->state &_FW_LINKED)) { DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state); return _FAIL; } @@ -885,8 +876,7 @@ static void byte_sub(u8 *in, u8 *out) { int i; - for (i = 0; i< 16; i++) - { + for (i = 0; i< 16; i++) { out[i] = sbox(in[i]); } @@ -926,8 +916,7 @@ static void mix_column(u8 *in, u8 *out) u8 temp[4]; u8 tempb[4]; - for (i = 0 ; i<4; i++) - { + for (i = 0 ; i<4; i++) { if ((in[i] & 0x80) == 0x80) add1b[i] = 0x1b; else @@ -949,11 +938,9 @@ static void mix_column(u8 *in, u8 *out) andf7[2] = in[2] & 0x7f; andf7[3] = in[3] & 0x7f; - for (i = 3; i>0; i--) /* logical shift left 1 bit */ - { + for (i = 3; i>0; i--) { /* logical shift left 1 bit */ andf7[i] = andf7[i] << 1; - if ((andf7[i-1] & 0x80) == 0x80) - { + if ((andf7[i-1] & 0x80) == 0x80) { andf7[i] = (andf7[i] | 0x01); } } @@ -986,21 +973,15 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) for (i = 0; i<16; i++) round_key[i] = key[i]; - for (round = 0; round < 11; round++) - { - if (round == 0) - { + for (round = 0; round < 11; round++) { + if (round == 0) { xor_128(round_key, data, ciphertext); next_key(round_key, round); - } - else if (round == 10) - { + } else if (round == 10) { byte_sub(ciphertext, intermediatea); shift_row(intermediatea, intermediateb); xor_128(intermediateb, round_key, ciphertext); - } - else /* 1 - 9 */ - { + } else { /* 1 - 9 */ byte_sub(ciphertext, intermediatea); shift_row(intermediatea, intermediateb); mix_column(&intermediateb[0], &intermediatea[0]); @@ -1086,20 +1067,17 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, mic_header2[6] = 0x00; mic_header2[7] = 0x00; /* mpdu[23]; */ - if (!qc_exists && a4_exists) - { + if (!qc_exists && a4_exists) { for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */ } - if (qc_exists && !a4_exists) - { + if (qc_exists && !a4_exists) { mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ mic_header2[9] = mpdu[25] & 0x00; } - if (qc_exists && a4_exists) - { + if (qc_exists && a4_exists) { for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */ mic_header2[14] = mpdu[30] & 0x0f; -- cgit v1.2.3-59-g8ed1b From 3e3f878f4d38c0724e51e192f232e1726daffd89 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Thu, 23 Oct 2014 20:17:48 -0700 Subject: Staging: rtl8723au: core: Fix switch-case indent This patch fixes the following checkpatch errors in rtw_cmd.c : ERROR: switch and case should be at the same indent Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 70 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 65a3cd1d8f48..01b44a4364dc 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1021,44 +1021,44 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) return; switch (lps_ctrl_type) { - case LPS_CTRL_SCAN: - rtl8723a_BT_wifiscan_notify(padapter, true); - if (!rtl8723a_BT_using_antenna_1(padapter)) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) - LPS_Leave23a(padapter); + case LPS_CTRL_SCAN: + rtl8723a_BT_wifiscan_notify(padapter, true); + if (!rtl8723a_BT_using_antenna_1(padapter)) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) + LPS_Leave23a(padapter); } - break; - case LPS_CTRL_JOINBSS: + break; + case LPS_CTRL_JOINBSS: + LPS_Leave23a(padapter); + break; + case LPS_CTRL_CONNECT: + mstatus = 1;/* connect */ + /* Reset LPS Setting */ + padapter->pwrctrlpriv.LpsIdleCount = 0; + rtl8723a_set_FwJoinBssReport_cmd(padapter, 1); + rtl8723a_BT_mediastatus_notify(padapter, mstatus); + break; + case LPS_CTRL_DISCONNECT: + mstatus = 0;/* disconnect */ + rtl8723a_BT_mediastatus_notify(padapter, mstatus); + if (!rtl8723a_BT_using_antenna_1(padapter)) LPS_Leave23a(padapter); - break; - case LPS_CTRL_CONNECT: - mstatus = 1;/* connect */ - /* Reset LPS Setting */ - padapter->pwrctrlpriv.LpsIdleCount = 0; - rtl8723a_set_FwJoinBssReport_cmd(padapter, 1); - rtl8723a_BT_mediastatus_notify(padapter, mstatus); - break; - case LPS_CTRL_DISCONNECT: - mstatus = 0;/* disconnect */ - rtl8723a_BT_mediastatus_notify(padapter, mstatus); - if (!rtl8723a_BT_using_antenna_1(padapter)) - LPS_Leave23a(padapter); - rtl8723a_set_FwJoinBssReport_cmd(padapter, 0); - break; - case LPS_CTRL_SPECIAL_PACKET: - pwrpriv->DelayLPSLastTimeStamp = jiffies; - rtl8723a_BT_specialpacket_notify(padapter); - if (!rtl8723a_BT_using_antenna_1(padapter)) - LPS_Leave23a(padapter); - break; - case LPS_CTRL_LEAVE: - rtl8723a_BT_lps_leave(padapter); - if (!rtl8723a_BT_using_antenna_1(padapter)) - LPS_Leave23a(padapter); - break; + rtl8723a_set_FwJoinBssReport_cmd(padapter, 0); + break; + case LPS_CTRL_SPECIAL_PACKET: + pwrpriv->DelayLPSLastTimeStamp = jiffies; + rtl8723a_BT_specialpacket_notify(padapter); + if (!rtl8723a_BT_using_antenna_1(padapter)) + LPS_Leave23a(padapter); + break; + case LPS_CTRL_LEAVE: + rtl8723a_BT_lps_leave(padapter); + if (!rtl8723a_BT_using_antenna_1(padapter)) + LPS_Leave23a(padapter); + break; - default: - break; + default: + break; } } -- cgit v1.2.3-59-g8ed1b From 1d06bb4e9df30162d8690a26792611a141676279 Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Sat, 25 Oct 2014 10:58:28 +0800 Subject: staging: remove unneeded parentheses around the right hand side of an assignment In assignments such as value = (FLASH_CMD_STATUS_REG_READ << 24);, parentheses are not needed. The Coccinelle semantic patch was used to find cases. @r@ identifier x; expression e1, e2; @@ - x = (e1 << e2); + x = e1 << e2; Signed-off-by: Jiayi Ye Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- drivers/staging/lustre/lustre/libcfs/debug.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 2 +- drivers/staging/media/omap24xx/omap24xxcam.c | 2 +- drivers/staging/ozwpan/ozhcd.c | 6 +++--- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/hal/hal_com.c | 2 +- drivers/staging/vt6655/dpc.c | 2 +- drivers/staging/xgifb/vb_setmode.c | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 8f5cdd584f85..045f2beb41d2 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2411,7 +2411,7 @@ kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev) goto out; } - mr_size = (1ULL << hdev->ibh_mr_shift); + mr_size = 1ULL << hdev->ibh_mr_shift; mm_size = (unsigned long)high_memory - PAGE_OFFSET; hdev->ibh_nmrs = (int)((mm_size + mr_size - 1) >> hdev->ibh_mr_shift); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 6054eee848d3..3822e0f3faf0 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -265,7 +265,7 @@ static void ldlm_pool_recalc_slv(struct ldlm_pool *pl) * SLV. And the opposite, the more grant plan is over-consumed * (load time) the faster drops SLV. */ - slv_factor = (grant_usage << LDLM_POOL_SLV_SHIFT); + slv_factor = grant_usage << LDLM_POOL_SLV_SHIFT; do_div(slv_factor, limit); slv = slv * slv_factor; slv = dru(slv, LDLM_POOL_SLV_SHIFT, round_up); diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index ba43b3067fa3..2c15a9e7332f 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -412,7 +412,7 @@ int libcfs_debug_init(unsigned long bufsize) max = TCD_MAX_PAGES; } else { max = (max / num_possible_cpus()); - max = (max << (20 - PAGE_CACHE_SHIFT)); + max = max << (20 - PAGE_CACHE_SHIFT); } rc = cfs_tracefile_init(max); diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 1f53b9863385..613d772357ac 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -145,7 +145,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, */ io->ci_lockreq = CILR_NEVER; - pos = (vmpage->index << PAGE_CACHE_SHIFT); + pos = vmpage->index << PAGE_CACHE_SHIFT; /* Create a temp IO to serve write. */ result = cl_io_rw_init(env, io, CIT_WRITE, pos, PAGE_CACHE_SIZE); diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 8828d6c2aab1..415502651033 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -633,7 +633,7 @@ resizer_calculate_normal_f_div_param(struct device *dev, int input_width, if (!(val % 2)) { h1 = val; } else { - val = (input_width << 7); + val = input_width << 7; val -= rsz >> 1; val /= rsz << 1; val <<= 1; diff --git a/drivers/staging/media/omap24xx/omap24xxcam.c b/drivers/staging/media/omap24xx/omap24xxcam.c index 5ca2bf5353fe..36d81e0e114c 100644 --- a/drivers/staging/media/omap24xx/omap24xxcam.c +++ b/drivers/staging/media/omap24xx/omap24xxcam.c @@ -326,7 +326,7 @@ static int omap24xxcam_vbq_alloc_mmap_buffer(struct videobuf_buffer *vb) dma->sglen++; i++; - alloc_size = (PAGE_SIZE << order); + alloc_size = PAGE_SIZE << order; /* clear pages before giving them to user space */ memset(page_address(page), 0, alloc_size); diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index e88045228607..8a52feb6e72e 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -2032,11 +2032,11 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) break; case USB_PORT_FEAT_C_CONNECTION: oz_dbg(HUB, "USB_PORT_FEAT_C_CONNECTION\n"); - clear_bits = (USB_PORT_STAT_C_CONNECTION << 16); + clear_bits = USB_PORT_STAT_C_CONNECTION << 16; break; case USB_PORT_FEAT_C_ENABLE: oz_dbg(HUB, "USB_PORT_FEAT_C_ENABLE\n"); - clear_bits = (USB_PORT_STAT_C_ENABLE << 16); + clear_bits = USB_PORT_STAT_C_ENABLE << 16; break; case USB_PORT_FEAT_C_SUSPEND: oz_dbg(HUB, "USB_PORT_FEAT_C_SUSPEND\n"); @@ -2046,7 +2046,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) break; case USB_PORT_FEAT_C_RESET: oz_dbg(HUB, "USB_PORT_FEAT_C_RESET\n"); - clear_bits = (USB_PORT_FEAT_C_RESET << 16); + clear_bits = USB_PORT_FEAT_C_RESET << 16; break; case USB_PORT_FEAT_TEST: oz_dbg(HUB, "USB_PORT_FEAT_TEST\n"); diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index caf2ca3a47e7..ac6abac58bfe 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1673,7 +1673,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) pRegToSet = RegToSet_Normal; /* 0xb972a841; */ FactorToSet = *((u8 *)val); if (FactorToSet <= 3) { - FactorToSet = (1<<(FactorToSet + 2)); + FactorToSet = 1 << (FactorToSet + 2); if (FactorToSet > 0xf) FactorToSet = 0xf; diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index f906317579bc..bf4cae20bd12 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -463,7 +463,7 @@ void rtl8723a_set_ampdu_factor(struct rtw_adapter *padapter, u8 FactorToSet) MaxAggNum = 0xF; if (FactorToSet <= 3) { - FactorToSet = (1 << (FactorToSet + 2)); + FactorToSet = 1 << (FactorToSet + 2); if (FactorToSet > MaxAggNum) FactorToSet = MaxAggNum; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 344e12f1184e..eecf6f559e29 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -358,7 +358,7 @@ device_receive_frame( if ((*pbyRsr & RSR_CRCOK) != 0) pDevice->byBasicMap |= 0x01; - dwDuration = (FrameSize << 4); + dwDuration = FrameSize << 4; dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE]; if (*pbyRxRate <= RATE_11M) { if (*pbyRxSts & 0x01) { diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index d5f49d2a8db3..1f6f699e238c 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -4135,7 +4135,7 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex, tempax -= 1; temp = (tempax & 0xFF00) >> 8; - temp = ((temp & 0x0003) << 4); + temp = (temp & 0x0003) << 4; xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); temp = (tempax & 0x00FF); xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); -- cgit v1.2.3-59-g8ed1b From 4475cf2ebff33bf669661daab4fa6e9eec349552 Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Sat, 25 Oct 2014 01:42:09 +0530 Subject: Staging: comedi: ni_mio_common.c: fixed brace coding style issue in two places Removed unnecessary braces with the help of checkpatch.pl tool. Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c855787e28f3..785ad7004d98 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -686,13 +686,12 @@ static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel) { unsigned bitfield; - if (channel >= 0) { + if (channel >= 0) bitfield = (ni_stc_dma_channel_select_bitfield(channel) << AI_DMA_Select_Shift) & AI_DMA_Select_Mask; - } else { + else bitfield = 0; - } ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield); } @@ -701,13 +700,12 @@ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) { unsigned bitfield; - if (channel >= 0) { + if (channel >= 0) bitfield = (ni_stc_dma_channel_select_bitfield(channel) << AO_DMA_Select_Shift) & AO_DMA_Select_Mask; - } else { + else bitfield = 0; - } ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield); } -- cgit v1.2.3-59-g8ed1b From f14557f93620f78adcf419f1adaa281947a5101d Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Fri, 24 Oct 2014 21:45:26 +0530 Subject: staging: rtl8192e: Remove unnecessary code kfree on NULL pointer is a no-op. This used the following semantic patch to identify such a instance // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // As rxb is always null at this point, so the code to kfree it and intializing it to NULL is removed completely. Suggested by: Julia Lawall Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 1c2014fd8d81..ca76ad013f5f 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1415,10 +1415,6 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 1; rx_dropped: - if (rxb != NULL) { - kfree(rxb); - rxb = NULL; - } ieee->stats.rx_dropped++; /* Returning 0 indicates to caller that we have not handled the SKB-- -- cgit v1.2.3-59-g8ed1b From 157b8e59fae807936cd98884dc43f90dbb0d5e57 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Fri, 24 Oct 2014 21:45:11 +0530 Subject: staging: rtl8188eu: os_dep: Remove null check before kfree This patch is generated by the following semantic patch // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index d8605be07a71..70b729f26613 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -2697,10 +2697,8 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, ie_len = len-12-2;/* 12 = param header, 2:no packed */ - if (pmlmepriv->wps_beacon_ie) { - kfree(pmlmepriv->wps_beacon_ie); - pmlmepriv->wps_beacon_ie = NULL; - } + kfree(pmlmepriv->wps_beacon_ie); + pmlmepriv->wps_beacon_ie = NULL; if (ie_len > 0) { pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); @@ -2734,10 +2732,8 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par ie_len = len-12-2;/* 12 = param header, 2:no packed */ - if (pmlmepriv->wps_probe_resp_ie) { - kfree(pmlmepriv->wps_probe_resp_ie); - pmlmepriv->wps_probe_resp_ie = NULL; - } + kfree(pmlmepriv->wps_probe_resp_ie); + pmlmepriv->wps_probe_resp_ie = NULL; if (ie_len > 0) { pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); @@ -2766,10 +2762,8 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par ie_len = len-12-2;/* 12 = param header, 2:no packed */ - if (pmlmepriv->wps_assoc_resp_ie) { - kfree(pmlmepriv->wps_assoc_resp_ie); - pmlmepriv->wps_assoc_resp_ie = NULL; - } + kfree(pmlmepriv->wps_assoc_resp_ie); + pmlmepriv->wps_assoc_resp_ie = NULL; if (ie_len > 0) { pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); -- cgit v1.2.3-59-g8ed1b From 0297ac39fae9edcccf8752a53e6ce6f903469c4f Mon Sep 17 00:00:00 2001 From: tssurya Date: Sat, 25 Oct 2014 00:37:33 +0530 Subject: Staging: comedi: ni_tiocmd: fixed a brace coding style issue Removed unneeded braces with the help of checkpatch.pl tool. Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 26e7291c4a51..46cf3eb2ee54 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -371,9 +371,8 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, of gate interrupt via dma read/write and report bogus gate errors */ if (counter->counter_dev->variant != - ni_gpct_variant_660x) { + ni_gpct_variant_660x) *gate_error = 1; - } } } if (gxx_status & GI_TC_ERROR(cidx)) { -- cgit v1.2.3-59-g8ed1b From 00e053bd9f7a86a8ed8f9a057dc994b610e3add7 Mon Sep 17 00:00:00 2001 From: WANG Chao Date: Tue, 14 Oct 2014 16:58:37 +0800 Subject: staging, unisys: remove leftover function kmalloc_kernel() kmalloc_kernel() previously declared in timskmodutils.h which recently got removed. Now also remove kmalloc_kernel(), because it's not used anywhere. Signed-off-by: WANG Chao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/visorkmodutils.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index d6815f9e1337..64b135d83c0d 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -36,16 +36,6 @@ int unisys_spar_platform; EXPORT_SYMBOL_GPL(unisys_spar_platform); -/** Callers to interfaces that set __GFP_NORETRY flag below - * must check for a NULL (error) result as we are telling the - * kernel interface that it is okay to fail. - */ - -void *kmalloc_kernel(size_t siz) -{ - return kmalloc(siz, GFP_KERNEL | __GFP_NORETRY); -} - static __init uint32_t visorutil_spar_detect(void) { -- cgit v1.2.3-59-g8ed1b From 1846472c911ce93fd6a140d821f5a393ac639cc0 Mon Sep 17 00:00:00 2001 From: Shrikrishna Khare Date: Sat, 18 Oct 2014 15:57:37 -0700 Subject: Staging: unisys: visorutil: easyproc: fixed a line over 80 characters coding style issue Fixed a coding style issue. Signed-off-by: Shrikrishna Khare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/easyproc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorutil/easyproc.c b/drivers/staging/unisys/visorutil/easyproc.c index 3b388494e2af..40f1ae9a155c 100644 --- a/drivers/staging/unisys/visorutil/easyproc.c +++ b/drivers/staging/unisys/visorutil/easyproc.c @@ -254,9 +254,9 @@ void visor_easyproc_CreateDeviceProperty(struct easyproc_device_info *p, } strcpy(px->property_name, property_name); if (px->procEntry == NULL) { - ERRDEVX(p->devno, "failed to register /proc/%s/device/%d/%s entry", - p->pdriver->ProcId, p->devno, property_name - ); + ERRDEVX(p->devno, + "failed to register /proc/%s/device/%d/%s entry", + p->pdriver->ProcId, p->devno, property_name); return; } px->show_device_property_info = show_property_info; -- cgit v1.2.3-59-g8ed1b From df55a1fadf4a542a2457288178354bf47321f75a Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:40 -0400 Subject: staging: unisys: clean up bracing in vbuschannel_sanitize_buffer() The bracing in vbuschannel_sanitize_buffer() in vbusdeviceinfo.h is messy. Clean these up. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index f13dddc1b5c8..58b64a3ac6eb 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -63,8 +63,9 @@ vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax) p++; remain--; chars++; - } else if (p == NULL) + } else if (p == NULL) { chars++; + } nonprintable_streak = 0; } if (remain > 0) { @@ -72,10 +73,12 @@ vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax) p++; remain--; chars++; - } else if (p == NULL) + } else if (p == NULL) { chars++; - } else + } + } else { nonprintable_streak = 1; + } src++; srcmax--; } -- cgit v1.2.3-59-g8ed1b From a6208124b260f2cdfa5470bd4de1a190db728294 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:41 -0400 Subject: staging: unisys: fix indentation on vbuschannel_devinfo_to_string() Fix the parameter indentation for vbuschannel_devinfo_to_string(), in vbusdeviceinfo.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index 58b64a3ac6eb..de0447c97df4 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -151,7 +151,7 @@ vbuschannel_itoa(char *p, int remain, int num) */ static inline int vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo, - char *p, int remain, int devix) + char *p, int remain, int devix) { char *psrc; int nsrc, x, i, pad; -- cgit v1.2.3-59-g8ed1b From 8d507c664d99ccb6885e76718b9b95c5911746d6 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:42 -0400 Subject: staging: unisys: clean up extra parens in vbuschannel_devinfo_to_string Get rid of the unnecessary parenthesis in several assignments in vbuschannel_devinfo_to_string(). Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index de0447c97df4..28864a89908c 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -157,7 +157,7 @@ vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo, int nsrc, x, i, pad; int chars = 0; - psrc = &(devinfo->devtype[0]); + psrc = &devinfo->devtype[0]; nsrc = sizeof(devinfo->devtype); if (vbuschannel_sanitize_buffer(NULL, 0, psrc, nsrc) <= 0) return 0; @@ -187,7 +187,7 @@ vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo, VBUSCHANNEL_ADDACHAR(' ', p, remain, chars); /* emit driver name */ - psrc = &(devinfo->drvname[0]); + psrc = &devinfo->drvname[0]; nsrc = sizeof(devinfo->drvname); x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc); p += x; @@ -199,7 +199,7 @@ vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo, VBUSCHANNEL_ADDACHAR(' ', p, remain, chars); /* emit strings */ - psrc = &(devinfo->infostrs[0]); + psrc = &devinfo->infostrs[0]; nsrc = sizeof(devinfo->infostrs); x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc); p += x; -- cgit v1.2.3-59-g8ed1b From 0d2400c35824cb37cae83d6a039166a5067bf047 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:43 -0400 Subject: staging: unisys: delete extra space character in vbuschannel_itoa() There's no need for that extra space in the typecast in vbuschannel_itoa(), so just delete it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index 28864a89908c..9b6d3e69355c 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -118,7 +118,7 @@ vbuschannel_itoa(char *p, int remain, int num) } /* form a backwards decimal ascii string in */ while (num > 0) { - if (digits >= (int) sizeof(s)) + if (digits >= (int)sizeof(s)) return 0; s[digits++] = (num % 10) + '0'; num = num / 10; -- cgit v1.2.3-59-g8ed1b From 753541ccead2353fa1afa34328cab79e791d5f05 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:44 -0400 Subject: staging: unisys: fix typedef for VMCALL_MONITOR_INTERFACE_METHOD_TUPLE Get rid of the typedef for VMCALL_MONITOR_INTERFACE_METHOD_TUPLE in favor of enum vmcall_monitor_interface_method_tuple. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index 7750086e5bb3..f19e29c003d1 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -33,7 +33,7 @@ /* define subsystem number for AppOS, used in uislib driver */ #define MDS_APPOS 0x4000000000000000L /* subsystem = 62 - AppOS */ -typedef enum { /* VMCALL identification tuples */ +enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples */ /* Note: when a new VMCALL is added: * - the 1st 2 hex digits correspond to one of the * VMCALL_MONITOR_INTERFACE types and @@ -66,7 +66,7 @@ typedef enum { /* VMCALL identification tuples */ * ULTRA_SERVICE_CAPABILITY_TIME * capable guest to make * VMCALL */ -} VMCALL_MONITOR_INTERFACE_METHOD_TUPLE; +}; #define VMCALL_SUCCESS 0 #define VMCALL_SUCCESSFUL(result) (result == 0) -- cgit v1.2.3-59-g8ed1b From d835a90c81fd13f936a6c5377caac7c61db91081 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:45 -0400 Subject: staging: unisys: fix CamelCase in ISSUE_IO_VMCALL macros Fix the parameter name in ISSUE_IO_VMCALL and ISSUE_IO_EXTENDED_VMCALL. Fix CamelCase names: InterfaceMethod => method Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index f19e29c003d1..cc8ed6e4cdb4 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -76,12 +76,12 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples */ __unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx) #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \ __unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx) -#define ISSUE_IO_VMCALL(InterfaceMethod, param, result) \ - (result = unisys_vmcall(InterfaceMethod, (param) & 0xFFFFFFFF, \ +#define ISSUE_IO_VMCALL(method, param, result) \ + (result = unisys_vmcall(method, (param) & 0xFFFFFFFF, \ (param) >> 32)) -#define ISSUE_IO_EXTENDED_VMCALL(InterfaceMethod, param1, param2, \ +#define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2, \ param3, result) \ - (result = unisys_extended_vmcall(InterfaceMethod, param1, \ + (result = unisys_extended_vmcall(method, param1, \ param2, param3)) /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently -- cgit v1.2.3-59-g8ed1b From eb44bd3f43429fcedde1aaff3e83badf17c8b3d9 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:46 -0400 Subject: staging: unisys: get rid of IO_DATA_STRUCTURE typedef Nobody was using this, so just remove it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index cc8ed6e4cdb4..78333719c496 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -107,7 +107,6 @@ struct phys_info { #pragma pack(pop) /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ -typedef struct phys_info IO_DATA_STRUCTURE; /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ -- cgit v1.2.3-59-g8ed1b From 9eee5d1f3ee1922d5153f732149dcf0c0a26581f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:47 -0400 Subject: staging: unisys: fix CamelCase channel constants The channel definitions in channel_guid.h contain several CamelCase constants. Fix these so they are no longer incorrectly cased, and use the name spar instead of the old "ultra" reference. Also, rename the corresponding UUID macros to match. Update all references to constants or UUID macros that were changed. Fix CamelCase names: UltraVhbaChannelProtocolGuid => spar_vhba_channel_protocol_uuid UltraVnicChannelProtocolGuid => spar_vnic_channel_protocol_uuid UltraSIOVMGuid => spar_siovm_uuid UltraControlDirectorChannelProtocolGuid => spar_controldirector_channel_protocol_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/channel_guid.h | 24 +++++++++++----------- .../common-spar/include/channels/iochannel.h | 12 +++++------ drivers/staging/unisys/uislib/uislib.c | 22 ++++++++++---------- .../unisys/visorchipset/visorchipset_main.c | 8 +++++--- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h index 63c67ca4c9ec..16df33a751a6 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h @@ -20,44 +20,44 @@ /* Used in IOChannel * {414815ed-c58c-11da-95a9-00e08161165f} */ -#define ULTRA_VHBA_CHANNEL_PROTOCOL_GUID \ +#define SPAR_VHBA_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x414815ed, 0xc58c, 0x11da, \ 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f) -static const uuid_le UltraVhbaChannelProtocolGuid = - ULTRA_VHBA_CHANNEL_PROTOCOL_GUID; +static const uuid_le spar_vhba_channel_protocol_uuid = + SPAR_VHBA_CHANNEL_PROTOCOL_UUID; /* Used in IOChannel * {8cd5994d-c58e-11da-95a9-00e08161165f} */ -#define ULTRA_VNIC_CHANNEL_PROTOCOL_GUID \ +#define SPAR_VNIC_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x8cd5994d, 0xc58e, 0x11da, \ 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f) -static const uuid_le UltraVnicChannelProtocolGuid = - ULTRA_VNIC_CHANNEL_PROTOCOL_GUID; +static const uuid_le spar_vnic_channel_protocol_uuid = + SPAR_VNIC_CHANNEL_PROTOCOL_UUID; /* Used in IOChannel * {72120008-4AAB-11DC-8530-444553544200} */ -#define ULTRA_SIOVM_GUID \ +#define SPAR_SIOVM_UUID \ UUID_LE(0x72120008, 0x4AAB, 0x11DC, \ 0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00) -static const uuid_le UltraSIOVMGuid = ULTRA_SIOVM_GUID; +static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID; /* Used in visornoop/visornoop_main.c * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f} */ -#define ULTRA_CONTROLDIRECTOR_CHANNEL_PROTOCOL_GUID \ +#define SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x5b52c5ac, 0xe5f5, 0x4d42, \ 0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f) -static const uuid_le UltraControlDirectorChannelProtocolGuid = - ULTRA_CONTROLDIRECTOR_CHANNEL_PROTOCOL_GUID; +static const uuid_le spar_controldirector_channel_protocol_uuid = + SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID; /* Used in visorchipset/visorchipset_main.c * {B4E79625-AEDE-4EAA-9E11-D3EDDCD4504C} */ -#define ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID \ +#define SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID \ UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \ 0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 806d5b3bca48..7de87a481a8c 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -61,23 +61,23 @@ #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1 #define ULTRA_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, UltraVhbaChannelProtocolGuid, \ + (ULTRA_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \ "vhba", MIN_IO_CHANNEL_SIZE, \ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE, \ __FILE__, __LINE__, logCtx)) #define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraVhbaChannelProtocolGuid, \ + (ULTRA_check_channel_server(spar_vhba_channel_protocol_uuid, \ "vhba", MIN_IO_CHANNEL_SIZE, actualBytes, \ __FILE__, __LINE__, logCtx)) #define ULTRA_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, UltraVnicChannelProtocolGuid, \ + (ULTRA_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, \ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE, \ __FILE__, __LINE__, logCtx)) #define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraVnicChannelProtocolGuid, \ + (ULTRA_check_channel_server(spar_vnic_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, actualBytes, \ __FILE__, __LINE__, logCtx)) #define ULTRA_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ @@ -807,7 +807,7 @@ static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, x->ChannelHeader.SrvState = CHANNELSRV_UNINITIALIZED; x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader); x->ChannelHeader.Size = COVER(bytes, 4096); - x->ChannelHeader.Type = UltraVhbaChannelProtocolGuid; + x->ChannelHeader.Type = spar_vhba_channel_protocol_uuid; x->ChannelHeader.ZoneGuid = NULL_UUID_LE; x->vhba.wwnn = *wwnn; x->vhba.max = *max; @@ -843,7 +843,7 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, x->ChannelHeader.SrvState = CHANNELSRV_UNINITIALIZED; x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader); x->ChannelHeader.Size = COVER(bytes, 4096); - x->ChannelHeader.Type = UltraVnicChannelProtocolGuid; + x->ChannelHeader.Type = spar_vnic_channel_protocol_uuid; x->ChannelHeader.ZoneGuid = NULL_UUID_LE; memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); x->vnic.num_rcv_bufs = num_rcv_bufs; diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index b1f6c6ef801b..35e8a61c7202 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -443,7 +443,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) struct guest_msgs cmd; if (!uuid_le_cmp(dev->channel_uuid, - UltraVhbaChannelProtocolGuid)) { + spar_vhba_channel_protocol_uuid)) { wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> @@ -468,7 +468,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) cmd.add_vhba.intr = dev->intr; } else if (!uuid_le_cmp(dev->channel_uuid, - UltraVnicChannelProtocolGuid)) { + spar_vnic_channel_protocol_uuid)) { wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> @@ -585,11 +585,11 @@ pause_device(CONTROLVM_MESSAGE *msg) * guest_msgs struct to callback */ if (!uuid_le_cmp(dev->channel_uuid, - UltraVhbaChannelProtocolGuid)) { + spar_vhba_channel_protocol_uuid)) { cmd.msgtype = GUEST_PAUSE_VHBA; cmd.pause_vhba.chanptr = dev->chanptr; } else if (!uuid_le_cmp(dev->channel_uuid, - UltraVnicChannelProtocolGuid)) { + spar_vnic_channel_protocol_uuid)) { cmd.msgtype = GUEST_PAUSE_VNIC; cmd.pause_vnic.chanptr = dev->chanptr; } else { @@ -654,11 +654,11 @@ resume_device(CONTROLVM_MESSAGE *msg) */ if (retval == CONTROLVM_RESP_SUCCESS) { if (!uuid_le_cmp(dev->channel_uuid, - UltraVhbaChannelProtocolGuid)) { + spar_vhba_channel_protocol_uuid)) { cmd.msgtype = GUEST_RESUME_VHBA; cmd.resume_vhba.chanptr = dev->chanptr; } else if (!uuid_le_cmp(dev->channel_uuid, - UltraVnicChannelProtocolGuid)) { + spar_vnic_channel_protocol_uuid)) { cmd.msgtype = GUEST_RESUME_VNIC; cmd.resume_vnic.chanptr = dev->chanptr; } else { @@ -724,11 +724,11 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) * guest_msgs struct to callback */ if (!uuid_le_cmp(dev->channel_uuid, - UltraVhbaChannelProtocolGuid)) { + spar_vhba_channel_protocol_uuid)) { cmd.msgtype = GUEST_DEL_VHBA; cmd.del_vhba.chanptr = dev->chanptr; } else if (!uuid_le_cmp(dev->channel_uuid, - UltraVnicChannelProtocolGuid)) { + spar_vnic_channel_protocol_uuid)) { cmd.msgtype = GUEST_DEL_VNIC; cmd.del_vnic.chanptr = dev->chanptr; } else { @@ -960,7 +960,7 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, return 0; } msg.cmd.createDevice.channelBytes = chan_bytes; - msg.cmd.createDevice.dataTypeGuid = UltraVhbaChannelProtocolGuid; + msg.cmd.createDevice.dataTypeGuid = spar_vhba_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA create_device failed.\n"); POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1019,7 +1019,7 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, return 0; } msg.cmd.createDevice.channelBytes = chan_bytes; - msg.cmd.createDevice.dataTypeGuid = UltraVnicChannelProtocolGuid; + msg.cmd.createDevice.dataTypeGuid = spar_vnic_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC create_device failed.\n"); POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1109,7 +1109,7 @@ uislib_client_add_vnic(u32 busNo) memset(&msg.cmd.createDevice.intr, 0, sizeof(struct irq_info)); msg.cmd.createDevice.channelAddr = PhysicalDataChan; msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; - msg.cmd.createDevice.dataTypeGuid = UltraVnicChannelProtocolGuid; + msg.cmd.createDevice.dataTypeGuid = spar_vnic_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("client create_device failed"); goto AwayCleanup; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index ee03c59dc889..cfacf17ad26a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -80,7 +80,7 @@ static CONTROLVM_MESSAGE_HEADER g_DiagMsgHdr; static CONTROLVM_MESSAGE_HEADER g_ChipSetMsgHdr; static CONTROLVM_MESSAGE_HEADER g_DelDumpMsgHdr; static const uuid_le UltraDiagPoolChannelProtocolGuid = - ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID; + SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; /* 0xffffff is an invalid Bus/Device number */ static ulong g_diagpoolBusNo = 0xffffff; static ulong g_diagpoolDevNo = 0xffffff; @@ -90,8 +90,10 @@ static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket; * "visorhackbus") */ #define FOR_VISORHACKBUS(channel_type_guid) \ - (((uuid_le_cmp(channel_type_guid, UltraVnicChannelProtocolGuid) == 0)\ - || (uuid_le_cmp(channel_type_guid, UltraVhbaChannelProtocolGuid) == 0))) + (((uuid_le_cmp(channel_type_guid,\ + spar_vnic_channel_protocol_uuid) == 0)\ + || (uuid_le_cmp(channel_type_guid,\ + spar_vhba_channel_protocol_uuid) == 0))) #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid))) #define is_diagpool_channel(channel_type_guid) \ -- cgit v1.2.3-59-g8ed1b From 4d08ae26accfa5189a9a22c65b593be92f67db8d Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:48 -0400 Subject: staging: unisys: clean up stray blank lines in channel_guid.h Just remove extra blank lines in channel_guid.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel_guid.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h index 16df33a751a6..706363fc3e9a 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h @@ -43,7 +43,6 @@ static const uuid_le spar_vnic_channel_protocol_uuid = 0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00) static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID; - /* Used in visornoop/visornoop_main.c * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f} */ @@ -60,5 +59,3 @@ static const uuid_le spar_controldirector_channel_protocol_uuid = #define SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID \ UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \ 0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c) - - -- cgit v1.2.3-59-g8ed1b From e2706697fd6a08fa7457d30bb4f7d8bc4d7c36b9 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:49 -0400 Subject: staging: unisys: remove channel mismatch macros Simplify the code in channel.h by removing CHANNEL_GUID_MISMATCH, CHANNEL_u64_MISMATCH, and CHANNEL_U32_MISMATCH, and printing the messages directly instead. The CamelCase names in the functions that used to use these macros will be fixed in a later patch. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 90 ++++++++-------------- 1 file changed, 30 insertions(+), 60 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index c25dfbf7f6bc..27de674b6432 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -50,33 +50,6 @@ #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L') -#define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \ - lin, logCtx) \ - do { \ - pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d\n", \ - chName, &chType, field, \ - &expected, &actual, \ - fil, lin); \ - } while (0) -#define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \ - lin, logCtx) \ - do { \ - pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \ - chName, &chType, field, \ - (unsigned long)expected, (unsigned long)actual, \ - fil, lin); \ - } while (0) - -#define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \ - lin, logCtx) \ - do { \ - pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \ - chName, &chType, field, \ - (unsigned long long)expected, \ - (unsigned long long)actual, \ - fil, lin); \ - } while (0) - #define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \ LineNumber, Str, args...) \ pr_info(Str, ## args) @@ -355,48 +328,45 @@ ULTRA_check_channel_client(void __iomem *pChannel, sizeof(guid)); /* caller wants us to verify type GUID */ if (uuid_le_cmp(guid, expectedTypeGuid) != 0) { - CHANNEL_GUID_MISMATCH(expectedTypeGuid, channelName, - "type", expectedTypeGuid, - guid, fileName, - lineNumber, logCtx); + pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n", + channelName, &expectedTypeGuid, + &expectedTypeGuid, &guid); return 0; } } - if (expectedMinBytes > 0) /* caller wants us to verify + if (expectedMinBytes > 0) { /* caller wants us to verify * channel size */ - if (readq(&((CHANNEL_HEADER __iomem *) - (pChannel))->Size) < expectedMinBytes) { - CHANNEL_U64_MISMATCH(expectedTypeGuid, channelName, - "size", expectedMinBytes, - readq(&((CHANNEL_HEADER __iomem *) - (pChannel))->Size), - fileName, - lineNumber, logCtx); + unsigned long long bytes = readq(&((CHANNEL_HEADER __iomem *) + (pChannel))->Size); + if (bytes < expectedMinBytes) { + pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n", + channelName, &expectedTypeGuid, + (unsigned long long)expectedMinBytes, bytes); return 0; } - if (expectedVersionId > 0) /* caller wants us to verify + } + if (expectedVersionId > 0) { /* caller wants us to verify * channel version */ - if (readl(&((CHANNEL_HEADER __iomem *) (pChannel))->VersionId) - != expectedVersionId) { - CHANNEL_U32_MISMATCH(expectedTypeGuid, channelName, - "version", expectedVersionId, - readl(&((CHANNEL_HEADER __iomem *) - (pChannel))->VersionId), - fileName, lineNumber, logCtx); + unsigned long ver = readl(&((CHANNEL_HEADER __iomem *) + (pChannel))->VersionId); + if (ver != expectedVersionId) { + pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n", + channelName, &expectedTypeGuid, + (unsigned long)expectedVersionId, ver); return 0; } - if (expectedSignature > 0) /* caller wants us to verify + } + if (expectedSignature > 0) { /* caller wants us to verify * channel signature */ - if (readq(&((CHANNEL_HEADER __iomem *) (pChannel))->Signature) - != expectedSignature) { - CHANNEL_U64_MISMATCH(expectedTypeGuid, channelName, - "signature", expectedSignature, - readq(&((CHANNEL_HEADER __iomem *) - (pChannel))->Signature), - fileName, - lineNumber, logCtx); + unsigned long long sig = readq(&((CHANNEL_HEADER __iomem *) + (pChannel))->Signature); + if (sig != expectedSignature) { + pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n", + channelName, &expectedTypeGuid, + expectedSignature, sig); return 0; } + } return 1; } @@ -415,9 +385,9 @@ ULTRA_check_channel_server(uuid_le typeGuid, if (expectedMinBytes > 0) /* caller wants us to verify * channel size */ if (actualBytes < expectedMinBytes) { - CHANNEL_U64_MISMATCH(typeGuid, channelName, "size", - expectedMinBytes, actualBytes, - fileName, lineNumber, logCtx); + pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n", + channelName, &typeGuid, expectedMinBytes, + actualBytes); return 0; } return 1; -- cgit v1.2.3-59-g8ed1b From ddb38ae6441be221f42bf30cbd8f3fce68cc204f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:50 -0400 Subject: staging: unisys: get rid of UltraLogEvent macro Remove the UltraLogEvent macro from channel.h, and fix all references so they call pr_info directly. CamelCase names used by functions that called UltraLogEvent will be fixed in later patches. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 140 +++++++-------------- 1 file changed, 48 insertions(+), 92 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 27de674b6432..d5102785c77b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -50,10 +50,6 @@ #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L') -#define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \ - LineNumber, Str, args...) \ - pr_info(Str, ## args) - typedef enum { CHANNELSRV_UNINITIALIZED = 0, /* channel is in an undefined state */ CHANNELSRV_READY = 1 /* channel has been initialized by server */ @@ -122,19 +118,14 @@ ULTRA_CHANNELCLI_STRING(u32 v) file, line) \ do { \ if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new)) \ - UltraLogEvent(logCtx, \ - CHANNELSTATE_DIAG_EVENTID_TRANSITERR, \ - CHANNELSTATE_DIAG_SEVERITY, \ - CHANNELSTATE_DIAG_SUBSYS, \ - __func__, __LINE__, \ - "%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \ - chanId, "CliState", \ - ULTRA_CHANNELCLI_STRING(old), \ - old, \ - ULTRA_CHANNELCLI_STRING(new), \ - new, \ - PathName_Last_N_Nodes((u8 *)file, 4), \ - line); \ + pr_info("%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \ + chanId, "CliState", \ + ULTRA_CHANNELCLI_STRING(old), \ + old, \ + ULTRA_CHANNELCLI_STRING(new), \ + new, \ + PathName_Last_N_Nodes((u8 *)file, 4), \ + line); \ } while (0) #define ULTRA_CHANNEL_CLIENT_TRANSITION(pChan, chanId, \ @@ -145,20 +136,16 @@ ULTRA_CHANNELCLI_STRING(u32 v) (pChan))->CliStateOS)), \ newstate, \ chanId, logCtx, __FILE__, __LINE__); \ - UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, \ - CHANNELSTATE_DIAG_SEVERITY, \ - CHANNELSTATE_DIAG_SUBSYS, \ - __func__, __LINE__, \ - "%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \ - chanId, "CliStateOS", \ - ULTRA_CHANNELCLI_STRING( \ + pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \ + chanId, "CliStateOS", \ + ULTRA_CHANNELCLI_STRING( \ readl(&((CHANNEL_HEADER __iomem *) \ (pChan))->CliStateOS)), \ - readl(&((CHANNEL_HEADER __iomem *) \ + readl(&((CHANNEL_HEADER __iomem *) \ (pChan))->CliStateOS), \ - ULTRA_CHANNELCLI_STRING(newstate), \ - newstate, \ - PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \ + ULTRA_CHANNELCLI_STRING(newstate), \ + newstate, \ + PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \ writel(newstate, &((CHANNEL_HEADER __iomem *) \ (pChan))->CliStateOS); \ mb(); /* required for channel synch */ \ @@ -439,30 +426,22 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, &pChan->CliErrorOS); /* throttle until acquire successful */ - UltraLogEvent(logCtx, - CHANNELSTATE_DIAG_EVENTID_TRANSITERR, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n", - chanId, PathName_Last_N_Nodes( - (u8 *) file, 4), line); + pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n", + chanId, PathName_Last_N_Nodes((u8 *) file, 4), + line); } return 0; } if ((readl(&pChan->CliStateOS) != CHANNELCLI_OWNED) && (readl(&pChan->CliStateBoot) == CHANNELCLI_DISABLED)) { /* Our competitor is DISABLED, so we can transition to OWNED */ - UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", - chanId, "CliStateOS", - ULTRA_CHANNELCLI_STRING( - readl(&pChan->CliStateOS)), - readl(&pChan->CliStateOS), - ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED), - CHANNELCLI_OWNED, - PathName_Last_N_Nodes((u8 *) file, 4), line); + pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", + chanId, "CliStateOS", + ULTRA_CHANNELCLI_STRING(readl(&pChan->CliStateOS)), + readl(&pChan->CliStateOS), + ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED), + CHANNELCLI_OWNED, + PathName_Last_N_Nodes((u8 *) file, 4), line); writel(CHANNELCLI_OWNED, &pChan->CliStateOS); mb(); /* required for channel synch */ } @@ -470,13 +449,9 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, if (readb(&pChan->CliErrorOS) != 0) { /* we are in an error msg throttling state; * come out of it */ - UltraLogEvent(logCtx, - CHANNELSTATE_DIAG_EVENTID_TRANSITOK, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel OS client acquire now successful @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, - 4), line); + pr_info("%s Channel OS client acquire now successful @%s:%d\n", + chanId, PathName_Last_N_Nodes((u8 *) file, 4), + line); writeb(0, &pChan->CliErrorOS); } return 1; @@ -493,17 +468,12 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED, &pChan->CliErrorOS); /* throttle until acquire successful */ - UltraLogEvent(logCtx, - CHANNELSTATE_DIAG_EVENTID_TRANSITERR, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d)) @%s:%d\n", - chanId, - ULTRA_CHANNELCLI_STRING( - readl(&pChan->CliStateOS)), - readl(&pChan->CliStateOS), - PathName_Last_N_Nodes((u8 *) file, 4), - line); + pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d)) @%s:%d\n", + chanId, ULTRA_CHANNELCLI_STRING( + readl(&pChan->CliStateOS)), + readl(&pChan->CliStateOS), + PathName_Last_N_Nodes((u8 *) file, 4), + line); } return 0; } @@ -517,13 +487,9 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, ULTRA_CLIERROROS_THROTTLEMSG_BUSY, &pChan->CliErrorOS); /* throttle until acquire successful */ - UltraLogEvent(logCtx, - CHANNELSTATE_DIAG_EVENTID_TRANSITBUSY, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, - 4), line); + pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n", + chanId, PathName_Last_N_Nodes((u8 *) file, 4), + line); } /* reset busy */ writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS); @@ -532,12 +498,9 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, } if (readb(&pChan->CliErrorOS) != 0) { /* we are in an error msg throttling state; come out of it */ - UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel OS client acquire now successful @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), - line); + pr_info("%s Channel OS client acquire now successful @%s:%d\n", + chanId, PathName_Last_N_Nodes((u8 *) file, 4), + line); writeb(0, &pChan->CliErrorOS); } return 1; @@ -551,26 +514,19 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, if (readb(&pChan->CliErrorOS) != 0) { /* we are in an error msg throttling state; come out of it */ - UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel OS client error state cleared @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), - line); + pr_info("%s Channel OS client error state cleared @%s:%d\n", + chanId, PathName_Last_N_Nodes((u8 *) file, 4), + line); writeb(0, &pChan->CliErrorOS); } if (readl(&pChan->CliStateOS) == CHANNELCLI_OWNED) return; if (readl(&pChan->CliStateOS) != CHANNELCLI_BUSY) { - UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITERR, - CHANNELSTATE_DIAG_SEVERITY, - CHANNELSTATE_DIAG_SUBSYS, func, line, - "%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d)) @%s:%d\n", - chanId, - ULTRA_CHANNELCLI_STRING( - readl(&pChan->CliStateOS)), - readl(&pChan->CliStateOS), - PathName_Last_N_Nodes((u8 *) file, 4), line); + pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d)) @%s:%d\n", + chanId, ULTRA_CHANNELCLI_STRING( + readl(&pChan->CliStateOS)), + readl(&pChan->CliStateOS), + PathName_Last_N_Nodes((u8 *) file, 4), line); /* return; */ } writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS); /* release busy */ -- cgit v1.2.3-59-g8ed1b From 1e73f4b53344b1c213e110383fb0f178e1ff4368 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:51 -0400 Subject: staging: unisys: remove typedef for CHANNEL_SERVERSTATE Remove the typedef for CHANNEL_SERVERSTATE and use enum channel_serverstate instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index d5102785c77b..8c54adf724ed 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -50,10 +50,10 @@ #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L') -typedef enum { +enum channel_serverstate { CHANNELSRV_UNINITIALIZED = 0, /* channel is in an undefined state */ CHANNELSRV_READY = 1 /* channel has been initialized by server */ -} CHANNEL_SERVERSTATE; +}; typedef enum { CHANNELCLI_DETACHED = 0, -- cgit v1.2.3-59-g8ed1b From 9831a29a384513c2c1a16c10f9ad619e112c10c0 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:52 -0400 Subject: staging: unisys: get rid of typedef for CHANNEL_CLIENTSTATE Remove the typedef for CHANNEL_CLIENTSTATE and just use enum channel_clientstate instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 8c54adf724ed..304f81b96d2a 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -55,7 +55,7 @@ enum channel_serverstate { CHANNELSRV_READY = 1 /* channel has been initialized by server */ }; -typedef enum { +enum channel_clientstate { CHANNELCLI_DETACHED = 0, CHANNELCLI_DISABLED = 1, /* client can see channel but is NOT * allowed to use it unless given TBD @@ -69,7 +69,7 @@ typedef enum { * using channel */ CHANNELCLI_OWNED = 5 /* "no worries" state - client can * access channel anytime */ -} CHANNEL_CLIENTSTATE; +}; static inline const u8 * ULTRA_CHANNELCLI_STRING(u32 v) { -- cgit v1.2.3-59-g8ed1b From 09a5073b822853b48f323dceb0fc999746407621 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:53 -0400 Subject: staging: unisys: fix missing blank line after enum channel_clientstate The enumeration needs to have a blank line after it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 304f81b96d2a..f32ec8496b22 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -70,6 +70,7 @@ enum channel_clientstate { CHANNELCLI_OWNED = 5 /* "no worries" state - client can * access channel anytime */ }; + static inline const u8 * ULTRA_CHANNELCLI_STRING(u32 v) { -- cgit v1.2.3-59-g8ed1b From 82d72bee4b5c7352be0a54747da6e206ea8893d5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:54 -0400 Subject: staging: unisys: fix spacing in ULTRA_CHANNELCLI_STRING Remove all the extraneous spaces in typecasts in ULTRA_CHANNELCLI_STRING(). Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/channel.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index f32ec8496b22..c77e9c7afcd9 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -76,21 +76,21 @@ ULTRA_CHANNELCLI_STRING(u32 v) { switch (v) { case CHANNELCLI_DETACHED: - return (const u8 *) ("DETACHED"); + return (const u8 *)("DETACHED"); case CHANNELCLI_DISABLED: - return (const u8 *) ("DISABLED"); + return (const u8 *)("DISABLED"); case CHANNELCLI_ATTACHING: - return (const u8 *) ("ATTACHING"); + return (const u8 *)("ATTACHING"); case CHANNELCLI_ATTACHED: - return (const u8 *) ("ATTACHED"); + return (const u8 *)("ATTACHED"); case CHANNELCLI_BUSY: - return (const u8 *) ("BUSY"); + return (const u8 *)("BUSY"); case CHANNELCLI_OWNED: - return (const u8 *) ("OWNED"); + return (const u8 *)("OWNED"); default: break; } - return (const u8 *) ("?"); + return (const u8 *)("?"); } #define ULTRA_CHANNELSRV_IS_READY(x) ((x) == CHANNELSRV_READY) -- cgit v1.2.3-59-g8ed1b From 9fd1b95aab5f4e72e8516e0a8b6dcb7dd6217d09 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:55 -0400 Subject: staging: unisys: remove typedef for CHANNEL_HEADER Switch everywhere that CHANNEL_HEADER, pCHANNEL_HEADER, or ULTRA_CHANNEL_PROTOCOL was used, to struct channel_header. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 10 +++-- drivers/staging/unisys/channels/chanstub.c | 4 +- drivers/staging/unisys/channels/chanstub.h | 8 ++-- .../unisys/common-spar/include/channels/channel.h | 47 ++++++++++++---------- .../include/channels/controlvmchannel.h | 2 +- .../common-spar/include/channels/diagchannel.h | 4 +- .../common-spar/include/channels/iochannel.h | 2 +- .../common-spar/include/channels/vbuschannel.h | 2 +- drivers/staging/unisys/include/uisqueue.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 12 +++--- drivers/staging/unisys/virthba/virthba.c | 4 +- drivers/staging/unisys/virtpci/virtpci.c | 6 +-- .../unisys/visorchannel/visorchannel_funcs.c | 30 ++++++++------ .../unisys/visorchipset/visorchipset_main.c | 2 +- 14 files changed, 73 insertions(+), 62 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index b4bdee4b575b..2033b3b8a11f 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -44,7 +44,8 @@ * 1 if the insertion succeeds, 0 if the queue was full. */ unsigned char -visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal) +visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, + void *pSignal) { void __iomem *psignal; unsigned int head, tail, nof; @@ -102,7 +103,8 @@ EXPORT_SYMBOL_GPL(visor_signal_insert); * 1 if the removal succeeds, 0 if the queue was empty. */ unsigned char -visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue, void *pSignal) +visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, + void *pSignal) { void __iomem *psource; unsigned int head, tail; @@ -157,7 +159,7 @@ EXPORT_SYMBOL_GPL(visor_signal_remove); * # of signals copied. */ unsigned int -SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, void *pSignal) +SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) { void *psource; unsigned int head, tail, signalCount = 0; @@ -208,7 +210,7 @@ SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, void *pSignal) * 1 if the signal queue is empty, 0 otherwise. */ unsigned char -visor_signalqueue_empty(CHANNEL_HEADER __iomem *pChannel, u32 Queue) +visor_signalqueue_empty(struct channel_header __iomem *pChannel, u32 Queue) { SIGNAL_QUEUE_HEADER __iomem *pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel + diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index d54c5d635a94..23d5aafef2cd 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -42,7 +42,7 @@ channel_mod_exit(void) } unsigned char -SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, +SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue, void *pSignal, spinlock_t *lock) { unsigned char result; @@ -55,7 +55,7 @@ SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, } unsigned char -SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, +SignalRemove_withLock(struct channel_header __iomem *pChannel, u32 Queue, void *pSignal, spinlock_t *lock) { unsigned char result; diff --git a/drivers/staging/unisys/channels/chanstub.h b/drivers/staging/unisys/channels/chanstub.h index d08e2c69d2ad..1531759a1b31 100644 --- a/drivers/staging/unisys/channels/chanstub.h +++ b/drivers/staging/unisys/channels/chanstub.h @@ -15,9 +15,9 @@ #ifndef __CHANSTUB_H__ #define __CHANSTUB_H__ -unsigned char SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, - void *pSignal, spinlock_t *lock); -unsigned char SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, u32 Queue, - void *pSignal, spinlock_t *lock); +unsigned char SignalInsert_withLock(struct channel_header __iomem *pChannel, + u32 Queue, void *pSignal, spinlock_t *lock); +unsigned char SignalRemove_withLock(struct channel_header __iomem *pChannel, + u32 Queue, void *pSignal, spinlock_t *lock); #endif diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index c77e9c7afcd9..a71bac0526b2 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -133,21 +133,21 @@ ULTRA_CHANNELCLI_STRING(u32 v) newstate, logCtx) \ do { \ ULTRA_CHANNEL_CLIENT_CHK_TRANSITION( \ - readl(&(((CHANNEL_HEADER __iomem *) \ + readl(&(((struct channel_header __iomem *) \ (pChan))->CliStateOS)), \ newstate, \ chanId, logCtx, __FILE__, __LINE__); \ pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \ chanId, "CliStateOS", \ ULTRA_CHANNELCLI_STRING( \ - readl(&((CHANNEL_HEADER __iomem *) \ + readl(&((struct channel_header __iomem *)\ (pChan))->CliStateOS)), \ - readl(&((CHANNEL_HEADER __iomem *) \ + readl(&((struct channel_header __iomem *) \ (pChan))->CliStateOS), \ ULTRA_CHANNELCLI_STRING(newstate), \ newstate, \ PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \ - writel(newstate, &((CHANNEL_HEADER __iomem *) \ + writel(newstate, &((struct channel_header __iomem *) \ (pChan))->CliStateOS); \ mb(); /* required for channel synch */ \ } while (0) @@ -200,18 +200,18 @@ ULTRA_CHANNELCLI_STRING(u32 v) #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ /* Common Channel Header */ -typedef struct _CHANNEL_HEADER { +struct channel_header { u64 Signature; /* Signature */ u32 LegacyState; /* DEPRECATED - being replaced by */ /* / SrvState, CliStateBoot, and CliStateOS below */ - u32 HeaderSize; /* sizeof(CHANNEL_HEADER) */ + u32 HeaderSize; /* sizeof(struct channel_header) */ u64 Size; /* Total size of this channel in bytes */ u64 Features; /* Flags to modify behavior */ uuid_le Type; /* Channel type: data, bus, control, etc. */ u64 PartitionHandle; /* ID of guest partition */ u64 Handle; /* Device number of this channel in client */ u64 oChannelSpace; /* Offset in bytes to channel specific area */ - u32 VersionId; /* CHANNEL_HEADER Version ID */ + u32 VersionId; /* struct channel_header Version ID */ u32 PartitionIndex; /* Index of guest partition */ uuid_le ZoneGuid; /* Guid of Channel's zone */ u32 oClientString; /* offset from channel header to @@ -238,7 +238,7 @@ typedef struct _CHANNEL_HEADER { u8 Filler[1]; /* Pad out to 128 byte cacheline */ /* Please add all new single-byte values below here */ u8 RecoverChannel; -} CHANNEL_HEADER, *pCHANNEL_HEADER, ULTRA_CHANNEL_PROTOCOL; +}; #define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0) @@ -312,7 +312,8 @@ ULTRA_check_channel_client(void __iomem *pChannel, uuid_le guid; memcpy_fromio(&guid, - &((CHANNEL_HEADER __iomem *)(pChannel))->Type, + &((struct channel_header __iomem *) + (pChannel))->Type, sizeof(guid)); /* caller wants us to verify type GUID */ if (uuid_le_cmp(guid, expectedTypeGuid) != 0) { @@ -324,8 +325,9 @@ ULTRA_check_channel_client(void __iomem *pChannel, } if (expectedMinBytes > 0) { /* caller wants us to verify * channel size */ - unsigned long long bytes = readq(&((CHANNEL_HEADER __iomem *) - (pChannel))->Size); + unsigned long long bytes = + readq(&((struct channel_header __iomem *) + (pChannel))->Size); if (bytes < expectedMinBytes) { pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n", channelName, &expectedTypeGuid, @@ -335,7 +337,7 @@ ULTRA_check_channel_client(void __iomem *pChannel, } if (expectedVersionId > 0) { /* caller wants us to verify * channel version */ - unsigned long ver = readl(&((CHANNEL_HEADER __iomem *) + unsigned long ver = readl(&((struct channel_header __iomem *) (pChannel))->VersionId); if (ver != expectedVersionId) { pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n", @@ -346,8 +348,9 @@ ULTRA_check_channel_client(void __iomem *pChannel, } if (expectedSignature > 0) { /* caller wants us to verify * channel signature */ - unsigned long long sig = readq(&((CHANNEL_HEADER __iomem *) - (pChannel))->Signature); + unsigned long long sig = + readq(&((struct channel_header __iomem *) + (pChannel))->Signature); if (sig != expectedSignature) { pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n", channelName, &expectedTypeGuid, @@ -416,7 +419,7 @@ static inline int ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, void *logCtx, char *file, int line, char *func) { - CHANNEL_HEADER __iomem *pChan = pChannel; + struct channel_header __iomem *pChan = pChannel; if (readl(&pChan->CliStateOS) == CHANNELCLI_DISABLED) { if ((readb(&pChan->CliErrorOS) @@ -511,7 +514,7 @@ static inline void ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, void *logCtx, char *file, int line, char *func) { - CHANNEL_HEADER __iomem *pChan = pChannel; + struct channel_header __iomem *pChan = pChannel; if (readb(&pChan->CliErrorOS) != 0) { /* we are in an error msg throttling state; come out of it */ @@ -552,8 +555,8 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, * full. */ -unsigned char visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue, - void *pSignal); +unsigned char visor_signal_insert(struct channel_header __iomem *pChannel, + u32 Queue, void *pSignal); /* * Routine Description: @@ -574,8 +577,8 @@ unsigned char visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, u32 Queue, * empty. */ -unsigned char visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue, - void *pSignal); +unsigned char visor_signal_remove(struct channel_header __iomem *pChannel, + u32 Queue, void *pSignal); /* * Routine Description: @@ -596,7 +599,7 @@ unsigned char visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, u32 Queue, * Return value: * # of signals copied. */ -unsigned int SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, +unsigned int SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal); /* @@ -610,7 +613,7 @@ unsigned int SignalRemoveAll(pCHANNEL_HEADER pChannel, u32 Queue, * Return value: * 1 if the signal queue is empty, 0 otherwise. */ -unsigned char visor_signalqueue_empty(CHANNEL_HEADER __iomem *pChannel, +unsigned char visor_signalqueue_empty(struct channel_header __iomem *pChannel, u32 Queue); #endif diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index f7ca6d167d60..8e8a5a57bddb 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -470,7 +470,7 @@ typedef struct _GUEST_DEVICES { } GUEST_DEVICES; typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { - CHANNEL_HEADER Header; + struct channel_header Header; GUEST_PHYSICAL_ADDRESS gpControlVm; /* guest physical address of * this channel */ GUEST_PHYSICAL_ADDRESS gpPartitionTables; /* guest physical address of diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 9912e51b89b5..590022fd9fb6 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -383,7 +383,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { /* ----------------------- */ /* Offsets/sizes for diagnostic channel attributes... */ -#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(ULTRA_CHANNEL_PROTOCOL)) +#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header)) #define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(SIGNAL_QUEUE_HEADER)) #define DIAG_CH_PROTOCOL_HEADER_OFFSET \ (DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE) @@ -416,7 +416,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { *Reserved: Reserved area to allow for correct channel size padding. */ typedef struct _ULTRA_DIAG_CHANNEL_PROTOCOL { - ULTRA_CHANNEL_PROTOCOL CommonChannelHeader; + struct channel_header CommonChannelHeader; SIGNAL_QUEUE_HEADER QueueHeader; DIAG_CHANNEL_PROTOCOL_HEADER DiagChannelHeader; DIAG_CHANNEL_EVENT Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 7de87a481a8c..77335964e3fe 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -685,7 +685,7 @@ struct uiscmdrsp { * this header there is a large region of memory which contains the command and * response queues as specified in cmdQ and rspQ SIGNAL_QUEUE_HEADERS. */ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { - CHANNEL_HEADER ChannelHeader; + struct channel_header ChannelHeader; SIGNAL_QUEUE_HEADER cmdQ; SIGNAL_QUEUE_HEADER rspQ; union { diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 420b7d859522..76bc7140d5e7 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -76,7 +76,7 @@ typedef struct _ULTRA_VBUS_HEADERINFO { } ULTRA_VBUS_HEADERINFO; struct ultra_vbus_channel_protocol { - ULTRA_CHANNEL_PROTOCOL ChannelHeader; /* initialized by server */ + struct channel_header ChannelHeader; /* initialized by server */ ULTRA_VBUS_HEADERINFO HdrInfo; /* initialized by server */ /* the remainder of this channel is filled in by the client */ struct ultra_vbus_deviceinfo ChpInfo; diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index db9d2051ae2f..7d01c42abcb9 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -34,7 +34,7 @@ #include "controlvmcompletionstatus.h" struct uisqueue_info { - CHANNEL_HEADER __iomem *chan; + struct channel_header __iomem *chan; /* channel containing queues in which scsi commands & * responses are queued */ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 35e8a61c7202..0de0eee95b8f 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -444,8 +444,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) if (!uuid_le_cmp(dev->channel_uuid, spar_vhba_channel_protocol_uuid)) { - wait_for_valid_guid(&((CHANNEL_HEADER - __iomem *) (dev-> + wait_for_valid_guid(&(( + struct channel_header + __iomem *) (dev-> chanptr))-> Type); if (!ULTRA_VHBA_CHANNEL_OK_CLIENT @@ -469,8 +470,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) } else if (!uuid_le_cmp(dev->channel_uuid, spar_vnic_channel_protocol_uuid)) { - wait_for_valid_guid(&((CHANNEL_HEADER - __iomem *) (dev-> + wait_for_valid_guid(&(( + struct channel_header + __iomem *) (dev-> chanptr))-> Type); if (!ULTRA_VNIC_CHANNEL_OK_CLIENT @@ -1565,7 +1567,7 @@ uislib_mod_init(void) LOGINF("sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL):%lu bytes\n", (ulong) sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL)); LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n", - (ulong) sizeof(CHANNEL_HEADER)); + (ulong) sizeof(struct channel_header)); LOGINF("sizeof(ULTRA_IO_CHANNEL_PROTOCOL):%lu bytes\n", (ulong) sizeof(ULTRA_IO_CHANNEL_PROTOCOL)); LOGINF("SIZEOF_CMDRSP:%lu bytes\n", SIZEOF_CMDRSP); diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index e4130c9714fc..c25c1d9f129c 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -420,7 +420,7 @@ static irqreturn_t virthba_ISR(int irq, void *dev_id) { struct virthba_info *virthbainfo = (struct virthba_info *) dev_id; - CHANNEL_HEADER __iomem *pChannelHeader; + struct channel_header __iomem *pChannelHeader; SIGNAL_QUEUE_HEADER __iomem *pqhdr; u64 mask; unsigned long long rc1; @@ -461,7 +461,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) int rsp; int i; irq_handler_t handler = virthba_ISR; - CHANNEL_HEADER __iomem *pChannelHeader; + struct channel_header __iomem *pChannelHeader; SIGNAL_QUEUE_HEADER __iomem *pqhdr; u64 mask; diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index f782916cbf2b..2be0447c612e 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -195,7 +195,7 @@ static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, LOGERR("vbus channel not present"); return -1; } - off = sizeof(ULTRA_CHANNEL_PROTOCOL) + chan->HdrInfo.chpInfoByteOffset; + off = sizeof(struct channel_header) + chan->HdrInfo.chpInfoByteOffset; if (chan->HdrInfo.chpInfoByteOffset == 0) { LOGERR("vbus channel not used, because chpInfoByteOffset == 0"); return -1; @@ -214,7 +214,7 @@ static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, LOGERR("vbus channel not present"); return -1; } - off = sizeof(ULTRA_CHANNEL_PROTOCOL) + chan->HdrInfo.busInfoByteOffset; + off = sizeof(struct channel_header) + chan->HdrInfo.busInfoByteOffset; if (chan->HdrInfo.busInfoByteOffset == 0) { LOGERR("vbus channel not used, because busInfoByteOffset == 0"); return -1; @@ -237,7 +237,7 @@ write_vbus_devInfo(struct ultra_vbus_channel_protocol *chan, return -1; } off = - (sizeof(ULTRA_CHANNEL_PROTOCOL) + + (sizeof(struct channel_header) + chan->HdrInfo.devInfoByteOffset) + (chan->HdrInfo.deviceInfoStructBytes * devix); if (chan->HdrInfo.devInfoByteOffset == 0) { diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 01a44c553500..d2fc89a0bbd2 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -30,7 +30,7 @@ struct VISORCHANNEL_Tag { MEMREGION *memregion; /* from visor_memregion_create() */ - CHANNEL_HEADER chan_hdr; + struct channel_header chan_hdr; uuid_le guid; ulong size; BOOL needs_lock; @@ -70,19 +70,19 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, /* prepare chan_hdr (abstraction to read/write channel memory) */ if (parent == NULL) p->memregion = - visor_memregion_create(physaddr, sizeof(CHANNEL_HEADER)); + visor_memregion_create(physaddr, + sizeof(struct channel_header)); else p->memregion = visor_memregion_create_overlapped(parent->memregion, - off, - sizeof(CHANNEL_HEADER)); + off, sizeof(struct channel_header)); if (p->memregion == NULL) { ERRDRV("visor_memregion_create failed failed: (status=0)\n"); rc = NULL; goto Away; } if (visor_memregion_read(p->memregion, 0, &p->chan_hdr, - sizeof(CHANNEL_HEADER)) < 0) { + sizeof(struct channel_header)) < 0) { ERRDRV("visor_memregion_read failed: (status=0)\n"); rc = NULL; goto Away; @@ -225,8 +225,11 @@ visorchannel_read(VISORCHANNEL *channel, ulong offset, { int rc = visor_memregion_read(channel->memregion, offset, local, nbytes); - if ((rc >= 0) && (offset == 0) && (nbytes >= sizeof(CHANNEL_HEADER))) - memcpy(&channel->chan_hdr, local, sizeof(CHANNEL_HEADER)); + if ((rc >= 0) && (offset == 0) && + (nbytes >= sizeof(struct channel_header))) { + memcpy(&channel->chan_hdr, local, + sizeof(struct channel_header)); + } return rc; } EXPORT_SYMBOL_GPL(visorchannel_read); @@ -235,8 +238,9 @@ int visorchannel_write(VISORCHANNEL *channel, ulong offset, void *local, ulong nbytes) { - if (offset == 0 && nbytes >= sizeof(CHANNEL_HEADER)) - memcpy(&channel->chan_hdr, local, sizeof(CHANNEL_HEADER)); + if (offset == 0 && nbytes >= sizeof(struct channel_header)) + memcpy(&channel->chan_hdr, local, + sizeof(struct channel_header)); return visor_memregion_write(channel->memregion, offset, local, nbytes); } EXPORT_SYMBOL_GPL(visorchannel_write); @@ -316,7 +320,7 @@ sig_read_header(VISORCHANNEL *channel, u32 queue, { BOOL rc = FALSE; - if (channel->chan_hdr.oChannelSpace < sizeof(CHANNEL_HEADER)) { + if (channel->chan_hdr.oChannelSpace < sizeof(struct channel_header)) { ERRDRV("oChannelSpace too small: (status=%d)\n", rc); goto Away; } @@ -559,8 +563,8 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, HOSTADDRESS addr = 0; ulong nbytes = 0, nbytes_region = 0; MEMREGION *memregion = NULL; - CHANNEL_HEADER hdr; - CHANNEL_HEADER *phdr = &hdr; + struct channel_header hdr; + struct channel_header *phdr = &hdr; int i = 0; int errcode = 0; @@ -576,7 +580,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, addr = visor_memregion_get_physaddr(memregion); nbytes_region = visor_memregion_get_nbytes(memregion); errcode = visorchannel_read(channel, off, - phdr, sizeof(CHANNEL_HEADER)); + phdr, sizeof(struct channel_header)); if (errcode < 0) { seq_printf(seq, "Read of channel header failed with errcode=%d)\n", diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index cfacf17ad26a..e26db99c4d58 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -114,7 +114,7 @@ typedef struct { /* Manages the request payload in the controlvm channel */ static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info; -static pCHANNEL_HEADER Test_Vnic_channel; +static struct channel_header *Test_Vnic_channel; typedef struct { CONTROLVM_MESSAGE_HEADER Dumpcapture_header; -- cgit v1.2.3-59-g8ed1b From a8a31f617721e092629f8ce27ce99376308372b1 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:56 -0400 Subject: staging: unisys: fix CamelCase names in struct channel_header Fix CamelCase names: Signature => signature LegacySignature => legacy_signature HeaderSize => header_size Size => size Features => features Type => chtype PartitionHandle => partition_handle Handle => handle oChannelSpace => ch_space_offset VersionId => version_id PartitionIndex => partition_index ZoneGuid => zone_uuid oClientString => cli_str_offset CliStateBoot => cli_state_boot CmdStateCli => cmd_state_cli CliStateOs => cli_state_os ChannelCharacteristics => ch_characteristic CmdStateSrv => cmd_state_srv srvState => srv_state CliErrorBoot => cli_error_boot CliErrorOs => cli_error_os Filler => filler RecoverChannel => recover_channel Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 8 +- .../unisys/common-spar/include/channels/channel.h | 135 ++++++++++----------- .../common-spar/include/channels/iochannel.h | 40 +++--- drivers/staging/unisys/uislib/uislib.c | 4 +- drivers/staging/unisys/virthba/virthba.c | 16 +-- .../unisys/visorchannel/visorchannel_funcs.c | 50 ++++---- 6 files changed, 126 insertions(+), 127 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index 2033b3b8a11f..c2f95f33b114 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -52,7 +52,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, SIGNAL_QUEUE_HEADER __iomem *pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) - ((char __iomem *) pChannel + readq(&pChannel->oChannelSpace)) + ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) + Queue; /* capture current head and tail */ @@ -110,7 +110,7 @@ visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, unsigned int head, tail; SIGNAL_QUEUE_HEADER __iomem *pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel + - readq(&pChannel->oChannelSpace)) + Queue; + readq(&pChannel->ch_space_offset)) + Queue; /* capture current head and tail */ head = readl(&pqhdr->Head); @@ -165,7 +165,7 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) unsigned int head, tail, signalCount = 0; pSIGNAL_QUEUE_HEADER pqhdr = (pSIGNAL_QUEUE_HEADER) ((char *) pChannel + - pChannel->oChannelSpace) + Queue; + pChannel->ch_space_offset) + Queue; /* capture current head and tail */ head = pqhdr->Head; @@ -214,7 +214,7 @@ visor_signalqueue_empty(struct channel_header __iomem *pChannel, u32 Queue) { SIGNAL_QUEUE_HEADER __iomem *pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel + - readq(&pChannel->oChannelSpace)) + Queue; + readq(&pChannel->ch_space_offset)) + Queue; return readl(&pqhdr->Head) == readl(&pqhdr->Tail); } EXPORT_SYMBOL_GPL(visor_signalqueue_empty); diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index a71bac0526b2..dafb14d50c9f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -95,7 +95,7 @@ ULTRA_CHANNELCLI_STRING(u32 v) #define ULTRA_CHANNELSRV_IS_READY(x) ((x) == CHANNELSRV_READY) #define ULTRA_CHANNEL_SERVER_READY(pChannel) \ - (ULTRA_CHANNELSRV_IS_READY(readl(&(pChannel)->SrvState))) + (ULTRA_CHANNELSRV_IS_READY(readl(&(pChannel)->srv_state))) #define ULTRA_VALID_CHANNELCLI_TRANSITION(o, n) \ (((((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_DISABLED)) || \ @@ -134,21 +134,21 @@ ULTRA_CHANNELCLI_STRING(u32 v) do { \ ULTRA_CHANNEL_CLIENT_CHK_TRANSITION( \ readl(&(((struct channel_header __iomem *) \ - (pChan))->CliStateOS)), \ + (pChan))->cli_state_os)), \ newstate, \ chanId, logCtx, __FILE__, __LINE__); \ pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \ chanId, "CliStateOS", \ ULTRA_CHANNELCLI_STRING( \ readl(&((struct channel_header __iomem *)\ - (pChan))->CliStateOS)), \ + (pChan))->cli_state_os)), \ readl(&((struct channel_header __iomem *) \ - (pChan))->CliStateOS), \ + (pChan))->cli_state_os), \ ULTRA_CHANNELCLI_STRING(newstate), \ newstate, \ PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \ writel(newstate, &((struct channel_header __iomem *) \ - (pChan))->CliStateOS); \ + (pChan))->cli_state_os); \ mb(); /* required for channel synch */ \ } while (0) @@ -201,43 +201,43 @@ ULTRA_CHANNELCLI_STRING(u32 v) #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ /* Common Channel Header */ struct channel_header { - u64 Signature; /* Signature */ - u32 LegacyState; /* DEPRECATED - being replaced by */ + u64 signature; /* Signature */ + u32 legacy_state; /* DEPRECATED - being replaced by */ /* / SrvState, CliStateBoot, and CliStateOS below */ - u32 HeaderSize; /* sizeof(struct channel_header) */ - u64 Size; /* Total size of this channel in bytes */ - u64 Features; /* Flags to modify behavior */ - uuid_le Type; /* Channel type: data, bus, control, etc. */ - u64 PartitionHandle; /* ID of guest partition */ - u64 Handle; /* Device number of this channel in client */ - u64 oChannelSpace; /* Offset in bytes to channel specific area */ - u32 VersionId; /* struct channel_header Version ID */ - u32 PartitionIndex; /* Index of guest partition */ - uuid_le ZoneGuid; /* Guid of Channel's zone */ - u32 oClientString; /* offset from channel header to + u32 header_size; /* sizeof(struct channel_header) */ + u64 size; /* Total size of this channel in bytes */ + u64 features; /* Flags to modify behavior */ + uuid_le chtype; /* Channel type: data, bus, control, etc. */ + u64 partition_handle; /* ID of guest partition */ + u64 handle; /* Device number of this channel in client */ + u64 ch_space_offset; /* Offset in bytes to channel specific area */ + u32 version_id; /* struct channel_header Version ID */ + u32 partition_index; /* Index of guest partition */ + uuid_le zone_uuid; /* Guid of Channel's zone */ + u32 cli_str_offset; /* offset from channel header to * nul-terminated ClientString (0 if * ClientString not present) */ - u32 CliStateBoot; /* CHANNEL_CLIENTSTATE of pre-boot + u32 cli_state_boot; /* CHANNEL_CLIENTSTATE of pre-boot * EFI client of this channel */ - u32 CmdStateCli; /* CHANNEL_COMMANDSTATE (overloaded in + u32 cmd_state_cli; /* CHANNEL_COMMANDSTATE (overloaded in * Windows drivers, see ServerStateUp, * ServerStateDown, etc) */ - u32 CliStateOS; /* CHANNEL_CLIENTSTATE of Guest OS + u32 cli_state_os; /* CHANNEL_CLIENTSTATE of Guest OS * client of this channel */ - u32 ChannelCharacteristics; /* CHANNEL_CHARACTERISTIC_ */ - u32 CmdStateSrv; /* CHANNEL_COMMANDSTATE (overloaded in + u32 ch_characteristic; /* CHANNEL_CHARACTERISTIC_ */ + u32 cmd_state_srv; /* CHANNEL_COMMANDSTATE (overloaded in * Windows drivers, see ServerStateUp, * ServerStateDown, etc) */ - u32 SrvState; /* CHANNEL_SERVERSTATE */ - u8 CliErrorBoot; /* bits to indicate err states for + u32 srv_state; /* CHANNEL_SERVERSTATE */ + u8 cli_error_boot; /* bits to indicate err states for * boot clients, so err messages can * be throttled */ - u8 CliErrorOS; /* bits to indicate err states for OS + u8 cli_error_os; /* bits to indicate err states for OS * clients, so err messages can be * throttled */ - u8 Filler[1]; /* Pad out to 128 byte cacheline */ + u8 filler[1]; /* Pad out to 128 byte cacheline */ /* Please add all new single-byte values below here */ - u8 RecoverChannel; + u8 recover_channel; }; #define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0) @@ -312,9 +312,8 @@ ULTRA_check_channel_client(void __iomem *pChannel, uuid_le guid; memcpy_fromio(&guid, - &((struct channel_header __iomem *) - (pChannel))->Type, - sizeof(guid)); + &((struct channel_header __iomem *)(pChannel))->chtype, + sizeof(guid)); /* caller wants us to verify type GUID */ if (uuid_le_cmp(guid, expectedTypeGuid) != 0) { pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n", @@ -327,7 +326,7 @@ ULTRA_check_channel_client(void __iomem *pChannel, * channel size */ unsigned long long bytes = readq(&((struct channel_header __iomem *) - (pChannel))->Size); + (pChannel))->size); if (bytes < expectedMinBytes) { pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n", channelName, &expectedTypeGuid, @@ -338,7 +337,7 @@ ULTRA_check_channel_client(void __iomem *pChannel, if (expectedVersionId > 0) { /* caller wants us to verify * channel version */ unsigned long ver = readl(&((struct channel_header __iomem *) - (pChannel))->VersionId); + (pChannel))->version_id); if (ver != expectedVersionId) { pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n", channelName, &expectedTypeGuid, @@ -350,7 +349,7 @@ ULTRA_check_channel_client(void __iomem *pChannel, * channel signature */ unsigned long long sig = readq(&((struct channel_header __iomem *) - (pChannel))->Signature); + (pChannel))->signature); if (sig != expectedSignature) { pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n", channelName, &expectedTypeGuid, @@ -421,13 +420,13 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, { struct channel_header __iomem *pChan = pChannel; - if (readl(&pChan->CliStateOS) == CHANNELCLI_DISABLED) { - if ((readb(&pChan->CliErrorOS) + if (readl(&pChan->cli_state_os) == CHANNELCLI_DISABLED) { + if ((readb(&pChan->cli_error_os) & ULTRA_CLIERROROS_THROTTLEMSG_DISABLED) == 0) { /* we are NOT throttling this message */ - writeb(readb(&pChan->CliErrorOS) | + writeb(readb(&pChan->cli_error_os) | ULTRA_CLIERROROS_THROTTLEMSG_DISABLED, - &pChan->CliErrorOS); + &pChan->cli_error_os); /* throttle until acquire successful */ pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n", @@ -436,27 +435,27 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, } return 0; } - if ((readl(&pChan->CliStateOS) != CHANNELCLI_OWNED) - && (readl(&pChan->CliStateBoot) == CHANNELCLI_DISABLED)) { + if ((readl(&pChan->cli_state_os) != CHANNELCLI_OWNED) + && (readl(&pChan->cli_state_boot) == CHANNELCLI_DISABLED)) { /* Our competitor is DISABLED, so we can transition to OWNED */ pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", - chanId, "CliStateOS", - ULTRA_CHANNELCLI_STRING(readl(&pChan->CliStateOS)), - readl(&pChan->CliStateOS), + chanId, "cli_state_os", + ULTRA_CHANNELCLI_STRING(readl(&pChan->cli_state_os)), + readl(&pChan->cli_state_os), ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED), CHANNELCLI_OWNED, PathName_Last_N_Nodes((u8 *) file, 4), line); - writel(CHANNELCLI_OWNED, &pChan->CliStateOS); + writel(CHANNELCLI_OWNED, &pChan->cli_state_os); mb(); /* required for channel synch */ } - if (readl(&pChan->CliStateOS) == CHANNELCLI_OWNED) { - if (readb(&pChan->CliErrorOS) != 0) { + if (readl(&pChan->cli_state_os) == CHANNELCLI_OWNED) { + if (readb(&pChan->cli_error_os) != 0) { /* we are in an error msg throttling state; * come out of it */ pr_info("%s Channel OS client acquire now successful @%s:%d\n", chanId, PathName_Last_N_Nodes((u8 *) file, 4), line); - writeb(0, &pChan->CliErrorOS); + writeb(0, &pChan->cli_error_os); } return 1; } @@ -464,48 +463,48 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, /* We have to do it the "hard way". We transition to BUSY, * and can use the channel iff our competitor has not also * transitioned to BUSY. */ - if (readl(&pChan->CliStateOS) != CHANNELCLI_ATTACHED) { - if ((readb(&pChan->CliErrorOS) + if (readl(&pChan->cli_state_os) != CHANNELCLI_ATTACHED) { + if ((readb(&pChan->cli_error_os) & ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED) == 0) { /* we are NOT throttling this message */ - writeb(readb(&pChan->CliErrorOS) | + writeb(readb(&pChan->cli_error_os) | ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED, - &pChan->CliErrorOS); + &pChan->cli_error_os); /* throttle until acquire successful */ pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d)) @%s:%d\n", chanId, ULTRA_CHANNELCLI_STRING( - readl(&pChan->CliStateOS)), - readl(&pChan->CliStateOS), + readl(&pChan->cli_state_os)), + readl(&pChan->cli_state_os), PathName_Last_N_Nodes((u8 *) file, 4), line); } return 0; } - writel(CHANNELCLI_BUSY, &pChan->CliStateOS); + writel(CHANNELCLI_BUSY, &pChan->cli_state_os); mb(); /* required for channel synch */ - if (readl(&pChan->CliStateBoot) == CHANNELCLI_BUSY) { - if ((readb(&pChan->CliErrorOS) + if (readl(&pChan->cli_state_boot) == CHANNELCLI_BUSY) { + if ((readb(&pChan->cli_error_os) & ULTRA_CLIERROROS_THROTTLEMSG_BUSY) == 0) { /* we are NOT throttling this message */ - writeb(readb(&pChan->CliErrorOS) | + writeb(readb(&pChan->cli_error_os) | ULTRA_CLIERROROS_THROTTLEMSG_BUSY, - &pChan->CliErrorOS); + &pChan->cli_error_os); /* throttle until acquire successful */ pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n", chanId, PathName_Last_N_Nodes((u8 *) file, 4), line); } /* reset busy */ - writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS); + writel(CHANNELCLI_ATTACHED, &pChan->cli_state_os); mb(); /* required for channel synch */ return 0; } - if (readb(&pChan->CliErrorOS) != 0) { + if (readb(&pChan->cli_error_os) != 0) { /* we are in an error msg throttling state; come out of it */ pr_info("%s Channel OS client acquire now successful @%s:%d\n", chanId, PathName_Last_N_Nodes((u8 *) file, 4), line); - writeb(0, &pChan->CliErrorOS); + writeb(0, &pChan->cli_error_os); } return 1; } @@ -516,24 +515,24 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, { struct channel_header __iomem *pChan = pChannel; - if (readb(&pChan->CliErrorOS) != 0) { + if (readb(&pChan->cli_error_os) != 0) { /* we are in an error msg throttling state; come out of it */ pr_info("%s Channel OS client error state cleared @%s:%d\n", chanId, PathName_Last_N_Nodes((u8 *) file, 4), line); - writeb(0, &pChan->CliErrorOS); + writeb(0, &pChan->cli_error_os); } - if (readl(&pChan->CliStateOS) == CHANNELCLI_OWNED) + if (readl(&pChan->cli_state_os) == CHANNELCLI_OWNED) return; - if (readl(&pChan->CliStateOS) != CHANNELCLI_BUSY) { + if (readl(&pChan->cli_state_os) != CHANNELCLI_BUSY) { pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d)) @%s:%d\n", chanId, ULTRA_CHANNELCLI_STRING( - readl(&pChan->CliStateOS)), - readl(&pChan->CliStateOS), + readl(&pChan->cli_state_os)), + readl(&pChan->cli_state_os), PathName_Last_N_Nodes((u8 *) file, 4), line); /* return; */ } - writel(CHANNELCLI_ATTACHED, &pChan->CliStateOS); /* release busy */ + writel(CHANNELCLI_ATTACHED, &pChan->cli_state_os); /* release busy */ } /* diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 77335964e3fe..c26363de86dd 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -750,29 +750,29 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { #define QSIZEFROMBYTES(bytes) (QSLOTSFROMBYTES(bytes)*SIZEOF_CMDRSP) #define SignalQInit(x) \ do { \ - x->cmdQ.Size = QSIZEFROMBYTES(x->ChannelHeader.Size); \ + x->cmdQ.Size = QSIZEFROMBYTES(x->ChannelHeader.size); \ x->cmdQ.oSignalBase = SIZEOF_PROTOCOL - \ offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ x->cmdQ.SignalSize = SIZEOF_CMDRSP; \ x->cmdQ.MaxSignalSlots = \ - QSLOTSFROMBYTES(x->ChannelHeader.Size); \ + QSLOTSFROMBYTES(x->ChannelHeader.size); \ x->cmdQ.MaxSignals = x->cmdQ.MaxSignalSlots - 1; \ - x->rspQ.Size = QSIZEFROMBYTES(x->ChannelHeader.Size); \ + x->rspQ.Size = QSIZEFROMBYTES(x->ChannelHeader.size); \ x->rspQ.oSignalBase = \ (SIZEOF_PROTOCOL + x->cmdQ.Size) - \ offsetof(ULTRA_IO_CHANNEL_PROTOCOL, rspQ); \ x->rspQ.SignalSize = SIZEOF_CMDRSP; \ x->rspQ.MaxSignalSlots = \ - QSLOTSFROMBYTES(x->ChannelHeader.Size); \ + QSLOTSFROMBYTES(x->ChannelHeader.size); \ x->rspQ.MaxSignals = x->rspQ.MaxSignalSlots - 1; \ - x->ChannelHeader.oChannelSpace = \ + x->ChannelHeader.ch_space_offset = \ offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ } while (0) #define INIT_CLIENTSTRING(chan, type, clientStr, clientStrLen) \ do { \ if (clientStr) { \ - chan->ChannelHeader.oClientString = \ + chan->ChannelHeader.cli_str_offset = \ offsetof(type, clientString); \ memcpy(chan->clientString, clientStr, \ MINNUM(clientStrLen, \ @@ -802,13 +802,13 @@ static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, unsigned char *clientStr, u32 clientStrLen, u64 bytes) { memset(x, 0, sizeof(ULTRA_IO_CHANNEL_PROTOCOL)); - x->ChannelHeader.VersionId = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID; - x->ChannelHeader.Signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE; - x->ChannelHeader.SrvState = CHANNELSRV_UNINITIALIZED; - x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader); - x->ChannelHeader.Size = COVER(bytes, 4096); - x->ChannelHeader.Type = spar_vhba_channel_protocol_uuid; - x->ChannelHeader.ZoneGuid = NULL_UUID_LE; + x->ChannelHeader.version_id = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID; + x->ChannelHeader.signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE; + x->ChannelHeader.srv_state = CHANNELSRV_UNINITIALIZED; + x->ChannelHeader.header_size = sizeof(x->ChannelHeader); + x->ChannelHeader.size = COVER(bytes, 4096); + x->ChannelHeader.chtype = spar_vhba_channel_protocol_uuid; + x->ChannelHeader.zone_uuid = NULL_UUID_LE; x->vhba.wwnn = *wwnn; x->vhba.max = *max; INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr, @@ -838,13 +838,13 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, u32 clientStrLen, u64 bytes) { memset(x, 0, sizeof(ULTRA_IO_CHANNEL_PROTOCOL)); - x->ChannelHeader.VersionId = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID; - x->ChannelHeader.Signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE; - x->ChannelHeader.SrvState = CHANNELSRV_UNINITIALIZED; - x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader); - x->ChannelHeader.Size = COVER(bytes, 4096); - x->ChannelHeader.Type = spar_vnic_channel_protocol_uuid; - x->ChannelHeader.ZoneGuid = NULL_UUID_LE; + x->ChannelHeader.version_id = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID; + x->ChannelHeader.signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE; + x->ChannelHeader.srv_state = CHANNELSRV_UNINITIALIZED; + x->ChannelHeader.header_size = sizeof(x->ChannelHeader); + x->ChannelHeader.size = COVER(bytes, 4096); + x->ChannelHeader.chtype = spar_vnic_channel_protocol_uuid; + x->ChannelHeader.zone_uuid = NULL_UUID_LE; memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); x->vnic.num_rcv_bufs = num_rcv_bufs; x->vnic.mtu = mtu; diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 0de0eee95b8f..687b7db94fe5 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -448,7 +448,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) struct channel_header __iomem *) (dev-> chanptr))-> - Type); + chtype); if (!ULTRA_VHBA_CHANNEL_OK_CLIENT (dev->chanptr, NULL)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.", @@ -474,7 +474,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) struct channel_header __iomem *) (dev-> chanptr))-> - Type); + chtype); if (!ULTRA_VNIC_CHANNEL_OK_CLIENT (dev->chanptr, NULL)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.", diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index c25c1d9f129c..3e9a56d78815 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -429,9 +429,9 @@ virthba_ISR(int irq, void *dev_id) return IRQ_NONE; virthbainfo->interrupts_rcvd++; pChannelHeader = virthbainfo->chinfo.queueinfo->chan; - if (((readq(&pChannelHeader->Features) + if (((readq(&pChannelHeader->features) & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) - && ((readq(&pChannelHeader->Features) & + && ((readq(&pChannelHeader->features) & ULTRA_IO_DRIVER_DISABLES_INTS) != 0)) { virthbainfo->interrupts_disabled++; @@ -444,7 +444,7 @@ virthba_ISR(int irq, void *dev_id) } pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannelHeader + - readq(&pChannelHeader->oChannelSpace)) + IOCHAN_FROM_IOPART; + readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; writeq(readq(&pqhdr->NumInterruptsReceived) + 1, &pqhdr->NumInterruptsReceived); atomic_set(&virthbainfo->interrupt_rcvd, 1); @@ -578,9 +578,9 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) INIT_WORK(&virthbainfo->serverdown_completion, virthba_serverdown_complete); - writeq(readq(&virthbainfo->chinfo.queueinfo->chan->Features) | + writeq(readq(&virthbainfo->chinfo.queueinfo->chan->features) | ULTRA_IO_CHANNEL_IS_POLLING, - &virthbainfo->chinfo.queueinfo->chan->Features); + &virthbainfo->chinfo.queueinfo->chan->features); /* start thread that will receive scsicmnd responses */ DBGINF("starting rsp thread -- queueinfo: 0x%p, threadinfo: 0x%p.\n", virthbainfo->chinfo.queueinfo, &virthbainfo->chinfo.threadinfo); @@ -588,7 +588,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) pChannelHeader = virthbainfo->chinfo.queueinfo->chan; pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *)pChannelHeader + - readq(&pChannelHeader->oChannelSpace)) + IOCHAN_FROM_IOPART; + readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; virthbainfo->flags_addr = &pqhdr->FeatureFlags; if (!uisthread_start(&virthbainfo->chinfo.threadinfo, @@ -622,7 +622,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR); } else { u64 __iomem *Features_addr = - &virthbainfo->chinfo.queueinfo->chan->Features; + &virthbainfo->chinfo.queueinfo->chan->features; LOGERR("request_irq(%d) uislib_virthba_ISR request succeeded\n", virthbainfo->interrupt_vector); mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | @@ -1453,7 +1453,7 @@ static ssize_t enable_ints_write(struct file *file, if (VirtHbasOpen[i].virthbainfo != NULL) { virthbainfo = VirtHbasOpen[i].virthbainfo; Features_addr = - &virthbainfo->chinfo.queueinfo->chan->Features; + &virthbainfo->chinfo.queueinfo->chan->features; if (new_value == 1) { mask = ~(ULTRA_IO_CHANNEL_IS_POLLING | ULTRA_IO_DRIVER_DISABLES_INTS); diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index d2fc89a0bbd2..19f5c775ca88 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -89,10 +89,10 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, } if (channelBytes == 0) /* we had better be a CLIENT of this channel */ - channelBytes = (ulong) p->chan_hdr.Size; + channelBytes = (ulong) p->chan_hdr.size; if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) /* we had better be a CLIENT of this channel */ - guid = p->chan_hdr.Type; + guid = p->chan_hdr.chtype; if (visor_memregion_resize(p->memregion, channelBytes) < 0) { ERRDRV("visor_memregion_resize failed: (status=0)\n"); rc = NULL; @@ -194,14 +194,14 @@ EXPORT_SYMBOL_GPL(visorchannel_id); char * visorchannel_zoneid(VISORCHANNEL *channel, char *s) { - return visorchannel_uuid_id(&channel->chan_hdr.ZoneGuid, s); + return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s); } EXPORT_SYMBOL_GPL(visorchannel_zoneid); HOSTADDRESS visorchannel_get_clientpartition(VISORCHANNEL *channel) { - return channel->chan_hdr.PartitionHandle; + return channel->chan_hdr.partition_handle; } EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition); @@ -295,7 +295,7 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); * channel header */ #define SIG_QUEUE_OFFSET(chan_hdr, q) \ - ((chan_hdr)->oChannelSpace + ((q) * sizeof(SIGNAL_QUEUE_HEADER))) + ((chan_hdr)->ch_space_offset + ((q) * sizeof(SIGNAL_QUEUE_HEADER))) /** Return offset of a specific queue entry (data) from the beginning of a * channel header @@ -320,7 +320,7 @@ sig_read_header(VISORCHANNEL *channel, u32 queue, { BOOL rc = FALSE; - if (channel->chan_hdr.oChannelSpace < sizeof(struct channel_header)) { + if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header)) { ERRDRV("oChannelSpace too small: (status=%d)\n", rc); goto Away; } @@ -591,38 +591,38 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, } else return; } - nbytes = (ulong) (phdr->Size); + nbytes = (ulong) (phdr->size); seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n", addr + off, nbytes, nbytes_region); - seq_printf(seq, "Type = %pUL\n", &phdr->Type); - seq_printf(seq, "ZoneGuid = %pUL\n", &phdr->ZoneGuid); + seq_printf(seq, "Type = %pUL\n", &phdr->chtype); + seq_printf(seq, "ZoneGuid = %pUL\n", &phdr->zone_uuid); seq_printf(seq, "Signature = 0x%-16.16Lx\n", - (long long) phdr->Signature); - seq_printf(seq, "LegacyState = %lu\n", (ulong) phdr->LegacyState); - seq_printf(seq, "SrvState = %lu\n", (ulong) phdr->SrvState); - seq_printf(seq, "CliStateBoot = %lu\n", (ulong) phdr->CliStateBoot); - seq_printf(seq, "CliStateOS = %lu\n", (ulong) phdr->CliStateOS); - seq_printf(seq, "HeaderSize = %lu\n", (ulong) phdr->HeaderSize); - seq_printf(seq, "Size = %llu\n", (long long) phdr->Size); + (long long) phdr->signature); + seq_printf(seq, "LegacyState = %lu\n", (ulong)phdr->legacy_state); + seq_printf(seq, "SrvState = %lu\n", (ulong)phdr->srv_state); + seq_printf(seq, "CliStateBoot = %lu\n", (ulong)phdr->cli_state_boot); + seq_printf(seq, "CliStateOS = %lu\n", (ulong)phdr->cli_state_os); + seq_printf(seq, "HeaderSize = %lu\n", (ulong)phdr->header_size); + seq_printf(seq, "Size = %llu\n", (long long)phdr->size); seq_printf(seq, "Features = 0x%-16.16llx\n", - (long long) phdr->Features); + (long long) phdr->features); seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n", - (long long) phdr->PartitionHandle); + (long long) phdr->partition_handle); seq_printf(seq, "Handle = 0x%-16.16llx\n", - (long long) phdr->Handle); - seq_printf(seq, "VersionId = %lu\n", (ulong) phdr->VersionId); + (long long) phdr->handle); + seq_printf(seq, "VersionId = %lu\n", (ulong) phdr->version_id); seq_printf(seq, "oChannelSpace = %llu\n", - (long long) phdr->oChannelSpace); - if ((phdr->oChannelSpace == 0) || (errcode < 0)) + (long long) phdr->ch_space_offset); + if ((phdr->ch_space_offset == 0) || (errcode < 0)) ; else for (i = 0; i < nQueues; i++) { SIGNAL_QUEUE_HEADER q; errcode = visorchannel_read(channel, - off + phdr->oChannelSpace + - (i * sizeof(q)), - &q, sizeof(q)); + off + phdr->ch_space_offset + + (i * sizeof(q)), + &q, sizeof(q)); if (errcode < 0) { seq_printf(seq, "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n", -- cgit v1.2.3-59-g8ed1b From 10b133c7628a83b058458c667934d35a12b3dc4f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:57 -0400 Subject: staging: unisys: clean up ULTRA_CHANNEL_SERVER_READY macro Simplify this macro so it is only one macro, rename it to SPAR_CHANNEL_SERVER_READY, and get rid of the CamelCase parameter name. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 5 ++--- drivers/staging/unisys/virtpci/virtpci.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index dafb14d50c9f..c6d04af589a7 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -93,9 +93,8 @@ ULTRA_CHANNELCLI_STRING(u32 v) return (const u8 *)("?"); } -#define ULTRA_CHANNELSRV_IS_READY(x) ((x) == CHANNELSRV_READY) -#define ULTRA_CHANNEL_SERVER_READY(pChannel) \ - (ULTRA_CHANNELSRV_IS_READY(readl(&(pChannel)->srv_state))) +#define SPAR_CHANNEL_SERVER_READY(ch) \ + (readl(&(ch)->srv_state) == CHANNELSRV_READY) #define ULTRA_VALID_CHANNELCLI_TRANSITION(o, n) \ (((((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_DISABLED)) || \ diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 2be0447c612e..160ed8284e88 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -177,7 +177,7 @@ int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem *chanptr) while (count > 0) { - if (ULTRA_CHANNEL_SERVER_READY(&chanptr->ChannelHeader)) + if (SPAR_CHANNEL_SERVER_READY(&chanptr->ChannelHeader)) return 1; UIS_THREAD_WAIT_SEC(1); count--; -- cgit v1.2.3-59-g8ed1b From 13d58a982df0227c9b57638e2f0553cba34cf576 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:58 -0400 Subject: staging: unisys: fix ULTRA_SPAR_CHANNEL_CLIENT_CHK_TRANSITION macro Rename the macro to SPAR_CHANNEL_CLIENT_CHK_TRANSITION, and rename CamelCase parameters to: chanId => id logCtx => log Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index c6d04af589a7..2ce687e2cd31 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -114,12 +114,12 @@ ULTRA_CHANNELCLI_STRING(u32 v) (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \ ? (1) : (0)) -#define ULTRA_CHANNEL_CLIENT_CHK_TRANSITION(old, new, chanId, logCtx, \ +#define SPAR_CHANNEL_CLIENT_CHK_TRANSITION(old, new, id, log, \ file, line) \ do { \ if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new)) \ pr_info("%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \ - chanId, "CliState", \ + id, "CliState", \ ULTRA_CHANNELCLI_STRING(old), \ old, \ ULTRA_CHANNELCLI_STRING(new), \ @@ -131,7 +131,7 @@ ULTRA_CHANNELCLI_STRING(u32 v) #define ULTRA_CHANNEL_CLIENT_TRANSITION(pChan, chanId, \ newstate, logCtx) \ do { \ - ULTRA_CHANNEL_CLIENT_CHK_TRANSITION( \ + SPAR_CHANNEL_CLIENT_CHK_TRANSITION( \ readl(&(((struct channel_header __iomem *) \ (pChan))->cli_state_os)), \ newstate, \ -- cgit v1.2.3-59-g8ed1b From 8800bfbc068352104efa11efb73424217427f9da Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:29:59 -0400 Subject: staging: unisys: fix CamelCase in PathName_Last_N_Nodes() Fix CamelCase name: PathName_Last_N_Nodes => pathname_last_n_nodes Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 2ce687e2cd31..c68d36cf5d48 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -124,7 +124,7 @@ ULTRA_CHANNELCLI_STRING(u32 v) old, \ ULTRA_CHANNELCLI_STRING(new), \ new, \ - PathName_Last_N_Nodes((u8 *)file, 4), \ + pathname_last_n_nodes((u8 *)file, 4), \ line); \ } while (0) @@ -145,7 +145,7 @@ ULTRA_CHANNELCLI_STRING(u32 v) (pChan))->cli_state_os), \ ULTRA_CHANNELCLI_STRING(newstate), \ newstate, \ - PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \ + pathname_last_n_nodes(__FILE__, 4), __LINE__); \ writel(newstate, &((struct channel_header __iomem *) \ (pChan))->cli_state_os); \ mb(); /* required for channel synch */ \ @@ -389,7 +389,7 @@ ULTRA_check_channel_server(uuid_le typeGuid, * in it, the return pointer will be to the beginning of the string. */ static inline u8 * -PathName_Last_N_Nodes(u8 *s, unsigned int n) +pathname_last_n_nodes(u8 *s, unsigned int n) { u8 *p = s; unsigned int node_count = 0; @@ -429,7 +429,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, /* throttle until acquire successful */ pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), + chanId, pathname_last_n_nodes((u8 *) file, 4), line); } return 0; @@ -443,7 +443,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, readl(&pChan->cli_state_os), ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED), CHANNELCLI_OWNED, - PathName_Last_N_Nodes((u8 *) file, 4), line); + pathname_last_n_nodes((u8 *) file, 4), line); writel(CHANNELCLI_OWNED, &pChan->cli_state_os); mb(); /* required for channel synch */ } @@ -452,7 +452,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, /* we are in an error msg throttling state; * come out of it */ pr_info("%s Channel OS client acquire now successful @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), + chanId, pathname_last_n_nodes((u8 *) file, 4), line); writeb(0, &pChan->cli_error_os); } @@ -474,7 +474,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, chanId, ULTRA_CHANNELCLI_STRING( readl(&pChan->cli_state_os)), readl(&pChan->cli_state_os), - PathName_Last_N_Nodes((u8 *) file, 4), + pathname_last_n_nodes((u8 *) file, 4), line); } return 0; @@ -490,7 +490,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, &pChan->cli_error_os); /* throttle until acquire successful */ pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), + chanId, pathname_last_n_nodes((u8 *) file, 4), line); } /* reset busy */ @@ -501,7 +501,7 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, if (readb(&pChan->cli_error_os) != 0) { /* we are in an error msg throttling state; come out of it */ pr_info("%s Channel OS client acquire now successful @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), + chanId, pathname_last_n_nodes((u8 *) file, 4), line); writeb(0, &pChan->cli_error_os); } @@ -517,7 +517,7 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, if (readb(&pChan->cli_error_os) != 0) { /* we are in an error msg throttling state; come out of it */ pr_info("%s Channel OS client error state cleared @%s:%d\n", - chanId, PathName_Last_N_Nodes((u8 *) file, 4), + chanId, pathname_last_n_nodes((u8 *) file, 4), line); writeb(0, &pChan->cli_error_os); } @@ -528,7 +528,7 @@ ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, chanId, ULTRA_CHANNELCLI_STRING( readl(&pChan->cli_state_os)), readl(&pChan->cli_state_os), - PathName_Last_N_Nodes((u8 *) file, 4), line); + pathname_last_n_nodes((u8 *) file, 4), line); /* return; */ } writel(CHANNELCLI_ATTACHED, &pChan->cli_state_os); /* release busy */ -- cgit v1.2.3-59-g8ed1b From ff97a3fdf5c99adee957841aec4741cf36519870 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:00 -0400 Subject: staging: unisys: fix up ULTRA_CHANNEL_CLIENT_TRANSITION macro Rename the macro to SPAR_CHANNEL_CLIENT_TRANSITION, and fix CamelCase parameters: pChan => ch chanId => id logCtx => log Update all places the macro was used to call the new name. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 22 ++++++++++------------ drivers/staging/unisys/virthba/virthba.c | 6 +++--- drivers/staging/unisys/virtpci/virtpci.c | 12 ++++++------ 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index c68d36cf5d48..0f575e861d16 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -128,26 +128,24 @@ ULTRA_CHANNELCLI_STRING(u32 v) line); \ } while (0) -#define ULTRA_CHANNEL_CLIENT_TRANSITION(pChan, chanId, \ - newstate, logCtx) \ +#define SPAR_CHANNEL_CLIENT_TRANSITION(ch, id, newstate, log) \ do { \ SPAR_CHANNEL_CLIENT_CHK_TRANSITION( \ - readl(&(((struct channel_header __iomem *) \ - (pChan))->cli_state_os)), \ - newstate, \ - chanId, logCtx, __FILE__, __LINE__); \ + readl(&(((struct channel_header __iomem *)\ + (ch))->cli_state_os)), \ + newstate, id, log, __FILE__, __LINE__); \ pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \ - chanId, "CliStateOS", \ + id, "CliStateOS", \ ULTRA_CHANNELCLI_STRING( \ readl(&((struct channel_header __iomem *)\ - (pChan))->cli_state_os)), \ - readl(&((struct channel_header __iomem *) \ - (pChan))->cli_state_os), \ + (ch))->cli_state_os)), \ + readl(&((struct channel_header __iomem *)\ + (ch))->cli_state_os), \ ULTRA_CHANNELCLI_STRING(newstate), \ newstate, \ pathname_last_n_nodes(__FILE__, 4), __LINE__); \ - writel(newstate, &((struct channel_header __iomem *) \ - (pChan))->cli_state_os); \ + writel(newstate, &((struct channel_header __iomem *)\ + (ch))->cli_state_os); \ mb(); /* required for channel synch */ \ } while (0) diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 3e9a56d78815..9e98af8451b3 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1498,9 +1498,9 @@ virthba_serverup(struct virtpci_dev *virtpcidev) /* Must transition channel to ATTACHED state BEFORE we * can start using the device again */ - ULTRA_CHANNEL_CLIENT_TRANSITION(virthbainfo->chinfo.queueinfo->chan, - dev_name(&virtpcidev->generic_dev), - CHANNELCLI_ATTACHED, NULL); + SPAR_CHANNEL_CLIENT_TRANSITION(virthbainfo->chinfo.queueinfo->chan, + dev_name(&virtpcidev->generic_dev), + CHANNELCLI_ATTACHED, NULL); /* Start Processing the IOVM Response Queue Again */ if (!uisthread_start(&virthbainfo->chinfo.threadinfo, diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 160ed8284e88..eaae4e8b9b45 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -1009,9 +1009,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype, * queues can begin at any time after device_register(). */ pDev = &virtpcidev->generic_dev; - ULTRA_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, - BUS_ID(pDev), - CHANNELCLI_ATTACHED, NULL); + SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, + BUS_ID(pDev), + CHANNELCLI_ATTACHED, NULL); /* don't register until device has been added to * list. Otherwise, a device_unregister from this function can @@ -1032,9 +1032,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype, if (ret) { LOGERR("device_register returned %d\n", ret); pDev = &virtpcidev->generic_dev; - ULTRA_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, - BUS_ID(pDev), - CHANNELCLI_DETACHED, NULL); + SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, + BUS_ID(pDev), + CHANNELCLI_DETACHED, NULL); /* remove virtpcidev, the one we just added, from the list */ write_lock_irqsave(&VpcidevListLock, flags); for (tmpvpcidev = VpcidevListHead, prev = NULL; -- cgit v1.2.3-59-g8ed1b From 9f16930e557bf64811f1e972dbbd62e40940c9dc Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:01 -0400 Subject: staging: unisys: refactor ULTRA_channel_client_acquire_os() Remove the unnecessary macro ULTRA_CHANNEL_CLIENT_ACQUIRE_OS for calling the function, and rename the function to spar_channel_client_acquire_os(). Get rid of unneeded parameters logCtx, file, and line, and Fix CamelCase names: pChannel => ch chanId => id pChan => hdr Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 93 ++++++++++------------ drivers/staging/unisys/uislib/uisqueue.c | 2 +- drivers/staging/unisys/virthba/virthba.c | 4 +- 3 files changed, 43 insertions(+), 56 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 0f575e861d16..8c3fdf7e879f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -149,10 +149,6 @@ ULTRA_CHANNELCLI_STRING(u32 v) mb(); /* required for channel synch */ \ } while (0) -#define ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(pChan, chanId, logCtx) \ - ULTRA_channel_client_acquire_os(pChan, chanId, logCtx, \ - (char *)__FILE__, __LINE__, \ - (char *)__func__) #define ULTRA_CHANNEL_CLIENT_RELEASE_OS(pChan, chanId, logCtx) \ ULTRA_channel_client_release_os(pChan, chanId, logCtx, \ (char *)__FILE__, __LINE__, (char *)__func__) @@ -412,47 +408,43 @@ pathname_last_n_nodes(u8 *s, unsigned int n) } static inline int -ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, - void *logCtx, char *file, int line, char *func) +spar_channel_client_acquire_os(void __iomem *ch, u8 *id) { - struct channel_header __iomem *pChan = pChannel; + struct channel_header __iomem *hdr = ch; - if (readl(&pChan->cli_state_os) == CHANNELCLI_DISABLED) { - if ((readb(&pChan->cli_error_os) + if (readl(&hdr->cli_state_os) == CHANNELCLI_DISABLED) { + if ((readb(&hdr->cli_error_os) & ULTRA_CLIERROROS_THROTTLEMSG_DISABLED) == 0) { /* we are NOT throttling this message */ - writeb(readb(&pChan->cli_error_os) | + writeb(readb(&hdr->cli_error_os) | ULTRA_CLIERROROS_THROTTLEMSG_DISABLED, - &pChan->cli_error_os); + &hdr->cli_error_os); /* throttle until acquire successful */ - pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n", - chanId, pathname_last_n_nodes((u8 *) file, 4), - line); + pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED\n", + id); } return 0; } - if ((readl(&pChan->cli_state_os) != CHANNELCLI_OWNED) - && (readl(&pChan->cli_state_boot) == CHANNELCLI_DISABLED)) { + if ((readl(&hdr->cli_state_os) != CHANNELCLI_OWNED) + && (readl(&hdr->cli_state_boot) == CHANNELCLI_DISABLED)) { /* Our competitor is DISABLED, so we can transition to OWNED */ - pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", - chanId, "cli_state_os", - ULTRA_CHANNELCLI_STRING(readl(&pChan->cli_state_os)), - readl(&pChan->cli_state_os), + pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d)\n", + id, "cli_state_os", + ULTRA_CHANNELCLI_STRING(readl(&hdr->cli_state_os)), + readl(&hdr->cli_state_os), ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED), - CHANNELCLI_OWNED, - pathname_last_n_nodes((u8 *) file, 4), line); - writel(CHANNELCLI_OWNED, &pChan->cli_state_os); + CHANNELCLI_OWNED); + writel(CHANNELCLI_OWNED, &hdr->cli_state_os); mb(); /* required for channel synch */ } - if (readl(&pChan->cli_state_os) == CHANNELCLI_OWNED) { - if (readb(&pChan->cli_error_os) != 0) { + if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED) { + if (readb(&hdr->cli_error_os) != 0) { /* we are in an error msg throttling state; * come out of it */ - pr_info("%s Channel OS client acquire now successful @%s:%d\n", - chanId, pathname_last_n_nodes((u8 *) file, 4), - line); - writeb(0, &pChan->cli_error_os); + pr_info("%s Channel OS client acquire now successful\n", + id); + writeb(0, &hdr->cli_error_os); } return 1; } @@ -460,48 +452,43 @@ ULTRA_channel_client_acquire_os(void __iomem *pChannel, u8 *chanId, /* We have to do it the "hard way". We transition to BUSY, * and can use the channel iff our competitor has not also * transitioned to BUSY. */ - if (readl(&pChan->cli_state_os) != CHANNELCLI_ATTACHED) { - if ((readb(&pChan->cli_error_os) + if (readl(&hdr->cli_state_os) != CHANNELCLI_ATTACHED) { + if ((readb(&hdr->cli_error_os) & ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED) == 0) { /* we are NOT throttling this message */ - writeb(readb(&pChan->cli_error_os) | + writeb(readb(&hdr->cli_error_os) | ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED, - &pChan->cli_error_os); + &hdr->cli_error_os); /* throttle until acquire successful */ - pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d)) @%s:%d\n", - chanId, ULTRA_CHANNELCLI_STRING( - readl(&pChan->cli_state_os)), - readl(&pChan->cli_state_os), - pathname_last_n_nodes((u8 *) file, 4), - line); + pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d))\n", + id, ULTRA_CHANNELCLI_STRING( + readl(&hdr->cli_state_os)), + readl(&hdr->cli_state_os)); } return 0; } - writel(CHANNELCLI_BUSY, &pChan->cli_state_os); + writel(CHANNELCLI_BUSY, &hdr->cli_state_os); mb(); /* required for channel synch */ - if (readl(&pChan->cli_state_boot) == CHANNELCLI_BUSY) { - if ((readb(&pChan->cli_error_os) + if (readl(&hdr->cli_state_boot) == CHANNELCLI_BUSY) { + if ((readb(&hdr->cli_error_os) & ULTRA_CLIERROROS_THROTTLEMSG_BUSY) == 0) { /* we are NOT throttling this message */ - writeb(readb(&pChan->cli_error_os) | + writeb(readb(&hdr->cli_error_os) | ULTRA_CLIERROROS_THROTTLEMSG_BUSY, - &pChan->cli_error_os); + &hdr->cli_error_os); /* throttle until acquire successful */ - pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n", - chanId, pathname_last_n_nodes((u8 *) file, 4), - line); + pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY\n", + id); } /* reset busy */ - writel(CHANNELCLI_ATTACHED, &pChan->cli_state_os); + writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os); mb(); /* required for channel synch */ return 0; } - if (readb(&pChan->cli_error_os) != 0) { + if (readb(&hdr->cli_error_os) != 0) { /* we are in an error msg throttling state; come out of it */ - pr_info("%s Channel OS client acquire now successful @%s:%d\n", - chanId, pathname_last_n_nodes((u8 *) file, 4), - line); - writeb(0, &pChan->cli_error_os); + pr_info("%s Channel OS client acquire now successful\n", id); + writeb(0, &hdr->cli_error_os); } return 1; } diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index 44208841bd5a..27d0b2023cc7 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -81,7 +81,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, u8 rc = 0; spin_lock_irqsave(lock, flags); - if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(queueinfo->chan, channelId, NULL)) + if (!spar_channel_client_acquire_os(queueinfo->chan, channelId)) goto unlock; if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) { queueinfo->packets_sent++; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 9e98af8451b3..5c79455962ea 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1276,8 +1276,8 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, while (1) { spin_lock_irqsave(&virthbainfo->chinfo.insertlock, flags); - if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(dc->queueinfo->chan, - "vhba", NULL)) { + if (!spar_channel_client_acquire_os(dc->queueinfo->chan, + "vhba")) { spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, flags); virthbainfo->acquire_failed_cnt++; -- cgit v1.2.3-59-g8ed1b From 0859891848dcbf192afa4a73ee5f8ddd5e6c0e11 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:02 -0400 Subject: staging: unisys: refactor ULTRA_channel_client_release_os() Remove the unnecessary macro ULTRA_CHANNEL_CLIENT_RELEASE_OS(), rename the function to spar_channel_client_release_os(), fix references to the macro to call the function directly instead, remove the unnecessary logCtx, file, and line parameters, and fix CamelCase names: pChannel => ch chanId => id pChan => hdr Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 32 ++++++++-------------- drivers/staging/unisys/uislib/uisqueue.c | 2 +- drivers/staging/unisys/virthba/virthba.c | 3 +- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 8c3fdf7e879f..84f64624bd63 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -149,10 +149,6 @@ ULTRA_CHANNELCLI_STRING(u32 v) mb(); /* required for channel synch */ \ } while (0) -#define ULTRA_CHANNEL_CLIENT_RELEASE_OS(pChan, chanId, logCtx) \ - ULTRA_channel_client_release_os(pChan, chanId, logCtx, \ - (char *)__FILE__, __LINE__, (char *)__func__) - /* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */ /* throttling invalid boot channel statetransition error due to client * disabled */ @@ -494,29 +490,25 @@ spar_channel_client_acquire_os(void __iomem *ch, u8 *id) } static inline void -ULTRA_channel_client_release_os(void __iomem *pChannel, u8 *chanId, - void *logCtx, char *file, int line, char *func) +spar_channel_client_release_os(void __iomem *ch, u8 *id) { - struct channel_header __iomem *pChan = pChannel; + struct channel_header __iomem *hdr = ch; - if (readb(&pChan->cli_error_os) != 0) { + if (readb(&hdr->cli_error_os) != 0) { /* we are in an error msg throttling state; come out of it */ - pr_info("%s Channel OS client error state cleared @%s:%d\n", - chanId, pathname_last_n_nodes((u8 *) file, 4), - line); - writeb(0, &pChan->cli_error_os); + pr_info("%s Channel OS client error state cleared\n", id); + writeb(0, &hdr->cli_error_os); } - if (readl(&pChan->cli_state_os) == CHANNELCLI_OWNED) + if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED) return; - if (readl(&pChan->cli_state_os) != CHANNELCLI_BUSY) { - pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d)) @%s:%d\n", - chanId, ULTRA_CHANNELCLI_STRING( - readl(&pChan->cli_state_os)), - readl(&pChan->cli_state_os), - pathname_last_n_nodes((u8 *) file, 4), line); + if (readl(&hdr->cli_state_os) != CHANNELCLI_BUSY) { + pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d))\n", + id, ULTRA_CHANNELCLI_STRING( + readl(&hdr->cli_state_os)), + readl(&hdr->cli_state_os)); /* return; */ } - writel(CHANNELCLI_ATTACHED, &pChan->cli_state_os); /* release busy */ + writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os); /* release busy */ } /* diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index 27d0b2023cc7..b9694a6d40c1 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -87,7 +87,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, queueinfo->packets_sent++; rc = 1; } - ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, NULL); + spar_channel_client_release_os(queueinfo->chan, channelId); unlock: spin_unlock_irqrestore((spinlock_t *)lock, flags); return rc; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 5c79455962ea..df0e89ccdc18 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1285,8 +1285,7 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, } qrslt = uisqueue_get_cmdrsp(dc->queueinfo, cmdrsp, IOCHAN_FROM_IOPART); - ULTRA_CHANNEL_CLIENT_RELEASE_OS(dc->queueinfo->chan, - "vhba", NULL); + spar_channel_client_release_os(dc->queueinfo->chan, "vhba"); spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, flags); if (qrslt == 0) break; -- cgit v1.2.3-59-g8ed1b From e0fed862c84dbd4b6fce1e6e525767b0a4b95c81 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:03 -0400 Subject: staging: unisys: remove typedef SIGNAL_QUEUE_HEADER Get rid of the typedef for SIGNAL_QUEUE_HEADER and use struct signal_queue_header directly instead. Fix all references to the typedef to use the struct. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 16 ++++----- .../unisys/common-spar/include/channels/channel.h | 4 +-- .../include/channels/controlvmchannel.h | 8 ++--- .../common-spar/include/channels/diagchannel.h | 4 +-- .../common-spar/include/channels/iochannel.h | 4 +-- drivers/staging/unisys/include/uisqueue.h | 4 +-- drivers/staging/unisys/virthba/virthba.c | 8 ++--- .../unisys/visorchannel/visorchannel_funcs.c | 41 ++++++++++++---------- 8 files changed, 46 insertions(+), 43 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index c2f95f33b114..d6db66181148 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -50,8 +50,8 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, void __iomem *psignal; unsigned int head, tail, nof; - SIGNAL_QUEUE_HEADER __iomem *pqhdr = - (SIGNAL_QUEUE_HEADER __iomem *) + struct signal_queue_header __iomem *pqhdr = + (struct signal_queue_header __iomem *) ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) + Queue; @@ -108,8 +108,8 @@ visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, { void __iomem *psource; unsigned int head, tail; - SIGNAL_QUEUE_HEADER __iomem *pqhdr = - (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel + + struct signal_queue_header __iomem *pqhdr = + (struct signal_queue_header __iomem *) ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) + Queue; /* capture current head and tail */ @@ -163,8 +163,8 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) { void *psource; unsigned int head, tail, signalCount = 0; - pSIGNAL_QUEUE_HEADER pqhdr = - (pSIGNAL_QUEUE_HEADER) ((char *) pChannel + + struct signal_queue_header *pqhdr = + (struct signal_queue_header *) ((char *) pChannel + pChannel->ch_space_offset) + Queue; /* capture current head and tail */ @@ -212,8 +212,8 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) unsigned char visor_signalqueue_empty(struct channel_header __iomem *pChannel, u32 Queue) { - SIGNAL_QUEUE_HEADER __iomem *pqhdr = - (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel + + struct signal_queue_header __iomem *pqhdr = + (struct signal_queue_header __iomem *) ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) + Queue; return readl(&pqhdr->Head) == readl(&pqhdr->Tail); } diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 84f64624bd63..3c4f7c058e53 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -232,7 +232,7 @@ struct channel_header { #define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0) /* Subheader for the Signal Type variation of the Common Channel */ -typedef struct _SIGNAL_QUEUE_HEADER { +struct signal_queue_header { /* 1st cache line */ u32 VersionId; /* SIGNAL_QUEUE_HEADER Version ID */ u32 Type; /* Queue type: storage, network */ @@ -265,7 +265,7 @@ typedef struct _SIGNAL_QUEUE_HEADER { * to denote trouble with client's * fields */ u8 Filler[12]; /* Pad out to 64 byte cacheline */ -} SIGNAL_QUEUE_HEADER, *pSIGNAL_QUEUE_HEADER; +}; #pragma pack(pop) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 8e8a5a57bddb..91e75f4d3e21 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -542,16 +542,16 @@ typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { u32 SPReserved; u8 Reserved2[28]; /* Force signals to begin on 128-byte cache * line */ - SIGNAL_QUEUE_HEADER RequestQueue; /* Service or guest partition + struct signal_queue_header RequestQueue;/* Service or guest partition * uses this queue to send * requests to Control */ - SIGNAL_QUEUE_HEADER ResponseQueue; /* Control uses this queue to + struct signal_queue_header ResponseQueue;/* Control uses this queue to * respond to service or guest * partition requests */ - SIGNAL_QUEUE_HEADER EventQueue; /* Control uses this queue to + struct signal_queue_header EventQueue; /* Control uses this queue to * send events to service or * guest partition */ - SIGNAL_QUEUE_HEADER EventAckQueue; /* Service or guest partition + struct signal_queue_header EventAckQueue;/* Service or guest partition * uses this queue to ack * Control events */ diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 590022fd9fb6..919f628360c2 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -384,7 +384,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { /* Offsets/sizes for diagnostic channel attributes... */ #define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header)) -#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(SIGNAL_QUEUE_HEADER)) +#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header)) #define DIAG_CH_PROTOCOL_HEADER_OFFSET \ (DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE) #define DIAG_CH_PROTOCOL_HEADER_SIZE (sizeof(DIAG_CHANNEL_PROTOCOL_HEADER)) @@ -417,7 +417,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { */ typedef struct _ULTRA_DIAG_CHANNEL_PROTOCOL { struct channel_header CommonChannelHeader; - SIGNAL_QUEUE_HEADER QueueHeader; + struct signal_queue_header QueueHeader; DIAG_CHANNEL_PROTOCOL_HEADER DiagChannelHeader; DIAG_CHANNEL_EVENT Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / sizeof(DIAG_CHANNEL_EVENT)]; diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index c26363de86dd..ac78d9c2585c 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -686,8 +686,8 @@ struct uiscmdrsp { * response queues as specified in cmdQ and rspQ SIGNAL_QUEUE_HEADERS. */ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { struct channel_header ChannelHeader; - SIGNAL_QUEUE_HEADER cmdQ; - SIGNAL_QUEUE_HEADER rspQ; + struct signal_queue_header cmdQ; + struct signal_queue_header rspQ; union { struct { struct vhba_wwnn wwnn; /* 8 bytes */ diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 7d01c42abcb9..25b6181d78af 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -47,8 +47,8 @@ struct uisqueue_info { u64 non_empty_wakeup_cnt; struct { - SIGNAL_QUEUE_HEADER reserved1; /* */ - SIGNAL_QUEUE_HEADER reserved2; /* */ + struct signal_queue_header reserved1; /* */ + struct signal_queue_header reserved2; /* */ } safe_uis_queue; unsigned int (*send_int_if_needed)(struct uisqueue_info *info, unsigned int whichcqueue, diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index df0e89ccdc18..9d4653d34608 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -421,7 +421,7 @@ virthba_ISR(int irq, void *dev_id) { struct virthba_info *virthbainfo = (struct virthba_info *) dev_id; struct channel_header __iomem *pChannelHeader; - SIGNAL_QUEUE_HEADER __iomem *pqhdr; + struct signal_queue_header __iomem *pqhdr; u64 mask; unsigned long long rc1; @@ -442,7 +442,7 @@ virthba_ISR(int irq, void *dev_id) virthbainfo->interrupts_notme++; return IRQ_NONE; } - pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) + pqhdr = (struct signal_queue_header __iomem *) ((char __iomem *) pChannelHeader + readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; writeq(readq(&pqhdr->NumInterruptsReceived) + 1, @@ -462,7 +462,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) int i; irq_handler_t handler = virthba_ISR; struct channel_header __iomem *pChannelHeader; - SIGNAL_QUEUE_HEADER __iomem *pqhdr; + struct signal_queue_header __iomem *pqhdr; u64 mask; LOGVER("entering virthba_probe...\n"); @@ -586,7 +586,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) virthbainfo->chinfo.queueinfo, &virthbainfo->chinfo.threadinfo); pChannelHeader = virthbainfo->chinfo.queueinfo->chan; - pqhdr = (SIGNAL_QUEUE_HEADER __iomem *) + pqhdr = (struct signal_queue_header __iomem *) ((char __iomem *)pChannelHeader + readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; virthbainfo->flags_addr = &pqhdr->FeatureFlags; diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 19f5c775ca88..7b30c66d3a3e 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -38,10 +38,10 @@ struct VISORCHANNEL_Tag { spinlock_t remove_lock; struct { - SIGNAL_QUEUE_HEADER req_queue; - SIGNAL_QUEUE_HEADER rsp_queue; - SIGNAL_QUEUE_HEADER event_queue; - SIGNAL_QUEUE_HEADER ack_queue; + struct signal_queue_header req_queue; + struct signal_queue_header rsp_queue; + struct signal_queue_header event_queue; + struct signal_queue_header ack_queue; } safe_uis_queue; }; @@ -295,7 +295,8 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); * channel header */ #define SIG_QUEUE_OFFSET(chan_hdr, q) \ - ((chan_hdr)->ch_space_offset + ((q) * sizeof(SIGNAL_QUEUE_HEADER))) + ((chan_hdr)->ch_space_offset + \ + ((q) * sizeof(struct signal_queue_header))) /** Return offset of a specific queue entry (data) from the beginning of a * channel header @@ -310,13 +311,13 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); #define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \ (visor_memregion_write(channel->memregion, \ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \ - offsetof(SIGNAL_QUEUE_HEADER, FIELD), \ + offsetof(struct signal_queue_header, FIELD),\ &((sig_hdr)->FIELD), \ sizeof((sig_hdr)->FIELD)) >= 0) static BOOL sig_read_header(VISORCHANNEL *channel, u32 queue, - SIGNAL_QUEUE_HEADER *sig_hdr) + struct signal_queue_header *sig_hdr) { BOOL rc = FALSE; @@ -329,7 +330,8 @@ sig_read_header(VISORCHANNEL *channel, u32 queue, if (visor_memregion_read(channel->memregion, SIG_QUEUE_OFFSET(&channel->chan_hdr, queue), - sig_hdr, sizeof(SIGNAL_QUEUE_HEADER)) < 0) { + sig_hdr, + sizeof(struct signal_queue_header)) < 0) { ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d", queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)); ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", rc); @@ -342,7 +344,8 @@ Away: static BOOL sig_do_data(VISORCHANNEL *channel, u32 queue, - SIGNAL_QUEUE_HEADER *sig_hdr, u32 slot, void *data, BOOL is_write) + struct signal_queue_header *sig_hdr, u32 slot, void *data, + BOOL is_write) { BOOL rc = FALSE; int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue, @@ -368,21 +371,21 @@ Away: static inline BOOL sig_read_data(VISORCHANNEL *channel, u32 queue, - SIGNAL_QUEUE_HEADER *sig_hdr, u32 slot, void *data) + struct signal_queue_header *sig_hdr, u32 slot, void *data) { return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE); } static inline BOOL sig_write_data(VISORCHANNEL *channel, u32 queue, - SIGNAL_QUEUE_HEADER *sig_hdr, u32 slot, void *data) + struct signal_queue_header *sig_hdr, u32 slot, void *data) { return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE); } static inline unsigned char -safe_sig_queue_validate(pSIGNAL_QUEUE_HEADER psafe_sqh, - pSIGNAL_QUEUE_HEADER punsafe_sqh, +safe_sig_queue_validate(struct signal_queue_header *psafe_sqh, + struct signal_queue_header *punsafe_sqh, u32 *phead, u32 *ptail) { if ((*phead >= psafe_sqh->MaxSignalSlots) @@ -406,7 +409,7 @@ BOOL visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) { BOOL rc = FALSE; - SIGNAL_QUEUE_HEADER sig_hdr; + struct signal_queue_header sig_hdr; if (channel->needs_lock) spin_lock(&channel->remove_lock); @@ -452,7 +455,7 @@ BOOL visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) { BOOL rc = FALSE; - SIGNAL_QUEUE_HEADER sig_hdr; + struct signal_queue_header sig_hdr; if (channel->needs_lock) spin_lock(&channel->insert_lock); @@ -505,7 +508,7 @@ EXPORT_SYMBOL_GPL(visorchannel_signalinsert); int visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue) { - SIGNAL_QUEUE_HEADER sig_hdr; + struct signal_queue_header sig_hdr; u32 slots_avail, slots_used; u32 head, tail; @@ -524,7 +527,7 @@ EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail); int visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue) { - SIGNAL_QUEUE_HEADER sig_hdr; + struct signal_queue_header sig_hdr; if (!sig_read_header(channel, queue, &sig_hdr)) return 0; @@ -533,7 +536,7 @@ visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue) EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots); static void -sigqueue_debug(SIGNAL_QUEUE_HEADER *q, int which, struct seq_file *seq) +sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq) { seq_printf(seq, "Signal Queue #%d\n", which); seq_printf(seq, " VersionId = %lu\n", (ulong) q->VersionId); @@ -617,7 +620,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, ; else for (i = 0; i < nQueues; i++) { - SIGNAL_QUEUE_HEADER q; + struct signal_queue_header q; errcode = visorchannel_read(channel, off + phdr->ch_space_offset + -- cgit v1.2.3-59-g8ed1b From 153cf7107214f0fc51df895f4fdd4f4b14011d0e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:04 -0400 Subject: staging: unisys: fix CamelCase in struct signal_queue_header Fix CamelCase names: VersionId => version Type => chtype Size => size oSignalBase => sig_base_offset FeatureFlags => features NumSignalsSent => num_sent NumOverflows => num_overflows SignalSize => signal_size MaxSignalSlots => max_slots MaxSignals => max_signals Head => head NumSignalsReceived => num_received Tail => tail Reserved1 => reserved1 Reserved2 => reserved2 ClientQueue => client_queue NumInterruptsReceived => num_irq_received NumEmptyCnt => num_empty ErrorFlags => errorflags Filler => filler Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 62 ++++++++--------- .../unisys/common-spar/include/channels/channel.h | 40 +++++------ .../common-spar/include/channels/iochannel.h | 38 +++++----- drivers/staging/unisys/virthba/virthba.c | 6 +- .../unisys/visorchannel/visorchannel_funcs.c | 80 +++++++++++----------- 5 files changed, 113 insertions(+), 113 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index d6db66181148..0a98c5c67ff9 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -56,30 +56,30 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, + Queue; /* capture current head and tail */ - head = readl(&pqhdr->Head); - tail = readl(&pqhdr->Tail); + head = readl(&pqhdr->head); + tail = readl(&pqhdr->tail); /* queue is full if (head + 1) % n equals tail */ - if (((head + 1) % readl(&pqhdr->MaxSignalSlots)) == tail) { - nof = readq(&pqhdr->NumOverflows) + 1; - writeq(nof, &pqhdr->NumOverflows); + if (((head + 1) % readl(&pqhdr->max_slots)) == tail) { + nof = readq(&pqhdr->num_overflows) + 1; + writeq(nof, &pqhdr->num_overflows); return 0; } /* increment the head index */ - head = (head + 1) % readl(&pqhdr->MaxSignalSlots); + head = (head + 1) % readl(&pqhdr->max_slots); /* copy signal to the head location from the area pointed to * by pSignal */ - psignal = (char __iomem *)pqhdr + readq(&pqhdr->oSignalBase) + - (head * readl(&pqhdr->SignalSize)); - memcpy_toio(psignal, pSignal, readl(&pqhdr->SignalSize)); + psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + + (head * readl(&pqhdr->signal_size)); + memcpy_toio(psignal, pSignal, readl(&pqhdr->signal_size)); mb(); /* channel synch */ - writel(head, &pqhdr->Head); + writel(head, &pqhdr->head); - writeq(readq(&pqhdr->NumSignalsSent) + 1, &pqhdr->NumSignalsSent); + writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent); return 1; } EXPORT_SYMBOL_GPL(visor_signal_insert); @@ -113,28 +113,28 @@ visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, readq(&pChannel->ch_space_offset)) + Queue; /* capture current head and tail */ - head = readl(&pqhdr->Head); - tail = readl(&pqhdr->Tail); + head = readl(&pqhdr->head); + tail = readl(&pqhdr->tail); /* queue is empty if the head index equals the tail index */ if (head == tail) { - writeq(readq(&pqhdr->NumEmptyCnt) + 1, &pqhdr->NumEmptyCnt); + writeq(readq(&pqhdr->num_empty) + 1, &pqhdr->num_empty); return 0; } /* advance past the 'empty' front slot */ - tail = (tail + 1) % readl(&pqhdr->MaxSignalSlots); + tail = (tail + 1) % readl(&pqhdr->max_slots); /* copy signal from tail location to the area pointed to by pSignal */ - psource = (char __iomem *) pqhdr + readq(&pqhdr->oSignalBase) + - (tail * readl(&pqhdr->SignalSize)); - memcpy_fromio(pSignal, psource, readl(&pqhdr->SignalSize)); + psource = (char __iomem *) pqhdr + readq(&pqhdr->sig_base_offset) + + (tail * readl(&pqhdr->signal_size)); + memcpy_fromio(pSignal, psource, readl(&pqhdr->signal_size)); mb(); /* channel synch */ - writel(tail, &pqhdr->Tail); + writel(tail, &pqhdr->tail); - writeq(readq(&pqhdr->NumSignalsReceived) + 1, - &pqhdr->NumSignalsReceived); + writeq(readq(&pqhdr->num_received) + 1, + &pqhdr->num_received); return 1; } EXPORT_SYMBOL_GPL(visor_signal_remove); @@ -168,8 +168,8 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) pChannel->ch_space_offset) + Queue; /* capture current head and tail */ - head = pqhdr->Head; - tail = pqhdr->Tail; + head = pqhdr->head; + tail = pqhdr->tail; /* queue is empty if the head index equals the tail index */ if (head == tail) @@ -177,22 +177,22 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) while (head != tail) { /* advance past the 'empty' front slot */ - tail = (tail + 1) % pqhdr->MaxSignalSlots; + tail = (tail + 1) % pqhdr->max_slots; /* copy signal from tail location to the area pointed * to by pSignal */ psource = - (char *) pqhdr + pqhdr->oSignalBase + - (tail * pqhdr->SignalSize); - memcpy((char *) pSignal + (pqhdr->SignalSize * signalCount), - psource, pqhdr->SignalSize); + (char *) pqhdr + pqhdr->sig_base_offset + + (tail * pqhdr->signal_size); + memcpy((char *) pSignal + (pqhdr->signal_size * signalCount), + psource, pqhdr->signal_size); mb(); /* channel synch */ - pqhdr->Tail = tail; + pqhdr->tail = tail; signalCount++; - pqhdr->NumSignalsReceived++; + pqhdr->num_received++; } return signalCount; @@ -215,7 +215,7 @@ visor_signalqueue_empty(struct channel_header __iomem *pChannel, u32 Queue) struct signal_queue_header __iomem *pqhdr = (struct signal_queue_header __iomem *) ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) + Queue; - return readl(&pqhdr->Head) == readl(&pqhdr->Tail); + return readl(&pqhdr->head) == readl(&pqhdr->tail); } EXPORT_SYMBOL_GPL(visor_signalqueue_empty); diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 3c4f7c058e53..c01c2e69379d 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -234,37 +234,37 @@ struct channel_header { /* Subheader for the Signal Type variation of the Common Channel */ struct signal_queue_header { /* 1st cache line */ - u32 VersionId; /* SIGNAL_QUEUE_HEADER Version ID */ - u32 Type; /* Queue type: storage, network */ - u64 Size; /* Total size of this queue in bytes */ - u64 oSignalBase; /* Offset to signal queue area */ - u64 FeatureFlags; /* Flags to modify behavior */ - u64 NumSignalsSent; /* Total # of signals placed in this queue */ - u64 NumOverflows; /* Total # of inserts failed due to + u32 version; /* SIGNAL_QUEUE_HEADER Version ID */ + u32 chtype; /* Queue type: storage, network */ + u64 size; /* Total size of this queue in bytes */ + u64 sig_base_offset; /* Offset to signal queue area */ + u64 features; /* Flags to modify behavior */ + u64 num_sent; /* Total # of signals placed in this queue */ + u64 num_overflows; /* Total # of inserts failed due to * full queue */ - u32 SignalSize; /* Total size of a signal for this queue */ - u32 MaxSignalSlots; /* Max # of slots in queue, 1 slot is + u32 signal_size; /* Total size of a signal for this queue */ + u32 max_slots; /* Max # of slots in queue, 1 slot is * always empty */ - u32 MaxSignals; /* Max # of signals in queue + u32 max_signals; /* Max # of signals in queue * (MaxSignalSlots-1) */ - u32 Head; /* Queue head signal # */ + u32 head; /* Queue head signal # */ /* 2nd cache line */ - u64 NumSignalsReceived; /* Total # of signals removed from this queue */ - u32 Tail; /* Queue tail signal # (on separate + u64 num_received; /* Total # of signals removed from this queue */ + u32 tail; /* Queue tail signal # (on separate * cache line) */ - u32 Reserved1; /* Reserved field */ - u64 Reserved2; /* Resrved field */ - u64 ClientQueue; - u64 NumInterruptsReceived; /* Total # of Interrupts received. This + u32 reserved1; /* Reserved field */ + u64 reserved2; /* Reserved field */ + u64 client_queue; + u64 num_irq_received; /* Total # of Interrupts received. This * is incremented by the ISR in the * guest windows driver */ - u64 NumEmptyCnt; /* Number of times that visor_signal_remove + u64 num_empty; /* Number of times that visor_signal_remove * is called and returned Empty * Status. */ - u32 ErrorFlags; /* Error bits set during SignalReinit + u32 errorflags; /* Error bits set during SignalReinit * to denote trouble with client's * fields */ - u8 Filler[12]; /* Pad out to 64 byte cacheline */ + u8 filler[12]; /* Pad out to 64 byte cacheline */ }; #pragma pack(pop) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index ac78d9c2585c..d487cb2f06aa 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -750,21 +750,21 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { #define QSIZEFROMBYTES(bytes) (QSLOTSFROMBYTES(bytes)*SIZEOF_CMDRSP) #define SignalQInit(x) \ do { \ - x->cmdQ.Size = QSIZEFROMBYTES(x->ChannelHeader.size); \ - x->cmdQ.oSignalBase = SIZEOF_PROTOCOL - \ + x->cmdQ.size = QSIZEFROMBYTES(x->ChannelHeader.size); \ + x->cmdQ.sig_base_offset = SIZEOF_PROTOCOL - \ offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ - x->cmdQ.SignalSize = SIZEOF_CMDRSP; \ - x->cmdQ.MaxSignalSlots = \ + x->cmdQ.signal_size = SIZEOF_CMDRSP; \ + x->cmdQ.max_slots = \ QSLOTSFROMBYTES(x->ChannelHeader.size); \ - x->cmdQ.MaxSignals = x->cmdQ.MaxSignalSlots - 1; \ - x->rspQ.Size = QSIZEFROMBYTES(x->ChannelHeader.size); \ - x->rspQ.oSignalBase = \ - (SIZEOF_PROTOCOL + x->cmdQ.Size) - \ + x->cmdQ.max_signals = x->cmdQ.max_slots - 1; \ + x->rspQ.size = QSIZEFROMBYTES(x->ChannelHeader.size); \ + x->rspQ.sig_base_offset = \ + (SIZEOF_PROTOCOL + x->cmdQ.size) - \ offsetof(ULTRA_IO_CHANNEL_PROTOCOL, rspQ); \ - x->rspQ.SignalSize = SIZEOF_CMDRSP; \ - x->rspQ.MaxSignalSlots = \ + x->rspQ.signal_size = SIZEOF_CMDRSP; \ + x->rspQ.max_slots = \ QSLOTSFROMBYTES(x->ChannelHeader.size); \ - x->rspQ.MaxSignals = x->rspQ.MaxSignalSlots - 1; \ + x->rspQ.max_signals = x->rspQ.max_slots - 1; \ x->ChannelHeader.ch_space_offset = \ offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ } while (0) @@ -814,12 +814,12 @@ static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr, clientStrLen); SignalQInit(x); - if ((x->cmdQ.MaxSignalSlots > MAX_NUMSIGNALS) || - (x->rspQ.MaxSignalSlots > MAX_NUMSIGNALS)) { + if ((x->cmdQ.max_slots > MAX_NUMSIGNALS) || + (x->rspQ.max_slots > MAX_NUMSIGNALS)) { return 0; } - if ((x->cmdQ.MaxSignalSlots < MIN_NUMSIGNALS) || - (x->rspQ.MaxSignalSlots < MIN_NUMSIGNALS)) { + if ((x->cmdQ.max_slots < MIN_NUMSIGNALS) || + (x->rspQ.max_slots < MIN_NUMSIGNALS)) { return 0; } return 1; @@ -852,12 +852,12 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr, clientStrLen); SignalQInit(x); - if ((x->cmdQ.MaxSignalSlots > MAX_NUMSIGNALS) || - (x->rspQ.MaxSignalSlots > MAX_NUMSIGNALS)) { + if ((x->cmdQ.max_slots > MAX_NUMSIGNALS) || + (x->rspQ.max_slots > MAX_NUMSIGNALS)) { return 0; } - if ((x->cmdQ.MaxSignalSlots < MIN_NUMSIGNALS) || - (x->rspQ.MaxSignalSlots < MIN_NUMSIGNALS)) { + if ((x->cmdQ.max_slots < MIN_NUMSIGNALS) || + (x->rspQ.max_slots < MIN_NUMSIGNALS)) { return 0; } return 1; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 9d4653d34608..a3da5e999331 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -445,8 +445,8 @@ virthba_ISR(int irq, void *dev_id) pqhdr = (struct signal_queue_header __iomem *) ((char __iomem *) pChannelHeader + readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; - writeq(readq(&pqhdr->NumInterruptsReceived) + 1, - &pqhdr->NumInterruptsReceived); + writeq(readq(&pqhdr->num_irq_received) + 1, + &pqhdr->num_irq_received); atomic_set(&virthbainfo->interrupt_rcvd, 1); wake_up_interruptible(&virthbainfo->rsp_queue); return IRQ_HANDLED; @@ -589,7 +589,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) pqhdr = (struct signal_queue_header __iomem *) ((char __iomem *)pChannelHeader + readq(&pChannelHeader->ch_space_offset)) + IOCHAN_FROM_IOPART; - virthbainfo->flags_addr = &pqhdr->FeatureFlags; + virthbainfo->flags_addr = &pqhdr->features; if (!uisthread_start(&virthbainfo->chinfo.threadinfo, process_incoming_rsps, diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 7b30c66d3a3e..c24052b13fd2 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -302,8 +302,8 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header); * channel header */ #define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \ - (SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->oSignalBase + \ - ((slot) * (sig_hdr)->SignalSize)) + (SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \ + ((slot) * (sig_hdr)->signal_size)) /** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back * into host memory @@ -353,13 +353,13 @@ sig_do_data(VISORCHANNEL *channel, u32 queue, if (is_write) { if (visor_memregion_write(channel->memregion, signal_data_offset, - data, sig_hdr->SignalSize) < 0) { + data, sig_hdr->signal_size) < 0) { ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", rc); goto Away; } } else { if (visor_memregion_read(channel->memregion, signal_data_offset, - data, sig_hdr->SignalSize) < 0) { + data, sig_hdr->signal_size) < 0) { ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", rc); goto Away; } @@ -388,18 +388,18 @@ safe_sig_queue_validate(struct signal_queue_header *psafe_sqh, struct signal_queue_header *punsafe_sqh, u32 *phead, u32 *ptail) { - if ((*phead >= psafe_sqh->MaxSignalSlots) - || (*ptail >= psafe_sqh->MaxSignalSlots)) { + if ((*phead >= psafe_sqh->max_slots) + || (*ptail >= psafe_sqh->max_slots)) { /* Choose 0 or max, maybe based on current tail value */ *phead = 0; *ptail = 0; /* Sync with client as necessary */ - punsafe_sqh->Head = *phead; - punsafe_sqh->Tail = *ptail; + punsafe_sqh->head = *phead; + punsafe_sqh->tail = *ptail; ERRDRV("safe_sig_queue_validate: head = 0x%x, tail = 0x%x, MaxSlots = 0x%x", - *phead, *ptail, psafe_sqh->MaxSignalSlots); + *phead, *ptail, psafe_sqh->max_slots); return 0; } return 1; @@ -418,27 +418,27 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) rc = FALSE; goto Away; } - if (sig_hdr.Head == sig_hdr.Tail) { + if (sig_hdr.head == sig_hdr.tail) { rc = FALSE; /* no signals to remove */ goto Away; } - sig_hdr.Tail = (sig_hdr.Tail + 1) % sig_hdr.MaxSignalSlots; - if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.Tail, msg)) { + sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; + if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) { ERRDRV("sig_read_data failed: (status=%d)\n", rc); goto Away; } - sig_hdr.NumSignalsReceived++; + sig_hdr.num_received++; /* For each data field in SIGNAL_QUEUE_HEADER that was modified, * update host memory. */ mb(); /* required for channel synch */ - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail)) { + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail)) { ERRDRV("visor_memregion_write of Tail failed: (status=%d)\n", rc); goto Away; } - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsReceived)) { + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) { ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", rc); goto Away; } @@ -465,10 +465,10 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) goto Away; } - sig_hdr.Head = ((sig_hdr.Head + 1) % sig_hdr.MaxSignalSlots); - if (sig_hdr.Head == sig_hdr.Tail) { - sig_hdr.NumOverflows++; - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumOverflows)) { + sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots); + if (sig_hdr.head == sig_hdr.tail) { + sig_hdr.num_overflows++; + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows)) { ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", rc); goto Away; } @@ -476,22 +476,22 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) goto Away; } - if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.Head, msg)) { + if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg)) { ERRDRV("sig_write_data failed: (status=%d)\n", rc); goto Away; } - sig_hdr.NumSignalsSent++; + sig_hdr.num_sent++; /* For each data field in SIGNAL_QUEUE_HEADER that was modified, * update host memory. */ mb(); /* required for channel synch */ - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head)) { + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head)) { ERRDRV("visor_memregion_write of Head failed: (status=%d)\n", rc); goto Away; } - if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsSent)) { + if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) { ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", rc); goto Away; } @@ -514,12 +514,12 @@ visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue) if (!sig_read_header(channel, queue, &sig_hdr)) return 0; - head = sig_hdr.Head; - tail = sig_hdr.Tail; + head = sig_hdr.head; + tail = sig_hdr.tail; if (head < tail) - head = head + sig_hdr.MaxSignalSlots; + head = head + sig_hdr.max_slots; slots_used = (head - tail); - slots_avail = sig_hdr.MaxSignals - slots_used; + slots_avail = sig_hdr.max_signals - slots_used; return (int) slots_avail; } EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail); @@ -531,7 +531,7 @@ visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue) if (!sig_read_header(channel, queue, &sig_hdr)) return 0; - return (int) sig_hdr.MaxSignals; + return (int) sig_hdr.max_signals; } EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots); @@ -539,24 +539,24 @@ static void sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq) { seq_printf(seq, "Signal Queue #%d\n", which); - seq_printf(seq, " VersionId = %lu\n", (ulong) q->VersionId); - seq_printf(seq, " Type = %lu\n", (ulong) q->Type); + seq_printf(seq, " VersionId = %lu\n", (ulong)q->version); + seq_printf(seq, " Type = %lu\n", (ulong)q->chtype); seq_printf(seq, " oSignalBase = %llu\n", - (long long) q->oSignalBase); - seq_printf(seq, " SignalSize = %lu\n", (ulong) q->SignalSize); + (long long)q->sig_base_offset); + seq_printf(seq, " SignalSize = %lu\n", (ulong)q->signal_size); seq_printf(seq, " MaxSignalSlots = %lu\n", - (ulong) q->MaxSignalSlots); - seq_printf(seq, " MaxSignals = %lu\n", (ulong) q->MaxSignals); + (ulong)q->max_slots); + seq_printf(seq, " MaxSignals = %lu\n", (ulong)q->max_signals); seq_printf(seq, " FeatureFlags = %-16.16Lx\n", - (long long) q->FeatureFlags); + (long long)q->features); seq_printf(seq, " NumSignalsSent = %llu\n", - (long long) q->NumSignalsSent); + (long long)q->num_sent); seq_printf(seq, " NumSignalsReceived = %llu\n", - (long long) q->NumSignalsReceived); + (long long)q->num_received); seq_printf(seq, " NumOverflows = %llu\n", - (long long) q->NumOverflows); - seq_printf(seq, " Head = %lu\n", (ulong) q->Head); - seq_printf(seq, " Tail = %lu\n", (ulong) q->Tail); + (long long)q->num_overflows); + seq_printf(seq, " Head = %lu\n", (ulong)q->head); + seq_printf(seq, " Tail = %lu\n", (ulong)q->tail); } void -- cgit v1.2.3-59-g8ed1b From 93a8456556b430f5b4d753ee8872c2a7a0dd24e9 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:05 -0400 Subject: staging: unisys: refactor ULTRA_check_channel_client() Rename the function ULTRA_check_channel_client() to spar_check_channel_client(), and fix CamelCase parameter names: pChannel => ch expectedTypeGuid => expected_uuid channelName => chname expectedMinBytes => expected_min_bytes expectedVersionId => expected_version expectedSignature => expected_signature Rename macros that use spar_check_channel_client: ULTRA_CONTROLVM_CHANNEL_OK_CLIENT => SPAR_CONTROLVM_CHANNEL_OK_CLIENT ULTRA_VHBA_CHANNEL_OK_CLIENT => SPAR_VHBA_CHANNEL_OK_CLIENT ULTRA_VNIC_CHANNEL_OK_CLIENT => SPAR_VNIC_CHANNEL_OK_CLIENT ULTRA_VSWITCH_CHANNEL_OK_CLIENT => SPAR_VSWITCH_CHANNEL_OK_CLIENT ULTRA_VBUS_CHANNEL_OK_CLIENT => SPAR_VBUS_CHANNEL_OK_CLIENT Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 13 ++-- drivers/staging/unisys/channels/chanstub.c | 2 +- .../unisys/common-spar/include/channels/channel.h | 82 ++++++++-------------- .../include/channels/controlvmchannel.h | 20 ++---- .../common-spar/include/channels/diagchannel.h | 5 +- .../common-spar/include/channels/iochannel.h | 47 +++++-------- .../common-spar/include/channels/vbuschannel.h | 21 ++---- drivers/staging/unisys/uislib/uislib.c | 6 +- drivers/staging/unisys/uislib/uisqueue.c | 2 +- .../unisys/visorchipset/visorchipset_main.c | 5 +- 10 files changed, 73 insertions(+), 130 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index 0a98c5c67ff9..4737b77476e1 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -43,17 +43,16 @@ * Return value: * 1 if the insertion succeeds, 0 if the queue was full. */ -unsigned char -visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, - void *pSignal) +unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, + void *sig) { void __iomem *psignal; unsigned int head, tail, nof; struct signal_queue_header __iomem *pqhdr = (struct signal_queue_header __iomem *) - ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) - + Queue; + ((char __iomem *) ch + readq(&ch->ch_space_offset)) + + queue; /* capture current head and tail */ head = readl(&pqhdr->head); @@ -74,7 +73,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, */ psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + (head * readl(&pqhdr->signal_size)); - memcpy_toio(psignal, pSignal, readl(&pqhdr->signal_size)); + memcpy_toio(psignal, sig, readl(&pqhdr->signal_size)); mb(); /* channel synch */ writel(head, &pqhdr->head); @@ -82,7 +81,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent); return 1; } -EXPORT_SYMBOL_GPL(visor_signal_insert); +EXPORT_SYMBOL_GPL(spar_signal_insert); /* * Routine Description: diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index 23d5aafef2cd..fae9ab3d0f60 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -49,7 +49,7 @@ SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue, unsigned long flags; spin_lock_irqsave(lock, flags); - result = visor_signal_insert(pChannel, Queue, pSignal); + result = spar_signal_insert(pChannel, Queue, pSignal); spin_unlock_irqrestore(lock, flags); return result; } diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index c01c2e69379d..16dd7a339433 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -289,89 +289,65 @@ struct signal_queue_header { * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. */ static inline int -ULTRA_check_channel_client(void __iomem *pChannel, - uuid_le expectedTypeGuid, - char *channelName, - u64 expectedMinBytes, - u32 expectedVersionId, - u64 expectedSignature, - char *fileName, int lineNumber, void *logCtx) +spar_check_channel_client(void __iomem *ch, + uuid_le expected_uuid, + char *chname, + u64 expected_min_bytes, + u32 expected_version, + u64 expected_signature) { - if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) { + if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) { uuid_le guid; memcpy_fromio(&guid, - &((struct channel_header __iomem *)(pChannel))->chtype, - sizeof(guid)); + &((struct channel_header __iomem *)(ch))->chtype, + sizeof(guid)); /* caller wants us to verify type GUID */ - if (uuid_le_cmp(guid, expectedTypeGuid) != 0) { + if (uuid_le_cmp(guid, expected_uuid) != 0) { pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n", - channelName, &expectedTypeGuid, - &expectedTypeGuid, &guid); + chname, &expected_uuid, + &expected_uuid, &guid); return 0; } } - if (expectedMinBytes > 0) { /* caller wants us to verify + if (expected_min_bytes > 0) { /* caller wants us to verify * channel size */ unsigned long long bytes = readq(&((struct channel_header __iomem *) - (pChannel))->size); - if (bytes < expectedMinBytes) { + (ch))->size); + if (bytes < expected_min_bytes) { pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n", - channelName, &expectedTypeGuid, - (unsigned long long)expectedMinBytes, bytes); + chname, &expected_uuid, + (unsigned long long)expected_min_bytes, bytes); return 0; } } - if (expectedVersionId > 0) { /* caller wants us to verify + if (expected_version > 0) { /* caller wants us to verify * channel version */ unsigned long ver = readl(&((struct channel_header __iomem *) - (pChannel))->version_id); - if (ver != expectedVersionId) { + (ch))->version_id); + if (ver != expected_version) { pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n", - channelName, &expectedTypeGuid, - (unsigned long)expectedVersionId, ver); + chname, &expected_uuid, + (unsigned long)expected_version, ver); return 0; } } - if (expectedSignature > 0) { /* caller wants us to verify + if (expected_signature > 0) { /* caller wants us to verify * channel signature */ unsigned long long sig = readq(&((struct channel_header __iomem *) - (pChannel))->signature); - if (sig != expectedSignature) { + (ch))->signature); + if (sig != expected_signature) { pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n", - channelName, &expectedTypeGuid, - expectedSignature, sig); + chname, &expected_uuid, + expected_signature, sig); return 0; } } return 1; } -/* Generic function useful for validating any type of channel when it is about - * to be initialized by the server of the channel. - * Note that is only needed for callers in the EFI environment, and - * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. - */ -static inline int -ULTRA_check_channel_server(uuid_le typeGuid, - char *channelName, - u64 expectedMinBytes, - u64 actualBytes, - char *fileName, int lineNumber, void *logCtx) -{ - if (expectedMinBytes > 0) /* caller wants us to verify - * channel size */ - if (actualBytes < expectedMinBytes) { - pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n", - channelName, &typeGuid, expectedMinBytes, - actualBytes); - return 0; - } - return 1; -} - /* Given a file pathname (with '/' or '\' separating directory nodes), * returns a pointer to the beginning of a node within that pathname such * that the number of nodes from that pointer to the end of the string is @@ -530,8 +506,8 @@ spar_channel_client_release_os(void __iomem *ch, u8 *id) * full. */ -unsigned char visor_signal_insert(struct channel_header __iomem *pChannel, - u32 Queue, void *pSignal); +unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, + void *sig); /* * Routine Description: diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 91e75f4d3e21..9a7531f66fdb 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid = * channel struct withOUT needing to increment this. */ #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1 -#define ULTRA_CONTROLVM_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, \ - UltraControlvmChannelProtocolGuid, \ - "controlvm", \ - sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE, \ - __FILE__, __LINE__, logCtx)) -#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraControlvmChannelProtocolGuid, \ - "controlvm", \ - sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ - actualBytes, __FILE__, __LINE__, logCtx)) +#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel) \ + (spar_check_channel_client(pChannel, \ + UltraControlvmChannelProtocolGuid, \ + "controlvm", \ + sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ + ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ + ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)) #define MY_DEVICE_INDEX 0 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 919f628360c2..97451bab64d2 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -59,13 +59,12 @@ static const uuid_le UltraDiagChannelProtocolGuid = #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, \ + (spar_check_channel_client(pChannel, \ UltraDiagChannelProtocolGuid, \ "diag", \ sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE, \ - __FILE__, __LINE__, logCtx)) + ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) #define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \ (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \ "diag", \ diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index d487cb2f06aa..f5fd542bb67f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -60,37 +60,22 @@ #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1 -#define ULTRA_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \ - "vhba", MIN_IO_CHANNEL_SIZE, \ - ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE, \ - __FILE__, __LINE__, logCtx)) -#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(spar_vhba_channel_protocol_uuid, \ - "vhba", MIN_IO_CHANNEL_SIZE, actualBytes, \ - __FILE__, __LINE__, logCtx)) -#define ULTRA_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ - "vnic", MIN_IO_CHANNEL_SIZE, \ - ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE, \ - __FILE__, __LINE__, logCtx)) -#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(spar_vnic_channel_protocol_uuid, \ - "vnic", MIN_IO_CHANNEL_SIZE, actualBytes, \ - __FILE__, __LINE__, logCtx)) -#define ULTRA_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \ - "vswitch", MIN_IO_CHANNEL_SIZE, \ - ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE, \ - __FILE__, __LINE__, logCtx)) -#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraVswitchChannelProtocolGuid, \ - "vswitch", MIN_IO_CHANNEL_SIZE, \ - actualBytes, \ - __FILE__, __LINE__, logCtx)) +#define SPAR_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \ + (spar_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \ + "vhba", MIN_IO_CHANNEL_SIZE, \ + ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ + ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE)) +#define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ + (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ + "vnic", MIN_IO_CHANNEL_SIZE, \ + ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ + ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) +#define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ + (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \ + "vswitch", MIN_IO_CHANNEL_SIZE, \ + ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \ + ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE)) + /* * Everything necessary to handle SCSI & NIC traffic between Guest Partition and * IO Partition is defined below. */ diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 76bc7140d5e7..7b32aa9fb90b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -43,22 +43,13 @@ static const uuid_le UltraVbusChannelProtocolGuid = * increment this. */ #define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1 -#define ULTRA_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (ULTRA_check_channel_client(pChannel, \ - UltraVbusChannelProtocolGuid, \ - "vbus", \ - sizeof(struct ultra_vbus_channel_protocol),\ +#define SPAR_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \ + (spar_check_channel_client(pChannel, \ + UltraVbusChannelProtocolGuid, \ + "vbus", \ + sizeof(struct ultra_vbus_channel_protocol),\ ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE, \ - __FILE__, __LINE__, logCtx)) - -#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraVbusChannelProtocolGuid, \ - "vbus", \ - sizeof(struct ultra_vbus_channel_protocol),\ - actualBytes, \ - __FILE__, __LINE__, logCtx)) - + ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \ #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ typedef struct _ULTRA_VBUS_HEADERINFO { diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 687b7db94fe5..bcb80ba40160 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes) rc = NULL; goto Away; } - if (!ULTRA_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) { + if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) { ERRDRV("%s channel cannot be used", __func__); uislib_iounmap(pChan); rc = NULL; @@ -449,7 +449,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) __iomem *) (dev-> chanptr))-> chtype); - if (!ULTRA_VHBA_CHANNEL_OK_CLIENT + if (!SPAR_VHBA_CHANNEL_OK_CLIENT (dev->chanptr, NULL)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.", devNo); @@ -475,7 +475,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) __iomem *) (dev-> chanptr))-> chtype); - if (!ULTRA_VNIC_CHANNEL_OK_CLIENT + if (!SPAR_VNIC_CHANNEL_OK_CLIENT (dev->chanptr, NULL)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.", devNo); diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index b9694a6d40c1..66da828ca352 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -83,7 +83,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, spin_lock_irqsave(lock, flags); if (!spar_channel_client_acquire_os(queueinfo->chan, channelId)) goto unlock; - if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) { + if (spar_signal_insert(queueinfo->chan, whichqueue, pSignal)) { queueinfo->packets_sent++; rc = 1; } diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e26db99c4d58..c94d65518f46 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2382,9 +2382,8 @@ visorchipset_init(void) (addr, sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), UltraControlvmChannelProtocolGuid); - if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT - (visorchannel_get_header(ControlVm_channel), - NULL)) { + if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( + visorchannel_get_header(ControlVm_channel))) { LOGINF("Channel %s (ControlVm) discovered", visorchannel_id(ControlVm_channel, s)); initialize_controlvm_payload(); -- cgit v1.2.3-59-g8ed1b From 3f12c5f95955ee979f55e599a586e065e710e80e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:06 -0400 Subject: staging: unisys: refactor visor_signal_remove() Rename visor_signal_remove() to spar_signal_remove() and fix CamelCase parameter names: pChannel => ch Queue => queue pSignal => sig Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 11 +++++------ drivers/staging/unisys/channels/chanstub.c | 2 +- drivers/staging/unisys/common-spar/include/channels/channel.h | 4 ++-- drivers/staging/unisys/uislib/uisqueue.c | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index 4737b77476e1..0b9a7cf35698 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -102,14 +102,13 @@ EXPORT_SYMBOL_GPL(spar_signal_insert); * 1 if the removal succeeds, 0 if the queue was empty. */ unsigned char -visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, - void *pSignal) +spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig) { void __iomem *psource; unsigned int head, tail; struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *) ((char __iomem *) pChannel + - readq(&pChannel->ch_space_offset)) + Queue; + (struct signal_queue_header __iomem *) ((char __iomem *) ch + + readq(&ch->ch_space_offset)) + queue; /* capture current head and tail */ head = readl(&pqhdr->head); @@ -127,7 +126,7 @@ visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, /* copy signal from tail location to the area pointed to by pSignal */ psource = (char __iomem *) pqhdr + readq(&pqhdr->sig_base_offset) + (tail * readl(&pqhdr->signal_size)); - memcpy_fromio(pSignal, psource, readl(&pqhdr->signal_size)); + memcpy_fromio(sig, psource, readl(&pqhdr->signal_size)); mb(); /* channel synch */ writel(tail, &pqhdr->tail); @@ -136,7 +135,7 @@ visor_signal_remove(struct channel_header __iomem *pChannel, u32 Queue, &pqhdr->num_received); return 1; } -EXPORT_SYMBOL_GPL(visor_signal_remove); +EXPORT_SYMBOL_GPL(spar_signal_remove); /* * Routine Description: diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index fae9ab3d0f60..b6fd126f16f1 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -61,7 +61,7 @@ SignalRemove_withLock(struct channel_header __iomem *pChannel, u32 Queue, unsigned char result; spin_lock(lock); - result = visor_signal_remove(pChannel, Queue, pSignal); + result = spar_signal_remove(pChannel, Queue, pSignal); spin_unlock(lock); return result; } diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 16dd7a339433..15c9cebcb8ec 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -528,8 +528,8 @@ unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, * empty. */ -unsigned char visor_signal_remove(struct channel_header __iomem *pChannel, - u32 Queue, void *pSignal); +unsigned char spar_signal_remove(struct channel_header __iomem *ch, u32 queue, + void *sig); /* * Routine Description: diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index 66da828ca352..f9f8442d58c5 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -125,7 +125,7 @@ int uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp, unsigned int whichqueue) { - if (!visor_signal_remove(queueinfo->chan, whichqueue, cmdrsp)) + if (!spar_signal_remove(queueinfo->chan, whichqueue, cmdrsp)) return 0; queueinfo->packets_received++; -- cgit v1.2.3-59-g8ed1b From a17f5b4af76e0a341685ca7f0327b5277ca1ec05 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:07 -0400 Subject: staging: unisys: refactor visor_signalqueue_empty() Rename visor_signalqueue_empty() to spar_signalqueue_empty(), and fix CamelCase parameter names: pChannel => ch Queue => queue Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 10 +++++----- drivers/staging/unisys/common-spar/include/channels/channel.h | 4 ++-- drivers/staging/unisys/virthba/virthba.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index 0b9a7cf35698..b1e2f9568540 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -207,13 +207,13 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) * Return value: * 1 if the signal queue is empty, 0 otherwise. */ -unsigned char -visor_signalqueue_empty(struct channel_header __iomem *pChannel, u32 Queue) +unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch, + u32 queue) { struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *) ((char __iomem *) pChannel + - readq(&pChannel->ch_space_offset)) + Queue; + (struct signal_queue_header __iomem *) ((char __iomem *) ch + + readq(&ch->ch_space_offset)) + queue; return readl(&pqhdr->head) == readl(&pqhdr->tail); } -EXPORT_SYMBOL_GPL(visor_signalqueue_empty); +EXPORT_SYMBOL_GPL(spar_signalqueue_empty); diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 15c9cebcb8ec..d982afada147 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -564,7 +564,7 @@ unsigned int SignalRemoveAll(struct channel_header *pChannel, u32 Queue, * Return value: * 1 if the signal queue is empty, 0 otherwise. */ -unsigned char visor_signalqueue_empty(struct channel_header __iomem *pChannel, - u32 Queue); +unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch, + u32 queue); #endif diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index a3da5e999331..4015933d78b0 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -438,7 +438,7 @@ virthba_ISR(int irq, void *dev_id) mask = ~ULTRA_CHANNEL_ENABLE_INTS; rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask); } - if (visor_signalqueue_empty(pChannelHeader, IOCHAN_FROM_IOPART)) { + if (spar_signalqueue_empty(pChannelHeader, IOCHAN_FROM_IOPART)) { virthbainfo->interrupts_notme++; return IRQ_NONE; } -- cgit v1.2.3-59-g8ed1b From bac9e37d744f28ce4885e3fb1555f5e789317816 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:08 -0400 Subject: staging: unisys: fix symbol placement in spar_channel_client_acquire The && belongs at the end of the previous line, not the start of the next one. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index d982afada147..90677a8852dd 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -398,8 +398,8 @@ spar_channel_client_acquire_os(void __iomem *ch, u8 *id) } return 0; } - if ((readl(&hdr->cli_state_os) != CHANNELCLI_OWNED) - && (readl(&hdr->cli_state_boot) == CHANNELCLI_DISABLED)) { + if ((readl(&hdr->cli_state_os) != CHANNELCLI_OWNED) && + (readl(&hdr->cli_state_boot) == CHANNELCLI_DISABLED)) { /* Our competitor is DISABLED, so we can transition to OWNED */ pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d)\n", id, "cli_state_os", -- cgit v1.2.3-59-g8ed1b From 29fe22b319599c7107e6a5bfdee79fa4a12cd89f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:09 -0400 Subject: staging: unisys: refactor SignalInit Macro Rename SignalInit to spar_signal_init, and fix CamelCase names: VersionId => version Type => chtype Size => size SignalSize => signal_size oSignalBase => sig_base_offset MaxSignalSlots => max_slots MaxSignals => max_signals Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 90677a8852dd..4d9e5d457e93 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -269,18 +269,18 @@ struct signal_queue_header { #pragma pack(pop) -#define SignalInit(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ) \ +#define spar_signal_init(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ) \ do { \ memset(&chan->QHDRFLD, 0, sizeof(chan->QHDRFLD)); \ - chan->QHDRFLD.VersionId = ver; \ - chan->QHDRFLD.Type = typ; \ - chan->QHDRFLD.Size = sizeof(chan->QDATAFLD); \ - chan->QHDRFLD.SignalSize = sizeof(QDATATYPE); \ - chan->QHDRFLD.oSignalBase = (u64)(chan->QDATAFLD)- \ + chan->QHDRFLD.version = ver; \ + chan->QHDRFLD.chtype = typ; \ + chan->QHDRFLD.size = sizeof(chan->QDATAFLD); \ + chan->QHDRFLD.signal_size = sizeof(QDATATYPE); \ + chan->QHDRFLD.sig_base_offset = (u64)(chan->QDATAFLD)- \ (u64)(&chan->QHDRFLD); \ - chan->QHDRFLD.MaxSignalSlots = \ + chan->QHDRFLD.max_slots = \ sizeof(chan->QDATAFLD)/sizeof(QDATATYPE); \ - chan->QHDRFLD.MaxSignals = chan->QHDRFLD.MaxSignalSlots-1; \ + chan->QHDRFLD.max_signals = chan->QHDRFLD.max_slots-1; \ } while (0) /* Generic function useful for validating any type of channel when it is -- cgit v1.2.3-59-g8ed1b From c11cf5fd0fb2fb12976be62ae13f0d86b6907509 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:10 -0400 Subject: staging: unisys: refactor SignalRemoveAll() Rename SignalRemoveAll to spar_signal_remove_all(), and fix CamelCase names: pChannel => ch Queue => queue pSignal => sig signalCount => count Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 16 ++++++++-------- .../unisys/common-spar/include/channels/channel.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index b1e2f9568540..2fc61a74ee54 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -156,14 +156,14 @@ EXPORT_SYMBOL_GPL(spar_signal_remove); * Return value: * # of signals copied. */ -unsigned int -SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) +unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, + void *sig) { void *psource; - unsigned int head, tail, signalCount = 0; + unsigned int head, tail, count = 0; struct signal_queue_header *pqhdr = - (struct signal_queue_header *) ((char *) pChannel + - pChannel->ch_space_offset) + Queue; + (struct signal_queue_header *) ((char *) ch + + ch->ch_space_offset) + queue; /* capture current head and tail */ head = pqhdr->head; @@ -183,17 +183,17 @@ SignalRemoveAll(struct channel_header *pChannel, u32 Queue, void *pSignal) psource = (char *) pqhdr + pqhdr->sig_base_offset + (tail * pqhdr->signal_size); - memcpy((char *) pSignal + (pqhdr->signal_size * signalCount), + memcpy((char *) sig + (pqhdr->signal_size * count), psource, pqhdr->signal_size); mb(); /* channel synch */ pqhdr->tail = tail; - signalCount++; + count++; pqhdr->num_received++; } - return signalCount; + return count; } /* diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 4d9e5d457e93..865d9a4883a3 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -550,8 +550,8 @@ unsigned char spar_signal_remove(struct channel_header __iomem *ch, u32 queue, * Return value: * # of signals copied. */ -unsigned int SignalRemoveAll(struct channel_header *pChannel, u32 Queue, - void *pSignal); +unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, + void *sig); /* * Routine Description: -- cgit v1.2.3-59-g8ed1b From 10c5ef69482d77f80678c2aa102b38cc09b241b5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:11 -0400 Subject: staging: unisys: refactor ULTRA_check_channel_server() Rename spar_check_channel_server() to spar_check_channel_server(), remove unused parameters fileName, lineNumber, and logCtx, update references to the function and remove unused parameters in macros that call it, and fix CamelCase names: typeGuid => typeuuid channelName => name expectedMinBytes => expected_min_bytes actualBytes => actual_bytes Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 20 ++++++++++++++++++++ .../common-spar/include/channels/controlvmchannel.h | 5 +++++ .../common-spar/include/channels/diagchannel.h | 10 +++++----- .../unisys/common-spar/include/channels/iochannel.h | 11 ++++++++++- .../common-spar/include/channels/vbuschannel.h | 6 ++++++ 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 865d9a4883a3..6fb6e5b3ddaf 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -348,6 +348,26 @@ spar_check_channel_client(void __iomem *ch, return 1; } +/* Generic function useful for validating any type of channel when it is about + * to be initialized by the server of the channel. + * Note that is only needed for callers in the EFI environment, and + * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. + */ +static inline int spar_check_channel_server(uuid_le typeuuid, char *name, + u64 expected_min_bytes, + u64 actual_bytes) +{ + if (expected_min_bytes > 0) /* caller wants us to verify + * channel size */ + if (actual_bytes < expected_min_bytes) { + pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n", + name, &typeuuid, expected_min_bytes, + actual_bytes); + return 0; + } + return 1; +} + /* Given a file pathname (with '/' or '\' separating directory nodes), * returns a pointer to the beginning of a node within that pathname such * that the number of nodes from that pointer to the end of the string is diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 9a7531f66fdb..ce601aecee65 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -52,6 +52,11 @@ static const uuid_le UltraControlvmChannelProtocolGuid = sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)) +#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraControlvmChannelProtocolGuid, \ + "controlvm", \ + sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ + actualBytes)) #define MY_DEVICE_INDEX 0 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 97451bab64d2..4132642aa05b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -65,11 +65,11 @@ static const uuid_le UltraDiagChannelProtocolGuid = sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \ - (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \ - "diag", \ - sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ - actualBytes, __FILE__, __LINE__, logCtx)) +#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraDiagChannelProtocolGuid, \ + "diag", \ + sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ + actualBytes)) #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ #define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info * accompanying event... */ diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index f5fd542bb67f..b1f4a47b3d62 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -65,17 +65,26 @@ "vhba", MIN_IO_CHANNEL_SIZE, \ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE)) +#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(spar_vhba_channel_protocol_uuid, \ + "vhba", MIN_IO_CHANNEL_SIZE, actualBytes)) #define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, \ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) +#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(spar_vnic_channel_protocol_uuid, \ + "vnic", MIN_IO_CHANNEL_SIZE, actualBytes)) #define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \ "vswitch", MIN_IO_CHANNEL_SIZE, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE)) - +#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraVswitchChannelProtocolGuid, \ + "vswitch", MIN_IO_CHANNEL_SIZE, \ + actualBytes)) /* * Everything necessary to handle SCSI & NIC traffic between Guest Partition and * IO Partition is defined below. */ diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 7b32aa9fb90b..9329e2838fde 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -51,6 +51,12 @@ static const uuid_le UltraVbusChannelProtocolGuid = ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \ +#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes) \ + (spar_check_channel_server(UltraVbusChannelProtocolGuid, \ + "vbus", \ + sizeof(struct ultra_vbus_channel_protocol),\ + actualBytes)) + #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ typedef struct _ULTRA_VBUS_HEADERINFO { u32 structBytes; /* size of this struct in bytes */ -- cgit v1.2.3-59-g8ed1b From 3f833b54f1bea153bbbeaf485d11789f42f6e9a3 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:12 -0400 Subject: staging: unisys: refactor ultra_segment_state Rename the struct to spar_segment_state and fix CamelCase names: Enabled => enabled Active => active Alive => alive Revoked => revoked Allocated => allocated Known => known Ready => ready Operating => operating Fix all references to modified names to use the new names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlframework.h | 27 +++++++------- .../include/channels/controlvmchannel.h | 6 ++-- .../unisys/visorchipset/visorchipset_main.c | 42 +++++++++++----------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index e718557f1c20..9f01f402e4ca 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -36,31 +36,34 @@ /* Define Ki scale page to be traditional 4KB page */ #define ULTRA_MEMORY_PAGE_Ki (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_Ki) -struct ultra_segment_state { - u16 Enabled:1; /* Bit 0: May enter other states */ - u16 Active:1; /* Bit 1: Assigned to active partition */ - u16 Alive:1; /* Bit 2: Configure message sent to +struct spar_segment_state { + u16 enabled:1; /* Bit 0: May enter other states */ + u16 active:1; /* Bit 1: Assigned to active partition */ + u16 alive:1; /* Bit 2: Configure message sent to * service/server */ - u16 Revoked:1; /* Bit 3: similar to partition state + u16 revoked:1; /* Bit 3: similar to partition state * ShuttingDown */ - u16 Allocated:1; /* Bit 4: memory (device/port number) + u16 allocated:1; /* Bit 4: memory (device/port number) * has been selected by Command */ - u16 Known:1; /* Bit 5: has been introduced to the + u16 known:1; /* Bit 5: has been introduced to the * service/guest partition */ - u16 Ready:1; /* Bit 6: service/Guest partition has + u16 ready:1; /* Bit 6: service/Guest partition has * responded to introduction */ - u16 Operating:1; /* Bit 7: resource is configured and + u16 operating:1; /* Bit 7: resource is configured and * operating */ /* Note: don't use high bit unless we need to switch to ushort * which is non-compliant */ }; -static const struct ultra_segment_state SegmentStateRunning = { + +static const struct spar_segment_state SegmentStateRunning = { 1, 1, 1, 0, 1, 1, 1, 1 }; -static const struct ultra_segment_state SegmentStatePaused = { + +static const struct spar_segment_state SegmentStatePaused = { 1, 1, 1, 0, 1, 1, 1, 0 }; -static const struct ultra_segment_state SegmentStateStandby = { + +static const struct spar_segment_state SegmentStateStandby = { 1, 1, 0, 0, 1, 1, 1, 0 }; diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index ce601aecee65..e638f8a3a205 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -389,13 +389,13 @@ typedef struct _CONTROLVM_MESSAGE_PACKET { } reconfigureDevice; /* for CONTROLVM_DEVICE_RECONFIGURE */ struct { u32 busNo; - struct ultra_segment_state state; + struct spar_segment_state state; u8 reserved[2]; /* Natural alignment purposes */ } busChangeState; /* for CONTROLVM_BUS_CHANGESTATE */ struct { u32 busNo; u32 devNo; - struct ultra_segment_state state; + struct spar_segment_state state; struct { u32 physicalDevice:1; /* =1 if message is for * a physical device */ @@ -406,7 +406,7 @@ typedef struct _CONTROLVM_MESSAGE_PACKET { struct { u32 busNo; u32 devNo; - struct ultra_segment_state state; + struct spar_segment_state state; u8 reserved[6]; /* Natural alignment purposes */ } deviceChangeStateEvent; /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */ struct { diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index c94d65518f46..4f27392f35f3 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -348,9 +348,8 @@ static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response); static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, ULTRA_CHIPSET_FEATURE features); -static void controlvm_respond_physdev_changestate( - CONTROLVM_MESSAGE_HEADER *msgHdr, int response, - struct ultra_segment_state state); +static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER * + msgHdr, int response, struct spar_segment_state state); static ssize_t toolaction_show(struct device *dev, struct device_attribute *attr, @@ -743,8 +742,7 @@ controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr, - int response, struct ultra_segment_state - state) + int response, struct spar_segment_state state) { CONTROLVM_MESSAGE outmsg; @@ -860,7 +858,7 @@ bus_responder(enum control_vm_id cmdId, ulong busNo, int response) static void device_changestate_responder(enum control_vm_id cmdId, ulong busNo, ulong devNo, int response, - struct ultra_segment_state responseState) + struct spar_segment_state responseState) { VISORCHIPSET_DEVICE_INFO *p = NULL; CONTROLVM_MESSAGE outmsg; @@ -994,7 +992,7 @@ bus_epilog(u32 busNo, } static void -device_epilog(u32 busNo, u32 devNo, struct ultra_segment_state state, u32 cmd, +device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, CONTROLVM_MESSAGE_HEADER *msgHdr, int response, BOOL needResponse, BOOL for_visorbus) { @@ -1033,8 +1031,8 @@ device_epilog(u32 busNo, u32 devNo, struct ultra_segment_state state, u32 cmd, break; case CONTROLVM_DEVICE_CHANGESTATE: /* ServerReady / ServerRunning / SegmentStateRunning */ - if (state.Alive == SegmentStateRunning.Alive && - state.Operating == SegmentStateRunning.Operating) { + if (state.alive == SegmentStateRunning.alive && + state.operating == SegmentStateRunning.operating) { if (notifiers->device_resume) { (*notifiers->device_resume) (busNo, devNo); @@ -1042,9 +1040,9 @@ device_epilog(u32 busNo, u32 devNo, struct ultra_segment_state state, u32 cmd, } } /* ServerNotReady / ServerLost / SegmentStateStandby */ - else if (state.Alive == SegmentStateStandby.Alive && - state.Operating == - SegmentStateStandby.Operating) { + else if (state.alive == SegmentStateStandby.alive && + state.operating == + SegmentStateStandby.operating) { /* technically this is standby case * where server is lost */ @@ -1053,9 +1051,9 @@ device_epilog(u32 busNo, u32 devNo, struct ultra_segment_state state, u32 cmd, devNo); notified = TRUE; } - } else if (state.Alive == SegmentStatePaused.Alive && - state.Operating == - SegmentStatePaused.Operating) { + } else if (state.alive == SegmentStatePaused.alive && + state.operating == + SegmentStatePaused.operating) { /* this is lite pause where channel is * still valid just 'pause' of it */ @@ -1306,7 +1304,7 @@ my_device_changestate(CONTROLVM_MESSAGE *inmsg) CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; ulong busNo = cmd->deviceChangeState.busNo; ulong devNo = cmd->deviceChangeState.devNo; - struct ultra_segment_state state = cmd->deviceChangeState.state; + struct spar_segment_state state = cmd->deviceChangeState.state; VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1631,7 +1629,7 @@ parahotplug_request_kickoff(struct parahotplug_request *req) sprintf(env_cmd, "SPAR_PARAHOTPLUG=1"); sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id); sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d", - cmd->deviceChangeState.state.Active); + cmd->deviceChangeState.state.active); sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d", cmd->deviceChangeState.busNo); sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d", @@ -1640,7 +1638,7 @@ parahotplug_request_kickoff(struct parahotplug_request *req) cmd->deviceChangeState.devNo & 0x7); LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n", - cmd->deviceChangeState.state.Active, + cmd->deviceChangeState.state.active, cmd->deviceChangeState.busNo, cmd->deviceChangeState.devNo >> 3, cmd->deviceChangeState.devNo & 7, req->id); @@ -1700,7 +1698,7 @@ parahotplug_request_complete(int id, u16 active) */ list_del(pos); spin_unlock(&Parahotplug_request_list_lock); - req->msg.cmd.deviceChangeState.state.Active = active; + req->msg.cmd.deviceChangeState.state.active = active; if (req->msg.hdr.Flags.responseExpected) controlvm_respond_physdev_changestate( &req->msg.hdr, CONTROLVM_RESP_SUCCESS, @@ -1729,7 +1727,7 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) return; } - if (inmsg->cmd.deviceChangeState.state.Active) { + if (inmsg->cmd.deviceChangeState.state.active) { /* For enable messages, just respond with success * right away. This is a bit of a hack, but there are * issues with the early enable messages we get (with @@ -1853,13 +1851,13 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)", (ulong) cmd->deviceChangeState.busNo, (ulong) cmd->deviceChangeState.devNo, - (ulong) cmd->deviceChangeState.state.Active); + (ulong) cmd->deviceChangeState.state.active); parahotplug_process_message(&inmsg); } else { LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)", (ulong) cmd->deviceChangeState.busNo, (ulong) cmd->deviceChangeState.devNo, - (ulong) cmd->deviceChangeState.state.Alive); + (ulong) cmd->deviceChangeState.state.alive); /* save the hdr and cmd structures for later use */ /* when sending back the response to Command */ my_device_changestate(&inmsg); -- cgit v1.2.3-59-g8ed1b From bd0d2dcc03db2bffcd4bd292fadc9234006edbfb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:13 -0400 Subject: staging: unisys: fix CamelCase constant names in controlframework.h Fix CamelCase names: SegmentStateRunning => segment_state_running SegmentStatePaused => segment_state_paused SegmentStateStandby => segment_state_standby Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/controlframework.h | 6 +++--- drivers/staging/unisys/uislib/uislib.c | 8 ++++---- .../staging/unisys/visorchipset/visorchipset_main.c | 21 +++++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index 9f01f402e4ca..80e2df139ea3 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -55,15 +55,15 @@ struct spar_segment_state { * which is non-compliant */ }; -static const struct spar_segment_state SegmentStateRunning = { +static const struct spar_segment_state segment_state_running = { 1, 1, 1, 0, 1, 1, 1, 1 }; -static const struct spar_segment_state SegmentStatePaused = { +static const struct spar_segment_state segment_state_paused = { 1, 1, 1, 0, 1, 1, 1, 0 }; -static const struct spar_segment_state SegmentStateStandby = { +static const struct spar_segment_state segment_state_standby = { 1, 1, 0, 0, 1, 1, 1, 0 }; diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index bcb80ba40160..a0b1e042b43d 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -891,7 +891,7 @@ uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no) init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); msg.cmd.deviceChangeState.busNo = bus_no; msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = SegmentStateStandby; + msg.cmd.deviceChangeState.state = segment_state_standby; rc = pause_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA pause_device failed. busNo=0x%x devNo=0x%x\n", @@ -911,7 +911,7 @@ uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no) init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); msg.cmd.deviceChangeState.busNo = bus_no; msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = SegmentStateRunning; + msg.cmd.deviceChangeState.state = segment_state_running; rc = resume_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA resume_device failed. busNo=0x%x devNo=0x%x\n", @@ -1044,7 +1044,7 @@ uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no) init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); msg.cmd.deviceChangeState.busNo = bus_no; msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = SegmentStateStandby; + msg.cmd.deviceChangeState.state = segment_state_standby; rc = pause_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC pause_device failed. busNo=0x%x devNo=0x%x\n", @@ -1064,7 +1064,7 @@ uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); msg.cmd.deviceChangeState.busNo = bus_no; msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = SegmentStateRunning; + msg.cmd.deviceChangeState.state = segment_state_running; rc = resume_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC resume_device failed. busNo=0x%x devNo=0x%x\n", diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 4f27392f35f3..f0a4dfa8e31b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1031,8 +1031,9 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, break; case CONTROLVM_DEVICE_CHANGESTATE: /* ServerReady / ServerRunning / SegmentStateRunning */ - if (state.alive == SegmentStateRunning.alive && - state.operating == SegmentStateRunning.operating) { + if (state.alive == segment_state_running.alive && + state.operating == + segment_state_running.operating) { if (notifiers->device_resume) { (*notifiers->device_resume) (busNo, devNo); @@ -1040,9 +1041,9 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, } } /* ServerNotReady / ServerLost / SegmentStateStandby */ - else if (state.alive == SegmentStateStandby.alive && + else if (state.alive == segment_state_standby.alive && state.operating == - SegmentStateStandby.operating) { + segment_state_standby.operating) { /* technically this is standby case * where server is lost */ @@ -1051,9 +1052,9 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, devNo); notified = TRUE; } - } else if (state.alive == SegmentStatePaused.alive && + } else if (state.alive == segment_state_paused.alive && state.operating == - SegmentStatePaused.operating) { + segment_state_paused.operating) { /* this is lite pause where channel is * still valid just 'pause' of it */ @@ -1292,7 +1293,7 @@ Away: LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", g_diagpoolBusNo, g_diagpoolDevNo); } - device_epilog(busNo, devNo, SegmentStateRunning, + device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.Flags.responseExpected == 1, FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); @@ -1356,7 +1357,7 @@ my_device_destroy(CONTROLVM_MESSAGE *inmsg) Away: if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) - device_epilog(busNo, devNo, SegmentStateRunning, + device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, inmsg->hdr.Flags.responseExpected == 1, FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); @@ -2174,7 +2175,7 @@ visorchipset_device_pause_response(ulong busNo, ulong devNo, int response) device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, busNo, devNo, response, - SegmentStateStandby); + segment_state_standby); } EXPORT_SYMBOL_GPL(visorchipset_device_pause_response); @@ -2183,7 +2184,7 @@ device_resume_response(ulong busNo, ulong devNo, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, busNo, devNo, response, - SegmentStateRunning); + segment_state_running); } BOOL -- cgit v1.2.3-59-g8ed1b From 5fbaa4b3a6fa7db8c62b7bd32a078d0dce00536a Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:14 -0400 Subject: staging: unisys: refactor UltraControlvmChannelProtocolGuid rename UltraControlvmChannelProtocolGuid to spar_controlvm_channel_protocol_uuid, and change ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID to SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID to match. Update references to the old name. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 10 +++++----- drivers/staging/unisys/visorchipset/visorchipset_main.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index e638f8a3a205..be94db678671 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -27,12 +27,12 @@ enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE, }; /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ -#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID \ +#define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \ 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d) -static const uuid_le UltraControlvmChannelProtocolGuid = - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID; +static const uuid_le spar_controlvm_channel_protocol_uuid = + SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID; #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \ ULTRA_CHANNEL_PROTOCOL_SIGNATURE @@ -47,13 +47,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid = #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel) \ (spar_check_channel_client(pChannel, \ - UltraControlvmChannelProtocolGuid, \ + spar_controlvm_channel_protocol_uuid, \ "controlvm", \ sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)) #define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(UltraControlvmChannelProtocolGuid, \ + (spar_check_channel_server(spar_controlvm_channel_protocol_uuid,\ "controlvm", \ sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ actualBytes)) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index f0a4dfa8e31b..e84c154a6a6d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2380,7 +2380,7 @@ visorchipset_init(void) visorchannel_create_with_lock (addr, sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), - UltraControlvmChannelProtocolGuid); + spar_controlvm_channel_protocol_uuid); if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( visorchannel_get_header(ControlVm_channel))) { LOGINF("Channel %s (ControlVm) discovered", -- cgit v1.2.3-59-g8ed1b From 7caac2fa2c72f76eeef01685dc505cee15fd3e71 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:15 -0400 Subject: staging: unisys: remove ULTRA_CONTROLVM_CHANNEL_OK_SERVER macro Nobody is using this macro, so remove it entirely. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/controlvmchannel.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index be94db678671..6b3cedf930d6 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -52,11 +52,6 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(spar_controlvm_channel_protocol_uuid,\ - "controlvm", \ - sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ - actualBytes)) #define MY_DEVICE_INDEX 0 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ -- cgit v1.2.3-59-g8ed1b From 600832fd3dffe2ddaa431cd84cd3b34a7e449285 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:16 -0400 Subject: staging: unisys: fix CamelCase in SPAR_CONTROLVM_CHANNEL_OK_CLIENT Fix CamelCase parameter name: pChannel => ch Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 6b3cedf930d6..c168e148a0c1 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -45,13 +45,13 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = * channel struct withOUT needing to increment this. */ #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1 -#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel) \ - (spar_check_channel_client(pChannel, \ - spar_controlvm_channel_protocol_uuid, \ - "controlvm", \ - sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)) +#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \ + spar_check_channel_client(ch, \ + spar_controlvm_channel_protocol_uuid, \ + "controlvm", \ + sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ + ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ + ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE) #define MY_DEVICE_INDEX 0 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ -- cgit v1.2.3-59-g8ed1b From 53bebb13a2ee242d33aaa3299d079e8d666a5773 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:17 -0400 Subject: staging: unisys: remove typedef CONTROLVM_ID Replace the typedef for CONTROLVM_ID with enum controlvm_id, and update all references to the old typedef. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/controlvmchannel.h | 2 +- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index c168e148a0c1..20e464eb4dde 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -82,7 +82,7 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = * - issued on the EventQueue queue (q #2) in the ControlVm channel * - responded to on the EventAckQueue queue (q #3) in the ControlVm channel */ -enum control_vm_id { +enum controlvm_id { CONTROLVM_INVALID = 0, /* SWITCH commands required Parameter: SwitchNumber */ /* BUS commands required Parameter: BusNumber */ diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index f8ffa0263e29..35794eff475f 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -155,7 +155,7 @@ u64 uislib_storage_channel(int client_id); #endif int uislib_get_owned_pdest(struct uisscsi_dest *pdest); -int uislib_send_event(enum control_vm_id id, CONTROLVM_MESSAGE_PACKET *event); +int uislib_send_event(enum controlvm_id id, CONTROLVM_MESSAGE_PACKET *event); /* structure used by vhba & vnic to keep track of queue & thread info */ struct chaninfo { diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e84c154a6a6d..ed26c29ec4b0 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -817,7 +817,7 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type) EXPORT_SYMBOL_GPL(visorchipset_save_message); static void -bus_responder(enum control_vm_id cmdId, ulong busNo, int response) +bus_responder(enum controlvm_id cmdId, ulong busNo, int response) { VISORCHIPSET_BUS_INFO *p = NULL; BOOL need_clear = FALSE; @@ -856,7 +856,7 @@ bus_responder(enum control_vm_id cmdId, ulong busNo, int response) } static void -device_changestate_responder(enum control_vm_id cmdId, +device_changestate_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, int response, struct spar_segment_state responseState) { @@ -893,7 +893,8 @@ device_changestate_responder(enum control_vm_id cmdId, } static void -device_responder(enum control_vm_id cmdId, ulong busNo, ulong devNo, int response) +device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, + int response) { VISORCHIPSET_DEVICE_INFO *p = NULL; BOOL need_clear = FALSE; -- cgit v1.2.3-59-g8ed1b From af3286bdb4037e62552c3f887e628505a63ba409 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:18 -0400 Subject: staging: unisys: fix CamelCase names in struct irq_info Fix CamelCase names in structure, and references to them: sendInterruptHandle => send_irq_handle recvInterruptHandle => recv_irq_handle recvInterruptVector => recv_irq_vector recvInterruptShared => recv_irq_shared Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 8 ++++---- drivers/staging/unisys/virthba/virthba.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 20e464eb4dde..ce628c11fd15 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -122,23 +122,23 @@ struct irq_info { * interrupt. Currently this is used by IOPart-SP to wake * up GP when Data Channel transitions from empty to * non-empty.*/ - u64 sendInterruptHandle; + u64 send_irq_handle; /**< specifies interrupt handle. It is used to retrieve the * corresponding interrupt pin from Monitor; and the * interrupt pin is used to connect to the corresponding * intrrupt. Used by IOPart-GP only. */ - u64 recvInterruptHandle; + u64 recv_irq_handle; /**< specifies interrupt vector. It, interrupt pin, and shared are * used to connect to the corresponding interrupt. Used by * IOPart-GP only. */ - u32 recvInterruptVector; + u32 recv_irq_vector; /**< specifies if the recvInterrupt is shared. It, interrupt pin * and vector are used to connect to 0 = not shared; 1 = shared. * the corresponding interrupt. Used by IOPart-GP only. */ - u8 recvInterruptShared; + u8 recv_irq_shared; u8 reserved[3]; /* Natural alignment purposes */ }; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 4015933d78b0..3a037f41ee40 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -603,16 +603,16 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) return -ENODEV; } LOGINF("sendInterruptHandle=0x%16llX", - virthbainfo->intr.sendInterruptHandle); + virthbainfo->intr.send_irq_handle); LOGINF("recvInterruptHandle=0x%16llX", - virthbainfo->intr.recvInterruptHandle); + virthbainfo->intr.recv_irq_handle); LOGINF("recvInterruptVector=0x%8X", - virthbainfo->intr.recvInterruptVector); + virthbainfo->intr.recv_irq_vector); LOGINF("recvInterruptShared=0x%2X", - virthbainfo->intr.recvInterruptShared); + virthbainfo->intr.recv_irq_shared); LOGINF("scsihost.hostt->name=%s", scsihost->hostt->name); virthbainfo->interrupt_vector = - virthbainfo->intr.recvInterruptHandle & INTERRUPT_VECTOR_MASK; + virthbainfo->intr.recv_irq_handle & INTERRUPT_VECTOR_MASK; rsp = request_irq(virthbainfo->interrupt_vector, handler, IRQF_SHARED, scsihost->hostt->name, virthbainfo); if (rsp != 0) { -- cgit v1.2.3-59-g8ed1b From 6822f736c6f02adbb9e121134e24490276bdfbfc Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:19 -0400 Subject: staging: unisys: fix CamelCase names in struct pci_id Fix CamelCase names: Domain => domain Bus => bus Slot => slot Func => func Reserved => reserved Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index ce628c11fd15..ac653330c0bc 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -143,11 +143,11 @@ struct irq_info { }; struct pci_id { - u16 Domain; - u8 Bus; - u8 Slot; - u8 Func; - u8 Reserved[3]; /* Natural alignment purposes */ + u16 domain; + u8 bus; + u8 slot; + u8 func; + u8 reserved[3]; /* Natural alignment purposes */ }; struct PciConfigHdr { -- cgit v1.2.3-59-g8ed1b From 18787366b1a2fcfddc01efabbdcf5d8727c144c0 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:20 -0400 Subject: staging: unisys: remove unused code from controlvmchannel.h Delete struct PciConfigHdr, struct ScsiId, struct WWID, struct VirtDiskInfo, enum CONTROLVM_ACTION, and enum ULTRA_TOOL_ACTIONS. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 63 ---------------------- 1 file changed, 63 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index ac653330c0bc..68cf118171d3 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -150,69 +150,6 @@ struct pci_id { u8 reserved[3]; /* Natural alignment purposes */ }; -struct PciConfigHdr { - u16 VendorId; - u16 SubSysVendor; - u16 DeviceId; - u16 SubSysDevice; - u32 ClassCode; - u32 Reserved; /* Natural alignment purposes */ -}; - -struct ScsiId { - u32 Bus; - u32 Target; - u32 Lun; - u32 Host; /* Command should ignore this for * - * DiskArrival/RemovalEvents */ -}; - -struct WWID { - u32 wwid1; - u32 wwid2; -}; - -struct virtDiskInfo { - u32 switchNo; /* defined by SWITCH_CREATE */ - u32 externalPortNo; /* 0 for SAS RAID provided (external) - * virtual disks, 1 for virtual disk - * images, 2 for gold disk images */ - u16 VirtualDiskIndex; /* Index of disk descriptor in the - * VirtualDisk segment associated with - * externalPortNo */ - u16 Reserved1; - u32 Reserved2; -}; - -typedef enum { - CONTROLVM_ACTION_NONE = 0, - CONTROLVM_ACTION_SET_RESTORE = 0x05E7, - CONTROLVM_ACTION_CLEAR_RESTORE = 0x0C18, - CONTROLVM_ACTION_RESTORING = 0x08E5, - CONTROLVM_ACTION_RESTORE_BUSY = 0x0999, - CONTROLVM_ACTION_CLEAR_NVRAM = 0xB01 -} CONTROLVM_ACTION; - -typedef enum _ULTRA_TOOL_ACTIONS { - /* enumeration that defines intended action */ - ULTRA_TOOL_ACTION_NONE = 0, /* normal boot of boot disk */ - ULTRA_TOOL_ACTION_INSTALL = 1, /* install source disk(s) to boot - * disk */ - ULTRA_TOOL_ACTION_CAPTURE = 2, /* capture boot disk to target disk(s) - * as 'gold image' */ - ULTRA_TOOL_ACTION_REPAIR = 3, /* use source disk(s) to repair - * installation on boot disk */ - ULTRA_TOOL_ACTION_CLEAN = 4, /* 'scrub' virtual disk before - * releasing back to storage pool */ - ULTRA_TOOL_ACTION_UPGRADE = 5, /* upgrade to use content of images - * referenced from newer blueprint */ - ULTRA_TOOL_ACTION_DIAG = 6, /* use tool to invoke diagnostic script - * provided by blueprint */ - ULTRA_TOOL_ACTION_FAILED = 7, /* used when tool fails installation - and cannot continue */ - ULTRA_TOOL_ACTION_COUNT = 8 -} ULTRA_TOOL_ACTIONS; - typedef struct _ULTRA_EFI_SPAR_INDICATION { u64 BootToFirmwareUI:1; /* Bit 0: Stop in uefi ui */ u64 ClearNvram:1; /* Bit 1: Clear NVRAM */ -- cgit v1.2.3-59-g8ed1b From 755e2ecc7d753ffe34703c0408e3923f2a58fd96 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:21 -0400 Subject: staging: unisys: replace typedef ULTRA_EFI_SPAR_INDICATION Replace ULTRA_EFI_SPAR_INDICATION with struct efi_spar_indication, and update references to the old type. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 8 ++++---- drivers/staging/unisys/visorchipset/visorchipset_main.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 68cf118171d3..0bf45960dce1 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -150,13 +150,13 @@ struct pci_id { u8 reserved[3]; /* Natural alignment purposes */ }; -typedef struct _ULTRA_EFI_SPAR_INDICATION { +struct efi_spar_indication { u64 BootToFirmwareUI:1; /* Bit 0: Stop in uefi ui */ u64 ClearNvram:1; /* Bit 1: Clear NVRAM */ u64 ClearCmos:1; /* Bit 2: Clear CMOS */ u64 BootToTool:1; /* Bit 3: Run install tool */ /* remaining bits are available */ -} ULTRA_EFI_SPAR_INDICATION; +}; typedef enum { ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001, @@ -468,8 +468,8 @@ typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { u8 ToolAction; /* ULTRA_TOOL_ACTIONS Installation Action * field */ u8 Reserved; /* alignment */ - ULTRA_EFI_SPAR_INDICATION EfiSparIndication; - ULTRA_EFI_SPAR_INDICATION EfiSparIndicationSupported; + struct efi_spar_indication EfiSparIndication; + struct efi_spar_indication EfiSparIndicationSupported; u32 SPReserved; u8 Reserved2[28]; /* Force signals to begin on 128-byte cache * line */ diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index ed26c29ec4b0..27bfa6e42e4e 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -386,12 +386,12 @@ static ssize_t boottotool_show(struct device *dev, struct device_attribute *attr, char *buf) { - ULTRA_EFI_SPAR_INDICATION efiSparIndication; + struct efi_spar_indication efiSparIndication; visorchannel_read(ControlVm_channel, offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication), &efiSparIndication, - sizeof(ULTRA_EFI_SPAR_INDICATION)); + sizeof(struct efi_spar_indication)); return scnprintf(buf, PAGE_SIZE, "%u\n", efiSparIndication.BootToTool); } @@ -401,7 +401,7 @@ static ssize_t boottotool_store(struct device *dev, const char *buf, size_t count) { int val, ret; - ULTRA_EFI_SPAR_INDICATION efiSparIndication; + struct efi_spar_indication efiSparIndication; if (kstrtoint(buf, 10, &val) != 0) return -EINVAL; @@ -411,7 +411,7 @@ static ssize_t boottotool_store(struct device *dev, offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication), &(efiSparIndication), - sizeof(ULTRA_EFI_SPAR_INDICATION)); + sizeof(struct efi_spar_indication)); if (ret) return ret; -- cgit v1.2.3-59-g8ed1b From 2450301a676fcfa57543e3ff30d6da7f032c8f58 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:22 -0400 Subject: staging: unisys: fix CamelCase names in struct efi_spar_indication Fix CamelCase names and update all references to them: BootToFirmwareUI => boot_to_fw_ui ClearNvram => clear_nvram ClearCmos => clear_cmos BootToTool => boot_to_tool Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 8 ++++---- drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 0bf45960dce1..d59dd3545128 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -151,10 +151,10 @@ struct pci_id { }; struct efi_spar_indication { - u64 BootToFirmwareUI:1; /* Bit 0: Stop in uefi ui */ - u64 ClearNvram:1; /* Bit 1: Clear NVRAM */ - u64 ClearCmos:1; /* Bit 2: Clear CMOS */ - u64 BootToTool:1; /* Bit 3: Run install tool */ + u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */ + u64 clear_nvram:1; /* Bit 1: Clear NVRAM */ + u64 clear_cmos:1; /* Bit 2: Clear CMOS */ + u64 boot_to_tool:1; /* Bit 3: Run install tool */ /* remaining bits are available */ }; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 27bfa6e42e4e..9269e46a2e7e 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -393,7 +393,7 @@ static ssize_t boottotool_show(struct device *dev, EfiSparIndication), &efiSparIndication, sizeof(struct efi_spar_indication)); return scnprintf(buf, PAGE_SIZE, "%u\n", - efiSparIndication.BootToTool); + efiSparIndication.boot_to_tool); } static ssize_t boottotool_store(struct device *dev, @@ -406,7 +406,7 @@ static ssize_t boottotool_store(struct device *dev, if (kstrtoint(buf, 10, &val) != 0) return -EINVAL; - efiSparIndication.BootToTool = val; + efiSparIndication.boot_to_tool = val; ret = visorchannel_write(ControlVm_channel, offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication), -- cgit v1.2.3-59-g8ed1b From 75185f57f110a7c48d9d33a585320c93334adf0c Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:23 -0400 Subject: staging: unisys: fix CamelCase macro names in controlframework.h Fix CamelCase names: ULTRA_MEMORY_COUNT_Ki => ULTRA_MEMORY_COUNT_KI ULTRA_MEMORY_PAGE_Ki => ULTRA_MEMORY_PAGE_KI Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .gitignore | 4 ++++ .../staging/unisys/common-spar/include/channels/controlframework.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e213b27f3921..6bfac06d79ca 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,7 @@ x509.genkey # Kconfig presets all.config + +#eclipse files +.project +.cproject diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index 80e2df139ea3..7f1adf64b173 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -28,14 +28,14 @@ #include #include "channel.h" -#define ULTRA_MEMORY_COUNT_Ki 1024 +#define ULTRA_MEMORY_COUNT_KI 1024 /* Scale order 0 is one 32-bit (4-byte) word (in 64 or 128-bit * architecture potentially 64 or 128-bit word) */ #define ULTRA_MEMORY_PAGE_WORD 4 /* Define Ki scale page to be traditional 4KB page */ -#define ULTRA_MEMORY_PAGE_Ki (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_Ki) +#define ULTRA_MEMORY_PAGE_KI (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_KI) struct spar_segment_state { u16 enabled:1; /* Bit 0: May enter other states */ u16 active:1; /* Bit 1: Assigned to active partition */ -- cgit v1.2.3-59-g8ed1b From b9b141e8535f157758ed1f457eb639703a7f2326 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:24 -0400 Subject: staging: unisys: refactor ULTRA_CHIPSET_FEATURE enum Get rid of the typedef and use enum ultra_chipset_feature instead, and update all references to the enumeration. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/controlvmchannel.h | 6 +++--- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index d59dd3545128..20c1506e7e96 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -158,11 +158,11 @@ struct efi_spar_indication { /* remaining bits are available */ }; -typedef enum { +enum ultra_chipset_feature { ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001, ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002, ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004 -} ULTRA_CHIPSET_FEATURE; +}; /** This is the common structure that is at the beginning of every * ControlVm message (both commands and responses) in any ControlVm @@ -346,7 +346,7 @@ typedef struct _CONTROLVM_MESSAGE_PACKET { u32 switchCount; /*< indicates the max number of * switches (applicable for service * partition only) */ - ULTRA_CHIPSET_FEATURE features; + enum ultra_chipset_feature features; u32 platformNumber; /* Platform Number */ } initChipset; /* for CONTROLVM_CHIPSET_INIT */ struct { diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 9269e46a2e7e..c8d8d258a7cd 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -347,7 +347,7 @@ static struct platform_device Visorchipset_platform_device = { static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response); static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, - ULTRA_CHIPSET_FEATURE features); + enum ultra_chipset_feature features); static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER * msgHdr, int response, struct spar_segment_state state); @@ -655,7 +655,7 @@ static void chipset_init(CONTROLVM_MESSAGE *inmsg) { static int chipset_inited; - ULTRA_CHIPSET_FEATURE features = 0; + enum ultra_chipset_feature features = 0; int rc = CONTROLVM_RESP_SUCCESS; POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); @@ -727,7 +727,7 @@ controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response) static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, - ULTRA_CHIPSET_FEATURE features) + enum ultra_chipset_feature features) { CONTROLVM_MESSAGE outmsg; -- cgit v1.2.3-59-g8ed1b From 2ea5117b5f09143f02a743e9784a6714dd800866 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:25 -0400 Subject: staging: unisys: refactor CONTROLVM_MESSAGE_PACKET This patch refactors the message union and internal structures so they will pass checkpatch.pl. The typedef is removed, and references are changed to struct controlvm_message_packet. The comments were reflowed and cleaned up to remove unnecessary information, and CamelCase member names were fixed here and in references: busNo => bus_no devNo => dev_no deviceCount => dev_count channelAddr => channel_addr channelBytes => channel_bytes busDataTypeGuid => bus_data_type_uuid busInstGuid => bus_inst_uuid destroyBus => destroy_bus guestHandle => guest_handle recvBusInterruptHandle => recv_bus_irq_handle configureBus => configure_bus createDevuce => create_device destroyDevice => destroy_device configureDevice => configure_device reconfigureDevice => reconfigure_device busChangeState => bus_change_state physicalDevice => phys_device busCount => bus_count switchCount => switch_count platformNumber => platformNumber initChipset => init_chipset Options => options Test => test chipsetSelftest => chipset_selftest Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 165 ++++++++------------- drivers/staging/unisys/include/uisutils.h | 3 +- drivers/staging/unisys/uislib/uislib.c | 164 ++++++++++---------- .../unisys/visorchipset/visorchipset_main.c | 154 +++++++++---------- 4 files changed, 226 insertions(+), 260 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 20c1506e7e96..6d68b2cfc4fd 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -251,135 +251,100 @@ typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE { } CONTROLVM_MESSAGE_DEVICE_CONFIGURE; /* total 56 bytes */ /* This is the format for a message in any ControlVm queue. */ -typedef struct _CONTROLVM_MESSAGE_PACKET { +struct controlvm_message_packet { union { - - /* BEGIN Request messages */ struct { - u32 busNo; /*< bus # (0..n-1) from the msg - * receiver's perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ - u32 deviceCount; /*< indicates the max number of - * devices on this bus */ - u64 channelAddr; /*< Guest physical address of the - * channel, which can be - * dereferenced by the receiver - * of this ControlVm command */ - u64 channelBytes; /*< size of the channel in bytes */ - uuid_le busDataTypeGuid;/*< indicates format of data in - bus channel */ - uuid_le busInstGuid; /*< instance guid for the bus */ - } createBus; /* for CONTROLVM_BUS_CREATE */ + u32 bus_no; /* bus # (0..n-1) from the msg + * receiver's perspective */ + u32 dev_count; /* indicates the max number of + * devices on this bus */ + u64 channel_addr; /* Guest physical address of + * the channel, which can be + * dereferenced by the receiver + * of this ControlVm command */ + u64 channel_bytes; /* size of the channel */ + uuid_le bus_data_type_uuid; /* indicates format of + * data in bus channel*/ + uuid_le bus_inst_uuid; /* instance uuid for the bus */ + } create_bus; /* for CONTROLVM_BUS_CREATE */ struct { - u32 busNo; /*< bus # (0..n-1) from the msg - * receiver's perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ + u32 bus_no; /* bus # (0..n-1) from the msg + * receiver's perspective */ u32 reserved; /* Natural alignment purposes */ - } destroyBus; /* for CONTROLVM_BUS_DESTROY */ + } destroy_bus; /* for CONTROLVM_BUS_DESTROY */ struct { - u32 busNo; /*< bus # (0..n-1) from the - * msg receiver's - * perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ - u32 reserved1; /* for alignment purposes */ - u64 guestHandle; /* This is used to convert - * guest physical address to real - * physical address for DMA, for ex. */ - u64 recvBusInterruptHandle;/*< specifies interrupt - * info. It is used by SP to register - * to receive interrupts from the CP. - * This interrupt is used for bus - * level notifications. The - * corresponding - * sendBusInterruptHandle is kept in - * CP. */ - } configureBus; /* for CONTROLVM_BUS_CONFIGURE */ - + u32 bus_no; /* bus # (0..n-1) from the receiver's + * perspective */ + u32 reserved1; /* for alignment purposes */ + u64 guest_handle; /* This is used to convert + * guest physical address to + * physical address */ + u64 recv_bus_irq_handle; + /* specifies interrupt info. It is used by SP + * to register to receive interrupts from the + * CP. This interrupt is used for bus level + * notifications. The corresponding + * sendBusInterruptHandle is kept in CP. */ + } configure_bus; /* for CONTROLVM_BUS_CONFIGURE */ /* for CONTROLVM_DEVICE_CREATE */ - CONTROLVM_PACKET_DEVICE_CREATE createDevice; + CONTROLVM_PACKET_DEVICE_CREATE create_device; struct { - u32 busNo; /*< bus # (0..n-1) from the msg - * receiver's perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ - u32 devNo; /*< bus-relative (0..n-1) device - * number */ - } destroyDevice; /* for CONTROLVM_DEVICE_DESTROY */ - + u32 bus_no; /* bus # (0..n-1) from the msg + * receiver's perspective */ + u32 dev_no; /* bus-relative (0..n-1) device # */ + } destroy_device; /* for CONTROLVM_DEVICE_DESTROY */ /* for CONTROLVM_DEVICE_CONFIGURE */ - CONTROLVM_PACKET_DEVICE_CONFIGURE configureDevice; + CONTROLVM_PACKET_DEVICE_CONFIGURE configure_device; struct { - u32 busNo; /*< bus # (0..n-1) from the msg - * receiver's perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ - u32 devNo; /*< bus-relative (0..n-1) device - * number */ - } reconfigureDevice; /* for CONTROLVM_DEVICE_RECONFIGURE */ + u32 bus_no; /* bus # (0..n-1) from the msg + * receiver's perspective */ + u32 dev_no; /* bus-relative (0..n-1) device # */ + } reconfigure_device; /* for CONTROLVM_DEVICE_RECONFIGURE */ struct { - u32 busNo; + u32 bus_no; struct spar_segment_state state; u8 reserved[2]; /* Natural alignment purposes */ - } busChangeState; /* for CONTROLVM_BUS_CHANGESTATE */ + } bus_change_state; /* for CONTROLVM_BUS_CHANGESTATE */ struct { - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; struct spar_segment_state state; struct { - u32 physicalDevice:1; /* =1 if message is for + u32 phys_device:1; /* =1 if message is for * a physical device */ - /* remaining bits in this 32-bit word are available */ } flags; u8 reserved[2]; /* Natural alignment purposes */ - } deviceChangeState; /* for CONTROLVM_DEVICE_CHANGESTATE */ + } device_change_state; /* for CONTROLVM_DEVICE_CHANGESTATE */ struct { - u32 busNo; - u32 devNo; + u32 bus_no; + u32 dev_no; struct spar_segment_state state; u8 reserved[6]; /* Natural alignment purposes */ - } deviceChangeStateEvent; /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */ + } device_change_state_event; + /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */ struct { - u32 busCount; /*< indicates the max number of busses */ - u32 switchCount; /*< indicates the max number of - * switches (applicable for service - * partition only) */ + u32 bus_count; /* indicates the max number of busses */ + u32 switch_count; /* indicates the max number of + * switches if a service partition */ enum ultra_chipset_feature features; - u32 platformNumber; /* Platform Number */ - } initChipset; /* for CONTROLVM_CHIPSET_INIT */ + u32 platform_number; /* Platform Number */ + } init_chipset; /* for CONTROLVM_CHIPSET_INIT */ struct { - u32 Options; /*< reserved */ - u32 Test; /*< bit 0 set to run embedded selftest */ - } chipsetSelftest; /* for CONTROLVM_CHIPSET_SELFTEST */ - - /* END Request messages */ - - /* BEGIN Response messages */ - - /* END Response messages */ - - /* BEGIN Event messages */ - - /* END Event messages */ - - /* BEGIN Ack messages */ - - /* END Ack messages */ - u64 addr; /*< a physical address of something, that - * can be dereferenced by the receiver of - * this ControlVm command (depends on - * command id) */ - u64 handle; /*< a handle of something (depends on - * command id) */ + u32 options; /* reserved */ + u32 test; /* bit 0 set to run embedded selftest */ + } chipset_selftest; /* for CONTROLVM_CHIPSET_SELFTEST */ + u64 addr; /* a physical address of something, that can be + * dereferenced by the receiver of this + * ControlVm command (depends on command id) */ + u64 handle; /* a handle of something (depends on command + * id) */ }; -} CONTROLVM_MESSAGE_PACKET; +}; /* All messages in any ControlVm queue have this layout. */ typedef struct _CONTROLVM_MESSAGE { CONTROLVM_MESSAGE_HEADER hdr; - CONTROLVM_MESSAGE_PACKET cmd; + struct controlvm_message_packet cmd; } CONTROLVM_MESSAGE; typedef struct _DEVICE_MAP { diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 35794eff475f..20758ae2bf26 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -155,7 +155,8 @@ u64 uislib_storage_channel(int client_id); #endif int uislib_get_owned_pdest(struct uisscsi_dest *pdest); -int uislib_send_event(enum controlvm_id id, CONTROLVM_MESSAGE_PACKET *event); +int uislib_send_event(enum controlvm_id id, + struct controlvm_message_packet *event); /* structure used by vhba & vnic to keep track of queue & thread info */ struct chaninfo { diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index a0b1e042b43d..87c62df526f6 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -168,8 +168,8 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) return CONTROLVM_RESP_ERROR_MAX_BUSES; } - busNo = msg->cmd.createBus.busNo; - deviceCount = msg->cmd.createBus.deviceCount; + busNo = msg->cmd.create_bus.bus_no; + deviceCount = msg->cmd.create_bus.dev_count; POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC, busNo, deviceCount, POSTCODE_SEVERITY_INFO); @@ -199,7 +199,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) bus->device_count = deviceCount; bus->device = (struct device_info **) ((char *) bus + sizeof(struct bus_info)); - bus->bus_inst_uuid = msg->cmd.createBus.busInstGuid; + bus->bus_inst_uuid = msg->cmd.create_bus.bus_inst_uuid; bus->bus_channel_bytes = 0; bus->bus_channel = NULL; @@ -221,12 +221,12 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) kfree(bus); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } - if ((msg->cmd.createBus.channelAddr != 0) - && (msg->cmd.createBus.channelBytes != 0)) { - bus->bus_channel_bytes = msg->cmd.createBus.channelBytes; + if ((msg->cmd.create_bus.channel_addr != 0) + && (msg->cmd.create_bus.channel_bytes != 0)) { + bus->bus_channel_bytes = msg->cmd.create_bus.channel_bytes; bus->bus_channel = - init_vbus_channel(msg->cmd.createBus.channelAddr, - msg->cmd.createBus.channelBytes); + init_vbus_channel(msg->cmd.create_bus.channel_addr, + msg->cmd.create_bus.channel_bytes); } /* the msg is bound for virtpci; send guest_msgs struct to callback */ if (!msg->hdr.Flags.server) { @@ -236,8 +236,8 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) cmd.add_vbus.bus_no = busNo; cmd.add_vbus.chanptr = bus->bus_channel; cmd.add_vbus.dev_count = deviceCount; - cmd.add_vbus.bus_uuid = msg->cmd.createBus.busDataTypeGuid; - cmd.add_vbus.instance_uuid = msg->cmd.createBus.busInstGuid; + cmd.add_vbus.bus_uuid = msg->cmd.create_bus.bus_data_type_uuid; + cmd.add_vbus.instance_uuid = msg->cmd.create_bus.bus_inst_uuid; if (!virt_control_chan_func) { LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered."); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no, @@ -279,7 +279,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) struct guest_msgs cmd; u32 busNo; - busNo = msg->cmd.destroyBus.busNo; + busNo = msg->cmd.destroy_bus.bus_no; read_lock(&BusListLock); @@ -354,8 +354,8 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) u64 minSize = MIN_IO_CHANNEL_SIZE; struct req_handler_info *pReqHandler; - busNo = msg->cmd.createDevice.busNo; - devNo = msg->cmd.createDevice.devNo; + busNo = msg->cmd.create_device.busNo; + devNo = msg->cmd.create_device.devNo; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); @@ -368,9 +368,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; } - dev->channel_uuid = msg->cmd.createDevice.dataTypeGuid; - dev->intr = msg->cmd.createDevice.intr; - dev->channel_addr = msg->cmd.createDevice.channelAddr; + dev->channel_uuid = msg->cmd.create_device.dataTypeGuid; + dev->intr = msg->cmd.create_device.intr; + dev->channel_addr = msg->cmd.create_device.channelAddr; dev->bus_no = busNo; dev->dev_no = devNo; sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */ @@ -385,9 +385,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) * channel */ minSize = pReqHandler->min_channel_bytes; - if (minSize > msg->cmd.createDevice.channelBytes) { + if (minSize > msg->cmd.create_device.channelBytes) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: channel size is too small, channel size:0x%lx, required size:0x%lx", - (ulong) msg->cmd.createDevice.channelBytes, + (ulong) msg->cmd.create_device.channelBytes, (ulong) minSize); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); @@ -396,19 +396,19 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) } dev->chanptr = uislib_ioremap_cache(dev->channel_addr, - msg->cmd.createDevice.channelBytes); + msg->cmd.create_device.channelBytes); if (!dev->chanptr) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", dev->channel_addr, - msg->cmd.createDevice.channelBytes); + msg->cmd.create_device.channelBytes); result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED; POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); goto Away; } } - dev->instance_uuid = msg->cmd.createDevice.devInstGuid; - dev->channel_bytes = msg->cmd.createDevice.channelBytes; + dev->instance_uuid = msg->cmd.create_device.devInstGuid; + dev->channel_bytes = msg->cmd.create_device.channelBytes; read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { @@ -552,8 +552,8 @@ pause_device(CONTROLVM_MESSAGE *msg) struct guest_msgs cmd; int retval = CONTROLVM_RESP_SUCCESS; - busNo = msg->cmd.deviceChangeState.busNo; - devNo = msg->cmd.deviceChangeState.devNo; + busNo = msg->cmd.device_change_state.bus_no; + devNo = msg->cmd.device_change_state.dev_no; read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { @@ -620,8 +620,8 @@ resume_device(CONTROLVM_MESSAGE *msg) struct guest_msgs cmd; int retval = CONTROLVM_RESP_SUCCESS; - busNo = msg->cmd.deviceChangeState.busNo; - devNo = msg->cmd.deviceChangeState.devNo; + busNo = msg->cmd.device_change_state.bus_no; + devNo = msg->cmd.device_change_state.dev_no; read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { @@ -689,8 +689,8 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) struct guest_msgs cmd; int retval = CONTROLVM_RESP_SUCCESS; - busNo = msg->cmd.destroyDevice.busNo; - devNo = msg->cmd.destroyDevice.devNo; + busNo = msg->cmd.destroy_device.bus_no; + devNo = msg->cmd.destroy_device.bus_no; read_lock(&BusListLock); LOGINF("destroy_device called for busNo=%u, devNo=%u", busNo, devNo); @@ -773,8 +773,8 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf) { POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); - MaxBusCount = msg->cmd.initChipset.busCount; - PlatformNumber = msg->cmd.initChipset.platformNumber; + MaxBusCount = msg->cmd.init_chipset.bus_count; + PlatformNumber = msg->cmd.init_chipset.platform_number; PhysicalDataChan = 0; /* We need to make sure we have our functions registered @@ -799,7 +799,7 @@ delete_bus_glue(u32 busNo) CONTROLVM_MESSAGE msg; init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.cmd.destroyBus.busNo = busNo; + msg.cmd.destroy_bus.bus_no = busNo; if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("destroy_bus failed. busNo=0x%x\n", busNo); return 0; @@ -813,8 +813,8 @@ delete_device_glue(u32 busNo, u32 devNo) CONTROLVM_MESSAGE msg; init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); - msg.cmd.destroyDevice.busNo = busNo; - msg.cmd.destroyDevice.devNo = devNo; + msg.cmd.destroy_device.bus_no = busNo; + msg.cmd.destroy_device.dev_no = devNo; if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("destroy_device failed. busNo=0x%x devNo=0x%x\n", busNo, devNo); @@ -843,8 +843,8 @@ uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, * after number 4, then the add_vnic will fail, and the * ultraboot will fail. */ - msg.cmd.initChipset.busCount = 23; - msg.cmd.initChipset.switchCount = 0; + msg.cmd.init_chipset.bus_count = 23; + msg.cmd.init_chipset.switch_count = 0; if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("init_chipset failed.\n"); return 0; @@ -858,10 +858,10 @@ uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_WARNING); init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); - msg.cmd.createBus.busNo = bus_no; - msg.cmd.createBus.deviceCount = 23; /* devNo+1; */ - msg.cmd.createBus.channelAddr = channel_addr; - msg.cmd.createBus.channelBytes = n_channel_bytes; + msg.cmd.create_bus.bus_no = bus_no; + msg.cmd.create_bus.dev_count = 23; /* devNo+1; */ + msg.cmd.create_bus.channel_addr = channel_addr; + msg.cmd.create_bus.channel_bytes = n_channel_bytes; if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("create_bus failed.\n"); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, @@ -889,9 +889,9 @@ uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no) int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = bus_no; - msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = segment_state_standby; + msg.cmd.device_change_state.bus_no = bus_no; + msg.cmd.device_change_state.dev_no = dev_no; + msg.cmd.device_change_state.state = segment_state_standby; rc = pause_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA pause_device failed. busNo=0x%x devNo=0x%x\n", @@ -909,9 +909,9 @@ uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no) int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = bus_no; - msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = segment_state_running; + msg.cmd.device_change_state.bus_no = bus_no; + msg.cmd.device_change_state.dev_no = dev_no; + msg.cmd.device_change_state.state = segment_state_running; rc = resume_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA resume_device failed. busNo=0x%x devNo=0x%x\n", @@ -945,15 +945,15 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, * need to be ioremap()ed */ msg.hdr.Flags.testMessage = 1; - msg.cmd.createDevice.busNo = bus_no; - msg.cmd.createDevice.devNo = dev_no; - msg.cmd.createDevice.devInstGuid = inst_uuid; + msg.cmd.create_device.busNo = bus_no; + msg.cmd.create_device.devNo = dev_no; + msg.cmd.create_device.devInstGuid = inst_uuid; if (intr) - msg.cmd.createDevice.intr = *intr; + msg.cmd.create_device.intr = *intr; else - memset(&msg.cmd.createDevice.intr, 0, + memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); - msg.cmd.createDevice.channelAddr = phys_chan_addr; + msg.cmd.create_device.channelAddr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE); @@ -961,8 +961,8 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); return 0; } - msg.cmd.createDevice.channelBytes = chan_bytes; - msg.cmd.createDevice.dataTypeGuid = spar_vhba_channel_protocol_uuid; + msg.cmd.create_device.channelBytes = chan_bytes; + msg.cmd.create_device.dataTypeGuid = spar_vhba_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA create_device failed.\n"); POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1004,15 +1004,15 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, * need to be ioremap()ed */ msg.hdr.Flags.testMessage = 1; - msg.cmd.createDevice.busNo = bus_no; - msg.cmd.createDevice.devNo = dev_no; - msg.cmd.createDevice.devInstGuid = inst_uuid; + msg.cmd.create_device.busNo = bus_no; + msg.cmd.create_device.devNo = dev_no; + msg.cmd.create_device.devInstGuid = inst_uuid; if (intr) - msg.cmd.createDevice.intr = *intr; + msg.cmd.create_device.intr = *intr; else - memset(&msg.cmd.createDevice.intr, 0, + memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); - msg.cmd.createDevice.channelAddr = phys_chan_addr; + msg.cmd.create_device.channelAddr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE); @@ -1020,8 +1020,8 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); return 0; } - msg.cmd.createDevice.channelBytes = chan_bytes; - msg.cmd.createDevice.dataTypeGuid = spar_vnic_channel_protocol_uuid; + msg.cmd.create_device.channelBytes = chan_bytes; + msg.cmd.create_device.dataTypeGuid = spar_vnic_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC create_device failed.\n"); POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1042,9 +1042,9 @@ uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no) int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = bus_no; - msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = segment_state_standby; + msg.cmd.device_change_state.bus_no = bus_no; + msg.cmd.device_change_state.dev_no = dev_no; + msg.cmd.device_change_state.state = segment_state_standby; rc = pause_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC pause_device failed. busNo=0x%x devNo=0x%x\n", @@ -1062,9 +1062,9 @@ uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); - msg.cmd.deviceChangeState.busNo = bus_no; - msg.cmd.deviceChangeState.devNo = dev_no; - msg.cmd.deviceChangeState.state = segment_state_running; + msg.cmd.device_change_state.bus_no = bus_no; + msg.cmd.device_change_state.dev_no = dev_no; + msg.cmd.device_change_state.state = segment_state_running; rc = resume_device(&msg); if (rc != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC resume_device failed. busNo=0x%x devNo=0x%x\n", @@ -1093,10 +1093,10 @@ uislib_client_add_vnic(u32 busNo) init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); msg.hdr.Flags.testMessage = 1; - msg.cmd.createBus.busNo = busNo; - msg.cmd.createBus.deviceCount = 4; - msg.cmd.createBus.channelAddr = 0; - msg.cmd.createBus.channelBytes = 0; + msg.cmd.create_bus.bus_no = busNo; + msg.cmd.create_bus.dev_count = 4; + msg.cmd.create_bus.channel_addr = 0; + msg.cmd.create_bus.channel_bytes = 0; if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("client create_bus failed"); return 0; @@ -1105,13 +1105,13 @@ uislib_client_add_vnic(u32 busNo) init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); msg.hdr.Flags.testMessage = 1; - msg.cmd.createDevice.busNo = busNo; - msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.devInstGuid = NULL_UUID_LE; - memset(&msg.cmd.createDevice.intr, 0, sizeof(struct irq_info)); - msg.cmd.createDevice.channelAddr = PhysicalDataChan; - msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; - msg.cmd.createDevice.dataTypeGuid = spar_vnic_channel_protocol_uuid; + msg.cmd.create_device.busNo = busNo; + msg.cmd.create_device.devNo = devNo; + msg.cmd.create_device.devInstGuid = NULL_UUID_LE; + memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); + msg.cmd.create_device.channelAddr = PhysicalDataChan; + msg.cmd.create_device.channelBytes = MIN_IO_CHANNEL_SIZE; + msg.cmd.create_device.dataTypeGuid = spar_vnic_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("client create_device failed"); goto AwayCleanup; @@ -1123,7 +1123,7 @@ AwayCleanup: if (busCreated) { init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); msg.hdr.Flags.testMessage = 1; - msg.cmd.destroyBus.busNo = busNo; + msg.cmd.destroy_bus.bus_no = busNo; if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) LOGERR("client destroy_bus failed.\n"); } @@ -1141,8 +1141,8 @@ uislib_client_delete_vnic(u32 busNo) init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); msg.hdr.Flags.testMessage = 1; - msg.cmd.destroyDevice.busNo = busNo; - msg.cmd.destroyDevice.devNo = devNo; + msg.cmd.destroy_device.bus_no = busNo; + msg.cmd.destroy_device.dev_no = devNo; if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { /* Don't error exit - try to see if bus can be destroyed... */ LOGERR("client destroy_device failed.\n"); @@ -1150,7 +1150,7 @@ uislib_client_delete_vnic(u32 busNo) init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); msg.hdr.Flags.testMessage = 1; - msg.cmd.destroyBus.busNo = busNo; + msg.cmd.destroy_bus.bus_no = busNo; if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) LOGERR("client destroy_bus failed.\n"); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index c8d8d258a7cd..7af23386e6ae 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -84,7 +84,7 @@ static const uuid_le UltraDiagPoolChannelProtocolGuid = /* 0xffffff is an invalid Bus/Device number */ static ulong g_diagpoolBusNo = 0xffffff; static ulong g_diagpoolDevNo = 0xffffff; -static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket; +static struct controlvm_message_packet g_DeviceChangeStatePacket; /* Only VNIC and VHBA channels are sent to visorclientbus (aka * "visorhackbus") @@ -670,7 +670,7 @@ chipset_init(CONTROLVM_MESSAGE *inmsg) /* Set features to indicate we support parahotplug (if Command * also supports it). */ features = - inmsg->cmd.initChipset. + inmsg->cmd.init_chipset. features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG; /* Set the "reply" bit so Command knows this is a @@ -708,9 +708,9 @@ controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response) /* For DiagPool channel DEVICE_CHANGESTATE, we need to send * back the deviceChangeState structure in the packet. */ if (msgHdr->Id == CONTROLVM_DEVICE_CHANGESTATE - && g_DeviceChangeStatePacket.deviceChangeState.busNo == + && g_DeviceChangeStatePacket.device_change_state.bus_no == g_diagpoolBusNo - && g_DeviceChangeStatePacket.deviceChangeState.devNo == + && g_DeviceChangeStatePacket.device_change_state.dev_no == g_diagpoolDevNo) outmsg.cmd = g_DeviceChangeStatePacket; if (outmsg.hdr.Flags.testMessage == 1) { @@ -732,7 +732,7 @@ controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, CONTROLVM_MESSAGE outmsg; controlvm_init_response(&outmsg, msgHdr, response); - outmsg.cmd.initChipset.features = features; + outmsg.cmd.init_chipset.features = features; if (!visorchannel_signalinsert(ControlVm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) { LOGERR("signalinsert failed!"); @@ -747,8 +747,8 @@ controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr, CONTROLVM_MESSAGE outmsg; controlvm_init_response(&outmsg, msgHdr, response); - outmsg.cmd.deviceChangeState.state = state; - outmsg.cmd.deviceChangeState.flags.physicalDevice = 1; + outmsg.cmd.device_change_state.state = state; + outmsg.cmd.device_change_state.flags.phys_device = 1; if (!visorchannel_signalinsert(ControlVm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) { LOGERR("signalinsert failed!"); @@ -879,9 +879,9 @@ device_changestate_responder(enum controlvm_id cmdId, controlvm_init_response(&outmsg, &p->pendingMsgHdr, response); - outmsg.cmd.deviceChangeState.busNo = busNo; - outmsg.cmd.deviceChangeState.devNo = devNo; - outmsg.cmd.deviceChangeState.state = responseState; + outmsg.cmd.device_change_state.bus_no = busNo; + outmsg.cmd.device_change_state.dev_no = devNo; + outmsg.cmd.device_change_state.state = responseState; if (!visorchannel_signalinsert(ControlVm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg)) { @@ -1094,8 +1094,8 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, static void bus_create(CONTROLVM_MESSAGE *inmsg) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; - ulong busNo = cmd->createBus.busNo; + struct controlvm_message_packet *cmd = &inmsg->cmd; + ulong busNo = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; VISORCHIPSET_BUS_INFO *pBusInfo = NULL; @@ -1121,7 +1121,7 @@ bus_create(CONTROLVM_MESSAGE *inmsg) INIT_LIST_HEAD(&pBusInfo->entry); pBusInfo->busNo = busNo; - pBusInfo->devNo = cmd->createBus.deviceCount; + pBusInfo->devNo = cmd->create_bus.dev_count; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); @@ -1131,10 +1131,10 @@ bus_create(CONTROLVM_MESSAGE *inmsg) pBusInfo->chanInfo.addrType = ADDRTYPE_localPhysical; pBusInfo->flags.server = inmsg->hdr.Flags.server; - pBusInfo->chanInfo.channelAddr = cmd->createBus.channelAddr; - pBusInfo->chanInfo.nChannelBytes = cmd->createBus.channelBytes; - pBusInfo->chanInfo.channelTypeGuid = cmd->createBus.busDataTypeGuid; - pBusInfo->chanInfo.channelInstGuid = cmd->createBus.busInstGuid; + pBusInfo->chanInfo.channelAddr = cmd->create_bus.channel_addr; + pBusInfo->chanInfo.nChannelBytes = cmd->create_bus.channel_bytes; + pBusInfo->chanInfo.channelTypeGuid = cmd->create_bus.bus_data_type_uuid; + pBusInfo->chanInfo.channelInstGuid = cmd->create_bus.bus_inst_uuid; list_add(&pBusInfo->entry, &BusInfoList); @@ -1148,8 +1148,8 @@ Away: static void bus_destroy(CONTROLVM_MESSAGE *inmsg) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; - ulong busNo = cmd->destroyBus.busNo; + struct controlvm_message_packet *cmd = &inmsg->cmd; + ulong busNo = cmd->destroy_bus.bus_no; VISORCHIPSET_BUS_INFO *pBusInfo; int rc = CONTROLVM_RESP_SUCCESS; @@ -1174,13 +1174,13 @@ Away: static void bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; - ulong busNo = cmd->configureBus.busNo; + struct controlvm_message_packet *cmd = &inmsg->cmd; + ulong busNo = cmd->configure_bus.bus_no; VISORCHIPSET_BUS_INFO *pBusInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; char s[99]; - busNo = cmd->configureBus.busNo; + busNo = cmd->configure_bus.bus_no; POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); pBusInfo = findbus(&BusInfoList, busNo); @@ -1210,7 +1210,7 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) goto Away; } - pBusInfo->partitionHandle = cmd->configureBus.guestHandle; + pBusInfo->partitionHandle = cmd->configure_bus.guest_handle; pBusInfo->partitionGuid = parser_id_get(parser_ctx); parser_param_start(parser_ctx, PARSERSTRING_NAME); pBusInfo->name = parser_string_get(parser_ctx); @@ -1225,9 +1225,9 @@ Away: static void my_device_create(CONTROLVM_MESSAGE *inmsg) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; - ulong busNo = cmd->createDevice.busNo; - ulong devNo = cmd->createDevice.devNo; + struct controlvm_message_packet *cmd = &inmsg->cmd; + ulong busNo = cmd->create_device.busNo; + ulong devNo = cmd->create_device.devNo; VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; VISORCHIPSET_BUS_INFO *pBusInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1271,7 +1271,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) INIT_LIST_HEAD(&pDevInfo->entry); pDevInfo->busNo = busNo; pDevInfo->devNo = devNo; - pDevInfo->devInstGuid = cmd->createDevice.devInstGuid; + pDevInfo->devInstGuid = cmd->create_device.devInstGuid; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); @@ -1279,10 +1279,10 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) pDevInfo->chanInfo.addrType = ADDRTYPE_localTest; else pDevInfo->chanInfo.addrType = ADDRTYPE_localPhysical; - pDevInfo->chanInfo.channelAddr = cmd->createDevice.channelAddr; - pDevInfo->chanInfo.nChannelBytes = cmd->createDevice.channelBytes; - pDevInfo->chanInfo.channelTypeGuid = cmd->createDevice.dataTypeGuid; - pDevInfo->chanInfo.intr = cmd->createDevice.intr; + pDevInfo->chanInfo.channelAddr = cmd->create_device.channelAddr; + pDevInfo->chanInfo.nChannelBytes = cmd->create_device.channelBytes; + pDevInfo->chanInfo.channelTypeGuid = cmd->create_device.dataTypeGuid; + pDevInfo->chanInfo.intr = cmd->create_device.intr; list_add(&pDevInfo->entry, &DevInfoList); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); @@ -1303,10 +1303,10 @@ Away: static void my_device_changestate(CONTROLVM_MESSAGE *inmsg) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; - ulong busNo = cmd->deviceChangeState.busNo; - ulong devNo = cmd->deviceChangeState.devNo; - struct spar_segment_state state = cmd->deviceChangeState.state; + struct controlvm_message_packet *cmd = &inmsg->cmd; + ulong busNo = cmd->device_change_state.bus_no; + ulong devNo = cmd->device_change_state.dev_no; + struct spar_segment_state state = cmd->device_change_state.state; VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1337,9 +1337,9 @@ Away: static void my_device_destroy(CONTROLVM_MESSAGE *inmsg) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; - ulong busNo = cmd->destroyDevice.busNo; - ulong devNo = cmd->destroyDevice.devNo; + struct controlvm_message_packet *cmd = &inmsg->cmd; + ulong busNo = cmd->destroy_device.bus_no; + ulong devNo = cmd->destroy_device.dev_no; VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1621,7 +1621,7 @@ parahotplug_request_destroy(struct parahotplug_request *req) static void parahotplug_request_kickoff(struct parahotplug_request *req) { - CONTROLVM_MESSAGE_PACKET *cmd = &req->msg.cmd; + struct controlvm_message_packet *cmd = &req->msg.cmd; char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40], env_func[40]; char *envp[] = { @@ -1631,18 +1631,19 @@ parahotplug_request_kickoff(struct parahotplug_request *req) sprintf(env_cmd, "SPAR_PARAHOTPLUG=1"); sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id); sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d", - cmd->deviceChangeState.state.active); + cmd->device_change_state.state.active); sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d", - cmd->deviceChangeState.busNo); + cmd->device_change_state.bus_no); sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d", - cmd->deviceChangeState.devNo >> 3); + cmd->device_change_state.dev_no >> 3); sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d", - cmd->deviceChangeState.devNo & 0x7); + cmd->device_change_state.dev_no & 0x7); LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n", - cmd->deviceChangeState.state.active, - cmd->deviceChangeState.busNo, cmd->deviceChangeState.devNo >> 3, - cmd->deviceChangeState.devNo & 7, req->id); + cmd->device_change_state.state.active, + cmd->device_change_state.bus_no, + cmd->device_change_state.dev_no >> 3, + cmd->device_change_state.dev_no & 7, req->id); kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, envp); @@ -1669,7 +1670,7 @@ parahotplug_process_list(void) controlvm_respond_physdev_changestate( &req->msg.hdr, CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT, - req->msg.cmd.deviceChangeState.state); + req->msg.cmd.device_change_state.state); parahotplug_request_destroy(req); } } @@ -1700,11 +1701,11 @@ parahotplug_request_complete(int id, u16 active) */ list_del(pos); spin_unlock(&Parahotplug_request_list_lock); - req->msg.cmd.deviceChangeState.state.active = active; + req->msg.cmd.device_change_state.state.active = active; if (req->msg.hdr.Flags.responseExpected) controlvm_respond_physdev_changestate( &req->msg.hdr, CONTROLVM_RESP_SUCCESS, - req->msg.cmd.deviceChangeState.state); + req->msg.cmd.device_change_state.state); parahotplug_request_destroy(req); return 0; } @@ -1729,7 +1730,7 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) return; } - if (inmsg->cmd.deviceChangeState.state.active) { + if (inmsg->cmd.device_change_state.state.active) { /* For enable messages, just respond with success * right away. This is a bit of a hack, but there are * issues with the early enable messages we get (with @@ -1741,9 +1742,8 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) */ parahotplug_request_kickoff(req); controlvm_respond_physdev_changestate(&inmsg->hdr, - CONTROLVM_RESP_SUCCESS, - inmsg->cmd. - deviceChangeState.state); + CONTROLVM_RESP_SUCCESS, inmsg->cmd. + device_change_state.state); parahotplug_request_destroy(req); } else { /* For disable messages, add the request to the @@ -1773,7 +1773,7 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) static BOOL handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) { - CONTROLVM_MESSAGE_PACKET *cmd = &inmsg.cmd; + struct controlvm_message_packet *cmd = &inmsg.cmd; u64 parametersAddr = 0; u32 parametersBytes = 0; PARSER_CONTEXT *parser_ctx = NULL; @@ -1824,42 +1824,42 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) switch (inmsg.hdr.Id) { case CONTROLVM_CHIPSET_INIT: LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)", - (ulong) inmsg.cmd.initChipset.busCount, - (ulong) inmsg.cmd.initChipset.switchCount); + (ulong) inmsg.cmd.init_chipset.bus_count, + (ulong) inmsg.cmd.init_chipset.switch_count); chipset_init(&inmsg); break; case CONTROLVM_BUS_CREATE: LOGINF("BUS_CREATE(%lu,#devs=%lu)", - (ulong) cmd->createBus.busNo, - (ulong) cmd->createBus.deviceCount); + (ulong) cmd->create_bus.bus_no, + (ulong) cmd->create_bus.dev_count); bus_create(&inmsg); break; case CONTROLVM_BUS_DESTROY: - LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroyBus.busNo); + LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroy_bus.bus_no); bus_destroy(&inmsg); break; case CONTROLVM_BUS_CONFIGURE: - LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configureBus.busNo); + LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configure_bus.bus_no); bus_configure(&inmsg, parser_ctx); break; case CONTROLVM_DEVICE_CREATE: LOGINF("DEVICE_CREATE(%lu,%lu)", - (ulong) cmd->createDevice.busNo, - (ulong) cmd->createDevice.devNo); + (ulong) cmd->create_device.busNo, + (ulong) cmd->create_device.devNo); my_device_create(&inmsg); break; case CONTROLVM_DEVICE_CHANGESTATE: - if (cmd->deviceChangeState.flags.physicalDevice) { + if (cmd->device_change_state.flags.phys_device) { LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)", - (ulong) cmd->deviceChangeState.busNo, - (ulong) cmd->deviceChangeState.devNo, - (ulong) cmd->deviceChangeState.state.active); + (ulong) cmd->device_change_state.bus_no, + (ulong) cmd->device_change_state.dev_no, + (ulong) cmd->device_change_state.state.active); parahotplug_process_message(&inmsg); } else { LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)", - (ulong) cmd->deviceChangeState.busNo, - (ulong) cmd->deviceChangeState.devNo, - (ulong) cmd->deviceChangeState.state.alive); + (ulong) cmd->device_change_state.bus_no, + (ulong) cmd->device_change_state.dev_no, + (ulong) cmd->device_change_state.state.alive); /* save the hdr and cmd structures for later use */ /* when sending back the response to Command */ my_device_changestate(&inmsg); @@ -1870,14 +1870,14 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) break; case CONTROLVM_DEVICE_DESTROY: LOGINF("DEVICE_DESTROY(%lu,%lu)", - (ulong) cmd->destroyDevice.busNo, - (ulong) cmd->destroyDevice.devNo); + (ulong) cmd->destroy_device.bus_no, + (ulong) cmd->destroy_device.dev_no); my_device_destroy(&inmsg); break; case CONTROLVM_DEVICE_CONFIGURE: LOGINF("DEVICE_CONFIGURE(%lu,%lu)", - (ulong) cmd->configureDevice.busNo, - (ulong) cmd->configureDevice.devNo); + (ulong) cmd->configure_device.busNo, + (ulong) cmd->configure_device.devNo); /* no op for now, just send a respond that we passed */ if (inmsg.hdr.Flags.responseExpected) controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); @@ -2056,8 +2056,8 @@ setup_crash_devices_work_queue(struct work_struct *work) /* send init chipset msg */ msg.hdr.Id = CONTROLVM_CHIPSET_INIT; - msg.cmd.initChipset.busCount = 23; - msg.cmd.initChipset.switchCount = 0; + msg.cmd.init_chipset.bus_count = 23; + msg.cmd.init_chipset.switch_count = 0; chipset_init(&msg); @@ -2116,7 +2116,7 @@ setup_crash_devices_work_queue(struct work_struct *work) } /* reuse IOVM create bus message */ - if (localCrashCreateBusMsg.cmd.createBus.channelAddr != 0) + if (localCrashCreateBusMsg.cmd.create_bus.channel_addr != 0) bus_create(&localCrashCreateBusMsg); else { LOGERR("CrashCreateBusMsg is null, no dump will be taken"); @@ -2126,7 +2126,7 @@ setup_crash_devices_work_queue(struct work_struct *work) } /* reuse create device message for storage device */ - if (localCrashCreateDevMsg.cmd.createDevice.channelAddr != 0) + if (localCrashCreateDevMsg.cmd.create_device.channelAddr != 0) my_device_create(&localCrashCreateDevMsg); else { LOGERR("CrashCreateDevMsg is null, no dump will be taken"); -- cgit v1.2.3-59-g8ed1b From 98d7b59477617d0950819d23168df30bf231e6bb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:26 -0400 Subject: staging: unisys: refactor CONTROLVM_MESSAGE_HEADER This patch removes the typedef from CONTROLVM_MESSAGE_HEADER, using the struct controlvm_message_header name directly instead. It fixes CamelCase names and updates all references to changed names: MessageSize => message_size SegmentIndex => segment_index CompletionStatus => completion_status responseExpected => response_expected testMessage => test_message partialCompletion => partial_completion writerInDiag => writer_in_diag Flags => flags Reserved => reserved MessageHandle => message_handle PayloadVmOffset => payload_vm_offset PayloadMaxBytes => payload_max_bytes PayloadBytes => payload_bytes Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 40 +++-- drivers/staging/unisys/uislib/uislib.c | 40 ++--- drivers/staging/unisys/visorchipset/visorchipset.h | 12 +- .../unisys/visorchipset/visorchipset_main.c | 184 +++++++++++---------- 4 files changed, 139 insertions(+), 137 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 6d68b2cfc4fd..abf6bc9f57d0 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -169,53 +169,51 @@ enum ultra_chipset_feature { * queue. Commands are easily distinguished from responses by * looking at the flags.response field. */ -typedef struct _CONTROLVM_MESSAGE_HEADER { - u32 Id; /* See control_vm_id. */ +struct controlvm_message_header { + u32 id; /* See CONTROLVM_ID. */ /* For requests, indicates the message type. */ /* For responses, indicates the type of message we are responding to. */ - u32 MessageSize; /* Includes size of this struct + size + u32 message_size; /* Includes size of this struct + size * of message */ - u32 SegmentIndex; /* Index of segment containing Vm + u32 segment_index; /* Index of segment containing Vm * message/information */ - u32 CompletionStatus; /* Error status code or result of + u32 completion_status; /* Error status code or result of * message completion */ struct { u32 failed:1; /**< =1 in a response to * signify * failure */ - u32 responseExpected:1; /**< =1 in all messages that expect a + u32 response_expected:1; /**< =1 in all messages that expect a * response (Control ignores this * bit) */ u32 server:1; /**< =1 in all bus & device-related * messages where the message * receiver is to act as the bus or * device server */ - u32 testMessage:1; /**< =1 for testing use only + u32 test_message:1; /**< =1 for testing use only * (Control and Command ignore this * bit) */ - u32 partialCompletion:1; /**< =1 if there are forthcoming + u32 partial_completion:1; /**< =1 if there are forthcoming * responses/acks associated * with this message */ u32 preserve:1; /**< =1 this is to let us know to * preserve channel contents * (for running guests)*/ - u32 writerInDiag:1; /**< =1 the DiagWriter is active in the + u32 writer_in_diag:1; /**< =1 the DiagWriter is active in the * Diagnostic Partition*/ - - /* remaining bits in this 32-bit word are available */ - } Flags; - u32 Reserved; /* Natural alignment */ - u64 MessageHandle; /* Identifies the particular message instance, + } flags; + u32 reserved; /* Natural alignment */ + u64 message_handle; /* Identifies the particular message instance, * and is used to match particular */ /* request instances with the corresponding response instance. */ - u64 PayloadVmOffset; /* Offset of payload area from start of this + u64 payload_vm_offset; /* Offset of payload area from start of this * instance of ControlVm segment */ - u32 PayloadMaxBytes; /* Maximum bytes allocated in payload + u32 payload_max_bytes; /* Maximum bytes allocated in payload * area of ControlVm segment */ - u32 PayloadBytes; /* Actual number of bytes of payload + u32 payload_bytes; /* Actual number of bytes of payload * area to copy between IO/Command; */ /* if non-zero, there is a payload to copy. */ -} CONTROLVM_MESSAGE_HEADER; +}; typedef struct _CONTROLVM_PACKET_DEVICE_CREATE { u32 busNo; /**< bus # (0..n-1) from the msg receiver's @@ -241,12 +239,12 @@ typedef struct _CONTROLVM_PACKET_DEVICE_CONFIGURE { } CONTROLVM_PACKET_DEVICE_CONFIGURE; /* for CONTROLVM_DEVICE_CONFIGURE */ typedef struct _CONTROLVM_MESSAGE_DEVICE_CREATE { - CONTROLVM_MESSAGE_HEADER Header; + struct controlvm_message_header Header; CONTROLVM_PACKET_DEVICE_CREATE Packet; } CONTROLVM_MESSAGE_DEVICE_CREATE; /* total 128 bytes */ typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE { - CONTROLVM_MESSAGE_HEADER Header; + struct controlvm_message_header Header; CONTROLVM_PACKET_DEVICE_CONFIGURE Packet; } CONTROLVM_MESSAGE_DEVICE_CONFIGURE; /* total 56 bytes */ @@ -343,7 +341,7 @@ struct controlvm_message_packet { /* All messages in any ControlVm queue have this layout. */ typedef struct _CONTROLVM_MESSAGE { - CONTROLVM_MESSAGE_HEADER hdr; + struct controlvm_message_header hdr; struct controlvm_message_packet cmd; } CONTROLVM_MESSAGE; diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 87c62df526f6..63f1d6ef6338 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -124,9 +124,9 @@ static void init_msg_header(CONTROLVM_MESSAGE *msg, u32 id, uint rsp, uint svr) { memset(msg, 0, sizeof(CONTROLVM_MESSAGE)); - msg->hdr.Id = id; - msg->hdr.Flags.responseExpected = rsp; - msg->hdr.Flags.server = svr; + msg->hdr.id = id; + msg->hdr.flags.response_expected = rsp; + msg->hdr.flags.server = svr; } static __iomem void * @@ -188,7 +188,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) /* Currently by default, the bus Number is the GuestHandle. * Configure Bus message can override this. */ - if (msg->hdr.Flags.testMessage) { + if (msg->hdr.flags.test_message) { /* This implies we're the IOVM so set guest handle to 0... */ bus->guest_handle = 0; bus->bus_no = busNo; @@ -229,7 +229,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) msg->cmd.create_bus.channel_bytes); } /* the msg is bound for virtpci; send guest_msgs struct to callback */ - if (!msg->hdr.Flags.server) { + if (!msg->hdr.flags.server) { struct guest_msgs cmd; cmd.msgtype = GUEST_ADD_VBUS; @@ -309,7 +309,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) } read_unlock(&BusListLock); - if (msg->hdr.Flags.server) + if (msg->hdr.flags.server) goto remove; /* client messages require us to call the virtpci callback associated @@ -376,7 +376,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */ sprintf(dev->devid, "vbus%u:dev%u", (unsigned) busNo, (unsigned) devNo); /* map the channel memory for the device. */ - if (msg->hdr.Flags.testMessage) + if (msg->hdr.flags.test_message) dev->chanptr = (void __iomem *)__va(dev->channel_addr); else { pReqHandler = req_handler_find(dev->channel_uuid); @@ -439,7 +439,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!msg->hdr.Flags.server) { + if (!msg->hdr.flags.server) { struct guest_msgs cmd; if (!uuid_le_cmp(dev->channel_uuid, @@ -534,7 +534,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) result = CONTROLVM_RESP_ERROR_BUS_INVALID; Away: - if (!msg->hdr.Flags.testMessage) { + if (!msg->hdr.flags.test_message) { uislib_iounmap(dev->chanptr); dev->chanptr = NULL; } @@ -758,7 +758,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) uislib_disable_channel_interrupts(busNo, devNo); } /* unmap the channel memory for the device. */ - if (!msg->hdr.Flags.testMessage) { + if (!msg->hdr.flags.test_message) { LOGINF("destroy_device, doing iounmap"); uislib_iounmap(dev->chanptr); } @@ -779,12 +779,12 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf) /* We need to make sure we have our functions registered * before processing messages. If we are a test vehicle the - * testMessage for init_chipset will be set. We can ignore the + * test_message for init_chipset will be set. We can ignore the * waits for the callbacks, since this will be manually entered - * from a user. If no testMessage is set, we will wait for the + * from a user. If no test_message is set, we will wait for the * functions. */ - if (!msg->hdr.Flags.testMessage) + if (!msg->hdr.flags.test_message) WAIT_ON_CALLBACK(virt_control_chan_func); chipset_inited = 1; @@ -944,7 +944,7 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, /* signify that the physical channel address does NOT * need to be ioremap()ed */ - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.create_device.busNo = bus_no; msg.cmd.create_device.devNo = dev_no; msg.cmd.create_device.devInstGuid = inst_uuid; @@ -1003,7 +1003,7 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, /* signify that the physical channel address does NOT * need to be ioremap()ed */ - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.create_device.busNo = bus_no; msg.cmd.create_device.devNo = dev_no; msg.cmd.create_device.devInstGuid = inst_uuid; @@ -1092,7 +1092,7 @@ uislib_client_add_vnic(u32 busNo) CONTROLVM_MESSAGE msg; init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.create_bus.bus_no = busNo; msg.cmd.create_bus.dev_count = 4; msg.cmd.create_bus.channel_addr = 0; @@ -1104,7 +1104,7 @@ uislib_client_add_vnic(u32 busNo) busCreated = TRUE; init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.create_device.busNo = busNo; msg.cmd.create_device.devNo = devNo; msg.cmd.create_device.devInstGuid = NULL_UUID_LE; @@ -1122,7 +1122,7 @@ uislib_client_add_vnic(u32 busNo) AwayCleanup: if (busCreated) { init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.destroy_bus.bus_no = busNo; if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) LOGERR("client destroy_bus failed.\n"); @@ -1140,7 +1140,7 @@ uislib_client_delete_vnic(u32 busNo) CONTROLVM_MESSAGE msg; init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.destroy_device.bus_no = busNo; msg.cmd.destroy_device.dev_no = devNo; if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { @@ -1149,7 +1149,7 @@ uislib_client_delete_vnic(u32 busNo) } init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.hdr.Flags.testMessage = 1; + msg.hdr.flags.test_message = 1; msg.cmd.destroy_bus.bus_no = busNo; if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) LOGERR("client destroy_bus failed.\n"); diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index cb93da931f75..966b1dd3e669 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -86,7 +86,7 @@ typedef struct { u64 Reserved2; u32 switchNo; /* when devState.attached==1 */ u32 internalPortNo; /* when devState.attached==1 */ - CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM_MESSAGE */ + struct controlvm_message_header pendingMsgHdr; /* CONTROLVM_MESSAGE */ /** For private use by the bus driver */ void *bus_driver_context; @@ -139,7 +139,7 @@ typedef struct { /* Add new fields above. */ /* Remaining bits in this 32-bit word are unused. */ } flags; - CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM MsgHdr */ + struct controlvm_message_header pendingMsgHdr; /* CONTROLVM MsgHdr */ /** For private use by the bus driver */ void *bus_driver_context; u64 devNo; @@ -172,7 +172,7 @@ typedef struct { u32 Reserved2; /* control_vm_id */ struct device dev; BOOL dev_exists; - CONTROLVM_MESSAGE_HEADER pendingMsgHdr; + struct controlvm_message_header pendingMsgHdr; } VISORCHIPSET_SWITCH_INFO; @@ -195,7 +195,7 @@ typedef struct { u32 Reserved2; /* control_vm_id */ struct device dev; BOOL dev_exists; - CONTROLVM_MESSAGE_HEADER pendingMsgHdr; + struct controlvm_message_header pendingMsgHdr; } VISORCHIPSET_EXTERNALPORT_INFO; @@ -209,8 +209,8 @@ typedef struct { u32 busNo; /* valid only when state.attached == 1 */ u32 devNo; /* valid only when state.attached == 1 */ u64 Reserved1; - u32 Reserved2; /* control_vm_id */ - CONTROLVM_MESSAGE_HEADER pendingMsgHdr; + u32 Reserved2; /* CONTROLVM_ID */ + struct controlvm_message_header pendingMsgHdr; MYPROCOBJECT *procObject; } VISORCHIPSET_INTERNALPORT_INFO; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 7af23386e6ae..b7d53527c824 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -76,9 +76,9 @@ typedef struct { unsigned int crc; } MESSAGE_ENVELOPE; -static CONTROLVM_MESSAGE_HEADER g_DiagMsgHdr; -static CONTROLVM_MESSAGE_HEADER g_ChipSetMsgHdr; -static CONTROLVM_MESSAGE_HEADER g_DelDumpMsgHdr; +static struct controlvm_message_header g_DiagMsgHdr; +static struct controlvm_message_header g_ChipSetMsgHdr; +static struct controlvm_message_header g_DelDumpMsgHdr; static const uuid_le UltraDiagPoolChannelProtocolGuid = SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID; /* 0xffffff is an invalid Bus/Device number */ @@ -117,9 +117,9 @@ static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info; static struct channel_header *Test_Vnic_channel; typedef struct { - CONTROLVM_MESSAGE_HEADER Dumpcapture_header; - CONTROLVM_MESSAGE_HEADER Gettextdump_header; - CONTROLVM_MESSAGE_HEADER Dumpcomplete_header; + struct controlvm_message_header Dumpcapture_header; + struct controlvm_message_header Gettextdump_header; + struct controlvm_message_header Dumpcomplete_header; BOOL Gettextdump_outstanding; u32 crc32; ulong length; @@ -182,7 +182,7 @@ struct putfile_request { u64 sig; /* PUTFILE_REQUEST_SIG */ /* header from original TransmitFile request */ - CONTROLVM_MESSAGE_HEADER controlvm_header; + struct controlvm_message_header controlvm_header; u64 file_request_number; /* from original TransmitFile request */ /* link to next struct putfile_request */ @@ -344,12 +344,14 @@ static struct platform_device Visorchipset_platform_device = { }; /* Function prototypes */ -static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response); -static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, - int response, - enum ultra_chipset_feature features); -static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER * - msgHdr, int response, struct spar_segment_state state); +static void controlvm_respond(struct controlvm_message_header *msgHdr, + int response); +static void controlvm_respond_chipset_init( + struct controlvm_message_header *msgHdr, int response, + enum ultra_chipset_feature features); +static void controlvm_respond_physdev_changestate( + struct controlvm_message_header *msgHdr, int response, + struct spar_segment_state state); static ssize_t toolaction_show(struct device *dev, struct device_attribute *attr, @@ -680,42 +682,42 @@ chipset_init(CONTROLVM_MESSAGE *inmsg) Away: if (rc < 0) cleanup_controlvm_structures(); - if (inmsg->hdr.Flags.responseExpected) + if (inmsg->hdr.flags.response_expected) controlvm_respond_chipset_init(&inmsg->hdr, rc, features); } static void controlvm_init_response(CONTROLVM_MESSAGE *msg, - CONTROLVM_MESSAGE_HEADER *msgHdr, int response) + struct controlvm_message_header *msgHdr, int response) { memset(msg, 0, sizeof(CONTROLVM_MESSAGE)); - memcpy(&msg->hdr, msgHdr, sizeof(CONTROLVM_MESSAGE_HEADER)); - msg->hdr.PayloadBytes = 0; - msg->hdr.PayloadVmOffset = 0; - msg->hdr.PayloadMaxBytes = 0; + memcpy(&msg->hdr, msgHdr, sizeof(struct controlvm_message_header)); + msg->hdr.payload_bytes = 0; + msg->hdr.payload_vm_offset = 0; + msg->hdr.payload_max_bytes = 0; if (response < 0) { - msg->hdr.Flags.failed = 1; - msg->hdr.CompletionStatus = (u32) (-response); + msg->hdr.flags.failed = 1; + msg->hdr.completion_status = (u32) (-response); } } static void -controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response) +controlvm_respond(struct controlvm_message_header *msgHdr, int response) { CONTROLVM_MESSAGE outmsg; controlvm_init_response(&outmsg, msgHdr, response); /* For DiagPool channel DEVICE_CHANGESTATE, we need to send * back the deviceChangeState structure in the packet. */ - if (msgHdr->Id == CONTROLVM_DEVICE_CHANGESTATE + if (msgHdr->id == CONTROLVM_DEVICE_CHANGESTATE && g_DeviceChangeStatePacket.device_change_state.bus_no == g_diagpoolBusNo && g_DeviceChangeStatePacket.device_change_state.dev_no == g_diagpoolDevNo) outmsg.cmd = g_DeviceChangeStatePacket; - if (outmsg.hdr.Flags.testMessage == 1) { + if (outmsg.hdr.flags.test_message == 1) { LOGINF("%s controlvm_msg=0x%x response=%d for test message", - __func__, outmsg.hdr.Id, response); + __func__, outmsg.hdr.id, response); return; } if (!visorchannel_signalinsert(ControlVm_channel, @@ -726,7 +728,8 @@ controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response) } static void -controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, +controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr, + int response, enum ultra_chipset_feature features) { CONTROLVM_MESSAGE outmsg; @@ -740,9 +743,9 @@ controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, } } -static void -controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr, - int response, struct spar_segment_state state) +static void controlvm_respond_physdev_changestate( + struct controlvm_message_header *msgHdr, int response, + struct spar_segment_state state) { CONTROLVM_MESSAGE outmsg; @@ -839,16 +842,16 @@ bus_responder(enum controlvm_id cmdId, ulong busNo, int response) need_clear = TRUE; } - if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) { + if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { LOGERR("bus_responder no pending msg"); return; /* no controlvm response needed */ } - if (p->pendingMsgHdr.Id != (u32) cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id); + if (p->pendingMsgHdr.id != (u32) cmdId) { + LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); return; } controlvm_respond(&p->pendingMsgHdr, response); - p->pendingMsgHdr.Id = CONTROLVM_INVALID; + p->pendingMsgHdr.id = CONTROLVM_INVALID; if (need_clear) { busInfo_clear(p); delbusdevices(&DevInfoList, busNo); @@ -868,12 +871,12 @@ device_changestate_responder(enum controlvm_id cmdId, LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); return; } - if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) { + if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { LOGERR("device_responder no pending msg"); return; /* no controlvm response needed */ } - if (p->pendingMsgHdr.Id != cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id); + if (p->pendingMsgHdr.id != cmdId) { + LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); return; } @@ -889,7 +892,7 @@ device_changestate_responder(enum controlvm_id cmdId, return; } - p->pendingMsgHdr.Id = CONTROLVM_INVALID; + p->pendingMsgHdr.id = CONTROLVM_INVALID; } static void @@ -911,23 +914,23 @@ device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, need_clear = TRUE; } - if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) { + if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { LOGERR("device_responder no pending msg"); return; /* no controlvm response needed */ } - if (p->pendingMsgHdr.Id != (u32) cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id); + if (p->pendingMsgHdr.id != (u32) cmdId) { + LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); return; } controlvm_respond(&p->pendingMsgHdr, response); - p->pendingMsgHdr.Id = CONTROLVM_INVALID; + p->pendingMsgHdr.id = CONTROLVM_INVALID; if (need_clear) devInfo_clear(p); } static void bus_epilog(u32 busNo, - u32 cmd, CONTROLVM_MESSAGE_HEADER *msgHdr, + u32 cmd, struct controlvm_message_header *msgHdr, int response, BOOL needResponse) { BOOL notified = FALSE; @@ -940,9 +943,9 @@ bus_epilog(u32 busNo, } if (needResponse) { memcpy(&pBusInfo->pendingMsgHdr, msgHdr, - sizeof(CONTROLVM_MESSAGE_HEADER)); + sizeof(struct controlvm_message_header)); } else - pBusInfo->pendingMsgHdr.Id = CONTROLVM_INVALID; + pBusInfo->pendingMsgHdr.id = CONTROLVM_INVALID; down(&NotifierLock); if (response == CONTROLVM_RESP_SUCCESS) { @@ -994,7 +997,7 @@ bus_epilog(u32 busNo, static void device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, - CONTROLVM_MESSAGE_HEADER *msgHdr, int response, + struct controlvm_message_header *msgHdr, int response, BOOL needResponse, BOOL for_visorbus) { VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL; @@ -1017,9 +1020,9 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, notifiers = &BusDev_Client_Notifiers; if (needResponse) { memcpy(&pDevInfo->pendingMsgHdr, msgHdr, - sizeof(CONTROLVM_MESSAGE_HEADER)); + sizeof(struct controlvm_message_header)); } else - pDevInfo->pendingMsgHdr.Id = CONTROLVM_INVALID; + pDevInfo->pendingMsgHdr.id = CONTROLVM_INVALID; down(&NotifierLock); if (response >= 0) { @@ -1125,12 +1128,12 @@ bus_create(CONTROLVM_MESSAGE *inmsg) POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); - if (inmsg->hdr.Flags.testMessage == 1) + if (inmsg->hdr.flags.test_message == 1) pBusInfo->chanInfo.addrType = ADDRTYPE_localTest; else pBusInfo->chanInfo.addrType = ADDRTYPE_localPhysical; - pBusInfo->flags.server = inmsg->hdr.Flags.server; + pBusInfo->flags.server = inmsg->hdr.flags.server; pBusInfo->chanInfo.channelAddr = cmd->create_bus.channel_addr; pBusInfo->chanInfo.nChannelBytes = cmd->create_bus.channel_bytes; pBusInfo->chanInfo.channelTypeGuid = cmd->create_bus.bus_data_type_uuid; @@ -1142,7 +1145,7 @@ bus_create(CONTROLVM_MESSAGE *inmsg) Away: bus_epilog(busNo, CONTROLVM_BUS_CREATE, &inmsg->hdr, - rc, inmsg->hdr.Flags.responseExpected == 1); + rc, inmsg->hdr.flags.response_expected == 1); } static void @@ -1168,7 +1171,7 @@ bus_destroy(CONTROLVM_MESSAGE *inmsg) Away: bus_epilog(busNo, CONTROLVM_BUS_DESTROY, &inmsg->hdr, - rc, inmsg->hdr.Flags.responseExpected == 1); + rc, inmsg->hdr.flags.response_expected == 1); } static void @@ -1201,9 +1204,9 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) goto Away; } /* TBD - add this check to other commands also... */ - if (pBusInfo->pendingMsgHdr.Id != CONTROLVM_INVALID) { + if (pBusInfo->pendingMsgHdr.id != CONTROLVM_INVALID) { LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding", - busNo, (uint) pBusInfo->pendingMsgHdr.Id); + busNo, (uint) pBusInfo->pendingMsgHdr.id); POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; @@ -1219,7 +1222,7 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); Away: bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, - rc, inmsg->hdr.Flags.responseExpected == 1); + rc, inmsg->hdr.flags.response_expected == 1); } static void @@ -1275,7 +1278,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); - if (inmsg->hdr.Flags.testMessage == 1) + if (inmsg->hdr.flags.test_message == 1) pDevInfo->chanInfo.addrType = ADDRTYPE_localTest; else pDevInfo->chanInfo.addrType = ADDRTYPE_localPhysical; @@ -1296,7 +1299,7 @@ Away: } device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, - inmsg->hdr.Flags.responseExpected == 1, + inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); } @@ -1330,7 +1333,7 @@ Away: if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) device_epilog(busNo, devNo, state, CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc, - inmsg->hdr.Flags.responseExpected == 1, + inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); } @@ -1360,7 +1363,7 @@ Away: if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, - inmsg->hdr.Flags.responseExpected == 1, + inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); } @@ -1490,15 +1493,15 @@ visorchipset_chipset_notready(void) EXPORT_SYMBOL_GPL(visorchipset_chipset_notready); static void -chipset_ready(CONTROLVM_MESSAGE_HEADER *msgHdr) +chipset_ready(struct controlvm_message_header *msgHdr) { int rc = visorchipset_chipset_ready(); if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; - if (msgHdr->Flags.responseExpected && !visorchipset_holdchipsetready) + if (msgHdr->flags.response_expected && !visorchipset_holdchipsetready) controlvm_respond(msgHdr, rc); - if (msgHdr->Flags.responseExpected && visorchipset_holdchipsetready) { + if (msgHdr->flags.response_expected && visorchipset_holdchipsetready) { /* Send CHIPSET_READY response when all modules have been loaded * and disks mounted for the partition */ @@ -1508,24 +1511,24 @@ chipset_ready(CONTROLVM_MESSAGE_HEADER *msgHdr) } static void -chipset_selftest(CONTROLVM_MESSAGE_HEADER *msgHdr) +chipset_selftest(struct controlvm_message_header *msgHdr) { int rc = visorchipset_chipset_selftest(); if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; - if (msgHdr->Flags.responseExpected) + if (msgHdr->flags.response_expected) controlvm_respond(msgHdr, rc); } static void -chipset_notready(CONTROLVM_MESSAGE_HEADER *msgHdr) +chipset_notready(struct controlvm_message_header *msgHdr) { int rc = visorchipset_chipset_notready(); if (rc != CONTROLVM_RESP_SUCCESS) rc = -rc; - if (msgHdr->Flags.responseExpected) + if (msgHdr->flags.response_expected) controlvm_respond(msgHdr, rc); } @@ -1538,8 +1541,9 @@ read_controlvm_event(CONTROLVM_MESSAGE *msg) if (visorchannel_signalremove(ControlVm_channel, CONTROLVM_QUEUE_EVENT, msg)) { /* got a message */ - if (msg->hdr.Flags.testMessage == 1) { - LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", msg->hdr.Id); + if (msg->hdr.flags.test_message == 1) { + LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", + msg->hdr.id); return FALSE; } return TRUE; @@ -1666,7 +1670,7 @@ parahotplug_process_list(void) list_entry(pos, struct parahotplug_request, list); if (time_after_eq(jiffies, req->expiration)) { list_del(pos); - if (req->msg.hdr.Flags.responseExpected) + if (req->msg.hdr.flags.response_expected) controlvm_respond_physdev_changestate( &req->msg.hdr, CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT, @@ -1702,7 +1706,7 @@ parahotplug_request_complete(int id, u16 active) list_del(pos); spin_unlock(&Parahotplug_request_list_lock); req->msg.cmd.device_change_state.state.active = active; - if (req->msg.hdr.Flags.responseExpected) + if (req->msg.hdr.flags.response_expected) controlvm_respond_physdev_changestate( &req->msg.hdr, CONTROLVM_RESP_SUCCESS, req->msg.cmd.device_change_state.state); @@ -1781,13 +1785,13 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) CONTROLVM_MESSAGE ackmsg; /* create parsing context if necessary */ - isLocalAddr = (inmsg.hdr.Flags.testMessage == 1); + isLocalAddr = (inmsg.hdr.flags.test_message == 1); if (channel_addr == 0) { LOGERR("HUH? channel_addr is 0!"); return TRUE; } - parametersAddr = channel_addr + inmsg.hdr.PayloadVmOffset; - parametersBytes = inmsg.hdr.PayloadBytes; + parametersAddr = channel_addr + inmsg.hdr.payload_vm_offset; + parametersBytes = inmsg.hdr.payload_bytes; /* Parameter and channel addresses within test messages actually lie * within our OS-controlled memory. We need to know that, because it @@ -1805,7 +1809,7 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) return FALSE; } LOGWRN("parsing failed"); - LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.Id); + LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.id); LOGWRN("parametersAddr=0x%llx", (u64) parametersAddr); LOGWRN("parametersBytes=%lu", (ulong) parametersBytes); LOGWRN("isLocalAddr=%d", isLocalAddr); @@ -1821,7 +1825,7 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) (ControlVm_channel, CONTROLVM_QUEUE_ACK, &ackmsg))) LOGWRN("failed to send ACK failed"); } - switch (inmsg.hdr.Id) { + switch (inmsg.hdr.id) { case CONTROLVM_CHIPSET_INIT: LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)", (ulong) inmsg.cmd.init_chipset.bus_count, @@ -1879,7 +1883,7 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) (ulong) cmd->configure_device.busNo, (ulong) cmd->configure_device.devNo); /* no op for now, just send a respond that we passed */ - if (inmsg.hdr.Flags.responseExpected) + if (inmsg.hdr.flags.response_expected) controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); break; case CONTROLVM_CHIPSET_READY: @@ -1895,8 +1899,8 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) chipset_notready(&inmsg.hdr); break; default: - LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.Id); - if (inmsg.hdr.Flags.responseExpected) + LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.id); + if (inmsg.hdr.flags.response_expected) controlvm_respond(&inmsg.hdr, -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN); break; @@ -1953,24 +1957,24 @@ controlvm_periodic_work(struct work_struct *work) * should be sent */ if (visorchipset_holdchipsetready - && (g_ChipSetMsgHdr.Id != CONTROLVM_INVALID)) { + && (g_ChipSetMsgHdr.id != CONTROLVM_INVALID)) { if (check_chipset_events() == 1) { LOGINF("Sending CHIPSET_READY response"); controlvm_respond(&g_ChipSetMsgHdr, 0); clear_chipset_events(); memset(&g_ChipSetMsgHdr, 0, - sizeof(CONTROLVM_MESSAGE_HEADER)); + sizeof(struct controlvm_message_header)); } } while (visorchannel_signalremove(ControlVm_channel, CONTROLVM_QUEUE_RESPONSE, &inmsg)) { - if (inmsg.hdr.PayloadMaxBytes != 0) { + if (inmsg.hdr.payload_max_bytes != 0) { LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.", - (ulong) inmsg.hdr.PayloadMaxBytes, - (ulong) inmsg.hdr.PayloadVmOffset, - inmsg.hdr.Id); + (ulong) inmsg.hdr.payload_max_bytes, + (ulong) inmsg.hdr.payload_vm_offset, + inmsg.hdr.id); } } if (!gotACommand) { @@ -2055,7 +2059,7 @@ setup_crash_devices_work_queue(struct work_struct *work) POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO); /* send init chipset msg */ - msg.hdr.Id = CONTROLVM_CHIPSET_INIT; + msg.hdr.id = CONTROLVM_CHIPSET_INIT; msg.cmd.init_chipset.bus_count = 23; msg.cmd.init_chipset.switch_count = 0; @@ -2406,11 +2410,11 @@ visorchipset_init(void) goto Away; } - memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); + memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); + memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); + memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header)); Putfile_buffer_list_pool = kmem_cache_create(Putfile_buffer_list_pool_name, @@ -2499,11 +2503,11 @@ visorchipset_exit(void) cleanup_controlvm_structures(); - memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); + memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); + memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header)); - memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); + memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header)); LOGINF("Channel %s (ControlVm) disconnected", visorchannel_id(ControlVm_channel, s)); -- cgit v1.2.3-59-g8ed1b From f91b926273134d9bfec32d6c4fcbd5188afd07dc Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:27 -0400 Subject: staging: unisys: refactor CONTROLVM_PACKET_DEVICE_CREATE Get rid of the typedef for CONTROLVM_PACKET_DEVICE_CREATE, instead using struct controlvm_packet_device_create. Fix CamelCase names and update all references to changed names. Clean up comments. busNo => bus_no devNo => dev_no channelAddr => channel_addr channelBytes => channel_bytes dataTypeGuid => data_type_uuid devInstGuid => dev_inst_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 29 +++++------ drivers/staging/unisys/uislib/uislib.c | 56 +++++++++++----------- .../unisys/visorchipset/visorchipset_main.c | 18 +++---- 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index abf6bc9f57d0..78c4b3366da4 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -215,20 +215,17 @@ struct controlvm_message_header { /* if non-zero, there is a payload to copy. */ }; -typedef struct _CONTROLVM_PACKET_DEVICE_CREATE { - u32 busNo; /**< bus # (0..n-1) from the msg receiver's - * perspective */ - - /* Control uses header SegmentIndex field to access bus number... */ - u32 devNo; /**< bus-relative (0..n-1) device number */ - u64 channelAddr; /**< Guest physical address of the channel, which - * can be dereferenced by the receiver - * of this ControlVm command */ - u64 channelBytes; /**< specifies size of the channel in bytes */ - uuid_le dataTypeGuid;/**< specifies format of data in channel */ - uuid_le devInstGuid; /**< instance guid for the device */ - struct irq_info intr; /**< specifies interrupt information */ -} CONTROLVM_PACKET_DEVICE_CREATE; /* for CONTROLVM_DEVICE_CREATE */ +struct controlvm_packet_device_create { + u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */ + u32 dev_no; /* bus-relative (0..n-1) device number */ + u64 channel_addr; /* Guest physical address of the channel, which + * can be dereferenced by the receiver of this + * ControlVm command */ + u64 channel_bytes; /* specifies size of the channel in bytes */ + uuid_le data_type_uuid; /* specifies format of data in channel */ + uuid_le dev_inst_uuid; /* instance guid for the device */ + struct irq_info intr; /* specifies interrupt information */ +}; /* for CONTROLVM_DEVICE_CREATE */ typedef struct _CONTROLVM_PACKET_DEVICE_CONFIGURE { u32 busNo; /**< bus # (0..n-1) from the msg @@ -240,7 +237,7 @@ typedef struct _CONTROLVM_PACKET_DEVICE_CONFIGURE { typedef struct _CONTROLVM_MESSAGE_DEVICE_CREATE { struct controlvm_message_header Header; - CONTROLVM_PACKET_DEVICE_CREATE Packet; + struct controlvm_packet_device_create Packet; } CONTROLVM_MESSAGE_DEVICE_CREATE; /* total 128 bytes */ typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE { @@ -285,7 +282,7 @@ struct controlvm_message_packet { * sendBusInterruptHandle is kept in CP. */ } configure_bus; /* for CONTROLVM_BUS_CONFIGURE */ /* for CONTROLVM_DEVICE_CREATE */ - CONTROLVM_PACKET_DEVICE_CREATE create_device; + struct controlvm_packet_device_create create_device; struct { u32 bus_no; /* bus # (0..n-1) from the msg * receiver's perspective */ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 63f1d6ef6338..2b1ae7cead46 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -354,8 +354,8 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) u64 minSize = MIN_IO_CHANNEL_SIZE; struct req_handler_info *pReqHandler; - busNo = msg->cmd.create_device.busNo; - devNo = msg->cmd.create_device.devNo; + busNo = msg->cmd.create_device.bus_no; + devNo = msg->cmd.create_device.dev_no; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); @@ -368,9 +368,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; } - dev->channel_uuid = msg->cmd.create_device.dataTypeGuid; + dev->channel_uuid = msg->cmd.create_device.data_type_uuid; dev->intr = msg->cmd.create_device.intr; - dev->channel_addr = msg->cmd.create_device.channelAddr; + dev->channel_addr = msg->cmd.create_device.channel_addr; dev->bus_no = busNo; dev->dev_no = devNo; sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */ @@ -385,9 +385,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) * channel */ minSize = pReqHandler->min_channel_bytes; - if (minSize > msg->cmd.create_device.channelBytes) { + if (minSize > msg->cmd.create_device.channel_bytes) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: channel size is too small, channel size:0x%lx, required size:0x%lx", - (ulong) msg->cmd.create_device.channelBytes, + (ulong) msg->cmd.create_device.channel_bytes, (ulong) minSize); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); @@ -396,19 +396,19 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) } dev->chanptr = uislib_ioremap_cache(dev->channel_addr, - msg->cmd.create_device.channelBytes); + msg->cmd.create_device.channel_bytes); if (!dev->chanptr) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", dev->channel_addr, - msg->cmd.create_device.channelBytes); + msg->cmd.create_device.channel_bytes); result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED; POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); goto Away; } } - dev->instance_uuid = msg->cmd.create_device.devInstGuid; - dev->channel_bytes = msg->cmd.create_device.channelBytes; + dev->instance_uuid = msg->cmd.create_device.dev_inst_uuid; + dev->channel_bytes = msg->cmd.create_device.channel_bytes; read_lock(&BusListLock); for (bus = BusListHead; bus; bus = bus->next) { @@ -945,15 +945,15 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, * need to be ioremap()ed */ msg.hdr.flags.test_message = 1; - msg.cmd.create_device.busNo = bus_no; - msg.cmd.create_device.devNo = dev_no; - msg.cmd.create_device.devInstGuid = inst_uuid; + msg.cmd.create_device.bus_no = bus_no; + msg.cmd.create_device.dev_no = dev_no; + msg.cmd.create_device.dev_inst_uuid = inst_uuid; if (intr) msg.cmd.create_device.intr = *intr; else memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); - msg.cmd.create_device.channelAddr = phys_chan_addr; + msg.cmd.create_device.channel_addr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE); @@ -961,8 +961,8 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); return 0; } - msg.cmd.create_device.channelBytes = chan_bytes; - msg.cmd.create_device.dataTypeGuid = spar_vhba_channel_protocol_uuid; + msg.cmd.create_device.channel_bytes = chan_bytes; + msg.cmd.create_device.data_type_uuid = spar_vhba_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VHBA create_device failed.\n"); POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1004,15 +1004,15 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, * need to be ioremap()ed */ msg.hdr.flags.test_message = 1; - msg.cmd.create_device.busNo = bus_no; - msg.cmd.create_device.devNo = dev_no; - msg.cmd.create_device.devInstGuid = inst_uuid; + msg.cmd.create_device.bus_no = bus_no; + msg.cmd.create_device.dev_no = dev_no; + msg.cmd.create_device.dev_inst_uuid = inst_uuid; if (intr) msg.cmd.create_device.intr = *intr; else memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); - msg.cmd.create_device.channelAddr = phys_chan_addr; + msg.cmd.create_device.channel_addr = phys_chan_addr; if (chan_bytes < MIN_IO_CHANNEL_SIZE) { LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n", chan_bytes, (unsigned int) MIN_IO_CHANNEL_SIZE); @@ -1020,8 +1020,8 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR); return 0; } - msg.cmd.create_device.channelBytes = chan_bytes; - msg.cmd.create_device.dataTypeGuid = spar_vnic_channel_protocol_uuid; + msg.cmd.create_device.channel_bytes = chan_bytes; + msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("VNIC create_device failed.\n"); POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no, @@ -1105,13 +1105,13 @@ uislib_client_add_vnic(u32 busNo) init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); msg.hdr.flags.test_message = 1; - msg.cmd.create_device.busNo = busNo; - msg.cmd.create_device.devNo = devNo; - msg.cmd.create_device.devInstGuid = NULL_UUID_LE; + msg.cmd.create_device.bus_no = busNo; + msg.cmd.create_device.dev_no = devNo; + msg.cmd.create_device.dev_inst_uuid = NULL_UUID_LE; memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); - msg.cmd.create_device.channelAddr = PhysicalDataChan; - msg.cmd.create_device.channelBytes = MIN_IO_CHANNEL_SIZE; - msg.cmd.create_device.dataTypeGuid = spar_vnic_channel_protocol_uuid; + msg.cmd.create_device.channel_addr = PhysicalDataChan; + msg.cmd.create_device.channel_bytes = MIN_IO_CHANNEL_SIZE; + msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid; if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { LOGERR("client create_device failed"); goto AwayCleanup; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index b7d53527c824..d7f644a5e980 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1229,8 +1229,8 @@ static void my_device_create(CONTROLVM_MESSAGE *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - ulong busNo = cmd->create_device.busNo; - ulong devNo = cmd->create_device.devNo; + ulong busNo = cmd->create_device.bus_no; + ulong devNo = cmd->create_device.dev_no; VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; VISORCHIPSET_BUS_INFO *pBusInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1274,7 +1274,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) INIT_LIST_HEAD(&pDevInfo->entry); pDevInfo->busNo = busNo; pDevInfo->devNo = devNo; - pDevInfo->devInstGuid = cmd->create_device.devInstGuid; + pDevInfo->devInstGuid = cmd->create_device.dev_inst_uuid; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); @@ -1282,9 +1282,9 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) pDevInfo->chanInfo.addrType = ADDRTYPE_localTest; else pDevInfo->chanInfo.addrType = ADDRTYPE_localPhysical; - pDevInfo->chanInfo.channelAddr = cmd->create_device.channelAddr; - pDevInfo->chanInfo.nChannelBytes = cmd->create_device.channelBytes; - pDevInfo->chanInfo.channelTypeGuid = cmd->create_device.dataTypeGuid; + pDevInfo->chanInfo.channelAddr = cmd->create_device.channel_addr; + pDevInfo->chanInfo.nChannelBytes = cmd->create_device.channel_bytes; + pDevInfo->chanInfo.channelTypeGuid = cmd->create_device.data_type_uuid; pDevInfo->chanInfo.intr = cmd->create_device.intr; list_add(&pDevInfo->entry, &DevInfoList); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, @@ -1848,8 +1848,8 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) break; case CONTROLVM_DEVICE_CREATE: LOGINF("DEVICE_CREATE(%lu,%lu)", - (ulong) cmd->create_device.busNo, - (ulong) cmd->create_device.devNo); + (ulong) cmd->create_device.bus_no, + (ulong) cmd->create_device.dev_no); my_device_create(&inmsg); break; case CONTROLVM_DEVICE_CHANGESTATE: @@ -2130,7 +2130,7 @@ setup_crash_devices_work_queue(struct work_struct *work) } /* reuse create device message for storage device */ - if (localCrashCreateDevMsg.cmd.create_device.channelAddr != 0) + if (localCrashCreateDevMsg.cmd.create_device.channel_addr != 0) my_device_create(&localCrashCreateDevMsg); else { LOGERR("CrashCreateDevMsg is null, no dump will be taken"); -- cgit v1.2.3-59-g8ed1b From e6ad00bbe5053ad4eca363105726976968ed8415 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:28 -0400 Subject: staging: unisys: refactor CONTROLVM_PACKET_DEVICE_CONFIGURE Remove the typedef from CONTROLVM_PACKET_DEVICE_CONFIGURE, in favor of struct controlvm_packet_device_configure. Fix CamelCase names and update all references to modified names. busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 12 ++++++------ drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 78c4b3366da4..7a5524da56c1 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -227,13 +227,13 @@ struct controlvm_packet_device_create { struct irq_info intr; /* specifies interrupt information */ }; /* for CONTROLVM_DEVICE_CREATE */ -typedef struct _CONTROLVM_PACKET_DEVICE_CONFIGURE { - u32 busNo; /**< bus # (0..n-1) from the msg +struct controlvm_packet_device_configure { + u32 bus_no; /**< bus # (0..n-1) from the msg * receiver's perspective */ /* Control uses header SegmentIndex field to access bus number... */ - u32 devNo; /**< bus-relative (0..n-1) device number */ -} CONTROLVM_PACKET_DEVICE_CONFIGURE; /* for CONTROLVM_DEVICE_CONFIGURE */ + u32 dev_no; /**< bus-relative (0..n-1) device number */ +} ; /* for CONTROLVM_DEVICE_CONFIGURE */ typedef struct _CONTROLVM_MESSAGE_DEVICE_CREATE { struct controlvm_message_header Header; @@ -242,7 +242,7 @@ typedef struct _CONTROLVM_MESSAGE_DEVICE_CREATE { typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE { struct controlvm_message_header Header; - CONTROLVM_PACKET_DEVICE_CONFIGURE Packet; + struct controlvm_packet_device_configure Packet; } CONTROLVM_MESSAGE_DEVICE_CONFIGURE; /* total 56 bytes */ /* This is the format for a message in any ControlVm queue. */ @@ -289,7 +289,7 @@ struct controlvm_message_packet { u32 dev_no; /* bus-relative (0..n-1) device # */ } destroy_device; /* for CONTROLVM_DEVICE_DESTROY */ /* for CONTROLVM_DEVICE_CONFIGURE */ - CONTROLVM_PACKET_DEVICE_CONFIGURE configure_device; + struct controlvm_packet_device_configure configure_device; struct { u32 bus_no; /* bus # (0..n-1) from the msg * receiver's perspective */ diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index d7f644a5e980..753ea994f293 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1880,8 +1880,8 @@ handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) break; case CONTROLVM_DEVICE_CONFIGURE: LOGINF("DEVICE_CONFIGURE(%lu,%lu)", - (ulong) cmd->configure_device.busNo, - (ulong) cmd->configure_device.devNo); + (ulong) cmd->configure_device.bus_no, + (ulong) cmd->configure_device.dev_no); /* no op for now, just send a respond that we passed */ if (inmsg.hdr.flags.response_expected) controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); -- cgit v1.2.3-59-g8ed1b From c36acb55798e703acde85ad581fe615548c29dff Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:29 -0400 Subject: staging: unisys: refactor CONTROLVM_MESSAGE_DEVICE_CREATE Remove the typedef from CONTROLVM_MESSAGE_DEVICE_CREATE, in favor of struct controlvm_message_device_create, fix CamelCase names, and update all references. Header => header Packet => packet Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 7a5524da56c1..120fa58fc0c9 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -235,10 +235,10 @@ struct controlvm_packet_device_configure { u32 dev_no; /**< bus-relative (0..n-1) device number */ } ; /* for CONTROLVM_DEVICE_CONFIGURE */ -typedef struct _CONTROLVM_MESSAGE_DEVICE_CREATE { - struct controlvm_message_header Header; - struct controlvm_packet_device_create Packet; -} CONTROLVM_MESSAGE_DEVICE_CREATE; /* total 128 bytes */ +struct controlvm_message_device_create { + struct controlvm_message_header header; + struct controlvm_packet_device_create packet; +}; /* total 128 bytes */ typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE { struct controlvm_message_header Header; -- cgit v1.2.3-59-g8ed1b From f676054dd8ca5d700bf434c56cc221ede3e33b05 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:30 -0400 Subject: staging: unisys: refactor CONTROLVM_MESSAGE_DEVICE_CONFIGURE Remove the typedef from CONTROLVM_MESSAGE_DEVICE_CONFIGURE, replacing it with struct controlvm_message_device_configure. Fix CamelCase names and update all references. Header => header Packet => packet Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlvmchannel.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 120fa58fc0c9..6dc79d8fd795 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -240,10 +240,10 @@ struct controlvm_message_device_create { struct controlvm_packet_device_create packet; }; /* total 128 bytes */ -typedef struct _CONTROLVM_MESSAGE_DEVICE_CONFIGURE { - struct controlvm_message_header Header; - struct controlvm_packet_device_configure Packet; -} CONTROLVM_MESSAGE_DEVICE_CONFIGURE; /* total 56 bytes */ +struct controlvm_message_device_configure { + struct controlvm_message_header header; + struct controlvm_packet_device_configure packet; +}; /* total 56 bytes */ /* This is the format for a message in any ControlVm queue. */ struct controlvm_message_packet { -- cgit v1.2.3-59-g8ed1b From 3ab477012935626a66ad50bdae1fe7acf03be10a Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:31 -0400 Subject: staging: unisys: remove typedef from CONTROLVM_MESSAGE Remove the typedef and use struct controlvm_message instead. Update all references. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 14 ++--- drivers/staging/unisys/uislib/uislib.c | 42 +++++++------- drivers/staging/unisys/visorchipset/testing.h | 5 +- drivers/staging/unisys/visorchipset/visorchipset.h | 7 ++- .../unisys/visorchipset/visorchipset_main.c | 65 +++++++++++----------- 5 files changed, 68 insertions(+), 65 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 6dc79d8fd795..8bc2e174ddcc 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -337,10 +337,10 @@ struct controlvm_message_packet { }; /* All messages in any ControlVm queue have this layout. */ -typedef struct _CONTROLVM_MESSAGE { +struct controlvm_message { struct controlvm_message_header hdr; struct controlvm_message_packet cmd; -} CONTROLVM_MESSAGE; +}; typedef struct _DEVICE_MAP { GUEST_PHYSICAL_ADDRESS DeviceChannelAddress; @@ -447,19 +447,19 @@ typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { * Control events */ /* Request fixed-size message pool - does not include payload */ - CONTROLVM_MESSAGE RequestMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message RequestMsg[CONTROLVM_MESSAGE_MAX]; /* Response fixed-size message pool - does not include payload */ - CONTROLVM_MESSAGE ResponseMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message ResponseMsg[CONTROLVM_MESSAGE_MAX]; /* Event fixed-size message pool - does not include payload */ - CONTROLVM_MESSAGE EventMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message EventMsg[CONTROLVM_MESSAGE_MAX]; /* Ack fixed-size message pool - does not include payload */ - CONTROLVM_MESSAGE EventAckMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message EventAckMsg[CONTROLVM_MESSAGE_MAX]; /* Message stored during IOVM creation to be reused after crash */ - CONTROLVM_MESSAGE SavedCrashMsg[CONTROLVM_CRASHMSG_MAX]; + struct controlvm_message SavedCrashMsg[CONTROLVM_CRASHMSG_MAX]; } ULTRA_CONTROLVM_CHANNEL_PROTOCOL; /* Offsets for VM channel attributes... */ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 2b1ae7cead46..513e00d2f979 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -121,9 +121,9 @@ static const struct file_operations debugfs_info_fops = { }; static void -init_msg_header(CONTROLVM_MESSAGE *msg, u32 id, uint rsp, uint svr) +init_msg_header(struct controlvm_message *msg, u32 id, uint rsp, uint svr) { - memset(msg, 0, sizeof(CONTROLVM_MESSAGE)); + memset(msg, 0, sizeof(struct controlvm_message)); msg->hdr.id = id; msg->hdr.flags.response_expected = rsp; msg->hdr.flags.server = svr; @@ -154,7 +154,7 @@ Away: } static int -create_bus(CONTROLVM_MESSAGE *msg, char *buf) +create_bus(struct controlvm_message *msg, char *buf) { u32 busNo, deviceCount; struct bus_info *tmp, *bus; @@ -272,7 +272,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) } static int -destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) +destroy_bus(struct controlvm_message *msg, char *buf) { int i; struct bus_info *bus, *prev = NULL; @@ -345,7 +345,7 @@ remove: } static int -create_device(CONTROLVM_MESSAGE *msg, char *buf) +create_device(struct controlvm_message *msg, char *buf) { struct device_info *dev; struct bus_info *bus; @@ -544,7 +544,7 @@ Away: } static int -pause_device(CONTROLVM_MESSAGE *msg) +pause_device(struct controlvm_message *msg) { u32 busNo, devNo; struct bus_info *bus; @@ -612,7 +612,7 @@ pause_device(CONTROLVM_MESSAGE *msg) } static int -resume_device(CONTROLVM_MESSAGE *msg) +resume_device(struct controlvm_message *msg) { u32 busNo, devNo; struct bus_info *bus; @@ -681,7 +681,7 @@ resume_device(CONTROLVM_MESSAGE *msg) } static int -destroy_device(CONTROLVM_MESSAGE *msg, char *buf) +destroy_device(struct controlvm_message *msg, char *buf) { u32 busNo, devNo; struct bus_info *bus; @@ -769,7 +769,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) } static int -init_chipset(CONTROLVM_MESSAGE *msg, char *buf) +init_chipset(struct controlvm_message *msg, char *buf) { POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); @@ -796,7 +796,7 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf) static int delete_bus_glue(u32 busNo) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); msg.cmd.destroy_bus.bus_no = busNo; @@ -810,7 +810,7 @@ delete_bus_glue(u32 busNo) static int delete_device_glue(u32 busNo, u32 devNo) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); msg.cmd.destroy_device.bus_no = busNo; @@ -827,7 +827,7 @@ int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid, u64 channel_addr, ulong n_channel_bytes) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; LOGINF("enter busNo=0x%x\n", bus_no); /* step 0: init the chipset */ @@ -885,7 +885,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus); int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); @@ -905,7 +905,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba); int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); @@ -929,7 +929,7 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no, int is_test_addr, uuid_le inst_uuid, struct irq_info *intr) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no); /* chipset init'ed with bus bus has been previously created - @@ -988,7 +988,7 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no, int is_test_addr, uuid_le inst_uuid, struct irq_info *intr) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no); /* chipset init'ed with bus bus has been previously created - @@ -1038,7 +1038,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_add_vnic); int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); @@ -1058,7 +1058,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic); int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no) { - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; int rc; init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0); @@ -1089,7 +1089,7 @@ uislib_client_add_vnic(u32 busNo) BOOL busCreated = FALSE; int devNo = 0; /* Default to 0, since only one device * will be created for this bus... */ - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); msg.hdr.flags.test_message = 1; @@ -1137,7 +1137,7 @@ uislib_client_delete_vnic(u32 busNo) { int devNo = 0; /* Default to 0, since only one device * will be created for this bus... */ - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); msg.hdr.flags.test_message = 1; @@ -1563,7 +1563,7 @@ uislib_mod_init(void) LOGINF("sizeof(uiscmdrsp_net):%lu\n", (ulong) sizeof(struct uiscmdrsp_net)); LOGINF("sizeof(CONTROLVM_MESSAGE):%lu bytes\n", - (ulong) sizeof(CONTROLVM_MESSAGE)); + (ulong) sizeof(struct controlvm_message)); LOGINF("sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL):%lu bytes\n", (ulong) sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL)); LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n", diff --git a/drivers/staging/unisys/visorchipset/testing.h b/drivers/staging/unisys/visorchipset/testing.h index 015d502cbb16..573aa8b5ba6a 100644 --- a/drivers/staging/unisys/visorchipset/testing.h +++ b/drivers/staging/unisys/visorchipset/testing.h @@ -23,8 +23,9 @@ #include "globals.h" #include "controlvmchannel.h" -void test_produce_test_message(CONTROLVM_MESSAGE *msg, int isLocalTestAddr); -BOOL test_consume_test_message(CONTROLVM_MESSAGE *msg); +void test_produce_test_message(struct controlvm_message *msg, + int isLocalTestAddr); +BOOL test_consume_test_message(struct controlvm_message *msg); void test_manufacture_vnic_client_add(void *p); void test_manufacture_vnic_client_add_phys(HOSTADDRESS addr); void test_manufacture_preamble_messages(void); diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 966b1dd3e669..feae36885376 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -267,7 +267,7 @@ visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, VISORCHIPSET_BUSDEV_RESPONDERS *responders, struct ultra_vbus_deviceinfo *driverInfo); -typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (CONTROLVM_MESSAGE *msg, +typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, int status); void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response); @@ -285,9 +285,10 @@ BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context); int visorchipset_chipset_ready(void); int visorchipset_chipset_selftest(void); int visorchipset_chipset_notready(void); -void visorchipset_controlvm_respond_reportEvent(CONTROLVM_MESSAGE *msg, +void visorchipset_controlvm_respond_reportEvent(struct controlvm_message *msg, void *payload); -void visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type); +void visorchipset_save_message(struct controlvm_message *msg, + CRASH_OBJ_TYPE type); void *visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block, char *fn, int ln); void visorchipset_cache_free(struct kmem_cache *pool, void *p, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 753ea994f293..e94e13422b6d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -72,7 +72,7 @@ static struct workqueue_struct *Periodic_controlvm_workqueue; static DEFINE_SEMAPHORE(NotifierLock); typedef struct { - CONTROLVM_MESSAGE message; + struct controlvm_message message; unsigned int crc; } MESSAGE_ENVELOPE; @@ -136,7 +136,7 @@ static LIVEDUMP_INFO LiveDump_info; * this scenario, we simply stash the controlvm message, then attempt to * process it again the next time controlvm_periodic_work() runs. */ -static CONTROLVM_MESSAGE ControlVm_Pending_Msg; +static struct controlvm_message ControlVm_Pending_Msg; static BOOL ControlVm_Pending_Msg_Valid = FALSE; /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming) @@ -220,7 +220,7 @@ struct parahotplug_request { struct list_head list; int id; unsigned long expiration; - CONTROLVM_MESSAGE msg; + struct controlvm_message msg; }; static LIST_HEAD(Parahotplug_request_list); @@ -654,7 +654,7 @@ cleanup_controlvm_structures(void) } static void -chipset_init(CONTROLVM_MESSAGE *inmsg) +chipset_init(struct controlvm_message *inmsg) { static int chipset_inited; enum ultra_chipset_feature features = 0; @@ -687,10 +687,10 @@ Away: } static void -controlvm_init_response(CONTROLVM_MESSAGE *msg, +controlvm_init_response(struct controlvm_message *msg, struct controlvm_message_header *msgHdr, int response) { - memset(msg, 0, sizeof(CONTROLVM_MESSAGE)); + memset(msg, 0, sizeof(struct controlvm_message)); memcpy(&msg->hdr, msgHdr, sizeof(struct controlvm_message_header)); msg->hdr.payload_bytes = 0; msg->hdr.payload_vm_offset = 0; @@ -704,7 +704,7 @@ controlvm_init_response(CONTROLVM_MESSAGE *msg, static void controlvm_respond(struct controlvm_message_header *msgHdr, int response) { - CONTROLVM_MESSAGE outmsg; + struct controlvm_message outmsg; controlvm_init_response(&outmsg, msgHdr, response); /* For DiagPool channel DEVICE_CHANGESTATE, we need to send @@ -732,7 +732,7 @@ controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr, int response, enum ultra_chipset_feature features) { - CONTROLVM_MESSAGE outmsg; + struct controlvm_message outmsg; controlvm_init_response(&outmsg, msgHdr, response); outmsg.cmd.init_chipset.features = features; @@ -747,7 +747,7 @@ static void controlvm_respond_physdev_changestate( struct controlvm_message_header *msgHdr, int response, struct spar_segment_state state) { - CONTROLVM_MESSAGE outmsg; + struct controlvm_message outmsg; controlvm_init_response(&outmsg, msgHdr, response); outmsg.cmd.device_change_state.state = state; @@ -760,7 +760,7 @@ static void controlvm_respond_physdev_changestate( } void -visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type) +visorchipset_save_message(struct controlvm_message *msg, CRASH_OBJ_TYPE type) { u32 localSavedCrashMsgOffset; u16 localSavedCrashMsgCount; @@ -799,7 +799,8 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type) if (type == CRASH_bus) { if (visorchannel_write(ControlVm_channel, localSavedCrashMsgOffset, - msg, sizeof(CONTROLVM_MESSAGE)) < 0) { + msg, + sizeof(struct controlvm_message)) < 0) { LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!"); POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC, POSTCODE_SEVERITY_ERR); @@ -808,8 +809,8 @@ visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type) } else { if (visorchannel_write(ControlVm_channel, localSavedCrashMsgOffset + - sizeof(CONTROLVM_MESSAGE), msg, - sizeof(CONTROLVM_MESSAGE)) < 0) { + sizeof(struct controlvm_message), msg, + sizeof(struct controlvm_message)) < 0) { LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!"); POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC, POSTCODE_SEVERITY_ERR); @@ -864,7 +865,7 @@ device_changestate_responder(enum controlvm_id cmdId, struct spar_segment_state responseState) { VISORCHIPSET_DEVICE_INFO *p = NULL; - CONTROLVM_MESSAGE outmsg; + struct controlvm_message outmsg; p = finddevice(&DevInfoList, busNo, devNo); if (!p) { @@ -1095,7 +1096,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, } static void -bus_create(CONTROLVM_MESSAGE *inmsg) +bus_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->create_bus.bus_no; @@ -1149,7 +1150,7 @@ Away: } static void -bus_destroy(CONTROLVM_MESSAGE *inmsg) +bus_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->destroy_bus.bus_no; @@ -1175,7 +1176,7 @@ Away: } static void -bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) +bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->configure_bus.bus_no; @@ -1226,7 +1227,7 @@ Away: } static void -my_device_create(CONTROLVM_MESSAGE *inmsg) +my_device_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->create_device.bus_no; @@ -1304,7 +1305,7 @@ Away: } static void -my_device_changestate(CONTROLVM_MESSAGE *inmsg) +my_device_changestate(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->device_change_state.bus_no; @@ -1338,7 +1339,7 @@ Away: } static void -my_device_destroy(CONTROLVM_MESSAGE *inmsg) +my_device_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->destroy_device.bus_no; @@ -1536,7 +1537,7 @@ chipset_notready(struct controlvm_message_header *msgHdr) * CONTROLVM_QUEUE_EVENT queue in the controlvm channel. */ static BOOL -read_controlvm_event(CONTROLVM_MESSAGE *msg) +read_controlvm_event(struct controlvm_message *msg) { if (visorchannel_signalremove(ControlVm_channel, CONTROLVM_QUEUE_EVENT, msg)) { @@ -1593,7 +1594,7 @@ parahotplug_next_expiration(void) * CONTROLVM_MESSAGE that we can stick on a list */ static struct parahotplug_request * -parahotplug_request_create(CONTROLVM_MESSAGE *msg) +parahotplug_request_create(struct controlvm_message *msg) { struct parahotplug_request *req = kmalloc(sizeof(struct parahotplug_request), @@ -1723,7 +1724,7 @@ parahotplug_request_complete(int id, u16 active) * Enables or disables a PCI device by kicking off a udev script */ static void -parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) +parahotplug_process_message(struct controlvm_message *inmsg) { struct parahotplug_request *req; @@ -1775,14 +1776,14 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) * either successfully or with an error. */ static BOOL -handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) +handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr) { struct controlvm_message_packet *cmd = &inmsg.cmd; u64 parametersAddr = 0; u32 parametersBytes = 0; PARSER_CONTEXT *parser_ctx = NULL; BOOL isLocalAddr = FALSE; - CONTROLVM_MESSAGE ackmsg; + struct controlvm_message ackmsg; /* create parsing context if necessary */ isLocalAddr = (inmsg.hdr.flags.test_message == 1); @@ -1931,7 +1932,7 @@ static void controlvm_periodic_work(struct work_struct *work) { VISORCHIPSET_CHANNEL_INFO chanInfo; - CONTROLVM_MESSAGE inmsg; + struct controlvm_message inmsg; BOOL gotACommand = FALSE; BOOL handle_command_failed = FALSE; static u64 Poll_Count; @@ -2040,9 +2041,9 @@ static void setup_crash_devices_work_queue(struct work_struct *work) { - CONTROLVM_MESSAGE localCrashCreateBusMsg; - CONTROLVM_MESSAGE localCrashCreateDevMsg; - CONTROLVM_MESSAGE msg; + struct controlvm_message localCrashCreateBusMsg; + struct controlvm_message localCrashCreateDevMsg; + struct controlvm_message msg; u32 localSavedCrashMsgOffset; u16 localSavedCrashMsgCount; @@ -2100,7 +2101,7 @@ setup_crash_devices_work_queue(struct work_struct *work) if (visorchannel_read(ControlVm_channel, localSavedCrashMsgOffset, &localCrashCreateBusMsg, - sizeof(CONTROLVM_MESSAGE)) < 0) { + sizeof(struct controlvm_message)) < 0) { LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!"); POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC, POSTCODE_SEVERITY_ERR); @@ -2110,9 +2111,9 @@ setup_crash_devices_work_queue(struct work_struct *work) /* read create device message for storage device */ if (visorchannel_read(ControlVm_channel, localSavedCrashMsgOffset + - sizeof(CONTROLVM_MESSAGE), + sizeof(struct controlvm_message), &localCrashCreateDevMsg, - sizeof(CONTROLVM_MESSAGE)) < 0) { + sizeof(struct controlvm_message)) < 0) { LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!"); POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC, POSTCODE_SEVERITY_ERR); -- cgit v1.2.3-59-g8ed1b From a348e0dcca13bd2823629622bc7fc9d0319e5e72 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:32 -0400 Subject: staging: unisys: refactor DEVICE_MAP Get rid of the typedef for DEVICE_MAP and use struct device_map instead. Fix CamelCase names. DeviceChannelSize => device_channel_size CA_Index => ca_index Reserved => reserved Reserved2 => reserved2 Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 8bc2e174ddcc..5aff65dd9d04 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -342,20 +342,20 @@ struct controlvm_message { struct controlvm_message_packet cmd; }; -typedef struct _DEVICE_MAP { - GUEST_PHYSICAL_ADDRESS DeviceChannelAddress; - u64 DeviceChannelSize; - u32 CA_Index; - u32 Reserved; /* natural alignment */ - u64 Reserved2; /* Align structure on 32-byte boundary */ -} DEVICE_MAP; +struct device_map { + GUEST_PHYSICAL_ADDRESS device_channel_address; + u64 device_channel_size; + u32 ca_index; + u32 reserved; /* natural alignment */ + u64 reserved2; /* Align structure on 32-byte boundary */ +}; typedef struct _GUEST_DEVICES { - DEVICE_MAP VideoChannel; - DEVICE_MAP KeyboardChannel; - DEVICE_MAP NetworkChannel; - DEVICE_MAP StorageChannel; - DEVICE_MAP ConsoleChannel; + struct device_map VideoChannel; + struct device_map KeyboardChannel; + struct device_map NetworkChannel; + struct device_map StorageChannel; + struct device_map ConsoleChannel; u32 PartitionIndex; u32 Pad; } GUEST_DEVICES; -- cgit v1.2.3-59-g8ed1b From 6f5a5b7b501e38fa6cc6faae39a19b819f712a11 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:33 -0400 Subject: staging: unisys: refactor GUEST_DEVICES Remove the typedef from GUEST_DEVICES and switch to struct guest_devices. Fix CamelCase names and update all references to renamed members. VideoChannel => video_channel KeyboardChannel => keyboard_channel NetworkChannel => network_channel StorageChannel => storage_channel ConsoleChannel => console_channel PartitionIndex => partition_index Pad => pad Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/controlvmchannel.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 5aff65dd9d04..363967a55267 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -350,15 +350,15 @@ struct device_map { u64 reserved2; /* Align structure on 32-byte boundary */ }; -typedef struct _GUEST_DEVICES { - struct device_map VideoChannel; - struct device_map KeyboardChannel; - struct device_map NetworkChannel; - struct device_map StorageChannel; - struct device_map ConsoleChannel; - u32 PartitionIndex; - u32 Pad; -} GUEST_DEVICES; +struct guest_devices { + struct device_map video_channel; + struct device_map keyboard_channel; + struct device_map network_channel; + struct device_map storage_channel; + struct device_map console_channel; + u32 partition_index; + u32 pad; +}; typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { struct channel_header Header; @@ -394,7 +394,7 @@ typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { GUEST_PHYSICAL_ADDRESS gpPhysicalSmbiosTable; /* guest phys addr of * SMBIOS table */ /* ULTRA_MAX_GUESTS_PER_SERVICE */ - GUEST_DEVICES gpObsoleteGuestDevices[16]; + struct guest_devices gpObsoleteGuestDevices[16]; /* guest physical address of EFI firmware image base */ GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareImageBase; -- cgit v1.2.3-59-g8ed1b From d19642f656c88e57a7e8b68730126cde591fe217 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:34 -0400 Subject: staging: unisys: refactor SPAR_CONTROLVM_CHANNEL_PROTOCOL Get rid of the typedef for SPAR_CONTROLVM_CHANNEL_PROTOCOL and replace it with struct spar_controlvm_channel_protocol. Fix CamelCase members of the structure and update all references to changed names. Header => header gpControlVm => gp_control_vm gpPartitionTables => gp_partition_tables gpDiagGuest => gp_diag_guest gpBootRomDisk => gp_boot_romdisk gpBootRamDisk => gp_boot_ramdisk gpAcpiTable => gp_acpi_table gpControlChannel => gp_control_channel gpdiagRomDisk => gp_diag_romdisk gpNvram => gp_nvram RequestPayloadOffset => request_payload_offset EventPayloadOffset => event_payload_offset RequestPayloadBytes => request_payload_bytes EventPayloadBytes => event_payload_bytes ControlChannelBytes => control_channel_bytes NvramChannelBytes => nvram_channel_bytes MessageBytes => message_bytes MessageCount => message_count gpSmbiosTable => gp_smbios_table gpPhysicalSmbiosTable => gp_physical_smbios_table gpobsoleteGuestDevices => gp_obsolete_guest_devices VirtualGuestFirmwareImageBase => virtual_guest_firmware_image_base VirtualGuestFirmwareEntryPoint => virtual_guest_firmware_entry_point VirtualGuestFirmwareImageSize => virtual_guest_firmware_image_size VirtualGuestFirmwareBootBase => virtual_guest_firmware_boot_base VirtualGuestImageBase => virtual_guest_image_base VirtualGuestImageSize => virtual_guest_image_size PrototypeControlChannelOffset => prototype_control_channel_offset VirtualGuestPartitionHandle => virtual_guest_partition_handle RestoreAction => restore_action DumpAction => dump_action NvramFailCount => nvram_fail_count SavedCrashMsgCount => saved_crash_message_count SavedCrashMsgOffset => saved_crash_message_offset InstallationError => installation_error InstallationTextId => installation_text_id InstallationRemainingSteps => installation_remaining_steps ToolAction => tool_action Reserved => reserved EfiSparIndication => efi_spar_ind EfiSparIndicationSupported => efi_spar_ind_supported SPReserved => sp_reserved Reserved2 => reserved2 RequestQueue => request_queue ResponseQueue => response_queue EventQueue => event_queue EventAckQueue => event_ack_queue RequestMsg => request_msg ResponseMsg => response_msg EventMsg => event_msg EventAckMsg => event_ack_msg SavedCrashMsg => saved_crash_msg Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 156 ++++++++++----------- drivers/staging/unisys/uislib/uislib.c | 4 +- drivers/staging/unisys/visorchipset/file.c | 6 +- .../unisys/visorchipset/visorchipset_main.c | 62 ++++---- 4 files changed, 114 insertions(+), 114 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 363967a55267..c949cd47cc82 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -47,11 +47,11 @@ static const uuid_le spar_controlvm_channel_protocol_uuid = #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \ spar_check_channel_client(ch, \ - spar_controlvm_channel_protocol_uuid, \ - "controlvm", \ - sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE) + spar_controlvm_channel_protocol_uuid, \ + "controlvm", \ + sizeof(struct spar_controlvm_channel_protocol), \ + ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ + ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE) #define MY_DEVICE_INDEX 0 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ @@ -360,127 +360,127 @@ struct guest_devices { u32 pad; }; -typedef struct _ULTRA_CONTROLVM_CHANNEL_PROTOCOL { - struct channel_header Header; - GUEST_PHYSICAL_ADDRESS gpControlVm; /* guest physical address of +struct spar_controlvm_channel_protocol { + struct channel_header header; + GUEST_PHYSICAL_ADDRESS gp_controlvm; /* guest physical address of * this channel */ - GUEST_PHYSICAL_ADDRESS gpPartitionTables; /* guest physical address of - * partition tables */ - GUEST_PHYSICAL_ADDRESS gpDiagGuest; /* guest physical address of + GUEST_PHYSICAL_ADDRESS gp_partition_tables;/* guest physical address of + * partition tables */ + GUEST_PHYSICAL_ADDRESS gp_diag_guest; /* guest physical address of * diagnostic channel */ - GUEST_PHYSICAL_ADDRESS gpBootRomDisk; /* guest phys addr of (read + GUEST_PHYSICAL_ADDRESS gp_boot_romdisk;/* guest phys addr of (read * only) Boot ROM disk */ - GUEST_PHYSICAL_ADDRESS gpBootRamDisk; /* guest phys addr of writable + GUEST_PHYSICAL_ADDRESS gp_boot_ramdisk;/* guest phys addr of writable * Boot RAM disk */ - GUEST_PHYSICAL_ADDRESS gpAcpiTable; /* guest phys addr of acpi + GUEST_PHYSICAL_ADDRESS gp_acpi_table; /* guest phys addr of acpi * table */ - GUEST_PHYSICAL_ADDRESS gpControlChannel; /* guest phys addr of control - * channel */ - GUEST_PHYSICAL_ADDRESS gpDiagRomDisk; /* guest phys addr of diagnostic + GUEST_PHYSICAL_ADDRESS gp_control_channel;/* guest phys addr of control + * channel */ + GUEST_PHYSICAL_ADDRESS gp_diag_romdisk;/* guest phys addr of diagnostic * ROM disk */ - GUEST_PHYSICAL_ADDRESS gpNvram; /* guest phys addr of NVRAM + GUEST_PHYSICAL_ADDRESS gp_nvram; /* guest phys addr of NVRAM * channel */ - u64 RequestPayloadOffset; /* Offset to request payload area */ - u64 EventPayloadOffset; /* Offset to event payload area */ - u32 RequestPayloadBytes; /* Bytes available in request payload + u64 request_payload_offset; /* Offset to request payload area */ + u64 event_payload_offset; /* Offset to event payload area */ + u32 request_payload_bytes; /* Bytes available in request payload * area */ - u32 EventPayloadBytes; /* Bytes available in event payload area */ - u32 ControlChannelBytes; - u32 NvramChannelBytes; /* Bytes in PartitionNvram segment */ - u32 MessageBytes; /* sizeof(CONTROLVM_MESSAGE) */ - u32 MessageCount; /* CONTROLVM_MESSAGE_MAX */ - GUEST_PHYSICAL_ADDRESS gpSmbiosTable; /* guest phys addr of SMBIOS + u32 event_payload_bytes;/* Bytes available in event payload area */ + u32 control_channel_bytes; + u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */ + u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */ + u32 message_count; /* CONTROLVM_MESSAGE_MAX */ + GUEST_PHYSICAL_ADDRESS gp_smbios_table;/* guest phys addr of SMBIOS * tables */ - GUEST_PHYSICAL_ADDRESS gpPhysicalSmbiosTable; /* guest phys addr of - * SMBIOS table */ + GUEST_PHYSICAL_ADDRESS gp_physical_smbios_table;/* guest phys addr of + * SMBIOS table */ /* ULTRA_MAX_GUESTS_PER_SERVICE */ - struct guest_devices gpObsoleteGuestDevices[16]; + struct guest_devices gp_obsolete_guest_devices[16]; /* guest physical address of EFI firmware image base */ - GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareImageBase; + GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_image_base; /* guest physical address of EFI firmware entry point */ - GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareEntryPoint; + GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_entry_point; /* guest EFI firmware image size */ - u64 VirtualGuestFirmwareImageSize; + u64 virtual_guest_firmware_image_size; /* GPA = 1MB where EFI firmware image is copied to */ - GUEST_PHYSICAL_ADDRESS VirtualGuestFirmwareBootBase; - GUEST_PHYSICAL_ADDRESS VirtualGuestImageBase; - GUEST_PHYSICAL_ADDRESS VirtualGuestImageSize; - u64 PrototypeControlChannelOffset; - GUEST_PHYSICAL_ADDRESS VirtualGuestPartitionHandle; + GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_boot_base; + GUEST_PHYSICAL_ADDRESS virtual_guest_image_base; + GUEST_PHYSICAL_ADDRESS virtual_guest_image_size; + u64 prototype_control_channel_offset; + GUEST_PHYSICAL_ADDRESS virtual_guest_partition_handle; - u16 RestoreAction; /* Restore Action field to restore the guest + u16 restore_action; /* Restore Action field to restore the guest * partition */ - u16 DumpAction; /* For Windows guests it shows if the visordisk + u16 dump_action; /* For Windows guests it shows if the visordisk * is running in dump mode */ - u16 NvramFailCount; - u16 SavedCrashMsgCount; /* = CONTROLVM_CRASHMSG_MAX */ - u32 SavedCrashMsgOffset; /* Offset to request payload area needed + u16 nvram_fail_count; + u16 saved_crash_message_count; /* = CONTROLVM_CRASHMSG_MAX */ + u32 saved_crash_message_offset; /* Offset to request payload area needed * for crash dump */ - u32 InstallationError; /* Type of error encountered during + u32 installation_error; /* Type of error encountered during * installation */ - u32 InstallationTextId; /* Id of string to display */ - u16 InstallationRemainingSteps; /* Number of remaining installation - * steps (for progress bars) */ - u8 ToolAction; /* ULTRA_TOOL_ACTIONS Installation Action + u32 installation_text_id; /* Id of string to display */ + u16 installation_remaining_steps;/* Number of remaining installation + * steps (for progress bars) */ + u8 tool_action; /* ULTRA_TOOL_ACTIONS Installation Action * field */ - u8 Reserved; /* alignment */ - struct efi_spar_indication EfiSparIndication; - struct efi_spar_indication EfiSparIndicationSupported; - u32 SPReserved; - u8 Reserved2[28]; /* Force signals to begin on 128-byte cache + u8 reserved; /* alignment */ + struct efi_spar_indication efi_spar_ind; + struct efi_spar_indication efi_spar_ind_supported; + u32 sp_reserved; + u8 reserved2[28]; /* Force signals to begin on 128-byte cache * line */ - struct signal_queue_header RequestQueue;/* Service or guest partition - * uses this queue to send - * requests to Control */ - struct signal_queue_header ResponseQueue;/* Control uses this queue to - * respond to service or guest - * partition requests */ - struct signal_queue_header EventQueue; /* Control uses this queue to + struct signal_queue_header request_queue;/* Service or guest partition + * uses this queue to send + * requests to Control */ + struct signal_queue_header response_queue;/* Control uses this queue to + * respond to service or guest + * partition requests */ + struct signal_queue_header event_queue; /* Control uses this queue to * send events to service or * guest partition */ - struct signal_queue_header EventAckQueue;/* Service or guest partition - * uses this queue to ack - * Control events */ + struct signal_queue_header event_ack_queue;/* Service or guest partition + * uses this queue to ack + * Control events */ /* Request fixed-size message pool - does not include payload */ - struct controlvm_message RequestMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX]; /* Response fixed-size message pool - does not include payload */ - struct controlvm_message ResponseMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX]; /* Event fixed-size message pool - does not include payload */ - struct controlvm_message EventMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX]; /* Ack fixed-size message pool - does not include payload */ - struct controlvm_message EventAckMsg[CONTROLVM_MESSAGE_MAX]; + struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX]; /* Message stored during IOVM creation to be reused after crash */ - struct controlvm_message SavedCrashMsg[CONTROLVM_CRASHMSG_MAX]; -} ULTRA_CONTROLVM_CHANNEL_PROTOCOL; + struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX]; +}; /* Offsets for VM channel attributes... */ #define VM_CH_REQ_QUEUE_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, RequestQueue) + offsetof(struct spar_controlvm_channel_protocol, request_queue) #define VM_CH_RESP_QUEUE_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ResponseQueue) + offsetof(struct spar_controlvm_channel_protocol, response_queue) #define VM_CH_EVENT_QUEUE_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventQueue) + offsetof(struct spar_controlvm_channel_protocol, event_queue) #define VM_CH_ACK_QUEUE_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventAckQueue) + offsetof(struct spar_controlvm_channel_protocol, event_ack_queue) #define VM_CH_REQ_MSG_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, RequestMsg) + offsetof(struct spar_controlvm_channel_protocol, request_msg) #define VM_CH_RESP_MSG_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ResponseMsg) + offsetof(struct spar_controlvm_channel_protocol, response_msg) #define VM_CH_EVENT_MSG_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventMsg) + offsetof(struct spar_controlvm_channel_protocol, event_msg) #define VM_CH_ACK_MSG_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EventAckMsg) + offsetof(struct spar_controlvm_channel_protocol, event_ack_msg) #define VM_CH_CRASH_MSG_OFFSET \ - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, SavedCrashMsg) + offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg) /* The following header will be located at the beginning of PayloadVmOffset for * various ControlVm commands. The receiver of a ControlVm command with a diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 513e00d2f979..b8db2700a1df 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1564,8 +1564,8 @@ uislib_mod_init(void) (ulong) sizeof(struct uiscmdrsp_net)); LOGINF("sizeof(CONTROLVM_MESSAGE):%lu bytes\n", (ulong) sizeof(struct controlvm_message)); - LOGINF("sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL):%lu bytes\n", - (ulong) sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL)); + LOGINF("sizeof(struct spar_controlvm_channel_protocol):%lu bytes\n", + (ulong) sizeof(struct spar_controlvm_channel_protocol)); LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n", (ulong) sizeof(struct channel_header)); LOGINF("sizeof(ULTRA_IO_CHANNEL_PROTOCOL):%lu bytes\n", diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 3321764069de..373fa36b7119 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -155,9 +155,9 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma) return -ENXIO; } visorchannel_read(*PControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - gpControlChannel), &addr, - sizeof(addr)); + offsetof(struct spar_controlvm_channel_protocol, + gp_control_channel), + &addr, sizeof(addr)); if (addr == 0) { ERRDRV("%s control channel address is 0", __func__); return -ENXIO; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e94e13422b6d..392e046be359 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -360,8 +360,8 @@ static ssize_t toolaction_show(struct device *dev, u8 toolAction; visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - ToolAction), &toolAction, sizeof(u8)); + offsetof(struct spar_controlvm_channel_protocol, + tool_action), &toolAction, sizeof(u8)); return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction); } @@ -376,7 +376,7 @@ static ssize_t toolaction_store(struct device *dev, return -EINVAL; ret = visorchannel_write(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ToolAction), + offsetof(struct spar_controlvm_channel_protocol, tool_action), &toolAction, sizeof(u8)); if (ret) @@ -391,8 +391,8 @@ static ssize_t boottotool_show(struct device *dev, struct efi_spar_indication efiSparIndication; visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - EfiSparIndication), &efiSparIndication, + offsetof(struct spar_controlvm_channel_protocol, + efi_spar_ind), &efiSparIndication, sizeof(struct efi_spar_indication)); return scnprintf(buf, PAGE_SIZE, "%u\n", efiSparIndication.boot_to_tool); @@ -410,8 +410,8 @@ static ssize_t boottotool_store(struct device *dev, efiSparIndication.boot_to_tool = val; ret = visorchannel_write(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - EfiSparIndication), + offsetof(struct spar_controlvm_channel_protocol, + efi_spar_ind), &(efiSparIndication), sizeof(struct efi_spar_indication)); @@ -426,7 +426,7 @@ static ssize_t error_show(struct device *dev, struct device_attribute *attr, u32 error; visorchannel_read(ControlVm_channel, offsetof( - ULTRA_CONTROLVM_CHANNEL_PROTOCOL, InstallationError), + struct spar_controlvm_channel_protocol, installation_error), &error, sizeof(u32)); return scnprintf(buf, PAGE_SIZE, "%i\n", error); } @@ -441,8 +441,8 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr, return -EINVAL; ret = visorchannel_write(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - InstallationError), + offsetof(struct spar_controlvm_channel_protocol, + installation_error), &error, sizeof(u32)); if (ret) return ret; @@ -455,7 +455,7 @@ static ssize_t textid_show(struct device *dev, struct device_attribute *attr, u32 textId; visorchannel_read(ControlVm_channel, offsetof( - ULTRA_CONTROLVM_CHANNEL_PROTOCOL, InstallationTextId), + struct spar_controlvm_channel_protocol, installation_text_id), &textId, sizeof(u32)); return scnprintf(buf, PAGE_SIZE, "%i\n", textId); } @@ -470,8 +470,8 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr, return -EINVAL; ret = visorchannel_write(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - InstallationTextId), + offsetof(struct spar_controlvm_channel_protocol, + installation_text_id), &textId, sizeof(u32)); if (ret) return ret; @@ -485,8 +485,8 @@ static ssize_t remaining_steps_show(struct device *dev, u16 remainingSteps; visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - InstallationRemainingSteps), + offsetof(struct spar_controlvm_channel_protocol, + installation_remaining_steps), &remainingSteps, sizeof(u16)); return scnprintf(buf, PAGE_SIZE, "%hu\n", remainingSteps); @@ -502,8 +502,8 @@ static ssize_t remaining_steps_store(struct device *dev, return -EINVAL; ret = visorchannel_write(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - InstallationRemainingSteps), + offsetof(struct spar_controlvm_channel_protocol, + installation_remaining_steps), &remainingSteps, sizeof(u16)); if (ret) return ret; @@ -767,8 +767,8 @@ visorchipset_save_message(struct controlvm_message *msg, CRASH_OBJ_TYPE type) /* get saved message count */ if (visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - SavedCrashMsgCount), + offsetof(struct spar_controlvm_channel_protocol, + saved_crash_message_count), &localSavedCrashMsgCount, sizeof(u16)) < 0) { LOGERR("failed to get Saved Message Count"); POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, @@ -787,8 +787,8 @@ visorchipset_save_message(struct controlvm_message *msg, CRASH_OBJ_TYPE type) /* get saved crash message offset */ if (visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - SavedCrashMsgOffset), + offsetof(struct spar_controlvm_channel_protocol, + saved_crash_message_offset), &localSavedCrashMsgOffset, sizeof(u32)) < 0) { LOGERR("failed to get Saved Message Offset"); POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, @@ -1389,7 +1389,7 @@ initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes, } memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO)); if ((offset == 0) || (bytes == 0)) { - LOGERR("CONTROLVM_PAYLOAD_INIT Failed: RequestPayloadOffset=%llu RequestPayloadBytes=%llu!", + LOGERR("CONTROLVM_PAYLOAD_INIT Failed: request_payload_offset=%llu request_payload_bytes=%llu!", (u64) offset, (u64) bytes); rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; goto Away; @@ -1436,8 +1436,8 @@ initialize_controlvm_payload(void) u32 payloadBytes = 0; if (visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - RequestPayloadOffset), + offsetof(struct spar_controlvm_channel_protocol, + request_payload_offset), &payloadOffset, sizeof(payloadOffset)) < 0) { LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!"); POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC, @@ -1445,8 +1445,8 @@ initialize_controlvm_payload(void) return; } if (visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - RequestPayloadBytes), + offsetof(struct spar_controlvm_channel_protocol, + request_payload_bytes), &payloadBytes, sizeof(payloadBytes)) < 0) { LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!"); POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC, @@ -2068,8 +2068,8 @@ setup_crash_devices_work_queue(struct work_struct *work) /* get saved message count */ if (visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - SavedCrashMsgCount), + offsetof(struct spar_controlvm_channel_protocol, + saved_crash_message_count), &localSavedCrashMsgCount, sizeof(u16)) < 0) { LOGERR("failed to get Saved Message Count"); POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, @@ -2088,8 +2088,8 @@ setup_crash_devices_work_queue(struct work_struct *work) /* get saved crash message offset */ if (visorchannel_read(ControlVm_channel, - offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, - SavedCrashMsgOffset), + offsetof(struct spar_controlvm_channel_protocol, + saved_crash_message_offset), &localSavedCrashMsgOffset, sizeof(u32)) < 0) { LOGERR("failed to get Saved Message Offset"); POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, @@ -2385,7 +2385,7 @@ visorchipset_init(void) ControlVm_channel = visorchannel_create_with_lock (addr, - sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), + sizeof(struct spar_controlvm_channel_protocol), spar_controlvm_channel_protocol_uuid); if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT( visorchannel_get_header(ControlVm_channel))) { -- cgit v1.2.3-59-g8ed1b From 6242089330454dd5abb5dcd9726944b0176ed249 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:35 -0400 Subject: staging: unisys: refactor ULTRA_CONTROLVM_PARAMETERS_HEADER Remove the typedef from ULTRA_CONTROLVM_PARAMETERS_HEADER, and use struct spar_controlvm_parameters_header instead. Fix CamelCase names in the structure, and update references to fixed names in other files and the comments. TotalLength => total_length HeaderLength => header_length ConnectionOffset => connection_offset ConnectionLength => connection_length InitiatorOffset => initiator_offset InitiatorLength => initiator_length TargetOffset => target_offset TargetLength => target_length ClientOffset => client_offset ClientLength => client_length NameOffset => name_offset NameLength => name_length Id => id Revision => revision Reserved => reserved Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../include/channels/controlvmchannel.h | 48 ++++++++++----------- drivers/staging/unisys/visorchipset/parser.c | 50 +++++++++++----------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index c949cd47cc82..4633b786fd55 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -483,31 +483,29 @@ struct spar_controlvm_channel_protocol { offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg) /* The following header will be located at the beginning of PayloadVmOffset for - * various ControlVm commands. The receiver of a ControlVm command with a - * PayloadVmOffset will dereference this address and then use ConnectionOffset, - * InitiatorOffset, and TargetOffset to get the location of UTF-8 formatted - * strings that can be parsed to obtain command-specific information. The value - * of TotalLength should equal PayloadBytes. The format of the strings at - * PayloadVmOffset will take different forms depending on the message. See the - * following Wiki page for more information: - * https://ustr-linux-1.na.uis.unisys.com/spar/index.php/ControlVm_Parameters_Area + * various ControlVm commands. The receiver of a ControlVm command with a + * PayloadVmOffset will dereference this address and then use connection_offset, + * initiator_offset, and target_offset to get the location of UTF-8 formatted + * strings that can be parsed to obtain command-specific information. The value + * of total_length should equal PayloadBytes. The format of the strings at + * PayloadVmOffset will take different forms depending on the message. */ -typedef struct _ULTRA_CONTROLVM_PARAMETERS_HEADER { - u32 TotalLength; - u32 HeaderLength; - u32 ConnectionOffset; - u32 ConnectionLength; - u32 InitiatorOffset; - u32 InitiatorLength; - u32 TargetOffset; - u32 TargetLength; - u32 ClientOffset; - u32 ClientLength; - u32 NameOffset; - u32 NameLength; - uuid_le Id; - u32 Revision; - u32 Reserved; /* Natural alignment */ -} ULTRA_CONTROLVM_PARAMETERS_HEADER; +struct spar_controlvm_parameters_header { + u32 total_length; + u32 header_length; + u32 connection_offset; + u32 connection_length; + u32 initiator_offset; + u32 initiator_length; + u32 target_offset; + u32 target_length; + u32 client_offset; + u32 client_length; + u32 name_offset; + u32 name_length; + uuid_le id; + u32 revision; + u32 reserved; /* Natural alignment */ +}; #endif /* __CONTROLVMCHANNEL_H__ */ diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index 661aaae9b154..6c2eac0346b6 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -48,7 +48,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, PARSER_CONTEXT *rc = NULL; PARSER_CONTEXT *ctx = NULL; MEMREGION *rgn = NULL; - ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL; + struct spar_controlvm_parameters_header *phdr = NULL; if (tryAgain) *tryAgain = FALSE; @@ -110,27 +110,29 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, rc = ctx; goto Away; } - phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data); - if (phdr->TotalLength != bytes) { + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); + if (phdr->total_length != bytes) { ERRDRV("%s - bad total length %lu (should be %lu)", __func__, - (ulong) (phdr->TotalLength), (ulong) (bytes)); + (ulong) (phdr->total_length), (ulong) (bytes)); rc = NULL; goto Away; } - if (phdr->TotalLength < phdr->HeaderLength) { + if (phdr->total_length < phdr->header_length) { ERRDRV("%s - total length < header length (%lu < %lu)", __func__, - (ulong) (phdr->TotalLength), - (ulong) (phdr->HeaderLength)); + (ulong) (phdr->total_length), + (ulong) (phdr->header_length)); rc = NULL; goto Away; } - if (phdr->HeaderLength < sizeof(ULTRA_CONTROLVM_PARAMETERS_HEADER)) { + if (phdr->header_length < + sizeof(struct spar_controlvm_parameters_header)) { ERRDRV("%s - header is too small (%lu < %lu)", __func__, - (ulong) (phdr->HeaderLength), - (ulong) (sizeof(ULTRA_CONTROLVM_PARAMETERS_HEADER))); + (ulong) (phdr->header_length), + (ulong)(sizeof( + struct spar_controlvm_parameters_header))); rc = NULL; goto Away; } @@ -159,7 +161,7 @@ parser_init(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain) } /* Call this instead of parser_init() if the payload area consists of just - * a sequence of bytes, rather than a ULTRA_CONTROLVM_PARAMETERS_HEADER + * a sequence of bytes, rather than a struct spar_controlvm_parameters_header * structures. Afterwards, you can call parser_simpleString_get() or * parser_byteStream_get() to obtain the data. */ @@ -196,44 +198,44 @@ parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes) uuid_le parser_id_get(PARSER_CONTEXT *ctx) { - ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL; + struct spar_controlvm_parameters_header *phdr = NULL; if (ctx == NULL) { ERRDRV("%s (%s:%d) - no context", __func__, __FILE__, __LINE__); return NULL_UUID_LE; } - phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data); - return phdr->Id; + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); + return phdr->id; } void parser_param_start(PARSER_CONTEXT *ctx, PARSER_WHICH_STRING which_string) { - ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL; + struct spar_controlvm_parameters_header *phdr = NULL; if (ctx == NULL) { ERRDRV("%s (%s:%d) - no context", __func__, __FILE__, __LINE__); goto Away; } - phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data); + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); switch (which_string) { case PARSERSTRING_INITIATOR: - ctx->curr = ctx->data + phdr->InitiatorOffset; - ctx->bytes_remaining = phdr->InitiatorLength; + ctx->curr = ctx->data + phdr->initiator_offset; + ctx->bytes_remaining = phdr->initiator_length; break; case PARSERSTRING_TARGET: - ctx->curr = ctx->data + phdr->TargetOffset; - ctx->bytes_remaining = phdr->TargetLength; + ctx->curr = ctx->data + phdr->target_offset; + ctx->bytes_remaining = phdr->target_length; break; case PARSERSTRING_CONNECTION: - ctx->curr = ctx->data + phdr->ConnectionOffset; - ctx->bytes_remaining = phdr->ConnectionLength; + ctx->curr = ctx->data + phdr->connection_offset; + ctx->bytes_remaining = phdr->connection_length; break; case PARSERSTRING_NAME: - ctx->curr = ctx->data + phdr->NameOffset; - ctx->bytes_remaining = phdr->NameLength; + ctx->curr = ctx->data + phdr->name_offset; + ctx->bytes_remaining = phdr->name_length; break; default: ERRDRV("%s - bad which_string %d", __func__, which_string); -- cgit v1.2.3-59-g8ed1b From 9921b74d48bb131ca21e6db84476445070bc23cb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:36 -0400 Subject: staging: unisys: fix misspelled word in controlvmchannel.h "intrrupt" should be "interrupt" in the comments in controlvmchannel.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 4633b786fd55..a66db7968d6c 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -127,7 +127,7 @@ struct irq_info { /**< specifies interrupt handle. It is used to retrieve the * corresponding interrupt pin from Monitor; and the * interrupt pin is used to connect to the corresponding - * intrrupt. Used by IOPart-GP only. */ + * interrupt. Used by IOPart-GP only. */ u64 recv_irq_handle; /**< specifies interrupt vector. It, interrupt pin, and shared are -- cgit v1.2.3-59-g8ed1b From e926cd5958d0554b0458f3ae9bf5288094aea902 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:37 -0400 Subject: staging: unisys: refactor UltraDiagChannelProtocolGuid Fix the CamelCase name: UltraDiagChannelProtocolGuid => spar_diag_channel_protocol_uuid Also, rename ULTRA_DIAG_CHANNEL_PROTOCOL_GUID to SPAR_DIAG_CHANNEL_PROTOCOL_UUID to match the new variable name. Update all references to the changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/diagchannel.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 4132642aa05b..920dc361750e 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -37,12 +37,12 @@ #include "channel.h" /* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */ -#define ULTRA_DIAG_CHANNEL_PROTOCOL_GUID \ +#define SPAR_DIAG_CHANNEL_PROTOCOL_UUID \ UUID_LE(0xeea7a573, 0xdb82, 0x447c, \ 0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58) -static const uuid_le UltraDiagChannelProtocolGuid = - ULTRA_DIAG_CHANNEL_PROTOCOL_GUID; +static const uuid_le spar_diag_channel_protocol_uuid = + SPAR_DIAG_CHANNEL_PROTOCOL_UUID; /* {E850F968-3263-4484-8CA5-2A35D087A5A8} */ #define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \ @@ -60,13 +60,13 @@ static const uuid_le UltraDiagChannelProtocolGuid = #define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, \ - UltraDiagChannelProtocolGuid, \ + spar_diag_channel_protocol_uuid, \ "diag", \ sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) #define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(UltraDiagChannelProtocolGuid, \ + (spar_check_channel_server(spar_diag_channel_protocol_uuid, \ "diag", \ sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ actualBytes)) -- cgit v1.2.3-59-g8ed1b From a2c758e2010c4b30bc33de57d76c2d2d153166f8 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:38 -0400 Subject: staging: unisys: refactor ULTRA_DIAG_CHANNEL_OK_CLIENT Rename this macro to SPAR_DIAG_CHANNEL_OK_CLIENT, fix the CamelCase parameter and get rid of the unused LogCtx parameter. pChannel => ch Fix the indentation and add a blank line after the macro definition so it looks nicer. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/diagchannel.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 920dc361750e..13fe4751ca79 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -58,13 +58,14 @@ static const uuid_le spar_diag_channel_protocol_uuid = * increment this. */ #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2 -#define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (spar_check_channel_client(pChannel, \ - spar_diag_channel_protocol_uuid, \ - "diag", \ - sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ - ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) +#define SPAR_DIAG_CHANNEL_OK_CLIENT(ch)\ + (spar_check_channel_client(ch,\ + spar_diag_channel_protocol_uuid,\ + "diag",\ + sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL),\ + ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\ + ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) + #define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes) \ (spar_check_channel_server(spar_diag_channel_protocol_uuid, \ "diag", \ -- cgit v1.2.3-59-g8ed1b From a7a6cceb09ecf9f1325a9ce5ba57a35a25e3a2d0 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:39 -0400 Subject: staging: unisys: refactor ULTRA_DIAG_CHANNEL_OK_SERVER Rename this macro to SPAR_DIAG_CHANNEL_OK_SERVER and fix the CamelCase parameter. ActualBytes => bytes Fix indentation and add a blank line after the macro for better readability. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/diagchannel.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 13fe4751ca79..db8b9829eea4 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -66,11 +66,12 @@ static const uuid_le spar_diag_channel_protocol_uuid = ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\ ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(spar_diag_channel_protocol_uuid, \ - "diag", \ - sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ - actualBytes)) +#define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\ + (spar_check_channel_server(spar_diag_channel_protocol_uuid,\ + "diag",\ + sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL),\ + bytes)) + #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ #define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info * accompanying event... */ -- cgit v1.2.3-59-g8ed1b From f38c5b13490a01b27adf4641b51b9cc41d06b377 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:40 -0400 Subject: staging: unisys: refactor DIAG_EFI_TIME Get rid of the typedef and use struct diag_efi_time instead. Fix CamelCase member names and update references to changed names. Year => year Month => month Day => day Hour => hour Minute => minute Second => second Pad1 => pad1 Nanosecond => nanosecond TimeZone => timezone Daylight => daylight Pad2 => pad2 Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/diagchannel.h | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index db8b9829eea4..8f2a7626cdfa 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -106,19 +106,19 @@ static const uuid_le spar_diag_channel_protocol_uuid = /* Copied from EFI's EFI_TIME struct in efidef.h. EFI headers are not allowed * in some of the Supervisor areas, such as Monitor, so it has been "ported" here * for use in diagnostic event timestamps... */ -typedef struct _DIAG_EFI_TIME { - u16 Year; /* 1998 - 20XX */ - u8 Month; /* 1 - 12 */ - u8 Day; /* 1 - 31 */ - u8 Hour; /* 0 - 23 */ - u8 Minute; /* 0 - 59 */ - u8 Second; /* 0 - 59 */ - u8 Pad1; - u32 Nanosecond; /* 0 - 999, 999, 999 */ - s16 TimeZone; /* -1440 to 1440 or 2047 */ - u8 Daylight; - u8 Pad2; -} DIAG_EFI_TIME; +struct diag_efi_time { + u16 year; /* 1998 - 20XX */ + u8 month; /* 1 - 12 */ + u8 day; /* 1 - 31 */ + u8 hour; /* 0 - 23 */ + u8 minute; /* 0 - 59 */ + u8 second; /* 0 - 59 */ + u8 pad1; + u32 nanosecond; /* 0 - 999, 999, 999 */ + s16 timezone; /* -1440 to 1440 or 2047 */ + u8 daylight; + u8 pad2; +}; typedef enum { ULTRA_COMPONENT_GUEST = 0, @@ -161,7 +161,7 @@ typedef struct _DIAG_CHANNEL_EVENT { u32 Severity; u8 ModuleName[MAX_MODULE_NAME_SIZE]; u32 LineNumber; - DIAG_EFI_TIME Timestamp; /* Size = 16 bytes */ + struct diag_efi_time Timestamp; /* Size = 16 bytes */ u32 PartitionNumber; /* Filled in by Diag Switch as pool blocks are * filled */ u16 VirtualProcessorNumber; -- cgit v1.2.3-59-g8ed1b From e91a008a47efcaeb20745e0bf77797b36d559fc5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:41 -0400 Subject: staging: unisys: refactor ULTRA_COMPONENT_TYPES Get rid of the typedef for ULTRA_COMPONENT_TYPES and use enum spar_component_types instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/diagchannel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 8f2a7626cdfa..61259e48905a 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -120,7 +120,7 @@ struct diag_efi_time { u8 pad2; }; -typedef enum { +enum spar_component_types { ULTRA_COMPONENT_GUEST = 0, ULTRA_COMPONENT_MONITOR = 0x01, ULTRA_COMPONENT_CCM = 0x02, /* Common Control module */ @@ -145,7 +145,7 @@ typedef enum { ULTRA_COMPONENT_PSERVICES = 0x17, ULTRA_COMPONENT_PDIAG = 0x18 /* RESERVED 0x18 - 0x1F */ -} ULTRA_COMPONENT_TYPES; +}; /* Structure: DIAG_CHANNEL_EVENT Purpose: Contains attributes that make up an * event to be written to the DIAG_CHANNEL memory. Attributes: EventId: Id of -- cgit v1.2.3-59-g8ed1b From 4cdc6890063ecc0a0c40df127366a5342e48723e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:42 -0400 Subject: staging: unisys: refactor DIAG_CHANNEL_EVENT Get rid of the typedef on DIAG_CHANNEL_EVENT, and use struct diag_channel_event instead. Update comments and fix CamelCase member names: EventId => event_id Severity => severity ModuleName => module_name LineNumber => line_number Timestamp => timestamp PartitionNumber => partition_number VirtualProcessorNumber => vcpu_number LogicalProcessorNumber => lcpu_number ComponentType => component_type Subsystem => subsystem Reserved0 => reserved0 BlockNumber => block_no BlockNumberHigh => block_no_high EventNumber => event_no EventNumberHigh => event_no_high Reserved => reserved AdditionalInfo => additional_info Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/diagchannel.h | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 61259e48905a..6b3c4c82b10e 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -147,7 +147,7 @@ enum spar_component_types { /* RESERVED 0x18 - 0x1F */ }; -/* Structure: DIAG_CHANNEL_EVENT Purpose: Contains attributes that make up an +/* Structure: diag_channel_event Purpose: Contains attributes that make up an * event to be written to the DIAG_CHANNEL memory. Attributes: EventId: Id of * the diagnostic event to write to memory. Severity: Severity of the event * (Error, Info, etc). ModuleName: Module/file name where event originated. @@ -156,40 +156,40 @@ enum spar_component_types { * Reserved: Padding to align structure on a 64-byte cache line boundary. * AdditionalInfo: Array of characters for additional event info (may be * empty). */ -typedef struct _DIAG_CHANNEL_EVENT { - u32 EventId; - u32 Severity; - u8 ModuleName[MAX_MODULE_NAME_SIZE]; - u32 LineNumber; - struct diag_efi_time Timestamp; /* Size = 16 bytes */ - u32 PartitionNumber; /* Filled in by Diag Switch as pool blocks are +struct diag_channel_event { + u32 event_id; + u32 severity; + u8 module_name[MAX_MODULE_NAME_SIZE]; + u32 line_number; + struct diag_efi_time timestamp; /* Size = 16 bytes */ + u32 partition_number; /* Filled in by Diag Switch as pool blocks are * filled */ - u16 VirtualProcessorNumber; - u16 LogicalProcessorNumber; - u8 ComponentType; /* ULTRA_COMPONENT_TYPES */ - u8 Subsystem; - u16 Reserved0; /* pad to u64 alignment */ - u32 BlockNumber; /* filled in by DiagSwitch as pool blocks are + u16 vcpu_number; + u16 lcpu_number; + u8 component_type; /* ULTRA_COMPONENT_TYPES */ + u8 subsystem; + u16 reserved0; /* pad to u64 alignment */ + u32 block_no; /* filled in by DiagSwitch as pool blocks are * filled */ - u32 BlockNumberHigh; - u32 EventNumber; /* filled in by DiagSwitch as pool blocks are + u32 block_no_high; + u32 event_no; /* filled in by DiagSwitch as pool blocks are * filled */ - u32 EventNumberHigh; + u32 event_no_high; - /* The BlockNumber and EventNumber fields are set only by DiagSwitch + /* The block_no and event_no fields are set only by DiagSwitch * and referenced only by WinDiagDisplay formatting tool as * additional diagnostic information. Other tools including * WinDiagDisplay currently ignore these 'Reserved' bytes. */ - u8 Reserved[8]; - u8 AdditionalInfo[MAX_ADDITIONAL_INFO_SIZE]; + u8 reserved[8]; + u8 additional_info[MAX_ADDITIONAL_INFO_SIZE]; - /* NOTE: Changesto DIAG_CHANNEL_EVENT generally need to be reflected in + /* NOTE: Changes to diag_channel_event generally need to be reflected in * existing copies * * - for AppOS at * GuestLinux/visordiag_early/supervisor_diagchannel.h * * - for WinDiagDisplay at * EFI/Ultra/Tools/WinDiagDisplay/WinDiagDisplay/diagstruct.h */ -} DIAG_CHANNEL_EVENT; +}; /* Levels of severity for diagnostic events, in order from lowest severity to * highest (i.e. fatal errors are the most severe, and should always be logged, @@ -240,14 +240,14 @@ typedef enum { DIAG_SEVERITY_ENUM_BEGIN = 0, * "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to * the Diag partition. This cause-severity combination will be used by Logger * DiagSwitch to segregate events into block types. The files are transferred in -* 256 byte chunks maximum, in the AdditionalInfo field of the DIAG_CHANNEL_EVENT +* 256 byte chunks maximum, in the AdditionalInfo field of the diag_channel_event * structure. In the file transfer mode, some event fields will have different * meaning: EventId specifies the file offset, severity specifies the block type, * ModuleName specifies the filename, LineNumber specifies the number of valid * data bytes in an event and AdditionalInfo contains up to 256 bytes of data. */ /* The Diag DiagWriter appends event blocks to events.raw as today, and for data - * blocks uses DIAG_CHANNEL_EVENT + * blocks uses diag_channel_event * PartitionNumber to extract and append 'AdditionalInfo' to filename (specified * by ModuleName). */ @@ -378,7 +378,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { /* ----------------------- */ /* | DiagChannel Header | Defined by DIAG_CHANNEL_PROTOCOL_HEADER */ /* ----------------------- */ -/* | Channel Event Info | Defined by (DIAG_CHANNEL_EVENT * MAX_EVENTS) */ +/* | Channel Event Info | Defined by diag_channel_event*MAX_EVENTS */ /* ----------------------- */ /* | Reserved | Reserved (pad out to 4MB) */ /* ----------------------- */ @@ -420,8 +420,8 @@ typedef struct _ULTRA_DIAG_CHANNEL_PROTOCOL { struct channel_header CommonChannelHeader; struct signal_queue_header QueueHeader; DIAG_CHANNEL_PROTOCOL_HEADER DiagChannelHeader; - DIAG_CHANNEL_EVENT Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / - sizeof(DIAG_CHANNEL_EVENT)]; + struct diag_channel_event Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / + sizeof(struct diag_channel_event)]; } ULTRA_DIAG_CHANNEL_PROTOCOL; -- cgit v1.2.3-59-g8ed1b From 1ac6f52dcc38ec024e7daa4e078cfa515bf00b6d Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:43 -0400 Subject: staging: unisys: remove typedef for DIAG_SEVERITY Get rid of the typedef for DIAG_SEVERITY and just use the enum diag_severity instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/diagchannel.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 6b3c4c82b10e..2f0a523a9659 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -202,7 +202,8 @@ struct diag_channel_event { * they are valid for controlling the amount of event data. This enum is also * defined in DotNet\sParFramework\ControlFramework\ControlFramework.cs. If a * change is made to this enum, they should also be reflected in that file. */ -typedef enum { DIAG_SEVERITY_ENUM_BEGIN = 0, +enum diag_severity { + DIAG_SEVERITY_ENUM_BEGIN = 0, DIAG_SEVERITY_OVERRIDE = DIAG_SEVERITY_ENUM_BEGIN, DIAG_SEVERITY_VERBOSE = DIAG_SEVERITY_OVERRIDE, /* 0 */ DIAG_SEVERITY_INFO = DIAG_SEVERITY_VERBOSE + 1, /* 1 */ @@ -213,7 +214,7 @@ typedef enum { DIAG_SEVERITY_ENUM_BEGIN = 0, DIAG_SEVERITY_ENUM_END = DIAG_SEVERITY_SHUTOFF, /* 5 */ DIAG_SEVERITY_NONFATAL_ERR = DIAG_SEVERITY_ERR, DIAG_SEVERITY_FATAL_ERR = DIAG_SEVERITY_PRINT -} DIAG_SEVERITY; +}; /* Event Cause enums * -- cgit v1.2.3-59-g8ed1b From c41ace756d3edd24fd742bdd5cc67393cb906045 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:44 -0400 Subject: staging: unisys: remove extra blank lines in diagchannel.h Take out the extra blank lines in diagchannel.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/diagchannel.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 2f0a523a9659..5d378811fc33 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -235,8 +235,6 @@ enum diag_severity { * If a change is made to this enum, they should also be reflected in that * file. */ - - /* A cause value "DIAG_CAUSE_FILE_XFER" together with a severity value of * "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to * the Diag partition. This cause-severity combination will be used by Logger -- cgit v1.2.3-59-g8ed1b From e63dc4e1149881adb5c9b6fe480d4a9ffb04aa0e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:45 -0400 Subject: staging: unisys: remove typedef from DIAG_CAUSE Remove the typedef from DIAG_CAUSE and just use enum diag_cause instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/diagchannel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 5d378811fc33..b24194ea546b 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -252,7 +252,7 @@ enum diag_severity { /* The Dell PDiag uses this new mechanism to stash DSET .zip onto the * 'diagnostic' virtual disk. */ -typedef enum { +enum diag_cause { DIAG_CAUSE_UNKNOWN = 0, DIAG_CAUSE_UNKNOWN_DEBUG = DIAG_CAUSE_UNKNOWN + 1, /* 1 */ DIAG_CAUSE_DEBUG = DIAG_CAUSE_UNKNOWN_DEBUG + 1, /* 2 */ @@ -264,7 +264,7 @@ typedef enum { DIAG_CAUSE_INTERNAL_ERROR = DIAG_CAUSE_INVALID_REQUEST + 1, /* 8 */ DIAG_CAUSE_FILE_XFER = DIAG_CAUSE_INTERNAL_ERROR + 1, /* 9 */ DIAG_CAUSE_ENUM_END = DIAG_CAUSE_FILE_XFER /* 9 */ -} DIAG_CAUSE; +}; /* Event Cause category defined into the byte 2 of Severity */ #define CAUSE_DEBUG (DIAG_CAUSE_DEBUG << CAUSE_SHIFT_AMT) -- cgit v1.2.3-59-g8ed1b From 5f0a528bc1f4af28287b80532d2f2cbd047b4307 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:46 -0400 Subject: staging: unisys: refactor DIAG_CHANNEL_PROTOCOL_HEADER Get rid of the typedef and use struct diag_channel_protocol_header instead. Fix CamelCase member names and update references and comments. DiagLock => diag_lock IsChannelInitialized => channel_initialized Reserved => reserved SubsystemSeverityFilter => subsystem_severity_filter Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/diagchannel.h | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index b24194ea546b..022027c9997c 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -344,7 +344,7 @@ enum diag_cause { #define CAUSE_FILE_XFER_SEVERITY_PRINT \ (CAUSE_FILE_XFER | DIAG_SEVERITY_PRINT) -/* Structure: DIAG_CHANNEL_PROTOCOL_HEADER +/* Structure: diag_channel_protocol_header * * Purpose: Contains attributes that make up the header specific to the * DIAG_CHANNEL area. @@ -362,12 +362,12 @@ enum diag_cause { * whether events are logged. Any event's severity for a * particular subsystem below this level will be discarded. */ -typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { - volatile u32 DiagLock; - u8 IsChannelInitialized; - u8 Reserved[3]; - u8 SubsystemSeverityFilter[64]; -} DIAG_CHANNEL_PROTOCOL_HEADER; +struct diag_channel_protocol_header { + u32 diag_lock; + u8 channel_initialized; + u8 reserved[3]; + u8 subsystem_severity_filter[64]; +}; /* The Diagram for the Diagnostic Channel: */ /* ----------------------- */ @@ -375,7 +375,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { /* ----------------------- */ /* | Signal Queue Header | Defined by SIGNAL_QUEUE_HEADER */ /* ----------------------- */ -/* | DiagChannel Header | Defined by DIAG_CHANNEL_PROTOCOL_HEADER */ +/* | DiagChannel Header | Defined by diag_channel_protocol_header */ /* ----------------------- */ /* | Channel Event Info | Defined by diag_channel_event*MAX_EVENTS */ /* ----------------------- */ @@ -387,7 +387,8 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { #define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header)) #define DIAG_CH_PROTOCOL_HEADER_OFFSET \ (DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE) -#define DIAG_CH_PROTOCOL_HEADER_SIZE (sizeof(DIAG_CHANNEL_PROTOCOL_HEADER)) +#define DIAG_CH_PROTOCOL_HEADER_SIZE \ + (sizeof(struct diag_channel_protocol_header)) #define DIAG_CH_EVENT_OFFSET \ (DIAG_CH_PROTOCOL_HEADER_OFFSET + DIAG_CH_PROTOCOL_HEADER_SIZE) #define DIAG_CH_SIZE (4096 * 1024) @@ -409,7 +410,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { * store event. * * DiagChannelHeader: Diagnostic channel header info (see - * DIAG_CHANNEL_PROTOCOL_HEADER comments). + * diag_channel_protocol_header comments). * * Events: Area where diagnostic events (up to MAX_EVENTS) are written. * @@ -418,7 +419,7 @@ typedef struct _DIAG_CHANNEL_PROTOCOL_HEADER { typedef struct _ULTRA_DIAG_CHANNEL_PROTOCOL { struct channel_header CommonChannelHeader; struct signal_queue_header QueueHeader; - DIAG_CHANNEL_PROTOCOL_HEADER DiagChannelHeader; + struct diag_channel_protocol_header DiagChannelHeader; struct diag_channel_event Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / sizeof(struct diag_channel_event)]; } -- cgit v1.2.3-59-g8ed1b From f207671f402b9aa7367ee21dbab2e450d16c9d7e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:47 -0400 Subject: staging: unisys: refactor ULTRA_DIAG_CHANNEL_PROTOCOL Get rid of the typedef and use struct spar_diag_channel_protocol instead. Fix CamelCase member names, and update references and comments to match. struct channel_header CommonChannelHeader; QueueHeader => queue_header DiagChannelHeader => diag_channel_header Events => events Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/diagchannel.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 022027c9997c..e8fb8678a8e2 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -62,14 +62,14 @@ static const uuid_le spar_diag_channel_protocol_uuid = (spar_check_channel_client(ch,\ spar_diag_channel_protocol_uuid,\ "diag",\ - sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL),\ + sizeof(struct spar_diag_channel_protocol),\ ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\ ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE)) #define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\ (spar_check_channel_server(spar_diag_channel_protocol_uuid,\ "diag",\ - sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL),\ + sizeof(struct spar_diag_channel_protocol),\ bytes)) #define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */ @@ -398,7 +398,7 @@ struct diag_channel_protocol_header { #define DIAG_CH_LRG_SIZE (2 * DIAG_CH_SIZE) /* 8 MB */ /* - * Structure: ULTRA_DIAG_CHANNEL_PROTOCOL + * Structure: spar_diag_channel_protocol * * Purpose: Contains attributes that make up the DIAG_CHANNEL memory. * @@ -416,13 +416,12 @@ struct diag_channel_protocol_header { * *Reserved: Reserved area to allow for correct channel size padding. */ -typedef struct _ULTRA_DIAG_CHANNEL_PROTOCOL { - struct channel_header CommonChannelHeader; - struct signal_queue_header QueueHeader; - struct diag_channel_protocol_header DiagChannelHeader; - struct diag_channel_event Events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / +struct spar_diag_channel_protocol { + struct channel_header common_channel_header; + struct signal_queue_header queue_header; + struct diag_channel_protocol_header diag_channel_header; + struct diag_channel_event events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) / sizeof(struct diag_channel_event)]; -} -ULTRA_DIAG_CHANNEL_PROTOCOL; +}; #endif -- cgit v1.2.3-59-g8ed1b From cd2f87e60b09f0c83c959a35da441269e429d6d4 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:48 -0400 Subject: staging: unisys: clean up line spacing in iochannel.h Get rid of extra blank lines in iochannel.h Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/iochannel.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index b1f4a47b3d62..87c66c084b97 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -8,7 +8,6 @@ * this file. Note: Everything is OS-independent because this file is * used by Windows, Linux and possible EFI drivers. */ - /* * Communication flow between the IOPart and GuestPart uses the channel headers * channel state. The following states are currently being used: @@ -89,7 +88,6 @@ * Everything necessary to handle SCSI & NIC traffic between Guest Partition and * IO Partition is defined below. */ - /* * Defines and enums. */ @@ -236,7 +234,6 @@ typedef enum { VDISK_MGMT_ACQUIRE = 1, VDISK_MGMT_RELEASE, /* * structs with pragma pack */ - /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */ /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */ @@ -404,12 +401,10 @@ struct uiscmdrsp_scsi { } \ } while (0) - /* * Struct & Defines to support sense information. */ - /* The following struct is returned in sensebuf field in uiscmdrsp_scsi. It is * initialized in exactly the manner that is recommended in Windows (hence the * odd values). @@ -478,7 +473,6 @@ struct net_pkt_xmt { * each fragment */ char ethhdr[ETH_HEADER_SIZE]; /* the ethernet header */ struct { - /* these are needed for csum at uisnic end */ u8 valid; /* 1 = rest of this struct is valid - else * ignore */ @@ -528,7 +522,6 @@ struct net_pkt_rcvpost { }; struct net_pkt_rcv { - /* the number of receive buffers that can be chained */ /* is based on max mtu and size of each rcv buf */ u32 rcv_done_len; /* length of received data */ @@ -727,7 +720,6 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { * INLINE functions for initializing and accessing I/O data channels */ - #define NUMSIGNALS(x, q) (((ULTRA_IO_CHANNEL_PROTOCOL *)(x))->q.MaxSignalSlots) #define SIZEOF_PROTOCOL (COVER(sizeof(ULTRA_IO_CHANNEL_PROTOCOL), 64)) #define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64)) @@ -781,7 +773,6 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { return 0; \ } while (0) - #define ULTRA_IO_CHANNEL_SERVER_READY(x, chanId, logCtx) \ ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, CHANNELSRV_READY, \ logCtx) @@ -864,7 +855,6 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, * pfn-off-size entires. */ - /* we deal with 4K page sizes when we it comes to passing page information * between */ /* Guest and IOPartition. */ @@ -894,7 +884,6 @@ add_physinfo_entries(u32 inp_pfn, /* input - specifies the pfn to be used firstlen = PI_PAGE_SIZE - inp_off; if (inp_len <= firstlen) { - /* the input entry spans only one page - add as is */ if (index >= max_pi_arr_entries) return 0; @@ -920,7 +909,6 @@ add_physinfo_entries(u32 inp_pfn, /* input - specifies the pfn to be used pi_arr[index + i].pi_len = (u16) MINNUM(len, (u32) PI_PAGE_SIZE); } - } return index + i; } -- cgit v1.2.3-59-g8ed1b From 797d682a454caaba3f05f82f6d5f2a88248d5245 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:49 -0400 Subject: staging: unisys: fix typecast spacing in iochannel.h Fix all the spaces between typecasts and their targets in iochannel.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/iochannel.h | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 87c66c084b97..631fc0450bf2 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -204,7 +204,7 @@ typedef enum { NET_RCV_POST = 0, /* submit buffer to hold receiving #endif /* MAX_MACADDR_LEN */ #define ETH_IS_LOCALLY_ADMINISTERED(Address) \ - (((u8 *) (Address))[0] & ((u8) 0x02)) + (((u8 *)(Address))[0] & ((u8) 0x02)) #define NIC_VENDOR_ID 0x0008000B /* various types of scsi task mgmt commands */ @@ -368,16 +368,16 @@ struct uiscmdrsp_scsi { do { \ memset(buf, 0, \ MINNUM(len, \ - (unsigned int) NO_DISK_INQUIRY_RESULT_LEN)); \ - buf[2] = (u8) SCSI_SPC2_VER; \ + (unsigned int)NO_DISK_INQUIRY_RESULT_LEN)); \ + buf[2] = (u8)SCSI_SPC2_VER; \ if (lun == 0) { \ - buf[0] = (u8) lun0notpresent; \ - buf[3] = (u8) DEV_HISUPPORT; \ + buf[0] = (u8)lun0notpresent; \ + buf[3] = (u8)DEV_HISUPPORT; \ } else \ - buf[0] = (u8) notpresent; \ - buf[4] = (u8) ( \ + buf[0] = (u8)notpresent; \ + buf[4] = (u8)( \ MINNUM(len, \ - (unsigned int) NO_DISK_INQUIRY_RESULT_LEN) - 5); \ + (unsigned int)NO_DISK_INQUIRY_RESULT_LEN) - 5);\ if (len >= NO_DISK_INQUIRY_RESULT_LEN) { \ buf[8] = 'D'; \ buf[9] = 'E'; \ @@ -762,9 +762,9 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { offsetof(type, clientString); \ memcpy(chan->clientString, clientStr, \ MINNUM(clientStrLen, \ - (u32) (MAX_CLIENTSTRING_LEN - 1))); \ + (u32)(MAX_CLIENTSTRING_LEN - 1))); \ chan->clientString[MINNUM(clientStrLen, \ - (u32) (MAX_CLIENTSTRING_LEN \ + (u32)(MAX_CLIENTSTRING_LEN \ - 1))] \ = '\0'; \ } \ @@ -888,8 +888,8 @@ add_physinfo_entries(u32 inp_pfn, /* input - specifies the pfn to be used if (index >= max_pi_arr_entries) return 0; pi_arr[index].pi_pfn = inp_pfn; - pi_arr[index].pi_off = (u16) inp_off; - pi_arr[index].pi_len = (u16) inp_len; + pi_arr[index].pi_off = (u16)inp_off; + pi_arr[index].pi_len = (u16)inp_len; return index + 1; } @@ -907,7 +907,7 @@ add_physinfo_entries(u32 inp_pfn, /* input - specifies the pfn to be used else { pi_arr[index + i].pi_off = 0; pi_arr[index + i].pi_len = - (u16) MINNUM(len, (u32) PI_PAGE_SIZE); + (u16)MINNUM(len, (u32)PI_PAGE_SIZE); } } return index + i; -- cgit v1.2.3-59-g8ed1b From 47da307d2c378a5ea3f8bfbb6a109a99a1a3b221 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:50 -0400 Subject: staging: unisys: clean up CamelCase parameter in SPAR_VHBA_CHANNEL_OK_CLIENT Remove the unused logCtx parameter and fix CamelCase parameter name: pChannel => ch Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 ++-- drivers/staging/unisys/uislib/uislib.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 631fc0450bf2..2e015498eb4f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -59,8 +59,8 @@ #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1 -#define SPAR_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (spar_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \ +#define SPAR_VHBA_CHANNEL_OK_CLIENT(ch) \ + (spar_check_channel_client(ch, spar_vhba_channel_protocol_uuid, \ "vhba", MIN_IO_CHANNEL_SIZE, \ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE)) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index b8db2700a1df..72c8479fe49c 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -450,7 +450,7 @@ create_device(struct controlvm_message *msg, char *buf) chanptr))-> chtype); if (!SPAR_VHBA_CHANNEL_OK_CLIENT - (dev->chanptr, NULL)) { + (dev->chanptr)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.", devNo); POSTCODE_LINUX_4 -- cgit v1.2.3-59-g8ed1b From c0eafd65de50f8f94e014e5bfdd561d57c0858d1 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:51 -0400 Subject: staging: unisys: remove unused macro ULTRA_VHBA_CHANNEL_OK_SERVER This macro is not used so remove it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 2e015498eb4f..67f3a7ea31f4 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -64,9 +64,7 @@ "vhba", MIN_IO_CHANNEL_SIZE, \ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(spar_vhba_channel_protocol_uuid, \ - "vhba", MIN_IO_CHANNEL_SIZE, actualBytes)) + #define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, \ -- cgit v1.2.3-59-g8ed1b From dabf9dc1e27eb922b2d6f4504375deb340a3ba90 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:52 -0400 Subject: staging: unisys: remove unused macro ULTRA_VNIC_CHANNEL_OK_SERVER This macro isn't being used either, so delete it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 67f3a7ea31f4..0e446c06605c 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -70,9 +70,7 @@ "vnic", MIN_IO_CHANNEL_SIZE, \ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(spar_vnic_channel_protocol_uuid, \ - "vnic", MIN_IO_CHANNEL_SIZE, actualBytes)) + #define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \ "vswitch", MIN_IO_CHANNEL_SIZE, \ -- cgit v1.2.3-59-g8ed1b From 44bd648d28dc5d7b522d1050e88f9ed10cf0cd1c Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:53 -0400 Subject: staging: unisys: remove unused macro ULTRA_VSWITCH_CHANNEL_OK_SERVER This macro isn't being used so take it out. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 0e446c06605c..51373a182e0d 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -76,10 +76,7 @@ "vswitch", MIN_IO_CHANNEL_SIZE, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE)) -#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(UltraVswitchChannelProtocolGuid, \ - "vswitch", MIN_IO_CHANNEL_SIZE, \ - actualBytes)) + /* * Everything necessary to handle SCSI & NIC traffic between Guest Partition and * IO Partition is defined below. */ -- cgit v1.2.3-59-g8ed1b From bdedd94ad5b0931ef0bd56f8d9a2892d86f2049e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:54 -0400 Subject: staging: unisys: fix parameters to macro SPAR_VNIC_CHANNEL_OK_CLIENT Remove the unused logCtx parameter and fix the CamelCase name: pChannel => ch Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 ++-- drivers/staging/unisys/uislib/uislib.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 51373a182e0d..1fb7174fc597 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -65,8 +65,8 @@ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE)) -#define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ +#define SPAR_VNIC_CHANNEL_OK_CLIENT(ch) \ + (spar_check_channel_client(ch, spar_vnic_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, \ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 72c8479fe49c..14948a082934 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -476,7 +476,7 @@ create_device(struct controlvm_message *msg, char *buf) chanptr))-> chtype); if (!SPAR_VNIC_CHANNEL_OK_CLIENT - (dev->chanptr, NULL)) { + (dev->chanptr)) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.", devNo); POSTCODE_LINUX_4 -- cgit v1.2.3-59-g8ed1b From 21f131b5d1da2b09cc8e8d6d506dd4ed357a1cd5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:55 -0400 Subject: staging: unisys: remove unused macro SPAR_VSWITCH_CHANNEL_OK_CLIENT Nobody is using this one either... Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 1fb7174fc597..520fd3f3e8cc 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -71,12 +71,6 @@ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE)) -#define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \ - "vswitch", MIN_IO_CHANNEL_SIZE, \ - ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE)) - /* * Everything necessary to handle SCSI & NIC traffic between Guest Partition and * IO Partition is defined below. */ -- cgit v1.2.3-59-g8ed1b From 9c68aae24738ae2df50affce9252eb5a89432ca0 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:56 -0400 Subject: staging: unisys: remove typedef from NET_TYPES Take out the typedef and just use enum net_types instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 520fd3f3e8cc..3f30969098c3 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -151,8 +151,9 @@ * SCSI Host value */ /* various types of network packets that can be sent in cmdrsp */ -typedef enum { NET_RCV_POST = 0, /* submit buffer to hold receiving - * incoming packet */ +enum net_types { + NET_RCV_POST = 0, /* submit buffer to hold receiving + * incoming packet */ /* virtnic -> uisnic */ NET_RCV, /* incoming packet received */ /* uisnic -> virtpci */ @@ -174,7 +175,7 @@ typedef enum { NET_RCV_POST = 0, /* submit buffer to hold receiving * its MAC addr */ NET_MACADDR_ACK, /* MAC address */ -} NET_TYPES; +}; #define ETH_HEADER_SIZE 14 /* size of ethernet header */ @@ -534,7 +535,7 @@ struct net_pkt_macaddr { /* cmd rsp packet used for VNIC network traffic */ struct uiscmdrsp_net { - NET_TYPES type; + enum net_types type; void *buf; union { struct net_pkt_xmt xmt; /* used for NET_XMIT */ -- cgit v1.2.3-59-g8ed1b From f43d9b50cded1d3a6908679a57bd9d83e1b8149a Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:57 -0400 Subject: staging: unisys: fix CamelCase in ETH_IS_LOCALLY_ADMINISTERED Fix the CamelCase parameter in this macro: Address => address Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 3f30969098c3..6ee45066742f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -191,8 +191,8 @@ enum net_types { #define MAX_MACADDR_LEN 6 /* number of bytes in MAC address */ #endif /* MAX_MACADDR_LEN */ -#define ETH_IS_LOCALLY_ADMINISTERED(Address) \ - (((u8 *)(Address))[0] & ((u8) 0x02)) +#define ETH_IS_LOCALLY_ADMINISTERED(address) \ + (((u8 *)(address))[0] & ((u8)0x02)) #define NIC_VENDOR_ID 0x0008000B /* various types of scsi task mgmt commands */ -- cgit v1.2.3-59-g8ed1b From 63f06ba1eeebf720366ee4836695828d47a3bf26 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:58 -0400 Subject: staging: unisys: refactor TASK_MGMT_TYPES Get rid of the typedef and use enum task_mgmt_types in its place. Clean up the indentation of the enumeration values and update all use of the name to the new name. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/common-spar/include/channels/iochannel.h | 12 +++++++----- drivers/staging/unisys/virthba/virthba.c | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 6ee45066742f..129f4b6d2d37 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -196,10 +196,12 @@ enum net_types { #define NIC_VENDOR_ID 0x0008000B /* various types of scsi task mgmt commands */ -typedef enum { TASK_MGMT_ABORT_TASK = - 1, TASK_MGMT_BUS_RESET, TASK_MGMT_LUN_RESET, - TASK_MGMT_TARGET_RESET, -} TASK_MGMT_TYPES; +enum task_mgmt_types { + TASK_MGMT_ABORT_TASK = 1, + TASK_MGMT_BUS_RESET, + TASK_MGMT_LUN_RESET, + TASK_MGMT_TARGET_RESET, +}; /* various types of vdisk mgmt commands */ typedef enum { VDISK_MGMT_ACQUIRE = 1, VDISK_MGMT_RELEASE, @@ -551,7 +553,7 @@ struct uiscmdrsp_net { }; struct uiscmdrsp_scsitaskmgmt { - TASK_MGMT_TYPES tasktype; + enum task_mgmt_types tasktype; /* the type of task */ struct uisscsi_dest vdest; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 3a037f41ee40..fdf5e22ab548 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -738,7 +738,8 @@ forward_vdiskmgmt_command(VDISK_MGMT_TYPES vdiskcmdtype, /*****************************************************/ static int -forward_taskmgmt_command(TASK_MGMT_TYPES tasktype, struct scsi_device *scsidev) +forward_taskmgmt_command(enum task_mgmt_types tasktype, + struct scsi_device *scsidev) { struct uiscmdrsp *cmdrsp; struct virthba_info *virthbainfo = -- cgit v1.2.3-59-g8ed1b From c8cf5d075e2fe20bb29a63a48c32dbb4c48a59e9 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:30:59 -0400 Subject: staging: unisys: refactor enum VDISK_MGMT_TYPES Get rid of the typedef and use enum vdisk_mgmt_types instead. Reformat the enumeration names and update any references to use the enum directly. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 8 +++++--- drivers/staging/unisys/virthba/virthba.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 129f4b6d2d37..3256ff526859 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -204,8 +204,10 @@ enum task_mgmt_types { }; /* various types of vdisk mgmt commands */ -typedef enum { VDISK_MGMT_ACQUIRE = 1, VDISK_MGMT_RELEASE, -} VDISK_MGMT_TYPES; +enum vdisk_mgmt_types { + VDISK_MGMT_ACQUIRE = 1, + VDISK_MGMT_RELEASE, +}; /* this is used in the vdest field */ #define VDEST_ALL 0xFFFF @@ -600,7 +602,7 @@ struct uiscmdrsp_disknotify { /* The following is used by virthba/vSCSI to send the Acquire/Release commands * to the IOVM. */ struct uiscmdrsp_vdiskmgmt { - VDISK_MGMT_TYPES vdisktype; + enum vdisk_mgmt_types vdisktype; /* the type of task */ struct uisscsi_dest vdest; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index fdf5e22ab548..1e921f0f596d 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -674,7 +674,7 @@ virthba_remove(struct virtpci_dev *virtpcidev) } static int -forward_vdiskmgmt_command(VDISK_MGMT_TYPES vdiskcmdtype, +forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype, struct Scsi_Host *scsihost, struct uisscsi_dest *vdest) { -- cgit v1.2.3-59-g8ed1b From 3f549af37963bf5805652e31053401875bbee6f3 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:00 -0400 Subject: staging: unisys: fix CamelCase names in struct sense_data Fix CamelCase names: ErrorCode => error_code Valid => valid SegmentNumber => segment_number SenseKey => sense_key Reserved => reserved IncorrectLength => incorrect_length EndOfMedia => end_of_media FileMark => file_mark Information => information AdditionalSenseLength => additional_sense_length CommandSpecificInformation => commmand_specific_information AdditionalSenseCode => additional_sense_code AdditionalSenseCodeQualifier => additional_sense_code_qualifier FieldReplaceableUnitCode => fru_code SenseKeySpecific => sense_key_specific Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/iochannel.h | 30 +++++++++++----------- drivers/staging/unisys/virthba/virthba.c | 6 ++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 3256ff526859..1ebaa5b66eb9 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -410,21 +410,21 @@ struct uiscmdrsp_scsi { * AdditionalSenseLength contains will be sizeof(sense_data)-8=10. */ struct sense_data { - u8 ErrorCode:7; - u8 Valid:1; - u8 SegmentNumber; - u8 SenseKey:4; - u8 Reserved:1; - u8 IncorrectLength:1; - u8 EndOfMedia:1; - u8 FileMark:1; - u8 Information[4]; - u8 AdditionalSenseLength; - u8 CommandSpecificInformation[4]; - u8 AdditionalSenseCode; - u8 AdditionalSenseCodeQualifier; - u8 FieldReplaceableUnitCode; - u8 SenseKeySpecific[3]; + u8 errorcode:7; + u8 valid:1; + u8 segment_number; + u8 sense_key:4; + u8 reserved:1; + u8 incorrect_length:1; + u8 end_of_media:1; + u8 file_mark:1; + u8 information[4]; + u8 additional_sense_length; + u8 command_specific_information[4]; + u8 additional_sense_code; + u8 additional_sense_code_qualifier; + u8 fru_code; + u8 sense_key_specific[3]; }; /* some SCSI ADSENSE codes */ diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 1e921f0f596d..a3ea0871664b 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1143,9 +1143,9 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) scsicmd, cmdrsp->scsi.cmnd[0], scsidev->host->host_no, scsidev->id, scsidev->channel, scsidev->lun, - cmdrsp->scsi.linuxstat, sd->Valid, sd->SenseKey, - sd->AdditionalSenseCode, - sd->AdditionalSenseCodeQualifier); + cmdrsp->scsi.linuxstat, sd->valid, sd->sense_key, + sd->additional_sense_code, + sd->additional_sense_code_qualifier); if (atomic_read(&vdisk->error_count) == VIRTHBA_ERROR_COUNT) { LOGERR("Throtling SCSICMD errors disk <%d:%d:%d:%llu>\n", -- cgit v1.2.3-59-g8ed1b From 60a2708327f3c30c8e87c54cf3044f1e0c6a5d4b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:01 -0400 Subject: staging: unisys: fix CamelCase name in net_pkt_rcvpost Fix the CamelCase name in this struct: UniqueNum => unique_num Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 1ebaa5b66eb9..949562295ca4 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -508,7 +508,7 @@ struct net_pkt_rcvpost { * to be describable */ struct phys_info frag; /* physical page information for the * single fragment 2K rcv buf */ - u64 UniqueNum; /* This is used to make sure that + u64 unique_num; /* This is used to make sure that * receive posts are returned to */ /* the Adapter which sent them origonally. */ }; -- cgit v1.2.3-59-g8ed1b From efc84499e90b7192dbf80a6493a487f695f344e4 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:02 -0400 Subject: staging: unisys: fix CamelCase names in net_pkt_rcv Fix CamelCase names: UniqueNum => unique_num RcvsDroppedDelta => rcvs_dropped_delta Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 949562295ca4..2f0cf5f341a6 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -523,8 +523,8 @@ struct net_pkt_rcv { * that must be chained; */ /* each entry is a receive buffer provided by NET_RCV_POST. */ /* NOTE: first rcvbuf in the chain will also be provided in net.buf. */ - u64 UniqueNum; - u32 RcvsDroppedDelta; + u64 unique_num; + u32 rcvs_dropped_delta; }; struct net_pkt_enbdis { -- cgit v1.2.3-59-g8ed1b From be3c366905e56ff324018e00339167a3beead31e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:03 -0400 Subject: staging: unisys: fix CamelCase in uiscmdrsp_disknotify Fix the CamelCase member of this structure: vHba => v_hba Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 2 +- drivers/staging/unisys/virthba/virthba.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 2f0cf5f341a6..b4da34758b3d 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -594,7 +594,7 @@ struct uiscmdrsp_scsitaskmgmt { /* Note that the vHba pointer is not used by the Client/Guest side. */ struct uiscmdrsp_disknotify { u8 add; /* 0-remove, 1-add */ - void *vHba; /* Pointer to vhba_info for channel info to + void *v_hba; /* Pointer to vhba_info for channel info to * route msg */ u32 channel, id, lun; /* SCSI Path of Disk to added or removed */ }; diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index a3ea0871664b..ee1be5a83e39 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1310,7 +1310,7 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, * a Client/Guest Partition. Let's be * safe and set it to NULL now. Do * not use it here! */ - cmdrsp->disknotify.vHba = NULL; + cmdrsp->disknotify.v_hba = NULL; process_disk_notify(shost, cmdrsp); } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) { if (!del_scsipending_entry(virthbainfo, -- cgit v1.2.3-59-g8ed1b From bedc756e3ae6b367cb740ddb5480dd63479b8a19 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:04 -0400 Subject: staging: unisys: refactor ULTRA_IO_CHANNEL_PROTOCOL Remove the typedef from ULTRA_IO_CHANNEL_PROTOCOL and use the name struct spar_io_channel_protocol instead. Fix CamelCase member names: ChannelHeader => channel_header cmdQ => cmd_q rspQ => rsp_q zoneGuid => zone_uuid ClientString => client_string Update all references to changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/iochannel.h | 127 +++++++++++---------- drivers/staging/unisys/uislib/uislib.c | 4 +- drivers/staging/unisys/virtpci/virtpci.c | 26 ++--- 3 files changed, 79 insertions(+), 78 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index b4da34758b3d..071cf72125a1 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -662,11 +662,11 @@ struct uiscmdrsp { /* This is just the header of the IO channel. It is assumed that directly after * this header there is a large region of memory which contains the command and -* response queues as specified in cmdQ and rspQ SIGNAL_QUEUE_HEADERS. */ -typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { - struct channel_header ChannelHeader; - struct signal_queue_header cmdQ; - struct signal_queue_header rspQ; +* response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. */ +struct spar_io_channel_protocol { + struct channel_header channel_header; + struct signal_queue_header cmd_q; + struct signal_queue_header rsp_q; union { struct { struct vhba_wwnn wwnn; /* 8 bytes */ @@ -676,14 +676,14 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { u8 macaddr[MAX_MACADDR_LEN]; /* 6 bytes */ u32 num_rcv_bufs; /* 4 */ u32 mtu; /* 4 */ - uuid_le zoneGuid; /* 16 */ + uuid_le zone_uuid; /* 16 */ } vnic; /* total 30 */ }; #define MAX_CLIENTSTRING_LEN 1024 - u8 clientString[MAX_CLIENTSTRING_LEN]; /* NULL terminated - so holds + u8 client_string[MAX_CLIENTSTRING_LEN];/* NULL terminated - so holds * max - 1 bytes */ -} ULTRA_IO_CHANNEL_PROTOCOL; +}; #pragma pack(pop) /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */ @@ -712,13 +712,14 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { * INLINE functions for initializing and accessing I/O data channels */ -#define NUMSIGNALS(x, q) (((ULTRA_IO_CHANNEL_PROTOCOL *)(x))->q.MaxSignalSlots) -#define SIZEOF_PROTOCOL (COVER(sizeof(ULTRA_IO_CHANNEL_PROTOCOL), 64)) +#define NUMSIGNALS(x, q) \ + (((struct spar_io_channel_protocol *)(x))->q.MaxSignalSlots) +#define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64)) #define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64)) #define IO_CHANNEL_SIZE(x) COVER(SIZEOF_PROTOCOL + \ - (NUMSIGNALS(x, cmdQ) + \ - NUMSIGNALS(x, rspQ)) * SIZEOF_CMDRSP, 4096) + (NUMSIGNALS(x, cmd_q) + \ + NUMSIGNALS(x, rsp_q)) * SIZEOF_CMDRSP, 4096) #define MIN_IO_CHANNEL_SIZE COVER(SIZEOF_PROTOCOL + \ 2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096) #ifdef __GNUC__ @@ -728,34 +729,34 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { #define QSIZEFROMBYTES(bytes) (QSLOTSFROMBYTES(bytes)*SIZEOF_CMDRSP) #define SignalQInit(x) \ do { \ - x->cmdQ.size = QSIZEFROMBYTES(x->ChannelHeader.size); \ - x->cmdQ.sig_base_offset = SIZEOF_PROTOCOL - \ - offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ - x->cmdQ.signal_size = SIZEOF_CMDRSP; \ - x->cmdQ.max_slots = \ - QSLOTSFROMBYTES(x->ChannelHeader.size); \ - x->cmdQ.max_signals = x->cmdQ.max_slots - 1; \ - x->rspQ.size = QSIZEFROMBYTES(x->ChannelHeader.size); \ - x->rspQ.sig_base_offset = \ - (SIZEOF_PROTOCOL + x->cmdQ.size) - \ - offsetof(ULTRA_IO_CHANNEL_PROTOCOL, rspQ); \ - x->rspQ.signal_size = SIZEOF_CMDRSP; \ - x->rspQ.max_slots = \ - QSLOTSFROMBYTES(x->ChannelHeader.size); \ - x->rspQ.max_signals = x->rspQ.max_slots - 1; \ - x->ChannelHeader.ch_space_offset = \ - offsetof(ULTRA_IO_CHANNEL_PROTOCOL, cmdQ); \ + x->cmd_q.size = QSIZEFROMBYTES(x->channel_header.size); \ + x->cmd_q.sig_base_offset = SIZEOF_PROTOCOL - \ + offsetof(struct spar_io_channel_protocol, cmd_q);\ + x->cmd_q.signal_size = SIZEOF_CMDRSP; \ + x->cmd_q.max_slots = \ + QSLOTSFROMBYTES(x->channel_header.size); \ + x->cmd_q.max_signals = x->cmd_q.max_slots - 1; \ + x->rsp_q.size = QSIZEFROMBYTES(x->channel_header.size); \ + x->rsp_q.sig_base_offset = \ + (SIZEOF_PROTOCOL + x->cmd_q.size) - \ + offsetof(struct spar_io_channel_protocol, rsp_q);\ + x->rsp_q.signal_size = SIZEOF_CMDRSP; \ + x->rsp_q.max_slots = \ + QSLOTSFROMBYTES(x->channel_header.size); \ + x->rsp_q.max_signals = x->rsp_q.max_slots - 1; \ + x->channel_header.ch_space_offset = \ + offsetof(struct spar_io_channel_protocol, cmd_q);\ } while (0) #define INIT_CLIENTSTRING(chan, type, clientStr, clientStrLen) \ do { \ if (clientStr) { \ - chan->ChannelHeader.cli_str_offset = \ - offsetof(type, clientString); \ - memcpy(chan->clientString, clientStr, \ + chan->channel_header.cli_str_offset = \ + offsetof(type, client_string); \ + memcpy(chan->client_string, clientStr, \ MINNUM(clientStrLen, \ (u32)(MAX_CLIENTSTRING_LEN - 1))); \ - chan->clientString[MINNUM(clientStrLen, \ + chan->client_string[MINNUM(clientStrLen, \ (u32)(MAX_CLIENTSTRING_LEN \ - 1))] \ = '\0'; \ @@ -773,68 +774,68 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, \ CHANNELSRV_UNINITIALIZED, logCtx) -static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, +static inline int ULTRA_VHBA_init_channel(struct spar_io_channel_protocol *x, struct vhba_wwnn *wwnn, struct vhba_config_max *max, unsigned char *clientStr, u32 clientStrLen, u64 bytes) { - memset(x, 0, sizeof(ULTRA_IO_CHANNEL_PROTOCOL)); - x->ChannelHeader.version_id = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID; - x->ChannelHeader.signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE; - x->ChannelHeader.srv_state = CHANNELSRV_UNINITIALIZED; - x->ChannelHeader.header_size = sizeof(x->ChannelHeader); - x->ChannelHeader.size = COVER(bytes, 4096); - x->ChannelHeader.chtype = spar_vhba_channel_protocol_uuid; - x->ChannelHeader.zone_uuid = NULL_UUID_LE; + memset(x, 0, sizeof(struct spar_io_channel_protocol)); + x->channel_header.version_id = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID; + x->channel_header.signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE; + x->channel_header.srv_state = CHANNELSRV_UNINITIALIZED; + x->channel_header.header_size = sizeof(x->channel_header); + x->channel_header.size = COVER(bytes, 4096); + x->channel_header.chtype = spar_vhba_channel_protocol_uuid; + x->channel_header.zone_uuid = NULL_UUID_LE; x->vhba.wwnn = *wwnn; x->vhba.max = *max; - INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr, + INIT_CLIENTSTRING(x, struct spar_io_channel_protocol, clientStr, clientStrLen); SignalQInit(x); - if ((x->cmdQ.max_slots > MAX_NUMSIGNALS) || - (x->rspQ.max_slots > MAX_NUMSIGNALS)) { + if ((x->cmd_q.max_slots > MAX_NUMSIGNALS) || + (x->rsp_q.max_slots > MAX_NUMSIGNALS)) { return 0; } - if ((x->cmdQ.max_slots < MIN_NUMSIGNALS) || - (x->rspQ.max_slots < MIN_NUMSIGNALS)) { + if ((x->cmd_q.max_slots < MIN_NUMSIGNALS) || + (x->rsp_q.max_slots < MIN_NUMSIGNALS)) { return 0; } return 1; } -static inline void ULTRA_VHBA_set_max(ULTRA_IO_CHANNEL_PROTOCOL *x, +static inline void ULTRA_VHBA_set_max(struct spar_io_channel_protocol *x, struct vhba_config_max *max) { x->vhba.max = *max; } -static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, +static inline int ULTRA_VNIC_init_channel(struct spar_io_channel_protocol *x, unsigned char *macaddr, u32 num_rcv_bufs, u32 mtu, uuid_le zoneGuid, unsigned char *clientStr, u32 clientStrLen, u64 bytes) { - memset(x, 0, sizeof(ULTRA_IO_CHANNEL_PROTOCOL)); - x->ChannelHeader.version_id = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID; - x->ChannelHeader.signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE; - x->ChannelHeader.srv_state = CHANNELSRV_UNINITIALIZED; - x->ChannelHeader.header_size = sizeof(x->ChannelHeader); - x->ChannelHeader.size = COVER(bytes, 4096); - x->ChannelHeader.chtype = spar_vnic_channel_protocol_uuid; - x->ChannelHeader.zone_uuid = NULL_UUID_LE; + memset(x, 0, sizeof(struct spar_io_channel_protocol)); + x->channel_header.version_id = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID; + x->channel_header.signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE; + x->channel_header.srv_state = CHANNELSRV_UNINITIALIZED; + x->channel_header.header_size = sizeof(x->channel_header); + x->channel_header.size = COVER(bytes, 4096); + x->channel_header.chtype = spar_vnic_channel_protocol_uuid; + x->channel_header.zone_uuid = NULL_UUID_LE; memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); x->vnic.num_rcv_bufs = num_rcv_bufs; x->vnic.mtu = mtu; - x->vnic.zoneGuid = zoneGuid; - INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr, + x->vnic.zone_uuid = zoneGuid; + INIT_CLIENTSTRING(x, struct spar_io_channel_protocol, clientStr, clientStrLen); SignalQInit(x); - if ((x->cmdQ.max_slots > MAX_NUMSIGNALS) || - (x->rspQ.max_slots > MAX_NUMSIGNALS)) { + if ((x->cmd_q.max_slots > MAX_NUMSIGNALS) || + (x->rsp_q.max_slots > MAX_NUMSIGNALS)) { return 0; } - if ((x->cmdQ.max_slots < MIN_NUMSIGNALS) || - (x->rspQ.max_slots < MIN_NUMSIGNALS)) { + if ((x->cmd_q.max_slots < MIN_NUMSIGNALS) || + (x->rsp_q.max_slots < MIN_NUMSIGNALS)) { return 0; } return 1; diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 14948a082934..6e0873455651 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1568,8 +1568,8 @@ uislib_mod_init(void) (ulong) sizeof(struct spar_controlvm_channel_protocol)); LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n", (ulong) sizeof(struct channel_header)); - LOGINF("sizeof(ULTRA_IO_CHANNEL_PROTOCOL):%lu bytes\n", - (ulong) sizeof(ULTRA_IO_CHANNEL_PROTOCOL)); + LOGINF("sizeof(struct spar_io_channel_protocol):%lu bytes\n", + (ulong) sizeof(struct spar_io_channel_protocol)); LOGINF("SIZEOF_CMDRSP:%lu bytes\n", SIZEOF_CMDRSP); LOGINF("SIZEOF_PROTOCOL:%lu bytes\n", SIZEOF_PROTOCOL); diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index eaae4e8b9b45..ee1beb546635 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -171,13 +171,13 @@ struct virtpci_busdev { /*****************************************************/ static inline -int WAIT_FOR_IO_CHANNEL(ULTRA_IO_CHANNEL_PROTOCOL __iomem *chanptr) +int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem *chanptr) { int count = 120; while (count > 0) { - if (SPAR_CHANNEL_SERVER_READY(&chanptr->ChannelHeader)) + if (SPAR_CHANNEL_SERVER_READY(&chanptr->channel_header)) return 1; UIS_THREAD_WAIT_SEC(1); count--; @@ -293,11 +293,11 @@ static int add_vbus(struct add_vbus_guestpart *addparams) */ #define GET_SCSIADAPINFO_FROM_CHANPTR(chanptr) { \ memcpy_fromio(&scsi.wwnn, \ - &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ + &((struct spar_io_channel_protocol __iomem *) \ chanptr)->vhba.wwnn, \ sizeof(struct vhba_wwnn)); \ memcpy_fromio(&scsi.max, \ - &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ + &((struct spar_io_channel_protocol __iomem *) \ chanptr)->vhba.max, \ sizeof(struct vhba_config_max)); \ } @@ -325,7 +325,7 @@ static int add_vhba(struct add_virt_guestpart *addparams) POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (!WAIT_FOR_IO_CHANNEL - ((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) addparams->chanptr)) { + ((struct spar_io_channel_protocol __iomem *) addparams->chanptr)) { LOGERR("Timed out. Channel not ready\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; @@ -355,17 +355,17 @@ static int add_vhba(struct add_virt_guestpart *addparams) */ #define GET_NETADAPINFO_FROM_CHANPTR(chanptr) { \ memcpy_fromio(net.mac_addr, \ - ((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ + ((struct spar_io_channel_protocol __iomem *) \ chanptr)->vnic.macaddr, \ MAX_MACADDR_LEN); \ net.num_rcv_bufs = \ - readl(&((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ + readl(&((struct spar_io_channel_protocol __iomem *)\ chanptr)->vnic.num_rcv_bufs); \ - net.mtu = readl(&((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ + net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \ chanptr)->vnic.mtu); \ memcpy_fromio(&net.zoneGuid, \ - &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ - chanptr)->vnic.zoneGuid, \ + &((struct spar_io_channel_protocol __iomem *)\ + chanptr)->vnic.zone_uuid, \ sizeof(uuid_le)); \ } @@ -382,7 +382,7 @@ add_vnic(struct add_virt_guestpart *addparams) POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (!WAIT_FOR_IO_CHANNEL - ((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) addparams->chanptr)) { + ((struct spar_io_channel_protocol __iomem *) addparams->chanptr)) { LOGERR("Timed out, channel not ready\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; @@ -905,7 +905,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, struct virtpci_dev *tmpvpcidev = NULL, *prev; unsigned long flags; int ret; - ULTRA_IO_CHANNEL_PROTOCOL __iomem *pIoChan = NULL; + struct spar_io_channel_protocol __iomem *pIoChan = NULL; struct device *pDev; LOGINF("virtpci_device_add parentbus:%p chanptr:%p\n", parentbus, @@ -946,7 +946,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, virtpcidev->queueinfo.send_int_if_needed = NULL; /* Set up safe queue... */ - pIoChan = (ULTRA_IO_CHANNEL_PROTOCOL __iomem *) + pIoChan = (struct spar_io_channel_protocol __iomem *) virtpcidev->queueinfo.chan; virtpcidev->intr = addparams->intr; -- cgit v1.2.3-59-g8ed1b From e80f6e3bd6f305fa551526b709e4d319126feb83 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:05 -0400 Subject: staging: unisys: remove unused code from iochannel.h The following macros and functions are unused, and should be deleted: NUMSIGNALS IO_CHANNEL_SIZE QSLOTSFROMBYTES QSIZEFROMBYTES SignalQInit INIT_CLIENTSTRING ULTRA_IO_CHANNEL_SERVER_READY ULTRA_IO_CHANNEL_SERVER_NOTREADY ULTRA_VHBA_init_channel ULTRA_VHBA_set_max ULTRA_VNIC_init_channel Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/iochannel.h | 125 --------------------- 1 file changed, 125 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 071cf72125a1..eb7efe484f6f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -712,136 +712,11 @@ struct spar_io_channel_protocol { * INLINE functions for initializing and accessing I/O data channels */ -#define NUMSIGNALS(x, q) \ - (((struct spar_io_channel_protocol *)(x))->q.MaxSignalSlots) #define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64)) #define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64)) -#define IO_CHANNEL_SIZE(x) COVER(SIZEOF_PROTOCOL + \ - (NUMSIGNALS(x, cmd_q) + \ - NUMSIGNALS(x, rsp_q)) * SIZEOF_CMDRSP, 4096) #define MIN_IO_CHANNEL_SIZE COVER(SIZEOF_PROTOCOL + \ 2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096) -#ifdef __GNUC__ -/* These defines should only ever be used in service partitons */ -/* because they rely on the size of uiscmdrsp */ -#define QSLOTSFROMBYTES(bytes) (((bytes-SIZEOF_PROTOCOL)/2)/SIZEOF_CMDRSP) -#define QSIZEFROMBYTES(bytes) (QSLOTSFROMBYTES(bytes)*SIZEOF_CMDRSP) -#define SignalQInit(x) \ - do { \ - x->cmd_q.size = QSIZEFROMBYTES(x->channel_header.size); \ - x->cmd_q.sig_base_offset = SIZEOF_PROTOCOL - \ - offsetof(struct spar_io_channel_protocol, cmd_q);\ - x->cmd_q.signal_size = SIZEOF_CMDRSP; \ - x->cmd_q.max_slots = \ - QSLOTSFROMBYTES(x->channel_header.size); \ - x->cmd_q.max_signals = x->cmd_q.max_slots - 1; \ - x->rsp_q.size = QSIZEFROMBYTES(x->channel_header.size); \ - x->rsp_q.sig_base_offset = \ - (SIZEOF_PROTOCOL + x->cmd_q.size) - \ - offsetof(struct spar_io_channel_protocol, rsp_q);\ - x->rsp_q.signal_size = SIZEOF_CMDRSP; \ - x->rsp_q.max_slots = \ - QSLOTSFROMBYTES(x->channel_header.size); \ - x->rsp_q.max_signals = x->rsp_q.max_slots - 1; \ - x->channel_header.ch_space_offset = \ - offsetof(struct spar_io_channel_protocol, cmd_q);\ - } while (0) - -#define INIT_CLIENTSTRING(chan, type, clientStr, clientStrLen) \ - do { \ - if (clientStr) { \ - chan->channel_header.cli_str_offset = \ - offsetof(type, client_string); \ - memcpy(chan->client_string, clientStr, \ - MINNUM(clientStrLen, \ - (u32)(MAX_CLIENTSTRING_LEN - 1))); \ - chan->client_string[MINNUM(clientStrLen, \ - (u32)(MAX_CLIENTSTRING_LEN \ - - 1))] \ - = '\0'; \ - } \ - else \ - if (clientStrLen > 0) \ - return 0; \ - } while (0) - -#define ULTRA_IO_CHANNEL_SERVER_READY(x, chanId, logCtx) \ - ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, CHANNELSRV_READY, \ - logCtx) - -#define ULTRA_IO_CHANNEL_SERVER_NOTREADY(x, chanId, logCtx) \ - ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, \ - CHANNELSRV_UNINITIALIZED, logCtx) - -static inline int ULTRA_VHBA_init_channel(struct spar_io_channel_protocol *x, - struct vhba_wwnn *wwnn, - struct vhba_config_max *max, - unsigned char *clientStr, - u32 clientStrLen, u64 bytes) { - memset(x, 0, sizeof(struct spar_io_channel_protocol)); - x->channel_header.version_id = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID; - x->channel_header.signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE; - x->channel_header.srv_state = CHANNELSRV_UNINITIALIZED; - x->channel_header.header_size = sizeof(x->channel_header); - x->channel_header.size = COVER(bytes, 4096); - x->channel_header.chtype = spar_vhba_channel_protocol_uuid; - x->channel_header.zone_uuid = NULL_UUID_LE; - x->vhba.wwnn = *wwnn; - x->vhba.max = *max; - INIT_CLIENTSTRING(x, struct spar_io_channel_protocol, clientStr, - clientStrLen); - SignalQInit(x); - if ((x->cmd_q.max_slots > MAX_NUMSIGNALS) || - (x->rsp_q.max_slots > MAX_NUMSIGNALS)) { - return 0; - } - if ((x->cmd_q.max_slots < MIN_NUMSIGNALS) || - (x->rsp_q.max_slots < MIN_NUMSIGNALS)) { - return 0; - } - return 1; -} - -static inline void ULTRA_VHBA_set_max(struct spar_io_channel_protocol *x, - struct vhba_config_max *max) { - x->vhba.max = *max; -} - -static inline int ULTRA_VNIC_init_channel(struct spar_io_channel_protocol *x, - unsigned char *macaddr, - u32 num_rcv_bufs, u32 mtu, - uuid_le zoneGuid, - unsigned char *clientStr, - u32 clientStrLen, - u64 bytes) { - memset(x, 0, sizeof(struct spar_io_channel_protocol)); - x->channel_header.version_id = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID; - x->channel_header.signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE; - x->channel_header.srv_state = CHANNELSRV_UNINITIALIZED; - x->channel_header.header_size = sizeof(x->channel_header); - x->channel_header.size = COVER(bytes, 4096); - x->channel_header.chtype = spar_vnic_channel_protocol_uuid; - x->channel_header.zone_uuid = NULL_UUID_LE; - memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); - x->vnic.num_rcv_bufs = num_rcv_bufs; - x->vnic.mtu = mtu; - x->vnic.zone_uuid = zoneGuid; - INIT_CLIENTSTRING(x, struct spar_io_channel_protocol, clientStr, - clientStrLen); - SignalQInit(x); - if ((x->cmd_q.max_slots > MAX_NUMSIGNALS) || - (x->rsp_q.max_slots > MAX_NUMSIGNALS)) { - return 0; - } - if ((x->cmd_q.max_slots < MIN_NUMSIGNALS) || - (x->rsp_q.max_slots < MIN_NUMSIGNALS)) { - return 0; - } - return 1; -} - -#endif /* __GNUC__ */ /* * INLINE function for expanding a guest's pfn-off-size into multiple 4K page -- cgit v1.2.3-59-g8ed1b From 8bde404338709f5d34f4123dd94e39d42c1a6957 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:06 -0400 Subject: staging: unisys: clean up UltraVbusChannelProtocol Fix the CamelCase name: UltraVbusChannelProtocolGuid => spar_vbus_channel_protocol_uuid Update related macro names to match. Update references to changed names. Fix indentation in macros where names changed. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/vbuschannel.h | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 9329e2838fde..aa2b34badf37 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -28,34 +28,34 @@ #include "channel.h" /* {193b331b-c58f-11da-95a9-00e08161165f} */ -#define ULTRA_VBUS_CHANNEL_PROTOCOL_GUID \ +#define SPAR_VBUS_CHANNEL_PROTOCOL_UUID \ UUID_LE(0x193b331b, 0xc58f, 0x11da, \ 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f) -static const uuid_le UltraVbusChannelProtocolGuid = - ULTRA_VBUS_CHANNEL_PROTOCOL_GUID; +static const uuid_le spar_vbus_channel_protocol_uuid = + SPAR_VBUS_CHANNEL_PROTOCOL_UUID; -#define ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE +#define SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE /* Must increment this whenever you insert or delete fields within this channel * struct. Also increment whenever you change the meaning of fields within this * channel struct so as to break pre-existing software. Note that you can * usually add fields to the END of the channel struct withOUT needing to * increment this. */ -#define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1 +#define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1 #define SPAR_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \ (spar_check_channel_client(pChannel, \ - UltraVbusChannelProtocolGuid, \ + spar_vbus_channel_protocol_uuid, \ "vbus", \ sizeof(struct ultra_vbus_channel_protocol),\ - ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ - ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \ + SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ + SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \ #define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes) \ - (spar_check_channel_server(UltraVbusChannelProtocolGuid, \ - "vbus", \ - sizeof(struct ultra_vbus_channel_protocol),\ - actualBytes)) + (spar_check_channel_server(spar_vbus_channel_protocol_uuid, \ + "vbus", \ + sizeof(struct ultra_vbus_channel_protocol),\ + actualBytes)) #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ typedef struct _ULTRA_VBUS_HEADERINFO { -- cgit v1.2.3-59-g8ed1b From 1aa46ce43dc26e69c8e46ac7d97fa0ef55178815 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:07 -0400 Subject: staging: unisys: fix parameters for SPAR_VBUS_CHANNEL_OK_CLIENT macro Remove the unused logCtx parameter and fix the CamelCase name: pChannel => ch Update calls to the macro to remove the unused second parameter. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/vbuschannel.h | 14 +++++++------- drivers/staging/unisys/uislib/uislib.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index aa2b34badf37..c1a73df43f35 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -43,13 +43,13 @@ static const uuid_le spar_vbus_channel_protocol_uuid = * increment this. */ #define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1 -#define SPAR_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \ - (spar_check_channel_client(pChannel, \ - spar_vbus_channel_protocol_uuid, \ - "vbus", \ - sizeof(struct ultra_vbus_channel_protocol),\ - SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ - SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \ +#define SPAR_VBUS_CHANNEL_OK_CLIENT(ch) \ + spar_check_channel_client(ch, \ + spar_vbus_channel_protocol_uuid, \ + "vbus", \ + sizeof(struct ultra_vbus_channel_protocol),\ + SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ + SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE) #define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes) \ (spar_check_channel_server(spar_vbus_channel_protocol_uuid, \ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 6e0873455651..354b6827bac4 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes) rc = NULL; goto Away; } - if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) { + if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan)) { ERRDRV("%s channel cannot be used", __func__); uislib_iounmap(pChan); rc = NULL; -- cgit v1.2.3-59-g8ed1b From 9b8a8a96b7b41fac458fab603f51ec562b31ae21 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:08 -0400 Subject: staging: unisys: refactor ULTRA_VBUS_CHANNEL_OK_SERVER Fix the name to SPAR_VBUS_CHANNEL_OK_SERVER and fix the CamelCase parameter: actualBytes => actual_bytes Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/vbuschannel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index c1a73df43f35..873ba76253dd 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -51,11 +51,11 @@ static const uuid_le spar_vbus_channel_protocol_uuid = SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE) -#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes) \ +#define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes) \ (spar_check_channel_server(spar_vbus_channel_protocol_uuid, \ "vbus", \ sizeof(struct ultra_vbus_channel_protocol),\ - actualBytes)) + actual_bytes)) #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ typedef struct _ULTRA_VBUS_HEADERINFO { -- cgit v1.2.3-59-g8ed1b From 1cb3b9de239b2aecfa3326401f2214e9c4770158 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:09 -0400 Subject: staging: unisys: refactor ULTRA_VBUS_HEADERINFO Remove the typedef and rename to struct spar_vbus_headerinfo. Fix CamelCase member names: structBytes => struct_bytes deviceInfoStructBytes => device_info_struct_bytes devInfoCount => dev_info_count chpInfoByteOffset => chp_info_offset busInfoByteOffset => bus_info_offset devInfoByteOffset => dev_info_offset Update all references to changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/vbuschannel.h | 18 +++++++++--------- drivers/staging/unisys/virtpci/virtpci.c | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 873ba76253dd..360fba67da15 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -58,23 +58,23 @@ static const uuid_le spar_vbus_channel_protocol_uuid = actual_bytes)) #pragma pack(push, 1) /* both GCC and VC now allow this pragma */ -typedef struct _ULTRA_VBUS_HEADERINFO { - u32 structBytes; /* size of this struct in bytes */ - u32 deviceInfoStructBytes; /* sizeof(ULTRA_VBUS_DEVICEINFO) */ - u32 devInfoCount; /* num of items in DevInfo member */ +struct spar_vbus_headerinfo { + u32 struct_bytes; /* size of this struct in bytes */ + u32 device_info_struct_bytes; /* sizeof(ULTRA_VBUS_DEVICEINFO) */ + u32 dev_info_count; /* num of items in DevInfo member */ /* (this is the allocated size) */ - u32 chpInfoByteOffset; /* byte offset from beginning of this struct */ + u32 chp_info_offset; /* byte offset from beginning of this struct */ /* to the ChpInfo struct (below) */ - u32 busInfoByteOffset; /* byte offset from beginning of this struct */ + u32 bus_info_offset; /* byte offset from beginning of this struct */ /* to the BusInfo struct (below) */ - u32 devInfoByteOffset; /* byte offset from beginning of this struct */ + u32 dev_info_offset; /* byte offset from beginning of this struct */ /* to the DevInfo array (below) */ u8 reserved[104]; -} ULTRA_VBUS_HEADERINFO; +}; struct ultra_vbus_channel_protocol { struct channel_header ChannelHeader; /* initialized by server */ - ULTRA_VBUS_HEADERINFO HdrInfo; /* initialized by server */ + struct spar_vbus_headerinfo HdrInfo; /* initialized by server */ /* the remainder of this channel is filled in by the client */ struct ultra_vbus_deviceinfo ChpInfo; /* describes client chipset device and driver */ diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index ee1beb546635..36174628af41 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -195,9 +195,9 @@ static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, LOGERR("vbus channel not present"); return -1; } - off = sizeof(struct channel_header) + chan->HdrInfo.chpInfoByteOffset; - if (chan->HdrInfo.chpInfoByteOffset == 0) { - LOGERR("vbus channel not used, because chpInfoByteOffset == 0"); + off = sizeof(struct channel_header) + chan->HdrInfo.chp_info_offset; + if (chan->HdrInfo.chp_info_offset == 0) { + LOGERR("vbus channel not used, because chp_info_offset == 0"); return -1; } memcpy(((u8 *) (chan)) + off, info, sizeof(*info)); @@ -214,9 +214,9 @@ static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, LOGERR("vbus channel not present"); return -1; } - off = sizeof(struct channel_header) + chan->HdrInfo.busInfoByteOffset; - if (chan->HdrInfo.busInfoByteOffset == 0) { - LOGERR("vbus channel not used, because busInfoByteOffset == 0"); + off = sizeof(struct channel_header) + chan->HdrInfo.bus_info_offset; + if (chan->HdrInfo.bus_info_offset == 0) { + LOGERR("vbus channel not used, because bus_info_offset == 0"); return -1; } memcpy(((u8 *) (chan)) + off, info, sizeof(*info)); @@ -238,10 +238,10 @@ write_vbus_devInfo(struct ultra_vbus_channel_protocol *chan, } off = (sizeof(struct channel_header) + - chan->HdrInfo.devInfoByteOffset) + - (chan->HdrInfo.deviceInfoStructBytes * devix); - if (chan->HdrInfo.devInfoByteOffset == 0) { - LOGERR("vbus channel not used, because devInfoByteOffset == 0"); + chan->HdrInfo.dev_info_offset) + + (chan->HdrInfo.device_info_struct_bytes * devix); + if (chan->HdrInfo.dev_info_offset == 0) { + LOGERR("vbus channel not used, because dev_info_offset == 0"); return -1; } memcpy(((u8 *) (chan)) + off, info, sizeof(*info)); -- cgit v1.2.3-59-g8ed1b From a02fd66ec80d25ff9c792e96bdc895e4b8e0935b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Thu, 23 Oct 2014 14:31:10 -0400 Subject: staging: unisys: refactor struct struct ultra_vbus_channel_protocol Rename the struct to spar_vbus_channel_protocol. Fix CamelCase member names: ChannelHeader => channel_header HdrInfo => hdr_info ChpInfo => chp_info BusInfo => bus_info DevInfo => dev_info Update all references to use the changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../common-spar/include/channels/vbuschannel.h | 22 +++++++++++----------- drivers/staging/unisys/virtpci/virtpci.c | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 360fba67da15..2c42ce16e0cf 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -45,11 +45,11 @@ static const uuid_le spar_vbus_channel_protocol_uuid = #define SPAR_VBUS_CHANNEL_OK_CLIENT(ch) \ spar_check_channel_client(ch, \ - spar_vbus_channel_protocol_uuid, \ - "vbus", \ - sizeof(struct ultra_vbus_channel_protocol),\ - SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ - SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE) + spar_vbus_channel_protocol_uuid, \ + "vbus", \ + sizeof(struct spar_vbus_channel_protocol),\ + SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ + SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE) #define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes) \ (spar_check_channel_server(spar_vbus_channel_protocol_uuid, \ @@ -72,15 +72,15 @@ struct spar_vbus_headerinfo { u8 reserved[104]; }; -struct ultra_vbus_channel_protocol { - struct channel_header ChannelHeader; /* initialized by server */ - struct spar_vbus_headerinfo HdrInfo; /* initialized by server */ +struct spar_vbus_channel_protocol { + struct channel_header channel_header; /* initialized by server */ + struct spar_vbus_headerinfo hdr_info; /* initialized by server */ /* the remainder of this channel is filled in by the client */ - struct ultra_vbus_deviceinfo ChpInfo; + struct ultra_vbus_deviceinfo chp_info; /* describes client chipset device and driver */ - struct ultra_vbus_deviceinfo BusInfo; + struct ultra_vbus_deviceinfo bus_info; /* describes client bus device and driver */ - struct ultra_vbus_deviceinfo DevInfo[0]; + struct ultra_vbus_deviceinfo dev_info[0]; /* describes client device and driver for each device on the bus */ }; diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 36174628af41..6fa8caf5381e 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -186,7 +186,7 @@ int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem *chanptr) } /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */ -static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, +static int write_vbus_chpInfo(struct spar_vbus_channel_protocol *chan, struct ultra_vbus_deviceinfo *info) { int off; @@ -195,8 +195,8 @@ static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, LOGERR("vbus channel not present"); return -1; } - off = sizeof(struct channel_header) + chan->HdrInfo.chp_info_offset; - if (chan->HdrInfo.chp_info_offset == 0) { + off = sizeof(struct channel_header) + chan->hdr_info.chp_info_offset; + if (chan->hdr_info.chp_info_offset == 0) { LOGERR("vbus channel not used, because chp_info_offset == 0"); return -1; } @@ -205,7 +205,7 @@ static int write_vbus_chpInfo(struct ultra_vbus_channel_protocol *chan, } /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */ -static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, +static int write_vbus_busInfo(struct spar_vbus_channel_protocol *chan, struct ultra_vbus_deviceinfo *info) { int off; @@ -214,8 +214,8 @@ static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, LOGERR("vbus channel not present"); return -1; } - off = sizeof(struct channel_header) + chan->HdrInfo.bus_info_offset; - if (chan->HdrInfo.bus_info_offset == 0) { + off = sizeof(struct channel_header) + chan->hdr_info.bus_info_offset; + if (chan->hdr_info.bus_info_offset == 0) { LOGERR("vbus channel not used, because bus_info_offset == 0"); return -1; } @@ -227,7 +227,7 @@ static int write_vbus_busInfo(struct ultra_vbus_channel_protocol *chan, * ULTRA_VBUS_CHANNEL_PROTOCOL.DevInfo[]. */ static int -write_vbus_devInfo(struct ultra_vbus_channel_protocol *chan, +write_vbus_devInfo(struct spar_vbus_channel_protocol *chan, struct ultra_vbus_deviceinfo *info, int devix) { int off; @@ -238,9 +238,9 @@ write_vbus_devInfo(struct ultra_vbus_channel_protocol *chan, } off = (sizeof(struct channel_header) + - chan->HdrInfo.dev_info_offset) + - (chan->HdrInfo.device_info_struct_bytes * devix); - if (chan->HdrInfo.dev_info_offset == 0) { + chan->hdr_info.dev_info_offset) + + (chan->hdr_info.device_info_struct_bytes * devix); + if (chan->hdr_info.dev_info_offset == 0) { LOGERR("vbus channel not used, because dev_info_offset == 0"); return -1; } -- cgit v1.2.3-59-g8ed1b From 94d2fc6361a75b61a0753114e52379f1c900fb30 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Sat, 25 Oct 2014 11:56:29 +0530 Subject: Staging: rtl8723au: Use USB API functions This patch replaces driver specific functions(RT_usb_endpoint_is_bulk_in, RT_usb_endpoint_is_bulk_out, RT_usb_endpoint_is_int_in) with USB API functions(usb_endpoint_is_bulk_in, usb_endpoint_is_bulk_out, usb_endpoint_is_int_in). Also, this patch removes these three RT functions as they are no longer needed after replacement. This patch also have one line over 80 characters as limiting it to 80 characters does not make code look good. Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_intf.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 865743ecd855..08424d478039 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -59,21 +59,6 @@ static struct usb_driver rtl8723a_usb_drv = { static struct usb_driver *usb_drv = &rtl8723a_usb_drv; -static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) -{ - return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); -} - -static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) -{ - return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); -} - -static inline int RT_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) -{ - return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); -} - static int rtw_init_intf_priv(struct dvobj_priv *dvobj) { mutex_init(&dvobj->usb_vendor_req_mutex); @@ -143,21 +128,21 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) le16_to_cpu(pendp_desc->wMaxPacketSize)); DBG_8723A("bInterval =%x\n", pendp_desc->bInterval); - if (RT_usb_endpoint_is_bulk_in(pendp_desc)) { - DBG_8723A("RT_usb_endpoint_is_bulk_in = %x\n", + if (usb_endpoint_is_bulk_in(pendp_desc)) { + DBG_8723A("usb_endpoint_is_bulk_in = %x\n", usb_endpoint_num(pendp_desc)); pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumInPipes++; - } else if (RT_usb_endpoint_is_int_in(pendp_desc)) { - DBG_8723A("RT_usb_endpoint_is_int_in = %x, Interval = %x\n", + } else if (usb_endpoint_is_int_in(pendp_desc)) { + DBG_8723A("usb_endpoint_is_int_in = %x, Interval = %x\n", usb_endpoint_num(pendp_desc), pendp_desc->bInterval); pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumInPipes++; - } else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) { - DBG_8723A("RT_usb_endpoint_is_bulk_out = %x\n", + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + DBG_8723A("usb_endpoint_is_bulk_out = %x\n", usb_endpoint_num(pendp_desc)); pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = usb_endpoint_num(pendp_desc); -- cgit v1.2.3-59-g8ed1b From 8a0aa750c1e8626808775bb7a55d6ae6bb1111cd Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Sat, 25 Oct 2014 20:07:52 +0800 Subject: staging: rtl8723au: delete successive assignments to the same location Successive assignments to the same location is meaningless and can be deleted. The Coccinelle semantic patch was used to find cases. @@ expression e1,e2,e3; @@ ( (<+...e1++...+>)=e2; | (<+...e1--...+>)=e2; | (<+...++e1...+>)=e2; | (<+...--e1...+>)=e2; | e1=e2; e1 = <+...e1...+>; | *e1=e2; *e1=e3; ) Signed-off-by: Jiayi Ye Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 -- drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 1 - 3 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 86f5217afe93..10f8031e29cf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2339,8 +2339,6 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) switch (hidden_ssid_mode) { case 1: next_ie = ssid_ie + 2 + ssid_len_ori; - remain_len = 0; - remain_len = ies_len -(next_ie-ies); ssid_ie[1] = 0; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index a5de03d45aa9..6c1dcf0b0d7d 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1485,7 +1485,6 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, } /* mask &= 0x0fffffff; */ - rate_bitmap = 0x0fffffff; rate_bitmap = ODM_Get_Rate_Bitmap23a(pHalData, mac_id, mask, rssi_level); DBG_8723A("%s => mac_id:%d, networkType:0x%02x, " diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 2f01714bc9e2..e154de9b656b 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2363,7 +2363,6 @@ void rtw_cfg80211_indicate_sta_assoc(struct rtw_adapter *padapter, ie_offset = offsetof(struct ieee80211_mgmt, u.reassoc_req.variable); - sinfo.filled = 0; sinfo.filled = STATION_INFO_ASSOC_REQ_IES; sinfo.assoc_req_ies = pmgmt_frame + ie_offset; sinfo.assoc_req_ies_len = frame_len - ie_offset; -- cgit v1.2.3-59-g8ed1b From de1de2f68b2be51cdc90e920cb9173598a88a9c0 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Sat, 25 Oct 2014 16:56:01 -0700 Subject: Staging: rtl8723au: core: Add braces around macro This patch fixes the following checkpatch warning: ERROR: Macros with complex values should be enclosed in parentheses 1535: FILE: drivers/staging/rtl8723au/core/rtw_mlme.c:1535: Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 21484e757b15..ba201300cc1f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1532,7 +1532,8 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) } #if defined(IEEE80211_SCAN_RESULT_EXPIRE) -#define RTW_SCAN_RESULT_EXPIRE IEEE80211_SCAN_RESULT_EXPIRE/HZ*1000 -1000 /* 3000 -1000 */ +#define RTW_SCAN_RESULT_EXPIRE \ + ((IEEE80211_SCAN_RESULT_EXPIRE / (HZ*1000)) - 1000) /* 3000 -1000 */ #else #define RTW_SCAN_RESULT_EXPIRE 2000 #endif -- cgit v1.2.3-59-g8ed1b From 08551cbb176afa0d71d4a059b2893c6575e8a8ad Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sun, 26 Oct 2014 23:30:05 +0200 Subject: staging: rtl8723au: Do not use comparisons on bool tests This patch removes unnecessary comparisons to bool. It fixes the following warning detected using coccinelle tool: WARNING: Comparison to bool. Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ++-- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 6a336cd2eb4d..d00255fbfcbc 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1605,7 +1605,7 @@ u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool acti if (!psta) return beacon_updated; - if (active == true) { + if (active) { /* tear down Rx AMPDU */ send_delba23a(padapter, 0, psta->hwaddr);/* recipient */ diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 01b44a4364dc..424d96a1859a 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1149,7 +1149,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) val = rtl8723a_chk_hi_queue_empty(padapter); - while (val == false) { + while (!val) { msleep(100); cnt++; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index ba201300cc1f..4e2b22d97101 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1121,7 +1121,7 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { - if (the_same_macaddr == true) { + if (the_same_macaddr) { ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); } else { pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 10f8031e29cf..2624c778eff7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3999,7 +3999,7 @@ int send_beacon23a(struct rtw_adapter *padapter) yield(); bxmitok = rtl8723a_get_bcn_valid(padapter); poll++; - } while ((poll % 10) != 0 && bxmitok == false && + } while ((poll % 10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 1eae885c1170..e2d51afe522c 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -159,7 +159,7 @@ void rtw_ps_processor23a(struct rtw_adapter *padapter) if (pwrpriv->ips_mode_req == IPS_NONE) goto exit; - if (rtw_pwr_unassociated_idle(padapter) == false) + if (!rtw_pwr_unassociated_idle(padapter)) goto exit; if (pwrpriv->rf_pwrstate == rf_on && diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index c0325c96d616..bc63d6f1773a 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -866,7 +866,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, int pie_len, ssid_len, privacy; const u8 *p, *ssid; - if (is_client_associated_to_ap23a(Adapter) == false) + if (!is_client_associated_to_ap23a(Adapter)) return _SUCCESS; if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) { diff --git a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c index 4b41bc4ce1e6..179a1ba03029 100644 --- a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c +++ b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c @@ -612,7 +612,7 @@ static void _PHY_PathADDAOn(struct rtw_adapter *pAdapter, u32 *ADDAReg, bool isP u32 i; pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4; - if (false == is2T) { + if (!is2T) { pathOn = 0x0bdb25a0; PHY_SetBBReg(pAdapter, ADDAReg[0], bMaskDWord, 0x0b1b25a0); } else { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8523908d5e5f..1ccf60a9e528 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1945,13 +1945,13 @@ Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, /* */ /* ThermalMeter from EEPROM */ /* */ - if (AutoloadFail == false) + if (!AutoloadFail) pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_8723A]; else pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - if ((pHalData->EEPROMThermalMeter == 0xff) || (AutoloadFail == true)) { + if ((pHalData->EEPROMThermalMeter == 0xff) || AutoloadFail) { pHalData->bAPKThermalMeterIgnore = true; pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; } diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 6c1dcf0b0d7d..adc2953fcaf4 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -480,7 +480,7 @@ static void _InitRFType(struct rtw_adapter *Adapter) pHalData->rf_chip = RF_6052; - if (is92CU == false) { + if (!is92CU) { pHalData->rf_type = RF_1T1R; DBG_8723A("Set RF Chip ID to RF_6052 and RF type to 1T1R.\n"); return; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 2ff01eb8fc0c..a6751f138336 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -270,7 +270,7 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state) { spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, state) == true) + if (check_fwstate(pmlmepriv, state)) pmlmepriv->fw_state ^= state; spin_unlock_bh(&pmlmepriv->lock); } -- cgit v1.2.3-59-g8ed1b From b9b4224b13c338f752c12a402e2db99f59047827 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sun, 26 Oct 2014 23:30:06 +0200 Subject: staging: rtl8723au: Remove uneeded semicolon This patch fixes the following warning detected using coccinelle: Unneeded semicolon. Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_recv.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index d00255fbfcbc..e394d12c36b0 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -636,7 +636,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) bcn_interval = (u16)pnetwork->beacon_interval; cur_channel = pnetwork->DSConfig; - cur_bwmode = HT_CHANNEL_WIDTH_20;; + cur_bwmode = HT_CHANNEL_WIDTH_20; cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; /* check if there is wps ie, */ diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 0c0896f3a16b..6cdfc2337c4b 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1694,7 +1694,7 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, skb_put(skb, pnfhdr->pkt->len); prframe->attrib.icv_len = pnfhdr->attrib.icv_len; - }; + } /* free the defrag_q queue and return the prframe */ rtw_free_recvframe23a_queue(defrag_q); -- cgit v1.2.3-59-g8ed1b From 147e45d9210ce303eb8a3a3c6593631ff78cd072 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sun, 26 Oct 2014 23:30:07 +0200 Subject: staging: rtl8723au: hal: Remove uneeded return variable This patch removes uneeded return variables, just using 'return _SUCCESS' or 'return HCI_STATUS_SUCCESS' instead. This fixes the following warning detected using coccinelle: Unneeded variable. It was done using the following semantic patch: @@ identifier ret; type T; expression e; @@ -T ret = e; ... when != ret when strict -return ret; +return e; Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 17 +++++------------ drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 7 ++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 14 ++++---------- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 3 +-- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 9054a987f06b..5de806e45c3b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -1766,9 +1766,7 @@ bthci_CmdSetEventFilter( struct packet_irp_hcicmd_data *pHciCmd ) { - enum hci_status status = HCI_STATUS_SUCCESS; - - return status; + return HCI_STATUS_SUCCESS; } /* 7.3.14 */ @@ -2984,8 +2982,7 @@ bthci_CmdReadLinkQuality( static enum hci_status bthci_CmdReadRSSI(struct rtw_adapter *padapter) { - enum hci_status status = HCI_STATUS_SUCCESS; - return status; + return HCI_STATUS_SUCCESS; } static enum hci_status @@ -2994,7 +2991,6 @@ bthci_CmdCreateLogicalLink( struct packet_irp_hcicmd_data *pHciCmd ) { - enum hci_status status = HCI_STATUS_SUCCESS; struct bt_30info *pBTInfo = GET_BT_INFO(padapter); struct bt_dgb *pBtDbg = &pBTInfo->BtDbg; @@ -3003,7 +2999,7 @@ bthci_CmdCreateLogicalLink( bthci_BuildLogicalLink(padapter, pHciCmd, HCI_CREATE_LOGICAL_LINK); - return status; + return HCI_STATUS_SUCCESS; } static enum hci_status @@ -3012,7 +3008,6 @@ bthci_CmdAcceptLogicalLink( struct packet_irp_hcicmd_data *pHciCmd ) { - enum hci_status status = HCI_STATUS_SUCCESS; struct bt_30info *pBTInfo = GET_BT_INFO(padapter); struct bt_dgb *pBtDbg = &pBTInfo->BtDbg; @@ -3021,7 +3016,7 @@ bthci_CmdAcceptLogicalLink( bthci_BuildLogicalLink(padapter, pHciCmd, HCI_ACCEPT_LOGICAL_LINK); - return status; + return HCI_STATUS_SUCCESS; } static enum hci_status @@ -4141,9 +4136,7 @@ static enum hci_status bthci_CmdHostNumberOfCompletedPackets(struct rtw_adapter *padapter, struct packet_irp_hcicmd_data *pHciCmd) { - enum hci_status status = HCI_STATUS_SUCCESS; - - return status; + return HCI_STATUS_SUCCESS; } static enum hci_status diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 271c33d6ca5a..7b56411cc3c8 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -115,19 +115,16 @@ exit: int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param) { - int res = _SUCCESS; - *((u32 *)param) = cpu_to_le32(*((u32 *)param)); FillH2CCmd(padapter, RSSI_SETTING_EID, 3, param); - return res; + return _SUCCESS; } int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg) { u8 buf[5]; - int res = _SUCCESS; memset(buf, 0, 5); mask = cpu_to_le32(mask); @@ -136,7 +133,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg) FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf); - return res; + return _SUCCESS; } /* bitmap[0:27] = tx_rate_bitmap */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 1ccf60a9e528..9a75eb6bb5a3 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1522,10 +1522,8 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) /* HW Auto state machine */ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) { - int rtStatus = _SUCCESS; - if (padapter->bSurpriseRemoved) { - return rtStatus; + return _SUCCESS; } /* RF Off Sequence ==== */ _DisableRFAFEAndResetBB(padapter); @@ -1542,18 +1540,14 @@ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("======> Card disable finished.\n")); - return rtStatus; + return _SUCCESS; } /* without HW Auto state machine */ int CardDisableWithoutHWSM(struct rtw_adapter *padapter) { - int rtStatus = _SUCCESS; - - /* RT_TRACE(COMP_INIT, DBG_LOUD, - ("======> Card Disable Without HWSM .\n")); */ if (padapter->bSurpriseRemoved) { - return rtStatus; + return _SUCCESS; } /* RF Off Sequence ==== */ @@ -1573,7 +1567,7 @@ int CardDisableWithoutHWSM(struct rtw_adapter *padapter) /* RT_TRACE(COMP_INIT, DBG_LOUD, ("<====== Card Disable Without HWSM .\n")); */ - return rtStatus; + return _SUCCESS; } void Hal_InitPGData(struct rtw_adapter *padapter, u8 *PROMContent) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 3d4d7ec27509..88e91cd8ebb9 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -418,7 +418,6 @@ PHY_SetRFReg(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath, *---------------------------------------------------------------------------*/ int PHY_MACConfig8723A(struct rtw_adapter *Adapter) { - int rtStatus = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); bool is92C = IS_92C_SERIAL(pHalData->VersionID); @@ -433,7 +432,7 @@ int PHY_MACConfig8723A(struct rtw_adapter *Adapter) if (is92C && (BOARD_USB_DONGLE == pHalData->BoardType)) rtl8723au_write8(Adapter, 0x40, 0x04); - return rtStatus; + return _SUCCESS; } /** -- cgit v1.2.3-59-g8ed1b From 35a0072771b14acdd437873c5aacf6715552ac85 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sun, 26 Oct 2014 23:30:08 +0200 Subject: staging: rtl8723au: os_dep: Remove uneeded return variable This patch removes uneeded return variables, using only 'return _SUCCESS' instead. It fixes the following warning detected by coccinelle: Unneeded variable. It was done using the following semantic patch: @@ identifier ret; type T; expression e; @@ -T ret = e; ... when != ret when strict -return ret; +return e; Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index ddd0a9f1eefb..d00100356630 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -175,7 +175,6 @@ static int netdev_close(struct net_device *pnetdev); static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) { struct registry_priv *registry_par = &padapter->registrypriv; - int status = _SUCCESS; GlobalDebugLevel23A = rtw_debug; registry_par->chip_version = (u8)rtw_chip_version; @@ -234,7 +233,7 @@ static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; registry_par->regulatory_tid = (u8)rtw_regulatory_id; - return status; + return _SUCCESS; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) @@ -384,7 +383,6 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - int ret = _SUCCESS; /* xmit_priv */ pxmitpriv->vcs = pregistrypriv->vcs_type; @@ -423,7 +421,7 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) /* misc. */ padapter->bReadPortCancel = false; padapter->bWritePortCancel = false; - return ret; + return _SUCCESS; } int rtw_reset_drv_sw23a(struct rtw_adapter *padapter) -- cgit v1.2.3-59-g8ed1b From 038b70395a8a9b290bcd3aed292e4130a83944c7 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sun, 26 Oct 2014 23:30:09 +0200 Subject: staging: rtl8723au: core: Remove uneeded return variable This patch removes uneeded return variables, using only 'return _SUCCESS' instead. It fixes the following warning detected by coccinelle: Unneeded variable. It was done using the following semantic patch: @@ identifier ret; type T; expression e; @@ -T ret = e; ... when != ret when strict -return ret; +return e; Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 3 +-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 +-- drivers/staging/rtl8723au/core/rtw_recv.c | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 4e2b22d97101..85d1eca5af8b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -50,7 +50,6 @@ static void rtw_init_mlme_timer(struct rtw_adapter *padapter) int rtw_init_mlme_priv23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int res = _SUCCESS; pmlmepriv->nic_hdl = padapter; @@ -68,7 +67,7 @@ int rtw_init_mlme_priv23a(struct rtw_adapter *padapter) rtw_clear_scan_deny(padapter); rtw_init_mlme_timer(padapter); - return res; + return _SUCCESS; } #ifdef CONFIG_8723AU_AP_MODE diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 2624c778eff7..0e0f73c86e53 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -567,7 +567,6 @@ static u8 init_channel_set(struct rtw_adapter *padapter, u8 cplan, int init_mlme_ext_priv23a(struct rtw_adapter *padapter) { - int res = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -594,7 +593,7 @@ int init_mlme_ext_priv23a(struct rtw_adapter *padapter) pmlmeext->mlmeext_init = true; pmlmeext->active_keep_alive_check = true; - return res; + return _SUCCESS; } void free_mlme_ext_priv23a (struct mlme_ext_priv *pmlmeext) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 6cdfc2337c4b..de98da5baa2b 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1554,8 +1554,6 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) u16 eth_type, len, hdrlen; u8 bsnaphdr; u8 *psnap; - - int ret = _SUCCESS; struct rtw_adapter *adapter = precvframe->adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -1616,7 +1614,7 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) } - return ret; + return _SUCCESS; } /* perform defrag */ -- cgit v1.2.3-59-g8ed1b From 85b4260ddfed16b0069262a2a843fd59562a2ee2 Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Sun, 26 Oct 2014 23:30:10 +0200 Subject: staging: rtl8723au: Remove duplicated argument to || This patch removes duplicated argument to ||, fixing the following warning detected using coccinelle tool: duplicated argument to && or ||. Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index bc63d6f1773a..69d9e0f17fd8 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1322,7 +1322,6 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) DBG_8723A("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; } else if (!memcmp(p + 2, BROADCOM_OUI1, 3) || - !memcmp(p + 2, BROADCOM_OUI2, 3) || !memcmp(p + 2, BROADCOM_OUI2, 3)) { DBG_8723A("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; -- cgit v1.2.3-59-g8ed1b From 3247c4e5ef5d78b47bf2b223d2e684e77845431b Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Sat, 25 Oct 2014 11:40:32 +0800 Subject: staging: lustre: lnet: klnds: o2iblnd: fix null dereference on failed path in o2iblnd.c If net is null and failed path is executed, dereference null may happen. This patch fixes it. The following Coccinelle semantic patch was used. @@ expression E, E1; identifier f; statement S1,S2,S3; @@ * if (E == NULL) { ... when != if (E == NULL) S1 else S2 when != E = E1 * E->f ... when any return ...; } else S3 Signed-off-by: Jiayi Ye Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 045f2beb41d2..bc479a721a60 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -3081,7 +3081,7 @@ kiblnd_startup (lnet_ni_t *ni) LIBCFS_ALLOC(net, sizeof(*net)); ni->ni_data = net; if (net == NULL) - goto failed; + goto net_failed; do_gettimeofday(&tv); net->ibn_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; @@ -3147,6 +3147,7 @@ failed: if (net->ibn_dev == NULL && ibdev != NULL) kiblnd_destroy_dev(ibdev); +net_failed: kiblnd_shutdown(ni); CDEBUG(D_NET, "kiblnd_startup failed\n"); -- cgit v1.2.3-59-g8ed1b From f526b20adf27f0a78c643b3fd7c4efc9687d313e Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Sat, 25 Oct 2014 14:45:55 -0700 Subject: Staging: lustre: lnet: Make functions static This patch makes the following functions static as they are only used in their respective files. These functions were detected by sparse. - lib-md.c : lnet_md_validate - lib-move.c : lnet_ni_* lnet_setpayloadbuffer lnet_peer_alive_locked lnet_msg2bufpool lnet_post_routed_recv_locked lnet_configure / lnet_unconfigure lnet_ioctl init_lnet fini_lnet Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/lib-md.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 16 ++++++++-------- drivers/staging/lustre/lnet/lnet/module.c | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index e4d906a65635..3225c069637d 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -218,7 +218,7 @@ lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd) lnet_eq2handle(&umd->eq_handle, lmd->md_eq); } -int +static int lnet_md_validate(lnet_md_t *umd) { if (umd->start == NULL && umd->length != 0) { diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 4b9567d67f33..5754725f0745 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -561,7 +561,7 @@ lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst, } EXPORT_SYMBOL(lnet_extract_kiov); -void +static void lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen) { @@ -599,7 +599,7 @@ lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, lnet_finalize(ni, msg, rc); } -void +static void lnet_setpayloadbuffer(lnet_msg_t *msg) { lnet_libmd_t *md = msg->msg_md; @@ -639,7 +639,7 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target, msg->msg_hdr.payload_length = cpu_to_le32(len); } -void +static void lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) { void *priv = msg->msg_private; @@ -654,7 +654,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) lnet_finalize(ni, msg, rc); } -int +static int lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) { int rc; @@ -679,7 +679,7 @@ lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) } /* NB: caller shall hold a ref on 'lp' as I'd drop lnet_net_lock */ -void +static void lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp) { unsigned long last_alive = 0; @@ -731,7 +731,7 @@ lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now) /* NB: returns 1 when alive, 0 when dead, negative when error; * may drop the lnet_net_lock */ -int +static int lnet_peer_alive_locked(lnet_peer_t *lp) { unsigned long now = cfs_time_current(); @@ -871,7 +871,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) } -lnet_rtrbufpool_t * +static lnet_rtrbufpool_t * lnet_msg2bufpool(lnet_msg_t *msg) { lnet_rtrbufpool_t *rbp; @@ -891,7 +891,7 @@ lnet_msg2bufpool(lnet_msg_t *msg) return rbp; } -int +static int lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) { /* lnet_parse is going to lnet_net_unlock immediately after this, so it diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index e84d59d23ae0..dc09b4377a2f 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -43,7 +43,7 @@ MODULE_PARM_DESC(config_on_load, "configure network at module load"); static struct mutex lnet_config_mutex; -int +static int lnet_configure(void *arg) { /* 'arg' only there so I can be passed to cfs_create_thread() */ @@ -63,7 +63,7 @@ lnet_configure(void *arg) return rc; } -int +static int lnet_unconfigure(void) { int refcount; @@ -83,7 +83,7 @@ lnet_unconfigure(void) return (refcount == 0) ? 0 : -EBUSY; } -int +static int lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) { int rc; @@ -110,7 +110,7 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl); -int +static int init_lnet(void) { int rc; @@ -135,7 +135,7 @@ init_lnet(void) return 0; } -void +static void fini_lnet(void) { int rc; -- cgit v1.2.3-59-g8ed1b From c650ba7377ad3602b3fad8651ceeec8a20b74b17 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Sat, 25 Oct 2014 16:35:49 -0700 Subject: Staging: lustre: llite: Simplify error handling This patch fixes the following checkpatch error: ERROR: do not use assignment in if condition 2172: FILE: drivers/staging/lustre/lustre/llite/llite_lib.c:2172: if (!inode || !(sbi = ll_i2sbi(inode))) { Signed-off-by: Tina Ruchandani Suggested-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 43ab250b087e..74cd4515ac50 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2169,7 +2169,13 @@ int ll_obd_statfs(struct inode *inode, void *arg) __u32 flags; int len = 0, rc; - if (!inode || !(sbi = ll_i2sbi(inode))) { + if (!inode) { + rc = -EINVAL; + goto out_statfs; + } + + sbi = ll_i2sbi(inode); + if (!sbi) { rc = -EINVAL; goto out_statfs; } -- cgit v1.2.3-59-g8ed1b From a707edd2360e739a27fd7b1720edd075ee5f7f64 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sun, 26 Oct 2014 21:35:04 +0530 Subject: staging: rtl8188eu: core: Remove redundant memset before memcpy The region set by the call to memset, immediately overwritten by the subsequent call to memcpy makes the memset redundant. This patch removes the redundant memset before memcpy using the following coccinelle script: @@ expression e1,e2,e3,e4; @@ - memset(e1,e2,e3); memcpy(e1,e4,e3); Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 1 - drivers/staging/rtl8188eu/core/rtw_mlme.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index fc280ce57d2c..2faf6b2e8129 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -98,7 +98,6 @@ u8 rtw_do_join(struct adapter *padapter) pibss = padapter->registrypriv.dev_network.MacAddress; - memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(padapter); diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index bbebe67a77db..b4e8504b34ed 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -674,7 +674,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); - memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(adapter); @@ -1334,7 +1333,6 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); - memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(adapter); -- cgit v1.2.3-59-g8ed1b From be40a5e29e3eba9c5628512b6f991ab6822a3f04 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sat, 25 Oct 2014 10:46:02 +0530 Subject: staging: unisys: visorchannel: Improved cleanup code kfree on NULL pointer is a no-op. This patch used the following semantic patch to find an instance where NULL check is present before kfree // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // Code is made more simpler by breaking up of sequence of kmallocs and adding some more exit labels. Removed unnecessary initialization of buf and fmtbuf to NULL as they are local variables. Suggested-by: Arnd Bergmann Suggested-by: Julia Lawall Signed-off-by: Tapasweni Pathak Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchannel/visorchannel_funcs.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index c24052b13fd2..5fbd5ada52e9 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -650,15 +650,17 @@ visorchannel_dump_section(VISORCHANNEL *chan, char *s, fmtbufsize = 100 * COVQ(len, 16); buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY); + if (!buf) + return; fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY); - if (buf == NULL || fmtbuf == NULL) - goto Away; + if (!fmtbuf) + goto fmt_failed; errcode = visorchannel_read(chan, off, buf, len); if (errcode < 0) { ERRDRV("%s failed to read %s from channel errcode=%d", s, __func__, errcode); - goto Away; + goto read_failed; } seq_printf(seq, "channel %s:\n", s); tbuf = buf; @@ -670,14 +672,9 @@ visorchannel_dump_section(VISORCHANNEL *chan, char *s, len -= 16; } -Away: - if (buf != NULL) { - kfree(buf); - buf = NULL; - } - if (fmtbuf != NULL) { - kfree(fmtbuf); - fmtbuf = NULL; - } +read_failed: + kfree(fmtbuf); +fmt_failed: + kfree(buf); } EXPORT_SYMBOL_GPL(visorchannel_dump_section); -- cgit v1.2.3-59-g8ed1b From f474f5e5353d9a935833b69d029db4856b6bd6e9 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Sat, 25 Oct 2014 13:16:42 +0300 Subject: staging: wlan-ng: Fix incorrect type in assignments fc variable type was u16 and it has an assignment from cpu_to_le16() so its type changed as __le16. This bug found by sparse. Signed-off-by: Ebru Akagunduz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211conv.c | 2 +- drivers/staging/wlan-ng/p80211hdr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 3b5468c64fde..7eaaf9a63503 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -107,7 +107,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, struct p80211_metawep *p80211_wep) { - u16 fc; + __le16 fc; u16 proto; struct wlan_ethhdr e_hdr; struct wlan_llc *e_llc; diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index 66b5e201d418..79d9b20b364d 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -148,7 +148,7 @@ /* Generic 802.11 Header types */ struct p80211_hdr_a3 { - u16 fc; + __le16 fc; u16 dur; u8 a1[ETH_ALEN]; u8 a2[ETH_ALEN]; -- cgit v1.2.3-59-g8ed1b From 308c32f9e8f4ead8e6b37ed3a479ac5f95e58707 Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Sat, 25 Oct 2014 20:04:17 +0800 Subject: staging: dgnc: delete successive assignments to the same location Successive assignments to the same location is meaningless and can be deleted. The Coccinelle semantic patch was used to find cases. @@ expression e1,e2,e3; @@ ( (<+...e1++...+>)=e2; | (<+...e1--...+>)=e2; | (<+...++e1...+>)=e2; | (<+...--e1...+>)=e2; | e1=e2; e1 = <+...e1...+>; | *e1=e2; *e1=e3; ) Signed-off-by: Jiayi Ye Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 8384e3d770f1..f81a375f8bc1 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -2205,8 +2205,6 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns if (!bd || bd->magic != DGNC_BOARD_MAGIC) return ret; - ret = 0; - ret = get_user(arg, value); if (ret) return ret; -- cgit v1.2.3-59-g8ed1b From 7353871aff29c09f342b774b524e6223e8954858 Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Mon, 27 Oct 2014 22:22:07 +0530 Subject: Staging: lustre: Place a space after a semi colon. Removes the following errors generated using checkpatch.pl tool: drivers/staging/lustre/lustre/ldlm/ldlm_internal.h:247: ERROR: space required after that ';' (ctx:VxV) drivers/staging/lustre/lustre/ldlm/ldlm_internal.h:269: ERROR: space required after that ';' (ctx:VxV) Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index f997566ef11e..06cf6d282e65 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -244,7 +244,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; \ return lprocfs_rd_uint(m, &tmp); \ } \ - struct __##var##__dummy_read {;} /* semicolon catcher */ + struct __##var##__dummy_read {; } /* semicolon catcher */ #define LDLM_POOL_PROC_WRITER(var, type) \ static int lprocfs_wr_##var(struct file *file, const char *buffer, \ @@ -266,7 +266,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; \ return rc; \ } \ - struct __##var##__dummy_write {;} /* semicolon catcher */ + struct __##var##__dummy_write {; } /* semicolon catcher */ static inline int is_granted_or_cancelled(struct ldlm_lock *lock) { -- cgit v1.2.3-59-g8ed1b From 427eed0244010c64f6905212f48258d3631bcb4d Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Sat, 25 Oct 2014 20:05:43 +0800 Subject: staging: rtl8192e: delete successive assignments to the same location Successive assignments to the same location is meaningless and can be deleted. The Coccinelle semantic patch was used to find cases. @@ expression e1,e2,e3; @@ ( (<+...e1++...+>)=e2; | (<+...e1--...+>)=e2; | (<+...++e1...+>)=e2; | (<+...--e1...+>)=e2; | e1=e2; e1 = <+...e1...+>; | *e1=e2; *e1=e3; ) Signed-off-by: Jiayi Ye Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index b6ce8c3b2f8c..885315cac3a4 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -1449,13 +1449,11 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - TempVal = 0; TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - TempVal = 0; TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; @@ -1465,13 +1463,11 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - TempVal = 0; TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - TempVal = 0; TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; @@ -1493,7 +1489,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, TempVal); - TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+ @@ -1501,7 +1496,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, TempVal); - TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ; @@ -1515,7 +1509,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, TempVal); - TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+ @@ -1523,7 +1516,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, TempVal); - TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; -- cgit v1.2.3-59-g8ed1b From 2f12163369562146699bb156d26975991d465edd Mon Sep 17 00:00:00 2001 From: Jiayi Ye Date: Sat, 25 Oct 2014 20:06:59 +0800 Subject: staging: rtl8192u: delete successive assignments to the same location Successive assignments to the same location is meaningless and can be deleted. The Coccinelle semantic patch was used to find cases. @@ expression e1,e2,e3; @@ ( (<+...e1++...+>)=e2; | (<+...e1--...+>)=e2; | (<+...++e1...+>)=e2; | (<+...--e1...+>)=e2; | e1=e2; e1 = <+...e1...+>; | *e1=e2; *e1=e3; ) Signed-off-by: Jiayi Ye Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index cf4d3dc5dc76..936565d46014 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1476,14 +1476,12 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); //Write 0xa24 ~ 0xa27 - TempVal = 0; TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16)+ (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); //Write 0xa28 0xa29 - TempVal = 0; TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] + (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ; @@ -1496,14 +1494,12 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); //Write 0xa24 ~ 0xa27 - TempVal = 0; TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16)+ (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); //Write 0xa28 0xa29 - TempVal = 0; TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] + (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ; @@ -1528,7 +1524,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, TempVal); //Write 0xa24 ~ 0xa27 - TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+ @@ -1537,7 +1532,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, TempVal); //Write 0xa28 0xa29 - TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ; @@ -1556,7 +1550,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, TempVal); //Write 0xa24 ~ 0xa27 - TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+ @@ -1565,7 +1558,6 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, TempVal); //Write 0xa28 0xa29 - TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; -- cgit v1.2.3-59-g8ed1b From baf9ef82fc96ef37cb1d85aaf225663ff0c15fa6 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Mon, 27 Oct 2014 17:56:33 +0530 Subject: Staging: rtl8192u: Annotate association types with proper endianness This patch fixes following sparse warning at number of places in file rtl819x_BAProc.c. Warning: incorrect type in assignment (different base types) expected unsigned short [unsigned] [usertype] tmp got restricted __le16 [usertype] Here, code before this change is correct. But this change silents sparse warnings and will not harm code too. Signed-off-by: Vaishali Thakkar Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 51552d42d66c..a95508d9820e 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -110,7 +110,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P struct sk_buff *skb = NULL; struct ieee80211_hdr_3addr *BAReq = NULL; u8 *tag = NULL; - u16 tmp = 0; + __le16 tmp = 0; u16 len = ieee->tx_headroom + 9; //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2)) IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev); @@ -196,7 +196,7 @@ static struct sk_buff *ieee80211_DELBA( struct sk_buff *skb = NULL; struct ieee80211_hdr_3addr *Delba = NULL; u8 *tag = NULL; - u16 tmp = 0; + __le16 tmp = 0; //len = head len + DELBA Parameter Set(2) + Reason Code(2) u16 len = 6 + ieee->tx_headroom; -- cgit v1.2.3-59-g8ed1b From 9ab6388cb8e7afa5377ae7f6976ab514025875d6 Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Sat, 25 Oct 2014 23:13:39 +0530 Subject: Staging: iio: light: Removed unnecessary parentheses Unnecessary parentheses around the right hand side of an assignment is removed using the following semantic patch: @@ identifier x,f; constant C; @@ ( -x = (f / C ); +x = f / C ; | -x = (f % C ); +x = f % C ; ) Signed-off-by: Tina Johnson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2x7x_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c index b3d73a9a42ab..423f96bdf595 100644 --- a/drivers/staging/iio/light/tsl2x7x_core.c +++ b/drivers/staging/iio/light/tsl2x7x_core.c @@ -1040,8 +1040,8 @@ static ssize_t tsl2x7x_als_persistence_show(struct device *dev, y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1; z = y * TSL2X7X_MIN_ITIME; filter_delay = z * (chip->tsl2x7x_settings.persistence & 0x0F); - y = (filter_delay / 1000); - z = (filter_delay % 1000); + y = filter_delay / 1000; + z = filter_delay % 1000; return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); } @@ -1086,8 +1086,8 @@ static ssize_t tsl2x7x_prox_persistence_show(struct device *dev, y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1; z = y * TSL2X7X_MIN_ITIME; filter_delay = z * ((chip->tsl2x7x_settings.persistence & 0xF0) >> 4); - y = (filter_delay / 1000); - z = (filter_delay % 1000); + y = filter_delay / 1000; + z = filter_delay % 1000; return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z); } -- cgit v1.2.3-59-g8ed1b From dfd94488a8aa9320d8048a108c602bf4307d4734 Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Sat, 25 Oct 2014 23:13:40 +0530 Subject: Staging: ft1000: ft1000-usb: Removed unnecessary parentheses Unnecessary parentheses around the right hand side of an assignment is removed using the following semantic patch: @@ identifier x,f; constant C; @@ ( -x = (f / C ); +x = f / C ; | -x = (f % C ); +x = f % C ; ) Signed-off-by: Tina Johnson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 37707da09e9c..7fb5c3f00632 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -837,7 +837,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, if (word_length & 0x1) word_length++; - word_length = (word_length / 2); + word_length = word_length / 2; for (; word_length > 0; word_length--) { /* In words */ @@ -871,7 +871,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, if (word_length & 0x1) word_length++; - word_length = (word_length / 2); + word_length = word_length / 2; for (; word_length > 0; word_length--) { /* In words */ -- cgit v1.2.3-59-g8ed1b From db9c9305701a2ee006d2a28770a7aa2dda70a087 Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Sat, 25 Oct 2014 23:13:41 +0530 Subject: Staging: slicoss: Removed unnecessary parentheses Unnecessary parentheses around the right hand side of an assignment is removed using the following semantic patch: @@ identifier x,f; constant C; @@ ( -x = (f / C ); +x = f / C ; | -x = (f % C ); +x = f % C ; ) Signed-off-by: Tina Johnson 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 71bc4edae322..cff7cbea526b 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1611,7 +1611,7 @@ static int slic_rcvqueue_init(struct adapter *adapter) rcvq->size = SLIC_RCVQ_ENTRIES; rcvq->errors = 0; rcvq->count = 0; - i = (SLIC_RCVQ_ENTRIES / SLIC_RCVQ_FILLENTRIES); + i = SLIC_RCVQ_ENTRIES / SLIC_RCVQ_FILLENTRIES; count = 0; while (i) { count += slic_rcvqueue_fill(adapter); -- cgit v1.2.3-59-g8ed1b From 9fd4af8ab48a1485615eeb771d5461b4157ba079 Mon Sep 17 00:00:00 2001 From: Tina Johnson Date: Sat, 25 Oct 2014 23:13:42 +0530 Subject: Staging: rts5208: Removed unnecessary parentheses Unnecessary parentheses around the right hand side of an assignment is removed using the following semantic patch: @@ identifier x,f; constant C; @@ ( -x = (f / C ); +x = f / C ; | -x = (f % C ); +x = f % C ; ) Signed-off-by: Tina Johnson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 0a67dca72dff..91fb61f61c91 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -539,7 +539,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, if (i == buf_cnt / (HOST_SG_TBL_BUF_LEN / 8)) sg_cnt = buf_cnt % (HOST_SG_TBL_BUF_LEN / 8); else - sg_cnt = (HOST_SG_TBL_BUF_LEN / 8); + sg_cnt = HOST_SG_TBL_BUF_LEN / 8; chip->sgi = 0; for (j = 0; j < sg_cnt; j++) { -- cgit v1.2.3-59-g8ed1b From 87a979318faa1dac75fe28df9440efe6c1c9c28b Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Mon, 27 Oct 2014 19:56:06 +0530 Subject: Staging: rts5028: rtsx_transport.c: fixed a brace coding style issue. Removed unwanted braces using checkpatch.pl tool. Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_transport.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 91fb61f61c91..756a9687c293 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -728,15 +728,13 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) return -EIO; - if (use_sg) { + if (use_sg) err = rtsx_transfer_sglist_adma_partial(chip, card, (struct scatterlist *)buf, use_sg, index, offset, (int)len, dma_dir, timeout); - } else { + else err = rtsx_transfer_buf(chip, card, buf, len, dma_dir, timeout); - } - if (err < 0) { if (RTSX_TST_DELINK(chip)) { RTSX_CLR_DELINK(chip); -- cgit v1.2.3-59-g8ed1b From 81a4e959f2011ecc9de133c509c37497800bf3bd Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 22:26:56 +0200 Subject: staging: vt6655: device.h: Comments fixes Replace C99 "//" comments by "/* */", remove not needed comments (year of adding code, commented code) Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 181 +++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 95 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index ab6be41d4964..d769d092fb87 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -50,7 +50,6 @@ #include #include #include -//#include #include #include #include @@ -58,16 +57,13 @@ #include /* Include Wireless Extension definition and check version - Jean II */ #include -#include // New driver API +#include /* New driver API */ -//2008-0409-07, by Einsn Liu #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT #endif -// -// device specific -// +/* device specific */ #include "device_cfg.h" #include "ttype.h" @@ -112,7 +108,7 @@ #define FB_RATE0 0 #define FB_RATE1 1 -// Antenna Mode +/* Antenna Mode */ #define ANT_A 0 #define ANT_B 1 #define ANT_DIVERSITY 2 @@ -129,10 +125,10 @@ #define RUN_AT(x) (jiffies+(x)) #endif -// DMA related +/* DMA related */ #define RESERV_AC0DMA 4 -// BUILD OBJ mode +/* BUILD OBJ mode */ #define AVAIL_TD(p, q) ((p)->sOpts.nTxDescs[(q)] - ((p)->iTDUsed[(q)])) @@ -148,7 +144,7 @@ do { \ printk(p, ##args); \ } while (0) -//0:11A 1:11B 2:11G +/* 0:11A 1:11B 2:11G */ typedef enum _VIA_BB_TYPE { BB_TYPE_11A = 0, @@ -156,7 +152,7 @@ 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 Basic Rate) +/* 0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) */ typedef enum _VIA_PKT_TYPE { PK_TYPE_11A = 0, @@ -166,21 +162,20 @@ typedef enum _VIA_PKT_TYPE } VIA_PKT_TYPE, *PVIA_PKT_TYPE; typedef enum __device_msg_level { - MSG_LEVEL_ERR = 0, //Errors that will cause abnormal operation. - MSG_LEVEL_NOTICE = 1, //Some errors need users to be notified. - MSG_LEVEL_INFO = 2, //Normal message. - MSG_LEVEL_VERBOSE = 3, //Will report all trival errors. - MSG_LEVEL_DEBUG = 4 //Only for debug purpose. + MSG_LEVEL_ERR = 0, /* Errors that will cause abnormal operation. */ + MSG_LEVEL_NOTICE = 1, /* Some errors need users to be notified. */ + MSG_LEVEL_INFO = 2, /* Normal message. */ + MSG_LEVEL_VERBOSE = 3, /* Will report all trival errors. */ + MSG_LEVEL_DEBUG = 4 /* Only for debug purpose. */ } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL; -//++ NDIS related - +/* NDIS related */ #define MAX_BSSIDINFO_4_PMKID 16 #define MAX_PMKIDLIST 5 -//Flags for PMKID Candidate list structure +/* Flags for PMKID Candidate list structure */ #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01 -// PMKID Structures +/* PMKID Structures */ typedef unsigned char NDIS_802_11_PMKID_VALUE[16]; typedef enum _NDIS_802_11_WEP_STATUS { @@ -203,10 +198,10 @@ typedef enum _NDIS_802_11_STATUS_TYPE { Ndis802_11StatusType_Authentication, Ndis802_11StatusType_MediaStreamMode, Ndis802_11StatusType_PMKID_CandidateList, - Ndis802_11StatusTypeMax // not a real type, defined as an upper bound + Ndis802_11StatusTypeMax /* defined as an upper bound */ } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE; -//Added new types for PMKID Candidate lists. +/* Added new types for PMKID Candidate lists. */ struct pmkid_candidate { NDIS_802_11_MAC_ADDRESS BSSID; unsigned long Flags; @@ -225,14 +220,12 @@ typedef struct tagSPMKID { typedef struct tagSPMKIDCandidateEvent { NDIS_802_11_STATUS_TYPE StatusType; - unsigned long Version; // Version of the structure - unsigned long NumCandidates; // No. of pmkid candidates + unsigned long Version; /* Version of the structure */ + unsigned long NumCandidates; /* No. of pmkid candidates */ struct pmkid_candidate CandidateList[MAX_PMKIDLIST]; } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent; -//-- - -//++ 802.11h related +/* 802.11h related */ #define MAX_QUIET_COUNT 8 typedef struct tagSQuietControl { @@ -242,7 +235,6 @@ typedef struct tagSQuietControl { unsigned short wDuration; } SQuietControl, *PSQuietControl; -//-- typedef struct __chip_info_tbl { CHIP_TYPE chip_id; char *name; @@ -256,22 +248,22 @@ typedef enum { OWNED_BY_NIC = 1 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE; -// The receive duplicate detection cache entry +/* The receive duplicate detection cache entry */ typedef struct tagSCacheEntry { unsigned short wFmSequence; unsigned char abyAddr2[ETH_ALEN]; } SCacheEntry, *PSCacheEntry; typedef struct tagSCache { -/* The receive cache is updated circularly. The next entry to be written is +/* The receive cache is updated circularly. The next entry to be written is * indexed by the "InPtr". */ - unsigned int uInPtr; // Place to use next + unsigned int uInPtr; /* Place to use next */ SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH]; } SCache, *PSCache; #define CB_MAX_RX_FRAG 64 -// DeFragment Control Block, used for collecting fragments prior to reassembly +/* DeFragment Control Block, used for collecting fragments prior to reassembly */ typedef struct tagSDeFragControlBlock { unsigned short wSequence; unsigned short wFragNum; @@ -283,7 +275,7 @@ typedef struct tagSDeFragControlBlock { bool bInUse; } SDeFragControlBlock, *PSDeFragControlBlock; -//flags for options +/* flags for options */ #define DEVICE_FLAGS_IP_ALIGN 0x00000001UL #define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL #define DEVICE_FLAGS_OP_MODE 0x00000004UL @@ -291,15 +283,15 @@ typedef struct tagSDeFragControlBlock { #define DEVICE_FLAGS_80211h_MODE 0x00000010UL #define DEVICE_FLAGS_DiversityANT 0x00000020UL -//flags for driver status +/* flags for driver status */ #define DEVICE_FLAGS_OPENED 0x00010000UL #define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL -//flags for capabilities +/* flags for capabilities */ #define DEVICE_FLAGS_TX_ALIGN 0x01000000UL #define DEVICE_FLAGS_HAVE_CAM 0x02000000UL #define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL -//flags for MII status +/* flags for MII status */ #define DEVICE_LINK_FAIL 0x00000001UL #define DEVICE_SPEED_10 0x00000002UL #define DEVICE_SPEED_100 0x00000004UL @@ -307,15 +299,15 @@ typedef struct tagSDeFragControlBlock { #define DEVICE_DUPLEX_FULL 0x00000010UL #define DEVICE_AUTONEG_ENABLE 0x00000020UL #define DEVICE_FORCED_BY_EEPROM 0x00000040UL -//for device_set_media_duplex +/* for device_set_media_duplex */ #define DEVICE_LINK_CHANGE 0x00000001UL typedef struct __device_opt { - int nRxDescs0; //Number of RX descriptors0 - int nRxDescs1; //Number of RX descriptors1 - int nTxDescs[2]; //Number of TX descriptors 0, 1 - int int_works; //interrupt limits - int rts_thresh; //rts threshold + int nRxDescs0; /* Number of RX descriptors0 */ + int nRxDescs1; /* Number of RX descriptors1 */ + int nTxDescs[2]; /* Number of TX descriptors 0, 1 */ + int int_works; /* interrupt limits */ + int rts_thresh; /* rts threshold */ int frag_thresh; int data_rate; int channel_num; @@ -328,10 +320,10 @@ typedef struct __device_opt { struct vnt_private { struct pci_dev *pcid; -// netdev +/* netdev */ struct net_device *dev; -//dma addr, rx/tx pool +/* dma addr, rx/tx pool */ dma_addr_t pool_dma; dma_addr_t rd0_pool_dma; dma_addr_t rd1_pool_dma; @@ -394,7 +386,7 @@ struct vnt_private { u32 rx_bytes; - // Version control + /* Version control */ unsigned char byLocalID; unsigned char byRFType; @@ -404,18 +396,18 @@ struct vnt_private { unsigned char byOriginalZonetype; unsigned char abyMacContext[MAC_MAX_CONTEXT_REG]; unsigned char abyCurrentNetAddr[ETH_ALEN]; - bool bLinkPass; // link status: OK or fail + bool bLinkPass; /* link status: OK or fail */ - // Adapter statistics + /* Adapter statistics */ SStatCounter scStatistic; - // 802.11 counter + /* 802.11 counter */ SDot11Counters s802_11Counter; - // 802.11 management + /* 802.11 management */ PSMgmtObject pMgmt; SMgmtObject sMgmtObj; - // 802.11 MAC specific + /* 802.11 MAC specific */ unsigned int uCurrRSSI; unsigned char byCurrSQ; @@ -427,22 +419,26 @@ struct vnt_private { bool bTxRxAntInv; unsigned char *pbyTmpBuff; - unsigned int uSIFS; //Current SIFS - unsigned int uDIFS; //Current DIFS - unsigned int uEIFS; //Current EIFS - unsigned int uSlot; //Current SlotTime - unsigned int uCwMin; //Current CwMin - unsigned int uCwMax; //CwMax is fixed on 1023. - // PHY parameter + unsigned int uSIFS; /* Current SIFS */ + unsigned int uDIFS; /* Current DIFS */ + unsigned int uEIFS; /* Current EIFS */ + unsigned int uSlot; /* Current SlotTime */ + unsigned int uCwMin; /* Current CwMin */ + unsigned int uCwMax; /* CwMax is fixed on 1023. */ + /* PHY parameter */ unsigned char bySIFS; unsigned char byDIFS; unsigned char byEIFS; unsigned char bySlot; unsigned char byCWMaxMin; - CARD_PHY_TYPE eCurrentPHYType; - - VIA_BB_TYPE byBBType; //0: 11A, 1:11B, 2:11G - VIA_PKT_TYPE byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) + CARD_PHY_TYPE eCurrentPHYType; + + VIA_BB_TYPE byBBType; /* 0:11A, 1:11B, 2:11G */ + VIA_PKT_TYPE byPacketType; /* + * 0:11a,1:11b,2:11gb (only CCK + * in BasicRate), 3:11ga (OFDM in + * Basic Rate) + */ unsigned short wBasicRate; unsigned char byACKRate; unsigned char byTopOFDMBasicRate; @@ -466,12 +462,12 @@ struct vnt_private { unsigned short wMaxTransmitMSDULifetime; unsigned char abyBSSID[ETH_ALEN]; unsigned char abyDesireBSSID[ETH_ALEN]; - unsigned short wACKDuration; // update while speed change - unsigned short wRTSTransmitLen; // update while speed change - unsigned char byRTSServiceField; // update while speed change - unsigned char byRTSSignalField; // update while speed change + unsigned short wACKDuration; /* update while speed change */ + unsigned short wRTSTransmitLen; /* update while speed change */ + unsigned char byRTSServiceField; /* update while speed change */ + unsigned char byRTSSignalField; /* update while speed change */ - unsigned long dwMaxReceiveLifetime; // dot11MaxReceiveLifetime + unsigned long dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ bool bEncryptionEnable; bool bLongHeader; @@ -490,14 +486,14 @@ struct vnt_private { bool bPWBitOn; WMAC_POWER_MODE ePSMode; - // GPIO Radio Control + /* GPIO Radio Control */ unsigned char byRadioCtl; unsigned char byGPIO; bool bHWRadioOff; bool bPrvActive4RadioOFF; bool bGPIOBlockRead; - // Beacon related + /* Beacon related */ unsigned short wSeqCounter; unsigned short wBCNBufLen; bool bBeaconBufReady; @@ -518,7 +514,7 @@ struct vnt_private { bool bStopTx0Pkt; unsigned int uAutoReConnectTime; - // 802.11 counter + /* 802.11 counter */ CMD_ITEM eCmdQueue[CMD_Q_SIZE]; unsigned int uCmdDequeueIdx; @@ -528,14 +524,11 @@ struct vnt_private { bool bCmdClear; bool bRoaming; - //WOW unsigned char abyIPAddr[4]; unsigned long ulTxPower; NDIS_802_11_WEP_STATUS eEncryptionStatus; bool bTransmitKey; -//2007-0925-01by MikeLiu -//mike add :save old Encryption NDIS_802_11_WEP_STATUS eOldEncryptionStatus; SKeyManagement sKey; @@ -553,14 +546,14 @@ struct vnt_private { bool bAES; unsigned char byCntMeasure; - // for AP mode + /* for AP mode */ unsigned int uAssocCount; bool bMoreData; - // QoS + /* QoS */ bool bGrpAckPolicy; - // for OID_802_11_ASSOCIATION_INFORMATION + /* for OID_802_11_ASSOCIATION_INFORMATION */ bool bAssocInfoSet; unsigned char byAutoFBCtrl; @@ -570,7 +563,7 @@ struct vnt_private { unsigned int uRATEIdx; - // For Update BaseBand VGA Gain Offset + /* For Update BaseBand VGA Gain Offset */ bool bUpdateBBVGA; unsigned int uBBVGADiffCount; unsigned char byBBVGANew; @@ -584,11 +577,10 @@ struct vnt_private { bool bRadioCmd; unsigned long dwDiagRefCount; - // For FOE Tuning + /* For FOE Tuning */ unsigned char byFOETuning; - // For Auto Power Tunning - + /* For Auto Power Tunning */ unsigned char byAutoPwrTunning; short sPSetPointCCK; short sPSetPointOFDMG; @@ -598,7 +590,7 @@ struct vnt_private { char cAdjustStep; char cMinTxAGC; - // For RF Power table + /* For RF Power table */ unsigned char byCCKPwr; unsigned char byOFDMPwrG; unsigned char byCurPwr; @@ -610,13 +602,13 @@ struct vnt_private { char abyRegPwr[CB_MAX_CHANNEL+1]; char abyLocalPwr[CB_MAX_CHANNEL+1]; - // BaseBand Loopback Use + /* BaseBand Loopback Use */ unsigned char byBBCR4d; unsigned char byBBCRc9; unsigned char byBBCR88; unsigned char byBBCR09; - // command timer + /* command timer */ struct timer_list sTimerCommand; struct timer_list sTimerTxData; unsigned long nTxDataTimeCout; @@ -624,9 +616,9 @@ struct vnt_private { bool IsTxDataTrigger; #ifdef WPA_SM_Transtatus - bool fWPA_Authened; //is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? + bool fWPA_Authened; /* is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */ #endif - unsigned char byReAssocCount; //mike add:re-association retry times! + unsigned char byReAssocCount; unsigned char byLinkWaitCount; unsigned char abyNodeName[17]; @@ -640,13 +632,13 @@ struct vnt_private { unsigned char byTMax3; unsigned long ulSQ3TH; -// ANT diversity + /* ANT diversity */ unsigned long uDiversityCnt; unsigned char byAntennaState; unsigned long ulRatio_State0; unsigned long ulRatio_State1; - //SQ3 functions for antenna diversity + /* SQ3 functions for antenna diversity */ struct timer_list TimerSQ3Tmax1; struct timer_list TimerSQ3Tmax2; struct timer_list TimerSQ3Tmax3; @@ -659,15 +651,15 @@ struct vnt_private { unsigned char abyBroadcastAddr[ETH_ALEN]; unsigned char abySNAP_RFC1042[ETH_ALEN]; unsigned char abySNAP_Bridgetunnel[ETH_ALEN]; - unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; //unsigned long alignment - // Pre-Authentication & PMK cache + unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */ + /* Pre-Authentication & PMK cache */ SPMKID gsPMKID; SPMKIDCandidateEvent gsPMKIDCandidate; - // for 802.11h + /* for 802.11h */ bool b11hEnable; unsigned char abyCountryCode[3]; - // for 802.11h DFS + /* for 802.11h DFS */ unsigned int uNumOfMeasureEIDs; PWLAN_IE_MEASURE_REQ pCurrMeasureEID; bool bMeasureInProgress; @@ -688,13 +680,13 @@ struct vnt_private { unsigned int uQuietEnqueue; unsigned long dwCurrentQuietEndTime; SQuietControl sQuiet[MAX_QUIET_COUNT]; - // for 802.11h TPC + /* for 802.11h TPC */ bool bCountryInfo5G; bool bCountryInfo24G; unsigned short wBeaconInterval; - //WPA supplicant deamon + /* WPA supplicant deamon */ struct net_device *wpadev; bool bWPADEVUp; struct sk_buff *skb; @@ -703,9 +695,8 @@ struct vnt_private { bool bWPASuppWextEnabled; #endif - //-- #ifdef HOSTAP - // user space daemon: hostapd, is used for HOSTAP + /* user space daemon: hostapd, is used for HOSTAP */ bool bEnableHostapd; bool bEnable8021x; bool bEnableHostWEP; @@ -715,7 +706,7 @@ struct vnt_private { unsigned int uChannel; bool bMACSuspend; - struct iw_statistics wstats; // wireless stats + struct iw_statistics wstats; /* wireless stats */ bool bCommit; }; -- cgit v1.2.3-59-g8ed1b From 77b6a6a3f52e980f91a471f3d3a99671292355b0 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 22:34:38 +0200 Subject: staging: vt6655: card.c: Comments fixes Replace C99 "//" comments by "/* */", remove not needed comments (year of adding code, commented code) Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 296 ++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 170 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index f2a33a9742c6..eae67897a615 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -59,28 +59,28 @@ /*--------------------- Static Definitions -------------------------*/ -#define C_SIFS_A 16 // micro sec. +#define C_SIFS_A 16 /* micro sec. */ #define C_SIFS_BG 10 -#define C_EIFS 80 // micro sec. +#define C_EIFS 80 /* micro sec. */ -#define C_SLOT_SHORT 9 // micro sec. +#define C_SLOT_SHORT 9 /* micro sec. */ #define C_SLOT_LONG 20 -#define C_CWMIN_A 15 // slot time +#define C_CWMIN_A 15 /* slot time */ #define C_CWMIN_B 31 -#define C_CWMAX 1023 // slot time +#define C_CWMAX 1023 /* slot time */ -#define WAIT_BEACON_TX_DOWN_TMO 3 // Times +#define WAIT_BEACON_TX_DOWN_TMO 3 /* Times */ -//1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M +/* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M */ static unsigned char abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; -//6M, 9M, 12M, 48M +/* 6M, 9M, 12M, 48M */ static unsigned char abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; -//6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M +/* 6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M */ static unsigned char abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; -//1M, 2M, 5M, 11M, +/* 1M, 2M, 5M, 11M, */ static unsigned char abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; /*--------------------- Static Variables --------------------------*/ @@ -113,7 +113,6 @@ s_vCalculateOFDMRParameter( * pbyRsvTime - pointer to RSPINF RsvTime field * * Return Value: none - * */ static void @@ -126,7 +125,7 @@ s_vCalculateOFDMRParameter( { switch (byRate) { case RATE_6M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9B; *pbyRsvTime = 44; } else { @@ -136,7 +135,7 @@ s_vCalculateOFDMRParameter( break; case RATE_9M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9F; *pbyRsvTime = 36; } else { @@ -146,7 +145,7 @@ s_vCalculateOFDMRParameter( break; case RATE_12M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9A; *pbyRsvTime = 32; } else { @@ -156,7 +155,7 @@ s_vCalculateOFDMRParameter( break; case RATE_18M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9E; *pbyRsvTime = 28; } else { @@ -166,7 +165,7 @@ s_vCalculateOFDMRParameter( break; case RATE_36M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9D; *pbyRsvTime = 24; } else { @@ -176,7 +175,7 @@ s_vCalculateOFDMRParameter( break; case RATE_48M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x98; *pbyRsvTime = 24; } else { @@ -186,7 +185,7 @@ s_vCalculateOFDMRParameter( break; case RATE_54M: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9C; *pbyRsvTime = 24; } else { @@ -197,7 +196,7 @@ s_vCalculateOFDMRParameter( case RATE_24M: default: - if (ePHYType == PHY_TYPE_11A) {//5GHZ + if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x99; *pbyRsvTime = 28; } else { @@ -218,7 +217,6 @@ s_vCalculateOFDMRParameter( * none * * Return Value: None. - * */ static void @@ -226,9 +224,9 @@ s_vSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, void *pvSupportRateIEs, void *pvExtSupportRateIEs) { union vnt_phy_field_swap phy; - unsigned char byTxRate = 0, byRsvTime = 0; // For OFDM + unsigned char byTxRate = 0, byRsvTime = 0; /* For OFDM */ - //Set to Page1 + /* Set to Page1 */ MACvSelectPage1(pDevice->PortOffset); /* RSPINF_b_1 */ @@ -270,60 +268,60 @@ s_vSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write); - //RSPINF_a_6 + /* RSPINF_a_6 */ s_vCalculateOFDMRParameter(RATE_6M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_9 + /* RSPINF_a_9 */ s_vCalculateOFDMRParameter(RATE_9M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_12 + /* RSPINF_a_12 */ s_vCalculateOFDMRParameter(RATE_12M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_18 + /* RSPINF_a_18 */ s_vCalculateOFDMRParameter(RATE_18M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_24 + /* RSPINF_a_24 */ s_vCalculateOFDMRParameter(RATE_24M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_36 + /* RSPINF_a_36 */ s_vCalculateOFDMRParameter( VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_48 + /* RSPINF_a_48 */ s_vCalculateOFDMRParameter( VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_54 + /* RSPINF_a_54 */ s_vCalculateOFDMRParameter( VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_72 + /* RSPINF_a_72 */ VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); - //Set to Page0 + /* Set to Page0 */ MACvSelectPage0(pDevice->PortOffset); } @@ -339,7 +337,6 @@ s_vSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, * none * * Return Value: true if short preamble; otherwise false - * */ bool CARDbIsShortPreamble(struct vnt_private *pDevice) { @@ -360,7 +357,6 @@ bool CARDbIsShortPreamble(struct vnt_private *pDevice) * none * * Return Value: true if short slot time; otherwise false - * */ bool CARDbIsShorSlotTime(struct vnt_private *pDevice) { @@ -378,7 +374,6 @@ bool CARDbIsShorSlotTime(struct vnt_private *pDevice) * none * * Return Value: None. - * */ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, unsigned short wCapInfo, unsigned char byERPField, @@ -392,13 +387,13 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs; PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs; - //Set SIFS, DIFS, EIFS, SlotTime, CwMin + /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ if (ePHYType == PHY_TYPE_11A) { if (pSupportRates == NULL) pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA; if (pDevice->byRFType == RF_AIROHA7230) { - // AL7230 use single PAPE and connect to PAPE_2.4G + /* AL7230 use single PAPE and connect to PAPE_2.4G */ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); pDevice->abyBBVGA[0] = 0x20; pDevice->abyBBVGA[2] = 0x10; @@ -449,7 +444,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, bySIFS = C_SIFS_BG; byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; byCWMaxMin = 0xA5; - } else {// PK_TYPE_11GA & PK_TYPE_11GB + } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ if (pSupportRates == NULL) { pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG; pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG; @@ -503,13 +498,17 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, } if (pDevice->byRFType == RF_RFMD2959) { - // bcs TX_PE will reserve 3 us - // hardware's processing time here is 2 us. + /* + * bcs TX_PE will reserve 3 us hardware's processing + * time here is 2 us. + */ bySIFS -= 3; byDIFS -= 3; - //{{ RobertYu: 20041202 - //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput - //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us. + /* + * TX_PE will reserve 3 us for MAX2829 A mode only, it is for + * better TX throughput; MAC will need 2 us to process, so the + * SIFS, DIFS can be shorter by 2 us. + */ } if (pDevice->bySIFS != bySIFS) { @@ -545,7 +544,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates); pDevice->eCurrentPHYType = ePHYType; - // set for NDIS OID_802_11SUPPORTED_RATES + /* set for NDIS OID_802_11SUPPORTED_RATES */ return true; } @@ -563,7 +562,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, * none * * Return Value: none - * */ bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate, u64 qwBSSTimestamp, u64 qwLocalTSF) @@ -572,8 +570,7 @@ bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate, if (qwBSSTimestamp != qwLocalTSF) { qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF); - // adjust TSF - // HW's TSF add TSF Offset reg + /* adjust TSF, HW's TSF add TSF Offset reg */ VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, (u32)qwTSFOffset); VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, (u32)(qwTSFOffset >> 32)); MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN); @@ -593,21 +590,20 @@ bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate, * none * * Return Value: true if succeed; otherwise false - * */ bool CARDbSetBeaconPeriod(struct vnt_private *pDevice, unsigned short wBeaconInterval) { u64 qwNextTBTT = 0; - CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); //Get Local TSF counter + CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); /* Get Local TSF counter */ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); - // set HW beacon interval + /* set HW beacon interval */ VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval); pDevice->wBeaconInterval = wBeaconInterval; - // Set NextTBTT + /* Set NextTBTT */ VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); @@ -626,7 +622,6 @@ bool CARDbSetBeaconPeriod(struct vnt_private *pDevice, * none * * Return Value: true if all data packet complete; otherwise false. - * */ bool CARDbStopTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) { @@ -654,12 +649,12 @@ bool CARDbStopTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) pDevice->cbBeaconBufReadySetCnt = 0; MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); } - // wait all TD0 complete + /* wait all TD0 complete */ if (pDevice->bStopTx0Pkt == true) { if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) return false; } - // wait all Data TD complete + /* wait all Data TD complete */ if (pDevice->bStopDataPkt == true) { if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) return false; @@ -679,7 +674,6 @@ bool CARDbStopTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) * none * * Return Value: true if success; false if failed. - * */ bool CARDbStartTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) { @@ -717,7 +711,6 @@ bool CARDbStartTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) * none * * Return Value: true if success; false if failed. - * */ bool CARDbSetBSSID(struct vnt_private *pDevice, unsigned char *pbyBSSID, enum nl80211_iftype op_mode) @@ -748,7 +741,7 @@ bool CARDbSetBSSID(struct vnt_private *pDevice, } pr_debug("wmgr: rx_mode = %x\n", pDevice->byRxMode); } - // Adopt BSS state in Adapter Device Object + /* Adopt BSS state in Adapter Device Object */ pDevice->op_mode = op_mode; return true; } @@ -764,7 +757,6 @@ bool CARDbSetBSSID(struct vnt_private *pDevice, * none * * Return Value: true if success; false if failed. - * */ /* @@ -782,7 +774,6 @@ bool CARDbSetBSSID(struct vnt_private *pDevice, * none * * Return Value: true if succeed; otherwise false - * */ bool CARDbSetTxDataRate( struct vnt_private *pDevice, @@ -794,8 +785,7 @@ bool CARDbSetTxDataRate( return true; } -/*+ - * +/* * Routine Description: * Consider to power down when no more packets to tx or rx. * @@ -806,8 +796,7 @@ bool CARDbSetTxDataRate( * none * * Return Value: true if power down success; otherwise false - * - -*/ + */ bool CARDbPowerDown( struct vnt_private *pDevice @@ -815,14 +804,14 @@ CARDbPowerDown( { unsigned int uIdx; - // check if already in Doze mode + /* check if already in Doze mode */ if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) return true; - // Froce PSEN on + /* Froce PSEN on */ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN); - // check if all TD are empty, + /* check if all TD are empty */ for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) { if (pDevice->iTDUsed[uIdx] != 0) @@ -844,7 +833,6 @@ CARDbPowerDown( * none * * Return Value: true if success; otherwise false - * */ bool CARDbRadioPowerOff(struct vnt_private *pDevice) { @@ -861,7 +849,7 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice) case RF_AIROHA: case RF_AL2230S: - case RF_AIROHA7230: //RobertYu:20050104 + case RF_AIROHA7230: MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2); MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); break; @@ -873,9 +861,8 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice) BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID); pDevice->bRadioOff = true; - //2007-0409-03, by chester pr_debug("chester power off\n"); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue + MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ return bResult; } @@ -889,7 +876,6 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice) * none * * Return Value: true if success; otherwise false - * */ bool CARDbRadioPowerOn(struct vnt_private *pDevice) { @@ -919,7 +905,7 @@ bool CARDbRadioPowerOn(struct vnt_private *pDevice) case RF_AIROHA: case RF_AL2230S: - case RF_AIROHA7230: //RobertYu:20050104 + case RF_AIROHA7230: MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); break; @@ -927,9 +913,8 @@ bool CARDbRadioPowerOn(struct vnt_private *pDevice) } pDevice->bRadioOff = false; -// 2007-0409-03, by chester pr_debug("chester power on\n"); - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue + MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ return bResult; } @@ -941,7 +926,6 @@ bool CARDbRemoveKey(struct vnt_private *pDevice, unsigned char *pbyBSSID) } /* - * * Description: * Add BSSID in PMKID Candidate list. * @@ -954,8 +938,7 @@ bool CARDbRemoveKey(struct vnt_private *pDevice, unsigned char *pbyBSSID) * none * * Return Value: none. - * - -*/ + */ bool CARDbAdd_PMKID_Candidate( struct vnt_private *pDevice, @@ -980,7 +963,7 @@ CARDbAdd_PMKID_Candidate( pr_debug("\n"); - // Update Old Candidate + /* Update Old Candidate */ for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { @@ -993,7 +976,7 @@ CARDbAdd_PMKID_Candidate( } } - // New Candidate + /* New Candidate */ pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; if (bRSNCapExist && (wRSNCap & BIT0)) pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; @@ -1017,7 +1000,6 @@ CARDpGetCurrentAddress( } /* - * * Description: * Start Spectrum Measure defined in 802.11h * @@ -1028,8 +1010,7 @@ CARDpGetCurrentAddress( * none * * Return Value: none. - * - -*/ + */ bool CARDbStartMeasure( struct vnt_private *pDevice, @@ -1054,7 +1035,7 @@ CARDbStartMeasure( MACvSelectPage1(pDevice->PortOffset); VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0); VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4); - // clear measure control + /* clear measure control */ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); MACvSelectPage0(pDevice->PortOffset); set_channel(pDevice, pDevice->byOrgChannel); @@ -1072,16 +1053,16 @@ CARDbStartMeasure( if (pDevice->byLocalID > REV_ID_VT3253_B1) { qwStartTSF = *((u64 *)(pDevice->pCurrMeasureEID->sReq.abyStartTime)); wDuration = *((unsigned short *)(pDevice->pCurrMeasureEID->sReq.abyDuration)); - wDuration += 1; // 1 TU for channel switching + wDuration += 1; /* 1 TU for channel switching */ if (qwStartTSF == 0) { - // start immediately by setting start TSF == current TSF + 2 TU + /* start immediately by setting start TSF == current TSF + 2 TU */ qwStartTSF = qwCurrTSF + 2048; bExpired = false; break; } else { - // start at setting start TSF - 1TU(for channel switching) + /* start at setting start TSF - 1TU(for channel switching) */ qwStartTSF -= 1024; } @@ -1098,7 +1079,7 @@ CARDbStartMeasure( pDevice->abyRPIs ); } else { - // hardware do not support measure + /* hardware do not support measure */ VNTWIFIbMeasureReport(pDevice->pMgmt, false, pDevice->pCurrMeasureEID, @@ -1118,7 +1099,7 @@ CARDbStartMeasure( MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); MACvSelectPage0(pDevice->PortOffset); } else { - // all measure start time expired we should complete action + /* all measure start time expired we should complete action */ VNTWIFIbMeasureReport(pDevice->pMgmt, true, NULL, @@ -1132,7 +1113,6 @@ CARDbStartMeasure( } /* - * * Description: * Do Channel Switch defined in 802.11h * @@ -1143,8 +1123,7 @@ CARDbStartMeasure( * none * * Return Value: none. - * - -*/ + */ bool CARDbChannelSwitch( struct vnt_private *pDevice, @@ -1173,7 +1152,6 @@ CARDbChannelSwitch( } /* - * * Description: * Handle Quiet EID defined in 802.11h * @@ -1184,8 +1162,7 @@ CARDbChannelSwitch( * none * * Return Value: none. - * - -*/ + */ bool CARDbSetQuiet( struct vnt_private *pDevice, @@ -1224,7 +1201,6 @@ CARDbSetQuiet( } /* - * * Description: * Do Quiet, It will be called by either ISR(after start) * or VNTWIFI(before start) so we do not need a SPINLOCK @@ -1236,8 +1212,7 @@ CARDbSetQuiet( * none * * Return Value: none. - * - -*/ + */ bool CARDbStartQuiet( struct vnt_private *pDevice @@ -1258,12 +1233,12 @@ CARDbStartQuiet( } } if (dwStartTime == 0xFFFFFFFF) { - // no more quiet + /* no more quiet */ pDevice->bQuietEnable = false; MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); } else { if (pDevice->bQuietEnable == false) { - // first quiet + /* first quiet */ pDevice->byQuietStartCount--; dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; dwNextTime %= pDevice->wBeaconInterval; @@ -1279,10 +1254,14 @@ CARDbStartQuiet( MACvSelectPage0(pDevice->PortOffset); } else { if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) { - // overlap with previous Quiet + /* overlap with previous Quiet */ dwGap = pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) { - // return false to indicate next quiet expired, should call this function again + /* + * return false to indicate next quiet + * expired, should call this function + * again + */ return false; } dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap; @@ -1291,7 +1270,7 @@ CARDbStartQuiet( dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime; dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration; } - // set GAP and Next duration + /* set GAP and Next duration */ MACvSelectPage1(pDevice->PortOffset); VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (unsigned short) dwGap); VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) dwDuration); @@ -1302,16 +1281,16 @@ CARDbStartQuiet( pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration; if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) { - // not period disable current quiet element + /* not period disable current quiet element */ pDevice->sQuiet[uCurrentQuietIndex].bEnable = false; } else { - // set next period start time + /* set next period start time */ dwNextTime = (unsigned long) pDevice->sQuiet[uCurrentQuietIndex].byPeriod; dwNextTime *= pDevice->wBeaconInterval; pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime; } if (pDevice->dwCurrentQuietEndTime > 0x80010000) { - // decreament all time to avoid wrap around + /* decreament all time to avoid wrap around */ for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { if (pDevice->sQuiet[ii].bEnable == true) pDevice->sQuiet[ii].dwStartTime -= 0x80000000; @@ -1324,7 +1303,6 @@ CARDbStartQuiet( } /* - * * Description: * Set Local Power Constraint * @@ -1335,8 +1313,7 @@ CARDbStartQuiet( * none * * Return Value: none. - * - -*/ + */ void CARDvSetPowerConstraint( struct vnt_private *pDevice, @@ -1357,7 +1334,6 @@ CARDvSetPowerConstraint( } /* - * * Description: * Set Local Power Constraint * @@ -1368,8 +1344,7 @@ CARDvSetPowerConstraint( * none * * Return Value: none. - * - -*/ + */ void CARDvGetPowerCapability( struct vnt_private *pDevice, @@ -1391,7 +1366,6 @@ CARDvGetPowerCapability( } /* - * * Description: * Get Current Tx Power * @@ -1402,7 +1376,6 @@ CARDvGetPowerCapability( * none * * Return Value: none. - * */ char CARDbyGetTransmitPower( @@ -1413,7 +1386,6 @@ CARDbyGetTransmitPower( return pDevice->byCurPwrdBm; } -//xxx void CARDvSafeResetTx( struct vnt_private *pDevice @@ -1422,7 +1394,7 @@ CARDvSafeResetTx( unsigned int uu; PSTxDesc pCurrTD; - // initialize TD index + /* initialize TD index */ pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]); pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]); @@ -1432,28 +1404,27 @@ CARDvSafeResetTx( for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) { pCurrTD = &(pDevice->apTD0Rings[uu]); pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST; - // init all Tx Packet pointer to NULL + /* init all Tx Packet pointer to NULL */ } for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) { pCurrTD = &(pDevice->apTD1Rings[uu]); pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST; - // init all Tx Packet pointer to NULL + /* init all Tx Packet pointer to NULL */ } - // set MAC TD pointer + /* set MAC TD pointer */ MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset, (pDevice->td0_pool_dma)); MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset, (pDevice->td1_pool_dma)); - // set MAC Beacon TX pointer + /* set MAC Beacon TX pointer */ MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, (pDevice->tx_beacon_dma)); } -/*+ - * +/* * Description: * Reset Rx * @@ -1464,8 +1435,7 @@ CARDvSafeResetTx( * none * * Return Value: none - * - -*/ + */ void CARDvSafeResetRx( struct vnt_private *pDevice @@ -1474,11 +1444,11 @@ CARDvSafeResetRx( unsigned int uu; PSRxDesc pDesc; - // initialize RD index + /* initialize RD index */ pDevice->pCurrRD[0] = &(pDevice->aRD0Ring[0]); pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]); - // init state, all RD is chip's + /* init state, all RD is chip's */ for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) { pDesc = &(pDevice->aRD0Ring[uu]); pDesc->m_rd0RD0.wResCount = (unsigned short)(pDevice->rx_buf_sz); @@ -1486,7 +1456,7 @@ CARDvSafeResetRx( pDesc->m_rd1RD1.wReqCount = (unsigned short)(pDevice->rx_buf_sz); } - // init state, all RD is chip's + /* init state, all RD is chip's */ for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) { pDesc = &(pDevice->aRD1Ring[uu]); pDesc->m_rd0RD0.wResCount = (unsigned short)(pDevice->rx_buf_sz); @@ -1497,10 +1467,10 @@ CARDvSafeResetRx( pDevice->cbDFCB = CB_MAX_RX_FRAG; pDevice->cbFreeDFCB = pDevice->cbDFCB; - // set perPkt mode + /* set perPkt mode */ MACvRx0PerPktMode(pDevice->PortOffset); MACvRx1PerPktMode(pDevice->PortOffset); - // set MAC RD pointer + /* set MAC RD pointer */ MACvSetCurrRx0DescAddr(pDevice->PortOffset, pDevice->rd0_pool_dma); @@ -1519,7 +1489,6 @@ CARDvSafeResetRx( * none * * Return Value: response Control frame rate - * */ static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice, unsigned short wRateIdx) @@ -1546,7 +1515,6 @@ static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice, * none * * Return Value: response Control frame rate - * */ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, unsigned short wRateIdx) @@ -1582,14 +1550,13 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, * none * * Return Value: None. - * */ void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType) { union vnt_phy_field_swap phy; - unsigned char byTxRate, byRsvTime; //For OFDM + unsigned char byTxRate, byRsvTime; /* For OFDM */ - //Set to Page1 + /* Set to Page1 */ MACvSelectPage1(pDevice->PortOffset); /* RSPINF_b_1 */ @@ -1629,62 +1596,61 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType) VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write); - //RSPINF_a_6 + /* RSPINF_a_6 */ s_vCalculateOFDMRParameter(RATE_6M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_9 + /* RSPINF_a_9 */ s_vCalculateOFDMRParameter(RATE_9M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_12 + /* RSPINF_a_12 */ s_vCalculateOFDMRParameter(RATE_12M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_18 + /* RSPINF_a_18 */ s_vCalculateOFDMRParameter(RATE_18M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_24 + /* RSPINF_a_24 */ s_vCalculateOFDMRParameter(RATE_24M, ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_36 + /* RSPINF_a_36 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_36M), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_48 + /* RSPINF_a_48 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_48M), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); - //RSPINF_a_54 + /* RSPINF_a_54 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); - - //RSPINF_a_72 + /* RSPINF_a_72 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), ePHYType, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); - //Set to Page0 + /* Set to Page0 */ MACvSelectPage0(pDevice->PortOffset); } @@ -1698,7 +1664,6 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType) * none * * Return Value: None. - * */ void vUpdateIFS(struct vnt_private *pDevice) { @@ -1706,19 +1671,20 @@ void vUpdateIFS(struct vnt_private *pDevice) unsigned char byMaxMin = 0; - if (pDevice->byPacketType == PK_TYPE_11A) {//0000 0000 0000 0000,11a + if (pDevice->byPacketType == PK_TYPE_11A) { /*0000 0000 0000 0000,11a*/ pDevice->uSlot = C_SLOT_SHORT; pDevice->uSIFS = C_SIFS_A; pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT; pDevice->uCwMin = C_CWMIN_A; byMaxMin = 4; - } else if (pDevice->byPacketType == PK_TYPE_11B) {//0000 0001 0000 0000,11b + } else if (pDevice->byPacketType == PK_TYPE_11B) { + /* 0000 0001 0000 0000,11b */ pDevice->uSlot = C_SLOT_LONG; pDevice->uSIFS = C_SIFS_BG; pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG; pDevice->uCwMin = C_CWMIN_B; byMaxMin = 5; - } else { // PK_TYPE_11GA & PK_TYPE_11GB + } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ pDevice->uSIFS = C_SIFS_BG; if (pDevice->bShortSlotTime) pDevice->uSlot = C_SLOT_SHORT; @@ -1726,7 +1692,8 @@ void vUpdateIFS(struct vnt_private *pDevice) pDevice->uSlot = C_SLOT_LONG; pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; - if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M + if (pDevice->wBasicRate & 0x0150) { + /* 0000 0001 0101 0000,24M,12M,6M */ pDevice->uCwMin = C_CWMIN_A; byMaxMin = 4; } else { @@ -1738,7 +1705,7 @@ void vUpdateIFS(struct vnt_private *pDevice) pDevice->uCwMax = C_CWMAX; pDevice->uEIFS = C_EIFS; if (pDevice->byRFType == RF_RFMD2959) { - // bcs TX_PE will reserve 3 us + /* bcs TX_PE will reserve 3 us */ VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (unsigned char)(pDevice->uSIFS - 3)); VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (unsigned char)(pDevice->uDIFS - 3)); } else { @@ -1747,7 +1714,7 @@ void vUpdateIFS(struct vnt_private *pDevice) } VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (unsigned char)pDevice->uEIFS); VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (unsigned char)pDevice->uSlot); - byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023 + byMaxMin |= 0xA0; /* 1010 1111,C_CWMAX = 1023 */ VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (unsigned char)byMaxMin); } @@ -1756,7 +1723,7 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) unsigned char byTopOFDM = RATE_24M, byTopCCK = RATE_1M; unsigned char ii; - //Determines the highest basic rate. + /* Determines the highest basic rate. */ for (ii = RATE_54M; ii >= RATE_6M; ii--) { if ((pDevice->wBasicRate) & ((unsigned short)(1<wBasicRate |= wRate; - //Determines the highest basic rate. + /* Determines the highest basic rate. */ CARDvUpdateBasicTopRate((void *)pDevice); return true; @@ -1821,7 +1788,6 @@ unsigned char CARDbyGetPktType(struct vnt_private *pDevice) * none * * Return Value: none - * */ void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode) { @@ -1834,9 +1800,9 @@ void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode) ASSERT(false); break; } - // set MAC loopback + /* set MAC loopback */ MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode)); - // set Baseband loopback + /* set Baseband loopback */ } /* @@ -1849,12 +1815,11 @@ void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode) * none * * Return Value: none - * */ bool CARDbSoftwareReset(struct vnt_private *pDevice) { - // reset MAC + /* reset MAC */ if (!MACbSafeSoftwareReset(pDevice->PortOffset)) return false; @@ -1874,7 +1839,6 @@ bool CARDbSoftwareReset(struct vnt_private *pDevice) * none * * Return Value: TSF Offset value - * */ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) { @@ -1901,7 +1865,6 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) * qwCurrTSF - Current TSF counter * * Return Value: true if success; otherwise false - * */ bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF) { @@ -1934,17 +1897,12 @@ bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF) * qwCurrTSF - Current TSF counter * * Return Value: TSF value of next Beacon - * */ u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval) { u32 beacon_int; beacon_int = wBeaconInterval * 1024; - - /* Next TBTT = - * ((local_current_TSF / beacon_interval) + 1) * beacon_interval - */ if (beacon_int) { do_div(qwTSF, beacon_int); qwTSF += 1; @@ -1966,16 +1924,15 @@ u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval) * none * * Return Value: none - * */ void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval) { u64 qwNextTBTT = 0; - CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter + CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); /* Get Local TSF counter */ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); - // Set NextTBTT + /* Set NextTBTT */ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); @@ -1994,12 +1951,11 @@ void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterva * none * * Return Value: none - * */ void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeaconInterval) { qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); - // Set NextTBTT + /* Set NextTBTT */ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwTSF); VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwTSF >> 32)); MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); -- cgit v1.2.3-59-g8ed1b From 99b4a7e0a2a42b33f5f10cce50d75472d8914652 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 22:44:25 +0200 Subject: staging: vt6655: dpc.h: Replace C99 // comment by /* */ Replace C99 "//" comment by "/* */" Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h index a068b846b1be..e97e32811916 100644 --- a/drivers/staging/vt6655/dpc.h +++ b/drivers/staging/vt6655/dpc.h @@ -39,4 +39,4 @@ device_receive_frame( PSRxDesc pCurrRD ); -#endif // __RXTX_H__ +#endif /* __RXTX_H__ */ -- cgit v1.2.3-59-g8ed1b From 1d39fe040b7e8cb77e330e4fa65c2ab2c73b26b3 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:06:56 +0200 Subject: staging: vt6655: dpc.c: Comment fixes Replace C99 "//" comments by "/* */", remove not needed comments about adding code Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.c | 241 ++++++++++++++++++++++--------------------- 1 file changed, 125 insertions(+), 116 deletions(-) diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index eecf6f559e29..67cadeaf2f7d 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -160,10 +160,10 @@ s_vProcessRxMACHeader(struct vnt_private *pDevice, if (bIsWEP) { if (bExtIV) { - // strip IV&ExtIV , add 8 byte + /* strip IV&ExtIV, add 8 byte */ cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 8); } else { - // strip IV , add 4 byte + /* strip IV, add 4 byte */ cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 4); } } else { @@ -182,9 +182,9 @@ s_vProcessRxMACHeader(struct vnt_private *pDevice, pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); if (bIsWEP) { if (bExtIV) - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV + *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); /* 8 is IV&ExtIV */ else - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV + *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); /* 4 is IV */ } else { *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN); @@ -195,9 +195,9 @@ s_vProcessRxMACHeader(struct vnt_private *pDevice, pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); if (bIsWEP) { if (bExtIV) - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV + *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); /* 8 is IV&ExtIV */ else - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV + *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); /* 4 is IV */ } else { *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN); @@ -243,14 +243,14 @@ s_vGetDASA(unsigned char *pbyRxBufferAddr, unsigned int *pcbHeaderSize, psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii]; } } else { - // IBSS mode + /* IBSS mode */ for (ii = 0; ii < ETH_ALEN; ii++) { psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii]; psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii]; } } } else { - // Is AP mode.. + /* Is AP mode.. */ if (pMACHeader->wFrameCtl & FC_FROMDS) { for (ii = 0; ii < ETH_ALEN; ii++) { psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii]; @@ -303,7 +303,7 @@ device_receive_frame( unsigned short wRxTSC15_0 = 0; unsigned long dwRxTSC47_16 = 0; SKeyItem STempKey; - // 802.11h RPI + /* 802.11h RPI */ unsigned long dwDuration = 0; long ldBm = 0; long ldBmThreshold = 0; @@ -318,10 +318,12 @@ device_receive_frame( pwFrameSize = (unsigned short *)(skb->data + 2); FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount); - // Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR - // Min (ACK): 10HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR + /* + * Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR + * Min (ACK): 10HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR + */ if ((FrameSize > 2364) || (FrameSize <= 32)) { - // Frame Size error drop this packet. + /* Frame Size error drop this packet. */ pr_debug("---------- WRONG Length 1\n"); return false; } @@ -335,16 +337,18 @@ device_receive_frame( pqwTSFTime = (__le64 *)(skb->data + FrameSize - 12); pbyFrame = (unsigned char *)(skb->data + 4); - // get packet size + /* get packet size */ FrameSize = cpu_to_le16(*pwFrameSize); - if ((FrameSize > 2346)|(FrameSize < 14)) { // Max: 2312Payload + 30HD +4CRC - // Min: 14 bytes ACK + if ((FrameSize > 2346)|(FrameSize < 14)) { /* + * Max: 2312Payload + 30HD +4CRC + * Min: 14 bytes ACK + */ pr_debug("---------- WRONG Length 2\n"); return false; } - // update receive statistic counter + /* update receive statistic counter */ STAvUpdateRDStatCounter(&pDevice->scStatistic, *pbyRsr, *pbyNewRsr, @@ -362,10 +366,10 @@ device_receive_frame( dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE]; if (*pbyRxRate <= RATE_11M) { if (*pbyRxSts & 0x01) { - // long preamble + /* long preamble */ dwDuration += 192; } else { - // short preamble + /* short preamble */ dwDuration += 96; } } else { @@ -391,10 +395,10 @@ device_receive_frame( } } - // Use for TKIP MIC + /* Use for TKIP MIC */ s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader); - // filter packet send from myself + /* filter packet send from myself */ if (ether_addr_equal(pDevice->sRxEthHeader.abySrcAddr, pDevice->abyCurrentNetAddr)) return false; @@ -402,7 +406,7 @@ device_receive_frame( if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { p802_11Header = (PS802_11Header)(pbyFrame); - // get SA NodeIndex + /* get SA NodeIndex */ if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(p802_11Header->abyAddr2), &iSANodeIndex)) { pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies; pMgmt->sNodeDBTable[iSANodeIndex].uInActiveCount = 0; @@ -474,25 +478,22 @@ device_receive_frame( return false; } if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) - FrameSize -= 8; // Message Integrity Code + FrameSize -= 8; /* Message Integrity Code */ else - FrameSize -= 4; // 4 is ICV + FrameSize -= 4; /* 4 is ICV */ } - // - // RX OK - // - //remove the CRC length + /* RX OK, remove the CRC length */ FrameSize -= ETH_FCS_LEN; - if ((!(*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI))) && // unicast address + if ((!(*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI))) && /* unicast address */ (IS_FRAGMENT_PKT((skb->data+4))) ) { - // defragment + /* defragment */ bDeFragRx = WCTLbHandleFragment(pDevice, (PS802_11Header)(skb->data+4), FrameSize, bIsWEP, bExtIV); pDevice->s802_11Counter.ReceivedFragmentCount++; if (bDeFragRx) { - // defrag complete + /* defrag complete */ skb = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb; FrameSize = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength; @@ -501,9 +502,9 @@ device_receive_frame( } } -// Management & Control frame Handle +/* Management & Control frame Handle */ if ((IS_TYPE_DATA((skb->data+4))) == false) { - // Handle Control & Manage Frame + /* Handle Control & Manage Frame */ if (IS_TYPE_MGMT((skb->data+4))) { unsigned char *pbyData1; @@ -515,7 +516,7 @@ device_receive_frame( pRxPacket->bySQ = *pbySQ; pRxPacket->qwLocalTSF = le64_to_cpu(*pqwTSFTime); if (bIsWEP) { - // strip IV + /* strip IV */ pbyData1 = WLAN_HDR_A3_DATA_PTR(skb->data+4); pbyData2 = WLAN_HDR_A3_DATA_PTR(skb->data+4) + 4; for (ii = 0; ii < (FrameSize - 4); ii++) { @@ -529,7 +530,7 @@ device_receive_frame( vMgrRxManagePacket((void *)pDevice, pDevice->pMgmt, pRxPacket); - // hostap Deamon handle 802.11 management + /* hostap Deamon handle 802.11 management */ if (pDevice->bEnableHostapd) { skb->dev = pDevice->apdev; skb->data += 4; @@ -547,7 +548,7 @@ device_receive_frame( return false; } else { if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - //In AP mode, hw only check addr1(BSSID or RA) if equal to local MAC. + /* In AP mode, hw only check addr1(BSSID or RA) if equal to local MAC. */ if (!(*pbyRsr & RSR_BSSIDOK)) { if (bDeFragRx) { if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { @@ -558,7 +559,7 @@ device_receive_frame( return false; } } else { - // discard DATA packet while not associate || BSSID error + /* discard DATA packet while not associate || BSSID error */ if (!pDevice->bLinkPass || !(*pbyRsr & RSR_BSSIDOK)) { if (bDeFragRx) { if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { @@ -568,10 +569,9 @@ device_receive_frame( } return false; } - //mike add:station mode check eapol-key challenge---> { - unsigned char Protocol_Version; //802.1x Authentication - unsigned char Packet_Type; //802.1x Authentication + unsigned char Protocol_Version; /* 802.1x Authentication */ + unsigned char Packet_Type; /* 802.1x Authentication */ if (bIsWEP) cbIVOffset = 8; @@ -581,18 +581,17 @@ device_receive_frame( skb->data[cbIVOffset + 8 + 24 + 6 + 1]; Protocol_Version = skb->data[cbIVOffset + 8 + 24 + 6 + 1 + 1]; Packet_Type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 + 1 + 1]; - if (wEtherType == ETH_P_PAE) { //Protocol Type in LLC-Header + if (wEtherType == ETH_P_PAE) { /* Protocol Type in LLC-Header */ if (((Protocol_Version == 1) || (Protocol_Version == 2)) && - (Packet_Type == 3)) { //802.1x OR eapol-key challenge frame receive + (Packet_Type == 3)) { /*802.1x OR eapol-key challenge frame receive */ bRxeapol_key = true; } } } - //mike add:station mode check eapol-key challenge<--- } } -// Data frame Handle +/* Data frame Handle */ if (pDevice->bEnablePSMode) { if (!IS_FC_MOREDATA((skb->data+4))) { @@ -601,7 +600,7 @@ device_receive_frame( } } - // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps + /* Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps */ if (pDevice->bDiversityEnable && (FrameSize > 50) && (pDevice->op_mode == NL80211_IFTYPE_STATION) && pDevice->bLinkPass) { @@ -616,7 +615,7 @@ device_receive_frame( if ((*pbyRSSI != 0) && (pMgmt->pCurrBSS != NULL)) { RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm); - // Monitor if RSSI is too strong. + /* Monitor if RSSI is too strong. */ pMgmt->pCurrBSS->byRSSIStatCnt++; pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT; pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm; @@ -626,12 +625,10 @@ device_receive_frame( } - // ----------------------------------------------- - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnable8021x) { unsigned char abyMacHdr[24]; - // Only 802.1x packet incoming allowed + /* Only 802.1x packet incoming allowed */ if (bIsWEP) cbIVOffset = 8; else @@ -644,7 +641,7 @@ device_receive_frame( skb->dev = pDevice->apdev; if (bIsWEP) { - // strip IV header(8) + /* strip IV header(8) */ memcpy(&abyMacHdr[0], (skb->data + 4), 24); memcpy((skb->data + 4 + cbIVOffset), &abyMacHdr[0], 24); } @@ -660,18 +657,17 @@ device_receive_frame( return true; } - // check if 802.1x authorized + /* check if 802.1x authorized */ if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED)) return false; } if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { if (bIsWEP) - FrameSize -= 8; //MIC + FrameSize -= 8; /* MIC */ } - //-------------------------------------------------------------------------------- - // Soft MIC + /* Soft MIC */ if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { if (bIsWEP) { __le32 *pdwMIC_L; @@ -702,7 +698,7 @@ device_receive_frame( MIC_vAppend((unsigned char *)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12); dwMIC_Priority = 0; MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); - // 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV. + /* 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV. */ MIC_vAppend((unsigned char *)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8), FrameSize - WLAN_HDR_ADDR3_LEN - 8); MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R); @@ -723,13 +719,12 @@ device_receive_frame( pDevice->dev->name); } } - //2008-0409-07, by Einsn Liu #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - //send event to wpa_supplicant + /* send event to wpa_supplicant */ { union iwreq_data wrqu; struct iw_michaelmicfailure ev; - int keyidx = pbyFrame[cbHeaderSize+3] >> 6; //top two-bits + int keyidx = pbyFrame[cbHeaderSize+3] >> 6; /* top two-bits */ memset(&ev, 0, sizeof(ev)); ev.flags = keyidx & IW_MICFAILURE_KEY_ID; @@ -776,17 +771,16 @@ device_receive_frame( } } - } //---end of SOFT MIC----------------------------------------------------------------------- - - // ++++++++++ Reply Counter Check +++++++++++++ + } + /* ++++++++++ Reply Counter Check +++++++++++++ */ if ((pKey != NULL) && ((pKey->byCipherSuite == KEY_CTL_TKIP) || (pKey->byCipherSuite == KEY_CTL_CCMP))) { if (bIsWEP) { unsigned short wLocalTSC15_0 = 0; unsigned long dwLocalTSC47_16 = 0; unsigned long long RSC = 0; - // endian issues + /* endian issues */ RSC = *((unsigned long long *)&(pKey->KeyRSC)); wLocalTSC15_0 = (unsigned short)RSC; dwLocalTSC47_16 = (unsigned long)(RSC>>16); @@ -798,7 +792,7 @@ device_receive_frame( if ((pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) && (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) { - // check RSC + /* check RSC */ if ((wRxTSC15_0 < wLocalTSC15_0) && (dwRxTSC47_16 <= dwLocalTSC47_16) && !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) { @@ -818,13 +812,13 @@ device_receive_frame( } } } - } // ----- End of Reply Counter Check -------------------------- + } s_vProcessRxMACHeader(pDevice, (unsigned char *)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset); FrameSize -= cbHeaderOffset; - cbHeaderOffset += 4; // 4 is Rcv buffer header + cbHeaderOffset += 4; /* 4 is Rcv buffer header */ - // Null data, framesize = 14 + /* Null data, framesize = 14 */ if (FrameSize < 15) return false; @@ -851,7 +845,7 @@ device_receive_frame( skb_put(skb, FrameSize); skb->protocol = eth_type_trans(skb, skb->dev); - //drop frame not met IEEE 802.3 + /* drop frame not met IEEE 802.3 */ skb->ip_summed = CHECKSUM_NONE; pStats->rx_bytes += skb->len; @@ -882,13 +876,14 @@ static bool s_bAPModeRxCtl( if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { p802_11Header = (PS802_11Header)(pbyFrame); if (!IS_TYPE_MGMT(pbyFrame)) { - // Data & PS-Poll packet - // check frame class + /* Data & PS-Poll packet, check frame class */ if (iSANodeIndex > 0) { - // frame class 3 fliter & checking + /* frame class 3 fliter & checking */ if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) { - // send deauth notification - // reason = (6) class 2 received from nonauth sta + /* + * send deauth notification + * reason = (6) class 2 received from nonauth sta + */ vMgrDeAuthenBeginSta(pDevice, pMgmt, (unsigned char *)(p802_11Header->abyAddr2), @@ -899,8 +894,10 @@ static bool s_bAPModeRxCtl( return true; } if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) { - // send deassoc notification - // reason = (7) class 3 received from nonassoc sta + /* + * send deassoc notification + * reason = (7) class 3 received from nonassoc sta + */ vMgrDisassocBeginSta(pDevice, pMgmt, (unsigned char *)(p802_11Header->abyAddr2), @@ -912,14 +909,16 @@ static bool s_bAPModeRxCtl( } if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) { - // delcare received ps-poll event + /* delcare received ps-poll event */ if (IS_CTL_PSPOLL(pbyFrame)) { pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL); pr_debug("dpc: WLAN_CMD_RX_PSPOLL 1\n"); } else { - // check Data PS state - // if PW bit off, send out all PS bufferring packets. + /* + * check Data PS state + * if PW bit off, send out all PS bufferring packets. + */ if (!IS_FC_POWERMGT(pbyFrame)) { pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; @@ -930,10 +929,10 @@ static bool s_bAPModeRxCtl( } else { if (IS_FC_POWERMGT(pbyFrame)) { pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = true; - // Once if STA in PS state, enable multicast bufferring + /* Once if STA in PS state, enable multicast bufferring */ pMgmt->sNodeDBTable[0].bPSEnable = true; } else { - // clear all pending PS frame. + /* clear all pending PS frame. */ if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) { pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; @@ -994,7 +993,7 @@ static bool s_bHandleRxEncryption( pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) { - pbyIV += 6; // 6 is 802.11 address4 + pbyIV += 6; /* 6 is 802.11 address4 */ PayloadLen -= 6; } byKeyIdx = (*(pbyIV+3) & 0xc0); @@ -1008,7 +1007,7 @@ static bool s_bHandleRxEncryption( (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { if (((*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) && (pDevice->pMgmt->byCSSPK != KEY_CTL_NONE)) { - // unicast pkt use pairwise key + /* unicast pkt use pairwise key */ pr_debug("unicast pkt\n"); if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == true) { if (pDevice->pMgmt->byCSSPK == KEY_CTL_TKIP) @@ -1018,7 +1017,7 @@ static bool s_bHandleRxEncryption( } pr_debug("unicast pkt: %d, %p\n", byDecMode, pKey); } else { - // use group key + /* use group key */ KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, byKeyIdx, &pKey); if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP) byDecMode = KEY_CTL_TKIP; @@ -1028,9 +1027,9 @@ static bool s_bHandleRxEncryption( byKeyIdx, byDecMode, pKey); } } - // our WEP only support Default Key + /* our WEP only support Default Key */ if (pKey == NULL) { - // use default group key + /* use default group key */ KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, byKeyIdx, &pKey); if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP) byDecMode = KEY_CTL_TKIP; @@ -1053,14 +1052,16 @@ static bool s_bHandleRxEncryption( return false; } if (byDecMode == KEY_CTL_WEP) { - // handle WEP + /* handle WEP */ if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true)) { - // Software WEP - // 1. 3253A - // 2. WEP 256 + /* + * Software WEP + * 1. 3253A + * 2. WEP 256 + */ - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc + PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); /* 24 is 802.11 header,4 is IV, 4 is crc */ memcpy(pDevice->abyPRNG, pbyIV, 3); memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength); rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); @@ -1072,9 +1073,9 @@ static bool s_bHandleRxEncryption( } } else if ((byDecMode == KEY_CTL_TKIP) || (byDecMode == KEY_CTL_CCMP)) { - // TKIP/AES + /* TKIP/AES */ - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc + PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); /* 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc */ *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); pr_debug("ExtIV: %lx\n", *pdwRxTSC47_16); if (byDecMode == KEY_CTL_TKIP) @@ -1086,8 +1087,10 @@ static bool s_bHandleRxEncryption( if ((byDecMode == KEY_CTL_TKIP) && (pDevice->byLocalID <= REV_ID_VT3253_A1)) { - // Software TKIP - // 1. 3253 A + /* + * Software TKIP + * 1. 3253 A + */ PS802_11Header pMACHeader = (PS802_11Header)(pbyFrame); TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG); @@ -1101,7 +1104,7 @@ static bool s_bHandleRxEncryption( pr_debug("PayloadLen = %d\n", PayloadLen); } } - }// end of TKIP/AES + } if ((*(pbyIV+3) & 0x20) != 0) *pbExtIV = true; @@ -1133,7 +1136,7 @@ static bool s_bHostWepRxEncryption( pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) { - pbyIV += 6; // 6 is 802.11 address4 + pbyIV += 6; /* 6 is 802.11 address4 */ PayloadLen -= 6; } byKeyIdx = (*(pbyIV+3) & 0xc0); @@ -1152,18 +1155,20 @@ static bool s_bHostWepRxEncryption( return false; if (byDecMode == KEY_CTL_WEP) { - // handle WEP + /* handle WEP */ pr_debug("byDecMode == KEY_CTL_WEP\n"); if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true) || !bOnFly) { - // Software WEP - // 1. 3253A - // 2. WEP 256 - // 3. NotOnFly - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc + /* + * Software WEP + * 1. 3253A + * 2. WEP 256 + * 3. NotOnFly + */ + + PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); /* 24 is 802.11 header,4 is IV, 4 is crc */ memcpy(pDevice->abyPRNG, pbyIV, 3); memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength); rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); @@ -1175,9 +1180,9 @@ static bool s_bHostWepRxEncryption( } } else if ((byDecMode == KEY_CTL_TKIP) || (byDecMode == KEY_CTL_CCMP)) { - // TKIP/AES + /* TKIP/AES */ - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc + PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); /* 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc */ *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); pr_debug("ExtIV: %lx\n", *pdwRxTSC47_16); @@ -1190,9 +1195,11 @@ static bool s_bHostWepRxEncryption( if (byDecMode == KEY_CTL_TKIP) { if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || !bOnFly) { - // Software TKIP - // 1. 3253 A - // 2. NotOnFly + /* + * Software TKIP + * 1. 3253 A + * 2. NotOnFly + */ pr_debug("soft KEY_CTL_TKIP\n"); pMACHeader = (PS802_11Header)(pbyFrame); TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG); @@ -1211,8 +1218,10 @@ static bool s_bHostWepRxEncryption( if (byDecMode == KEY_CTL_CCMP) { if (!bOnFly) { - // Software CCMP - // NotOnFly + /* + * Software CCMP + * NotOnFly + */ pr_debug("soft KEY_CTL_CCMP\n"); if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) { *pbyNewRsr |= NEWRSR_DECRYPTOK; @@ -1223,7 +1232,7 @@ static bool s_bHostWepRxEncryption( } } - }// end of TKIP/AES + } if ((*(pbyIV+3) & 0x20) != 0) *pbExtIV = true; @@ -1249,12 +1258,12 @@ static bool s_bAPModeRxData( if (FrameSize > CB_MAX_BUF_SIZE) return false; - // check DA + /* check DA */ if (is_multicast_ether_addr((unsigned char *)(skb->data+cbHeaderOffset))) { if (pMgmt->sNodeDBTable[0].bPSEnable) { skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz); - // if any node in PS mode, buffer packet until DTIM. + /* if any node in PS mode, buffer packet until DTIM. */ if (skbcpy == NULL) { pr_info("relay multicast no skb available\n"); } else { @@ -1264,18 +1273,18 @@ static bool s_bAPModeRxData( skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy); pMgmt->sNodeDBTable[0].wEnQueueCnt++; - // set tx map + /* set tx map */ pMgmt->abyPSTxMap[0] |= byMask[0]; } } else { bRelayAndForward = true; } } else { - // check if relay + /* check if relay */ if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data+cbHeaderOffset), &iDANodeIndex)) { if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) { if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) { - // queue this skb until next PS tx, and then release. + /* queue this skb until next PS tx, and then release. */ skb->data += cbHeaderOffset; skb->tail += cbHeaderOffset; @@ -1296,7 +1305,7 @@ static bool s_bAPModeRxData( } if (bRelayOnly || bRelayAndForward) { - // relay this packet right now + /* relay this packet right now */ if (bRelayAndForward) iDANodeIndex = 0; @@ -1306,7 +1315,7 @@ static bool s_bAPModeRxData( if (bRelayOnly) return false; } - // none associate, don't forward + /* none associate, don't forward */ if (pDevice->uAssocCount == 0) return false; -- cgit v1.2.3-59-g8ed1b From b69c0bfd92e46cceda1757b5eaf1e25e04bd7c63 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:08:50 +0200 Subject: staging: vt6655: desc.h: Comments fixes Replace C99 "//" comments by "/* */", remove blank commented lines Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 101 +++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index 5a2bbd2047d8..8f510c69cee1 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -40,38 +40,30 @@ #define B_OWNED_BY_CHIP 1 #define B_OWNED_BY_HOST 0 -// -// Bits in the RSR register -// +/* Bits in the RSR register */ #define RSR_ADDRBROAD 0x80 #define RSR_ADDRMULTI 0x40 #define RSR_ADDRUNI 0x00 #define RSR_IVLDTYP 0x20 -#define RSR_IVLDLEN 0x10 // invalid len (> 2312 byte) +#define RSR_IVLDLEN 0x10 /* invalid len (> 2312 byte) */ #define RSR_BSSIDOK 0x08 #define RSR_CRCOK 0x04 #define RSR_BCNSSIDOK 0x02 #define RSR_ADDROK 0x01 -// -// Bits in the new RSR register -// +/* Bits in the new RSR register */ #define NEWRSR_DECRYPTOK 0x10 #define NEWRSR_CFPIND 0x08 #define NEWRSR_HWUTSF 0x04 #define NEWRSR_BCNHITAID 0x02 #define NEWRSR_BCNHITAID0 0x01 -// -// Bits in the TSR0 register -// +/* Bits in the TSR0 register */ #define TSR0_PWRSTS1_2 0xC0 #define TSR0_PWRSTS7 0x20 #define TSR0_NCR 0x1F -// -// Bits in the TSR1 register -// +/* Bits in the TSR1 register */ #define TSR1_TERR 0x80 #define TSR1_PWRSTS4_6 0x70 #define TSR1_RETRYTMO 0x08 @@ -79,16 +71,14 @@ #define TSR1_PWRSTS3 0x02 #define ACK_DATA 0x01 -// -// Bits in the TCR register -// -#define EDMSDU 0x04 // end of sdu -#define TCR_EDP 0x02 // end of packet -#define TCR_STP 0x01 // start of packet +/* Bits in the TCR register */ +#define EDMSDU 0x04 /* end of sdu */ +#define TCR_EDP 0x02 /* end of packet */ +#define TCR_STP 0x01 /* start of packet */ -// max transmit or receive buffer size +/* max transmit or receive buffer size */ #define CB_MAX_BUF_SIZE 2900U - // NOTE: must be multiple of 4 + /* NOTE: must be multiple of 4 */ #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE @@ -100,18 +90,21 @@ #define CB_MIN_TX_DESC 16 #define CB_MAX_RECEIVED_PACKETS 16 - // limit our receive routine to indicating - // this many at a time for 2 reasons: - // 1. driver flow control to protocol layer - // 2. limit the time used in ISR routine + /* + * limit our receive routine to indicating + * this many at a time for 2 reasons: + * 1. driver flow control to protocol layer + * 2. limit the time used in ISR routine + */ #define CB_EXTRA_RD_NUM 32 #define CB_RD_NUM 32 #define CB_TD_NUM 32 -// max number of physical segments -// in a single NDIS packet. Above this threshold, the packet -// is copied into a single physically contiguous buffer +/* + * max number of physical segments in a single NDIS packet. Above this + * threshold, the packet is copied into a single physically contiguous buffer + */ #define CB_MAX_SEGMENT 4 #define CB_MIN_MAP_REG_NUM 4 @@ -119,14 +112,15 @@ #define CB_PROTOCOL_RESERVED_SECTION 16 -// if retrys excess 15 times , tx will abort, and -// if tx fifo underflow, tx will fail -// we should try to resend it +/* + * if retrys excess 15 times , tx will abort, and if tx fifo underflow, + * tx will fail, we should try to resend it + */ #define CB_MAX_TX_ABORT_RETRY 3 #ifdef __BIG_ENDIAN -// WMAC definition FIFO Control +/* WMAC definition FIFO Control */ #define FIFOCTL_AUTO_FB_1 0x0010 #define FIFOCTL_AUTO_FB_0 0x0008 #define FIFOCTL_GRPACK 0x0004 @@ -143,7 +137,7 @@ #define FIFOCTL_NEEDACK 0x0200 #define FIFOCTL_LHEAD 0x0100 -//WMAC definition Frag Control +/* WMAC definition Frag Control */ #define FRAGCTL_AES 0x0003 #define FRAGCTL_TKIP 0x0002 #define FRAGCTL_LEGACY 0x0001 @@ -171,7 +165,7 @@ #define FIFOCTL_NEEDACK 0x0002 #define FIFOCTL_LHEAD 0x0001 -//WMAC definition Frag Control +/* WMAC definition Frag Control */ #define FRAGCTL_AES 0x0300 #define FRAGCTL_TKIP 0x0200 #define FRAGCTL_LEGACY 0x0100 @@ -195,14 +189,17 @@ #define TYPE_RXDMA1 1 #define TYPE_MAXRD 2 -// TD_INFO flags control bit -#define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb -#define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap) -#define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit +/* TD_INFO flags control bit */ +#define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */ +#define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb (hostap) */ +#define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */ -// ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel. -// Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj -// may link to older skb that leads error. +/* + * ref_sk_buff is used for mapping the skb structure between pre-built + * driver-obj & running kernel. Since different kernel version (2.4x) may + * change skb structure, i.e. pre-built driver-obj may link to older skb that + * leads error. + */ typedef struct tagDEVICE_RD_INFO { struct sk_buff *skb; @@ -242,9 +239,7 @@ typedef struct tagRDES1 { } __attribute__ ((__packed__)) SRDES1; -// -// Rx descriptor -// +/* Rx descriptor*/ typedef struct tagSRxDesc { volatile SRDES0 m_rd0RD0; volatile SRDES1 m_rd1RD1; @@ -302,9 +297,7 @@ typedef struct tagDEVICE_TD_INFO { unsigned char byFlags; } DEVICE_TD_INFO, *PDEVICE_TD_INFO; -// -// transmit descriptor -// +/* transmit descriptor */ typedef struct tagSTxDesc { volatile STDES0 m_td0TD0; volatile STDES1 m_td1TD1; @@ -319,8 +312,8 @@ typedef const STxDesc *PCSTxDesc; typedef struct tagSTxSyncDesc { volatile STDES0 m_td0TD0; volatile STDES1 m_td1TD1; - volatile u32 buff_addr; // pointer to logical buffer - volatile u32 next_desc; // pointer to next logical descriptor + volatile u32 buff_addr; /* pointer to logical buffer */ + volatile u32 next_desc; /* pointer to next logical descriptor */ volatile unsigned short m_wFIFOCtl; volatile unsigned short m_wTimeStamp; struct tagSTxSyncDesc *next __aligned(8); @@ -329,9 +322,7 @@ typedef struct tagSTxSyncDesc { STxSyncDesc, *PSTxSyncDesc; typedef const STxSyncDesc *PCSTxSyncDesc; -// -// RsvTime buffer header -// +/* RsvTime buffer header */ typedef struct tagSRrvTime_atim { unsigned short wCTSTxRrvTime_ba; unsigned short wTxRrvTime_a; @@ -352,9 +343,7 @@ union vnt_phy_field_swap { u32 field_write; }; -// -// Tx FIFO header -// +/* Tx FIFO header */ typedef struct tagSTxBufHead { u32 adwTxKey[4]; unsigned short wFIFOCtl; @@ -392,4 +381,4 @@ typedef struct tagSKeyEntry { } __attribute__ ((__packed__)) SKeyEntry; -#endif // __DESC_H__ +#endif /* __DESC_H__ */ -- cgit v1.2.3-59-g8ed1b From 29425feb5c498e2983c820ed0787d53a84eb3d55 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:10:43 +0200 Subject: staging: vt6655: bssdb.h: Replace C99 // comments by /* */ Replace C99 "//" comments by "/* */" Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/bssdb.h | 47 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index 5d4dd28b6223..8a37a11809bb 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -37,44 +37,43 @@ #define MAX_NODE_NUM 64 #define MAX_BSS_NUM 42 -#define LOST_BEACON_COUNT 10 // 10 sec, XP defined -#define MAX_PS_TX_BUF 32 // sta max power saving tx buf -#define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only -#define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh +#define LOST_BEACON_COUNT 10 /* 10 sec, XP defined */ +#define MAX_PS_TX_BUF 32 /* sta max power saving tx buf */ +#define ADHOC_LOST_BEACON_COUNT 30 /* 30 sec, beacon lost for adhoc only */ +#define MAX_INACTIVE_COUNT 300 /* 300 sec, inactive STA node refresh */ -#define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period -#define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check +#define USE_PROTECT_PERIOD 10 /*10 sec, Use protect mode check period*/ +#define ERP_RECOVER_COUNT 30 /* 30 sec, ERP support callback check */ #define BSS_CLEAR_COUNT 1 #define RSSI_STAT_COUNT 10 #define MAX_CHECK_RSSI_COUNT 8 -// STA dwflags +/* STA dwflags */ #define WLAN_STA_AUTH BIT0 #define WLAN_STA_ASSOC BIT1 #define WLAN_STA_PS BIT2 #define WLAN_STA_TIM BIT3 -// permanent; do not remove entry on expiration +/* permanent; do not remove entry on expiration */ #define WLAN_STA_PERM BIT4 -// If 802.1X is used, this flag is -// controlling whether STA is authorized to -// send and receive non-IEEE 802.1X frames +/* + * If 802.1X is used, this flag is controlling whether STA is authorized + * to send and receive non-IEEE 802.1X frames + */ #define WLAN_STA_AUTHORIZED BIT5 #define MAX_RATE 12 #define MAX_WPA_IE_LEN 64 -// -// IEEE 802.11 Structures and definitions -// +/* IEEE 802.11 Structures and definitions */ typedef enum _NDIS_802_11_NETWORK_TYPE { Ndis802_11FH, Ndis802_11DS, Ndis802_11OFDM5, Ndis802_11OFDM24, - Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound + Ndis802_11NetworkTypeMax /* defined as an upper bound */ } NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE; typedef struct tagSERPObject { @@ -87,7 +86,7 @@ typedef struct tagSRSNCapObject { unsigned short wRSNCap; } SRSNCapObject, *PSRSNCapObject; -// BSS info(AP) +/* BSS info(AP) */ #pragma pack(1) typedef struct tagKnownBSS { bool bActive; @@ -152,7 +151,7 @@ typedef enum tagNODE_STATE { NODE_ASSOC } NODE_STATE, *PNODE_STATE; -// STA node info +/* STA node info */ typedef struct tagKnownNodeDB { bool bActive; unsigned char abyMACAddr[WLAN_ADDR_LEN]; @@ -163,13 +162,13 @@ typedef struct tagKnownNodeDB { bool bERPExist; bool bShortSlotTime; unsigned int uInActiveCount; - unsigned short wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp. - unsigned short wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon. + unsigned short wMaxBasicRate; /* Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp. */ + unsigned short wMaxSuppRate; /* Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon. */ unsigned short wSuppRate; - unsigned char byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode - unsigned char byTopCCKBasicRate; //Records the highest basic rate in CCK mode + unsigned char byTopOFDMBasicRate; /* Records the highest basic rate in OFDM mode */ + unsigned char byTopCCKBasicRate; /* Records the highest basic rate in CCK mode */ - // For AP mode + /* For AP mode */ struct sk_buff_head sTxPSQueue; unsigned short wCapInfo; unsigned short wListenInterval; @@ -192,7 +191,7 @@ typedef struct tagKnownNodeDB { unsigned short wTSC15_0; unsigned int uWepKeyLength; unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN]; - // Auto rate fallback vars + /* Auto rate fallback vars */ bool bIsInFallback; unsigned int uAverageRSSI; unsigned int uRateRecoveryTimeout; @@ -323,4 +322,4 @@ BSSvClearAnyBSSJoinRecord( void *hDeviceContext ); -#endif //__BSSDB_H__ +#endif /*__BSSDB_H__ */ -- cgit v1.2.3-59-g8ed1b From c834e7656b6caeee56259bf4b241dd7f016b57e4 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:12:46 +0200 Subject: staging: vt6655: channel.c: Comments fixes Replace C99 "//" comments by "/* */", remove not needed comments about adding code Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 4ce964ba14b7..a19965fbcc97 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -375,9 +375,7 @@ bool is_channel_valid(unsigned int ChannelIndex) bool bValid; bValid = false; - /* - * If Channel Index is invalid, return invalid - */ + /* If Channel Index is invalid, return invalid */ if ((ChannelIndex > CB_MAX_CHANNEL) || (ChannelIndex == 0)) { bValid = false; @@ -450,7 +448,6 @@ void init_channel_table(void *pDeviceHandler) } } else { for (ii = 0; ii < CHANNEL_MAX_24G; ii++) { - //2008-8-4 by chester if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { sChannelTbl[ii + 1].bValid = true; pDevice->abyRegPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1]; @@ -538,27 +535,25 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) (pDevice->eCurrentPHYType == PHY_TYPE_11A)) { CARDbSetPhyParameter(pDevice, PHY_TYPE_11G, 0, 0, NULL, NULL); } - // clear NAV + /* clear NAV */ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV); - //{{ RobertYu: 20041202 - //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput + /* TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput */ if (pDevice->byRFType == RF_AIROHA7230) RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (unsigned char)uConnectionChannel); - //}} RobertYu pDevice->byCurrentCh = (unsigned char)uConnectionChannel; bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (unsigned char)uConnectionChannel); - // Init Synthesizer Table + /* Init Synthesizer Table */ if (pDevice->bEnablePSMode) RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel); BBvSoftwareReset(pDevice->PortOffset); if (pDevice->byLocalID > REV_ID_VT3253_B1) { - // set HW default power register + /* set HW default power register */ MACvSelectPage1(pDevice->PortOffset); RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh); VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr); @@ -644,7 +639,7 @@ unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) pIE->len = 0; pbyChTupple = pIE->abyChannelTuple; byLen = 2; - // lower band + /* lower band */ byCount = 0; if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == true) { for (ii = 28; ii < 36; ii += 2) { @@ -665,7 +660,7 @@ unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) *pbyChTupple++ = byCount; byLen += 2; } - // middle band + /* middle band */ byCount = 0; if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == true) { for (ii = 36; ii < 40; ii++) { @@ -677,7 +672,7 @@ unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) *pbyChTupple++ = byCount; byLen += 2; } - // higher band + /* higher band */ byCount = 0; if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == true) { for (ii = 40; ii < 51; ii++) { -- cgit v1.2.3-59-g8ed1b From d8e340de7d2e7df230bd0dc9f43e8205a8a70350 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:18:03 +0200 Subject: staging: vt6655: IEEE11h.h: Replace C99 // comment by /* */ Replace C99 "//" comment by "/* */" Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/IEEE11h.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/IEEE11h.h b/drivers/staging/vt6655/IEEE11h.h index 551922022b19..b3e318d7278f 100644 --- a/drivers/staging/vt6655/IEEE11h.h +++ b/drivers/staging/vt6655/IEEE11h.h @@ -39,4 +39,4 @@ bool IEEE11hbMSRRepTx( void *pMgmtHandle ); -#endif // __IEEE11h_H__ +#endif /* __IEEE11h_H__ */ -- cgit v1.2.3-59-g8ed1b From bd2ac90116fdd516922095557278eb75d934a810 Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:19:40 +0200 Subject: staging: vt6655: ioctl.h: Replace C99 // comment by /* */ Replace C99 "//" comment by "/* */" Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h index 2dc5a5743e8d..1b5d19495fad 100644 --- a/drivers/staging/vt6655/ioctl.h +++ b/drivers/staging/vt6655/ioctl.h @@ -33,4 +33,4 @@ int private_ioctl(struct vnt_private *, struct ifreq *rq); -#endif // __IOCTL_H__ +#endif /* __IOCTL_H__ */ -- cgit v1.2.3-59-g8ed1b From fab2f89359dc1656c3d84629f76f16603514173f Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:21:20 +0200 Subject: staging: vt6655: iowpa.h: Replace C99 // comments by /* */ Replace C99 "//" comments by "/* */" Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iowpa.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/iowpa.h b/drivers/staging/vt6655/iowpa.h index fe4b22ed49f4..7f79eaeecc9e 100644 --- a/drivers/staging/vt6655/iowpa.h +++ b/drivers/staging/vt6655/iowpa.h @@ -31,7 +31,7 @@ #define WPA_IE_LEN 64 -//WPA related +/* WPA related */ enum { VIAWGET_SET_WPA = 1, @@ -117,9 +117,9 @@ struct viawget_scan_result { u16 wpa_ie_len; u8 rsn_ie[WPA_IE_LEN]; u16 rsn_ie_len; - int freq; // MHz - int caps; // e.g. privacy - int qual; // signal quality + int freq; /* MHz */ + int caps; /* e.g. privacy */ + int qual; /* signal quality */ int noise; int level; int maxrate; @@ -127,4 +127,4 @@ struct viawget_scan_result { #pragma pack() -#endif //__IOWPA_H__ +#endif /* __IOWPA_H__ */ -- cgit v1.2.3-59-g8ed1b From af969c84571d9d9140122f5f7c8c615e64d2d7fa Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:23:04 +0200 Subject: staging: vt6655: iocmd.h: Replace C99 // comments by /* */ Replace C99 "//" comments by "/* */" Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iocmd.h | 84 ++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h index a665cfd8a482..804c903404a1 100644 --- a/drivers/staging/vt6655/iocmd.h +++ b/drivers/staging/vt6655/iocmd.h @@ -31,7 +31,7 @@ #include "ttype.h" -// ioctl Command code +/* ioctl Command code */ #define MAGIC_CODE 0x3142 #define IOCTL_CMD_TEST (SIOCDEVPRIVATE + 0) #define IOCTL_CMD_SET (SIOCDEVPRIVATE + 1) @@ -88,9 +88,7 @@ typedef enum tagWZONETYPE { #define WEP_104BIT_LEN 13 #define WEP_232BIT_LEN 16 -// Ioctl interface structure -// Command structure -// +/* Ioctl interface structure, Command structure */ #pragma pack(1) typedef struct tagSCmdRequest { u8 name[16]; @@ -99,18 +97,12 @@ typedef struct tagSCmdRequest { u16 wCmdCode; } SCmdRequest, *PSCmdRequest; -// -// Scan -// - +/* Scan */ typedef struct tagSCmdScan { u8 ssid[SSID_MAXLEN + 2]; } SCmdScan, *PSCmdScan; -// -// BSS Join -// - +/* BSS Join */ typedef struct tagSCmdBSSJoin { u16 wBSSType; u16 wBBPType; @@ -120,10 +112,7 @@ typedef struct tagSCmdBSSJoin { bool bShareKeyAuth; } SCmdBSSJoin, *PSCmdBSSJoin; -// -// Zonetype Setting -// - +/* Zonetype Setting */ typedef struct tagSCmdZoneTypeSet { bool bWrite; WZONETYPE ZoneType; @@ -163,7 +152,7 @@ typedef struct tagSBSSIDItem { u8 abySSID[SSID_MAXLEN + 1]; u8 byNetType; u16 wBeaconInterval; - u16 wCapInfo; // for address of byNetType at align 4 + u16 wCapInfo; /* for address of byNetType at align 4 */ bool bWEPOn; u32 uRSSI; @@ -184,9 +173,7 @@ typedef struct tagSCmdLinkStatus { u32 uLinkRate; } SCmdLinkStatus, *PSCmdLinkStatus; -// -// 802.11 counter -// +/* 802.11 counter */ typedef struct tagSDot11MIBCount { u32 TransmittedFragmentCount; u32 MulticastTransmittedFrameCount; @@ -202,13 +189,9 @@ typedef struct tagSDot11MIBCount { u32 FCSErrorCount; } SDot11MIBCount, *PSDot11MIBCount; -// -// statistic counter -// +/* statistic counter */ typedef struct tagSStatMIBCount { - // - // ISR status count - // + /* ISR status count */ u32 dwIsrTx0OK; u32 dwIsrTx1OK; u32 dwIsrBeaconTxOK; @@ -221,8 +204,7 @@ typedef struct tagSStatMIBCount { u32 dwIsrUnknown; - // RSR status count - // + /* RSR status count */ u32 dwRsrFrmAlgnErr; u32 dwRsrErr; u32 dwRsrCRCErr; @@ -243,10 +225,10 @@ typedef struct tagSStatMIBCount { u32 dwRsrBroadcast; u32 dwRsrMulticast; u32 dwRsrDirected; - // 64-bit OID + /* 64-bit OID */ u32 ullRsrOK; - // for some optional OIDs (64 bits) and DMI support + /* for some optional OIDs (64 bits) and DMI support */ u32 ullRxBroadcastBytes; u32 ullRxMulticastBytes; u32 ullRxDirectedBytes; @@ -262,13 +244,12 @@ typedef struct tagSStatMIBCount { u32 dwRsrRxFrmLen512_1023; u32 dwRsrRxFrmLen1024_1518; - // TSR0,1 status count - // - u32 dwTsrTotalRetry[2]; // total collision retry count - u32 dwTsrOnceRetry[2]; // this packet only occur one collision - u32 dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision - u32 dwTsrRetry[2]; // this packet has ever occur collision, - // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0) + /* TSR0,1 status count */ + u32 dwTsrTotalRetry[2]; /* total collision retry count */ + u32 dwTsrOnceRetry[2]; /* this packet only occur one collision */ + u32 dwTsrMoreThanOnceRetry[2]; /* this packet occur more than one collision */ + u32 dwTsrRetry[2]; /* this packet has ever occur collision */ + /* that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0) */ u32 dwTsrACKData[2]; u32 dwTsrErr[2]; u32 dwAllTsrOK[2]; @@ -281,23 +262,23 @@ typedef struct tagSStatMIBCount { u32 dwTsrMulticast[2]; u32 dwTsrDirected[2]; - // RD/TD count + /* RD/TD count */ u32 dwCntRxFrmLength; u32 dwCntTxBufLength; u8 abyCntRxPattern[16]; u8 abyCntTxPattern[16]; - // Software check.... - u32 dwCntRxDataErr; // rx buffer data software compare CRC err count - u32 dwCntDecryptErr; // rx buffer data software compare CRC err count - u32 dwCntRxICVErr; // rx buffer data software compare CRC err count - u32 idxRxErrorDesc; // index for rx data error RD + /* Software check */ + u32 dwCntRxDataErr; /* rx buffer data software compare CRC err count */ + u32 dwCntDecryptErr; /* rx buffer data software compare CRC err count */ + u32 dwCntRxICVErr; /* rx buffer data software compare CRC err count */ + u32 idxRxErrorDesc; /* index for rx data error RD */ - // 64-bit OID + /* 64-bit OID */ u32 ullTsrOK[2]; - // for some optional OIDs (64 bits) and DMI support + /* for some optional OIDs (64 bits) and DMI support */ u32 ullTxBroadcastFrames[2]; u32 ullTxMulticastFrames[2]; u32 ullTxDirectedFrames[2]; @@ -307,7 +288,7 @@ typedef struct tagSStatMIBCount { } SStatMIBCount, *PSStatMIBCount; typedef struct tagSNodeItem { - // STA info + /* STA info */ u16 wAID; u8 abyMACAddr[6]; u16 wTxDataRate; @@ -318,7 +299,7 @@ typedef struct tagSNodeItem { u8 byKeyIndex; u16 wWepKeyLength; u8 abyWepKey[WEP_KEYMAXLEN]; - // Auto rate fallback vars + /* Auto rate fallback vars */ bool bIsInFallback; u32 uTxFailures; u32 uTxAttempts; @@ -334,10 +315,7 @@ typedef struct tagSCmdValue { u32 dwValue; } SCmdValue, *PSCmdValue; -// -// hostapd & viawget ioctl related -// - +/* hostapd & viawget ioctl related */ enum { VIAWGET_HOSTAPD_FLUSH = 1, VIAWGET_HOSTAPD_ADD_STA = 2, @@ -356,7 +334,7 @@ enum { #define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ ((int)(&((struct viawget_hostapd_param *)0)->u.generic_elem.data)) -// Maximum length for algorithm names (-1 for nul termination) used in ioctl() +/*Maximum length for algorithm names (-1 for nul termination) used in ioctl()*/ struct viawget_hostapd_param { u32 cmd; @@ -405,4 +383,4 @@ struct viawget_hostapd_param { #pragma pack() -#endif //__IOCMD_H__ +#endif /* __IOCMD_H__ */ -- cgit v1.2.3-59-g8ed1b From 1e06c3a492107ca392798ccf835288969ea269ec Mon Sep 17 00:00:00 2001 From: Veronika Kabatova Date: Sat, 25 Oct 2014 23:53:38 +0200 Subject: staging: vt6655: iwctl.c: Comments fixes Replace C99 "//" comments by "/* */", remove comments about adding code, remove commented code (one left there for debugging of the function) Signed-off-by: Veronika Kabatova Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iwctl.c | 510 ++++++++++++++++++----------------------- 1 file changed, 220 insertions(+), 290 deletions(-) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index cc261d7dd058..cbcb152a4a0b 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -46,11 +46,10 @@ #endif #include -extern unsigned short TxRate_iwconfig;//2008-5-8 by chester +extern unsigned short TxRate_iwconfig; /*--------------------- Static Definitions -------------------------*/ -//2008-0409-07, by Einsn Liu #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT #define SUPPORTED_WIRELESS_EXT 18 #else @@ -109,10 +108,8 @@ static int iwctl_commit(struct net_device *dev, return 0; } -/* - * Wireless Handler : get protocol name - */ +/* Wireless Handler : get protocol name */ int iwctl_giwname(struct net_device *dev, struct iw_request_info *info, char *wrq, @@ -122,10 +119,7 @@ int iwctl_giwname(struct net_device *dev, return 0; } -/* - * Wireless Handler : set scan - */ - +/* Wireless Handler : set scan */ static int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -139,8 +133,8 @@ static int iwctl_siwscan(struct net_device *dev, pr_debug(" SIOCSIWSCAN\n"); - if (pDevice->byReAssocCount > 0) { //reject scan when re-associating! -//send scan event to wpa_Supplicant + if (pDevice->byReAssocCount > 0) { /* reject scan when re-associating! */ +/* send scan event to wpa_Supplicant */ union iwreq_data wrqu; PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n"); @@ -152,9 +146,9 @@ static int iwctl_siwscan(struct net_device *dev, spin_lock_irq(&pDevice->lock); BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); -//mike add: active scan OR passive scan OR desire_ssid scan +/* active scan OR passive scan OR desire_ssid scan */ if (wrq->length == sizeof(struct iw_scan_req)) { - if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan + if (wrq->flags & IW_SCAN_THIS_ESSID) { /* desire_ssid scan */ memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); pItemSSID = (PWLAN_IE_SSID)abyScanSSID; pItemSSID->byElementID = WLAN_EID_SSID; @@ -171,10 +165,10 @@ static int iwctl_siwscan(struct net_device *dev, spin_unlock_irq(&pDevice->lock); return 0; - } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan + } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { /* passive scan */ pMgmt->eScanType = WMAC_SCAN_PASSIVE; } - } else { //active scan + } else { /* active scan */ pMgmt->eScanType = WMAC_SCAN_ACTIVE; } @@ -185,10 +179,7 @@ static int iwctl_siwscan(struct net_device *dev, return 0; } -/* - * Wireless Handler : get scan results - */ - +/* Wireless Handler : get scan results */ static int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -210,7 +201,7 @@ static int iwctl_giwscan(struct net_device *dev, pr_debug(" SIOCGIWSCAN\n"); if (pMgmt->eScanState == WMAC_IS_SCANNING) { - // In scanning.. + /* In scanning.. */ return -EAGAIN; } pBSS = &(pMgmt->sBSSList[0]); @@ -219,20 +210,20 @@ static int iwctl_giwscan(struct net_device *dev, break; pBSS = &(pMgmt->sBSSList[jj]); if (pBSS->bActive) { - //ADD mac address + /* ADD mac address */ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN); current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); - //ADD ssid + /* ADD ssid */ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWESSID; pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; iwe.u.data.length = pItemSSID->len; iwe.u.data.flags = 1; current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID); - //ADD mode + /* ADD mode */ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWMODE; if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) @@ -242,7 +233,7 @@ static int iwctl_giwscan(struct net_device *dev, iwe.len = IW_EV_UINT_LEN; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); - //ADD frequency + /* ADD frequency */ pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates; pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates; memset(&iwe, 0, sizeof(iwe)); @@ -251,7 +242,6 @@ static int iwctl_giwscan(struct net_device *dev, iwe.u.freq.e = 0; iwe.u.freq.i = 0; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); - //2008-0409-04, by Einsn Liu { int f = (int)pBSS->uChannel - 1; @@ -260,13 +250,12 @@ static int iwctl_giwscan(struct net_device *dev, iwe.u.freq.e = 1; } current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); - //ADD quality + /* ADD quality */ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVQUAL; RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); iwe.u.qual.level = ldBm; iwe.u.qual.noise = 0; -//2008-0409-01, by Einsn Liu if (-ldBm < 50) iwe.u.qual.qual = 100; else if (-ldBm > 90) @@ -296,14 +285,14 @@ static int iwctl_giwscan(struct net_device *dev, for (kk = 0; kk < 12; kk++) { if (pSuppRates->abyRates[kk] == 0) break; - // Bit rate given in 500 kb/s units (+ 0x80) + /* Bit rate given in 500 kb/s units (+ 0x80) */ iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000); current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); } for (kk = 0; kk < 8; kk++) { if (pExtSuppRates->abyRates[kk] == 0) break; - // Bit rate given in 500 kb/s units (+ 0x80) + /* Bit rate given in 500 kb/s units (+ 0x80) */ iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000); current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); } @@ -332,16 +321,13 @@ static int iwctl_giwscan(struct net_device *dev, } } - }// for + } wrq->length = current_ev - extra; return 0; } -/* - * Wireless Handler : set frequency or channel - */ - +/* Wireless Handler : set frequency or channel */ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info, struct iw_freq *wrq, @@ -352,7 +338,7 @@ int iwctl_siwfreq(struct net_device *dev, pr_debug(" SIOCSIWFREQ\n"); - // If setting by frequency, convert to a channel + /* If setting by frequency, convert to a channel */ if ((wrq->e == 1) && (wrq->m >= (int) 2.412e8) && (wrq->m <= (int) 2.487e8)) { @@ -364,7 +350,7 @@ int iwctl_siwfreq(struct net_device *dev, wrq->e = 0; wrq->m = c + 1; } - // Setting by channel number + /* Setting by channel number */ if ((wrq->m > 14) || (wrq->e > 0)) rc = -EOPNOTSUPP; else { @@ -375,11 +361,10 @@ int iwctl_siwfreq(struct net_device *dev, dev->name, wrq->m); rc = -EINVAL; } else { - // Yes ! We can set it !!! + /* Yes ! We can set it !!! */ pr_debug(" Set to channel = %d\n", channel); pDevice->uChannel = channel; - //2007-0207-04, by EinsnLiu - //Make change effect at once + /* Make change effect at once */ pDevice->bCommit = true; } } @@ -387,10 +372,7 @@ int iwctl_siwfreq(struct net_device *dev, return rc; } -/* - * Wireless Handler : get frequency or channel - */ - +/* Wireless Handler : get frequency or channel */ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info, struct iw_freq *wrq, @@ -418,10 +400,7 @@ int iwctl_giwfreq(struct net_device *dev, return 0; } -/* - * Wireless Handler : set operation mode - */ - +/* Wireless Handler : set operation mode */ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, __u32 *wmode, @@ -475,10 +454,7 @@ int iwctl_siwmode(struct net_device *dev, return rc; } -/* - * Wireless Handler : get operation mode - */ - +/* Wireless Handler : get operation mode */ int iwctl_giwmode(struct net_device *dev, struct iw_request_info *info, __u32 *wmode, @@ -488,7 +464,7 @@ int iwctl_giwmode(struct net_device *dev, PSMgmtObject pMgmt = &(pDevice->sMgmtObj); pr_debug(" SIOCGIWMODE\n"); - // If not managed, assume it's ad-hoc + /* If not managed, assume it's ad-hoc */ switch (pMgmt->eConfigMode) { case WMAC_CONFIG_ESS_STA: *wmode = IW_MODE_INFRA; @@ -509,10 +485,7 @@ int iwctl_giwmode(struct net_device *dev, return 0; } -/* - * Wireless Handler : get capability range - */ - +/* Wireless Handler : get capability range */ int iwctl_giwrange(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -529,16 +502,18 @@ int iwctl_giwrange(struct net_device *dev, range->min_nwid = 0x0000; range->max_nwid = 0x0000; range->num_channels = 14; - // Should be based on cap_rid.country to give only - // what the current card support + /* + * Should be based on cap_rid.country to give only + * what the current card supports + */ k = 0; for (i = 0; i < 14; i++) { - range->freq[k].i = i + 1; // List index + range->freq[k].i = i + 1; /* List index */ range->freq[k].m = frequency_list[i] * 100000; - range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10 + range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ } range->num_frequency = k; - // Hum... Should put the right values there + /* Hum... Should put the right values there */ #ifdef Calcu_LinkQual range->max_qual.qual = 100; #else @@ -555,9 +530,10 @@ int iwctl_giwrange(struct net_device *dev, } range->num_bitrates = i; - // Set an indication of the max TCP throughput - // in bit/s that we can expect using this interface. - // May be use for QoS stuff... Jean II + /* + * Set an indication of the max TCP throughput in bit/s that we + * can expect using this interface. May be used for QoS stuff + */ if (i > 2) range->throughput = 5 * 1000 * 1000; else @@ -568,29 +544,29 @@ int iwctl_giwrange(struct net_device *dev, range->min_frag = 256; range->max_frag = 2312; - // the encoding capabilities + /* the encoding capabilities */ range->num_encoding_sizes = 3; - // 64(40) bits WEP + /* 64(40) bits WEP */ range->encoding_size[0] = 5; - // 128(104) bits WEP + /* 128(104) bits WEP */ range->encoding_size[1] = 13; - // 256 bits for WPA-PSK + /* 256 bits for WPA-PSK */ range->encoding_size[2] = 32; - // 4 keys are allowed + /* 4 keys are allowed */ range->max_encoding_tokens = 4; range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; range->min_pmp = 0; - range->max_pmp = 1000000;// 1 secs + range->max_pmp = 1000000; /* 1 secs */ range->min_pmt = 0; - range->max_pmt = 1000000;// 1 secs + range->max_pmt = 1000000; /* 1 secs */ range->pmp_flags = IW_POWER_PERIOD; range->pmt_flags = IW_POWER_TIMEOUT; range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; - // Transmit Power - values are in mW + /* Transmit Power - values are in mW */ range->txpower[0] = 100; range->num_txpower = 1; @@ -604,21 +580,20 @@ int iwctl_giwrange(struct net_device *dev, range->max_retry = 65535; range->min_r_time = 1024; range->max_r_time = 65535 * 1024; - // Experimental measurements - boundary 11/5.5 Mb/s - // Note : with or without the (local->rssi), results - // are somewhat different. - Jean II + /* + * Experimental measurements - boundary 11/5.5 Mb/s + * Note : with or without the (local->rssi), results + * are somewhat different. - Jean II + */ range->avg_qual.qual = 6; - range->avg_qual.level = 176; // -80 dBm + range->avg_qual.level = 176; /* -80 dBm */ range->avg_qual.noise = 0; } return 0; } -/* - * Wireless Handler : set ap mac address - */ - +/* Wireless Handler : set ap mac address */ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *wrq, @@ -631,26 +606,26 @@ int iwctl_siwap(struct net_device *dev, pr_debug(" SIOCSIWAP\n"); if (pMgmt->eScanState == WMAC_IS_SCANNING) { - // In scanning.. + /* In scanning.. */ pr_debug("SIOCSIWAP(??)-->In scanning..\n"); } if (wrq->sa_family != ARPHRD_ETHER) rc = -EINVAL; else { memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6); - //2008-0409-05, by Einsn Liu if ((pDevice->bLinkPass == true) && (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6) == 0)) { return rc; } - //mike :add if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) || (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)) { PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n"); return rc; } - //mike add: if desired AP is hidden ssid(there are two same BSSID in list), - // then ignore,because you don't known which one to be connect with?? + /* if desired AP is hidden ssid(there are two same BSSID in + * list), then ignore,because you don't known which one + * to be connected with?? + */ { unsigned int ii, uSameBssidNum = 0; @@ -661,7 +636,7 @@ int iwctl_siwap(struct net_device *dev, uSameBssidNum++; } } - if (uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!! + if (uSameBssidNum >= 2) { /* hit: desired AP is in hidden ssid mode!!! */ PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n"); return rc; } @@ -674,10 +649,7 @@ int iwctl_siwap(struct net_device *dev, return rc; } -/* - * Wireless Handler : get ap mac address - */ - +/* Wireless Handler : get ap mac address */ int iwctl_giwap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *wrq, @@ -689,7 +661,6 @@ int iwctl_giwap(struct net_device *dev, pr_debug(" SIOCGIWAP\n"); memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); - //2008-0410, by Einsn Liu if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) memset(wrq->sa_data, 0, 6); @@ -701,10 +672,7 @@ int iwctl_giwap(struct net_device *dev, return 0; } -/* - * Wireless Handler : get ap list - */ - +/* Wireless Handler : get ap list */ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -774,10 +742,7 @@ exit: return rc; } -/* - * Wireless Handler : set essid - */ - +/* Wireless Handler : set essid */ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -786,18 +751,17 @@ int iwctl_siwessid(struct net_device *dev, struct vnt_private *pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PWLAN_IE_SSID pItemSSID; - //2008-0409-05, by Einsn Liu unsigned char len; pr_debug(" SIOCSIWESSID\n"); pDevice->fWPA_Authened = false; if (pMgmt->eScanState == WMAC_IS_SCANNING) { - // In scanning.. + /* In scanning.. */ pr_debug("SIOCSIWESSID(??)-->In scanning..\n"); } - // Check if we asked for `any' + /* Check if we asked for 'any' */ if (wrq->flags == 0) { - // Just send an empty SSID list + /* Just send an empty SSID list */ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memset(pMgmt->abyDesireBSSID, 0xFF, 6); PRINT_K("set essid to 'any'\n"); @@ -805,7 +769,7 @@ int iwctl_siwessid(struct net_device *dev, return 0; #endif } else { - // Set the SSID + /* Set the SSID */ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; pItemSSID->byElementID = WLAN_EID_SSID; @@ -817,21 +781,22 @@ int iwctl_siwessid(struct net_device *dev, } else pItemSSID->len = wrq->length; pr_debug("set essid to %s\n", pItemSSID->abySSID); - //2008-0409-05, by Einsn Liu len = (pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) ? pItemSSID->len : ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len; if ((pDevice->bLinkPass == true) && (memcmp(pItemSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, len) == 0)) return 0; - //mike:need clear desiredBSSID + /* need clear desiredBSSID */ if (pItemSSID->len == 0) { memset(pMgmt->abyDesireBSSID, 0xFF, 6); return 0; } #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - //Wext wil order another command of siwap to link with desired AP, - //so here need not associate?? + /* + * Wext wil order another command of siwap to link with desired + * AP, so here need not associate?? + */ if (pDevice->bWPASuppWextEnabled == true) { /*******search if in hidden ssid mode ****/ { @@ -852,8 +817,12 @@ int iwctl_siwessid(struct net_device *dev, pMgmt->eScanType = WMAC_SCAN_ACTIVE; bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID); - } else { //mike:to find out if that desired SSID is a hidden-ssid AP , - // by means of judging if there are two same BSSID exist in list ? + } else { /* + * to find out if that desired SSID + * is a hidden-ssid AP, by means of + * judging if there are two same + * BSSID exist in list ? + */ for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (pMgmt->sBSSList[ii].bActive && ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, @@ -861,10 +830,10 @@ int iwctl_siwessid(struct net_device *dev, uSameBssidNum++; } } - if (uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!! + if (uSameBssidNum >= 2) { /* hit: desired AP is in hidden ssid mode!!! */ pr_debug("SIOCSIWESSID:hidden ssid directly associate.......\n"); vResetCommandTimer((void *)pDevice); - pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result! + pMgmt->eScanType = WMAC_SCAN_PASSIVE; /* this scan type, you'll submit scan result! */ bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID); } @@ -883,10 +852,7 @@ int iwctl_siwessid(struct net_device *dev, return 0; } -/* - * Wireless Handler : get essid - */ - +/* Wireless Handler : get essid */ int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -898,25 +864,23 @@ int iwctl_giwessid(struct net_device *dev, pr_debug(" SIOCGIWESSID\n"); - // Note : if wrq->u.data.flags != 0, we should - // get the relevant SSID from the SSID list... + /* + * Note : if wrq->u.data.flags != 0, we should get the relevant SSID + * from the SSID list... + */ - // Get the current SSID + /* Get the current SSID */ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memcpy(extra, pItemSSID->abySSID , pItemSSID->len); extra[pItemSSID->len] = '\0'; wrq->length = pItemSSID->len + 1; - //2008-0409-03, by Einsn Liu wrq->length = pItemSSID->len; - wrq->flags = 1; // active + wrq->flags = 1; /* active */ return 0; } -/* - * Wireless Handler : set data rate - */ - +/* Wireless Handler : set data rate */ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -934,19 +898,18 @@ int iwctl_siwrate(struct net_device *dev, return rc; } - // First : get a valid bit rate value + /* First : get a valid bit rate value */ - // Which type of value + /* Which type of value */ if ((wrq->value < 13) && (wrq->value >= 0)) { - // Setting by rate index - // Find value in the magic rate table + /* Setting by rate index, Find value in the magic rate table */ brate = wrq->value; } else { - // Setting by frequency value + /* Setting by frequency value */ u8 normvalue = (u8) (wrq->value/500000); - // Check if rate is valid + /* Check if rate is valid */ for (i = 0; i < 13; i++) { if (normvalue == abySupportedRates[i]) { brate = i; @@ -954,9 +917,9 @@ int iwctl_siwrate(struct net_device *dev, } } } - // -1 designed the max rate (mostly auto mode) + /* -1 designed the max rate (mostly auto mode) */ if (wrq->value == -1) { - // Get the highest available rate + /* Get the highest available rate */ for (i = 0; i < 13; i++) { if (abySupportedRates[i] == 0) break; @@ -965,17 +928,15 @@ int iwctl_siwrate(struct net_device *dev, brate = i - 1; } - // Check that it is valid - // brate is index of abySupportedRates[] + /* Check that it is valid, brate is index of abySupportedRates[] */ if (brate > 13) { rc = -EINVAL; return rc; } - // Now, check if we want a fixed or auto value + /* Now, check if we want a fixed or auto value */ if (wrq->fixed != 0) { - // Fixed mode - // One rate, fixed + /* Fixed mode, One rate, fixed */ pr_debug("Rate Fix\n"); pDevice->bFixRate = true; if ((pDevice->byBBType == BB_TYPE_11B) && (brate > 3)) { @@ -995,25 +956,18 @@ int iwctl_siwrate(struct net_device *dev, return rc; } -/* - * Wireless Handler : get data rate - */ - +/* Wireless Handler : get data rate */ int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra) { struct vnt_private *pDevice = netdev_priv(dev); -//2007-0118-05, by EinsnLiu -//Mark the unnecessary sentences. -// PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - +/* Mark the unnecessary sentences. */ pr_debug(" SIOCGIWRATE\n"); { unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; int brate = 0; -//2008-5-8 by chester if (pDevice->bLinkPass) { if (pDevice->bFixRate == true) { if (pDevice->uConnectionRate < 13) { @@ -1032,7 +986,7 @@ int iwctl_giwrate(struct net_device *dev, } else brate = 0; wrq->value = brate * 500000; - // If more than one rate, set auto + /* If more than one rate, set auto */ if (pDevice->bFixRate == true) wrq->fixed = true; } @@ -1040,10 +994,7 @@ int iwctl_giwrate(struct net_device *dev, return 0; } -/* - * Wireless Handler : set rts threshold - */ - +/* Wireless Handler : set rts threshold */ int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1069,10 +1020,7 @@ int iwctl_siwrts(struct net_device *dev, return 0; } -/* - * Wireless Handler : get rts - */ - +/* Wireless Handler : get rts */ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1088,10 +1036,7 @@ int iwctl_giwrts(struct net_device *dev, return 0; } -/* - * Wireless Handler : set fragment threshold - */ - +/* Wireless Handler : set fragment threshold */ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1108,17 +1053,14 @@ int iwctl_siwfrag(struct net_device *dev, if ((fthr < 256) || (fthr > 2312)) { rc = -EINVAL; } else { - fthr &= ~0x1; // Get an even value + fthr &= ~0x1; /* Get an even value */ pDevice->wFragmentationThreshold = (u16)fthr; } return rc; } -/* - * Wireless Handler : get fragment threshold - */ - +/* Wireless Handler : get fragment threshold */ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1134,9 +1076,7 @@ int iwctl_giwfrag(struct net_device *dev, return 0; } -/* - * Wireless Handler : set retry threshold - */ +/* Wireless Handler : set retry threshold */ int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1158,7 +1098,7 @@ int iwctl_siwretry(struct net_device *dev, else if (wrq->flags & IW_RETRY_MIN) pDevice->byShortRetryLimit = wrq->value; else { - // No modifier : set both + /* No modifier : set both */ pDevice->byShortRetryLimit = wrq->value; pDevice->byLongRetryLimit = wrq->value; } @@ -1169,9 +1109,7 @@ int iwctl_siwretry(struct net_device *dev, return rc; } -/* - * Wireless Handler : get retry threshold - */ +/* Wireless Handler : get retry threshold */ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1180,12 +1118,12 @@ int iwctl_giwretry(struct net_device *dev, struct vnt_private *pDevice = netdev_priv(dev); pr_debug(" SIOCGIWRETRY\n"); - wrq->disabled = 0; // Can't be disabled + wrq->disabled = 0; /* Can't be disabled */ - // Note : by default, display the min retry number + /* Note : by default, display the min retry number */ if ((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { wrq->flags = IW_RETRY_LIFETIME; - wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms + wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; /* ms */ } else if ((wrq->flags & IW_RETRY_MAX)) { wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; wrq->value = (int)pDevice->byLongRetryLimit; @@ -1199,9 +1137,7 @@ int iwctl_giwretry(struct net_device *dev, return 0; } -/* - * Wireless Handler : set encode mode - */ +/* Wireless Handler : set encode mode */ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -1213,28 +1149,30 @@ int iwctl_siwencode(struct net_device *dev, int ii, uu, rc = 0; int index = (wrq->flags & IW_ENCODE_INDEX); -//2007-0207-07, by EinsnLiu -//There are some problems when using iwconfig encode/key command to set the WEP key. -//I almost rewrite this function. -//now it support:(assume the wireless interface's name is eth0) -//iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/ -//iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */ -//iwconfig eth0 key 1122334455 /*set key string to driver using index*/ -//iwconfig eth0 key restricted /*enable share key*/ +/* + * There are some problems when using iwconfig encode/key command to set the + * WEP key. I almost rewrite this function. Now it supports: (assume the + * wireless interface's name is eth0) + * iwconfig eth0 key [1] 1122334455 open -> set key stirng to index 1, and + driver using key index is set to 1 + * iwconfig eth0 key [3] -> set driver using key index to 3,the key string no change + * iwconfig eth0 key 1122334455 -> set key string to driver using index + * iwconfig eth0 key restricted -> enable share key + */ PSKeyTable pkeytab; pr_debug(" SIOCSIWENCODE\n"); if ((wrq->flags & IW_ENCODE_DISABLED) == 0) { - //Not disable encryption + /* Not disable encryption */ if (dwKeyIndex > WLAN_WEP_NKEYS) { rc = -EINVAL; return rc; } - if (dwKeyIndex < 1 && ((wrq->flags & IW_ENCODE_NOKEY) == 0)) {//set default key + if (dwKeyIndex < 1 && ((wrq->flags & IW_ENCODE_NOKEY) == 0)) { /* set default key */ if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) dwKeyIndex = pDevice->byKeyIndex; else @@ -1243,13 +1181,13 @@ int iwctl_siwencode(struct net_device *dev, dwKeyIndex--; } - // Check the size of the key + /* Check the size of the key */ if (wrq->length > WLAN_WEP232_KEYLEN) { rc = -EINVAL; return rc; } - if (wrq->length > 0) {//have key + if (wrq->length > 0) { /* have key */ if (wrq->length == WLAN_WEP232_KEYLEN) { pr_debug("Set 232 bit wep key\n"); @@ -1258,7 +1196,7 @@ int iwctl_siwencode(struct net_device *dev, } else if (wrq->length == WLAN_WEP40_KEYLEN) { pr_debug("Set 40 bit wep key, index= %d\n", (int)dwKeyIndex); - } else {//no support length + } else { /* no support length */ rc = -EINVAL; return rc; } @@ -1289,8 +1227,11 @@ int iwctl_siwencode(struct net_device *dev, pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; } else if (index > 0) { - //when the length is 0 the request only changes the default transmit key index - //check the new key if it has a non zero length + /* + * when the length is 0 the request only changes the + * default transmit key index, check the new key if it + * has a non zero length + */ if (pDevice->bEncryptionEnable == false) { rc = -EINVAL; return rc; @@ -1307,7 +1248,7 @@ int iwctl_siwencode(struct net_device *dev, pkeytab->GroupKey[(unsigned char)dwKeyIndex].dwKeyIndex = dwKeyIndex | (1 << 31); } - } else {//disable the key + } else { /* disable the key */ pr_debug("Disable WEP function\n"); if (pDevice->bEncryptionEnable == false) return 0; @@ -1321,7 +1262,6 @@ int iwctl_siwencode(struct net_device *dev, spin_unlock_irq(&pDevice->lock); } } -//End Modify,Einsn if (wrq->flags & IW_ENCODE_RESTRICTED) { pr_debug("Enable WEP & ShareKey System\n"); @@ -1351,7 +1291,7 @@ int iwctl_giwencode(struct net_device *dev, if (index > WLAN_WEP_NKEYS) return -EINVAL; - if (index < 1) {//get default key + if (index < 1) { /* get default key */ if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) index = pDevice->byKeyIndex; else @@ -1361,9 +1301,9 @@ int iwctl_giwencode(struct net_device *dev, } memset(abyKey, 0, WLAN_WEP232_KEYLEN); - // Check encryption mode + /* Check encryption mode */ wrq->flags = IW_ENCODE_NOKEY; - // Is WEP enabled ??? + /* Is WEP enabled ??? */ if (pDevice->bEncryptionEnable) wrq->flags |= IW_ENCODE_ENABLED; else @@ -1376,7 +1316,7 @@ int iwctl_giwencode(struct net_device *dev, wrq->length = 0; if ((index == 0) && (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled || - pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)) {//get wpa pairwise key + pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)) { /* get wpa pairwise key */ if (KeybGetKey(&(pDevice->sKey), pMgmt->abyCurrBSSID, 0xffffffff, &pKey)) { wrq->length = pKey->uKeyLength; memcpy(abyKey, pKey->abyKey, pKey->uKeyLength); @@ -1393,9 +1333,7 @@ int iwctl_giwencode(struct net_device *dev, return 0; } -/* - * Wireless Handler : set power mode - */ +/* Wireless Handler : set power mode */ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1443,9 +1381,7 @@ int iwctl_siwpower(struct net_device *dev, return rc; } -/* - * Wireless Handler : get power mode - */ +/* Wireless Handler : get power mode */ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1473,9 +1409,7 @@ int iwctl_giwpower(struct net_device *dev, return 0; } -/* - * Wireless Handler : get Sensitivity - */ +/* Wireless Handler : get Sensitivity */ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, @@ -1497,7 +1431,6 @@ int iwctl_giwsens(struct net_device *dev, return 0; } -//2008-0409-07, by Einsn Liu #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT int iwctl_siwauth(struct net_device *dev, @@ -1508,7 +1441,7 @@ int iwctl_siwauth(struct net_device *dev, struct vnt_private *pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); int ret = 0; - static int wpa_version = 0; //must be static to save the last value,einsn liu + static int wpa_version = 0; /* must be static to save the last value */ static int pairwise = 0; pr_debug(" SIOCSIWAUTH\n"); @@ -1532,7 +1465,7 @@ int iwctl_siwauth(struct net_device *dev, else if (pairwise == IW_AUTH_CIPHER_WEP40 || pairwise == IW_AUTH_CIPHER_WEP104) pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; else if (pairwise == IW_AUTH_CIPHER_NONE) - ; /* do nothing,einsn liu */ + ; /* do nothing */ else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; @@ -1645,7 +1578,7 @@ int iwctl_siwgenie(struct net_device *dev, pMgmt->wWPAIELen = 0; } -out://not completely ...not necessary in wpa_supplicant 0.5.8 +out: /* not completely ...not necessary in wpa_supplicant 0.5.8 */ return ret; } @@ -1682,7 +1615,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct vnt_private *pDevice = netdev_priv(dev); struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct viawget_wpa_param *param = NULL; -//original member +/* original member */ enum wpa_alg alg_name; u8 addr[6]; int key_idx, set_tx = 0; @@ -1699,7 +1632,7 @@ int iwctl_siwencodeext(struct net_device *dev, if (param == NULL) return -ENOMEM; -//recover alg_name +/* recover alg_name */ switch (ext->alg) { case IW_ENCODE_ALG_NONE: alg_name = WPA_ALG_NONE; @@ -1718,19 +1651,19 @@ int iwctl_siwencodeext(struct net_device *dev, ret = -ENOMEM; goto error; } -//recover addr +/* recover addr */ ether_addr_copy(addr, ext->addr.sa_data); -//recover key_idx +/* recover key_idx */ key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1; -//recover set_tx +/* recover set_tx */ if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) set_tx = 1; -//recover seq,seq_len +/* recover seq,seq_len */ if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { seq_len = IW_ENCODE_SEQ_MAX_SIZE; memcpy(seq, ext->rx_seq, seq_len); } -//recover key,key_len +/* recover key,key_len */ if (ext->key_len) { key_len = ext->key_len; memcpy(key, &ext->key[0], key_len); @@ -1740,7 +1673,7 @@ int iwctl_siwencodeext(struct net_device *dev, if (key_len > 0) { memcpy(key_array, key, key_len); if (key_len == 32) { - // notice ! the oder + /* notice ! the oder */ memcpy(&key_array[16], &key[24], 8); memcpy(&key_array[24], &key[16], 8); } @@ -1756,8 +1689,10 @@ int iwctl_siwencodeext(struct net_device *dev, param->u.wpa_key.seq = (u8 *)seq; param->u.wpa_key.seq_len = seq_len; -//****set if current action is Network Manager count?? -//****this method is so foolish,but there is no other way??? +/* + * set if current action is Network Manager count?? this method is so + * foolish,but there is no other way??? + */ if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { if (param->u.wpa_key.key_index == 0) pDevice->bwextcount++; @@ -1777,7 +1712,6 @@ int iwctl_siwencodeext(struct net_device *dev, pDevice->bwextcount = 0; pDevice->bWPASuppWextEnabled = true; } -//****** spin_lock_irq(&pDevice->lock); ret = wpa_set_keys(pDevice, param, true); @@ -1817,13 +1751,15 @@ int iwctl_siwmlme(struct net_device *dev, } switch (mime.cmd) { case IW_MLME_DEAUTH: - //this command seems to be not complete,please test it --einsnliu - //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason); + /* + * this command seems to be not complete,please test it --einsnliu + * bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason); + */ break; case IW_MLME_DISASSOC: if (pDevice->bLinkPass == true) { pr_debug("iwctl_siwmlme--->send DISASSOCIATE\n"); - //clear related flags + /* clear related flags */ memset(pMgmt->abyDesireBSSID, 0xFF, 6); KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); @@ -1838,76 +1774,70 @@ int iwctl_siwmlme(struct net_device *dev, #endif -/*------------------------------------------------------------------*/ -/* - * Structures to export the Wireless Handlers - */ - +/* Structures to export the Wireless Handlers */ static const iw_handler iwctl_handler[] = { - (iw_handler) iwctl_commit, // SIOCSIWCOMMIT - (iw_handler) NULL, // SIOCGIWNAME - (iw_handler) NULL, // SIOCSIWNWID - (iw_handler) NULL, // SIOCGIWNWID - (iw_handler) NULL, // SIOCSIWFREQ - (iw_handler) NULL, // SIOCGIWFREQ - (iw_handler) NULL, // SIOCSIWMODE - (iw_handler) NULL, // SIOCGIWMODE - (iw_handler) NULL, // SIOCSIWSENS - (iw_handler) NULL, // SIOCGIWSENS - (iw_handler) NULL, // SIOCSIWRANGE - (iw_handler) iwctl_giwrange, // SIOCGIWRANGE - (iw_handler) NULL, // SIOCSIWPRIV - (iw_handler) NULL, // SIOCGIWPRIV - (iw_handler) NULL, // SIOCSIWSTATS - (iw_handler) NULL, // SIOCGIWSTATS - (iw_handler) NULL, // SIOCSIWSPY - (iw_handler) NULL, // SIOCGIWSPY - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // SIOCSIWAP - (iw_handler) NULL, // SIOCGIWAP - (iw_handler) NULL, // -- hole -- 0x16 - (iw_handler) NULL, // SIOCGIWAPLIST - (iw_handler) iwctl_siwscan, // SIOCSIWSCAN - (iw_handler) iwctl_giwscan, // SIOCGIWSCAN - (iw_handler) NULL, // SIOCSIWESSID - (iw_handler) NULL, // SIOCGIWESSID - (iw_handler) NULL, // SIOCSIWNICKN - (iw_handler) NULL, // SIOCGIWNICKN - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // SIOCSIWRATE 0x20 - (iw_handler) NULL, // SIOCGIWRATE - (iw_handler) NULL, // SIOCSIWRTS - (iw_handler) NULL, // SIOCGIWRTS - (iw_handler) NULL, // SIOCSIWFRAG - (iw_handler) NULL, // SIOCGIWFRAG - (iw_handler) NULL, // SIOCSIWTXPOW - (iw_handler) NULL, // SIOCGIWTXPOW - (iw_handler) NULL, // SIOCSIWRETRY - (iw_handler) NULL, // SIOCGIWRETRY - (iw_handler) NULL, // SIOCSIWENCODE - (iw_handler) NULL, // SIOCGIWENCODE - (iw_handler) NULL, // SIOCSIWPOWER - (iw_handler) NULL, // SIOCGIWPOWER - -//2008-0409-07, by Einsn Liu - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // SIOCSIWGENIE - (iw_handler) NULL, // SIOCGIWGENIE - (iw_handler) NULL, // SIOCSIWAUTH - (iw_handler) NULL, // SIOCGIWAUTH - (iw_handler) NULL, // SIOCSIWENCODEEXT - (iw_handler) NULL, // SIOCGIWENCODEEXT - (iw_handler) NULL, // SIOCSIWPMKSA - (iw_handler) NULL, // -- hole -- + (iw_handler) iwctl_commit, /* SIOCSIWCOMMIT */ + (iw_handler) NULL, /* SIOCGIWNAME */ + (iw_handler) NULL, /* SIOCSIWNWID */ + (iw_handler) NULL, /* SIOCGIWNWID */ + (iw_handler) NULL, /* SIOCSIWFREQ */ + (iw_handler) NULL, /* SIOCGIWFREQ */ + (iw_handler) NULL, /* SIOCSIWMODE */ + (iw_handler) NULL, /* SIOCGIWMODE */ + (iw_handler) NULL, /* SIOCSIWSENS */ + (iw_handler) NULL, /* SIOCGIWSENS */ + (iw_handler) NULL, /* SIOCSIWRANGE */ + (iw_handler) iwctl_giwrange, /* SIOCGIWRANGE */ + (iw_handler) NULL, /* SIOCSIWPRIV */ + (iw_handler) NULL, /* SIOCGIWPRIV */ + (iw_handler) NULL, /* SIOCSIWSTATS */ + (iw_handler) NULL, /* SIOCGIWSTATS */ + (iw_handler) NULL, /* SIOCSIWSPY */ + (iw_handler) NULL, /* SIOCGIWSPY */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* SIOCSIWAP */ + (iw_handler) NULL, /* SIOCGIWAP */ + (iw_handler) NULL, /* -- hole -- 0x16 */ + (iw_handler) NULL, /* SIOCGIWAPLIST */ + (iw_handler) iwctl_siwscan, /* SIOCSIWSCAN */ + (iw_handler) iwctl_giwscan, /* SIOCGIWSCAN */ + (iw_handler) NULL, /* SIOCSIWESSID */ + (iw_handler) NULL, /* SIOCGIWESSID */ + (iw_handler) NULL, /* SIOCSIWNICKN */ + (iw_handler) NULL, /* SIOCGIWNICKN */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* SIOCSIWRATE 0x20 */ + (iw_handler) NULL, /* SIOCGIWRATE */ + (iw_handler) NULL, /* SIOCSIWRTS */ + (iw_handler) NULL, /* SIOCGIWRTS */ + (iw_handler) NULL, /* SIOCSIWFRAG */ + (iw_handler) NULL, /* SIOCGIWFRAG */ + (iw_handler) NULL, /* SIOCSIWTXPOW */ + (iw_handler) NULL, /* SIOCGIWTXPOW */ + (iw_handler) NULL, /* SIOCSIWRETRY */ + (iw_handler) NULL, /* SIOCGIWRETRY */ + (iw_handler) NULL, /* SIOCSIWENCODE */ + (iw_handler) NULL, /* SIOCGIWENCODE */ + (iw_handler) NULL, /* SIOCSIWPOWER */ + (iw_handler) NULL, /* SIOCGIWPOWER */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* SIOCSIWGENIE */ + (iw_handler) NULL, /* SIOCGIWGENIE */ + (iw_handler) NULL, /* SIOCSIWAUTH */ + (iw_handler) NULL, /* SIOCGIWAUTH */ + (iw_handler) NULL, /* SIOCSIWENCODEEXT */ + (iw_handler) NULL, /* SIOCGIWENCODEEXT */ + (iw_handler) NULL, /* SIOCSIWPMKSA */ + (iw_handler) NULL, /* -- hole -- */ }; static const iw_handler iwctl_private_handler[] = { - NULL, // SIOCIWFIRSTPRIV + NULL, /* SIOCIWFIRSTPRIV */ }; struct iw_priv_args iwctl_private_args[] = { -- cgit v1.2.3-59-g8ed1b From 8a43572c32ffbfe122c38873e29e98ef7ace1709 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 25 Oct 2014 23:33:06 +0200 Subject: staging: dgnc: dgnc_kcompat.h: remove unused macros This patch removes the macros PARM_STR and PARM_ULONG given that they are not used anywhere in the driver files. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_kcompat.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_kcompat.h b/drivers/staging/dgnc/dgnc_kcompat.h index eaec7e6a28e1..4a347e54fe7f 100644 --- a/drivers/staging/dgnc/dgnc_kcompat.h +++ b/drivers/staging/dgnc/dgnc_kcompat.h @@ -42,23 +42,10 @@ # define __chk_user_ptr(x) (void)0 # endif - -# define PARM_STR(VAR, INIT, PERM, DESC) \ - static char *VAR = INIT; \ - char *dgnc_##VAR; \ - module_param(VAR, charp, PERM); \ - MODULE_PARM_DESC(VAR, DESC); - # define PARM_INT(VAR, INIT, PERM, DESC) \ static int VAR = INIT; \ int dgnc_##VAR; \ module_param(VAR, int, PERM); \ MODULE_PARM_DESC(VAR, DESC); -# define PARM_ULONG(VAR, INIT, PERM, DESC) \ - static ulong VAR = INIT; \ - ulong dgnc_##VAR; \ - module_param(VAR, long, PERM); \ - MODULE_PARM_DESC(VAR, DESC); - #endif /* ! __DGNC_KCOMPAT_H */ -- cgit v1.2.3-59-g8ed1b From 6db43a9c388061060dfab0146d4f4e1cc990ecf8 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 25 Oct 2014 23:40:15 +0200 Subject: staging: dgnc: dgnc_driver: remove all occurences of trcbuf_size This patch removes the variable trcbuf_size given there is no real use for it anymore. All of the debug variables in this driver is basically dead code. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 2 -- drivers/staging/dgnc/dgnc_driver.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 0eafd1f35a82..62843d6f8d05 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -57,7 +57,6 @@ MODULE_SUPPORTED_DEVICE("dgnc"); */ PARM_INT(debug, 0x00, 0644, "Driver debugging level"); PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input"); -PARM_INT(trcbuf_size, 0x100000, 0644, "Debugging trace buffer size."); /************************************************************************** * @@ -743,7 +742,6 @@ static void dgnc_init_globals(void) int i = 0; dgnc_rawreadok = rawreadok; - dgnc_trcbuf_size = trcbuf_size; dgnc_debug = debug; dgnc_NumBoards = 0; diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 695c3c6d3233..f1b15645a82f 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -431,7 +431,6 @@ extern uint dgnc_Major; /* Our driver/mgmt major */ extern int dgnc_debug; /* Debug variable */ extern int dgnc_rawreadok; /* Set if user wants rawreads */ extern int dgnc_poll_tick; /* Poll interval - 20 ms */ -extern int dgnc_trcbuf_size; /* Size of the ringbuffer */ extern spinlock_t dgnc_global_lock; /* Driver global spinlock */ extern uint dgnc_NumBoards; /* Total number of boards */ extern struct dgnc_board *dgnc_Board[MAXBOARDS]; /* Array of board structs */ -- cgit v1.2.3-59-g8ed1b From ade5b9435bd6038f552dd25f7529103a7c7af5ff Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 25 Oct 2014 23:43:33 +0200 Subject: staging: dgnc: remove unused variable named rawreadok This patch removes the variable rawreadok since it is only intialized but not used in any of the driver functions. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 2 -- drivers/staging/dgnc/dgnc_driver.h | 1 - drivers/staging/dgnc/dgnc_sysfs.c | 19 ------------------- 3 files changed, 22 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 62843d6f8d05..bf8632841c2e 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -56,7 +56,6 @@ MODULE_SUPPORTED_DEVICE("dgnc"); * us to specify the variable type, name, initial value, and description. */ PARM_INT(debug, 0x00, 0644, "Driver debugging level"); -PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input"); /************************************************************************** * @@ -741,7 +740,6 @@ static void dgnc_init_globals(void) { int i = 0; - dgnc_rawreadok = rawreadok; dgnc_debug = debug; dgnc_NumBoards = 0; diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index f1b15645a82f..e67b913224ec 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -429,7 +429,6 @@ struct channel_t { */ extern uint dgnc_Major; /* Our driver/mgmt major */ extern int dgnc_debug; /* Debug variable */ -extern int dgnc_rawreadok; /* Set if user wants rawreads */ extern int dgnc_poll_tick; /* Poll interval - 20 ms */ extern spinlock_t dgnc_global_lock; /* Driver global spinlock */ extern uint dgnc_NumBoards; /* Total number of boards */ diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 6c3b387622e9..ba0d8ac2d32a 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -80,23 +80,6 @@ static ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *bu static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgnc_driver_debug_show, dgnc_driver_debug_store); -static ssize_t dgnc_driver_rawreadok_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_rawreadok); -} - -static ssize_t dgnc_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count) -{ - int ret; - - ret = sscanf(buf, "0x%x\n", &dgnc_rawreadok); - if (ret != 1) - return -EINVAL; - return count; -} -static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgnc_driver_rawreadok_show, dgnc_driver_rawreadok_store); - - static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) { return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick); @@ -123,7 +106,6 @@ void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_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_pollrate); if (rc) printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n"); @@ -138,7 +120,6 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) 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); } -- cgit v1.2.3-59-g8ed1b From 2a71a3c7c7c1add1ecbfba4ef77c28ef234e82b4 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 25 Oct 2014 23:46:03 +0200 Subject: staging: dgnc: remove debug symbols This patch removes all of the debug symbols and the variable dgnc_debug since they are not used anywhere in the code. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 9 --------- drivers/staging/dgnc/dgnc_driver.h | 32 +------------------------------- drivers/staging/dgnc/dgnc_sysfs.c | 18 ------------------ 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index bf8632841c2e..ba98ff348112 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -49,14 +49,6 @@ MODULE_AUTHOR("Digi International, http://www.digi.com"); MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line"); MODULE_SUPPORTED_DEVICE("dgnc"); -/* - * insmod command line overrideable parameters - * - * NOTE: we use a set of macros to create the variables, which allows - * us to specify the variable type, name, initial value, and description. - */ -PARM_INT(debug, 0x00, 0644, "Driver debugging level"); - /************************************************************************** * * protos for this file @@ -740,7 +732,6 @@ static void dgnc_init_globals(void) { int i = 0; - dgnc_debug = debug; dgnc_NumBoards = 0; for (i = 0; i < MAXBOARDS; i++) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index e67b913224ec..a8157eba28da 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -42,42 +42,13 @@ * *************************************************************************/ -/* Driver identification, error and debugging statments */ +/* Driver identification and error statments */ #define PROCSTR "dgnc" /* /proc entries */ #define DEVSTR "/dev/dg/dgnc" /* /dev entries */ #define DRVSTR "dgnc" /* Driver name string */ #define TRC_TO_CONSOLE 1 -/* - * Debugging levels can be set using debug insmod variable - * They can also be compiled out completely. - */ - -#define DBG_INIT (dgnc_debug & 0x01) -#define DBG_BASIC (dgnc_debug & 0x02) -#define DBG_CORE (dgnc_debug & 0x04) - -#define DBG_OPEN (dgnc_debug & 0x08) -#define DBG_CLOSE (dgnc_debug & 0x10) -#define DBG_READ (dgnc_debug & 0x20) -#define DBG_WRITE (dgnc_debug & 0x40) - -#define DBG_IOCTL (dgnc_debug & 0x80) - -#define DBG_PROC (dgnc_debug & 0x100) -#define DBG_PARAM (dgnc_debug & 0x200) -#define DBG_PSCAN (dgnc_debug & 0x400) -#define DBG_EVENT (dgnc_debug & 0x800) - -#define DBG_DRAIN (dgnc_debug & 0x1000) -#define DBG_MSIGS (dgnc_debug & 0x2000) - -#define DBG_MGMT (dgnc_debug & 0x4000) -#define DBG_INTR (dgnc_debug & 0x8000) - -#define DBG_CARR (dgnc_debug & 0x10000) - /* Number of boards we support at once. */ #define MAXBOARDS 20 #define MAXPORTS 8 @@ -428,7 +399,6 @@ struct channel_t { * Our Global Variables. */ extern uint dgnc_Major; /* Our driver/mgmt major */ -extern int dgnc_debug; /* Debug variable */ extern int dgnc_poll_tick; /* Poll interval - 20 ms */ extern spinlock_t dgnc_global_lock; /* Driver global spinlock */ extern uint dgnc_NumBoards; /* Total number of boards */ diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index ba0d8ac2d32a..2fd34ca70c59 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -63,22 +63,6 @@ static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf) } static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL); -static ssize_t dgnc_driver_debug_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_debug); -} - -static ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count) -{ - int ret; - - ret = sscanf(buf, "0x%x\n", &dgnc_debug); - if (ret != 1) - return -EINVAL; - return count; -} -static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgnc_driver_debug_show, dgnc_driver_debug_store); - static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) { @@ -105,7 +89,6 @@ void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_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_pollrate); if (rc) printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n"); @@ -119,7 +102,6 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_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_pollrate); } -- cgit v1.2.3-59-g8ed1b From ac611dc60fc0cc050344861668f916c191f4b6cd Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 25 Oct 2014 23:47:57 +0200 Subject: staging: dgnc: dgnc_kcompat.h: remove unused macro This patch removes the macro PARM_INT after removing all the variables that depended on it. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_kcompat.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_kcompat.h b/drivers/staging/dgnc/dgnc_kcompat.h index 4a347e54fe7f..566cad0d33e7 100644 --- a/drivers/staging/dgnc/dgnc_kcompat.h +++ b/drivers/staging/dgnc/dgnc_kcompat.h @@ -42,10 +42,5 @@ # define __chk_user_ptr(x) (void)0 # endif -# define PARM_INT(VAR, INIT, PERM, DESC) \ - static int VAR = INIT; \ - int dgnc_##VAR; \ - module_param(VAR, int, PERM); \ - MODULE_PARM_DESC(VAR, DESC); #endif /* ! __DGNC_KCOMPAT_H */ -- cgit v1.2.3-59-g8ed1b From 353fdf17060b15d1d857899cd3ed9d5db4818acf Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sun, 26 Oct 2014 19:20:16 +0530 Subject: staging: android: Replace timeval with timespec64 'timeval' is used to print timestamps in seconds and millisecond. 32-bit systems using 'struct timeval' will break in the year 2038, So we have to replace that code with more appropriate types. This patch changes the android driver to use timespec64. Since this is a staging driver and the output is only used for a debugfs file, it is fine to slightly change the output and use nanoseconds instead. ktime_to_timespec64, is used which will return seconds and nanoseconds. Signed-off-by: Tapasweni Pathak Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 257fc91bf02b..1532a86404be 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "sync.h" #ifdef CONFIG_DEBUG_FS @@ -95,9 +96,9 @@ static void sync_print_pt(struct seq_file *s, struct sync_pt *pt, bool fence) sync_status_str(status)); if (status <= 0) { - struct timeval tv = ktime_to_timeval(pt->base.timestamp); + struct timespec64 ts64 = ktime_to_timespec64(pt->base.timestamp); - seq_printf(s, "@%ld.%06ld", tv.tv_sec, tv.tv_usec); + seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); } if (parent->ops->timeline_value_str && -- cgit v1.2.3-59-g8ed1b From 43f61da20769923f951ded489b3b2de2e5dc0e3f Mon Sep 17 00:00:00 2001 From: Melike Yurtoglu Date: Sun, 26 Oct 2014 23:55:22 +0200 Subject: staging: ozwpan: Fix incorrect type in assignments This patch fixes following sparse warnings: drivers/staging/ozwpan/ozhcd.c:1917:35: warning: incorrect type in assignment (different base types) drivers/staging/ozwpan/ozhcd.c:1917:35: expected restricted __le16 [usertype] wHubCharacteristics drivers/staging/ozwpan/ozhcd.c:1917:35: got unsigned short [unsigned] [usertype] Signed-off-by: Melike Yurtoglu Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 8a52feb6e72e..3d03e9255831 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1914,7 +1914,7 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd, memset(desc, 0, sizeof(*desc)); desc->bDescriptorType = 0x29; desc->bDescLength = 9; - desc->wHubCharacteristics = (__force __u16)cpu_to_le16(0x0001); + desc->wHubCharacteristics = cpu_to_le16(0x0001); desc->bNbrPorts = OZ_NB_PORTS; } -- cgit v1.2.3-59-g8ed1b From ac2f46c365e655dd2c366f69c609febc4ac310fd Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sun, 26 Oct 2014 20:38:32 +0530 Subject: staging: dgap: Use unsigned for loop index The following semantic patch is used to do this @r exists@ // find anything that might decrement the variable identifier i; expression E; position p; @@ int i@p; ... ( &i | i-- | --i | i-=E | i+=E ) @x disable decl_init@ identifier r.i; expression E; position p1 != r.p; @@ ( volatile int i = 0; | volatile int i; | + unsigned int i@p1 = 0; | + unsigned int i@p1; ) <... when != i = E ( i = 0 | i = 1 ) ...> Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ad8c8ecaaf06..dfdf20969987 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -656,7 +656,7 @@ static void dgap_remove_one(struct pci_dev *dev) */ static void dgap_cleanup_module(void) { - int i; + unsigned int i; ulong lock_flags; spin_lock_irqsave(&dgap_poll_lock, lock_flags); @@ -691,7 +691,7 @@ static void dgap_cleanup_module(void) */ static void dgap_cleanup_board(struct board_t *brd) { - int i; + unsigned int i; if (!brd || brd->magic != DGAP_BOARD_MAGIC) return; @@ -1063,7 +1063,7 @@ static void dgap_unmap(struct board_t *brd) static void dgap_poll_handler(ulong dummy) { - int i; + unsigned int i; struct board_t *brd; unsigned long lock_flags; ulong new_time; @@ -1196,7 +1196,7 @@ static irqreturn_t dgap_intr(int irq, void *voidbrd) */ static void dgap_init_globals(void) { - int i; + unsigned int i; for (i = 0; i < MAXBOARDS; i++) dgap_board[i] = NULL; @@ -1515,7 +1515,7 @@ static void dgap_tty_free(struct board_t *brd) static void dgap_cleanup_tty(struct board_t *brd) { struct device *dev; - int i; + unsigned int i; dgap_boards_by_major[brd->serial_driver->major] = NULL; brd->dgap_serial_major = 0; @@ -4121,7 +4121,7 @@ static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) { u8 __iomem *addr; uint offset; - int i; + unsigned int i; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) return; @@ -4217,7 +4217,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) u8 string[100]; u8 __iomem *config; u8 *xconfig; - int i = 0; + unsigned int i = 0; xconfig = dgap_create_config_string(brd, string); @@ -4293,7 +4293,7 @@ static void dgap_do_reset_board(struct board_t *brd) u8 check; u32 check1; u32 check2; - int i; + unsigned int i; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase || !brd->re_map_port) @@ -5630,7 +5630,7 @@ static ssize_t dgap_ports_state_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5651,7 +5651,7 @@ static ssize_t dgap_ports_baud_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5672,7 +5672,7 @@ static ssize_t dgap_ports_msignals_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5709,7 +5709,7 @@ static ssize_t dgap_ports_iflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5729,7 +5729,7 @@ static ssize_t dgap_ports_cflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5749,7 +5749,7 @@ static ssize_t dgap_ports_oflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5769,7 +5769,7 @@ static ssize_t dgap_ports_lflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5789,7 +5789,7 @@ static ssize_t dgap_ports_digi_flag_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5809,7 +5809,7 @@ static ssize_t dgap_ports_rxcount_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) @@ -5829,7 +5829,7 @@ static ssize_t dgap_ports_txcount_show(struct device *p, { struct board_t *bd; int count = 0; - int i; + unsigned int i; bd = dgap_verify_board(p); if (!bd) -- cgit v1.2.3-59-g8ed1b From 6b9214b793a4ae2350f748a587a61a267bfd119b Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Mon, 27 Oct 2014 19:58:20 +0530 Subject: Staging: comedi: nio_tiocmd: fixed a brace coding style issue. Removed unnecessary braces using checkpatch.pl tool Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 46cf3eb2ee54..6037bec77ef1 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -449,11 +449,10 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, return; } gpct_mite_status = mite_get_status(counter->mite_chan); - if (gpct_mite_status & CHSR_LINKC) { + if (gpct_mite_status & CHSR_LINKC) writel(CHOR_CLRLC, counter->mite_chan->mite->mite_io_addr + MITE_CHOR(counter->mite_chan->channel)); - } mite_sync_input_dma(counter->mite_chan, s); spin_unlock_irqrestore(&counter->lock, flags); } -- cgit v1.2.3-59-g8ed1b From 346b0d4a0818fa76bfe0dbe67c6c7ad3e19845e1 Mon Sep 17 00:00:00 2001 From: Ebru Akagunduz Date: Tue, 28 Oct 2014 10:46:35 +0200 Subject: staging: ft1000: Remove curly braces for single statement blocks This patch removes curly braces for single statement blocks using following coccinelle script: @@ expression e1; @@ - if (e1) { + if (e1) return ...; - } Signed-off-by: Ebru Akagunduz Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 5899c4eca41f..4672c4d56205 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -540,17 +540,14 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/ - if (ft1000_flarion_cnt == 0) { + if (ft1000_flarion_cnt == 0) return -EBADF; - } - if (ft1000dev->DrvMsgPend) { + if (ft1000dev->DrvMsgPend) return -ENOTTY; - } - if (ft1000dev->fProvComplete == 0) { + if (ft1000dev->fProvComplete == 0) return -EACCES; - } ft1000dev->fAppMsgPend = 1; @@ -677,9 +674,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ - if (ft1000_flarion_cnt == 0) { + if (ft1000_flarion_cnt == 0) return -EBADF; - } /* Search for matching file object */ for (i=0; i Date: Sun, 26 Oct 2014 19:59:43 +0200 Subject: staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_* This patch removes the custom printk macros dprintk, zilog_notify, zilog_error, and zilog_info. All the calls to these macros were replaced by dev_dbg, dev_notice, dev_err, and dev_info respectively whenever possible. There were cases in which pr_debug, pr_notice, pr_err and pr_info were used. It was when the calling function did not provide an appropiate dev variable. Applying this patch will trigger the out of memory checkpatch warning for two lines. It will be fixed in a separate patch. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_zilog.c | 139 ++++++++++++++++---------------- 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index 567feba0011c..11a7cb128d9e 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c @@ -152,23 +152,12 @@ struct tx_data_struct { static struct tx_data_struct *tx_data; static struct mutex tx_data_lock; -#define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \ - ## args) -#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) -#define zilog_info(s, args...) printk(KERN_INFO KBUILD_MODNAME ": " s, ## args) /* module parameters */ static bool debug; /* debug output */ static bool tx_only; /* only handle the IR Tx function */ static int minor = -1; /* minor number */ -#define dprintk(fmt, args...) \ - do { \ - if (debug) \ - printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \ - ## args); \ - } while (0) - /* struct IR reference counting */ static struct IR *get_ir_device(struct IR *ir, bool ir_devices_lock_held) @@ -333,7 +322,7 @@ static int add_to_buf(struct IR *ir) struct IR_tx *tx; if (lirc_buffer_full(rbuf)) { - dprintk("buffer overflow\n"); + dev_dbg(ir->l.dev, "buffer overflow\n"); return -EOVERFLOW; } @@ -379,16 +368,17 @@ static int add_to_buf(struct IR *ir) */ ret = i2c_master_send(rx->c, sendbuf, 1); if (ret != 1) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(ir->l.dev, "i2c_master_send failed with %d\n", + ret); if (failures >= 3) { mutex_unlock(&ir->ir_lock); - zilog_error("unable to read from the IR chip " + dev_err(ir->l.dev, "unable to read from the IR chip " "after 3 resets, giving up\n"); break; } /* Looks like the chip crashed, reset it */ - zilog_error("polling the IR receiver chip failed, " + dev_err(ir->l.dev, "polling the IR receiver chip failed, " "trying reset\n"); set_current_state(TASK_UNINTERRUPTIBLE); @@ -415,13 +405,14 @@ static int add_to_buf(struct IR *ir) ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf)); mutex_unlock(&ir->ir_lock); if (ret != sizeof(keybuf)) { - zilog_error("i2c_master_recv failed with %d -- " + dev_err(ir->l.dev, "i2c_master_recv failed with %d -- " "keeping last read buffer\n", ret); } else { rx->b[0] = keybuf[3]; rx->b[1] = keybuf[4]; rx->b[2] = keybuf[5]; - dprintk("key (0x%02x/0x%02x)\n", rx->b[0], rx->b[1]); + dev_dbg(ir->l.dev, "key (0x%02x/0x%02x)\n", + rx->b[0], rx->b[1]); } /* key pressed ? */ @@ -472,7 +463,7 @@ static int lirc_thread(void *arg) struct IR *ir = arg; struct lirc_buffer *rbuf = ir->l.rbuf; - dprintk("poll thread started\n"); + dev_dbg(ir->l.dev, "poll thread started\n"); while (!kthread_should_stop()) { set_current_state(TASK_INTERRUPTIBLE); @@ -500,7 +491,7 @@ static int lirc_thread(void *arg) wake_up_interruptible(&rbuf->wait_poll); } - dprintk("poll thread ended\n"); + dev_dbg(ir->l.dev, "poll thread ended\n"); return 0; } @@ -644,7 +635,7 @@ static int get_key_data(unsigned char *buf, return -EPROTO; corrupt: - zilog_error("firmware is corrupt\n"); + pr_err("firmware is corrupt\n"); return -EFAULT; } @@ -662,10 +653,11 @@ static int send_data_block(struct IR_tx *tx, unsigned char *data_block) buf[0] = (unsigned char)(i + 1); for (j = 0; j < tosend; ++j) buf[1 + j] = data_block[i + j]; - dprintk("%*ph", 5, buf); + dev_dbg(tx->ir->l.dev, "%*ph", 5, buf); ret = i2c_master_send(tx->c, buf, tosend + 1); if (ret != tosend + 1) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", + ret); return ret < 0 ? ret : -EFAULT; } i += tosend; @@ -689,7 +681,7 @@ static int send_boot_data(struct IR_tx *tx) buf[1] = 0x20; ret = i2c_master_send(tx->c, buf, 2); if (ret != 2) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } @@ -706,21 +698,22 @@ static int send_boot_data(struct IR_tx *tx) } if (ret != 1) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } /* Here comes the firmware version... (hopefully) */ ret = i2c_master_recv(tx->c, buf, 4); if (ret != 4) { - zilog_error("i2c_master_recv failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_recv failed with %d\n", ret); return 0; } if ((buf[0] != 0x80) && (buf[0] != 0xa0)) { - zilog_error("unexpected IR TX init response: %02x\n", buf[0]); + dev_err(tx->ir->l.dev, "unexpected IR TX init response: %02x\n", + buf[0]); return 0; } - zilog_notify("Zilog/Hauppauge IR blaster firmware version " + dev_notice(tx->ir->l.dev, "Zilog/Hauppauge IR blaster firmware version " "%d.%d.%d loaded\n", buf[1], buf[2], buf[3]); return 0; @@ -738,7 +731,7 @@ static void fw_unload_locked(void) vfree(tx_data); tx_data = NULL; - dprintk("successfully unloaded IR blaster firmware\n"); + pr_debug("successfully unloaded IR blaster firmware\n"); } } @@ -768,17 +761,17 @@ static int fw_load(struct IR_tx *tx) /* Request codeset data file */ ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", tx->ir->l.dev); if (ret != 0) { - zilog_error("firmware haup-ir-blaster.bin not available (%d)\n", + dev_err(tx->ir->l.dev, "firmware haup-ir-blaster.bin not available (%d)\n", ret); ret = ret < 0 ? ret : -EFAULT; goto out; } - dprintk("firmware of size %zu loaded\n", fw_entry->size); + dev_dbg(tx->ir->l.dev, "firmware of size %zu loaded\n", fw_entry->size); /* Parse the file */ tx_data = vmalloc(sizeof(*tx_data)); if (tx_data == NULL) { - zilog_error("out of memory\n"); + dev_err(tx->ir->l.dev, "out of memory\n"); release_firmware(fw_entry); ret = -ENOMEM; goto out; @@ -788,7 +781,7 @@ static int fw_load(struct IR_tx *tx) /* Copy the data so hotplug doesn't get confused and timeout */ tx_data->datap = vmalloc(fw_entry->size); if (tx_data->datap == NULL) { - zilog_error("out of memory\n"); + dev_err(tx->ir->l.dev, "out of memory\n"); release_firmware(fw_entry); vfree(tx_data); ret = -ENOMEM; @@ -803,7 +796,7 @@ static int fw_load(struct IR_tx *tx) if (!read_uint8(&data, tx_data->endp, &version)) goto corrupt; if (version != 1) { - zilog_error("unsupported code set file version (%u, expected" + dev_err(tx->ir->l.dev, "unsupported code set file version (%u, expected" "1) -- please upgrade to a newer driver", version); fw_unload_locked(); @@ -820,7 +813,8 @@ static int fw_load(struct IR_tx *tx) &tx_data->num_code_sets)) goto corrupt; - dprintk("%u IR blaster codesets loaded\n", tx_data->num_code_sets); + dev_dbg(tx->ir->l.dev, "%u IR blaster codesets loaded\n", + tx_data->num_code_sets); tx_data->code_sets = vmalloc( tx_data->num_code_sets * sizeof(char *)); @@ -884,7 +878,7 @@ static int fw_load(struct IR_tx *tx) goto out; corrupt: - zilog_error("firmware is corrupt\n"); + dev_err(tx->ir->l.dev, "firmware is corrupt\n"); fw_unload_locked(); ret = -EFAULT; @@ -904,9 +898,9 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n, unsigned int m; DECLARE_WAITQUEUE(wait, current); - dprintk("read called\n"); + dev_dbg(ir->l.dev, "read called\n"); if (n % rbuf->chunk_size) { - dprintk("read result = -EINVAL\n"); + dev_dbg(ir->l.dev, "read result = -EINVAL\n"); return -EINVAL; } @@ -950,7 +944,7 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n, unsigned char buf[MAX_XFER_SIZE]; if (rbuf->chunk_size > sizeof(buf)) { - zilog_error("chunk_size is too big (%d)!\n", + dev_err(ir->l.dev, "chunk_size is too big (%d)!\n", rbuf->chunk_size); ret = -EINVAL; break; @@ -964,7 +958,7 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n, retries++; } if (retries >= 5) { - zilog_error("Buffer read failed!\n"); + dev_err(ir->l.dev, "Buffer read failed!\n"); ret = -EIO; } } @@ -974,7 +968,8 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n, put_ir_rx(rx, false); set_current_state(TASK_RUNNING); - dprintk("read result = %d (%s)\n", ret, ret ? "Error" : "OK"); + dev_dbg(ir->l.dev, "read result = %d (%s)\n", + ret, ret ? "Error" : "OK"); return ret ? ret : written; } @@ -990,7 +985,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) ret = get_key_data(data_block, code, key); if (ret == -EPROTO) { - zilog_error("failed to get data for code %u, key %u -- check " + dev_err(tx->ir->l.dev, "failed to get data for code %u, key %u -- check " "lircd.conf entries\n", code, key); return ret; } else if (ret != 0) @@ -1006,7 +1001,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) buf[1] = 0x40; ret = i2c_master_send(tx->c, buf, 2); if (ret != 2) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } @@ -1019,18 +1014,18 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) } if (ret != 1) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } /* Send finished download? */ ret = i2c_master_recv(tx->c, buf, 1); if (ret != 1) { - zilog_error("i2c_master_recv failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_recv failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } if (buf[0] != 0xA0) { - zilog_error("unexpected IR TX response #1: %02x\n", + dev_err(tx->ir->l.dev, "unexpected IR TX response #1: %02x\n", buf[0]); return -EFAULT; } @@ -1040,7 +1035,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) buf[1] = 0x80; ret = i2c_master_send(tx->c, buf, 2); if (ret != 2) { - zilog_error("i2c_master_send failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_send failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } @@ -1050,7 +1045,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) * going to skip this whole mess and say we're done on the HD PVR */ if (!tx->post_tx_ready_poll) { - dprintk("sent code %u, key %u\n", code, key); + dev_dbg(tx->ir->l.dev, "sent code %u, key %u\n", code, key); return 0; } @@ -1066,11 +1061,11 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) ret = i2c_master_send(tx->c, buf, 1); if (ret == 1) break; - dprintk("NAK expected: i2c_master_send " + dev_dbg(tx->ir->l.dev, "NAK expected: i2c_master_send " "failed with %d (try %d)\n", ret, i+1); } if (ret != 1) { - zilog_error("IR TX chip never got ready: last i2c_master_send " + dev_err(tx->ir->l.dev, "IR TX chip never got ready: last i2c_master_send " "failed with %d\n", ret); return ret < 0 ? ret : -EFAULT; } @@ -1078,16 +1073,17 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) /* Seems to be an 'ok' response */ i = i2c_master_recv(tx->c, buf, 1); if (i != 1) { - zilog_error("i2c_master_recv failed with %d\n", ret); + dev_err(tx->ir->l.dev, "i2c_master_recv failed with %d\n", ret); return -EFAULT; } if (buf[0] != 0x80) { - zilog_error("unexpected IR TX response #2: %02x\n", buf[0]); + dev_err(tx->ir->l.dev, "unexpected IR TX response #2: %02x\n", + buf[0]); return -EFAULT; } /* Oh good, it worked */ - dprintk("sent code %u, key %u\n", code, key); + dev_dbg(tx->ir->l.dev, "sent code %u, key %u\n", code, key); return 0; } @@ -1173,11 +1169,11 @@ static ssize_t write(struct file *filep, const char __user *buf, size_t n, */ if (ret != 0) { /* Looks like the chip crashed, reset it */ - zilog_error("sending to the IR transmitter chip " + dev_err(tx->ir->l.dev, "sending to the IR transmitter chip " "failed, trying reset\n"); if (failures >= 3) { - zilog_error("unable to send to the IR chip " + dev_err(tx->ir->l.dev, "unable to send to the IR chip " "after 3 resets, giving up\n"); mutex_unlock(&ir->ir_lock); mutex_unlock(&tx->client_lock); @@ -1212,7 +1208,7 @@ static unsigned int poll(struct file *filep, poll_table *wait) struct lirc_buffer *rbuf = ir->l.rbuf; unsigned int ret; - dprintk("poll called\n"); + dev_dbg(ir->l.dev, "poll called\n"); rx = get_ir_rx(ir); if (rx == NULL) { @@ -1220,7 +1216,7 @@ static unsigned int poll(struct file *filep, poll_table *wait) * Revisit this, if our poll function ever reports writeable * status for Tx */ - dprintk("poll result = POLLERR\n"); + dev_dbg(ir->l.dev, "poll result = POLLERR\n"); return POLLERR; } @@ -1233,7 +1229,8 @@ static unsigned int poll(struct file *filep, poll_table *wait) /* Indicate what ops could happen immediately without blocking */ ret = lirc_buffer_empty(rbuf) ? 0 : (POLLIN|POLLRDNORM); - dprintk("poll result = %s\n", ret ? "POLLIN|POLLRDNORM" : "none"); + dev_dbg(ir->l.dev, "poll result = %s\n", + ret ? "POLLIN|POLLRDNORM" : "none"); return ret; } @@ -1340,7 +1337,7 @@ static int close(struct inode *node, struct file *filep) struct IR *ir = filep->private_data; if (ir == NULL) { - zilog_error("close: no private_data attached to the file!\n"); + dev_err(ir->l.dev, "close: no private_data attached to the file!\n"); return -ENODEV; } @@ -1452,7 +1449,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) int ret; bool tx_probe = false; - dprintk("%s: %s on i2c-%d (%s), client addr=0x%02x\n", + pr_debug("%s: %s on i2c-%d (%s), client addr=0x%02x\n", __func__, id->name, adap->nr, adap->name, client->addr); /* @@ -1465,7 +1462,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) else if (tx_only) /* module option */ return -ENXIO; - zilog_info("probing IR %s on %s (i2c-%d)\n", + pr_info("probing IR %s on %s (i2c-%d)\n", tx_probe ? "Tx" : "Rx", adap->name, adap->nr); mutex_lock(&ir_devices_lock); @@ -1547,7 +1544,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) /* Proceed only if the Rx client is also ready or not needed */ if (rx == NULL && !tx_only) { - zilog_info("probe of IR Tx on %s (i2c-%d) done. Waiting" + dev_info(tx->ir->l.dev, "probe of IR Tx on %s (i2c-%d) done. Waiting" " on IR Rx.\n", adap->name, adap->nr); goto out_ok; } @@ -1586,7 +1583,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) "zilog-rx-i2c-%d", adap->nr); if (IS_ERR(rx->task)) { ret = PTR_ERR(rx->task); - zilog_error("%s: could not start IR Rx polling thread" + dev_err(tx->ir->l.dev, "%s: could not start IR Rx polling thread" "\n", __func__); /* Failed kthread, so put back the ir ref */ put_ir_device(ir, true); @@ -1599,7 +1596,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) /* Proceed only if the Tx client is also ready */ if (tx == NULL) { - zilog_info("probe of IR Rx on %s (i2c-%d) done. Waiting" + pr_info("probe of IR Rx on %s (i2c-%d) done. Waiting" " on IR Tx.\n", adap->name, adap->nr); goto out_ok; } @@ -1609,12 +1606,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) ir->l.minor = minor; /* module option: user requested minor number */ ir->l.minor = lirc_register_driver(&ir->l); if (ir->l.minor < 0 || ir->l.minor >= MAX_IRCTL_DEVICES) { - zilog_error("%s: \"minor\" must be between 0 and %d (%d)!\n", + dev_err(tx->ir->l.dev, "%s: \"minor\" must be between 0 and %d (%d)!\n", __func__, MAX_IRCTL_DEVICES-1, ir->l.minor); ret = -EBADRQC; goto out_put_xx; } - zilog_info("IR unit on %s (i2c-%d) registered as lirc%d and ready\n", + dev_info(ir->l.dev, "IR unit on %s (i2c-%d) registered as lirc%d and ready\n", adap->name, adap->nr, ir->l.minor); out_ok: @@ -1623,7 +1620,7 @@ out_ok: if (tx != NULL) put_ir_tx(tx, true); put_ir_device(ir, true); - zilog_info("probe of IR %s on %s (i2c-%d) done\n", + dev_info(ir->l.dev, "probe of IR %s on %s (i2c-%d) done\n", tx_probe ? "Tx" : "Rx", adap->name, adap->nr); mutex_unlock(&ir_devices_lock); return 0; @@ -1636,7 +1633,7 @@ out_put_xx: out_put_ir: put_ir_device(ir, true); out_no_ir: - zilog_error("%s: probing IR %s on %s (i2c-%d) failed with %d\n", + dev_err(ir->l.dev, "%s: probing IR %s on %s (i2c-%d) failed with %d\n", __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr, ret); mutex_unlock(&ir_devices_lock); @@ -1647,7 +1644,7 @@ static int __init zilog_init(void) { int ret; - zilog_notify("Zilog/Hauppauge IR driver initializing\n"); + pr_notice("Zilog/Hauppauge IR driver initializing\n"); mutex_init(&tx_data_lock); @@ -1655,9 +1652,9 @@ static int __init zilog_init(void) ret = i2c_add_driver(&driver); if (ret) - zilog_error("initialization failed\n"); + pr_err("initialization failed\n"); else - zilog_notify("initialization complete\n"); + pr_notice("initialization complete\n"); return ret; } @@ -1667,7 +1664,7 @@ static void __exit zilog_exit(void) i2c_del_driver(&driver); /* if loaded */ fw_unload(); - zilog_notify("Zilog/Hauppauge IR driver unloaded\n"); + pr_notice("Zilog/Hauppauge IR driver unloaded\n"); } module_init(zilog_init); -- cgit v1.2.3-59-g8ed1b From c96bf1d6a49f0b0d38d668195ee34de52693fb87 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sun, 26 Oct 2014 19:46:00 +0200 Subject: staging: media: lirc: lirc_sir.c: use pr_debug and dev_dbg instead of dprintk This patch removes the custom printk macro dprintk and replaces most of the calls made to it by dev_dbg. pr_debug was used when the calling function did not provide the appropiate device variable. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_sir.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_sir.c b/drivers/staging/media/lirc/lirc_sir.c index 2ee55eaf2a53..4af82e6b2d77 100644 --- a/drivers/staging/media/lirc/lirc_sir.c +++ b/drivers/staging/media/lirc/lirc_sir.c @@ -140,12 +140,6 @@ static int rx_buf[RBUF_LEN]; static unsigned int rx_tail, rx_head; static bool debug; -#define dprintk(fmt, args...) \ - do { \ - if (debug) \ - printk(KERN_DEBUG LIRC_DRIVER_NAME ": " \ - fmt, ## args); \ - } while (0) /* SECTION: Prototypes */ @@ -322,7 +316,7 @@ static void add_read_queue(int flag, unsigned long val) unsigned int new_rx_tail; int newval; - dprintk("add flag %d with val %lu\n", flag, val); + pr_debug("add flag %d with val %lu\n", flag, val); newval = val & PULSE_MASK; @@ -342,7 +336,7 @@ static void add_read_queue(int flag, unsigned long val) } new_rx_tail = (rx_tail + 1) & (RBUF_LEN - 1); if (new_rx_tail == rx_head) { - dprintk("Buffer overrun.\n"); + pr_debug("Buffer overrun.\n"); return; } rx_buf[rx_tail] = newval; @@ -439,7 +433,8 @@ static void sir_timeout(unsigned long data) outb(UART_FCR_CLEAR_RCVR, io + UART_FCR); /* determine 'virtual' pulse end: */ pulse_end = delta(&last_tv, &last_intr_tv); - dprintk("timeout add %d for %lu usec\n", last_value, pulse_end); + dev_dbg(driver.dev, "timeout add %d for %lu usec\n", + last_value, pulse_end); add_read_queue(last_value, pulse_end); last_value = 0; last_tv = last_intr_tv; @@ -479,14 +474,15 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id) do_gettimeofday(&curr_tv); deltv = delta(&last_tv, &curr_tv); deltintrtv = delta(&last_intr_tv, &curr_tv); - dprintk("t %lu, d %d\n", deltintrtv, (int)data); + dev_dbg(driver.dev, "t %lu, d %d\n", + deltintrtv, (int)data); /* * if nothing came in last X cycles, * it was gap */ if (deltintrtv > TIME_CONST * threshold) { if (last_value) { - dprintk("GAP\n"); + dev_dbg(driver.dev, "GAP\n"); /* simulate signal change */ add_read_queue(last_value, deltv - -- cgit v1.2.3-59-g8ed1b From 732ba199ab07973dbc8f70903bea54cfbb63d11b Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sun, 26 Oct 2014 19:39:27 +0200 Subject: staging: media: lirc: lirc_imon.c: replace printk by dev_dbg This patch replaces the calls to printk by dev_dbg. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_imon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index e4cfbe34e56d..e3b1fa9fd2f4 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -600,8 +600,8 @@ static void imon_incoming_packet(struct imon_context *context, if (debug) { dev_info(dev, "raw packet: "); for (i = 0; i < len; ++i) - printk("%02x ", buf[i]); - printk("\n"); + dev_dbg(dev, "%02x ", buf[i]); + dev_dbg(dev, "\n"); } /* -- cgit v1.2.3-59-g8ed1b From 72f3f59e734c88f789fca5c60707c78e6533d064 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sun, 26 Oct 2014 19:35:20 +0200 Subject: staging: media: lirc: lirc_bt829.c: replace dprintk by dev_dbg This patch removes the custom printk macro dprintk and replaces all the calls made to it by dev_dbg. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_bt829.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_bt829.c b/drivers/staging/media/lirc/lirc_bt829.c index 4c806ba41323..44f565547179 100644 --- a/drivers/staging/media/lirc/lirc_bt829.c +++ b/drivers/staging/media/lirc/lirc_bt829.c @@ -56,11 +56,6 @@ static unsigned char do_get_bits(void); #define DRIVER_NAME "lirc_bt829" static bool debug; -#define dprintk(fmt, args...) \ - do { \ - if (debug) \ - printk(KERN_DEBUG DRIVER_NAME ": "fmt, ## args); \ - } while (0) static int atir_minor; static phys_addr_t pci_addr_phys; @@ -101,7 +96,7 @@ static int atir_add_to_buf(void *data, struct lirc_buffer *buf) status = poll_main(); key = (status >> 8) & 0xFF; if (status & 0xFF) { - dprintk("reading key %02X\n", key); + dev_dbg(atir_driver.dev, "reading key %02X\n", key); lirc_buffer_write(buf, &key); return 0; } @@ -110,13 +105,13 @@ static int atir_add_to_buf(void *data, struct lirc_buffer *buf) static int atir_set_use_inc(void *data) { - dprintk("driver is opened\n"); + dev_dbg(atir_driver.dev, "driver is opened\n"); return 0; } static void atir_set_use_dec(void *data) { - dprintk("driver is closed\n"); + dev_dbg(atir_driver.dev, "driver is closed\n"); } int init_module(void) @@ -154,7 +149,8 @@ int init_module(void) rc = atir_minor; goto err_unmap; } - dprintk("driver is registered on minor %d\n", atir_minor); + dev_dbg(atir_driver.dev, "driver is registered on minor %d\n", + atir_minor); return 0; -- cgit v1.2.3-59-g8ed1b From ed09b447dd079d2e73f7aa9b00b2cd0e81ba2b21 Mon Sep 17 00:00:00 2001 From: anuvazhayil Date: Wed, 29 Oct 2014 03:43:26 +0530 Subject: Staging: rtl8723au: rtw_cmd: Fix space prohibited between function name and open parenthesis Fixed the checkpatch.pl WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: anuvazhayil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 424d96a1859a..f80e81cd14e6 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -36,25 +36,25 @@ static struct cmd_hdl wlancmds[] = { GEN_MLME_EXT_HANDLER(0, NULL) GEN_MLME_EXT_HANDLER(0, NULL) GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), join_cmd_hdl23a) /*14*/ - GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl23a) - GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), createbss_hdl23a) - GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl23a) - GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), sitesurvey_cmd_hdl23a) /*18*/ - GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl23a) - GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl23a) /*20*/ - GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl23a) - GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL) /*30*/ - GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), join_cmd_hdl23a) /*14*/ + GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl23a) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), createbss_hdl23a) + GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl23a) + GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl23a) /*18*/ + GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl23a) + GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl23a) /*20*/ + GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl23a) + GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct del_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct setstapwrstate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct setbasicrate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct getbasicrate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct setdatarate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct getdatarate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct setphyinfo_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct getphyinfo_parm), NULL) /*30*/ + GEN_MLME_EXT_HANDLER(sizeof(struct setphy_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct getphy_parm), NULL) GEN_MLME_EXT_HANDLER(0, NULL) GEN_MLME_EXT_HANDLER(0, NULL) GEN_MLME_EXT_HANDLER(0, NULL) -- cgit v1.2.3-59-g8ed1b From 1e76bb40f85c543c306562b4e7fcb6209b39c5fa Mon Sep 17 00:00:00 2001 From: anuvazhayil Date: Wed, 29 Oct 2014 03:13:54 +0530 Subject: Staging: lustre: libcfs_cpu: Fix ERROR: do not initialise globals to 0 or NULL Fixed the ERROR: do not initialise globals to 0 or NULL Signed-off-by: anuvazhayil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index dbb81b6cc200..31a558115a96 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -38,7 +38,7 @@ #include "../../include/linux/libcfs/libcfs.h" /** Global CPU partition table */ -struct cfs_cpt_table *cfs_cpt_table __read_mostly = NULL; +struct cfs_cpt_table *cfs_cpt_table __read_mostly; EXPORT_SYMBOL(cfs_cpt_table); #ifndef HAVE_LIBCFS_CPT -- cgit v1.2.3-59-g8ed1b From af3491b3709e9da39c42b8ce9a2cc17ded0926fd Mon Sep 17 00:00:00 2001 From: anuvazhayil Date: Wed, 29 Oct 2014 02:34:56 +0530 Subject: Staging: media: dm365_isif: Add blank line after variable declarations WARNING: Missing a blank line after declarations Signed-off-by: anuvazhayil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/dm365_isif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index f00cd9f23227..fe66d98e28f4 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1602,6 +1602,7 @@ isif_pad_get_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, if (crop->which == V4L2_SUBDEV_FORMAT_TRY) { struct v4l2_rect *rect; + rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK); memcpy(&crop->rect, rect, sizeof(*rect)); } else { -- cgit v1.2.3-59-g8ed1b From c2f5a8d79358851cef76cb0b941d467dadfb5458 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 13 Oct 2014 13:41:20 +0100 Subject: staging: comedi: cb_pcimdas: use preferred block comment style Use the preferred block comment style for the copyright and Comedi driver description header comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdas.c | 71 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index fe4d2544f3dc..804b3c3d6a9d 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -1,40 +1,41 @@ /* - comedi/drivers/cb_pcimdas.c - Comedi driver for Computer Boards PCIM-DAS1602/16 - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. -*/ + * comedi/drivers/cb_pcimdas.c + * Comedi driver for Computer Boards PCIM-DAS1602/16 + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + /* -Driver: cb_pcimdas -Description: Measurement Computing PCI Migration series boards -Devices: [ComputerBoards] PCIM-DAS1602/16 (cb_pcimdas) -Author: Richard Bytheway -Updated: Wed, 13 Nov 2002 12:34:56 +0000 -Status: experimental - -Written to support the PCIM-DAS1602/16 on a 2.4 series kernel. - -Configuration Options: - [0] - PCI bus number - [1] - PCI slot number - -Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org). -Only supports DIO, AO and simple AI in it's present form. -No interrupts, multi channel or FIFO AI, -although the card looks like it could support this. -See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. -*/ + * Driver: cb_pcimdas + * Description: Measurement Computing PCI Migration series boards + * Devices: [ComputerBoards] PCIM-DAS1602/16 (cb_pcimdas) + * Author: Richard Bytheway + * Updated: Wed, 13 Nov 2002 12:34:56 +0000 + * Status: experimental + * + * Written to support the PCIM-DAS1602/16 on a 2.4 series kernel. + * + * Configuration Options: + * [0] - PCI bus number + * [1] - PCI slot number + * + * Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org). + * Only supports DIO, AO and simple AI in it's present form. + * No interrupts, multi channel or FIFO AI, + * although the card looks like it could support this. + * See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. + */ #include #include -- cgit v1.2.3-59-g8ed1b From a3f8c58d6ad69949ba2724b0992b6f2bff94a9a3 Mon Sep 17 00:00:00 2001 From: Bernd Porr Date: Fri, 10 Oct 2014 20:32:42 +0100 Subject: staging: comedi: usbduxsigma: updated contact details and status I've updated my contact details of the driver. I've also tested it thoroughly and it works perfectly. I've changed the status to stable. Signed-off-by: Bernd Porr Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index ebd68e365bac..a869e38c777b 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1,6 +1,6 @@ /* * usbduxsigma.c - * Copyright (C) 2011 Bernd Porr, Bernd.Porr@f2s.com + * Copyright (C) 2011-2014 Bernd Porr, mail@berndporr.me.uk * * 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 @@ -17,9 +17,9 @@ * Driver: usbduxsigma * Description: University of Stirling USB DAQ & INCITE Technology Limited * Devices: (ITL) USB-DUX [usbduxsigma] - * Author: Bernd Porr - * Updated: 8 Nov 2011 - * Status: testing + * Author: Bernd Porr + * Updated: 10 Oct 2014 + * Status: stable */ /* -- cgit v1.2.3-59-g8ed1b From 430c7421694c7508f557bf5a565c5a75c94bfa57 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 13 Oct 2014 13:41:21 +0100 Subject: staging: comedi: cb_pcimdas: update driver comment The Comedi driver comment mentions a couple of manual configuration options, but manual configuration via the COMEDI_DEVCONFIG ioctl and comedi "attach" handler is no longer supported by this driver. Update the comment appropriately. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdas.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 804b3c3d6a9d..433941a9aa36 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -27,8 +27,10 @@ * Written to support the PCIM-DAS1602/16 on a 2.4 series kernel. * * Configuration Options: - * [0] - PCI bus number - * [1] - PCI slot number + * none + * + * Manual configuration of PCI cards is not supported; they are configured + * automatically. * * Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org). * Only supports DIO, AO and simple AI in it's present form. -- cgit v1.2.3-59-g8ed1b From 79f54ac18be5f5cadd7d0c1439491f98ab4c3a47 Mon Sep 17 00:00:00 2001 From: Bernd Porr Date: Fri, 10 Oct 2014 20:34:04 +0100 Subject: staging: comedi: usbdux: updated contact details / comments I've updated my contact details and removed obsolete comments. Signed-off-by: Bernd Porr Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 59 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 5adbfedf780f..89f6ece2f0aa 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1,37 +1,34 @@ /* - comedi/drivers/usbdux.c - Copyright (C) 2003-2007 Bernd Porr, Bernd.Porr@f2s.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + * usbdux.c + * Copyright (C) 2003-2014 Bernd Porr, mail@berndporr.me.uk + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ + /* -Driver: usbdux -Description: University of Stirling USB DAQ & INCITE Technology Limited -Devices: [ITL] USB-DUX (usbdux.o) -Author: Bernd Porr -Updated: 8 Dec 2008 -Status: Stable -Configuration options: - You have to upload firmware with the -i option. The - firmware is usually installed under /usr/share/usb or - /usr/local/share/usb or /lib/firmware. - -Connection scheme for the counter at the digital port: - 0=/CLK0, 1=UP/DOWN0, 2=RESET0, 4=/CLK1, 5=UP/DOWN1, 6=RESET1. - The sampling rate of the counter is approximately 500Hz. - -Please note that under USB2.0 the length of the channel list determines -the max sampling rate. If you sample only one channel you get 8kHz -sampling rate. If you sample two channels you get 4kHz and so on. -*/ + * Driver: usbdux + * Description: University of Stirling USB DAQ & INCITE Technology Limited + * Devices: (ITL) USB-DUX [usbdux] + * Author: Bernd Porr + * Updated: 10 Oct 2014 + * Status: Stable + * Connection scheme for the counter at the digital port: + * 0=/CLK0, 1=UP/DOWN0, 2=RESET0, 4=/CLK1, 5=UP/DOWN1, 6=RESET1. + * The sampling rate of the counter is approximately 500Hz. + * + * Note that under USB2.0 the length of the channel list determines + * the max sampling rate. If you sample only one channel you get 8kHz + * sampling rate. If you sample two channels you get 4kHz and so on. + */ + /* * I must give credit here to Chris Baugher who * wrote the driver for AT-MIO-16d. I used some parts of this -- cgit v1.2.3-59-g8ed1b From 4e3d14af1286886b5a06ee0da5600df8ce320773 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 13 Oct 2014 13:41:22 +0100 Subject: staging: comedi: cb_pcimdas: add support for PCIe-DAS1602/16 The Measurement Computing PCIe-DAS1602/16 is a PCI-Express version of the PCIM-DAS1602/16, but has a different PCI device ID. Add support for this device and update the driver description, Kconfig description and MODULE_DESCRIPTION. Thanks to Christoph Langbein for supplying the PCI device ID. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 4 ++-- drivers/staging/comedi/drivers/cb_pcimdas.c | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index a8bc2b567789..77c5013d81c5 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -939,11 +939,11 @@ config COMEDI_CB_PCIDDA called cb_pcidda. config COMEDI_CB_PCIMDAS - tristate "MeasurementComputing PCIM-DAS1602/16 support" + tristate "MeasurementComputing PCIM-DAS1602/16, PCIe-DAS1602/16 support" select COMEDI_8255 ---help--- Enable support for ComputerBoards/MeasurementComputing PCI Migration - series PCIM-DAS1602/16 + series PCIM-DAS1602/16 and PCIe-DAS1602/16. To compile this driver as a module, choose M here: the module will be called cb_pcimdas. diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 433941a9aa36..73e5c96ff249 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -1,6 +1,6 @@ /* * comedi/drivers/cb_pcimdas.c - * Comedi driver for Computer Boards PCIM-DAS1602/16 + * Comedi driver for Computer Boards PCIM-DAS1602/16 and PCIe-DAS1602/16 * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef @@ -19,24 +19,26 @@ /* * Driver: cb_pcimdas * Description: Measurement Computing PCI Migration series boards - * Devices: [ComputerBoards] PCIM-DAS1602/16 (cb_pcimdas) + * Devices: [ComputerBoards] PCIM-DAS1602/16 (cb_pcimdas), PCIe-DAS1602/16 * Author: Richard Bytheway - * Updated: Wed, 13 Nov 2002 12:34:56 +0000 + * Updated: Mon, 13 Oct 2014 11:57:39 +0000 * Status: experimental * - * Written to support the PCIM-DAS1602/16 on a 2.4 series kernel. + * Written to support the PCIM-DAS1602/16 and PCIe-DAS1602/16. * * Configuration Options: * none * - * Manual configuration of PCI cards is not supported; they are configured + * Manual configuration of PCI(e) cards is not supported; they are configured * automatically. * * Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org). * Only supports DIO, AO and simple AI in it's present form. * No interrupts, multi channel or FIFO AI, * although the card looks like it could support this. - * See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. + * + * http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf + * http://www.mccdaq.com/PDFs/Manuals/pcie-das1602-16.pdf */ #include @@ -48,7 +50,7 @@ #include "plx9052.h" #include "8255.h" -/* Registers for the PCIM-DAS1602/16 */ +/* Registers for the PCIM-DAS1602/16 and PCIe-DAS1602/16 */ /* DAC Offsets */ #define ADC_TRIG 0 @@ -254,7 +256,8 @@ static int cb_pcimdas_pci_probe(struct pci_dev *dev, } static const struct pci_device_id cb_pcimdas_pci_table[] = { - { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0056) }, + { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0056) }, /* PCIM-DAS1602/16 */ + { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0115) }, /* PCIe-DAS1602/16 */ { 0 } }; MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table); @@ -268,5 +271,5 @@ static struct pci_driver cb_pcimdas_pci_driver = { module_comedi_pci_driver(cb_pcimdas_driver, cb_pcimdas_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for PCIM-DAS1602/16 and PCIe-DAS1602/16"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From 533de0f865d727a01a545116fb2447fd60c0bf19 Mon Sep 17 00:00:00 2001 From: Bernd Porr Date: Fri, 10 Oct 2014 20:35:11 +0100 Subject: staging: comedi: usbduxfast: updated address details Updated the range of years, e-mail and added driver desription as usually done in comedi. Signed-off-by: Bernd Porr Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index f85818dd5e11..cddc2ba294bb 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Bernd Porr, Bernd.Porr@f2s.com + * Copyright (C) 2004-2014 Bernd Porr, mail@berndporr.me.uk * * 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 @@ -12,6 +12,15 @@ * GNU General Public License for more details. */ +/* + * Driver: usbduxfast + * Description: University of Stirling USB DAQ & INCITE Technology Limited + * Devices: (ITL) USB-DUX [usbduxfast] + * Author: Bernd Porr + * Updated: 10 Oct 2014 + * Status: stable + */ + /* * I must give credit here to Chris Baugher who * wrote the driver for AT-MIO-16d. I used some parts of this -- cgit v1.2.3-59-g8ed1b From 42170711b7190824a7458b0719353912c9199bfc Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 12 Oct 2014 14:23:24 +0200 Subject: staging: comedi: drivers: comedi_bond.c: Changed from using strncat to strlcat Changed from using strncat to strlcat to simplify the code Signed-off-by: Rickard Strandqvist Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 8450c99af8b0..5d19861fbabc 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -262,12 +262,10 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) { /* Append dev:subdev to devpriv->name */ char buf[20]; - int left = - MAX_BOARD_NAME - strlen(devpriv->name) - 1; snprintf(buf, sizeof(buf), "%u:%u ", bdev->minor, bdev->subdev); - buf[sizeof(buf) - 1] = 0; - strncat(devpriv->name, buf, left); + strlcat(devpriv->name, buf, + sizeof(devpriv->name)); } } -- cgit v1.2.3-59-g8ed1b From bb856b6c041c200910b031b535397e2c805789c5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 13 Oct 2014 09:56:07 -0700 Subject: staging: comedi: comedidev.h: don't expose COMEDI_CB_* defines to userspace The COMEDI_CB_* defines are the comedi_async "events" that the drivers set to let the core detect the state of running async commands. These "events" are only relevant to the kernel modules and should not be exposed to userspace in the comedi.h user API header. Move the defines to comedidev.h to avoid exposing them. For aesthetics, convert the defines to bit shifts to better indicate that they are bitmask values. Cleanup the documentation. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi.h | 11 ----------- drivers/staging/comedi/comedidev.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index c8c99e65423b..f302ce6c93de 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -514,17 +514,6 @@ struct comedi_bufinfo { #define COMEDI_MIN_SPEED ((unsigned int)0xffffffff) -/* callback stuff */ -/* only relevant to kernel modules. */ - -#define COMEDI_CB_EOS 1 /* end of scan */ -#define COMEDI_CB_EOA 2 /* end of acquisition/output */ -#define COMEDI_CB_BLOCK 4 /* data has arrived: - * wakes up read() / write() */ -#define COMEDI_CB_EOBUF 8 /* DEPRECATED: end of buffer */ -#define COMEDI_CB_ERROR 16 /* card error during acquisition */ -#define COMEDI_CB_OVERFLOW 32 /* buffer overflow/underflow */ - /**********************************************************/ /* everything after this line is ALPHA */ /**********************************************************/ diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 1b2bbd56f6ef..0b504b1d3f00 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -213,6 +213,22 @@ struct comedi_async { unsigned int x); }; +/** + * comedi_async callback "events" + * @COMEDI_CB_EOS: end-of-scan + * @COMEDI_CB_EOA: end-of-acquisition/output + * @COMEDI_CB_BLOCK: data has arrived, wakes up read() / write() + * @COMEDI_CB_EOBUF: DEPRECATED: end of buffer + * @COMEDI_CB_ERROR: card error during acquisition + * @COMEDI_CB_OVERFLOW: buffer overflow/underflow + */ +#define COMEDI_CB_EOS (1 << 0) +#define COMEDI_CB_EOA (1 << 1) +#define COMEDI_CB_BLOCK (1 << 2) +#define COMEDI_CB_EOBUF (1 << 3) +#define COMEDI_CB_ERROR (1 << 4) +#define COMEDI_CB_OVERFLOW (1 << 5) + struct comedi_driver { struct comedi_driver *next; -- cgit v1.2.3-59-g8ed1b From 781f933c151ee47e3cc1c8ef5491db23f1b61c9a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 13 Oct 2014 09:56:08 -0700 Subject: staging: comedi: comedidev.h: clarify async->event error/cancel detection Introduce COMEDI_CB_ERROR_MASK and COMEDI_CB_CANCEL_MASK to clarify the async->events that indicate errors and cancel an async command. Use the new defines to tidy up and clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 18 ++++++++---------- drivers/staging/comedi/comedidev.h | 6 ++++++ drivers/staging/comedi/drivers.c | 2 +- drivers/staging/comedi/drivers/amplc_pci230.c | 10 ++-------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 224af2b2a685..2fb0f874f71f 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1555,9 +1555,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, comedi_buf_reset(s); - async->cb_mask = - COMEDI_CB_EOA | COMEDI_CB_BLOCK | COMEDI_CB_ERROR | - COMEDI_CB_OVERFLOW; + async->cb_mask = COMEDI_CB_BLOCK | COMEDI_CB_CANCEL_MASK; if (async->cmd.flags & CMDF_WAKE_EOS) async->cb_mask |= COMEDI_CB_EOS; @@ -2390,14 +2388,14 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) if (!comedi_is_subdevice_running(s)) return; - if (s-> - async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | - COMEDI_CB_OVERFLOW)) { + if (s->async->events & COMEDI_CB_CANCEL_MASK) runflags_mask |= SRF_RUNNING; - } - /* remember if an error event has occurred, so an error - * can be returned the next time the user does a read() */ - if (s->async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) { + + /* + * Remember if an error event has occurred, so an error + * can be returned the next time the user does a read(). + */ + if (s->async->events & COMEDI_CB_ERROR_MASK) { runflags_mask |= SRF_ERROR; runflags |= SRF_ERROR; } diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 0b504b1d3f00..fb8ff84dab35 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -221,6 +221,9 @@ struct comedi_async { * @COMEDI_CB_EOBUF: DEPRECATED: end of buffer * @COMEDI_CB_ERROR: card error during acquisition * @COMEDI_CB_OVERFLOW: buffer overflow/underflow + * + * @COMEDI_CB_ERROR_MASK: events that indicate an error has occurred + * @COMEDI_CB_CANCEL_MASK: events that will cancel an async command */ #define COMEDI_CB_EOS (1 << 0) #define COMEDI_CB_EOA (1 << 1) @@ -229,6 +232,9 @@ struct comedi_async { #define COMEDI_CB_ERROR (1 << 4) #define COMEDI_CB_OVERFLOW (1 << 5) +#define COMEDI_CB_ERROR_MASK (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW) +#define COMEDI_CB_CANCEL_MASK (COMEDI_CB_EOA | COMEDI_CB_ERROR_MASK) + struct comedi_driver { struct comedi_driver *next; diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 859b722188cc..ff2df8587eca 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -375,7 +375,7 @@ unsigned int comedi_handle_events(struct comedi_device *dev, if (events == 0) return events; - if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) + if (events & COMEDI_CB_CANCEL_MASK) s->cancel(dev, s); comedi_event(dev, s); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index a04ce6bd3705..a3b34d881a08 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1119,7 +1119,6 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, unsigned short dacstat; unsigned int i, n; unsigned int events = 0; - bool running; /* Get DAC FIFO status. */ dacstat = inw(devpriv->daqio + PCI230_DACCON); @@ -1201,12 +1200,8 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } } - if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) - running = false; - else - running = true; async->events |= events; - return running; + return !(async->events & COMEDI_CB_CANCEL_MASK); } static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev, @@ -2128,8 +2123,7 @@ static void pci230_handle_ai(struct comedi_device *dev, events |= COMEDI_CB_BLOCK; } async->events |= events; - if (!(async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | - COMEDI_CB_OVERFLOW))) { + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { /* update FIFO interrupt trigger level */ pci230_ai_update_fifo_trigger_level(dev, s); } -- cgit v1.2.3-59-g8ed1b From 8e89ba5b3ddc976f01944eaacd354d91a222b0dc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:11:26 -0700 Subject: staging: comedi: addi_apci_3200: remove driver This driver has some serious bitrot. In addition, it's not in the Kconfig or Makefile so it can't even be built. Just remove it. It would be easier to rewrite the driver than fix it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3200.c | 3002 -------------------- drivers/staging/comedi/drivers/addi_apci_3200.c | 125 - 2 files changed, 3127 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c delete mode 100644 drivers/staging/comedi/drivers/addi_apci_3200.c diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c deleted file mode 100644 index 470b3f0d457f..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ /dev/null @@ -1,3002 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-------------------------------+---------------------------------------+ - | Project : APCI-3200 | Compiler : GCC | - | Module name : hwdrv_apci3200.c| Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-------------------------------+---------------------------------------+ - | Description : Hardware Layer Access For APCI-3200 | - +-----------------------------------------------------------------------+ - | UPDATES | - +----------+-----------+------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | 02.07.04 | J. Krauth | Modification from the driver in order to | - | | | correct some errors when using several boards. | - | | | | - | | | | - +----------+-----------+------------------------------------------------+ - | 26.10.04 | J. Krauth | - Update for COMEDI 0.7.68 | - | | | - Read eeprom value | - | | | - Append APCI-3300 | - +----------+-----------+------------------------------------------------+ -*/ - -/* Card Specific information */ -/* #define APCI3200_ADDRESS_RANGE 264 */ - -/* Analog Input related Defines */ -#define APCI3200_AI_OFFSET_GAIN 0 -#define APCI3200_AI_SC_TEST 4 -#define APCI3200_AI_IRQ 8 -#define APCI3200_AI_AUTOCAL 12 -#define APCI3200_RELOAD_CONV_TIME_VAL 32 -#define APCI3200_CONV_TIME_TIME_BASE 36 -#define APCI3200_RELOAD_DELAY_TIME_VAL 40 -#define APCI3200_DELAY_TIME_TIME_BASE 44 -#define APCI3200_AI_MODULE1 0 -#define APCI3200_AI_MODULE2 64 -#define APCI3200_AI_MODULE3 128 -#define APCI3200_AI_MODULE4 192 -#define TRUE 1 -#define FALSE 0 -#define APCI3200_AI_EOSIRQ 16 -#define APCI3200_AI_EOS 20 -#define APCI3200_AI_CHAN_ID 24 -#define APCI3200_AI_CHAN_VAL 28 -#define ANALOG_INPUT 0 -#define TEMPERATURE 1 -#define RESISTANCE 2 - -#define ENABLE_EXT_TRIG 1 -#define ENABLE_EXT_GATE 2 -#define ENABLE_EXT_TRIG_GATE 3 - -#define APCI3200_MAXVOLT 2.5 -#define ADDIDATA_GREATER_THAN_TEST 0 -#define ADDIDATA_LESS_THAN_TEST 1 - -#define ADDIDATA_UNIPOLAR 1 -#define ADDIDATA_BIPOLAR 2 - -#define MAX_MODULE 4 - -/* ANALOG INPUT RANGE */ -static const struct comedi_lrange range_apci3200_ai = { - 8, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1) - } -}; - -static const struct comedi_lrange range_apci3300_ai = { - 4, { - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1) - } -}; - -int MODULE_NO; -struct { - int i_Gain; - int i_Polarity; - int i_OffsetRange; - int i_Coupling; - int i_SingleDiff; - int i_AutoCalibration; - unsigned int ui_ReloadValue; - unsigned int ui_TimeUnitReloadVal; - int i_Interrupt; - int i_ModuleSelection; -} Config_Parameters_Module1, Config_Parameters_Module2, - Config_Parameters_Module3, Config_Parameters_Module4; - - -struct str_ADDIDATA_RTDStruct { - unsigned int ul_NumberOfValue; - unsigned int *pul_ResistanceValue; - unsigned int *pul_TemperatureValue; -}; - -struct str_Module { - unsigned long ul_CurrentSourceCJC; - unsigned long ul_CurrentSource[5]; - unsigned long ul_GainFactor[8]; /* Gain Factor */ - unsigned int w_GainValue[10]; -}; - -struct str_BoardInfos { - - int i_CJCAvailable; - int i_CJCPolarity; - int i_CJCGain; - int i_InterruptFlag; - int i_ADDIDATAPolarity; - int i_ADDIDATAGain; - int i_AutoCalibration; - int i_ADDIDATAConversionTime; - int i_ADDIDATAConversionTimeUnit; - int i_ADDIDATAType; - int i_ChannelNo; - int i_ChannelCount; - int i_ScanType; - int i_FirstChannel; - int i_LastChannel; - int i_Sum; - int i_Offset; - unsigned int ui_Channel_num; - int i_Count; - int i_Initialised; - unsigned int ui_InterruptChannelValue[144]; /* Buffer */ - unsigned char b_StructInitialized; - /* 7 is the maximal number of channels */ - unsigned int ui_ScanValueArray[7 + 12]; - - int i_ConnectionType; - int i_NbrOfModule; - struct str_Module s_Module[MAX_MODULE]; -}; - -/* BEGIN JK 06.07.04: Management of sevrals boards */ -/* - int i_CJCAvailable=1; - int i_CJCPolarity=0; - int i_CJCGain=2;/* changed from 0 to 2 */ - int i_InterruptFlag=0; - int i_ADDIDATAPolarity; - int i_ADDIDATAGain; - int i_AutoCalibration=0; /* : auto calibration */ - int i_ADDIDATAConversionTime; - int i_ADDIDATAConversionTimeUnit; - int i_ADDIDATAType; - int i_ChannelNo; - int i_ChannelCount=0; - int i_ScanType; - int i_FirstChannel; - int i_LastChannel; - int i_Sum=0; - int i_Offset; - unsigned int ui_Channel_num=0; - static int i_Count=0; - int i_Initialised=0; - unsigned int ui_InterruptChannelValue[96]; /* Buffer */ -*/ -struct str_BoardInfos s_BoardInfos[100]; /* 100 will be the max number of boards to be used */ -/* END JK 06.07.04: Management of sevrals boards */ - -#define AMCC_OP_REG_MCSR 0x3c -#define EEPROM_BUSY 0x80000000 -#define NVCMD_LOAD_LOW (0x4 << 5) /* nvRam load low command */ -#define NVCMD_LOAD_HIGH (0x5 << 5) /* nvRam load high command */ -#define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */ -#define NVCMD_BEGIN_WRITE (0x6 << 5) /* EEPROM begin write command */ - -static int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead, - unsigned int dw_PCIBoardEepromAddress, - unsigned short w_EepromStartAddress, - unsigned short *pw_DataRead) -{ - unsigned int dw_eeprom_busy = 0; - int i_Counter = 0; - int i_WordCounter; - int i; - unsigned char pb_ReadByte[1]; - unsigned char b_ReadLowByte = 0; - unsigned char b_ReadHighByte = 0; - unsigned char b_SelectedAddressLow = 0; - unsigned char b_SelectedAddressHigh = 0; - unsigned short w_ReadWord = 0; - - for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead; - i_WordCounter++) { - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - for (i_Counter = 0; i_Counter < 2; i_Counter++) { - b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; /* Read the low 8 bit part */ - b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; /* Read the high 8 bit part */ - - /* Select the load low address mode */ - outb(NVCMD_LOAD_LOW, - dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + - 3); - - /* Wait on busy */ - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - /* Load the low address */ - outb(b_SelectedAddressLow, - dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + - 2); - - /* Wait on busy */ - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - /* Select the load high address mode */ - outb(NVCMD_LOAD_HIGH, - dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + - 3); - - /* Wait on busy */ - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - /* Load the high address */ - outb(b_SelectedAddressHigh, - dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + - 2); - - /* Wait on busy */ - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - /* Select the READ mode */ - outb(NVCMD_BEGIN_READ, - dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR + - 3); - - /* Wait on busy */ - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - /* Read data into the EEPROM */ - *pb_ReadByte = - inb(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR + 2); - - /* Wait on busy */ - do { - dw_eeprom_busy = - inl(dw_PCIBoardEepromAddress + - AMCC_OP_REG_MCSR); - dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY; - } while (dw_eeprom_busy == EEPROM_BUSY); - - /* Select the upper address part */ - if (i_Counter == 0) - b_ReadLowByte = pb_ReadByte[0]; - else - b_ReadHighByte = pb_ReadByte[0]; - - - /* Sleep */ - msleep(1); - - } - w_ReadWord = - (b_ReadLowByte | (((unsigned short)b_ReadHighByte) * - 256)); - - pw_DataRead[i_WordCounter] = w_ReadWord; - - w_EepromStartAddress += 2; /* to read the next word */ - - } /* for (...) i_NbOfWordsToRead */ - return 0; -} - -static void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress, - struct str_BoardInfos *BoardInformations) -{ - unsigned short w_AnalogInputMainHeaderAddress; - unsigned short w_AnalogInputComponentAddress; - unsigned short w_NumberOfModuls = 0; - unsigned short w_CurrentSources[2]; - unsigned short w_ModulCounter = 0; - unsigned short w_FirstHeaderSize = 0; - unsigned short w_NumberOfInputs = 0; - unsigned short w_CJCFlag = 0; - unsigned short w_NumberOfGainValue = 0; - unsigned short w_SingleHeaderAddress = 0; - unsigned short w_SingleHeaderSize = 0; - unsigned short w_Input = 0; - unsigned short w_GainFactorAddress = 0; - unsigned short w_GainFactorValue[2]; - unsigned short w_GainIndex = 0; - unsigned short w_GainValue = 0; - - /*****************************************/ - /** Get the Analog input header address **/ - /*****************************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, 0x116, /* w_EepromStartAddress: Analog input header address */ - &w_AnalogInputMainHeaderAddress); - - /*******************************************/ - /** Compute the real analog input address **/ - /*******************************************/ - w_AnalogInputMainHeaderAddress = w_AnalogInputMainHeaderAddress + 0x100; - - /******************************/ - /** Get the number of moduls **/ - /******************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputMainHeaderAddress + 0x02, /* w_EepromStartAddress: Number of conponment */ - &w_NumberOfModuls); - - for (w_ModulCounter = 0; w_ModulCounter < w_NumberOfModuls; - w_ModulCounter++) { - /***********************************/ - /** Compute the component address **/ - /***********************************/ - w_AnalogInputComponentAddress = - w_AnalogInputMainHeaderAddress + - (w_FirstHeaderSize * w_ModulCounter) + 0x04; - - /****************************/ - /** Read first header size **/ - /****************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress, /* Address of the first header */ - &w_FirstHeaderSize); - - w_FirstHeaderSize = w_FirstHeaderSize >> 4; - - /***************************/ - /** Read number of inputs **/ - /***************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x06, /* Number of inputs for the first modul */ - &w_NumberOfInputs); - - w_NumberOfInputs = w_NumberOfInputs >> 4; - - /***********************/ - /** Read the CJC flag **/ - /***********************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x08, /* CJC flag */ - &w_CJCFlag); - - w_CJCFlag = (w_CJCFlag >> 3) & 0x1; /* Get only the CJC flag */ - - /*******************************/ - /** Read number of gain value **/ - /*******************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 0x44, /* Number of gain value */ - &w_NumberOfGainValue); - - w_NumberOfGainValue = w_NumberOfGainValue & 0xFF; - - /***********************************/ - /** Compute single header address **/ - /***********************************/ - w_SingleHeaderAddress = - w_AnalogInputComponentAddress + 0x46 + - (((w_NumberOfGainValue / 16) + 1) * 2) + - (6 * w_NumberOfGainValue) + - (4 * (((w_NumberOfGainValue / 16) + 1) * 2)); - - /********************************************/ - /** Read current sources value for input 1 **/ - /********************************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_SingleHeaderAddress, /* w_EepromStartAddress: Single header address */ - &w_SingleHeaderSize); - - w_SingleHeaderSize = w_SingleHeaderSize >> 4; - - /*************************************/ - /** Read gain factor for the module **/ - /*************************************/ - w_GainFactorAddress = w_AnalogInputComponentAddress; - - for (w_GainIndex = 0; w_GainIndex < w_NumberOfGainValue; - w_GainIndex++) { - /************************************/ - /** Read gain value for the module **/ - /************************************/ - i_AddiHeaderRW_ReadEeprom(1, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + (2 * (1 + (w_NumberOfGainValue / 16))) + (0x02 * w_GainIndex), /* Gain value */ - &w_GainValue); - - BoardInformations->s_Module[w_ModulCounter]. - w_GainValue[w_GainIndex] = w_GainValue; - - /*************************************/ - /** Read gain factor for the module **/ - /*************************************/ - i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, w_AnalogInputComponentAddress + 70 + ((2 * w_NumberOfGainValue) + (2 * (1 + (w_NumberOfGainValue / 16)))) + (0x04 * w_GainIndex), /* Gain factor */ - w_GainFactorValue); - - BoardInformations->s_Module[w_ModulCounter]. - ul_GainFactor[w_GainIndex] = - (w_GainFactorValue[1] << 16) + - w_GainFactorValue[0]; - } - - /***************************************************************/ - /** Read current source value for each channels of the module **/ - /***************************************************************/ - for (w_Input = 0; w_Input < w_NumberOfInputs; w_Input++) { - /********************************************/ - /** Read current sources value for input 1 **/ - /********************************************/ - i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, - (w_Input * w_SingleHeaderSize) + - w_SingleHeaderAddress + 0x0C, w_CurrentSources); - - /************************************/ - /** Save the current sources value **/ - /************************************/ - BoardInformations->s_Module[w_ModulCounter]. - ul_CurrentSource[w_Input] = - (w_CurrentSources[0] + - ((w_CurrentSources[1] & 0xFFF) << 16)); - } - - /***************************************/ - /** Read the CJC current source value **/ - /***************************************/ - i_AddiHeaderRW_ReadEeprom(2, /* i_NbOfWordsToRead */ - dw_PCIBoardEepromAddress, - (w_Input * w_SingleHeaderSize) + w_SingleHeaderAddress + - 0x0C, w_CurrentSources); - - /************************************/ - /** Save the current sources value **/ - /************************************/ - BoardInformations->s_Module[w_ModulCounter]. - ul_CurrentSourceCJC = - (w_CurrentSources[0] + - ((w_CurrentSources[1] & 0xFFF) << 16)); - } -} - -static int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev, - unsigned int ui_Channel_num, - unsigned int *CJCCurrentSource, - unsigned int *ChannelCurrentSource, - unsigned int *ChannelGainFactor) -{ - int i_DiffChannel = 0; - int i_Module = 0; - - /* Test if single or differential mode */ - if (s_BoardInfos[dev->minor].i_ConnectionType == 1) { - /* if diff */ - - if (ui_Channel_num <= 1) - i_DiffChannel = ui_Channel_num, i_Module = 0; - else if ((ui_Channel_num >= 2) && (ui_Channel_num <= 3)) - i_DiffChannel = ui_Channel_num - 2, i_Module = 1; - else if ((ui_Channel_num >= 4) && (ui_Channel_num <= 5)) - i_DiffChannel = ui_Channel_num - 4, i_Module = 2; - else if ((ui_Channel_num >= 6) && (ui_Channel_num <= 7)) - i_DiffChannel = ui_Channel_num - 6, i_Module = 3; - - } else { - /* if single */ - if ((ui_Channel_num == 0) || (ui_Channel_num == 1)) - i_DiffChannel = 0, i_Module = 0; - else if ((ui_Channel_num == 2) || (ui_Channel_num == 3)) - i_DiffChannel = 1, i_Module = 0; - else if ((ui_Channel_num == 4) || (ui_Channel_num == 5)) - i_DiffChannel = 0, i_Module = 1; - else if ((ui_Channel_num == 6) || (ui_Channel_num == 7)) - i_DiffChannel = 1, i_Module = 1; - else if ((ui_Channel_num == 8) || (ui_Channel_num == 9)) - i_DiffChannel = 0, i_Module = 2; - else if ((ui_Channel_num == 10) || (ui_Channel_num == 11)) - i_DiffChannel = 1, i_Module = 2; - else if ((ui_Channel_num == 12) || (ui_Channel_num == 13)) - i_DiffChannel = 0, i_Module = 3; - else if ((ui_Channel_num == 14) || (ui_Channel_num == 15)) - i_DiffChannel = 1, i_Module = 3; - } - - /* Test if thermocouple or RTD mode */ - *CJCCurrentSource = - s_BoardInfos[dev->minor].s_Module[i_Module].ul_CurrentSourceCJC; - - *ChannelCurrentSource = - s_BoardInfos[dev->minor].s_Module[i_Module]. - ul_CurrentSource[i_DiffChannel]; - /* } */ - /* } */ - - /* Channle gain factor */ - *ChannelGainFactor = - s_BoardInfos[dev->minor].s_Module[i_Module]. - ul_GainFactor[s_BoardInfos[dev->minor].i_ADDIDATAGain]; - /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - - return 0; -} - -static int apci3200_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[1] = inl(devpriv->i_IobaseReserved) & 0xf; - - return insn->n; -} - -static int apci3200_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - s->state = inl(devpriv->i_IobaseAddon) & 0xf; - - if (comedi_dio_update_state(s, data)) - outl(s->state, devpriv->i_IobaseAddon); - - data[1] = s->state; - - return insn->n; -} - -static int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_EOC = 0; - unsigned int ui_ChannelNo = 0; - unsigned int ui_CommandRegister = 0; - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_ChannelNo=i_ChannelNo; */ - ui_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo; - - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /*********************************/ - /* Write the channel to configure */ - /*********************************/ - /* Begin JK 20.10.2004: Bad channel value is used when using differential mode */ - /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */ - /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */ - outl(0 | s_BoardInfos[dev->minor].i_ChannelNo, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4); - /* End JK 20.10.2004: Bad channel value is used when using differential mode */ - - /*******************************/ - /* Set the convert timing unit */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - - /**************************/ - /* Set the convert timing */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - - /**************************************************************************/ - /* Set the start end stop index to the selected channel and set the start */ - /**************************************************************************/ - - ui_CommandRegister = ui_ChannelNo | (ui_ChannelNo << 8) | 0x80000; - - /*Test if the interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { - /* Enable the interrupt */ - ui_CommandRegister = ui_CommandRegister | 0x00100000; - } - - /******************************/ - /* Write the command register */ - /******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */ - outl(ui_CommandRegister, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - - /*Test if interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { - do { - /*************************/ - /*Read the EOC Status bit */ - /*************************/ - - /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ - ui_EOC = inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 20) & 1; - - } while (ui_EOC != 1); - - /***************************************/ - /* Read the digital value of the input */ - /***************************************/ - - /* data[0] = inl (devpriv->iobase+i_Offset + 28); */ - data[0] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - /* END JK 06.07.04: Management of sevrals boards */ - - } - return 0; -} - -static int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_Temp = 0, ui_EOC = 0; - unsigned int ui_CommandRegister = 0; - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /*********************************/ - /* Write the channel to configure */ - /*********************************/ - /* Begin JK 20.10.2004: This seems not necessary ! */ - /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */ - /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */ - /* End JK 20.10.2004: This seems not necessary ! */ - - /*******************************/ - /* Set the convert timing unit */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - /**************************/ - /* Set the convert timing */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - /*****************************/ - /*Read the calibration offset */ - /*****************************/ - /* ui_Temp = inl(devpriv->iobase+i_Offset + 12); */ - ui_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - - /*********************************/ - /*Configure the Offset Conversion */ - /*********************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); */ - outl((ui_Temp | 0x00020000), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - /*******************************/ - /*Initialise ui_CommandRegister */ - /*******************************/ - - ui_CommandRegister = 0; - - /*Test if the interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { - /*Enable the interrupt */ - ui_CommandRegister = ui_CommandRegister | 0x00100000; - } - - /**********************/ - /*Start the conversion */ - /**********************/ - ui_CommandRegister = ui_CommandRegister | 0x00080000; - - /***************************/ - /*Write the command regiter */ - /***************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */ - outl(ui_CommandRegister, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - - /*Test if interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { - do { - /*******************/ - /*Read the EOC flag */ - /*******************/ - - /* ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; */ - ui_EOC = inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 20) & 1; - - } while (ui_EOC != 1); - - /**************************************************/ - /*Read the digital value of the calibration Offset */ - /**************************************************/ - - /* data[0] = inl(devpriv->iobase+i_Offset+ 28); */ - data[0] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - } - return 0; -} - -static int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_EOC = 0; - int ui_CommandRegister = 0; - - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /*********************************/ - /* Write the channel to configure */ - /*********************************/ - /* Begin JK 20.10.2004: This seems not necessary ! */ - /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */ - /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */ - /* End JK 20.10.2004: This seems not necessary ! */ - - /***************************/ - /*Read the calibration gain */ - /***************************/ - /*******************************/ - /* Set the convert timing unit */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - /**************************/ - /* Set the convert timing */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - /*******************************/ - /*Configure the Gain Conversion */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(0x00040000 , devpriv->iobase+i_Offset + 12); */ - outl(0x00040000, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - - /*******************************/ - /*Initialise ui_CommandRegister */ - /*******************************/ - - ui_CommandRegister = 0; - - /*Test if the interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { - /*Enable the interrupt */ - ui_CommandRegister = ui_CommandRegister | 0x00100000; - } - - /**********************/ - /*Start the conversion */ - /**********************/ - - ui_CommandRegister = ui_CommandRegister | 0x00080000; - /***************************/ - /*Write the command regiter */ - /***************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */ - outl(ui_CommandRegister, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - - /*Test if interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { - do { - - /*******************/ - /*Read the EOC flag */ - /*******************/ - - /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ - ui_EOC = inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 20) & 1; - - } while (ui_EOC != 1); - - /************************************************/ - /*Read the digital value of the calibration Gain */ - /************************************************/ - - /* data[0] = inl(devpriv->iobase+i_Offset + 28); */ - data[0] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - - } - return 0; -} - -static int i_APCI3200_ReadCJCValue(struct comedi_device *dev, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_EOC = 0; - int ui_CommandRegister = 0; - - /******************************/ - /*Set the converting time unit */ - /******************************/ - - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - /**************************/ - /* Set the convert timing */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - - /******************************/ - /*Configure the CJC Conversion */ - /******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl( 0x00000400 , devpriv->iobase+i_Offset + 4); */ - outl(0x00000400, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); - /*******************************/ - /*Initialise dw_CommandRegister */ - /*******************************/ - ui_CommandRegister = 0; - /*Test if the interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { - /*Enable the interrupt */ - ui_CommandRegister = ui_CommandRegister | 0x00100000; - } - - /**********************/ - /*Start the conversion */ - /**********************/ - - ui_CommandRegister = ui_CommandRegister | 0x00080000; - - /***************************/ - /*Write the command regiter */ - /***************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */ - outl(ui_CommandRegister, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - - /*Test if interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { - do { - - /*******************/ - /*Read the EOC flag */ - /*******************/ - - /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ - ui_EOC = inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 20) & 1; - - } while (ui_EOC != 1); - - /***********************************/ - /*Read the digital value of the CJC */ - /***********************************/ - - /* data[0] = inl(devpriv->iobase+i_Offset + 28); */ - data[0] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - } - return 0; -} - -static int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_EOC = 0; - int ui_CommandRegister = 0; - - /*******************************************/ - /*Read calibration offset value for the CJC */ - /*******************************************/ - /*******************************/ - /* Set the convert timing unit */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - /**************************/ - /* Set the convert timing */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - /******************************/ - /*Configure the CJC Conversion */ - /******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(0x00000400 , devpriv->iobase+i_Offset + 4); */ - outl(0x00000400, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); - /*********************************/ - /*Configure the Offset Conversion */ - /*********************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(0x00020000, devpriv->iobase+i_Offset + 12); */ - outl(0x00020000, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - /*******************************/ - /*Initialise ui_CommandRegister */ - /*******************************/ - ui_CommandRegister = 0; - /*Test if the interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { - /*Enable the interrupt */ - ui_CommandRegister = ui_CommandRegister | 0x00100000; - } - - /**********************/ - /*Start the conversion */ - /**********************/ - ui_CommandRegister = ui_CommandRegister | 0x00080000; - /***************************/ - /*Write the command regiter */ - /***************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); */ - outl(ui_CommandRegister, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { - do { - /*******************/ - /*Read the EOC flag */ - /*******************/ - /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ - ui_EOC = inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 20) & 1; - } while (ui_EOC != 1); - - /**************************************************/ - /*Read the digital value of the calibration Offset */ - /**************************************************/ - /* data[0] = inl(devpriv->iobase+i_Offset + 28); */ - data[0] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - } - return 0; -} - -static int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_EOC = 0; - int ui_CommandRegister = 0; - - /*******************************/ - /* Set the convert timing unit */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - /**************************/ - /* Set the convert timing */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */ - outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - /******************************/ - /*Configure the CJC Conversion */ - /******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(0x00000400,devpriv->iobase+i_Offset + 4); */ - outl(0x00000400, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); - /*******************************/ - /*Configure the Gain Conversion */ - /*******************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(0x00040000,devpriv->iobase+i_Offset + 12); */ - outl(0x00040000, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - - /*******************************/ - /*Initialise dw_CommandRegister */ - /*******************************/ - ui_CommandRegister = 0; - /*Test if the interrupt is enable */ - if (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { - /*Enable the interrupt */ - ui_CommandRegister = ui_CommandRegister | 0x00100000; - } - /**********************/ - /*Start the conversion */ - /**********************/ - ui_CommandRegister = ui_CommandRegister | 0x00080000; - /***************************/ - /*Write the command regiter */ - /***************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); */ - outl(ui_CommandRegister, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) { - do { - /*******************/ - /*Read the EOC flag */ - /*******************/ - /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */ - ui_EOC = inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 20) & 1; - } while (ui_EOC != 1); - /************************************************/ - /*Read the digital value of the calibration Gain */ - /************************************************/ - /* data[0] = inl (devpriv->iobase+i_Offset + 28); */ - data[0] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - } - return 0; -} - -static int apci3200_reset(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - int i_Temp; - unsigned int dw_Dummy; - - /* i_InterruptFlag=0; */ - /* i_Initialised==0; */ - /* i_Count=0; */ - /* i_Sum=0; */ - - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - s_BoardInfos[dev->minor].i_Initialised = 0; - s_BoardInfos[dev->minor].i_Count = 0; - s_BoardInfos[dev->minor].i_Sum = 0; - s_BoardInfos[dev->minor].b_StructInitialized = 0; - - outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); - outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - outl(0, devpriv->i_IobaseAddon); /* Resets the output */ - /***************/ - /*Empty the buffer */ - /**************/ - for (i_Temp = 0; i_Temp <= 95; i_Temp++) { - /* ui_InterruptChannelValue[i_Temp]=0; */ - s_BoardInfos[dev->minor].ui_InterruptChannelValue[i_Temp] = 0; - } /* for(i_Temp=0;i_Temp<=95;i_Temp++) */ - /*****************************/ - /*Reset the START and IRQ bit */ - /*****************************/ - for (i_Temp = 0; i_Temp <= 192;) { - while (((inl(devpriv->iobase + i_Temp + 12) >> 19) & 1) != 1) ; - outl(0, devpriv->iobase + i_Temp + 8); - i_Temp = i_Temp + 64; - } /* for(i_Temp=0;i_Temp<=192;i_Temp+64) */ - return 0; -} - -/* - * Read value of the selected channel - * - * data[0] : Digital Value Of Input - * data[1] : Calibration Offset Value - * data[2] : Calibration Gain Value - * data[3] : CJC value - * data[4] : CJC offset value - * data[5] : CJC gain value - * data[6] : CJC current source from eeprom - * data[7] : Channel current source from eeprom - * data[8] : Channle gain factor from eeprom - */ -static int apci3200_ai_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int ui_DummyValue = 0; - int i_ConvertCJCCalibration; - int i = 0; - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if(i_Initialised==0) */ - if (s_BoardInfos[dev->minor].i_Initialised == 0) - /* END JK 06.07.04: Management of sevrals boards */ - { - apci3200_reset(dev); - return -EINVAL; - } /* if(i_Initialised==0); */ - - switch (insn->unused[0]) { - case 0: - - i_APCI3200_Read1AnalogInputChannel(dev, s, insn, - &ui_DummyValue); - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev->minor]. - i_Count + 0] = ui_DummyValue; - /* END JK 06.07.04: Management of sevrals boards */ - - /* Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - i_APCI3200_GetChannelCalibrationValue(dev, - s_BoardInfos[dev->minor].ui_Channel_num, - &s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev->minor]. - i_Count + 6], - &s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev->minor]. - i_Count + 7], - &s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev->minor]. - i_Count + 8]); - /* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */ - if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2) - && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE) - && (s_BoardInfos[dev->minor].i_CJCAvailable == 1)) - /* END JK 06.07.04: Management of sevrals boards */ - { - i_APCI3200_ReadCJCValue(dev, &ui_DummyValue); - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev-> - minor].i_Count + 3] = ui_DummyValue; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */ - else { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count + 3]=0; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev-> - minor].i_Count + 3] = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */ - if ((s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) - && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)) - /* END JK 06.07.04: Management of sevrals boards */ - { - i_APCI3200_ReadCalibrationOffsetValue(dev, - &ui_DummyValue); - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev-> - minor].i_Count + 1] = ui_DummyValue; - /* END JK 06.07.04: Management of sevrals boards */ - i_APCI3200_ReadCalibrationGainValue(dev, - &ui_DummyValue); - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos[dev-> - minor].i_Count + 2] = ui_DummyValue; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) */ - if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2) - && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE) - && (s_BoardInfos[dev->minor].i_CJCAvailable == 1)) - /* END JK 06.07.04: Management of sevrals boards */ - { - /**********************************************************/ - /*Test if the Calibration channel must be read for the CJC */ - /**********************************************************/ - /**********************************/ - /*Test if the polarity is the same */ - /**********************************/ - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ - if (s_BoardInfos[dev->minor].i_CJCPolarity != - s_BoardInfos[dev->minor].i_ADDIDATAPolarity) - /* END JK 06.07.04: Management of sevrals boards */ - { - i_ConvertCJCCalibration = 1; - } /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ - else { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if(i_CJCGain==i_ADDIDATAGain) */ - if (s_BoardInfos[dev->minor].i_CJCGain == - s_BoardInfos[dev->minor].i_ADDIDATAGain) - /* END JK 06.07.04: Management of sevrals boards */ - { - i_ConvertCJCCalibration = 0; - } /* if(i_CJCGain==i_ADDIDATAGain) */ - else { - i_ConvertCJCCalibration = 1; - } /* elseif(i_CJCGain==i_ADDIDATAGain) */ - } /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */ - if (i_ConvertCJCCalibration == 1) { - i_APCI3200_ReadCJCCalOffset(dev, - &ui_DummyValue); - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos - [dev->minor].i_Count + 4] = - ui_DummyValue; - /* END JK 06.07.04: Management of sevrals boards */ - - i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue); - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos - [dev->minor].i_Count + 5] = - ui_DummyValue; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(i_ConvertCJCCalibration==1) */ - else { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ui_InterruptChannelValue[i_Count+4]=0; */ - /* ui_InterruptChannelValue[i_Count+5]=0; */ - - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos - [dev->minor].i_Count + 4] = 0; - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[s_BoardInfos - [dev->minor].i_Count + 5] = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* elseif(i_ConvertCJCCalibration==1) */ - } /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if(i_ScanType!=1) */ - if (s_BoardInfos[dev->minor].i_ScanType != 1) { - /* i_Count=0; */ - s_BoardInfos[dev->minor].i_Count = 0; - } /* if(i_ScanType!=1) */ - else { - /* i_Count=i_Count +6; */ - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; */ - s_BoardInfos[dev->minor].i_Count = - s_BoardInfos[dev->minor].i_Count + 9; - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - } /* else if(i_ScanType!=1) */ - - /* if((i_ScanType==1) &&(i_InterruptFlag==1)) */ - if ((s_BoardInfos[dev->minor].i_ScanType == 1) - && (s_BoardInfos[dev->minor].i_InterruptFlag == 1)) { - /* i_Count=i_Count-6; */ - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; */ - s_BoardInfos[dev->minor].i_Count = - s_BoardInfos[dev->minor].i_Count - 9; - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - } - /* if(i_ScanType==0) */ - if (s_BoardInfos[dev->minor].i_ScanType == 0) { - /* - data[0]= ui_InterruptChannelValue[0]; - data[1]= ui_InterruptChannelValue[1]; - data[2]= ui_InterruptChannelValue[2]; - data[3]= ui_InterruptChannelValue[3]; - data[4]= ui_InterruptChannelValue[4]; - data[5]= ui_InterruptChannelValue[5]; - */ - data[0] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[0]; - data[1] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[1]; - data[2] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[2]; - data[3] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[3]; - data[4] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[4]; - data[5] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[5]; - - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - i_APCI3200_GetChannelCalibrationValue(dev, - s_BoardInfos[dev->minor].ui_Channel_num, - &data[6], &data[7], &data[8]); - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - } - break; - case 1: - - for (i = 0; i < insn->n; i++) { - /* data[i]=ui_InterruptChannelValue[i]; */ - data[i] = - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue[i]; - } - - /* i_Count=0; */ - /* i_Sum=0; */ - /* if(i_ScanType==1) */ - s_BoardInfos[dev->minor].i_Count = 0; - s_BoardInfos[dev->minor].i_Sum = 0; - if (s_BoardInfos[dev->minor].i_ScanType == 1) { - /* i_Initialised=0; */ - /* i_InterruptFlag=0; */ - s_BoardInfos[dev->minor].i_Initialised = 0; - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } - break; - default: - printk("\nThe parameters passed are in error\n"); - apci3200_reset(dev); - return -EINVAL; - } /* switch(insn->unused[0]) */ - - return insn->n; -} - -/* - * Configures The Analog Input Subdevice - * - * data[0] = 0 Normal AI - * = 1 RTD - * = 2 THERMOCOUPLE - * data[1] = Gain To Use - * data[2] = 0 Bipolar - * = 1 Unipolar - * data[3] = Offset Range - * data[4] = 0 DC Coupling - * = 1 AC Coupling - * data[5] = 0 Single - * = 1 Differential - * data[6] = TimerReloadValue - * data[7] = ConvertingTimeUnit - * data[8] = 0 Analog voltage measurement - * = 1 Resistance measurement - * = 2 Temperature measurement - * data[9] = 0 Interrupt Disable - * = 1 INterrupt Enable - * data[10] = Type of Thermocouple - * data[11] = single channel Module Number - * data[12] = 0 Single Read - * = 1 Read more channel - * = 2 Single scan - * = 3 Continuous Scan - * data[13] = Number of channels to read - * data[14] = 0 RTD not used - * = 1 RTD 2 wire connection - * = 2 RTD 3 wire connection - * = 3 RTD 4 wire connection - */ -static int apci3200_ai_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ul_Config = 0, ul_Temp = 0; - unsigned int ui_ChannelNo = 0; - unsigned int ui_Dummy = 0; - int i_err = 0; - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* Initialize the structure */ - if (s_BoardInfos[dev->minor].b_StructInitialized != 1) { - s_BoardInfos[dev->minor].i_CJCAvailable = 1; - s_BoardInfos[dev->minor].i_CJCPolarity = 0; - s_BoardInfos[dev->minor].i_CJCGain = 2; /* changed from 0 to 2 */ - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - s_BoardInfos[dev->minor].i_AutoCalibration = 0; /* : auto calibration */ - s_BoardInfos[dev->minor].i_ChannelCount = 0; - s_BoardInfos[dev->minor].i_Sum = 0; - s_BoardInfos[dev->minor].ui_Channel_num = 0; - s_BoardInfos[dev->minor].i_Count = 0; - s_BoardInfos[dev->minor].i_Initialised = 0; - s_BoardInfos[dev->minor].b_StructInitialized = 1; - - /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - s_BoardInfos[dev->minor].i_ConnectionType = 0; - /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - - /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - memset(s_BoardInfos[dev->minor].s_Module, 0, - sizeof(s_BoardInfos[dev->minor].s_Module[MAX_MODULE])); - - v_GetAPCI3200EepromCalibrationValue(devpriv->i_IobaseAmcc, - &s_BoardInfos[dev->minor]); - /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - } - - if (data[0] != 0 && data[0] != 1 && data[0] != 2) { - printk("\nThe selection of acquisition type is in error\n"); - i_err++; - } /* if(data[0]!=0 && data[0]!=1 && data[0]!=2) */ - if (data[0] == 1) { - if (data[14] != 0 && data[14] != 1 && data[14] != 2 - && data[14] != 4) { - printk("\n Error in selection of RTD connection type\n"); - i_err++; - } /* if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) */ - } /* if(data[0]==1 ) */ - if (data[1] < 0 || data[1] > 7) { - printk("\nThe selection of gain is in error\n"); - i_err++; - } /* if(data[1]<0 || data[1]>7) */ - if (data[2] != 0 && data[2] != 1) { - printk("\nThe selection of polarity is in error\n"); - i_err++; - } /* if(data[2]!=0 && data[2]!=1) */ - if (data[3] != 0) { - printk("\nThe selection of offset range is in error\n"); - i_err++; - } /* if(data[3]!=0) */ - if (data[4] != 0 && data[4] != 1) { - printk("\nThe selection of coupling is in error\n"); - i_err++; - } /* if(data[4]!=0 && data[4]!=1) */ - if (data[5] != 0 && data[5] != 1) { - printk("\nThe selection of single/differential mode is in error\n"); - i_err++; - } /* if(data[5]!=0 && data[5]!=1) */ - if (data[8] != 0 && data[8] != 1 && data[2] != 2) { - printk("\nError in selection of functionality\n"); - } /* if(data[8]!=0 && data[8]!=1 && data[2]!=2) */ - if (data[12] == 0 || data[12] == 1) { - if (data[6] != 20 && data[6] != 40 && data[6] != 80 - && data[6] != 160) { - printk("\nThe selection of conversion time reload value is in error\n"); - i_err++; - } /* if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) */ - if (data[7] != 2) { - printk("\nThe selection of conversion time unit is in error\n"); - i_err++; - } /* if(data[7]!=2) */ - } - if (data[9] != 0 && data[9] != 1) { - printk("\nThe selection of interrupt enable is in error\n"); - i_err++; - } /* if(data[9]!=0 && data[9]!=1) */ - if (data[11] < 0 || data[11] > 4) { - printk("\nThe selection of module is in error\n"); - i_err++; - } /* if(data[11] <0 || data[11]>1) */ - if (data[12] < 0 || data[12] > 3) { - printk("\nThe selection of singlechannel/scan selection is in error\n"); - i_err++; - } /* if(data[12] < 0 || data[12]> 3) */ - if (data[13] < 0 || data[13] > 16) { - printk("\nThe selection of number of channels is in error\n"); - i_err++; - } /* if(data[13] <0 ||data[13] >15) */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* - i_ChannelCount=data[13]; - i_ScanType=data[12]; - i_ADDIDATAPolarity = data[2]; - i_ADDIDATAGain=data[1]; - i_ADDIDATAConversionTime=data[6]; - i_ADDIDATAConversionTimeUnit=data[7]; - i_ADDIDATAType=data[0]; - */ - - /* Save acquisition configuration for the actual board */ - s_BoardInfos[dev->minor].i_ChannelCount = data[13]; - s_BoardInfos[dev->minor].i_ScanType = data[12]; - s_BoardInfos[dev->minor].i_ADDIDATAPolarity = data[2]; - s_BoardInfos[dev->minor].i_ADDIDATAGain = data[1]; - s_BoardInfos[dev->minor].i_ADDIDATAConversionTime = data[6]; - s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit = data[7]; - s_BoardInfos[dev->minor].i_ADDIDATAType = data[0]; - /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - s_BoardInfos[dev->minor].i_ConnectionType = data[5]; - /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* END JK 06.07.04: Management of sevrals boards */ - - /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); /* 7 is the maximal number of channels */ - /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - - /* BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards */ - /* while(i_InterruptFlag==1) */ - while (s_BoardInfos[dev->minor].i_InterruptFlag == 1) { -#ifndef MSXBOX - udelay(1); -#else - /* In the case where the driver is compiled for the MSX-Box */ - /* we used a printk to have a little delay because udelay */ - /* seems to be broken under the MSX-Box. */ - /* This solution hat to be studied. */ - printk(""); -#endif - } - /* END JK 02.07.04 : This while can't be do, it block the process when using severals boards */ - - ui_ChannelNo = CR_CHAN(insn->chanspec); /* get the channel */ - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_ChannelNo=ui_ChannelNo; */ - /* ui_Channel_num =ui_ChannelNo; */ - - s_BoardInfos[dev->minor].i_ChannelNo = ui_ChannelNo; - s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNo; - - /* END JK 06.07.04: Management of sevrals boards */ - - if (data[5] == 0) { - if (ui_ChannelNo > 15) { - printk("\nThe Selection of the channel is in error\n"); - i_err++; - } /* if(ui_ChannelNo>15) */ - } /* if(data[5]==0) */ - else { - if (data[14] == 2) { - if (ui_ChannelNo > 3) { - printk("\nThe Selection of the channel is in error\n"); - i_err++; - } /* if(ui_ChannelNo>3) */ - } /* if(data[14]==2) */ - else { - if (ui_ChannelNo > 7) { - printk("\nThe Selection of the channel is in error\n"); - i_err++; - } /* if(ui_ChannelNo>7) */ - } /* elseif(data[14]==2) */ - } /* elseif(data[5]==0) */ - if (data[12] == 0 || data[12] == 1) { - switch (data[5]) { - case 0: - if (ui_ChannelNo <= 3) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=0; */ - s_BoardInfos[dev->minor].i_Offset = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo <=3) */ - if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=64; */ - s_BoardInfos[dev->minor].i_Offset = 64; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo >=4 && ui_ChannelNo <=7) */ - if (ui_ChannelNo >= 8 && ui_ChannelNo <= 11) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=128; */ - s_BoardInfos[dev->minor].i_Offset = 128; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo >=8 && ui_ChannelNo <=11) */ - if (ui_ChannelNo >= 12 && ui_ChannelNo <= 15) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=192; */ - s_BoardInfos[dev->minor].i_Offset = 192; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo >=12 && ui_ChannelNo <=15) */ - break; - case 1: - if (data[14] == 2) { - if (ui_ChannelNo == 0) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=0; */ - s_BoardInfos[dev->minor].i_Offset = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo ==0 ) */ - if (ui_ChannelNo == 1) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=0; */ - s_BoardInfos[dev->minor].i_Offset = 64; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo ==1) */ - if (ui_ChannelNo == 2) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=128; */ - s_BoardInfos[dev->minor].i_Offset = 128; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo ==2 ) */ - if (ui_ChannelNo == 3) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=192; */ - s_BoardInfos[dev->minor].i_Offset = 192; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo ==3) */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_ChannelNo=0; */ - s_BoardInfos[dev->minor].i_ChannelNo = 0; - /* END JK 06.07.04: Management of sevrals boards */ - ui_ChannelNo = 0; - break; - } /* if(data[14]==2) */ - if (ui_ChannelNo <= 1) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=0; */ - s_BoardInfos[dev->minor].i_Offset = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(ui_ChannelNo <=1) */ - if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_ChannelNo=i_ChannelNo-2; */ - /* i_Offset=64; */ - s_BoardInfos[dev->minor].i_ChannelNo = - s_BoardInfos[dev->minor].i_ChannelNo - - 2; - s_BoardInfos[dev->minor].i_Offset = 64; - /* END JK 06.07.04: Management of sevrals boards */ - ui_ChannelNo = ui_ChannelNo - 2; - } /* if(ui_ChannelNo >=2 && ui_ChannelNo <=3) */ - if (ui_ChannelNo >= 4 && ui_ChannelNo <= 5) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_ChannelNo=i_ChannelNo-4; */ - /* i_Offset=128; */ - s_BoardInfos[dev->minor].i_ChannelNo = - s_BoardInfos[dev->minor].i_ChannelNo - - 4; - s_BoardInfos[dev->minor].i_Offset = 128; - /* END JK 06.07.04: Management of sevrals boards */ - ui_ChannelNo = ui_ChannelNo - 4; - } /* if(ui_ChannelNo >=4 && ui_ChannelNo <=5) */ - if (ui_ChannelNo >= 6 && ui_ChannelNo <= 7) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_ChannelNo=i_ChannelNo-6; */ - /* i_Offset=192; */ - s_BoardInfos[dev->minor].i_ChannelNo = - s_BoardInfos[dev->minor].i_ChannelNo - - 6; - s_BoardInfos[dev->minor].i_Offset = 192; - /* END JK 06.07.04: Management of sevrals boards */ - ui_ChannelNo = ui_ChannelNo - 6; - } /* if(ui_ChannelNo >=6 && ui_ChannelNo <=7) */ - break; - - default: - printk("\n This selection of polarity does not exist\n"); - i_err++; - } /* switch(data[2]) */ - } /* if(data[12]==0 || data[12]==1) */ - else { - switch (data[11]) { - case 1: - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=0; */ - s_BoardInfos[dev->minor].i_Offset = 0; - /* END JK 06.07.04: Management of sevrals boards */ - break; - case 2: - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=64; */ - s_BoardInfos[dev->minor].i_Offset = 64; - /* END JK 06.07.04: Management of sevrals boards */ - break; - case 3: - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=128; */ - s_BoardInfos[dev->minor].i_Offset = 128; - /* END JK 06.07.04: Management of sevrals boards */ - break; - case 4: - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Offset=192; */ - s_BoardInfos[dev->minor].i_Offset = 192; - /* END JK 06.07.04: Management of sevrals boards */ - break; - default: - printk("\nError in module selection\n"); - i_err++; - } /* switch(data[11]) */ - } /* elseif(data[12]==0 || data[12]==1) */ - if (i_err) { - apci3200_reset(dev); - return -EINVAL; - } - /* if(i_ScanType!=1) */ - if (s_BoardInfos[dev->minor].i_ScanType != 1) { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Count=0; */ - /* i_Sum=0; */ - s_BoardInfos[dev->minor].i_Count = 0; - s_BoardInfos[dev->minor].i_Sum = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(i_ScanType!=1) */ - - ul_Config = - data[1] | (data[2] << 6) | (data[5] << 7) | (data[3] << 8) | - (data[4] << 9); - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* END JK 06.07.04: Management of sevrals boards */ - /*********************************/ - /* Write the channel to configure */ - /*********************************/ - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); */ - outl(0 | ui_ChannelNo, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4); - /* END JK 06.07.04: Management of sevrals boards */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* END JK 06.07.04: Management of sevrals boards */ - /**************************/ - /* Reset the configuration */ - /**************************/ - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* outl(0 , devpriv->iobase+i_Offset + 0x0); */ - outl(0, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0); - /* END JK 06.07.04: Management of sevrals boards */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* END JK 06.07.04: Management of sevrals boards */ - - /***************************/ - /* Write the configuration */ - /***************************/ - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* outl(ul_Config , devpriv->iobase+i_Offset + 0x0); */ - outl(ul_Config, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0); - /* END JK 06.07.04: Management of sevrals boards */ - - /***************************/ - /*Reset the calibration bit */ - /***************************/ - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* ul_Temp = inl(devpriv->iobase+i_Offset + 12); */ - ul_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - /* END JK 06.07.04: Management of sevrals boards */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* END JK 06.07.04: Management of sevrals boards */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); */ - outl((ul_Temp & 0xFFF9FFFF), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - /* END JK 06.07.04: Management of sevrals boards */ - - if (data[9] == 1) { - devpriv->tsk_Current = current; - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_InterruptFlag=1; */ - s_BoardInfos[dev->minor].i_InterruptFlag = 1; - /* END JK 06.07.04: Management of sevrals boards */ - } /* if(data[9]==1) */ - else { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_InterruptFlag=0; */ - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - /* END JK 06.07.04: Management of sevrals boards */ - } /* else if(data[9]==1) */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Initialised=1; */ - s_BoardInfos[dev->minor].i_Initialised = 1; - /* END JK 06.07.04: Management of sevrals boards */ - - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* if(i_ScanType==1) */ - if (s_BoardInfos[dev->minor].i_ScanType == 1) - /* END JK 06.07.04: Management of sevrals boards */ - { - /* BEGIN JK 06.07.04: Management of sevrals boards */ - /* i_Sum=i_Sum+1; */ - s_BoardInfos[dev->minor].i_Sum = - s_BoardInfos[dev->minor].i_Sum + 1; - /* END JK 06.07.04: Management of sevrals boards */ - - insn->unused[0] = 0; - apci3200_ai_read(dev, s, insn, &ui_Dummy); - } - - return insn->n; -} - -/* - * Tests the Selected Anlog Input Channel - * - * data[0] = 0 TestAnalogInputShortCircuit - * = 1 TestAnalogInputConnection - * - * data[0] : Digital value obtained - * data[1] : calibration offset - * data[2] : calibration gain - */ -static int apci3200_ai_bits_test(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_Configuration = 0; - int i_Temp; /* ,i_TimeUnit; */ - - /* if(i_Initialised==0) */ - - if (s_BoardInfos[dev->minor].i_Initialised == 0) { - apci3200_reset(dev); - return -EINVAL; - } /* if(i_Initialised==0); */ - if (data[0] != 0 && data[0] != 1) { - printk("\nError in selection of functionality\n"); - apci3200_reset(dev); - return -EINVAL; - } /* if(data[0]!=0 && data[0]!=1) */ - - if (data[0] == 1) /* Perform Short Circuit TEST */ - { - /**************************/ - /*Set the short-cicuit bit */ - /**************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. - i_Offset + 12) >> 19) & 1) != - 1) ; - /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ - outl((0x00001000 | s_BoardInfos[dev->minor].i_ChannelNo), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 4); - /*************************/ - /*Set the time unit to ns */ - /*************************/ - /* i_TimeUnit= i_ADDIDATAConversionTimeUnit; - i_ADDIDATAConversionTimeUnit= 1; */ - /* i_Temp= i_InterruptFlag ; */ - i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag; - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data); - /* if(i_AutoCalibration == FALSE) */ - if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) { - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. - i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl((0x00001000 |i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ - outl((0x00001000 | s_BoardInfos[dev->minor]. - i_ChannelNo), - devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 4); - data++; - i_APCI3200_ReadCalibrationOffsetValue(dev, data); - data++; - i_APCI3200_ReadCalibrationGainValue(dev, data); - } - } else { - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. - i_Offset + 12) >> 19) & 1) != - 1) ; - /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ - outl((0x00000800 | s_BoardInfos[dev->minor].i_ChannelNo), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 4); - /* ui_Configuration = inl(devpriv->iobase+i_Offset + 0); */ - ui_Configuration = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 0); - /*************************/ - /*Set the time unit to ns */ - /*************************/ - /* i_TimeUnit= i_ADDIDATAConversionTimeUnit; - i_ADDIDATAConversionTimeUnit= 1; */ - /* i_Temp= i_InterruptFlag ; */ - i_Temp = s_BoardInfos[dev->minor].i_InterruptFlag; - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - i_APCI3200_Read1AnalogInputChannel(dev, s, insn, data); - /* if(i_AutoCalibration == FALSE) */ - if (s_BoardInfos[dev->minor].i_AutoCalibration == FALSE) { - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor]. - i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl((0x00000800|i_ChannelNo) , devpriv->iobase+i_Offset + 4); */ - outl((0x00000800 | s_BoardInfos[dev->minor]. - i_ChannelNo), - devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 4); - data++; - i_APCI3200_ReadCalibrationOffsetValue(dev, data); - data++; - i_APCI3200_ReadCalibrationGainValue(dev, data); - } - } - /* i_InterruptFlag=i_Temp ; */ - s_BoardInfos[dev->minor].i_InterruptFlag = i_Temp; - return insn->n; -} - -static int apci3200_ai_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - apci3200_reset(dev); - return insn->n; -} - -static int apci3200_ai_cmdtest(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_cmd *cmd) -{ - - int err = 0; - unsigned int ui_ConvertTime = 0; - unsigned int ui_ConvertTimeBase = 0; - unsigned int ui_DelayTime = 0; - unsigned int ui_DelayTimeBase = 0; - int i_NbrOfChannel = 0; - int i_Cpt = 0; - double d_ConversionTimeForAllChannels = 0.0; - double d_SCANTimeNewUnit = 0.0; - unsigned int arg; - - /* Step 1 : check if triggers are trivially valid */ - - err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT); - err |= cfc_check_trigger_src(&cmd->scan_begin_src, - TRIG_TIMER | TRIG_FOLLOW); - err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER); - err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); - err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); - - if (s_BoardInfos[dev->minor].i_InterruptFlag == 0) - err |= -EINVAL; - - if (err) { - apci3200_reset(dev); - return 1; - } - - /* Step 2a : make sure trigger sources are unique */ - - err |= cfc_check_trigger_is_unique(&cmd->start_src); - err |= cfc_check_trigger_is_unique(&cmd->scan_begin_src); - err |= cfc_check_trigger_is_unique(&cmd->stop_src); - - /* Step 2b : and mutually compatible */ - - if (err) { - apci3200_reset(dev); - return 2; - } - - /* Step 3: check if arguments are trivially valid */ - - switch (cmd->start_src) { - case TRIG_NOW: - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); - break; - case TRIG_EXT: - /* validate the trigger edge selection */ - arg = cmd->start_arg & 0xffff; - if (arg < 1 || arg > 3) { - cmd->start_arg &= ~0xffff; - cmd->start_arg |= 1; - err |= -EINVAL; - } - /* validate the trigger mode selection */ - arg = cmd->start_arg >> 16; - if (arg != 2) { - cmd->start_arg &= ~(0xffff << 16); - cmd->start_arg |= (2 << 16); - err |= -EINVAL; - } - break; - } - - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); - - /* i_FirstChannel=cmd->chanlist[0]; */ - s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0]; - /* i_LastChannel=cmd->chanlist[1]; */ - s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1]; - - if (cmd->convert_src == TRIG_TIMER) { - ui_ConvertTime = cmd->convert_arg & 0xFFFF; - ui_ConvertTimeBase = cmd->convert_arg >> 16; - if (ui_ConvertTime != 20 && ui_ConvertTime != 40 - && ui_ConvertTime != 80 && ui_ConvertTime != 160) - { - printk("\nThe selection of conversion time reload value is in error\n"); - err++; - } /* if (ui_ConvertTime!=20 && ui_ConvertTime!=40 && ui_ConvertTime!=80 && ui_ConvertTime!=160 ) */ - if (ui_ConvertTimeBase != 2) { - printk("\nThe selection of conversion time unit is in error\n"); - err++; - } /* if(ui_ConvertTimeBase!=2) */ - } else { - ui_ConvertTime = 0; - ui_ConvertTimeBase = 0; - } - if (cmd->scan_begin_src == TRIG_FOLLOW) { - ui_DelayTime = 0; - ui_DelayTimeBase = 0; - } /* if(cmd->scan_begin_src==TRIG_FOLLOW) */ - else { - ui_DelayTime = cmd->scan_begin_arg & 0xFFFF; - ui_DelayTimeBase = cmd->scan_begin_arg >> 16; - if (ui_DelayTimeBase != 2 && ui_DelayTimeBase != 3) { - err++; - printk("\nThe Delay time base selection is in error\n"); - } - if (ui_DelayTime < 1 || ui_DelayTime > 1023) { - err++; - printk("\nThe Delay time value is in error\n"); - } - if (err) { - apci3200_reset(dev); - return 3; - } - fpu_begin(); - d_SCANTimeNewUnit = (double)ui_DelayTime; - /* i_NbrOfChannel= i_LastChannel-i_FirstChannel + 4; */ - i_NbrOfChannel = - s_BoardInfos[dev->minor].i_LastChannel - - s_BoardInfos[dev->minor].i_FirstChannel + 4; - /**********************************************************/ - /*calculate the total conversion time for all the channels */ - /**********************************************************/ - d_ConversionTimeForAllChannels = - (double)((double)ui_ConvertTime / - (double)i_NbrOfChannel); - - /*******************************/ - /*Convert the frequence in time */ - /*******************************/ - d_ConversionTimeForAllChannels = - (double)1.0 / d_ConversionTimeForAllChannels; - ui_ConvertTimeBase = 3; - /***********************************/ - /*Test if the time unit is the same */ - /***********************************/ - - if (ui_DelayTimeBase <= ui_ConvertTimeBase) { - - for (i_Cpt = 0; - i_Cpt < (ui_ConvertTimeBase - ui_DelayTimeBase); - i_Cpt++) { - - d_ConversionTimeForAllChannels = - d_ConversionTimeForAllChannels * 1000; - d_ConversionTimeForAllChannels = - d_ConversionTimeForAllChannels + 1; - } - } else { - for (i_Cpt = 0; - i_Cpt < (ui_DelayTimeBase - ui_ConvertTimeBase); - i_Cpt++) { - d_SCANTimeNewUnit = d_SCANTimeNewUnit * 1000; - - } - } - - if (d_ConversionTimeForAllChannels >= d_SCANTimeNewUnit) { - - printk("\nSCAN Delay value cannot be used\n"); - /*********************************/ - /*SCAN Delay value cannot be used */ - /*********************************/ - err++; - } - fpu_end(); - } /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */ - - if (err) { - apci3200_reset(dev); - return 4; - } - - return 0; -} - -static int apci3200_cancel(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_Configuration = 0; - - /* i_InterruptFlag=0; */ - /* i_Initialised=0; */ - /* i_Count=0; */ - /* i_Sum=0; */ - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - s_BoardInfos[dev->minor].i_Initialised = 0; - s_BoardInfos[dev->minor].i_Count = 0; - s_BoardInfos[dev->minor].i_Sum = 0; - - /*******************/ - /*Read the register */ - /*******************/ - /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */ - ui_Configuration = - inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - /*****************************/ - /*Reset the START and IRQ bit */ - /*****************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl((ui_Configuration & 0xFFE7FFFF),devpriv->iobase+i_Offset + 8); */ - outl((ui_Configuration & 0xFFE7FFFF), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - return 0; -} - -/* - * Does asynchronous acquisition - * Determines the mode 1 or 2. - */ -static int apci3200_ai_cmd(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct addi_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - unsigned int ui_Configuration = 0; - /* INT i_CurrentSource = 0; */ - unsigned int ui_Trigger = 0; - unsigned int ui_TriggerEdge = 0; - unsigned int ui_Triggermode = 0; - unsigned int ui_ScanMode = 0; - unsigned int ui_ConvertTime = 0; - unsigned int ui_ConvertTimeBase = 0; - unsigned int ui_DelayTime = 0; - unsigned int ui_DelayTimeBase = 0; - unsigned int ui_DelayMode = 0; - - /* i_FirstChannel=cmd->chanlist[0]; */ - /* i_LastChannel=cmd->chanlist[1]; */ - s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0]; - s_BoardInfos[dev->minor].i_LastChannel = cmd->chanlist[1]; - if (cmd->start_src == TRIG_EXT) { - ui_Trigger = 1; - ui_TriggerEdge = cmd->start_arg & 0xFFFF; - ui_Triggermode = cmd->start_arg >> 16; - } /* if(cmd->start_src==TRIG_EXT) */ - else { - ui_Trigger = 0; - } /* elseif(cmd->start_src==TRIG_EXT) */ - - if (cmd->stop_src == TRIG_COUNT) { - ui_ScanMode = 0; - } /* if (cmd->stop_src==TRIG_COUNT) */ - else { - ui_ScanMode = 2; - } /* else if (cmd->stop_src==TRIG_COUNT) */ - - if (cmd->scan_begin_src == TRIG_FOLLOW) { - ui_DelayTime = 0; - ui_DelayTimeBase = 0; - ui_DelayMode = 0; - } /* if(cmd->scan_begin_src==TRIG_FOLLOW) */ - else { - ui_DelayTime = cmd->scan_begin_arg & 0xFFFF; - ui_DelayTimeBase = cmd->scan_begin_arg >> 16; - ui_DelayMode = 1; - } /* else if(cmd->scan_begin_src==TRIG_FOLLOW) */ - if (cmd->convert_src == TRIG_TIMER) { - ui_ConvertTime = cmd->convert_arg & 0xFFFF; - ui_ConvertTimeBase = cmd->convert_arg >> 16; - } else { - ui_ConvertTime = 0; - ui_ConvertTimeBase = 0; - } - - /* if(i_ADDIDATAType ==1 || ((i_ADDIDATAType==2))) */ - /* { */ - /**************************************************/ - /*Read the old configuration of the current source */ - /**************************************************/ - /* ui_Configuration = inl(devpriv->iobase+i_Offset + 12); */ - ui_Configuration = - inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - /***********************************************/ - /*Write the configuration of the current source */ - /***********************************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl((ui_Configuration & 0xFFC00000 ), devpriv->iobase+i_Offset +12); */ - outl((ui_Configuration & 0xFFC00000), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12); - /* } */ - ui_Configuration = 0; - - /* ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 | */ - ui_Configuration = - s_BoardInfos[dev->minor].i_FirstChannel | (s_BoardInfos[dev-> - minor]. - i_LastChannel << 8) | 0x00100000 | (ui_Trigger << 24) | - (ui_TriggerEdge << 25) | (ui_Triggermode << 27) | (ui_DelayMode - << 18) | (ui_ScanMode << 16); - - /*************************/ - /*Write the Configuration */ - /*************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl( ui_Configuration, devpriv->iobase+i_Offset + 0x8); */ - outl(ui_Configuration, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x8); - /***********************/ - /*Write the Delay Value */ - /***********************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_DelayTime,devpriv->iobase+i_Offset + 40); */ - outl(ui_DelayTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 40); - /***************************/ - /*Write the Delay time base */ - /***************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_DelayTimeBase,devpriv->iobase+i_Offset + 44); */ - outl(ui_DelayTimeBase, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 44); - /*********************************/ - /*Write the conversion time value */ - /*********************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_ConvertTime,devpriv->iobase+i_Offset + 32); */ - outl(ui_ConvertTime, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32); - - /********************************/ - /*Write the conversion time base */ - /********************************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl(ui_ConvertTimeBase,devpriv->iobase+i_Offset + 36); */ - outl(ui_ConvertTimeBase, - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36); - /*******************/ - /*Read the register */ - /*******************/ - /* ui_Configuration = inl(devpriv->iobase+i_Offset + 4); */ - ui_Configuration = - inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); - /******************/ - /*Set the SCAN bit */ - /******************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - - /* outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); */ - outl(((ui_Configuration & 0x1E0FF) | 0x00002000), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4); - /*******************/ - /*Read the register */ - /*******************/ - ui_Configuration = 0; - /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */ - ui_Configuration = - inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - - /*******************/ - /*Set the START bit */ - /*******************/ - /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */ - while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + - 12) >> 19) & 1) != 1) ; - /* outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); */ - outl((ui_Configuration | 0x00080000), - devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8); - return 0; -} - -/* - * This function copies the acquired data(from FIFO) to Comedi buffer. - */ -static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - unsigned int ui_StatusRegister = 0; - - /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* comedi_async *async = s->async; */ - /* UINT *data; */ - /* data=async->data+async->buf_int_ptr;//new samples added from here onwards */ - int n = 0, i = 0; - /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - - /************************************/ - /*Read the interrupt status register */ - /************************************/ - /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */ - ui_StatusRegister = - inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16); - - /*************************/ - /*Test if interrupt occur */ - /*************************/ - - if ((ui_StatusRegister & 0x2) == 0x2) { - /*************************/ - /*Read the channel number */ - /*************************/ - /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */ - /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* This value is not used */ - /* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); */ - /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - - /*************************************/ - /*Read the digital Analog Input value */ - /*************************************/ - - /* data[i_Count] = inl(devpriv->iobase+i_Offset + 28); */ - /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); */ - s_BoardInfos[dev->minor].ui_ScanValueArray[s_BoardInfos[dev-> - minor].i_Count] = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - - /* if((i_Count == (i_LastChannel-i_FirstChannel+3))) */ - if ((s_BoardInfos[dev->minor].i_Count == - (s_BoardInfos[dev->minor].i_LastChannel - - s_BoardInfos[dev->minor]. - i_FirstChannel + 3))) { - - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - s_BoardInfos[dev->minor].i_Count++; - - for (i = s_BoardInfos[dev->minor].i_FirstChannel; - i <= s_BoardInfos[dev->minor].i_LastChannel; - i++) { - i_APCI3200_GetChannelCalibrationValue(dev, i, - &s_BoardInfos[dev->minor]. - ui_ScanValueArray[s_BoardInfos[dev-> - minor].i_Count + ((i - - s_BoardInfos - [dev->minor]. - i_FirstChannel) - * 3)], - &s_BoardInfos[dev->minor]. - ui_ScanValueArray[s_BoardInfos[dev-> - minor].i_Count + ((i - - s_BoardInfos - [dev->minor]. - i_FirstChannel) - * 3) + 1], - &s_BoardInfos[dev->minor]. - ui_ScanValueArray[s_BoardInfos[dev-> - minor].i_Count + ((i - - s_BoardInfos - [dev->minor]. - i_FirstChannel) - * 3) + 2]); - } - - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - - /* i_Count=-1; */ - - s_BoardInfos[dev->minor].i_Count = -1; - - /* async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */ - /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */ - /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */ - /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */ - /* comedi_eos(dev,s); */ - - /* Set the event type (Comedi Buffer End Of Scan) */ - s->async->events |= COMEDI_CB_EOS; - - /* Test if enougth memory is available and allocate it for 7 values */ - n = comedi_buf_write_alloc(s, - (7 + 12) * sizeof(unsigned int)); - - /* If not enough memory available, event is set to Comedi Buffer Error */ - if (n > ((7 + 12) * sizeof(unsigned int))) { - printk("\ncomedi_buf_write_alloc n = %i", n); - s->async->events |= COMEDI_CB_ERROR; - } - /* Write all 7 scan values in the comedi buffer */ - comedi_buf_memcpy_to(s, 0, - (unsigned int *) s_BoardInfos[dev->minor]. - ui_ScanValueArray, (7 + 12) * sizeof(unsigned int)); - - /* Update comedi buffer pinters indexes */ - comedi_buf_write_free(s, - (7 + 12) * sizeof(unsigned int)); - - comedi_handle_events(dev, s); - /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - - /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - /* */ - /* if (s->async->buf_int_ptr>=s->async->data_len) // for buffer rool over */ - /* { */ - /* /* buffer rollover */ */ - /* s->async->buf_int_ptr=0; */ - /* comedi_eobuf(dev,s); */ - /* } */ - /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */ - } - /* i_Count++; */ - s_BoardInfos[dev->minor].i_Count++; - } - /* i_InterruptFlag=0; */ - s_BoardInfos[dev->minor].i_InterruptFlag = 0; - return 0; -} - -static void apci3200_interrupt(int irq, void *d) -{ - struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; - unsigned int ui_StatusRegister = 0; - unsigned int ui_ChannelNumber = 0; - int i_CalibrationFlag = 0; - int i_CJCFlag = 0; - unsigned int ui_DummyValue = 0; - unsigned int ui_DigitalTemperature = 0; - unsigned int ui_DigitalInput = 0; - int i_ConvertCJCCalibration; - /* BEGIN JK TEST */ - int i_ReturnValue = 0; - /* END JK TEST */ - - /* switch(i_ScanType) */ - switch (s_BoardInfos[dev->minor].i_ScanType) { - case 0: - case 1: - /* switch(i_ADDIDATAType) */ - switch (s_BoardInfos[dev->minor].i_ADDIDATAType) { - case 0: - case 1: - - /************************************/ - /*Read the interrupt status register */ - /************************************/ - /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */ - ui_StatusRegister = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 16); - if ((ui_StatusRegister & 0x2) == 0x2) { - /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */ - i_CalibrationFlag = - ((inl(devpriv->iobase + - s_BoardInfos[dev-> - minor]. - i_Offset + - 12) & 0x00060000) >> - 17); - /*************************/ - /*Read the channel number */ - /*************************/ - /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */ - - /*************************************/ - /*Read the digital analog input value */ - /*************************************/ - /* ui_DigitalInput = inl(devpriv->iobase+i_Offset + 28); */ - ui_DigitalInput = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - - /***********************************************/ - /* Test if the value read is the channel value */ - /***********************************************/ - if (i_CalibrationFlag == 0) { - /* ui_InterruptChannelValue[i_Count + 0] = ui_DigitalInput; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 0] = ui_DigitalInput; - - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - /* - i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num, - &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 6], - &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 7], - &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 8]); - */ - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - - /******************************************************/ - /*Start the conversion of the calibration offset value */ - /******************************************************/ - i_APCI3200_ReadCalibrationOffsetValue - (dev, &ui_DummyValue); - } /* if (i_CalibrationFlag == 0) */ - /**********************************************************/ - /* Test if the value read is the calibration offset value */ - /**********************************************************/ - - if (i_CalibrationFlag == 1) { - - /******************/ - /* Save the value */ - /******************/ - - /* ui_InterruptChannelValue[i_Count + 1] = ui_DigitalInput; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 1] = ui_DigitalInput; - - /******************************************************/ - /* Start the conversion of the calibration gain value */ - /******************************************************/ - i_APCI3200_ReadCalibrationGainValue(dev, - &ui_DummyValue); - } /* if (i_CalibrationFlag == 1) */ - /******************************************************/ - /*Test if the value read is the calibration gain value */ - /******************************************************/ - - if (i_CalibrationFlag == 2) { - - /****************/ - /*Save the value */ - /****************/ - /* ui_InterruptChannelValue[i_Count + 2] = ui_DigitalInput; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 2] = ui_DigitalInput; - /* if(i_ScanType==1) */ - if (s_BoardInfos[dev->minor]. - i_ScanType == 1) { - - /* i_InterruptFlag=0; */ - s_BoardInfos[dev->minor]. - i_InterruptFlag = 0; - /* i_Count=i_Count + 6; */ - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */ - s_BoardInfos[dev->minor]. - i_Count = - s_BoardInfos[dev-> - minor].i_Count + 9; - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - } /* if(i_ScanType==1) */ - else { - /* i_Count=0; */ - s_BoardInfos[dev->minor]. - i_Count = 0; - } /* elseif(i_ScanType==1) */ - /* if(i_ScanType!=1) */ - if (s_BoardInfos[dev->minor]. - i_ScanType != 1) { - i_ReturnValue = send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } /* if(i_ScanType!=1) */ - else { - /* if(i_ChannelCount==i_Sum) */ - if (s_BoardInfos[dev->minor]. - i_ChannelCount == - s_BoardInfos[dev-> - minor].i_Sum) { - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } - } /* if(i_ScanType!=1) */ - } /* if (i_CalibrationFlag == 2) */ - } /* if ((ui_StatusRegister & 0x2) == 0x2) */ - - break; - - case 2: - /************************************/ - /*Read the interrupt status register */ - /************************************/ - - /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */ - ui_StatusRegister = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 16); - /*************************/ - /*Test if interrupt occur */ - /*************************/ - - if ((ui_StatusRegister & 0x2) == 0x2) { - - /* i_CJCFlag = ((inl(devpriv->iobase+i_Offset + 4) & 0x00000400) >> 10); */ - i_CJCFlag = - ((inl(devpriv->iobase + - s_BoardInfos[dev-> - minor]. - i_Offset + - 4) & 0x00000400) >> 10); - - /* i_CalibrationFlag = ((inl(devpriv->iobase+i_Offset + 12) & 0x00060000) >> 17); */ - i_CalibrationFlag = - ((inl(devpriv->iobase + - s_BoardInfos[dev-> - minor]. - i_Offset + - 12) & 0x00060000) >> - 17); - - /*************************/ - /*Read the channel number */ - /*************************/ - - /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */ - ui_ChannelNumber = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 24); - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - s_BoardInfos[dev->minor].ui_Channel_num = - ui_ChannelNumber; - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - - /************************************/ - /*Read the digital temperature value */ - /************************************/ - /* ui_DigitalTemperature = inl(devpriv->iobase+i_Offset + 28); */ - ui_DigitalTemperature = - inl(devpriv->iobase + - s_BoardInfos[dev->minor].i_Offset + 28); - - /*********************************************/ - /*Test if the value read is the channel value */ - /*********************************************/ - - if ((i_CalibrationFlag == 0) - && (i_CJCFlag == 0)) { - /* ui_InterruptChannelValue[i_Count + 0]=ui_DigitalTemperature; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 0] = - ui_DigitalTemperature; - - /*********************************/ - /*Start the conversion of the CJC */ - /*********************************/ - i_APCI3200_ReadCJCValue(dev, - &ui_DummyValue); - - } /* if ((i_CalibrationFlag == 0) && (i_CJCFlag == 0)) */ - - /*****************************************/ - /*Test if the value read is the CJC value */ - /*****************************************/ - - if ((i_CJCFlag == 1) - && (i_CalibrationFlag == 0)) { - /* ui_InterruptChannelValue[i_Count + 3]=ui_DigitalTemperature; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 3] = - ui_DigitalTemperature; - - /******************************************************/ - /*Start the conversion of the calibration offset value */ - /******************************************************/ - i_APCI3200_ReadCalibrationOffsetValue - (dev, &ui_DummyValue); - } /* if ((i_CJCFlag == 1) && (i_CalibrationFlag == 0)) */ - - /********************************************************/ - /*Test if the value read is the calibration offset value */ - /********************************************************/ - - if ((i_CalibrationFlag == 1) - && (i_CJCFlag == 0)) { - /* ui_InterruptChannelValue[i_Count + 1]=ui_DigitalTemperature; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 1] = - ui_DigitalTemperature; - - /****************************************************/ - /*Start the conversion of the calibration gain value */ - /****************************************************/ - i_APCI3200_ReadCalibrationGainValue(dev, - &ui_DummyValue); - - } /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 0)) */ - - /******************************************************/ - /*Test if the value read is the calibration gain value */ - /******************************************************/ - - if ((i_CalibrationFlag == 2) - && (i_CJCFlag == 0)) { - /* ui_InterruptChannelValue[i_Count + 2]=ui_DigitalTemperature; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 2] = - ui_DigitalTemperature; - - /**********************************************************/ - /*Test if the Calibration channel must be read for the CJC */ - /**********************************************************/ - - /*Test if the polarity is the same */ - /**********************************/ - /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ - if (s_BoardInfos[dev->minor]. - i_CJCPolarity != - s_BoardInfos[dev->minor]. - i_ADDIDATAPolarity) { - i_ConvertCJCCalibration = 1; - } /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */ - else { - /* if(i_CJCGain==i_ADDIDATAGain) */ - if (s_BoardInfos[dev->minor]. - i_CJCGain == - s_BoardInfos[dev-> - minor]. - i_ADDIDATAGain) { - i_ConvertCJCCalibration - = 0; - } /* if(i_CJCGain==i_ADDIDATAGain) */ - else { - i_ConvertCJCCalibration - = 1; - } /* elseif(i_CJCGain==i_ADDIDATAGain) */ - } /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */ - if (i_ConvertCJCCalibration == 1) { - /****************************************************************/ - /*Start the conversion of the calibration gain value for the CJC */ - /****************************************************************/ - i_APCI3200_ReadCJCCalOffset(dev, - &ui_DummyValue); - - } /* if(i_ConvertCJCCalibration==1) */ - else { - /* ui_InterruptChannelValue[i_Count + 4]=0; */ - /* ui_InterruptChannelValue[i_Count + 5]=0; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev-> - minor].i_Count + - 4] = 0; - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev-> - minor].i_Count + - 5] = 0; - } /* elseif(i_ConvertCJCCalibration==1) */ - } /* else if ((i_CalibrationFlag == 2) && (i_CJCFlag == 0)) */ - - /********************************************************************/ - /*Test if the value read is the calibration offset value for the CJC */ - /********************************************************************/ - - if ((i_CalibrationFlag == 1) - && (i_CJCFlag == 1)) { - /* ui_InterruptChannelValue[i_Count + 4]=ui_DigitalTemperature; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 4] = - ui_DigitalTemperature; - - /****************************************************************/ - /*Start the conversion of the calibration gain value for the CJC */ - /****************************************************************/ - i_APCI3200_ReadCJCCalGain(dev, - &ui_DummyValue); - - } /* if ((i_CalibrationFlag == 1) && (i_CJCFlag == 1)) */ - - /******************************************************************/ - /*Test if the value read is the calibration gain value for the CJC */ - /******************************************************************/ - - if ((i_CalibrationFlag == 2) - && (i_CJCFlag == 1)) { - /* ui_InterruptChannelValue[i_Count + 5]=ui_DigitalTemperature; */ - s_BoardInfos[dev->minor]. - ui_InterruptChannelValue - [s_BoardInfos[dev->minor]. - i_Count + 5] = - ui_DigitalTemperature; - - /* if(i_ScanType==1) */ - if (s_BoardInfos[dev->minor]. - i_ScanType == 1) { - - /* i_InterruptFlag=0; */ - s_BoardInfos[dev->minor]. - i_InterruptFlag = 0; - /* i_Count=i_Count + 6; */ - /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count + 6; */ - s_BoardInfos[dev->minor]. - i_Count = - s_BoardInfos[dev-> - minor].i_Count + 9; - /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */ - } /* if(i_ScanType==1) */ - else { - /* i_Count=0; */ - s_BoardInfos[dev->minor]. - i_Count = 0; - } /* elseif(i_ScanType==1) */ - - /* if(i_ScanType!=1) */ - if (s_BoardInfos[dev->minor]. - i_ScanType != 1) { - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } /* if(i_ScanType!=1) */ - else { - /* if(i_ChannelCount==i_Sum) */ - if (s_BoardInfos[dev->minor]. - i_ChannelCount == - s_BoardInfos[dev-> - minor].i_Sum) { - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - - } /* if(i_ChannelCount==i_Sum) */ - } /* else if(i_ScanType!=1) */ - } /* if ((i_CalibrationFlag == 2) && (i_CJCFlag == 1)) */ - - } /* else if ((ui_StatusRegister & 0x2) == 0x2) */ - break; - } /* switch(i_ADDIDATAType) */ - break; - case 2: - case 3: - i_APCI3200_InterruptHandleEos(dev); - break; - } /* switch(i_ScanType) */ - return; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_3200.c b/drivers/staging/comedi/drivers/addi_apci_3200.c deleted file mode 100644 index fe6897eff3db..000000000000 --- a/drivers/staging/comedi/drivers/addi_apci_3200.c +++ /dev/null @@ -1,125 +0,0 @@ -#include -#include - -#include - -#include "../comedidev.h" -#include "comedi_fc.h" -#include "amcc_s5933.h" - -#include "addi-data/addi_common.h" - -static void fpu_begin(void) -{ - kernel_fpu_begin(); -} - -static void fpu_end(void) -{ - kernel_fpu_end(); -} - -#include "addi-data/addi_eeprom.c" -#include "addi-data/hwdrv_apci3200.c" -#include "addi-data/addi_common.c" - -enum apci3200_boardid { - BOARD_APCI3200, - BOARD_APCI3300, -}; - -static const struct addi_board apci3200_boardtypes[] = { - [BOARD_APCI3200] = { - .pc_DriverName = "apci3200", - .i_IorangeBase1 = 256, - .i_PCIEeprom = 1, - .pc_EepromChip = "S5920", - .i_NbrAiChannel = 16, - .i_NbrAiChannelDiff = 8, - .i_AiChannelList = 16, - .i_AiMaxdata = 0x3ffff, - .pr_AiRangelist = &range_apci3200_ai, - .i_NbrDiChannel = 4, - .i_NbrDoChannel = 4, - .ui_MinAcquisitiontimeNs = 10000, - .ui_MinDelaytimeNs = 100000, - .interrupt = apci3200_interrupt, - .reset = apci3200_reset, - .ai_config = apci3200_ai_config, - .ai_read = apci3200_ai_read, - .ai_write = apci3200_ai_write, - .ai_bits = apci3200_ai_bits_test, - .ai_cmdtest = apci3200_ai_cmdtest, - .ai_cmd = apci3200_ai_cmd, - .ai_cancel = apci3200_cancel, - .di_bits = apci3200_di_insn_bits, - .do_bits = apci3200_do_insn_bits, - }, - [BOARD_APCI3300] = { - .pc_DriverName = "apci3300", - .i_IorangeBase1 = 256, - .i_PCIEeprom = 1, - .pc_EepromChip = "S5920", - .i_NbrAiChannelDiff = 8, - .i_AiChannelList = 8, - .i_AiMaxdata = 0x3ffff, - .pr_AiRangelist = &range_apci3300_ai, - .i_NbrDiChannel = 4, - .i_NbrDoChannel = 4, - .ui_MinAcquisitiontimeNs = 10000, - .ui_MinDelaytimeNs = 100000, - .interrupt = apci3200_interrupt, - .reset = apci3200_reset, - .ai_config = apci3200_ai_config, - .ai_read = apci3200_ai_read, - .ai_write = apci3200_ai_write, - .ai_bits = apci3200_ai_bits_test, - .ai_cmdtest = apci3200_ai_cmdtest, - .ai_cmd = apci3200_ai_cmd, - .ai_cancel = apci3200_cancel, - .di_bits = apci3200_di_insn_bits, - .do_bits = apci3200_do_insn_bits, - }, -}; - -static int apci3200_auto_attach(struct comedi_device *dev, - unsigned long context) -{ - const struct addi_board *board = NULL; - - if (context < ARRAY_SIZE(apci3200_boardtypes)) - board = &apci3200_boardtypes[context]; - if (!board) - return -ENODEV; - dev->board_ptr = board; - - return addi_auto_attach(dev, context); -} - -static struct comedi_driver apci3200_driver = { - .driver_name = "addi_apci_3200", - .module = THIS_MODULE, - .auto_attach = apci3200_auto_attach, - .detach = i_ADDI_Detach, -}; - -static int apci3200_pci_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - return comedi_pci_auto_config(dev, &apci3200_driver, id->driver_data); -} - -static const struct pci_device_id apci3200_pci_table[] = { - { PCI_VDEVICE(ADDIDATA, 0x3000), BOARD_APCI3200 }, - { PCI_VDEVICE(ADDIDATA, 0x3007), BOARD_APCI3300 }, - { 0 } -}; -MODULE_DEVICE_TABLE(pci, apci3200_pci_table); - -static struct pci_driver apci3200_pci_driver = { - .name = "addi_apci_3200", - .id_table = apci3200_pci_table, - .probe = apci3200_pci_probe, - .remove = comedi_pci_auto_unconfig, -}; -module_comedi_pci_driver(apci3200_driver, apci3200_pci_driver); -- cgit v1.2.3-59-g8ed1b From 6a9c41990da91566733e559b6af8286a902a16e0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:17 -0700 Subject: staging: comedi: addi_common.c: remove i_ADDI_Detach() The addi_apci_035 and addi_apci_1500 are the only drivers left that use this function in addi_common.c. Remove the function an add a private comedi_driver (*detach) function to those drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.c | 7 ------- drivers/staging/comedi/drivers/addi_apci_035.c | 9 ++++++++- drivers/staging/comedi/drivers/addi_apci_1500.c | 9 ++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index 2e7fb218340f..51574a8d027a 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -265,10 +265,3 @@ static int addi_auto_attach(struct comedi_device *dev, i_ADDI_Reset(dev); return 0; } - -static void i_ADDI_Detach(struct comedi_device *dev) -{ - if (dev->iobase) - i_ADDI_Reset(dev); - comedi_pci_detach(dev); -} diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index af70c8401880..b06fde1d6c39 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -45,11 +45,18 @@ static int apci035_auto_attach(struct comedi_device *dev, return addi_auto_attach(dev, context); } +static void apci035_detach(struct comedi_device *dev) +{ + if (dev->iobase) + i_ADDI_Reset(dev); + comedi_pci_detach(dev); +} + static struct comedi_driver apci035_driver = { .driver_name = "addi_apci_035", .module = THIS_MODULE, .auto_attach = apci035_auto_attach, - .detach = i_ADDI_Detach, + .detach = apci035_detach, }; static int apci035_pci_probe(struct pci_dev *dev, diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index b7a284ac6649..50a147fc38bf 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -44,11 +44,18 @@ static int apci1500_auto_attach(struct comedi_device *dev, return addi_auto_attach(dev, context); } +static void apci1500_detach(struct comedi_device *dev) +{ + if (dev->iobase) + i_ADDI_Reset(dev); + comedi_pci_detach(dev); +} + static struct comedi_driver apci1500_driver = { .driver_name = "addi_apci_1500", .module = THIS_MODULE, .auto_attach = apci1500_auto_attach, - .detach = i_ADDI_Detach, + .detach = apci1500_detach, }; static int apci1500_pci_probe(struct pci_dev *dev, -- cgit v1.2.3-59-g8ed1b From 5b1ccca7276d49daa3546dabebc5cdbb63c8d21d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:18 -0700 Subject: staging: comedi: addi_common.c: remove i_ADDI_Reset() The addi_apci_035 and addi_apci_1500 are the only drivers left that use this function in addi_common.c. The function simply calls the 'reset' function that is in the boardinfo of the driver. Both drivers use the same 'reset' function for all boardnfo entries. Remove the i_ADDI_Reset() function as well as the 'reset' boardinfo and just call the 'reset' function directly. The i_ADDI_Reset() is called by addi_auto_attach() in addi_common.c after a sucessful attach. Modify the (*auto_attach) in the drivers to call the 'reset' function directly and remove it from addi_auto_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.c | 9 --------- drivers/staging/comedi/drivers/addi_apci_035.c | 13 ++++++++++--- drivers/staging/comedi/drivers/addi_apci_1500.c | 13 ++++++++++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index 51574a8d027a..d0bd8127d52c 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -65,14 +65,6 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d) return IRQ_RETVAL(1); } -static int i_ADDI_Reset(struct comedi_device *dev) -{ - const struct addi_board *this_board = dev->board_ptr; - - this_board->reset(dev); - return 0; -} - static int addi_auto_attach(struct comedi_device *dev, unsigned long context_unused) { @@ -262,6 +254,5 @@ static int addi_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - i_ADDI_Reset(dev); return 0; } diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index b06fde1d6c39..dd28adb00e3d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -28,7 +28,6 @@ static const struct addi_board apci035_boardtypes[] = { .ui_MinAcquisitiontimeNs = 10000, .ui_MinDelaytimeNs = 100000, .interrupt = apci035_interrupt, - .reset = apci035_reset, .ai_config = apci035_ai_config, .ai_read = apci035_ai_read, .timer_config = apci035_timer_config, @@ -40,15 +39,23 @@ static const struct addi_board apci035_boardtypes[] = { static int apci035_auto_attach(struct comedi_device *dev, unsigned long context) { + int ret; + dev->board_ptr = &apci035_boardtypes[0]; - return addi_auto_attach(dev, context); + ret = addi_auto_attach(dev, context); + if (ret) + return ret; + + apci035_reset(dev); + + return 0; } static void apci035_detach(struct comedi_device *dev) { if (dev->iobase) - i_ADDI_Reset(dev); + apci035_reset(dev); comedi_pci_detach(dev); } diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 50a147fc38bf..d4b42618859e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -21,7 +21,6 @@ static const struct addi_board apci1500_boardtypes[] = { .i_DoMaxdata = 0xffff, .i_Timer = 1, .interrupt = apci1500_interrupt, - .reset = apci1500_reset, .di_config = apci1500_di_config, .di_read = apci1500_di_read, .di_write = apci1500_di_write, @@ -39,15 +38,23 @@ static const struct addi_board apci1500_boardtypes[] = { static int apci1500_auto_attach(struct comedi_device *dev, unsigned long context) { + int ret; + dev->board_ptr = &apci1500_boardtypes[0]; - return addi_auto_attach(dev, context); + ret = addi_auto_attach(dev, context); + if (ret) + return ret; + + apci1500_reset(dev); + + return 0; } static void apci1500_detach(struct comedi_device *dev) { if (dev->iobase) - i_ADDI_Reset(dev); + apci1500_reset(dev); comedi_pci_detach(dev); } -- cgit v1.2.3-59-g8ed1b From 3c3dcdd7eb6c4353620392c27965cf14a4231c62 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:19 -0700 Subject: staging: comedi: addi_common.c: remove addi_auto_attach() The addi_apci_035 and addi_apci_1500 are the only drivers left that use this function in addi_common.c. The addi_common code adds a lot of bloat to the drivers. Copy the addi_auto_attach() code to the (*auto_attach) functions of the drivers and remove the function. This will help with removing the bloat. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.c | 192 --------------------- drivers/staging/comedi/drivers/addi_apci_035.c | 180 ++++++++++++++++++- drivers/staging/comedi/drivers/addi_apci_1500.c | 180 ++++++++++++++++++- 3 files changed, 358 insertions(+), 194 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index d0bd8127d52c..850bdae48243 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -64,195 +64,3 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d) this_board->interrupt(irq, d); return IRQ_RETVAL(1); } - -static int addi_auto_attach(struct comedi_device *dev, - unsigned long context_unused) -{ - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv; - struct comedi_subdevice *s; - int ret, n_subdevices; - unsigned int dw_Dummy; - - dev->board_name = this_board->pc_DriverName; - - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - - ret = comedi_pci_enable(dev); - if (ret) - return ret; - - if (this_board->i_IorangeBase1) - dev->iobase = pci_resource_start(pcidev, 1); - else - dev->iobase = pci_resource_start(pcidev, 0); - - devpriv->iobase = dev->iobase; - devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); - devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); - devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); - - /* Initialize parameters that can be overridden in EEPROM */ - devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; - devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; - devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; - devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; - devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; - devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; - devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; - devpriv->s_EeParameters.i_Timer = this_board->i_Timer; - devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = - this_board->ui_MinAcquisitiontimeNs; - devpriv->s_EeParameters.ui_MinDelaytimeNs = - this_board->ui_MinDelaytimeNs; - - /* ## */ - - if (pcidev->irq > 0) { - ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, - dev->board_name, dev); - if (ret == 0) - dev->irq = pcidev->irq; - } - - /* Read eepeom and fill addi_board Structure */ - - if (this_board->i_PCIEeprom) { - if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { - /* Set 3 wait stait */ - if (!(strcmp(dev->board_name, "apci035"))) - outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - else - outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); - outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - } - addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); - } - - n_subdevices = 7; - ret = comedi_alloc_subdevices(dev, n_subdevices); - if (ret) - return ret; - - /* Allocate and Initialise AI Subdevice Structures */ - s = &dev->subdevices[0]; - if ((devpriv->s_EeParameters.i_NbrAiChannel) - || (this_board->i_NbrAiChannelDiff)) { - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = - SDF_READABLE | SDF_COMMON | SDF_GROUND - | SDF_DIFF; - if (devpriv->s_EeParameters.i_NbrAiChannel) - s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel; - else - s->n_chan = this_board->i_NbrAiChannelDiff; - s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; - s->len_chanlist = this_board->i_AiChannelList; - s->range_table = this_board->pr_AiRangelist; - - s->insn_config = this_board->ai_config; - s->insn_read = this_board->ai_read; - s->insn_write = this_board->ai_write; - s->insn_bits = this_board->ai_bits; - s->do_cmdtest = this_board->ai_cmdtest; - s->do_cmd = this_board->ai_cmd; - s->cancel = this_board->ai_cancel; - - } else { - s->type = COMEDI_SUBD_UNUSED; - } - - /* Allocate and Initialise AO Subdevice Structures */ - s = &dev->subdevices[1]; - if (devpriv->s_EeParameters.i_NbrAoChannel) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; - s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrAoChannel; - s->insn_write = this_board->ao_write; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - /* Allocate and Initialise DI Subdevice Structures */ - s = &dev->subdevices[2]; - if (devpriv->s_EeParameters.i_NbrDiChannel) { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; - s->maxdata = 1; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDiChannel; - s->range_table = &range_digital; - s->insn_config = this_board->di_config; - s->insn_read = this_board->di_read; - s->insn_write = this_board->di_write; - s->insn_bits = this_board->di_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - /* Allocate and Initialise DO Subdevice Structures */ - s = &dev->subdevices[3]; - if (devpriv->s_EeParameters.i_NbrDoChannel) { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; - s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDoChannel; - s->range_table = &range_digital; - - /* insn_config - for digital output memory */ - s->insn_config = this_board->do_config; - s->insn_write = this_board->do_write; - s->insn_bits = this_board->do_bits; - s->insn_read = this_board->do_read; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - - /* Allocate and Initialise Timer Subdevice Structures */ - s = &dev->subdevices[4]; - if (devpriv->s_EeParameters.i_Timer) { - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 1; - s->maxdata = 0; - s->len_chanlist = 1; - s->range_table = &range_digital; - - s->insn_write = this_board->timer_write; - s->insn_read = this_board->timer_read; - s->insn_config = this_board->timer_config; - s->insn_bits = this_board->timer_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - - /* Allocate and Initialise TTL */ - s = &dev->subdevices[5]; - s->type = COMEDI_SUBD_UNUSED; - - /* EEPROM */ - s = &dev->subdevices[6]; - if (this_board->i_PCIEeprom) { - s->type = COMEDI_SUBD_MEMORY; - s->subdev_flags = SDF_READABLE | SDF_INTERNAL; - s->n_chan = 256; - s->maxdata = 0xffff; - s->insn_read = i_ADDIDATA_InsnReadEeprom; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - - return 0; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index dd28adb00e3d..4f068c2e6a70 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -39,14 +39,192 @@ static const struct addi_board apci035_boardtypes[] = { static int apci035_auto_attach(struct comedi_device *dev, unsigned long context) { + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + const struct addi_board *this_board = dev->board_ptr; + struct addi_private *devpriv; + struct comedi_subdevice *s; + unsigned int dw_Dummy; int ret; dev->board_ptr = &apci035_boardtypes[0]; + dev->board_name = this_board->pc_DriverName; - ret = addi_auto_attach(dev, context); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + + ret = comedi_pci_enable(dev); if (ret) return ret; + if (this_board->i_IorangeBase1) + dev->iobase = pci_resource_start(pcidev, 1); + else + dev->iobase = pci_resource_start(pcidev, 0); + + devpriv->iobase = dev->iobase; + devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); + devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); + devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); + + /* Initialize parameters that can be overridden in EEPROM */ + devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; + devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; + devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; + devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; + devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; + devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; + devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; + devpriv->s_EeParameters.i_Timer = this_board->i_Timer; + devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = + this_board->ui_MinAcquisitiontimeNs; + devpriv->s_EeParameters.ui_MinDelaytimeNs = + this_board->ui_MinDelaytimeNs; + + /* ## */ + + if (pcidev->irq > 0) { + ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, + dev->board_name, dev); + if (ret == 0) + dev->irq = pcidev->irq; + } + + /* Read eepeom and fill addi_board Structure */ + + if (this_board->i_PCIEeprom) { + if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { + /* Set 3 wait stait */ + if (!(strcmp(dev->board_name, "apci035"))) + outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); + else + outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); + + /* Enable the interrupt for the controller */ + dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); + outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); + } + addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); + } + + ret = comedi_alloc_subdevices(dev, 7); + if (ret) + return ret; + + /* Allocate and Initialise AI Subdevice Structures */ + s = &dev->subdevices[0]; + if ((devpriv->s_EeParameters.i_NbrAiChannel) + || (this_board->i_NbrAiChannelDiff)) { + dev->read_subdev = s; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = + SDF_READABLE | SDF_COMMON | SDF_GROUND + | SDF_DIFF; + if (devpriv->s_EeParameters.i_NbrAiChannel) + s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel; + else + s->n_chan = this_board->i_NbrAiChannelDiff; + s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; + s->len_chanlist = this_board->i_AiChannelList; + s->range_table = this_board->pr_AiRangelist; + + s->insn_config = this_board->ai_config; + s->insn_read = this_board->ai_read; + s->insn_write = this_board->ai_write; + s->insn_bits = this_board->ai_bits; + s->do_cmdtest = this_board->ai_cmdtest; + s->do_cmd = this_board->ai_cmd; + s->cancel = this_board->ai_cancel; + + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise AO Subdevice Structures */ + s = &dev->subdevices[1]; + if (devpriv->s_EeParameters.i_NbrAoChannel) { + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; + s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrAoChannel; + s->insn_write = this_board->ao_write; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + /* Allocate and Initialise DI Subdevice Structures */ + s = &dev->subdevices[2]; + if (devpriv->s_EeParameters.i_NbrDiChannel) { + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; + s->maxdata = 1; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrDiChannel; + s->range_table = &range_digital; + s->insn_config = this_board->di_config; + s->insn_read = this_board->di_read; + s->insn_write = this_board->di_write; + s->insn_bits = this_board->di_bits; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + /* Allocate and Initialise DO Subdevice Structures */ + s = &dev->subdevices[3]; + if (devpriv->s_EeParameters.i_NbrDoChannel) { + s->type = COMEDI_SUBD_DO; + s->subdev_flags = + SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; + s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrDoChannel; + s->range_table = &range_digital; + + /* insn_config - for digital output memory */ + s->insn_config = this_board->do_config; + s->insn_write = this_board->do_write; + s->insn_bits = this_board->do_bits; + s->insn_read = this_board->do_read; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise Timer Subdevice Structures */ + s = &dev->subdevices[4]; + if (devpriv->s_EeParameters.i_Timer) { + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + + s->insn_write = this_board->timer_write; + s->insn_read = this_board->timer_read; + s->insn_config = this_board->timer_config; + s->insn_bits = this_board->timer_bits; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise TTL */ + s = &dev->subdevices[5]; + s->type = COMEDI_SUBD_UNUSED; + + /* EEPROM */ + s = &dev->subdevices[6]; + if (this_board->i_PCIEeprom) { + s->type = COMEDI_SUBD_MEMORY; + s->subdev_flags = SDF_READABLE | SDF_INTERNAL; + s->n_chan = 256; + s->maxdata = 0xffff; + s->insn_read = i_ADDIDATA_InsnReadEeprom; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + apci035_reset(dev); return 0; diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index d4b42618859e..a4a0dab85d6a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -38,14 +38,192 @@ static const struct addi_board apci1500_boardtypes[] = { static int apci1500_auto_attach(struct comedi_device *dev, unsigned long context) { + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + const struct addi_board *this_board = dev->board_ptr; + struct addi_private *devpriv; + struct comedi_subdevice *s; + unsigned int dw_Dummy; int ret; dev->board_ptr = &apci1500_boardtypes[0]; + dev->board_name = this_board->pc_DriverName; - ret = addi_auto_attach(dev, context); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + + ret = comedi_pci_enable(dev); if (ret) return ret; + if (this_board->i_IorangeBase1) + dev->iobase = pci_resource_start(pcidev, 1); + else + dev->iobase = pci_resource_start(pcidev, 0); + + devpriv->iobase = dev->iobase; + devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); + devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); + devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); + + /* Initialize parameters that can be overridden in EEPROM */ + devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; + devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; + devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; + devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; + devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; + devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; + devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; + devpriv->s_EeParameters.i_Timer = this_board->i_Timer; + devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = + this_board->ui_MinAcquisitiontimeNs; + devpriv->s_EeParameters.ui_MinDelaytimeNs = + this_board->ui_MinDelaytimeNs; + + /* ## */ + + if (pcidev->irq > 0) { + ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, + dev->board_name, dev); + if (ret == 0) + dev->irq = pcidev->irq; + } + + /* Read eepeom and fill addi_board Structure */ + + if (this_board->i_PCIEeprom) { + if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { + /* Set 3 wait stait */ + if (!(strcmp(dev->board_name, "apci035"))) + outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); + else + outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); + + /* Enable the interrupt for the controller */ + dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); + outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); + } + addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); + } + + ret = comedi_alloc_subdevices(dev, 7); + if (ret) + return ret; + + /* Allocate and Initialise AI Subdevice Structures */ + s = &dev->subdevices[0]; + if ((devpriv->s_EeParameters.i_NbrAiChannel) + || (this_board->i_NbrAiChannelDiff)) { + dev->read_subdev = s; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = + SDF_READABLE | SDF_COMMON | SDF_GROUND + | SDF_DIFF; + if (devpriv->s_EeParameters.i_NbrAiChannel) + s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel; + else + s->n_chan = this_board->i_NbrAiChannelDiff; + s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; + s->len_chanlist = this_board->i_AiChannelList; + s->range_table = this_board->pr_AiRangelist; + + s->insn_config = this_board->ai_config; + s->insn_read = this_board->ai_read; + s->insn_write = this_board->ai_write; + s->insn_bits = this_board->ai_bits; + s->do_cmdtest = this_board->ai_cmdtest; + s->do_cmd = this_board->ai_cmd; + s->cancel = this_board->ai_cancel; + + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise AO Subdevice Structures */ + s = &dev->subdevices[1]; + if (devpriv->s_EeParameters.i_NbrAoChannel) { + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; + s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrAoChannel; + s->insn_write = this_board->ao_write; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + /* Allocate and Initialise DI Subdevice Structures */ + s = &dev->subdevices[2]; + if (devpriv->s_EeParameters.i_NbrDiChannel) { + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; + s->maxdata = 1; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrDiChannel; + s->range_table = &range_digital; + s->insn_config = this_board->di_config; + s->insn_read = this_board->di_read; + s->insn_write = this_board->di_write; + s->insn_bits = this_board->di_bits; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + /* Allocate and Initialise DO Subdevice Structures */ + s = &dev->subdevices[3]; + if (devpriv->s_EeParameters.i_NbrDoChannel) { + s->type = COMEDI_SUBD_DO; + s->subdev_flags = + SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; + s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrDoChannel; + s->range_table = &range_digital; + + /* insn_config - for digital output memory */ + s->insn_config = this_board->do_config; + s->insn_write = this_board->do_write; + s->insn_bits = this_board->do_bits; + s->insn_read = this_board->do_read; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise Timer Subdevice Structures */ + s = &dev->subdevices[4]; + if (devpriv->s_EeParameters.i_Timer) { + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + + s->insn_write = this_board->timer_write; + s->insn_read = this_board->timer_read; + s->insn_config = this_board->timer_config; + s->insn_bits = this_board->timer_bits; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise TTL */ + s = &dev->subdevices[5]; + s->type = COMEDI_SUBD_UNUSED; + + /* EEPROM */ + s = &dev->subdevices[6]; + if (this_board->i_PCIEeprom) { + s->type = COMEDI_SUBD_MEMORY; + s->subdev_flags = SDF_READABLE | SDF_INTERNAL; + s->n_chan = 256; + s->maxdata = 0xffff; + s->insn_read = i_ADDIDATA_InsnReadEeprom; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + apci1500_reset(dev); return 0; -- cgit v1.2.3-59-g8ed1b From 6c76d4e778a05c86f463a5bee3e2b06a9cc4396a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:20 -0700 Subject: staging: comedi: addi_common.c: remove v_ADDI_Interrupt() The addi_apci_035 and addi_apci_1500 are the only drivers left that use this function in addi_common.c. The function simply calls the 'interrupt' function that is in the boardinfo of the driver. Both drivers use the same 'interrupt' function for all boardnfo entries. Remove the i_ADDI_Reset() function as well as the 'interrupt' boardinfo and use the 'interrupt' function directly when doing the request_irq(). In addition, the addi_apci_3120 driver has a private v_ADDI_Interrupt() function that is doing the same thing. Remove that one as well. Fix the return type of 'interrupt' functions in the drivers and add the return vaules. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.c | 9 --------- drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c | 4 +++- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c | 4 +++- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 6 ++++-- drivers/staging/comedi/drivers/addi_apci_035.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_1500.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_3120.c | 13 +------------ 7 files changed, 13 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index 850bdae48243..014342748765 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -55,12 +55,3 @@ static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, return insn->n; } - -static irqreturn_t v_ADDI_Interrupt(int irq, void *d) -{ - struct comedi_device *dev = d; - const struct addi_board *this_board = dev->board_ptr; - - this_board->interrupt(irq, d); - return IRQ_RETVAL(1); -} diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index 53bb51bd77b5..a07ee1bd3311 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -434,7 +434,7 @@ static int apci035_reset(struct comedi_device *dev) return 0; } -static void apci035_interrupt(int irq, void *d) +static irqreturn_t apci035_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct addi_private *devpriv = dev->private; @@ -477,4 +477,6 @@ static void apci035_interrupt(int irq, void *d) /* send signal to the sample */ send_sig(SIGIO, devpriv->tsk_Current, 0); } + + return IRQ_HANDLED; } diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c index 0ea081e1e119..9896468d86f9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c @@ -2011,7 +2011,7 @@ static int apci1500_do_bits(struct comedi_device *dev, return insn->n; } -static void apci1500_interrupt(int irq, void *d) +static irqreturn_t apci1500_interrupt(int irq, void *d) { struct comedi_device *dev = d; @@ -2180,6 +2180,8 @@ static void apci1500_interrupt(int irq, void *d) "Interrupt from unknown source\n"); } + + return IRQ_HANDLED; } static int apci1500_reset(struct comedi_device *dev) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b06142b27df7..ed1d92ecc9ea 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1415,7 +1415,7 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) return 0; } -static void apci3120_interrupt(int irq, void *d) +static irqreturn_t apci3120_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct addi_private *devpriv = dev->private; @@ -1432,7 +1432,7 @@ static void apci3120_interrupt(int irq, void *d) if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) { dev_err(dev->class_dev, "IRQ from unknown source\n"); - return; + return IRQ_NONE; } outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */ @@ -1587,6 +1587,8 @@ static void apci3120_interrupt(int irq, void *d) } comedi_handle_events(dev, s); + + return IRQ_HANDLED; } /* diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index 4f068c2e6a70..a712cc522006 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -27,7 +27,6 @@ static const struct addi_board apci035_boardtypes[] = { .i_Timer = 1, .ui_MinAcquisitiontimeNs = 10000, .ui_MinDelaytimeNs = 100000, - .interrupt = apci035_interrupt, .ai_config = apci035_ai_config, .ai_read = apci035_ai_read, .timer_config = apci035_timer_config, @@ -84,7 +83,7 @@ static int apci035_auto_attach(struct comedi_device *dev, /* ## */ if (pcidev->irq > 0) { - ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, + ret = request_irq(pcidev->irq, apci035_interrupt, IRQF_SHARED, dev->board_name, dev); if (ret == 0) dev->irq = pcidev->irq; diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index a4a0dab85d6a..857ac9876467 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -20,7 +20,6 @@ static const struct addi_board apci1500_boardtypes[] = { .i_NbrDoChannel = 16, .i_DoMaxdata = 0xffff, .i_Timer = 1, - .interrupt = apci1500_interrupt, .di_config = apci1500_di_config, .di_read = apci1500_di_read, .di_write = apci1500_di_write, @@ -83,7 +82,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* ## */ if (pcidev->irq > 0) { - ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, + ret = request_irq(pcidev->irq, apci1500_interrupt, IRQF_SHARED, dev->board_name, dev); if (ret == 0) dev->irq = pcidev->irq; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ba71e24a56fd..38da44bd4eef 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -26,7 +26,6 @@ static const struct addi_board apci3120_boardtypes[] = { .i_NbrDiChannel = 4, .i_NbrDoChannel = 4, .i_DoMaxdata = 0x0f, - .interrupt = apci3120_interrupt, }, [BOARD_APCI3001] = { .pc_DriverName = "apci3001", @@ -37,19 +36,9 @@ static const struct addi_board apci3120_boardtypes[] = { .i_NbrDiChannel = 4, .i_NbrDoChannel = 4, .i_DoMaxdata = 0x0f, - .interrupt = apci3120_interrupt, }, }; -static irqreturn_t v_ADDI_Interrupt(int irq, void *d) -{ - struct comedi_device *dev = d; - const struct addi_board *this_board = dev->board_ptr; - - this_board->interrupt(irq, d); - return IRQ_RETVAL(1); -} - static int apci3120_auto_attach(struct comedi_device *dev, unsigned long context) { @@ -82,7 +71,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); if (pcidev->irq > 0) { - ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, + ret = request_irq(pcidev->irq, apci3120_interrupt, IRQF_SHARED, dev->board_name, dev); if (ret == 0) dev->irq = pcidev->irq; -- cgit v1.2.3-59-g8ed1b From f6a154c5c737013865f50c61367d30381a8584f5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:21 -0700 Subject: staging: comedi: addi_common.c: remove included source file The addi_apci_035 and addi_apci_1500 are the only drivers left that include this source file. Copy the i_ADDIDATA_InsnReadEeprom() function from that file to those drivers and remove the addi_common.c file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.c | 57 ---------------------- drivers/staging/comedi/drivers/addi_apci_035.c | 18 ++++++- drivers/staging/comedi/drivers/addi_apci_1500.c | 18 ++++++- 3 files changed, 34 insertions(+), 59 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_common.c diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c deleted file mode 100644 index 014342748765..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ /dev/null @@ -1,57 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstrasse 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : ADDI DATA | Compiler : GCC | - | Modulname : addi_common.c | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Author : | Date : | - +-----------------------------------------------------------------------+ - | Description : ADDI COMMON Main Module | - +-----------------------------------------------------------------------+ -*/ - -static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - unsigned short w_Address = CR_CHAN(insn->chanspec); - unsigned short w_Data; - - w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, - this_board->pc_EepromChip, 2 * w_Address); - data[0] = w_Data; - - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index a712cc522006..fd7d3f1d7205 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -11,7 +11,6 @@ #include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_apci035.c" -#include "addi-data/addi_common.c" static const struct addi_board apci035_boardtypes[] = { { @@ -35,6 +34,23 @@ static const struct addi_board apci035_boardtypes[] = { }, }; +static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + const struct addi_board *this_board = dev->board_ptr; + struct addi_private *devpriv = dev->private; + unsigned short w_Address = CR_CHAN(insn->chanspec); + unsigned short w_Data; + + w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, + this_board->pc_EepromChip, 2 * w_Address); + data[0] = w_Data; + + return insn->n; +} + static int apci035_auto_attach(struct comedi_device *dev, unsigned long context) { diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 857ac9876467..a68840e721a6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -9,7 +9,6 @@ #include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_apci1500.c" -#include "addi-data/addi_common.c" static const struct addi_board apci1500_boardtypes[] = { { @@ -34,6 +33,23 @@ static const struct addi_board apci1500_boardtypes[] = { }, }; +static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + const struct addi_board *this_board = dev->board_ptr; + struct addi_private *devpriv = dev->private; + unsigned short w_Address = CR_CHAN(insn->chanspec); + unsigned short w_Data; + + w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, + this_board->pc_EepromChip, 2 * w_Address); + data[0] = w_Data; + + return insn->n; +} + static int apci1500_auto_attach(struct comedi_device *dev, unsigned long context) { -- cgit v1.2.3-59-g8ed1b From 422b5353d013d7f9ebb2a6cfa9d3886776e68ea5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:22 -0700 Subject: staging: comedi: addi_apci_035: remove subdevice callbacks from boardinfo This driver only has one boardinfo entry so the subdevice callbacks are always the same. Remvoe the callbacks from the boardinfo and use them directly when initializing the subdevices. Remove all the subdevice callback initialization that would be set to NULL. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_035.c | 35 ++++---------------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index fd7d3f1d7205..c9cd68cc6101 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -26,11 +26,6 @@ static const struct addi_board apci035_boardtypes[] = { .i_Timer = 1, .ui_MinAcquisitiontimeNs = 10000, .ui_MinDelaytimeNs = 100000, - .ai_config = apci035_ai_config, - .ai_read = apci035_ai_read, - .timer_config = apci035_timer_config, - .timer_write = apci035_timer_write, - .timer_read = apci035_timer_read, }, }; @@ -142,15 +137,8 @@ static int apci035_auto_attach(struct comedi_device *dev, s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; s->len_chanlist = this_board->i_AiChannelList; s->range_table = this_board->pr_AiRangelist; - - s->insn_config = this_board->ai_config; - s->insn_read = this_board->ai_read; - s->insn_write = this_board->ai_write; - s->insn_bits = this_board->ai_bits; - s->do_cmdtest = this_board->ai_cmdtest; - s->do_cmd = this_board->ai_cmd; - s->cancel = this_board->ai_cancel; - + s->insn_config = apci035_ai_config; + s->insn_read = apci035_ai_read; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -164,7 +152,6 @@ static int apci035_auto_attach(struct comedi_device *dev, s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; s->len_chanlist = devpriv->s_EeParameters.i_NbrAoChannel; - s->insn_write = this_board->ao_write; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -178,10 +165,6 @@ static int apci035_auto_attach(struct comedi_device *dev, s->len_chanlist = devpriv->s_EeParameters.i_NbrDiChannel; s->range_table = &range_digital; - s->insn_config = this_board->di_config; - s->insn_read = this_board->di_read; - s->insn_write = this_board->di_write; - s->insn_bits = this_board->di_bits; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -196,12 +179,6 @@ static int apci035_auto_attach(struct comedi_device *dev, s->len_chanlist = devpriv->s_EeParameters.i_NbrDoChannel; s->range_table = &range_digital; - - /* insn_config - for digital output memory */ - s->insn_config = this_board->do_config; - s->insn_write = this_board->do_write; - s->insn_bits = this_board->do_bits; - s->insn_read = this_board->do_read; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -215,11 +192,9 @@ static int apci035_auto_attach(struct comedi_device *dev, s->maxdata = 0; s->len_chanlist = 1; s->range_table = &range_digital; - - s->insn_write = this_board->timer_write; - s->insn_read = this_board->timer_read; - s->insn_config = this_board->timer_config; - s->insn_bits = this_board->timer_bits; + s->insn_write = apci035_timer_write; + s->insn_read = apci035_timer_read; + s->insn_config = apci035_timer_config; } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From 4cab75b5557490d7beefc60c79947a9b4d82a8ed Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:23 -0700 Subject: staging: comedi: addi_apci_1500: remove subdevice callbacks from boardinfo This driver only has one boardinfo entry so the subdevice callbacks are always the same. Remvoe the callbacks from the boardinfo and use them directly when initializing the subdevices. Remove all the subdevice callback initialization that would be set to NULL. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 47 ++++++------------------- 1 file changed, 11 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index a68840e721a6..d6d2e67c5ba7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -19,17 +19,6 @@ static const struct addi_board apci1500_boardtypes[] = { .i_NbrDoChannel = 16, .i_DoMaxdata = 0xffff, .i_Timer = 1, - .di_config = apci1500_di_config, - .di_read = apci1500_di_read, - .di_write = apci1500_di_write, - .di_bits = apci1500_di_insn_bits, - .do_config = apci1500_do_config, - .do_write = apci1500_do_write, - .do_bits = apci1500_do_bits, - .timer_config = apci1500_timer_config, - .timer_write = apci1500_timer_write, - .timer_read = apci1500_timer_read, - .timer_bits = apci1500_timer_bits, }, }; @@ -141,15 +130,6 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; s->len_chanlist = this_board->i_AiChannelList; s->range_table = this_board->pr_AiRangelist; - - s->insn_config = this_board->ai_config; - s->insn_read = this_board->ai_read; - s->insn_write = this_board->ai_write; - s->insn_bits = this_board->ai_bits; - s->do_cmdtest = this_board->ai_cmdtest; - s->do_cmd = this_board->ai_cmd; - s->cancel = this_board->ai_cancel; - } else { s->type = COMEDI_SUBD_UNUSED; } @@ -163,7 +143,6 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; s->len_chanlist = devpriv->s_EeParameters.i_NbrAoChannel; - s->insn_write = this_board->ao_write; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -177,10 +156,10 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->len_chanlist = devpriv->s_EeParameters.i_NbrDiChannel; s->range_table = &range_digital; - s->insn_config = this_board->di_config; - s->insn_read = this_board->di_read; - s->insn_write = this_board->di_write; - s->insn_bits = this_board->di_bits; + s->insn_config = apci1500_di_config; + s->insn_read = apci1500_di_read; + s->insn_write = apci1500_di_write; + s->insn_bits = apci1500_di_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -195,12 +174,9 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->len_chanlist = devpriv->s_EeParameters.i_NbrDoChannel; s->range_table = &range_digital; - - /* insn_config - for digital output memory */ - s->insn_config = this_board->do_config; - s->insn_write = this_board->do_write; - s->insn_bits = this_board->do_bits; - s->insn_read = this_board->do_read; + s->insn_config = apci1500_do_config; + s->insn_write = apci1500_do_write; + s->insn_bits = apci1500_do_bits; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -214,11 +190,10 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->maxdata = 0; s->len_chanlist = 1; s->range_table = &range_digital; - - s->insn_write = this_board->timer_write; - s->insn_read = this_board->timer_read; - s->insn_config = this_board->timer_config; - s->insn_bits = this_board->timer_bits; + s->insn_write = apci1500_timer_write; + s->insn_read = apci1500_timer_read; + s->insn_config = apci1500_timer_config; + s->insn_bits = apci1500_timer_bits; } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From 1881c0f3b9b67bc9a836f19f5b3a2d521174ce66 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:24 -0700 Subject: staging: comedi: addi_common.h: remove subdevice callbacks from struct addi_board None of the drivers that still include this header use the subdevice callbacks. Remove all of them to reduce the bloat. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.h | 54 ---------------------- 1 file changed, 54 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index e2a3ffeee5cf..b757f460740a 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -38,60 +38,6 @@ struct addi_board { int i_Timer; /* timer subdevice present or not */ unsigned int ui_MinAcquisitiontimeNs; /* Minimum Acquisition in Nano secs */ unsigned int ui_MinDelaytimeNs; /* Minimum Delay in Nano secs */ - - /* interrupt and reset */ - void (*interrupt)(int irq, void *d); - int (*reset)(struct comedi_device *); - - /* Subdevice functions */ - - /* ANALOG INPUT */ - int (*ai_config)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*ai_read)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*ai_write)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*ai_bits)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*ai_cmdtest)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_cmd *); - int (*ai_cmd)(struct comedi_device *, struct comedi_subdevice *); - int (*ai_cancel)(struct comedi_device *, struct comedi_subdevice *); - - /* Analog Output */ - int (*ao_write)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - - /* Digital Input */ - int (*di_config)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*di_read)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*di_write)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*di_bits)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - - /* Digital Output */ - int (*do_config)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*do_write)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*do_bits)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*do_read)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - - /* TIMER */ - int (*timer_config)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*timer_write)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*timer_read)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - int (*timer_bits)(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); }; struct addi_private { -- cgit v1.2.3-59-g8ed1b From 8d3e0bf092309808f715fd703bed2719eb77b982 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:25 -0700 Subject: staging: comedi: addi_apci_035: remove unnecessary subdevice initialization The subdevices that don't initialize any of the callbacks don't really exist. Remove the unnecessary initialzation and just set the type to COMEDI_SUBD_UNUSED. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_035.c | 38 ++++---------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index c9cd68cc6101..f2cc95aaa8a2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -145,43 +145,15 @@ static int apci035_auto_attach(struct comedi_device *dev, /* Allocate and Initialise AO Subdevice Structures */ s = &dev->subdevices[1]; - if (devpriv->s_EeParameters.i_NbrAoChannel) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; - s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrAoChannel; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; + /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[2]; - if (devpriv->s_EeParameters.i_NbrDiChannel) { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; - s->maxdata = 1; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDiChannel; - s->range_table = &range_digital; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; + /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[3]; - if (devpriv->s_EeParameters.i_NbrDoChannel) { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; - s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDoChannel; - s->range_table = &range_digital; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[4]; -- cgit v1.2.3-59-g8ed1b From a6b5d2a272f7cecec3f01f0049bd26ccb61a6d23 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:26 -0700 Subject: staging: comedi: addi_apci_035: remove unused subdevices Only allocate space for the subdevicess used by the driver. Remove all the COMEDI_SUBD_UNUSED subdevices. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_035.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index f2cc95aaa8a2..3eeb244ef855 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -117,7 +117,7 @@ static int apci035_auto_attach(struct comedi_device *dev, addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); } - ret = comedi_alloc_subdevices(dev, 7); + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; @@ -143,20 +143,8 @@ static int apci035_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise AO Subdevice Structures */ - s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_UNUSED; - - /* Allocate and Initialise DI Subdevice Structures */ - s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_UNUSED; - - /* Allocate and Initialise DO Subdevice Structures */ - s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_UNUSED; - /* Allocate and Initialise Timer Subdevice Structures */ - s = &dev->subdevices[4]; + s = &dev->subdevices[1]; if (devpriv->s_EeParameters.i_Timer) { s->type = COMEDI_SUBD_TIMER; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; @@ -171,12 +159,8 @@ static int apci035_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise TTL */ - s = &dev->subdevices[5]; - s->type = COMEDI_SUBD_UNUSED; - /* EEPROM */ - s = &dev->subdevices[6]; + s = &dev->subdevices[2]; if (this_board->i_PCIEeprom) { s->type = COMEDI_SUBD_MEMORY; s->subdev_flags = SDF_READABLE | SDF_INTERNAL; -- cgit v1.2.3-59-g8ed1b From 35ce3c3cc1b8b1fc108abd5f482326213fb68c0b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:27 -0700 Subject: staging: comedi: addi_apci_1500: remove unnecessary subdevice initialization The subdevices that don't initialize any of the callbacks don't really exist. Remove the unnecessary initialzation and just set the type to COMEDI_SUBD_UNUSED. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 28 ++----------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index d6d2e67c5ba7..13b31aba2378 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -116,36 +116,12 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise AI Subdevice Structures */ s = &dev->subdevices[0]; - if ((devpriv->s_EeParameters.i_NbrAiChannel) - || (this_board->i_NbrAiChannelDiff)) { - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = - SDF_READABLE | SDF_COMMON | SDF_GROUND - | SDF_DIFF; - if (devpriv->s_EeParameters.i_NbrAiChannel) - s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel; - else - s->n_chan = this_board->i_NbrAiChannelDiff; - s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; - s->len_chanlist = this_board->i_AiChannelList; - s->range_table = this_board->pr_AiRangelist; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; /* Allocate and Initialise AO Subdevice Structures */ s = &dev->subdevices[1]; - if (devpriv->s_EeParameters.i_NbrAoChannel) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; - s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrAoChannel; - } else { s->type = COMEDI_SUBD_UNUSED; - } + /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[2]; if (devpriv->s_EeParameters.i_NbrDiChannel) { -- cgit v1.2.3-59-g8ed1b From dd2762023e2dccc1b095032c65314035974b74f6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:28 -0700 Subject: staging: comedi: addi_apci_1500: remove unused subdevices Only allocate space for the subdevicess used by the driver. Remove all the COMEDI_SUBD_UNUSED subdevices. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 13b31aba2378..7da0c35d12b1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -110,20 +110,12 @@ static int apci1500_auto_attach(struct comedi_device *dev, addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); } - ret = comedi_alloc_subdevices(dev, 7); + ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; - /* Allocate and Initialise AI Subdevice Structures */ - s = &dev->subdevices[0]; - s->type = COMEDI_SUBD_UNUSED; - - /* Allocate and Initialise AO Subdevice Structures */ - s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_UNUSED; - /* Allocate and Initialise DI Subdevice Structures */ - s = &dev->subdevices[2]; + s = &dev->subdevices[0]; if (devpriv->s_EeParameters.i_NbrDiChannel) { s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; @@ -140,7 +132,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } /* Allocate and Initialise DO Subdevice Structures */ - s = &dev->subdevices[3]; + s = &dev->subdevices[1]; if (devpriv->s_EeParameters.i_NbrDoChannel) { s->type = COMEDI_SUBD_DO; s->subdev_flags = @@ -158,7 +150,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, } /* Allocate and Initialise Timer Subdevice Structures */ - s = &dev->subdevices[4]; + s = &dev->subdevices[2]; if (devpriv->s_EeParameters.i_Timer) { s->type = COMEDI_SUBD_TIMER; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; @@ -174,12 +166,8 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise TTL */ - s = &dev->subdevices[5]; - s->type = COMEDI_SUBD_UNUSED; - /* EEPROM */ - s = &dev->subdevices[6]; + s = &dev->subdevices[3]; if (this_board->i_PCIEeprom) { s->type = COMEDI_SUBD_MEMORY; s->subdev_flags = SDF_READABLE | SDF_INTERNAL; -- cgit v1.2.3-59-g8ed1b From 23abae881b69b903b07b34a0bece086811d77271 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:29 -0700 Subject: staging: comedi: addi_common.h: rename boardinfo 'pc_DriverName' Rename this CamelCase member of the boardinfo. The comedi_device 'board_name' is set to this member during the (*auto_attach) of the addi-data that still use this boardinfo drivers. For aesthetics, use the dev->board_name instead of the boardinfo in the drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 2 +- drivers/staging/comedi/drivers/addi-data/addi_eeprom.c | 2 +- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 12 ++++-------- drivers/staging/comedi/drivers/addi_apci_035.c | 4 ++-- drivers/staging/comedi/drivers/addi_apci_1500.c | 4 ++-- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +++--- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index b757f460740a..9def296568ff 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -19,7 +19,7 @@ #include struct addi_board { - const char *pc_DriverName; /* driver name */ + const char *name; int i_IorangeBase1; int i_PCIEeprom; /* eeprom present or not */ char *pc_EepromChip; /* type of chip */ diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c index b731856c27da..4e3d5ed70990 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c @@ -287,7 +287,7 @@ static void addi_eeprom_read_ai_info(struct comedi_device *dev, /* No of channels for 1st hard component */ tmp = addi_eeprom_readw(iobase, type, addr + 10); devpriv->s_EeParameters.i_NbrAiChannel = (tmp >> 4) & 0x3ff; - if (!strcmp(this_board->pc_DriverName, "apci3200")) + if (!strcmp(dev->board_name, "apci3200")) devpriv->s_EeParameters.i_NbrAiChannel *= 4; tmp = addi_eeprom_readw(iobase, type, addr + 16); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index ed1d92ecc9ea..d76435668d9a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -351,7 +351,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv = dev->private; unsigned short us_ConvertTiming, us_TmpValue, i; unsigned char b_Tmp; @@ -382,7 +381,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(this_board->pc_DriverName, "apci3001")) { + || !strcmp(dev->board_name, "apci3001")) { us_ConvertTiming = (us_ConvertTiming * 2) - 2; } else { us_ConvertTiming = @@ -781,7 +780,6 @@ static int apci3120_cyclic_ai(int mode, struct comedi_device *dev, struct comedi_subdevice *s) { - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned char b_Tmp; @@ -838,7 +836,7 @@ static int apci3120_cyclic_ai(int mode, /* EL241003 Begin: add this section to replace floats calculation by integer calculations */ /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(this_board->pc_DriverName, "apci3001")) { + || !strcmp(dev->board_name, "apci3001")) { ui_TimerValue0 = ui_ConvertTiming * 2 - 2000; ui_TimerValue0 = ui_TimerValue0 / 1000; @@ -1604,7 +1602,6 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv = dev->private; unsigned int ui_Timervalue2; unsigned short us_TmpValue; @@ -1624,7 +1621,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, * is an APCI3001 and calculate the time value to set in the timer */ if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(this_board->pc_DriverName, "apci3001")) { + || !strcmp(dev->board_name, "apci3001")) { /* Calculate the time value to set in the timer */ ui_Timervalue2 = ui_Timervalue2 / 50; } else { @@ -1742,7 +1739,6 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv = dev->private; unsigned int ui_Timervalue2 = 0; unsigned short us_TmpValue; @@ -1862,7 +1858,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, * is an APCI3001 and calculate the time value to set in the timer */ if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(this_board->pc_DriverName, "apci3001")) { + || !strcmp(dev->board_name, "apci3001")) { /* Calculate the time value to set in the timer */ ui_Timervalue2 = ui_Timervalue2 / 50; } else { diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index 3eeb244ef855..a5e3d325165a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -14,7 +14,7 @@ static const struct addi_board apci035_boardtypes[] = { { - .pc_DriverName = "apci035", + .name = "apci035", .i_IorangeBase1 = APCI035_ADDRESS_RANGE, .i_PCIEeprom = 1, .pc_EepromChip = "S5920", @@ -57,7 +57,7 @@ static int apci035_auto_attach(struct comedi_device *dev, int ret; dev->board_ptr = &apci035_boardtypes[0]; - dev->board_name = this_board->pc_DriverName; + dev->board_name = this_board->name; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 7da0c35d12b1..03e65a106816 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -12,7 +12,7 @@ static const struct addi_board apci1500_boardtypes[] = { { - .pc_DriverName = "apci1500", + .name = "apci1500", .i_IorangeBase1 = APCI1500_ADDRESS_RANGE, .i_PCIEeprom = 0, .i_NbrDiChannel = 16, @@ -50,7 +50,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, int ret; dev->board_ptr = &apci1500_boardtypes[0]; - dev->board_name = this_board->pc_DriverName; + dev->board_name = this_board->name; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 38da44bd4eef..1fa53cf629fc 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,7 +16,7 @@ enum apci3120_boardid { static const struct addi_board apci3120_boardtypes[] = { [BOARD_APCI3120] = { - .pc_DriverName = "apci3120", + .name = "apci3120", .i_NbrAiChannel = 16, .i_NbrAiChannelDiff = 8, .i_AiChannelList = 16, @@ -28,7 +28,7 @@ static const struct addi_board apci3120_boardtypes[] = { .i_DoMaxdata = 0x0f, }, [BOARD_APCI3001] = { - .pc_DriverName = "apci3001", + .name = "apci3001", .i_NbrAiChannel = 16, .i_NbrAiChannelDiff = 8, .i_AiChannelList = 16, @@ -53,7 +53,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, if (!this_board) return -ENODEV; dev->board_ptr = this_board; - dev->board_name = this_board->pc_DriverName; + dev->board_name = this_board->name; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) -- cgit v1.2.3-59-g8ed1b From d75a78435c7d0ca945de0ba17e5814a0875700c5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:30 -0700 Subject: staging: comedi: addi_common.h: remove boardinfo 'i_IorangeBase1' This member of the boardinfo is used as a flag to determine what PCI BAR to use for the main 'iobase' used by the driver. Remove the boardinfo member and refactor the (*auto_attach) of the drivers to use the correct PCI BAR. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi_apci_035.c | 7 +------ drivers/staging/comedi/drivers/addi_apci_1500.c | 7 +------ 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 9def296568ff..0752a61a7c2a 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -20,7 +20,6 @@ struct addi_board { const char *name; - int i_IorangeBase1; int i_PCIEeprom; /* eeprom present or not */ char *pc_EepromChip; /* type of chip */ int i_NbrAiChannel; /* num of A/D chans */ diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index a5e3d325165a..a197f64e63c1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -15,7 +15,6 @@ static const struct addi_board apci035_boardtypes[] = { { .name = "apci035", - .i_IorangeBase1 = APCI035_ADDRESS_RANGE, .i_PCIEeprom = 1, .pc_EepromChip = "S5920", .i_NbrAiChannel = 16, @@ -67,11 +66,7 @@ static int apci035_auto_attach(struct comedi_device *dev, if (ret) return ret; - if (this_board->i_IorangeBase1) - dev->iobase = pci_resource_start(pcidev, 1); - else - dev->iobase = pci_resource_start(pcidev, 0); - + dev->iobase = pci_resource_start(pcidev, 1); devpriv->iobase = dev->iobase; devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 03e65a106816..c69510bcf931 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -13,7 +13,6 @@ static const struct addi_board apci1500_boardtypes[] = { { .name = "apci1500", - .i_IorangeBase1 = APCI1500_ADDRESS_RANGE, .i_PCIEeprom = 0, .i_NbrDiChannel = 16, .i_NbrDoChannel = 16, @@ -60,11 +59,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, if (ret) return ret; - if (this_board->i_IorangeBase1) - dev->iobase = pci_resource_start(pcidev, 1); - else - dev->iobase = pci_resource_start(pcidev, 0); - + dev->iobase = pci_resource_start(pcidev, 1); devpriv->iobase = dev->iobase; devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); -- cgit v1.2.3-59-g8ed1b From 73901b52156775361f222b93663b680b190f1945 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:31 -0700 Subject: staging: comedi: addi_apci_1500: remove eeprom support As indicated in the boardinfo, the hardware does not have an eeprom. Remove the subdevice and support code for it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 51 +------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index c69510bcf931..7c32c856f562 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -7,13 +7,11 @@ #include "addi-data/addi_common.h" -#include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_apci1500.c" static const struct addi_board apci1500_boardtypes[] = { { .name = "apci1500", - .i_PCIEeprom = 0, .i_NbrDiChannel = 16, .i_NbrDoChannel = 16, .i_DoMaxdata = 0xffff, @@ -21,23 +19,6 @@ static const struct addi_board apci1500_boardtypes[] = { }, }; -static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - unsigned short w_Address = CR_CHAN(insn->chanspec); - unsigned short w_Data; - - w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, - this_board->pc_EepromChip, 2 * w_Address); - data[0] = w_Data; - - return insn->n; -} - static int apci1500_auto_attach(struct comedi_device *dev, unsigned long context) { @@ -45,7 +26,6 @@ static int apci1500_auto_attach(struct comedi_device *dev, const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv; struct comedi_subdevice *s; - unsigned int dw_Dummy; int ret; dev->board_ptr = &apci1500_boardtypes[0]; @@ -88,24 +68,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, dev->irq = pcidev->irq; } - /* Read eepeom and fill addi_board Structure */ - - if (this_board->i_PCIEeprom) { - if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { - /* Set 3 wait stait */ - if (!(strcmp(dev->board_name, "apci035"))) - outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - else - outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); - outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - } - addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); - } - - ret = comedi_alloc_subdevices(dev, 4); + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; @@ -161,18 +124,6 @@ static int apci1500_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* EEPROM */ - s = &dev->subdevices[3]; - if (this_board->i_PCIEeprom) { - s->type = COMEDI_SUBD_MEMORY; - s->subdev_flags = SDF_READABLE | SDF_INTERNAL; - s->n_chan = 256; - s->maxdata = 0xffff; - s->insn_read = i_ADDIDATA_InsnReadEeprom; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - apci1500_reset(dev); return 0; -- cgit v1.2.3-59-g8ed1b From b6cc74814f86e3057eba4440d5843433e238ef49 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:32 -0700 Subject: staging: comedi: addi_apci_035: board has eeprom As indicated in the boardinfo, the hardware has an eeprom. Simplify the board attach code and remove the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_035.c | 38 +++++++++----------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index a197f64e63c1..ed4ed17888a1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -15,7 +15,6 @@ static const struct addi_board apci035_boardtypes[] = { { .name = "apci035", - .i_PCIEeprom = 1, .pc_EepromChip = "S5920", .i_NbrAiChannel = 16, .i_NbrAiChannelDiff = 8, @@ -95,22 +94,15 @@ static int apci035_auto_attach(struct comedi_device *dev, dev->irq = pcidev->irq; } - /* Read eepeom and fill addi_board Structure */ + /* Set 3 wait stait */ + outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - if (this_board->i_PCIEeprom) { - if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { - /* Set 3 wait stait */ - if (!(strcmp(dev->board_name, "apci035"))) - outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - else - outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); - outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - } - addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); - } + /* Enable the interrupt for the controller */ + dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); + outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); + + /* Read eepeom and fill addi_board Structure */ + addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); ret = comedi_alloc_subdevices(dev, 3); if (ret) @@ -156,15 +148,11 @@ static int apci035_auto_attach(struct comedi_device *dev, /* EEPROM */ s = &dev->subdevices[2]; - if (this_board->i_PCIEeprom) { - s->type = COMEDI_SUBD_MEMORY; - s->subdev_flags = SDF_READABLE | SDF_INTERNAL; - s->n_chan = 256; - s->maxdata = 0xffff; - s->insn_read = i_ADDIDATA_InsnReadEeprom; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_MEMORY; + s->subdev_flags = SDF_READABLE | SDF_INTERNAL; + s->n_chan = 256; + s->maxdata = 0xffff; + s->insn_read = i_ADDIDATA_InsnReadEeprom; apci035_reset(dev); -- cgit v1.2.3-59-g8ed1b From e10e23db5478d3159cabe8f6af8dcfef2f627aa0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:33 -0700 Subject: staging: comedi: addi_common.h: remove boardinfo member 'i_PCIEeprom' This member of the boardinfo is not used by any of the drivers. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 0752a61a7c2a..5518332d677a 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -20,7 +20,6 @@ struct addi_board { const char *name; - int i_PCIEeprom; /* eeprom present or not */ char *pc_EepromChip; /* type of chip */ int i_NbrAiChannel; /* num of A/D chans */ int i_NbrAiChannelDiff; /* num of A/D chans in diff mode */ -- cgit v1.2.3-59-g8ed1b From bb599f39fa8fbffbe43d7c1937333544e0cdbf16 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:34 -0700 Subject: staging: comedi: addi_apci_1500: remove boardinfo The hardware does not have an eeprom so the 's_EeParameters' use is not necessary. Remove it. Since the boardinfo only has one entry its not really necessary. Remove it and initialize the subdevices directly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 103 +++++++----------------- 1 file changed, 29 insertions(+), 74 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 7c32c856f562..dc90a8f5388f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -9,28 +9,14 @@ #include "addi-data/hwdrv_apci1500.c" -static const struct addi_board apci1500_boardtypes[] = { - { - .name = "apci1500", - .i_NbrDiChannel = 16, - .i_NbrDoChannel = 16, - .i_DoMaxdata = 0xffff, - .i_Timer = 1, - }, -}; - static int apci1500_auto_attach(struct comedi_device *dev, unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv; struct comedi_subdevice *s; int ret; - dev->board_ptr = &apci1500_boardtypes[0]; - dev->board_name = this_board->name; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; @@ -45,22 +31,6 @@ static int apci1500_auto_attach(struct comedi_device *dev, devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); - /* Initialize parameters that can be overridden in EEPROM */ - devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; - devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; - devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; - devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; - devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; - devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; - devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; - devpriv->s_EeParameters.i_Timer = this_board->i_Timer; - devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = - this_board->ui_MinAcquisitiontimeNs; - devpriv->s_EeParameters.ui_MinDelaytimeNs = - this_board->ui_MinDelaytimeNs; - - /* ## */ - if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci1500_interrupt, IRQF_SHARED, dev->board_name, dev); @@ -74,55 +44,40 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[0]; - if (devpriv->s_EeParameters.i_NbrDiChannel) { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; - s->maxdata = 1; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDiChannel; - s->range_table = &range_digital; - s->insn_config = apci1500_di_config; - s->insn_read = apci1500_di_read; - s->insn_write = apci1500_di_write; - s->insn_bits = apci1500_di_insn_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_config = apci1500_di_config; + s->insn_read = apci1500_di_read; + s->insn_write = apci1500_di_write; + s->insn_bits = apci1500_di_insn_bits; + /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[1]; - if (devpriv->s_EeParameters.i_NbrDoChannel) { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; - s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDoChannel; - s->range_table = &range_digital; - s->insn_config = apci1500_do_config; - s->insn_write = apci1500_do_write; - s->insn_bits = apci1500_do_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DO; + s->subdev_flags = + SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_config = apci1500_do_config; + s->insn_write = apci1500_do_write; + s->insn_bits = apci1500_do_bits; /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[2]; - if (devpriv->s_EeParameters.i_Timer) { - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 1; - s->maxdata = 0; - s->len_chanlist = 1; - s->range_table = &range_digital; - s->insn_write = apci1500_timer_write; - s->insn_read = apci1500_timer_read; - s->insn_config = apci1500_timer_config; - s->insn_bits = apci1500_timer_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + s->insn_write = apci1500_timer_write; + s->insn_read = apci1500_timer_read; + s->insn_config = apci1500_timer_config; + s->insn_bits = apci1500_timer_bits; apci1500_reset(dev); -- cgit v1.2.3-59-g8ed1b From 715ce8aac445efd2e9319bccb0919cb30856a26a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:35 -0700 Subject: staging: comedi: addi_apci_035: remove boardinfo The hardware has an eeprom but the boardinfo properly defines the subdevice support so reading the eeprom and setting the 's_EeParameters' use is not necessary. Since the boardinfo only has one entry its not really necessary. Also, providing a subdevice the read the eeprom is not really interesting. Remove the eeprom support code along with the boardinfo and initialize the subdevices directly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_035.c | 116 ++++--------------------- 1 file changed, 19 insertions(+), 97 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index ed4ed17888a1..37b58845231b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -9,54 +9,17 @@ #define ADDIDATA_WATCHDOG 2 /* Or shold it be something else */ -#include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_apci035.c" -static const struct addi_board apci035_boardtypes[] = { - { - .name = "apci035", - .pc_EepromChip = "S5920", - .i_NbrAiChannel = 16, - .i_NbrAiChannelDiff = 8, - .i_AiChannelList = 16, - .i_AiMaxdata = 0xff, - .pr_AiRangelist = &range_apci035_ai, - .i_Timer = 1, - .ui_MinAcquisitiontimeNs = 10000, - .ui_MinDelaytimeNs = 100000, - }, -}; - -static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - unsigned short w_Address = CR_CHAN(insn->chanspec); - unsigned short w_Data; - - w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, - this_board->pc_EepromChip, 2 * w_Address); - data[0] = w_Data; - - return insn->n; -} - static int apci035_auto_attach(struct comedi_device *dev, unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv; struct comedi_subdevice *s; unsigned int dw_Dummy; int ret; - dev->board_ptr = &apci035_boardtypes[0]; - dev->board_name = this_board->name; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; @@ -71,22 +34,6 @@ static int apci035_auto_attach(struct comedi_device *dev, devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); - /* Initialize parameters that can be overridden in EEPROM */ - devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; - devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; - devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; - devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; - devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; - devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; - devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; - devpriv->s_EeParameters.i_Timer = this_board->i_Timer; - devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = - this_board->ui_MinAcquisitiontimeNs; - devpriv->s_EeParameters.ui_MinDelaytimeNs = - this_board->ui_MinDelaytimeNs; - - /* ## */ - if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci035_interrupt, IRQF_SHARED, dev->board_name, dev); @@ -101,58 +48,33 @@ static int apci035_auto_attach(struct comedi_device *dev, dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - /* Read eepeom and fill addi_board Structure */ - addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); - - ret = comedi_alloc_subdevices(dev, 3); + ret = comedi_alloc_subdevices(dev, 2); if (ret) return ret; /* Allocate and Initialise AI Subdevice Structures */ s = &dev->subdevices[0]; - if ((devpriv->s_EeParameters.i_NbrAiChannel) - || (this_board->i_NbrAiChannelDiff)) { - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = - SDF_READABLE | SDF_COMMON | SDF_GROUND - | SDF_DIFF; - if (devpriv->s_EeParameters.i_NbrAiChannel) - s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel; - else - s->n_chan = this_board->i_NbrAiChannelDiff; - s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; - s->len_chanlist = this_board->i_AiChannelList; - s->range_table = this_board->pr_AiRangelist; - s->insn_config = apci035_ai_config; - s->insn_read = apci035_ai_read; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + dev->read_subdev = s; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; + s->n_chan = 16; + s->maxdata = 0xff; + s->len_chanlist = s->n_chan; + s->range_table = &range_apci035_ai; + s->insn_config = apci035_ai_config; + s->insn_read = apci035_ai_read; /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[1]; - if (devpriv->s_EeParameters.i_Timer) { - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 1; - s->maxdata = 0; - s->len_chanlist = 1; - s->range_table = &range_digital; - s->insn_write = apci035_timer_write; - s->insn_read = apci035_timer_read; - s->insn_config = apci035_timer_config; - } else { - s->type = COMEDI_SUBD_UNUSED; - } - - /* EEPROM */ - s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_MEMORY; - s->subdev_flags = SDF_READABLE | SDF_INTERNAL; - s->n_chan = 256; - s->maxdata = 0xffff; - s->insn_read = i_ADDIDATA_InsnReadEeprom; + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + s->insn_write = apci035_timer_write; + s->insn_read = apci035_timer_read; + s->insn_config = apci035_timer_config; apci035_reset(dev); -- cgit v1.2.3-59-g8ed1b From 3b00a0e0d6611935bbed56fd2b298fb10cfb3f7b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:36 -0700 Subject: staging: comedi: addi_eeprom: remove source file This source file is no longer included by any of the addi-data drivers. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_eeprom.c | 360 --------------------- 1 file changed, 360 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_eeprom.c diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c deleted file mode 100644 index 4e3d5ed70990..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - * addi_eeprom.c - ADDI EEPROM Module - * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - * Project manager: Eric Stolz - * - * ADDI-DATA GmbH - * Dieselstrasse 3 - * D-77833 Ottersweier - * Tel: +19(0)7223/9493-0 - * Fax: +49(0)7223/9493-92 - * http://www.addi-data.com - * info@addi-data.com - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include - -#define NVRAM_USER_DATA_START 0x100 - -#define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */ -#define NVCMD_LOAD_LOW (0x4 << 5) /* nvRam load low command */ -#define NVCMD_LOAD_HIGH (0x5 << 5) /* nvRam load high command */ - -#define EE93C76_CLK_BIT (1 << 0) -#define EE93C76_CS_BIT (1 << 1) -#define EE93C76_DOUT_BIT (1 << 2) -#define EE93C76_DIN_BIT (1 << 3) -#define EE93C76_READ_CMD (0x0180 << 4) -#define EE93C76_CMD_LEN 13 - -#define EEPROM_DIGITALINPUT 0 -#define EEPROM_DIGITALOUTPUT 1 -#define EEPROM_ANALOGINPUT 2 -#define EEPROM_ANALOGOUTPUT 3 -#define EEPROM_TIMER 4 -#define EEPROM_WATCHDOG 5 -#define EEPROM_TIMER_WATCHDOG_COUNTER 10 - -static void addi_eeprom_clk_93c76(unsigned long iobase, unsigned int val) -{ - outl(val & ~EE93C76_CLK_BIT, iobase); - udelay(100); - - outl(val | EE93C76_CLK_BIT, iobase); - udelay(100); -} - -static unsigned int addi_eeprom_cmd_93c76(unsigned long iobase, - unsigned int cmd, - unsigned char len) -{ - unsigned int val = EE93C76_CS_BIT; - int i; - - /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */ - outl(val, iobase); - udelay(100); - - /* Send EEPROM command - one bit at a time */ - for (i = (len - 1); i >= 0; i--) { - if (cmd & (1 << i)) - val |= EE93C76_DOUT_BIT; - else - val &= ~EE93C76_DOUT_BIT; - - /* Write the command */ - outl(val, iobase); - udelay(100); - - addi_eeprom_clk_93c76(iobase, val); - } - return val; -} - -static unsigned short addi_eeprom_readw_93c76(unsigned long iobase, - unsigned short addr) -{ - unsigned short val = 0; - unsigned int cmd; - unsigned int tmp; - int i; - - /* Send EEPROM read command and offset to EEPROM */ - cmd = EE93C76_READ_CMD | (addr / 2); - cmd = addi_eeprom_cmd_93c76(iobase, cmd, EE93C76_CMD_LEN); - - /* Get the 16-bit value */ - for (i = 0; i < 16; i++) { - addi_eeprom_clk_93c76(iobase, cmd); - - tmp = inl(iobase); - udelay(100); - - val <<= 1; - if (tmp & EE93C76_DIN_BIT) - val |= 0x1; - } - - /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */ - outl(0, iobase); - udelay(100); - - return val; -} - -static void addi_eeprom_nvram_wait(unsigned long iobase) -{ - unsigned char val; - - do { - val = inb(iobase + AMCC_OP_REG_MCSR_NVCMD); - } while (val & 0x80); -} - -static unsigned short addi_eeprom_readw_nvram(unsigned long iobase, - unsigned short addr) -{ - unsigned short val = 0; - unsigned char tmp; - unsigned char i; - - for (i = 0; i < 2; i++) { - /* Load the low 8 bit address */ - outb(NVCMD_LOAD_LOW, iobase + AMCC_OP_REG_MCSR_NVCMD); - addi_eeprom_nvram_wait(iobase); - outb((addr + i) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA); - addi_eeprom_nvram_wait(iobase); - - /* Load the high 8 bit address */ - outb(NVCMD_LOAD_HIGH, iobase + AMCC_OP_REG_MCSR_NVCMD); - addi_eeprom_nvram_wait(iobase); - outb(((addr + i) >> 8) & 0xff, - iobase + AMCC_OP_REG_MCSR_NVDATA); - addi_eeprom_nvram_wait(iobase); - - /* Read the eeprom data byte */ - outb(NVCMD_BEGIN_READ, iobase + AMCC_OP_REG_MCSR_NVCMD); - addi_eeprom_nvram_wait(iobase); - tmp = inb(iobase + AMCC_OP_REG_MCSR_NVDATA); - addi_eeprom_nvram_wait(iobase); - - if (i == 0) - val |= tmp; - else - val |= (tmp << 8); - } - - return val; -} - -static unsigned short addi_eeprom_readw(unsigned long iobase, - char *type, - unsigned short addr) -{ - unsigned short val = 0; - - /* Add the offset to the start of the user data */ - addr += NVRAM_USER_DATA_START; - - if (!strcmp(type, "S5920") || !strcmp(type, "S5933")) - val = addi_eeprom_readw_nvram(iobase, addr); - - if (!strcmp(type, "93C76")) - val = addi_eeprom_readw_93c76(iobase, addr); - - return val; -} - -static void addi_eeprom_read_di_info(struct comedi_device *dev, - unsigned long iobase, - unsigned short addr) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - char *type = this_board->pc_EepromChip; - unsigned short tmp; - - /* Number of channels */ - tmp = addi_eeprom_readw(iobase, type, addr + 6); - devpriv->s_EeParameters.i_NbrDiChannel = tmp; - - /* Interruptible or not */ - tmp = addi_eeprom_readw(iobase, type, addr + 8); - tmp = (tmp >> 7) & 0x01; - - /* How many interruptible logic */ - tmp = addi_eeprom_readw(iobase, type, addr + 10); -} - -static void addi_eeprom_read_do_info(struct comedi_device *dev, - unsigned long iobase, - unsigned short addr) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - char *type = this_board->pc_EepromChip; - unsigned short tmp; - - /* Number of channels */ - tmp = addi_eeprom_readw(iobase, type, addr + 6); - devpriv->s_EeParameters.i_NbrDoChannel = tmp; - - devpriv->s_EeParameters.i_DoMaxdata = 0xffffffff >> (32 - tmp); -} - -static void addi_eeprom_read_timer_info(struct comedi_device *dev, - unsigned long iobase, - unsigned short addr) -{ - struct addi_private *devpriv = dev->private; -#if 0 - const struct addi_board *this_board = dev->board_ptr; - char *type = this_board->pc_EepromChip; - unsigned short offset = 0; - unsigned short ntimers; - unsigned short tmp; - int i; - - /* Number of Timers */ - ntimers = addi_eeprom_readw(iobase, type, addr + 6); - - /* Read header size */ - for (i = 0; i < ntimers; i++) { - unsigned short size; - unsigned short res; - unsigned short mode; - unsigned short min_timing; - unsigned short timebase; - - size = addi_eeprom_readw(iobase, type, addr + 8 + offset + 0); - - /* Resolution / Mode */ - tmp = addi_eeprom_readw(iobase, type, addr + 8 + offset + 2); - res = (tmp >> 10) & 0x3f; - mode = (tmp >> 4) & 0x3f; - - /* MinTiming / Timebase */ - tmp = addi_eeprom_readw(iobase, type, addr + 8 + offset + 4); - min_timing = (tmp >> 6) & 0x3ff; - Timebase = tmp & 0x3f; - - offset += size; - } -#endif - /* Timer subdevice present */ - devpriv->s_EeParameters.i_Timer = 1; -} - -static void addi_eeprom_read_ao_info(struct comedi_device *dev, - unsigned long iobase, - unsigned short addr) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - char *type = this_board->pc_EepromChip; - unsigned short tmp; - - /* No of channels for 1st hard component */ - tmp = addi_eeprom_readw(iobase, type, addr + 10); - devpriv->s_EeParameters.i_NbrAoChannel = (tmp >> 4) & 0x3ff; - - /* Resolution for 1st hard component */ - tmp = addi_eeprom_readw(iobase, type, addr + 16); - tmp = (tmp >> 8) & 0xff; - devpriv->s_EeParameters.i_AoMaxdata = 0xfff >> (16 - tmp); -} - -static void addi_eeprom_read_ai_info(struct comedi_device *dev, - unsigned long iobase, - unsigned short addr) -{ - const struct addi_board *this_board = dev->board_ptr; - struct addi_private *devpriv = dev->private; - char *type = this_board->pc_EepromChip; - unsigned short offset; - unsigned short tmp; - - /* No of channels for 1st hard component */ - tmp = addi_eeprom_readw(iobase, type, addr + 10); - devpriv->s_EeParameters.i_NbrAiChannel = (tmp >> 4) & 0x3ff; - if (!strcmp(dev->board_name, "apci3200")) - devpriv->s_EeParameters.i_NbrAiChannel *= 4; - - tmp = addi_eeprom_readw(iobase, type, addr + 16); - devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = tmp * 1000; - - tmp = addi_eeprom_readw(iobase, type, addr + 30); - devpriv->s_EeParameters.ui_MinDelaytimeNs = tmp * 1000; - - tmp = addi_eeprom_readw(iobase, type, addr + 20); - /* dma = (tmp >> 13) & 0x01; */ - - tmp = addi_eeprom_readw(iobase, type, addr + 72) & 0xff; - if (tmp) { /* > 0 */ - /* offset of first analog input single header */ - offset = 74 + (2 * tmp) + (10 * (1 + (tmp / 16))); - } else { /* = 0 */ - offset = 74; - } - - /* Resolution */ - tmp = addi_eeprom_readw(iobase, type, addr + offset + 2) & 0x1f; - devpriv->s_EeParameters.i_AiMaxdata = 0xffff >> (16 - tmp); -} - -static void addi_eeprom_read_info(struct comedi_device *dev, - unsigned long iobase) -{ - const struct addi_board *this_board = dev->board_ptr; - char *type = this_board->pc_EepromChip; - unsigned short size; - unsigned char nfuncs; - int i; - - size = addi_eeprom_readw(iobase, type, 8); - nfuncs = addi_eeprom_readw(iobase, type, 10) & 0xff; - - /* Read functionality details */ - for (i = 0; i < nfuncs; i++) { - unsigned short offset = i * 4; - unsigned short addr; - unsigned char func; - - func = addi_eeprom_readw(iobase, type, 12 + offset) & 0x3f; - addr = addi_eeprom_readw(iobase, type, 14 + offset); - - switch (func) { - case EEPROM_DIGITALINPUT: - addi_eeprom_read_di_info(dev, iobase, addr); - break; - - case EEPROM_DIGITALOUTPUT: - addi_eeprom_read_do_info(dev, iobase, addr); - break; - - case EEPROM_ANALOGINPUT: - addi_eeprom_read_ai_info(dev, iobase, addr); - break; - - case EEPROM_ANALOGOUTPUT: - addi_eeprom_read_ao_info(dev, iobase, addr); - break; - - case EEPROM_TIMER: - case EEPROM_WATCHDOG: - case EEPROM_TIMER_WATCHDOG_COUNTER: - addi_eeprom_read_timer_info(dev, iobase, addr); - break; - } - } -} -- cgit v1.2.3-59-g8ed1b From 7fab573b61a7cc771a9f7537e54818b13dcb07cc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:37 -0700 Subject: staging: comedi: hwdrv_apci3120: remove need for boardinfo access The apci3120_ai_insn_config() function is broken in this driver. It does not follow the comedi API and will fail to work correctly. For now just remove the need for the boardinfo access to allow additional cleanup. The 'i_NbrAiChannel' is actually the subdevice 'n_chan' use that instead and remove the boardinfo access. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index d76435668d9a..e120d620b3ce 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -246,7 +246,6 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct addi_board *this_board = dev->board_ptr; struct addi_private *devpriv = dev->private; unsigned int i; @@ -261,8 +260,7 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, /* Test the number of the channel */ for (i = 0; i < data[3]; i++) { - if (CR_CHAN(data[4 + i]) >= - this_board->i_NbrAiChannel) { + if (CR_CHAN(data[4 + i]) >= s->n_chan) { dev_err(dev->class_dev, "bad channel list\n"); return -2; } -- cgit v1.2.3-59-g8ed1b From dbf502e4b8d7eb016321ac97489384f8ae404822 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:38 -0700 Subject: staging: comedi: addi_common.h: remove boardinfo definition The addi_board definition is not only used by the addi_apci_3120 driver. Introduce a private definition in that driver and remove the global definition from addi_common.h. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.h | 20 -------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 5518332d677a..28aec3f8352d 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -18,26 +18,6 @@ #include #include -struct addi_board { - const char *name; - char *pc_EepromChip; /* type of chip */ - int i_NbrAiChannel; /* num of A/D chans */ - int i_NbrAiChannelDiff; /* num of A/D chans in diff mode */ - int i_AiChannelList; /* len of chanlist */ - int i_NbrAoChannel; /* num of D/A chans */ - int i_AiMaxdata; /* resolution of A/D */ - int i_AoMaxdata; /* resolution of D/A */ - const struct comedi_lrange *pr_AiRangelist; /* rangelist for A/D */ - - int i_NbrDiChannel; /* Number of DI channels */ - int i_NbrDoChannel; /* Number of DO channels */ - int i_DoMaxdata; /* data to set all channels high */ - - int i_Timer; /* timer subdevice present or not */ - unsigned int ui_MinAcquisitiontimeNs; /* Minimum Acquisition in Nano secs */ - unsigned int ui_MinDelaytimeNs; /* Minimum Delay in Nano secs */ -}; - struct addi_private { int iobase; int i_IobaseAmcc; /* base+size for AMCC chip */ diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 1fa53cf629fc..ae81fdb2a97f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -14,7 +14,20 @@ enum apci3120_boardid { BOARD_APCI3001, }; -static const struct addi_board apci3120_boardtypes[] = { +struct apci3120_board { + const char *name; + int i_NbrAiChannel; + int i_NbrAiChannelDiff; + int i_AiChannelList; + int i_NbrAoChannel; + int i_AiMaxdata; + int i_AoMaxdata; + int i_NbrDiChannel; + int i_NbrDoChannel; + int i_DoMaxdata; +}; + +static const struct apci3120_board apci3120_boardtypes[] = { [BOARD_APCI3120] = { .name = "apci3120", .i_NbrAiChannel = 16, @@ -43,7 +56,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct addi_board *this_board = NULL; + const struct apci3120_board *this_board = NULL; struct addi_private *devpriv; struct comedi_subdevice *s; int ret, order, i; -- cgit v1.2.3-59-g8ed1b From 7067a347665feec4aa1f7ecdd892a24715f094a6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:39 -0700 Subject: staging: comedi: addi_common.h: remove unused members from addi_private Remove all the unused members from the addi_private definition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 28aec3f8352d..52f35b4c00dc 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -49,20 +49,4 @@ struct addi_private { /* Pointer to the current process */ struct task_struct *tsk_Current; - - /* Parameters read from EEPROM overriding static board info */ - struct { - int i_NbrAiChannel; /* num of A/D chans */ - int i_NbrAoChannel; /* num of D/A chans */ - int i_AiMaxdata; /* resolution of A/D */ - int i_AoMaxdata; /* resolution of D/A */ - int i_NbrDiChannel; /* Number of DI channels */ - int i_NbrDoChannel; /* Number of DO channels */ - int i_DoMaxdata; /* data to set all channels high */ - int i_Timer; /* timer subdevice present or not */ - unsigned int ui_MinAcquisitiontimeNs; - /* Minimum Acquisition in Nano secs */ - unsigned int ui_MinDelaytimeNs; - /* Minimum Delay in Nano secs */ - } s_EeParameters; }; -- cgit v1.2.3-59-g8ed1b From 73fc3c6c0516754c8b1ce5f8c0dcc54e0d37a9f0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:40 -0700 Subject: staging: comedi: addi_apci_3120: remove boardinfo 'i_DoMaxdata' The maxdata for a Digital Output subdevice is always '1'. Remove this incorrect boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ae81fdb2a97f..9f5d7a528945 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -24,7 +24,6 @@ struct apci3120_board { int i_AoMaxdata; int i_NbrDiChannel; int i_NbrDoChannel; - int i_DoMaxdata; }; static const struct apci3120_board apci3120_boardtypes[] = { @@ -38,7 +37,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { .i_AoMaxdata = 0x3fff, .i_NbrDiChannel = 4, .i_NbrDoChannel = 4, - .i_DoMaxdata = 0x0f, }, [BOARD_APCI3001] = { .name = "apci3001", @@ -48,7 +46,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { .i_AiMaxdata = 0xfff, .i_NbrDiChannel = 4, .i_NbrDoChannel = 4, - .i_DoMaxdata = 0x0f, }, }; @@ -166,7 +163,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = this_board->i_NbrDoChannel; - s->maxdata = this_board->i_DoMaxdata; + s->maxdata = 1; s->len_chanlist = this_board->i_NbrDoChannel; s->range_table = &range_digital; s->insn_bits = apci3120_do_insn_bits; -- cgit v1.2.3-59-g8ed1b From 4241d6b82ddf080ce82f062281b93eb68c291298 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:41 -0700 Subject: staging: comedi: addi_apci_3120: remove boardinfo 'i_NbrDoChannel' All boardinfo entries have this member set as '4'. Remove the member and initialize the Digial Output 'n_chan' with 4 directly. Also, remove the initialization of 'len_chanlist'. This member is only used with subdevices that support async commands. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 9f5d7a528945..fd6f64ab7fc1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -23,7 +23,6 @@ struct apci3120_board { int i_AiMaxdata; int i_AoMaxdata; int i_NbrDiChannel; - int i_NbrDoChannel; }; static const struct apci3120_board apci3120_boardtypes[] = { @@ -36,7 +35,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { .i_AiMaxdata = 0xffff, .i_AoMaxdata = 0x3fff, .i_NbrDiChannel = 4, - .i_NbrDoChannel = 4, }, [BOARD_APCI3001] = { .name = "apci3001", @@ -45,7 +43,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { .i_AiChannelList = 16, .i_AiMaxdata = 0xfff, .i_NbrDiChannel = 4, - .i_NbrDoChannel = 4, }, }; @@ -162,9 +159,8 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = this_board->i_NbrDoChannel; + s->n_chan = 4; s->maxdata = 1; - s->len_chanlist = this_board->i_NbrDoChannel; s->range_table = &range_digital; s->insn_bits = apci3120_do_insn_bits; -- cgit v1.2.3-59-g8ed1b From 171192d0d084ae432f9da25230e17d967ed7eeed Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:42 -0700 Subject: staging: comedi: addi_apci_3120: remove boardinfo 'i_NbrDiChannel' All boardinfo entries have this member set as '4'. Remove the member and initialize the Digial Input 'n_chan' with 4 directly. Also, remove the initialization of 'len_chanlist'. This member is only used with subdevices that support async commands. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index fd6f64ab7fc1..18e0b1367ce4 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -22,7 +22,6 @@ struct apci3120_board { int i_NbrAoChannel; int i_AiMaxdata; int i_AoMaxdata; - int i_NbrDiChannel; }; static const struct apci3120_board apci3120_boardtypes[] = { @@ -34,7 +33,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { .i_NbrAoChannel = 8, .i_AiMaxdata = 0xffff, .i_AoMaxdata = 0x3fff, - .i_NbrDiChannel = 4, }, [BOARD_APCI3001] = { .name = "apci3001", @@ -42,7 +40,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { .i_NbrAiChannelDiff = 8, .i_AiChannelList = 16, .i_AiMaxdata = 0xfff, - .i_NbrDiChannel = 4, }, }; @@ -148,9 +145,8 @@ static int apci3120_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = this_board->i_NbrDiChannel; + s->n_chan = 4; s->maxdata = 1; - s->len_chanlist = this_board->i_NbrDiChannel; s->range_table = &range_digital; s->insn_bits = apci3120_di_insn_bits; -- cgit v1.2.3-59-g8ed1b From 98ea9f854a2577b36e3a06d0824db5f51c514667 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:43 -0700 Subject: staging: comedi: addi_apci_3120: remove boardinfo 'i_NbrAiChannel' All boardinfo entries have this member set as '16'. This will initialize the Analog Input 'n_chan' and cause the 'i_NbrAiChannelDiff' member to never get used. Remove both members and initialize the Analog Input 'n_chan' with 16 directly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 18e0b1367ce4..32e5ad487a1c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,8 +16,6 @@ enum apci3120_boardid { struct apci3120_board { const char *name; - int i_NbrAiChannel; - int i_NbrAiChannelDiff; int i_AiChannelList; int i_NbrAoChannel; int i_AiMaxdata; @@ -27,8 +25,6 @@ struct apci3120_board { static const struct apci3120_board apci3120_boardtypes[] = { [BOARD_APCI3120] = { .name = "apci3120", - .i_NbrAiChannel = 16, - .i_NbrAiChannelDiff = 8, .i_AiChannelList = 16, .i_NbrAoChannel = 8, .i_AiMaxdata = 0xffff, @@ -36,8 +32,6 @@ static const struct apci3120_board apci3120_boardtypes[] = { }, [BOARD_APCI3001] = { .name = "apci3001", - .i_NbrAiChannel = 16, - .i_NbrAiChannelDiff = 8, .i_AiChannelList = 16, .i_AiMaxdata = 0xfff, }, @@ -113,10 +107,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; - if (this_board->i_NbrAiChannel) - s->n_chan = this_board->i_NbrAiChannel; - else - s->n_chan = this_board->i_NbrAiChannelDiff; + s->n_chan = 16; s->maxdata = this_board->i_AiMaxdata; s->len_chanlist = this_board->i_AiChannelList; s->range_table = &range_apci3120_ai; -- cgit v1.2.3-59-g8ed1b From 7fcf666b4a57b9317739f13a6a65d0dbecd47ca8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:44 -0700 Subject: staging: comedi: addi_apci_3120: remove boardinfo 'i_AiChannelList' All boardinfo entries have this member set as '16'. This is also the Analog Input 'n_chan'. For aesthetics, initialize the Analog Input 'len_chanlist' with s->n_chan and remove the boardinfo member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 32e5ad487a1c..d555427d3359 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,7 +16,6 @@ enum apci3120_boardid { struct apci3120_board { const char *name; - int i_AiChannelList; int i_NbrAoChannel; int i_AiMaxdata; int i_AoMaxdata; @@ -25,14 +24,12 @@ struct apci3120_board { static const struct apci3120_board apci3120_boardtypes[] = { [BOARD_APCI3120] = { .name = "apci3120", - .i_AiChannelList = 16, .i_NbrAoChannel = 8, .i_AiMaxdata = 0xffff, .i_AoMaxdata = 0x3fff, }, [BOARD_APCI3001] = { .name = "apci3001", - .i_AiChannelList = 16, .i_AiMaxdata = 0xfff, }, }; @@ -109,7 +106,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, | SDF_DIFF; s->n_chan = 16; s->maxdata = this_board->i_AiMaxdata; - s->len_chanlist = this_board->i_AiChannelList; + s->len_chanlist = s->n_chan; s->range_table = &range_apci3120_ai; s->insn_config = apci3120_ai_insn_config; -- cgit v1.2.3-59-g8ed1b From 2cd6b2b2a9ebca2d8ab9e74ac919a82e6eae45b3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:45 -0700 Subject: staging: comedi: addi_apci_3120: simplify analog output boardinfo There are two boards supported by this driver. One with eight 14-bit analog outputs and the other without analog outputs. Add a bit field flag, 'has_ao', to the boardinfo and remove the 'i_NbrAoChannel' and 'i_AoMaxdata' members. Use the new flag to determine if the analog output subdevice needs to be initialized and open code the n_chan and maxdata. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index d555427d3359..de1dabf72bb3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,17 +16,15 @@ enum apci3120_boardid { struct apci3120_board { const char *name; - int i_NbrAoChannel; int i_AiMaxdata; - int i_AoMaxdata; + unsigned int has_ao:1; }; static const struct apci3120_board apci3120_boardtypes[] = { [BOARD_APCI3120] = { .name = "apci3120", - .i_NbrAoChannel = 8, .i_AiMaxdata = 0xffff, - .i_AoMaxdata = 0x3fff, + .has_ao = 1, }, [BOARD_APCI3001] = { .name = "apci3001", @@ -117,12 +115,11 @@ static int apci3120_auto_attach(struct comedi_device *dev, /* Allocate and Initialise AO Subdevice Structures */ s = &dev->subdevices[1]; - if (this_board->i_NbrAoChannel) { + if (this_board->has_ao) { s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = this_board->i_NbrAoChannel; - s->maxdata = this_board->i_AoMaxdata; - s->len_chanlist = this_board->i_NbrAoChannel; + s->n_chan = 8; + s->maxdata = 0x3fff; s->range_table = &range_apci3120_ao; s->insn_write = apci3120_ao_insn_write; } else { -- cgit v1.2.3-59-g8ed1b From 6a02623de52c574a68be09e03ce15abe378b85aa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:46 -0700 Subject: staging: comedi: addi_apci_3120: simplify analog input boardinfo There are two boards supported by this driver. One with 16-bit analog inputs and the other 12-bit analog inputs. Add a bit field flag, 'ai_is_16bit', to the boardinfo and remove the 'i_AiMaxdata' member. Use the new flag to initialize tne analog input subdevice maxdata correctly. For aesthetics, adjust the whitespace in the boardinfo declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index de1dabf72bb3..9ba66d8ab04f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,19 +16,18 @@ enum apci3120_boardid { struct apci3120_board { const char *name; - int i_AiMaxdata; + unsigned int ai_is_16bit:1; unsigned int has_ao:1; }; static const struct apci3120_board apci3120_boardtypes[] = { [BOARD_APCI3120] = { - .name = "apci3120", - .i_AiMaxdata = 0xffff, - .has_ao = 1, + .name = "apci3120", + .ai_is_16bit = 1, + .has_ao = 1, }, [BOARD_APCI3001] = { - .name = "apci3001", - .i_AiMaxdata = 0xfff, + .name = "apci3001", }, }; @@ -103,7 +102,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; s->n_chan = 16; - s->maxdata = this_board->i_AiMaxdata; + s->maxdata = this_board->ai_is_16bit ? 0xffff : 0x0fff; s->len_chanlist = s->n_chan; s->range_table = &range_apci3120_ai; -- cgit v1.2.3-59-g8ed1b From 0317ffd281663c8f19567d8895866b23cb02e4fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:47 -0700 Subject: staging: comedi: addi_apci_035: separate from addi_common.h Remove the need to include addi_common.h by introducing a new private data definition. Only include the members that are actually used by the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c | 14 +++++++------- drivers/staging/comedi/drivers/addi_apci_035.c | 13 +++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c index a07ee1bd3311..d833da2eeac6 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c @@ -118,7 +118,7 @@ static int apci035_timer_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; unsigned int ui_Status; unsigned int ui_Command; unsigned int ui_Mode; @@ -248,7 +248,7 @@ static int apci035_timer_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; unsigned int ui_Command; int i_Count; @@ -345,7 +345,7 @@ static int apci035_timer_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; unsigned int ui_Status; /* Status register */ i_WatchdogNbr = insn->unused[0]; @@ -380,7 +380,7 @@ static int apci035_ai_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; devpriv->tsk_Current = current; outl(0x200 | 0, devpriv->iobase + 128 + 0x4); @@ -404,7 +404,7 @@ static int apci035_ai_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; unsigned int ui_CommandRegister; /* Set the start */ @@ -420,7 +420,7 @@ static int apci035_ai_read(struct comedi_device *dev, static int apci035_reset(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; int i_Count; for (i_Count = 1; i_Count <= 4; i_Count++) { @@ -437,7 +437,7 @@ static int apci035_reset(struct comedi_device *dev) static irqreturn_t apci035_interrupt(int irq, void *d) { struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; + struct apci035_private *devpriv = dev->private; unsigned int ui_StatusRegister1; unsigned int ui_StatusRegister2; unsigned int ui_ReadCommand; diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index 37b58845231b..d7b7e1aa8b33 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -1,11 +1,20 @@ #include #include +#include +#include #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" -#include "addi-data/addi_common.h" +struct apci035_private { + int iobase; + int i_IobaseAmcc; + int i_IobaseAddon; + int i_IobaseReserved; + unsigned char b_TimerSelectMode; + struct task_struct *tsk_Current; +}; #define ADDIDATA_WATCHDOG 2 /* Or shold it be something else */ @@ -15,7 +24,7 @@ static int apci035_auto_attach(struct comedi_device *dev, unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct addi_private *devpriv; + struct apci035_private *devpriv; struct comedi_subdevice *s; unsigned int dw_Dummy; int ret; -- cgit v1.2.3-59-g8ed1b From 1b7d0642b873370babbd4cb7843de0f2d0446dc9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:48 -0700 Subject: staging: comedi: addi_apci_1500: separate from addi_common.h Remove the need to include addi_common.h by introducing a new private data definition. Only include the members that are actually used by the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1500.c | 24 +++++++++++----------- drivers/staging/comedi/drivers/addi_apci_1500.c | 13 ++++++++++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c index 9896468d86f9..bfa9228c833f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c @@ -158,7 +158,7 @@ static int apci1500_di_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_PatternPolarity = 0, i_PatternTransition = 0, i_PatternMask = 0; int i_MaxChannel = 0, i_Count = 0, i_EventMask = 0; int i_PatternTransitionCount = 0, i_RegValue; @@ -466,7 +466,7 @@ static int apci1500_di_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_Event1InterruptStatus = 0, i_Event2InterruptStatus = 0, i_RegValue; @@ -653,7 +653,7 @@ static int apci1500_di_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_DummyRead = 0; /* Software reset */ @@ -789,7 +789,7 @@ static int apci1500_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; data[1] = inw(devpriv->i_IobaseAddon + APCI1500_DIGITAL_IP); @@ -807,7 +807,7 @@ static int apci1500_do_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; devpriv->b_OutputMemoryStatus = data[0]; return insn->n; @@ -821,7 +821,7 @@ static int apci1500_do_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; static unsigned int ui_Temp; unsigned int ui_Temp1; unsigned int ui_NoOfChannel = CR_CHAN(insn->chanspec); /* get the channel */ @@ -981,7 +981,7 @@ static int apci1500_timer_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_TimerCounterMode, i_MasterConfiguration; devpriv->tsk_Current = current; @@ -1471,7 +1471,7 @@ static int apci1500_timer_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_CommandAndStatusValue; switch (data[0]) { @@ -1731,7 +1731,7 @@ static int apci1500_timer_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_CommandAndStatusValue; switch (data[0]) { @@ -1895,7 +1895,7 @@ static int apci1500_do_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; unsigned int ui_Status; int i_RegValue; int i_Constant; @@ -2015,7 +2015,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) { struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; unsigned int ui_InterruptStatus = 0; int i_RegValue = 0; @@ -2186,7 +2186,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) static int apci1500_reset(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci1500_private *devpriv = dev->private; int i_DummyRead = 0; i_TimerCounter1Init = 0; diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index dc90a8f5388f..de8d74fc6335 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -1,11 +1,20 @@ #include #include +#include +#include #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" -#include "addi-data/addi_common.h" +struct apci1500_private { + int iobase; + int i_IobaseAmcc; + int i_IobaseAddon; + int i_IobaseReserved; + unsigned char b_OutputMemoryStatus; + struct task_struct *tsk_Current; +}; #include "addi-data/hwdrv_apci1500.c" @@ -13,7 +22,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct addi_private *devpriv; + struct apci1500_private *devpriv; struct comedi_subdevice *s; int ret; -- cgit v1.2.3-59-g8ed1b From 4e068bec48c6c25ce0be41a5e38edb5442665b1d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:49 -0700 Subject: staging: comedi: addi_apci_3120: separate from addi_common.h Remove the need to include addi_common.h by introducing a new private data definition. Only include the members that are actually used by the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 38 ++++++++++---------- drivers/staging/comedi/drivers/addi_apci_3120.c | 42 ++++++++++++++++++---- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index e120d620b3ce..a2db2facab70 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -246,7 +246,7 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int i; if ((data[0] != APCI3120_EOC_MODE) && (data[0] != APCI3120_EOS_MODE)) @@ -300,7 +300,7 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, unsigned int *chanlist, char check) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int i; unsigned int gain; unsigned short us_TmpValue; @@ -349,7 +349,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned short us_ConvertTiming, us_TmpValue, i; unsigned char b_Tmp; @@ -585,7 +585,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, static int apci3120_reset(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int i; unsigned short us_TmpValue; @@ -638,7 +638,7 @@ static int apci3120_reset(struct comedi_device *dev) static int apci3120_exttrig_enable(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); @@ -647,7 +647,7 @@ static int apci3120_exttrig_enable(struct comedi_device *dev) static int apci3120_exttrig_disable(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); @@ -657,7 +657,7 @@ static int apci3120_exttrig_disable(struct comedi_device *dev) static int apci3120_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; /* Disable A2P Fifo write and AMWEN signal */ outw(0, devpriv->i_IobaseAddon + 4); @@ -778,7 +778,7 @@ static int apci3120_cyclic_ai(int mode, struct comedi_device *dev, struct comedi_subdevice *s) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned char b_Tmp; unsigned int ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 = @@ -1200,7 +1200,7 @@ static int apci3120_cyclic_ai(int mode, static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; /* loading private structure with cmd structure inputs */ @@ -1225,7 +1225,7 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, unsigned short *dma_buffer, unsigned int num_samples) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; devpriv->ui_AiActualScan += @@ -1245,7 +1245,7 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, static void apci3120_interrupt_dma(int irq, void *d) { struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; unsigned int next_dma_buf, samplesinbuf; @@ -1393,7 +1393,7 @@ static void apci3120_interrupt_dma(int irq, void *d) */ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; int n_chan, i; int err = 1; @@ -1414,7 +1414,7 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) static irqreturn_t apci3120_interrupt(int irq, void *d) { struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; unsigned short int_daq; unsigned int int_amcc, ui_Check, i; @@ -1600,7 +1600,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int ui_Timervalue2; unsigned short us_TmpValue; unsigned char b_Tmp; @@ -1737,7 +1737,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int ui_Timervalue2 = 0; unsigned short us_TmpValue; unsigned char b_Tmp; @@ -1902,7 +1902,7 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned char b_Tmp; unsigned short us_TmpValue, us_TmpValue_2, us_StatusValue; @@ -1950,7 +1950,7 @@ static int apci3120_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int val; /* the input channels are bits 11:8 of the status reg */ @@ -1965,7 +1965,7 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; if (comedi_dio_update_state(s, data)) { /* The do channels are bits 7:4 of the do register */ @@ -1985,7 +1985,7 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; unsigned int ui_Range, ui_Channel; unsigned short us_TmpValue; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 9ba66d8ab04f..2f0b642cfbff 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1,14 +1,12 @@ #include #include +#include +#include #include "../comedidev.h" #include "comedi_fc.h" #include "amcc_s5933.h" -#include "addi-data/addi_common.h" - -#include "addi-data/hwdrv_apci3120.c" - enum apci3120_boardid { BOARD_APCI3120, BOARD_APCI3001, @@ -31,12 +29,44 @@ static const struct apci3120_board apci3120_boardtypes[] = { }, }; +struct apci3120_private { + int iobase; + int i_IobaseAmcc; + int i_IobaseAddon; + int i_IobaseReserved; + unsigned int ui_AiActualScan; + unsigned int ui_AiNbrofChannels; + unsigned int ui_AiChannelList[32]; + unsigned int ui_AiReadData[32]; + unsigned short us_UseDma; + unsigned char b_DmaDoubleBuffer; + unsigned int ui_DmaActualBuffer; + unsigned short *ul_DmaBufferVirtual[2]; + dma_addr_t ul_DmaBufferHw[2]; + unsigned int ui_DmaBufferSize[2]; + unsigned int ui_DmaBufferUsesize[2]; + unsigned char b_DigitalOutputRegister; + unsigned char b_TimerSelectMode; + unsigned char b_ModeSelectRegister; + unsigned short us_OutputRegister; + unsigned char b_Timer2Mode; + unsigned char b_Timer2Interrupt; + unsigned int ai_running:1; + unsigned char b_InterruptMode; + unsigned char b_EocEosInterrupt; + unsigned int ui_EocEosConversionTime; + unsigned char b_ExttrigEnable; + struct task_struct *tsk_Current; +}; + +#include "addi-data/hwdrv_apci3120.c" + static int apci3120_auto_attach(struct comedi_device *dev, unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct apci3120_board *this_board = NULL; - struct addi_private *devpriv; + struct apci3120_private *devpriv; struct comedi_subdevice *s; int ret, order, i; @@ -163,7 +193,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, static void apci3120_detach(struct comedi_device *dev) { - struct addi_private *devpriv = dev->private; + struct apci3120_private *devpriv = dev->private; if (dev->iobase) apci3120_reset(dev); -- cgit v1.2.3-59-g8ed1b From a0a7ae158a18a62b0661b3ef23ec1cbfec09ace0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 10:44:50 -0700 Subject: staging: comedi: addi_common.h: remove file This header is no longer included by any of the addi-data drivers. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.h | 52 ---------------------- 1 file changed, 52 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_common.h diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h deleted file mode 100644 index 52f35b4c00dc..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - * - * ADDI-DATA GmbH - * Dieselstrasse 3 - * D-77833 Ottersweier - * Tel: +19(0)7223/9493-0 - * Fax: +49(0)7223/9493-92 - * http://www.addi-data.com - * info@addi-data.com - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include - -struct addi_private { - int iobase; - int i_IobaseAmcc; /* base+size for AMCC chip */ - int i_IobaseAddon; /* addon base address */ - int i_IobaseReserved; - unsigned int ui_AiActualScan; /* how many scans we finished */ - unsigned int ui_AiNbrofChannels; /* how many channels is measured */ - unsigned int ui_AiChannelList[32]; /* actual chanlist */ - unsigned int ui_AiReadData[32]; - unsigned short us_UseDma; /* To use Dma or not */ - unsigned char b_DmaDoubleBuffer; /* we can use double buffering */ - unsigned int ui_DmaActualBuffer; /* which buffer is used now */ - unsigned short *ul_DmaBufferVirtual[2]; /* pointers to DMA buffer */ - dma_addr_t ul_DmaBufferHw[2]; /* hw address of DMA buff */ - unsigned int ui_DmaBufferSize[2]; /* size of dma buffer in bytes */ - unsigned int ui_DmaBufferUsesize[2]; /* which size we may now used for transfer */ - unsigned char b_DigitalOutputRegister; /* Digital Output Register */ - unsigned char b_OutputMemoryStatus; - unsigned char b_TimerSelectMode; /* Contain data written at iobase + 0C */ - unsigned char b_ModeSelectRegister; /* Contain data written at iobase + 0E */ - unsigned short us_OutputRegister; /* Contain data written at iobase + 0 */ - unsigned char b_Timer2Mode; /* Specify the timer 2 mode */ - unsigned char b_Timer2Interrupt; /* Timer2 interrupt enable or disable */ - unsigned int ai_running:1; - unsigned char b_InterruptMode; /* eoc eos or dma */ - unsigned char b_EocEosInterrupt; /* Enable disable eoc eos interrupt */ - unsigned int ui_EocEosConversionTime; - unsigned char b_ExttrigEnable; /* To enable or disable external trigger */ - - /* Pointer to the current process */ - struct task_struct *tsk_Current; -}; -- cgit v1.2.3-59-g8ed1b From 67f61f7ae9dd3e1b0ac9c2136aba2fca6740d8bf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 12:14:37 -0700 Subject: staging: comedi: usbdux: introduce usbduxsub_ao_handle_urb() Factor the urb handling and resubmit out of the analog output urb completion handler and tidy it up. This allows a common exit path to be used in the completion handler to stop the async command and handle the events. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Reviewed-by: Bernd Porr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 130 +++++++++++++++----------------- 1 file changed, 62 insertions(+), 68 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 89f6ece2f0aa..5fdbf2644e09 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -399,69 +399,25 @@ static int usbdux_ao_cancel(struct comedi_device *dev, return 0; } -static void usbduxsub_ao_isoc_irq(struct urb *urb) +static void usbduxsub_ao_handle_urb(struct comedi_device *dev, + struct comedi_subdevice *s, + struct urb *urb) { - struct comedi_device *dev = urb->context; - struct comedi_subdevice *s = dev->write_subdev; struct usbdux_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; uint8_t *datap; int ret; int i; - switch (urb->status) { - case 0: - /* success */ - break; - - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - case -ECONNABORTED: - /* after an unlink command, unplug, ... etc */ - /* no unlink needed here. Already shutting down. */ - if (devpriv->ao_cmd_running) { - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - usbdux_ao_stop(dev, 0); - } - return; - - default: - /* a real error */ - if (devpriv->ao_cmd_running) { - dev_err(dev->class_dev, - "Non-zero urb status received in ao intr context: %d\n", - urb->status); - s->async->events |= COMEDI_CB_ERROR; - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - /* we do an unlink if we are in the high speed mode */ - usbdux_ao_stop(dev, 0); - } - return; - } - - /* are we actually running? */ - if (!devpriv->ao_cmd_running) - return; - - /* normal operation: executing a command in this subdevice */ devpriv->ao_counter--; - if ((int)devpriv->ao_counter <= 0) { - /* timer zero */ + if (devpriv->ao_counter == 0) { devpriv->ao_counter = devpriv->ao_timer; - /* handle non continous acquisition */ if (cmd->stop_src == TRIG_COUNT) { - /* fixed number of samples */ devpriv->ao_sample_count--; if (devpriv->ao_sample_count < 0) { - /* all samples transmitted */ - usbdux_ao_stop(dev, 0); - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - /* no resubmit of the urb */ + async->events |= COMEDI_CB_EOA; return; } } @@ -473,26 +429,26 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short val; - ret = comedi_buf_get(s, &val); - if (ret < 0) { + if (!comedi_buf_get(s, &val)) { dev_err(dev->class_dev, "buffer underflow\n"); - s->async->events |= (COMEDI_CB_EOA | - COMEDI_CB_OVERFLOW); + async->events |= COMEDI_CB_OVERFLOW; + return; } + /* pointer to the DA */ *datap++ = val & 0xff; *datap++ = (val >> 8) & 0xff; *datap++ = chan << 6; s->readback[chan] = val; - - s->async->events |= COMEDI_CB_BLOCK; - comedi_event(dev, s); } + async->events |= COMEDI_CB_BLOCK; } - urb->transfer_buffer_length = SIZEOUTBUF; - urb->dev = comedi_to_usb_dev(dev); - urb->status = 0; - if (devpriv->ao_cmd_running) { + + /* if command is still running, resubmit urb for BULK transfer */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + urb->transfer_buffer_length = SIZEOUTBUF; + urb->dev = comedi_to_usb_dev(dev); + urb->status = 0; if (devpriv->high_speed) urb->interval = 8; /* uframes */ else @@ -509,16 +465,54 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) if (ret == -EL2NSYNC) dev_err(dev->class_dev, "buggy USB host controller or bug in IRQ handling!\n"); - - s->async->events |= COMEDI_CB_EOA; - s->async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); - /* don't do an unlink here */ - usbdux_ao_stop(dev, 0); + async->events |= COMEDI_CB_ERROR; } } } +static void usbduxsub_ao_isoc_irq(struct urb *urb) +{ + struct comedi_device *dev = urb->context; + struct comedi_subdevice *s = dev->write_subdev; + struct comedi_async *async = s->async; + struct usbdux_private *devpriv = dev->private; + + /* exit if not running a command, do not resubmit urb */ + if (!devpriv->ao_cmd_running) + return; + + switch (urb->status) { + case 0: + usbduxsub_ao_handle_urb(dev, s, urb); + break; + + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + case -ECONNABORTED: + /* after an unlink command, unplug, ... etc */ + async->events |= COMEDI_CB_ERROR; + break; + + default: + /* a real error */ + dev_err(dev->class_dev, + "Non-zero urb status received in ao intr context: %d\n", + urb->status); + async->events |= COMEDI_CB_ERROR; + break; + } + + /* + * comedi_handle_events() cannot be used in this driver. The (*cancel) + * operation would unlink the urb. + */ + if (async->events & COMEDI_CB_CANCEL_MASK) + usbdux_ao_stop(dev, 0); + + comedi_event(dev, s); +} + static int usbdux_submit_urbs(struct comedi_device *dev, struct urb **urbs, int num_urbs, int input_urb) -- cgit v1.2.3-59-g8ed1b From 41ca22a8c575b5f2e76150a30db5d1a934ed7ca9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 12:14:38 -0700 Subject: staging: comedi: usbdux: introduce usbduxsub_ai_handle_urb() Factor the urb handling and resubmit out of the analog input urb completion handler and tidy it up. This allows a common exit path to be used in the completion handler to stop the async command and handle the events. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Reviewed-by: Bernd Porr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 174 +++++++++++++++----------------- 1 file changed, 79 insertions(+), 95 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 5fdbf2644e09..eae441f3858c 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -250,128 +250,112 @@ static int usbdux_ai_cancel(struct comedi_device *dev, return 0; } -/* analogue IN - interrupt service routine */ +static void usbduxsub_ai_handle_urb(struct comedi_device *dev, + struct comedi_subdevice *s, + struct urb *urb) +{ + struct usbdux_private *devpriv = dev->private; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + int ret; + int i; + + devpriv->ai_counter--; + if (devpriv->ai_counter == 0) { + devpriv->ai_counter = devpriv->ai_timer; + + if (cmd->stop_src == TRIG_COUNT) { + devpriv->ai_sample_count--; + if (devpriv->ai_sample_count < 0) { + async->events |= COMEDI_CB_EOA; + return; + } + } + + /* get the data from the USB bus and hand it over to comedi */ + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int range = CR_RANGE(cmd->chanlist[i]); + uint16_t val = le16_to_cpu(devpriv->in_buf[i]); + + /* bipolar data is two's-complement */ + if (comedi_range_is_bipolar(s, range)) + val ^= ((s->maxdata + 1) >> 1); + + /* transfer data */ + if (!comedi_buf_put(s, val)) + return; + } + async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + } + + /* if command is still running, resubmit urb */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + urb->dev = comedi_to_usb_dev(dev); + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret < 0) { + dev_err(dev->class_dev, + "urb resubmit failed in int-context! err=%d\n", + ret); + if (ret == -EL2NSYNC) + dev_err(dev->class_dev, + "buggy USB host controller or bug in IRQ handler!\n"); + async->events |= COMEDI_CB_ERROR; + } + } +} + static void usbduxsub_ai_isoc_irq(struct urb *urb) { struct comedi_device *dev = urb->context; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; struct usbdux_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - int i, err; - /* first we test if something unusual has just happened */ + /* exit if not running a command, do not resubmit urb */ + if (!devpriv->ai_cmd_running) + return; + switch (urb->status) { case 0: /* copy the result in the transfer buffer */ memcpy(devpriv->in_buf, urb->transfer_buffer, SIZEINBUF); + usbduxsub_ai_handle_urb(dev, s, urb); break; + case -EILSEQ: - /* error in the ISOchronous data */ - /* we don't copy the data into the transfer buffer */ - /* and recycle the last data byte */ + /* + * error in the ISOchronous data + * we don't copy the data into the transfer buffer + * and recycle the last data byte + */ dev_dbg(dev->class_dev, "CRC error in ISO IN stream\n"); + usbduxsub_ai_handle_urb(dev, s, urb); break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: case -ECONNABORTED: - /* happens after an unlink command */ - if (devpriv->ai_cmd_running) { - s->async->events |= COMEDI_CB_EOA; - s->async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); - /* stop the transfer w/o unlink */ - usbdux_ai_stop(dev, 0); - } - return; + /* after an unlink command, unplug, ... etc */ + async->events |= COMEDI_CB_ERROR; + break; default: - /* a real error on the bus */ - /* pass error to comedi if we are really running a command */ - if (devpriv->ai_cmd_running) { - dev_err(dev->class_dev, - "Non-zero urb status received in ai intr context: %d\n", - urb->status); - s->async->events |= COMEDI_CB_EOA; - s->async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); - /* don't do an unlink here */ - usbdux_ai_stop(dev, 0); - } - return; + /* a real error */ + dev_err(dev->class_dev, + "Non-zero urb status received in ai intr context: %d\n", + urb->status); + async->events |= COMEDI_CB_ERROR; + break; } /* - * at this point we are reasonably sure that nothing dodgy has happened - * are we running a command? + * comedi_handle_events() cannot be used in this driver. The (*cancel) + * operation would unlink the urb. */ - if (unlikely(!devpriv->ai_cmd_running)) { - /* - * not running a command, do not continue execution if no - * asynchronous command is running in particular not resubmit - */ - return; - } - - urb->dev = comedi_to_usb_dev(dev); - - /* resubmit the urb */ - err = usb_submit_urb(urb, GFP_ATOMIC); - if (unlikely(err < 0)) { - dev_err(dev->class_dev, - "urb resubmit failed in int-context! err=%d\n", err); - if (err == -EL2NSYNC) - dev_err(dev->class_dev, - "buggy USB host controller or bug in IRQ handler!\n"); - s->async->events |= COMEDI_CB_EOA; - s->async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); - /* don't do an unlink here */ + if (async->events & COMEDI_CB_CANCEL_MASK) usbdux_ai_stop(dev, 0); - return; - } - - devpriv->ai_counter--; - if (likely(devpriv->ai_counter > 0)) - return; - - /* timer zero, transfer measurements to comedi */ - devpriv->ai_counter = devpriv->ai_timer; - /* test, if we transmit only a fixed number of samples */ - if (cmd->stop_src == TRIG_COUNT) { - /* not continuous, fixed number of samples */ - devpriv->ai_sample_count--; - /* all samples received? */ - if (devpriv->ai_sample_count < 0) { - /* prevent a resubmit next time */ - usbdux_ai_stop(dev, 0); - /* say comedi that the acquistion is over */ - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - return; - } - } - /* get the data from the USB bus and hand it over to comedi */ - for (i = 0; i < cmd->chanlist_len; i++) { - unsigned int range = CR_RANGE(cmd->chanlist[i]); - uint16_t val = le16_to_cpu(devpriv->in_buf[i]); - - /* bipolar data is two's-complement */ - if (comedi_range_is_bipolar(s, range)) - val ^= ((s->maxdata + 1) >> 1); - - /* transfer data */ - err = comedi_buf_put(s, val); - if (unlikely(err == 0)) { - /* buffer overflow */ - usbdux_ai_stop(dev, 0); - return; - } - } - /* tell comedi that data is there */ - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; comedi_event(dev, s); } -- cgit v1.2.3-59-g8ed1b From 7c88f9f48c6fcf31aeda755b723befad642150ca Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 12:14:39 -0700 Subject: staging: comedi: usbduxfast: introduce usbduxfast_ai_handle_urb() Factor the urb handling and resubmit out of the completion handler and tidy it up. This allows a common exit path to be used in the completion handler to stop the async command and handle the events. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Reviewed-by: Bernd Porr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 131 +++++++++++----------------- 1 file changed, 52 insertions(+), 79 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index cddc2ba294bb..95c2ec7ed22a 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -236,114 +236,87 @@ static int usbduxfast_ai_cancel(struct comedi_device *dev, return ret; } -/* - * analogue IN - * interrupt service routine - */ +static void usbduxfast_ai_handle_urb(struct comedi_device *dev, + struct comedi_subdevice *s, + struct urb *urb) +{ + struct usbduxfast_private *devpriv = dev->private; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + int ret; + + if (devpriv->ignore) { + devpriv->ignore--; + } else { + unsigned int nbytes = urb->actual_length; + + if (cmd->stop_src == TRIG_COUNT) { + unsigned int nsamples = nbytes / bytes_per_sample(s); + + if (devpriv->ai_sample_count < nsamples) { + nsamples = devpriv->ai_sample_count; + async->events |= COMEDI_CB_EOA; + } + devpriv->ai_sample_count -= nsamples; + nbytes = nsamples * bytes_per_sample(s); + } + + cfc_write_array_to_buffer(s, urb->transfer_buffer, nbytes); + } + + /* if command is still running, resubmit urb for BULK transfer */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + urb->dev = comedi_to_usb_dev(dev); + urb->status = 0; + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret < 0) { + dev_err(dev->class_dev, "urb resubm failed: %d", ret); + async->events |= COMEDI_CB_ERROR; + } + } +} + static void usbduxfast_ai_interrupt(struct urb *urb) { struct comedi_device *dev = urb->context; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; - struct usb_device *usb = comedi_to_usb_dev(dev); struct usbduxfast_private *devpriv = dev->private; - int n, err; - /* are we running a command? */ - if (unlikely(!devpriv->ai_cmd_running)) { - /* - * not running a command - * do not continue execution if no asynchronous command - * is running in particular not resubmit - */ + /* exit if not running a command, do not resubmit urb */ + if (!devpriv->ai_cmd_running) return; - } - /* first we test if something unusual has just happened */ switch (urb->status) { case 0: + usbduxfast_ai_handle_urb(dev, s, urb); break; - /* - * happens after an unlink command or when the device - * is plugged out - */ case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: case -ECONNABORTED: - /* tell this comedi */ - async->events |= COMEDI_CB_EOA; + /* after an unlink command, unplug, ... etc */ async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); - /* stop the transfer w/o unlink */ - usbduxfast_ai_stop(dev, 0); - return; + break; default: + /* a real error */ dev_err(dev->class_dev, "non-zero urb status received in ai intr context: %d\n", urb->status); - async->events |= COMEDI_CB_EOA; async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); - usbduxfast_ai_stop(dev, 0); - return; - } - - if (!devpriv->ignore) { - if (cmd->stop_src == TRIG_COUNT) { - /* not continuous, fixed number of samples */ - n = urb->actual_length / sizeof(uint16_t); - if (unlikely(devpriv->ai_sample_count < n)) { - unsigned int num_bytes; - - /* partial sample received */ - num_bytes = devpriv->ai_sample_count * - sizeof(uint16_t); - cfc_write_array_to_buffer(s, - urb->transfer_buffer, - num_bytes); - usbduxfast_ai_stop(dev, 0); - /* tell comedi that the acquistion is over */ - async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - return; - } - devpriv->ai_sample_count -= n; - } - /* write the full buffer to comedi */ - err = cfc_write_array_to_buffer(s, urb->transfer_buffer, - urb->actual_length); - if (unlikely(err == 0)) { - /* buffer overflow */ - usbduxfast_ai_stop(dev, 0); - return; - } - - /* tell comedi that data is there */ - comedi_event(dev, s); - } else { - /* ignore this packet */ - devpriv->ignore--; + break; } /* - * command is still running - * resubmit urb for BULK transfer + * comedi_handle_events() cannot be used in this driver. The (*cancel) + * operation would unlink the urb. */ - urb->dev = usb; - urb->status = 0; - err = usb_submit_urb(urb, GFP_ATOMIC); - if (err < 0) { - dev_err(dev->class_dev, - "urb resubm failed: %d", err); - async->events |= COMEDI_CB_EOA; - async->events |= COMEDI_CB_ERROR; - comedi_event(dev, s); + if (async->events & COMEDI_CB_CANCEL_MASK) usbduxfast_ai_stop(dev, 0); - } + + comedi_event(dev, s); } static int usbduxfast_submit_urb(struct comedi_device *dev) -- cgit v1.2.3-59-g8ed1b From 7a5dfb212010e017b8bbc91f8df196258f790f90 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 12:14:40 -0700 Subject: staging: comedi: usbduxsigma: introduce usbduxsigma_ao_handle_urb() Factor the urb handling and resubmit out of the analog output urb completion handler and tidy it up. This allows a common exit path to be used in the completion handler to stop the async command and handle the events. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Reviewed-by: Bernd Porr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 148 ++++++++++++++------------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index a869e38c777b..985c6f08c56e 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -349,62 +349,25 @@ static int usbduxsigma_ao_cancel(struct comedi_device *dev, return 0; } -static void usbduxsigma_ao_urb_complete(struct urb *urb) +static void usbduxsigma_ao_handle_urb(struct comedi_device *dev, + struct comedi_subdevice *s, + struct urb *urb) { - struct comedi_device *dev = urb->context; struct usbduxsigma_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->write_subdev; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; uint8_t *datap; int ret; int i; - switch (urb->status) { - case 0: - /* success */ - break; - - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - case -ECONNABORTED: - /* happens after an unlink command */ - if (devpriv->ao_cmd_running) { - usbduxsigma_ao_stop(dev, 0); /* w/o unlink */ - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - } - return; - - default: - /* a real error */ - if (devpriv->ao_cmd_running) { - dev_err(dev->class_dev, - "%s: non-zero urb status (%d)\n", - __func__, urb->status); - usbduxsigma_ao_stop(dev, 0); /* w/o unlink */ - s->async->events |= (COMEDI_CB_ERROR | COMEDI_CB_EOA); - comedi_event(dev, s); - } - return; - } - - if (!devpriv->ao_cmd_running) - return; - devpriv->ao_counter--; - if ((int)devpriv->ao_counter <= 0) { - /* timer zero, transfer from comedi */ + if (devpriv->ao_counter == 0) { devpriv->ao_counter = devpriv->ao_timer; if (cmd->stop_src == TRIG_COUNT) { - /* not continuous, fixed number of samples */ devpriv->ao_sample_count--; if (devpriv->ao_sample_count < 0) { - usbduxsigma_ao_stop(dev, 0); /* w/o unlink */ - /* acquistion is over, tell comedi */ - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); + async->events |= COMEDI_CB_EOA; return; } } @@ -416,44 +379,85 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short val; - ret = comedi_buf_get(s, &val); - if (ret < 0) { + if (!comedi_buf_get(s, &val)) { dev_err(dev->class_dev, "buffer underflow\n"); - s->async->events |= (COMEDI_CB_EOA | - COMEDI_CB_OVERFLOW); + async->events |= COMEDI_CB_OVERFLOW; + return; } + *datap++ = val; *datap++ = chan; s->readback[chan] = val; - - s->async->events |= COMEDI_CB_BLOCK; - comedi_event(dev, s); } + async->events |= COMEDI_CB_BLOCK; } - urb->transfer_buffer_length = SIZEOUTBUF; - urb->dev = comedi_to_usb_dev(dev); - urb->status = 0; - if (devpriv->high_speed) - urb->interval = 8; /* uframes */ - else - urb->interval = 1; /* frames */ - urb->number_of_packets = 1; - urb->iso_frame_desc[0].offset = 0; - urb->iso_frame_desc[0].length = SIZEOUTBUF; - urb->iso_frame_desc[0].status = 0; - ret = usb_submit_urb(urb, GFP_ATOMIC); - if (ret < 0) { - dev_err(dev->class_dev, - "%s: urb resubmit failed (%d)\n", - __func__, ret); - if (ret == -EL2NSYNC) + /* if command is still running, resubmit urb */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + urb->transfer_buffer_length = SIZEOUTBUF; + urb->dev = comedi_to_usb_dev(dev); + urb->status = 0; + if (devpriv->high_speed) + urb->interval = 8; /* uframes */ + else + urb->interval = 1; /* frames */ + urb->number_of_packets = 1; + urb->iso_frame_desc[0].offset = 0; + urb->iso_frame_desc[0].length = SIZEOUTBUF; + urb->iso_frame_desc[0].status = 0; + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret < 0) { dev_err(dev->class_dev, - "buggy USB host controller or bug in IRQ handler\n"); - usbduxsigma_ao_stop(dev, 0); /* w/o unlink */ - s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR); - comedi_event(dev, s); + "%s: urb resubmit failed (%d)\n", + __func__, ret); + if (ret == -EL2NSYNC) + dev_err(dev->class_dev, + "buggy USB host controller or bug in IRQ handler\n"); + async->events |= COMEDI_CB_ERROR; + } + } +} + +static void usbduxsigma_ao_urb_complete(struct urb *urb) +{ + struct comedi_device *dev = urb->context; + struct usbduxsigma_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->write_subdev; + struct comedi_async *async = s->async; + + /* exit if not running a command, do not resubmit urb */ + if (!devpriv->ao_cmd_running) + return; + + switch (urb->status) { + case 0: + usbduxsigma_ao_handle_urb(dev, s, urb); + break; + + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + case -ECONNABORTED: + /* happens after an unlink command */ + async->events |= COMEDI_CB_ERROR; + break; + + default: + /* a real error */ + dev_err(dev->class_dev, "%s: non-zero urb status (%d)\n", + __func__, urb->status); + async->events |= COMEDI_CB_ERROR; + break; } + + /* + * comedi_handle_events() cannot be used in this driver. The (*cancel) + * operation would unlink the urb. + */ + if (async->events & COMEDI_CB_CANCEL_MASK) + usbduxsigma_ao_stop(dev, 0); + + comedi_event(dev, s); } static int usbduxsigma_submit_urbs(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From bcbb0c47c73dc19f19b78e849545cb4b030e94dd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 14 Oct 2014 12:14:41 -0700 Subject: staging: comedi: usbduxsigma: introduce usbduxsigma_ai_handle_urb() Factor the urb handling and resubmit out of the analog input urb completion handler and tidy it up. This allows a common exit path to be used in the completion handler to stop the async command and handle the events. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Reviewed-by: Bernd Porr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 157 +++++++++++++-------------- 1 file changed, 76 insertions(+), 81 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 985c6f08c56e..1d12cc6c1ade 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -211,23 +211,80 @@ static int usbduxsigma_ai_cancel(struct comedi_device *dev, return 0; } -static void usbduxsigma_ai_urb_complete(struct urb *urb) +static void usbduxsigma_ai_handle_urb(struct comedi_device *dev, + struct comedi_subdevice *s, + struct urb *urb) { - struct comedi_device *dev = urb->context; struct usbduxsigma_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; unsigned int dio_state; uint32_t val; int ret; int i; - /* first we test if something unusual has just happened */ + devpriv->ai_counter--; + if (devpriv->ai_counter == 0) { + devpriv->ai_counter = devpriv->ai_timer; + + if (cmd->stop_src == TRIG_COUNT) { + devpriv->ai_sample_count--; + if (devpriv->ai_sample_count < 0) { + async->events |= COMEDI_CB_EOA; + return; + } + } + + /* get the state of the dio pins to allow external trigger */ + dio_state = be32_to_cpu(devpriv->in_buf[0]); + + /* get the data from the USB bus and hand it over to comedi */ + for (i = 0; i < cmd->chanlist_len; i++) { + /* transfer data, note first byte is the DIO state */ + val = be32_to_cpu(devpriv->in_buf[i+1]); + val &= 0x00ffffff; /* strip status byte */ + val ^= 0x00800000; /* convert to unsigned */ + + if (!cfc_write_array_to_buffer(s, &val, + sizeof(uint32_t))) + return; + } + } + + /* if command is still running, resubmit urb */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + urb->dev = comedi_to_usb_dev(dev); + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret < 0) { + dev_err(dev->class_dev, + "%s: urb resubmit failed (%d)\n", + __func__, ret); + if (ret == -EL2NSYNC) + dev_err(dev->class_dev, + "buggy USB host controller or bug in IRQ handler\n"); + async->events |= COMEDI_CB_ERROR; + } + } +} + +static void usbduxsigma_ai_urb_complete(struct urb *urb) +{ + struct comedi_device *dev = urb->context; + struct usbduxsigma_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + + /* exit if not running a command, do not resubmit urb */ + if (!devpriv->ai_cmd_running) + return; + switch (urb->status) { case 0: /* copy the result in the transfer buffer */ memcpy(devpriv->in_buf, urb->transfer_buffer, SIZEINBUF); + usbduxsigma_ai_handle_urb(dev, s, urb); break; + case -EILSEQ: /* * error in the ISOchronous data @@ -235,7 +292,7 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb) * and recycle the last data byte */ dev_dbg(dev->class_dev, "CRC error in ISO IN stream\n"); - + usbduxsigma_ai_handle_urb(dev, s, urb); break; case -ECONNRESET: @@ -243,86 +300,24 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb) case -ESHUTDOWN: case -ECONNABORTED: /* happens after an unlink command */ - if (devpriv->ai_cmd_running) { - usbduxsigma_ai_stop(dev, 0); /* w/o unlink */ - /* we are still running a command, tell comedi */ - s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR); - comedi_event(dev, s); - } - return; + async->events |= COMEDI_CB_ERROR; + break; default: - /* - * a real error on the bus - * pass error to comedi if we are really running a command - */ - if (devpriv->ai_cmd_running) { - dev_err(dev->class_dev, - "%s: non-zero urb status (%d)\n", - __func__, urb->status); - usbduxsigma_ai_stop(dev, 0); /* w/o unlink */ - s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR); - comedi_event(dev, s); - } - return; - } - - if (unlikely(!devpriv->ai_cmd_running)) - return; - - urb->dev = comedi_to_usb_dev(dev); - - ret = usb_submit_urb(urb, GFP_ATOMIC); - if (unlikely(ret < 0)) { - dev_err(dev->class_dev, "%s: urb resubmit failed (%d)\n", - __func__, ret); - if (ret == -EL2NSYNC) - dev_err(dev->class_dev, - "buggy USB host controller or bug in IRQ handler\n"); - usbduxsigma_ai_stop(dev, 0); /* w/o unlink */ - s->async->events |= (COMEDI_CB_EOA | COMEDI_CB_ERROR); - comedi_event(dev, s); - return; - } - - /* get the state of the dio pins to allow external trigger */ - dio_state = be32_to_cpu(devpriv->in_buf[0]); - - devpriv->ai_counter--; - if (likely(devpriv->ai_counter > 0)) - return; - - /* timer zero, transfer measurements to comedi */ - devpriv->ai_counter = devpriv->ai_timer; - - if (cmd->stop_src == TRIG_COUNT) { - /* not continuous, fixed number of samples */ - devpriv->ai_sample_count--; - if (devpriv->ai_sample_count < 0) { - usbduxsigma_ai_stop(dev, 0); /* w/o unlink */ - /* acquistion is over, tell comedi */ - s->async->events |= COMEDI_CB_EOA; - comedi_event(dev, s); - return; - } + /* a real error */ + dev_err(dev->class_dev, "%s: non-zero urb status (%d)\n", + __func__, urb->status); + async->events |= COMEDI_CB_ERROR; + break; } - /* get the data from the USB bus and hand it over to comedi */ - for (i = 0; i < cmd->chanlist_len; i++) { - /* transfer data, note first byte is the DIO state */ - val = be32_to_cpu(devpriv->in_buf[i+1]); - val &= 0x00ffffff; /* strip status byte */ - val ^= 0x00800000; /* convert to unsigned */ + /* + * comedi_handle_events() cannot be used in this driver. The (*cancel) + * operation would unlink the urb. + */ + if (async->events & COMEDI_CB_CANCEL_MASK) + usbduxsigma_ai_stop(dev, 0); - ret = cfc_write_array_to_buffer(s, &val, sizeof(uint32_t)); - if (unlikely(ret == 0)) { - /* buffer overflow */ - usbduxsigma_ai_stop(dev, 0); /* w/o unlink */ - return; - } - } - /* tell comedi that data is there */ - s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); comedi_event(dev, s); } -- cgit v1.2.3-59-g8ed1b From 4a3df1540b980216d558c063a1e32a81d194bf6d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 10:37:43 -0700 Subject: staging: comedi: addi_apci_035: remove driver According to ADDI-DATA, this board was discontinued last year and they feel that no further development is needed for this driver. Remove the driver from comedi to help with the addi-data cleanup. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 8 - drivers/staging/comedi/drivers/Makefile | 1 - .../comedi/drivers/addi-data/hwdrv_apci035.c | 482 --------------------- drivers/staging/comedi/drivers/addi_apci_035.c | 129 ------ 4 files changed, 620 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c delete mode 100644 drivers/staging/comedi/drivers/addi_apci_035.c diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 77c5013d81c5..d4214c086f39 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -594,14 +594,6 @@ config COMEDI_ADDI_WATCHDOG boards. This module will be automatically selected when needed. The module will be called addi_watchdog. -config COMEDI_ADDI_APCI_035 - tristate "ADDI-DATA APCI_035 support" - ---help--- - Enable support for ADDI-DATA APCI_035 cards - - To compile this driver as a module, choose M here: the module will be - called addi_apci_035. - config COMEDI_ADDI_APCI_1032 tristate "ADDI-DATA APCI_1032 support" ---help--- diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 6bc9ef3b25b3..84fdf20ca986 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -60,7 +60,6 @@ obj-$(CONFIG_COMEDI_S526) += s526.o # Comedi PCI drivers obj-$(CONFIG_COMEDI_8255_PCI) += 8255_pci.o obj-$(CONFIG_COMEDI_ADDI_WATCHDOG) += addi_watchdog.o -obj-$(CONFIG_COMEDI_ADDI_APCI_035) += addi_apci_035.o obj-$(CONFIG_COMEDI_ADDI_APCI_1032) += addi_apci_1032.o obj-$(CONFIG_COMEDI_ADDI_APCI_1500) += addi_apci_1500.o obj-$(CONFIG_COMEDI_ADDI_APCI_1516) += addi_apci_1516.o diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c deleted file mode 100644 index d833da2eeac6..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - * - * ADDI-DATA GmbH - * Dieselstrasse 3 - * D-77833 Ottersweier - * Tel: +19(0)7223/9493-0 - * Fax: +49(0)7223/9493-92 - * http://www.addi-data.com - * info@addi-data.com - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - */ - -/* Card Specific information */ -#define APCI035_ADDRESS_RANGE 255 - -/* Timer / Watchdog Related Defines */ -#define APCI035_TCW_SYNC_ENABLEDISABLE 0 -#define APCI035_TCW_RELOAD_VALUE 4 -#define APCI035_TCW_TIMEBASE 8 -#define APCI035_TCW_PROG 12 -#define APCI035_TCW_TRIG_STATUS 16 -#define APCI035_TCW_IRQ 20 -#define APCI035_TCW_WARN_TIMEVAL 24 -#define APCI035_TCW_WARN_TIMEBASE 28 - -#define ADDIDATA_TIMER 0 -/* #define ADDIDATA_WATCHDOG 1 */ - -#define APCI035_TW1 0 -#define APCI035_TW2 32 -#define APCI035_TW3 64 -#define APCI035_TW4 96 - -#define APCI035_AI_OFFSET 0 -#define APCI035_TEMP 128 -#define APCI035_ALR_SEQ 4 -#define APCI035_START_STOP_INDEX 8 -#define APCI035_ALR_START_STOP 12 -#define APCI035_ALR_IRQ 16 -#define APCI035_EOS 20 -#define APCI035_CHAN_NO 24 -#define APCI035_CHAN_VAL 28 -#define APCI035_CONV_TIME_TIME_BASE 36 -#define APCI035_RELOAD_CONV_TIME_VAL 32 -#define APCI035_DELAY_TIME_TIME_BASE 44 -#define APCI035_RELOAD_DELAY_TIME_VAL 40 -#define ENABLE_EXT_TRIG 1 -#define ENABLE_EXT_GATE 2 -#define ENABLE_EXT_TRIG_GATE 3 - -#define ANALOG_INPUT 0 -#define TEMPERATURE 1 -#define RESISTANCE 2 - -#define ADDIDATA_GREATER_THAN_TEST 0 -#define ADDIDATA_LESS_THAN_TEST 1 - -#define APCI035_MAXVOLT 2.5 - -#define ADDIDATA_UNIPOLAR 1 -#define ADDIDATA_BIPOLAR 2 - -/* ANALOG INPUT RANGE */ -static struct comedi_lrange range_apci035_ai = { - 8, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1) - } -}; - -static int i_WatchdogNbr; -static int i_Temp; -static int i_Flag = 1; - -/* - * Configures The Timer , Counter or Watchdog - * - * data[0] 0 = Configure As Timer, 1 = Configure As Watchdog - * data[1] Watchdog number - * data[2] Time base Unit - * data[3] Reload Value - * data[4] External Trigger, 1 = Enable, 0 = Disable - * data[5] External Trigger Level - * 00 = Trigger Disabled - * 01 = Trigger Enabled (Low level) - * 10 = Trigger Enabled (High Level) - * 11 = Trigger Enabled (High/Low level) - * data[6] External Gate, 1 = Enable, 0 = Disable - * data[7] External Gate level - * 00 = Gate Disabled - * 01 = Gate Enabled (Low level) - * 10 = Gate Enabled (High Level) - * data[8] Warning Relay, 1 = Enable, 0 = Disable - * data[9] Warning Delay available - * data[10] Warning Relay Time unit - * data[11] Warning Relay Time Reload value - * data[12] Reset Relay, 1 = Enable, 0 = Disable - * data[13] Interrupt, 1 = Enable, 0 = Disable - */ -static int apci035_timer_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci035_private *devpriv = dev->private; - unsigned int ui_Status; - unsigned int ui_Command; - unsigned int ui_Mode; - - i_Temp = 0; - devpriv->tsk_Current = current; - devpriv->b_TimerSelectMode = data[0]; - i_WatchdogNbr = data[1]; - if (data[0] == 0) - ui_Mode = 2; - else - ui_Mode = 0; - - ui_Command = 0; - outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - - 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 */ - /* - Disable the warning */ - /* - Disable the reset */ - /* - Enable the timer mode */ - /* - Set the timer mode */ - - 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 { - 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 = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - - /* Disable the hardware trigger */ - ui_Command = ui_Command & 0xFFFFF89FUL; - if (data[4] == 1) { - /* Set the hardware trigger level */ - ui_Command = ui_Command | (data[5] << 5); - } - outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - - ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - - /* Disable the hardware gate */ - ui_Command = ui_Command & 0xFFFFF87FUL; - if (data[6] == 1) { - /* Set the hardware gate level */ - ui_Command = ui_Command | (data[7] << 7); - } - outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - - 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] == 1) { - /* 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 = 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 */ - 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); - outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - - return insn->n; -} - -/* - * Start / Stop The Selected Timer , or Watchdog - * - * data[0] - * 0 - Stop Selected Timer/Watchdog - * 1 - Start Selected Timer/Watch*dog - * 2 - Trigger Selected Timer/Watchdog - * 3 - Stop All Timer/Watchdog - * 4 - Start All Timer/Watchdog - * 5 - Trigger All Timer/Watchdog - */ -static int apci035_timer_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci035_private *devpriv = dev->private; - unsigned int ui_Command; - int i_Count; - - 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] == 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); - } - - 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; - */ - outl(ui_Command, - devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); - } - 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) - ui_Command = 0x2UL; - else - ui_Command = 0x10UL; - - i_WatchdogNbr = i_Count; - outl(ui_Command, - devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + - 0); - } - - } - 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) - ui_Command = 0x1UL; - 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 */ - ui_Command = 0; - for (i_Count = 1; i_Count <= 4; i_Count++) { - if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) - ui_Command = 0x4UL; - else - ui_Command = 0x20UL; - - i_WatchdogNbr = i_Count; - outl(ui_Command, - devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + - 0); - } - i_Temp = 1; - } - return insn->n; -} - -/* - * Read The Selected Timer , Counter or Watchdog - * - * data[0] software trigger status - * data[1] hardware trigger status - * data[2] Software clear status - * data[3] Overflow status - * data[4] Timer actual value - */ -static int apci035_timer_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci035_private *devpriv = dev->private; - unsigned int ui_Status; /* Status register */ - - 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); - - return insn->n; -} - -/* - * Configures The Analog Input Subdevice - * - * data[0] Warning delay value - */ -static int apci035_ai_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci035_private *devpriv = dev->private; - - 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); - - return insn->n; -} - -/* - * Read value of the selected channel - * - * data[0] Digital Value Of Input - */ -static int apci035_ai_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci035_private *devpriv = dev->private; - unsigned int ui_CommandRegister; - - /* 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; -} - -static int apci035_reset(struct comedi_device *dev) -{ - struct apci035_private *devpriv = dev->private; - int i_Count; - - for (i_Count = 1; i_Count <= 4; i_Count++) { - i_WatchdogNbr = i_Count; - - /* stop all timers */ - outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); - } - outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */ - - return 0; -} - -static irqreturn_t apci035_interrupt(int irq, void *d) -{ - struct comedi_device *dev = d; - struct apci035_private *devpriv = dev->private; - unsigned int ui_StatusRegister1; - unsigned int ui_StatusRegister2; - unsigned int ui_ReadCommand; - unsigned int ui_ChannelNumber; - unsigned int ui_DigitalTemperature; - - if (i_Temp == 1) { - 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 signal to the sample */ - send_sig(SIGIO, devpriv->tsk_Current, 0); - - } else if ((ui_StatusRegister2 & 0x1) == 0x1) { - /* send signal to the sample */ - send_sig(SIGIO, devpriv->tsk_Current, 0); - } - - return IRQ_HANDLED; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c deleted file mode 100644 index d7b7e1aa8b33..000000000000 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include -#include -#include - -#include "../comedidev.h" -#include "comedi_fc.h" -#include "amcc_s5933.h" - -struct apci035_private { - int iobase; - int i_IobaseAmcc; - int i_IobaseAddon; - int i_IobaseReserved; - unsigned char b_TimerSelectMode; - struct task_struct *tsk_Current; -}; - -#define ADDIDATA_WATCHDOG 2 /* Or shold it be something else */ - -#include "addi-data/hwdrv_apci035.c" - -static int apci035_auto_attach(struct comedi_device *dev, - unsigned long context) -{ - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct apci035_private *devpriv; - struct comedi_subdevice *s; - unsigned int dw_Dummy; - int ret; - - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - - ret = comedi_pci_enable(dev); - if (ret) - return ret; - - dev->iobase = pci_resource_start(pcidev, 1); - devpriv->iobase = dev->iobase; - devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); - devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); - devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); - - if (pcidev->irq > 0) { - ret = request_irq(pcidev->irq, apci035_interrupt, IRQF_SHARED, - dev->board_name, dev); - if (ret == 0) - dev->irq = pcidev->irq; - } - - /* Set 3 wait stait */ - outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); - outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - - ret = comedi_alloc_subdevices(dev, 2); - if (ret) - return ret; - - /* Allocate and Initialise AI Subdevice Structures */ - s = &dev->subdevices[0]; - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; - s->n_chan = 16; - s->maxdata = 0xff; - s->len_chanlist = s->n_chan; - s->range_table = &range_apci035_ai; - s->insn_config = apci035_ai_config; - s->insn_read = apci035_ai_read; - - /* Allocate and Initialise Timer Subdevice Structures */ - s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 1; - s->maxdata = 0; - s->len_chanlist = 1; - s->range_table = &range_digital; - s->insn_write = apci035_timer_write; - s->insn_read = apci035_timer_read; - s->insn_config = apci035_timer_config; - - apci035_reset(dev); - - return 0; -} - -static void apci035_detach(struct comedi_device *dev) -{ - if (dev->iobase) - apci035_reset(dev); - comedi_pci_detach(dev); -} - -static struct comedi_driver apci035_driver = { - .driver_name = "addi_apci_035", - .module = THIS_MODULE, - .auto_attach = apci035_auto_attach, - .detach = apci035_detach, -}; - -static int apci035_pci_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - return comedi_pci_auto_config(dev, &apci035_driver, id->driver_data); -} - -static const struct pci_device_id apci035_pci_table[] = { - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x0300) }, - { 0 } -}; -MODULE_DEVICE_TABLE(pci, apci035_pci_table); - -static struct pci_driver apci035_pci_driver = { - .name = "addi_apci_035", - .id_table = apci035_pci_table, - .probe = apci035_pci_probe, - .remove = comedi_pci_auto_unconfig, -}; -module_comedi_pci_driver(apci035_driver, apci035_pci_driver); - -MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); -MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From 60942e707f78b2910444579079ba5426b296cb9e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 15:04:30 -0700 Subject: staging: comedi: ni_mio_common: remove deadcode in ni_cdio_cmdtest() Reported-by: coverity (CID 142967) Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 785ad7004d98..fa5b25063661 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3513,9 +3513,6 @@ static int ni_cdio_cmdtest(struct comedi_device *dev, /* Step 2a : make sure trigger sources are unique */ /* 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); -- cgit v1.2.3-59-g8ed1b From e7ea440a57fa0ace880e3c9406e02d580f24a91f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 15:03:15 -0700 Subject: staging: comedi: ni_6527: remove deadcode in ni6527_intr_cmdtest() Reported-by: coverity (CID 142962) Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_6527.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index b77354bc75e6..b35e1aeb6626 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -238,9 +238,6 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev, /* Step 2a : make sure trigger sources are unique */ /* 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); -- cgit v1.2.3-59-g8ed1b From c3e1715890b2c3009155e8865d5c6d649a16a4b5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 15:02:14 -0700 Subject: staging: comedi: ni_65xx: remove deadcode in ni_65xx_intr_cmdtest() Reported-by: coverity (CID 142963) Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_65xx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 3c27f532aa6e..973f0058a1e4 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -534,9 +534,6 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev, /* Step 2a : make sure trigger sources are unique */ /* 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); -- cgit v1.2.3-59-g8ed1b From 1b90779b238a8554a465fb99b3828a9e0500ff2a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:08 -0700 Subject: staging: comedi: addi_apci_3120: DMA requires an interrupt An interrupt is required for DMA to work. Factor out the DMA buffer allocation from the (*auto_attach) and only allocate the buffers if the interrupt is available. For aesthetics, also factor the DMA buffer free from the (*detach). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 85 ++++++++++++++----------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 2f0b642cfbff..08ac390edc3f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -61,6 +61,51 @@ struct apci3120_private { #include "addi-data/hwdrv_apci3120.c" +static void apci3120_dma_alloc(struct comedi_device *dev) +{ + struct apci3120_private *devpriv = dev->private; + int order; + int i; + + for (i = 0; i < 2; i++) { + for (order = 2; order >= 0; order--) { + devpriv->ul_DmaBufferVirtual[i] = + dma_alloc_coherent(dev->hw_dev, PAGE_SIZE << order, + &devpriv->ul_DmaBufferHw[i], + GFP_KERNEL); + + if (devpriv->ul_DmaBufferVirtual[i]) + break; + } + if (!devpriv->ul_DmaBufferVirtual[i]) + break; + devpriv->ui_DmaBufferSize[i] = PAGE_SIZE << order; + + if (i == 0) + devpriv->us_UseDma = 1; + if (i == 1) + devpriv->b_DmaDoubleBuffer = 1; + } +} + +static void apci3120_dma_free(struct comedi_device *dev) +{ + struct apci3120_private *devpriv = dev->private; + int i; + + if (!devpriv) + return; + + for (i = 0; i < 2; i++) { + if (devpriv->ul_DmaBufferVirtual[i]) { + dma_free_coherent(dev->hw_dev, + devpriv->ui_DmaBufferSize[i], + devpriv->ul_DmaBufferVirtual[i], + devpriv->ul_DmaBufferHw[i]); + } + } +} + static int apci3120_auto_attach(struct comedi_device *dev, unsigned long context) { @@ -68,7 +113,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, const struct apci3120_board *this_board = NULL; struct apci3120_private *devpriv; struct comedi_subdevice *s; - int ret, order, i; + int ret; if (context < ARRAY_SIZE(apci3120_boardtypes)) this_board = &apci3120_boardtypes[context]; @@ -95,30 +140,12 @@ static int apci3120_auto_attach(struct comedi_device *dev, if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci3120_interrupt, IRQF_SHARED, dev->board_name, dev); - if (ret == 0) + if (ret == 0) { dev->irq = pcidev->irq; - } - - /* Allocate DMA buffers */ - for (i = 0; i < 2; i++) { - for (order = 2; order >= 0; order--) { - devpriv->ul_DmaBufferVirtual[i] = - dma_alloc_coherent(dev->hw_dev, PAGE_SIZE << order, - &devpriv->ul_DmaBufferHw[i], - GFP_KERNEL); - if (devpriv->ul_DmaBufferVirtual[i]) - break; + apci3120_dma_alloc(dev); } - if (!devpriv->ul_DmaBufferVirtual[i]) - break; - devpriv->ui_DmaBufferSize[i] = PAGE_SIZE << order; } - if (devpriv->ul_DmaBufferVirtual[0]) - devpriv->us_UseDma = 1; - - if (devpriv->ul_DmaBufferVirtual[1]) - devpriv->b_DmaDoubleBuffer = 1; ret = comedi_alloc_subdevices(dev, 5); if (ret) @@ -193,24 +220,10 @@ static int apci3120_auto_attach(struct comedi_device *dev, static void apci3120_detach(struct comedi_device *dev) { - struct apci3120_private *devpriv = dev->private; - if (dev->iobase) apci3120_reset(dev); comedi_pci_detach(dev); - if (devpriv) { - unsigned int i; - - for (i = 0; i < 2; i++) { - if (devpriv->ul_DmaBufferVirtual[i]) { - dma_free_coherent(dev->hw_dev, - devpriv->ui_DmaBufferSize[i], - devpriv-> - ul_DmaBufferVirtual[i], - devpriv->ul_DmaBufferHw[i]); - } - } - } + apci3120_dma_free(dev); } static struct comedi_driver apci3120_driver = { -- cgit v1.2.3-59-g8ed1b From 8f83d52d305216f5d6516d11af48abfb0b44bab6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:09 -0700 Subject: staging: comedi: addi_apci_3120: introduce struct apci3120_dmabuf For aesthetics, wrap the DMA buffer information in a struct. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 85 +++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 39 +++++----- 2 files changed, 57 insertions(+), 67 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a2db2facab70..7ed04b692301 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1003,6 +1003,8 @@ static int apci3120_cyclic_ai(int mode, } } else { /* If DMA Enabled */ + struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0]; + struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1]; unsigned int scan_bytes = cmd->scan_end_arg * sizeof(short); devpriv->b_InterruptMode = APCI3120_DMA_MODE; @@ -1014,8 +1016,8 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - dmalen0 = devpriv->ui_DmaBufferSize[0]; - dmalen1 = devpriv->ui_DmaBufferSize[1]; + dmalen0 = dmabuf0->size; + dmalen1 = dmabuf1->size; if (cmd->stop_src == TRIG_COUNT) { /* @@ -1050,8 +1052,8 @@ static int apci3120_cyclic_ai(int mode, if (dmalen1 > s->async->prealloc_bufsz) dmalen1 = s->async->prealloc_bufsz; } - devpriv->ui_DmaBufferUsesize[0] = dmalen0; - devpriv->ui_DmaBufferUsesize[1] = dmalen1; + dmabuf0->use_size = dmalen0; + dmabuf1->use_size = dmalen1; /* Initialize DMA */ @@ -1094,13 +1096,11 @@ static int apci3120_cyclic_ai(int mode, /* DMA Start Address Low */ outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); - outw((devpriv->ul_DmaBufferHw[0] & 0xFFFF), - devpriv->i_IobaseAddon + 2); + outw(dmabuf0->hw & 0xffff, devpriv->i_IobaseAddon + 2); /* DMA Start Address High */ outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); - outw((devpriv->ul_DmaBufferHw[0] / 65536), - devpriv->i_IobaseAddon + 2); + outw((dmabuf0->hw >> 16) & 0xffff, devpriv->i_IobaseAddon + 2); /* * 4 @@ -1110,13 +1110,12 @@ static int apci3120_cyclic_ai(int mode, /* Nbr of acquisition LOW */ outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); - outw((devpriv->ui_DmaBufferUsesize[0] & 0xFFFF), - devpriv->i_IobaseAddon + 2); + outw(dmabuf0->use_size & 0xffff, devpriv->i_IobaseAddon + 2); /* Nbr of acquisition HIGH */ outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); - outw((devpriv->ui_DmaBufferUsesize[0] / 65536), - devpriv->i_IobaseAddon + 2); + outw((dmabuf0->use_size >> 16) & 0xffff, + devpriv->i_IobaseAddon + 2); /* * 5 @@ -1248,18 +1247,17 @@ static void apci3120_interrupt_dma(int irq, void *d) struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int next_dma_buf, samplesinbuf; - unsigned long low_word, high_word, var; + struct apci3120_dmabuf *dmabuf; + unsigned int samplesinbuf; unsigned int ui_Tmp; - samplesinbuf = - devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer] - - inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC); + dmabuf = &devpriv->dmabuf[devpriv->ui_DmaActualBuffer]; + + samplesinbuf = dmabuf->use_size - + inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC); - if (samplesinbuf < - devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]) { + if (samplesinbuf < dmabuf->use_size) dev_err(dev->class_dev, "Interrupted DMA transfer!\n"); - } if (samplesinbuf & 1) { dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n"); apci3120_cancel(dev, s); @@ -1268,7 +1266,9 @@ static void apci3120_interrupt_dma(int irq, void *d) samplesinbuf = samplesinbuf >> 1; /* number of received samples */ if (devpriv->b_DmaDoubleBuffer) { /* switch DMA buffers if is used double buffering */ - next_dma_buf = 1 - devpriv->ui_DmaActualBuffer; + struct apci3120_dmabuf *next_dmabuf; + + next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS); @@ -1280,31 +1280,24 @@ static void apci3120_interrupt_dma(int irq, void *d) outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* 0x1000 is out putted in windows driver */ - var = devpriv->ul_DmaBufferHw[next_dma_buf]; - low_word = var & 0xffff; - var = devpriv->ul_DmaBufferHw[next_dma_buf]; - high_word = var / 65536; - /* DMA Start Address Low */ outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); - outw(low_word, devpriv->i_IobaseAddon + 2); + outw(next_dmabuf->hw & 0xffff, devpriv->i_IobaseAddon + 2); /* DMA Start Address High */ outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); - outw(high_word, devpriv->i_IobaseAddon + 2); - - var = devpriv->ui_DmaBufferUsesize[next_dma_buf]; - low_word = var & 0xffff; - var = devpriv->ui_DmaBufferUsesize[next_dma_buf]; - high_word = var / 65536; + outw((next_dmabuf->hw >> 16) & 0xffff, + devpriv->i_IobaseAddon + 2); /* Nbr of acquisition LOW */ outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); - outw(low_word, devpriv->i_IobaseAddon + 2); + outw(next_dmabuf->use_size & 0xffff, + devpriv->i_IobaseAddon + 2); /* Nbr of acquisition HIGH */ outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); - outw(high_word, devpriv->i_IobaseAddon + 2); + outw((next_dmabuf->use_size > 16) & 0xffff, + devpriv->i_IobaseAddon + 2); /* * To configure A2P FIFO @@ -1319,9 +1312,8 @@ static void apci3120_interrupt_dma(int irq, void *d) } if (samplesinbuf) { - v_APCI3120_InterruptDmaMoveBlock16bit(dev, s, - devpriv->ul_DmaBufferVirtual[devpriv-> - ui_DmaActualBuffer], samplesinbuf); + v_APCI3120_InterruptDmaMoveBlock16bit(dev, s, dmabuf->virt, + samplesinbuf); if (!(cmd->flags & CMDF_WAKE_EOS)) s->async->events |= COMEDI_CB_EOS; @@ -1356,23 +1348,16 @@ static void apci3120_interrupt_dma(int irq, void *d) outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); - var = devpriv->ul_DmaBufferHw[0]; - low_word = var & 0xffff; - var = devpriv->ul_DmaBufferHw[0]; - high_word = var / 65536; outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); - outw(low_word, devpriv->i_IobaseAddon + 2); + outw(dmabuf->hw & 0xffff, devpriv->i_IobaseAddon + 2); outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); - outw(high_word, devpriv->i_IobaseAddon + 2); + outw((dmabuf->hw >> 16) & 0xffff, devpriv->i_IobaseAddon + 2); - var = devpriv->ui_DmaBufferUsesize[0]; - low_word = var & 0xffff; /* changed */ - var = devpriv->ui_DmaBufferUsesize[0]; - high_word = var / 65536; outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); - outw(low_word, devpriv->i_IobaseAddon + 2); + outw(dmabuf->use_size & 0xffff, devpriv->i_IobaseAddon + 2); outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); - outw(high_word, devpriv->i_IobaseAddon + 2); + outw((dmabuf->use_size >> 16) & 0xffff, + devpriv->i_IobaseAddon + 2); /* * To configure A2P FIFO diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 08ac390edc3f..759245b5b707 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -29,6 +29,13 @@ static const struct apci3120_board apci3120_boardtypes[] = { }, }; +struct apci3120_dmabuf { + unsigned short *virt; + dma_addr_t hw; + unsigned int size; + unsigned int use_size; +}; + struct apci3120_private { int iobase; int i_IobaseAmcc; @@ -41,10 +48,7 @@ struct apci3120_private { unsigned short us_UseDma; unsigned char b_DmaDoubleBuffer; unsigned int ui_DmaActualBuffer; - unsigned short *ul_DmaBufferVirtual[2]; - dma_addr_t ul_DmaBufferHw[2]; - unsigned int ui_DmaBufferSize[2]; - unsigned int ui_DmaBufferUsesize[2]; + struct apci3120_dmabuf dmabuf[2]; unsigned char b_DigitalOutputRegister; unsigned char b_TimerSelectMode; unsigned char b_ModeSelectRegister; @@ -64,22 +68,23 @@ struct apci3120_private { static void apci3120_dma_alloc(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; + struct apci3120_dmabuf *dmabuf; int order; int i; for (i = 0; i < 2; i++) { + dmabuf = &devpriv->dmabuf[i]; for (order = 2; order >= 0; order--) { - devpriv->ul_DmaBufferVirtual[i] = - dma_alloc_coherent(dev->hw_dev, PAGE_SIZE << order, - &devpriv->ul_DmaBufferHw[i], - GFP_KERNEL); - - if (devpriv->ul_DmaBufferVirtual[i]) + dmabuf->virt = dma_alloc_coherent(dev->hw_dev, + PAGE_SIZE << order, + &dmabuf->hw, + GFP_KERNEL); + if (dmabuf->virt) break; } - if (!devpriv->ul_DmaBufferVirtual[i]) + if (!dmabuf->virt) break; - devpriv->ui_DmaBufferSize[i] = PAGE_SIZE << order; + dmabuf->size = PAGE_SIZE << order; if (i == 0) devpriv->us_UseDma = 1; @@ -91,17 +96,17 @@ static void apci3120_dma_alloc(struct comedi_device *dev) static void apci3120_dma_free(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; + struct apci3120_dmabuf *dmabuf; int i; if (!devpriv) return; for (i = 0; i < 2; i++) { - if (devpriv->ul_DmaBufferVirtual[i]) { - dma_free_coherent(dev->hw_dev, - devpriv->ui_DmaBufferSize[i], - devpriv->ul_DmaBufferVirtual[i], - devpriv->ul_DmaBufferHw[i]); + dmabuf = &devpriv->dmabuf[i]; + if (dmabuf->virt) { + dma_free_coherent(dev->hw_dev, dmabuf->size, + dmabuf->virt, dmabuf->hw); } } } -- cgit v1.2.3-59-g8ed1b From 99940229e58b98c30c7d570d36cd77ed9cf29d90 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:10 -0700 Subject: staging: comedi: addi_apci_3120: remove unused struct definition The struct str_AnalogReadInformation is not used in this driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 7ed04b692301..e7cb66f557ee 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -200,23 +200,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY APCI3120_DISABLE_TIMER1 & \ APCI3120_DISABLE_TIMER2) -#define MAX_ANALOGINPUT_CHANNELS 32 - -struct str_AnalogReadInformation { - /* EOC or EOS */ - unsigned char b_Type; - /* Interrupt use or not */ - unsigned char b_InterruptFlag; - /* Selection of the conversion time */ - unsigned int ui_ConvertTiming; - /* Number of channel to read */ - unsigned char b_NbrOfChannel; - /* Number of the channel to be read */ - unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS]; - /* Gain of each channel */ - unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; -}; - /* ANALOG INPUT RANGE */ static const struct comedi_lrange range_apci3120_ai = { 8, { -- cgit v1.2.3-59-g8ed1b From 12d984ed512aa20b46ba16abf3c4f64c6a893fe7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:11 -0700 Subject: staging: comedi: addi_apci_3120: remove unipolar range from analog outputs The analog outputs of the APCI-3120 have a 14-bit bipolar range and use straight binary values (0x0000 = -10V to 0x3fff = +10V) to set the outputs. This driver tries to fake a unipolar range by munging the comedi data values to only output 0V to +10V signals (0x0000 to 0x1fff values are munged to 0x2000 - 0x3fff). This causes problems with the comedilib API functions that convert between comedi values and physical values. It's also possible for the user to pass a data value that would get munged and actually change the wrong channel. Fix this by change the subdevice range_table to range_bipolar10 and remove the munging in apci3120_ao_insn_write(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 31 ++-------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index e7cb66f557ee..b9f444e36b6a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -214,16 +214,6 @@ static const struct comedi_lrange range_apci3120_ai = { } }; -/* ANALOG OUTPUT RANGE */ -static const struct comedi_lrange range_apci3120_ao = { - 2, { - BIP_RANGE(10), - UNI_RANGE(10) - } -}; - - -/* FUNCTION DEFINITIONS */ static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -1954,29 +1944,12 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned int ui_Range, ui_Channel; + unsigned int ui_Channel; unsigned short us_TmpValue; - ui_Range = CR_RANGE(insn->chanspec); ui_Channel = CR_CHAN(insn->chanspec); - if (ui_Range) { /* if 1 then unipolar */ - - if (data[0] != 0) - data[0] = - ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 << - 13) | (data[0] + 8191)); - else - data[0] = - ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 << - 13) | 8192); - - } else { /* if 0 then bipolar */ - data[0] = - ((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) | - data[0]); - - } + data[0] = ((((ui_Channel & 0x03) << 14) & 0xC000) | data[0]); do { /* Waiting of DA_READY BIT */ us_TmpValue = diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 759245b5b707..774ba7abc95d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -181,7 +181,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; s->maxdata = 0x3fff; - s->range_table = &range_apci3120_ao; + s->range_table = &range_bipolar10; s->insn_write = apci3120_ao_insn_write; } else { s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From 82263947b1023bdb9cec39c0f8deb0c447433014 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:12 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'i_IobaseReserved' This member of the private data is not used by the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 774ba7abc95d..5a5392fe0bac 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -40,7 +40,6 @@ struct apci3120_private { int iobase; int i_IobaseAmcc; int i_IobaseAddon; - int i_IobaseReserved; unsigned int ui_AiActualScan; unsigned int ui_AiNbrofChannels; unsigned int ui_AiChannelList[32]; @@ -140,7 +139,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, devpriv->iobase = dev->iobase; devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); - devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci3120_interrupt, IRQF_SHARED, -- cgit v1.2.3-59-g8ed1b From 0defecbfd24fdd78754c1a0fc1bef38adc31b408 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:13 -0700 Subject: staging: comedi: addi_apci_3120: use correct iobase to write AMCC registers The AMCC registers are accessed using the base address devpriv->i_IobaseAmcc not devpriv->i_IobaseAddon. Fix a couple writes in apci3120_interrupt_dma() that are using the wrong base address. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b9f444e36b6a..c651756f9467 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1244,7 +1244,7 @@ static void apci3120_interrupt_dma(int irq, void *d) next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; - outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS); + outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); @@ -1306,7 +1306,7 @@ static void apci3120_interrupt_dma(int irq, void *d) * ADDED REINITIALISE THE DMA */ ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; - outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS); + outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); -- cgit v1.2.3-59-g8ed1b From 758cdd4a1723ae6fdeef411d4112da1bb4920f4d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:14 -0700 Subject: staging: comedi: addi_apci_3120: use correct iobase to read board register The board registers are accessed using the bse address devpriv->iobase not devpriv->i_IobaseAmcc. Fix a read in apci3120_interrupt() that is using the wrong base address. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c651756f9467..133266931ca0 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1399,7 +1399,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) devpriv->b_ExttrigEnable = APCI3120_DISABLE; } /* clear the timer 2 interrupt */ - inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER); + inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); if (int_amcc & MASTER_ABORT_INT) dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n"); -- cgit v1.2.3-59-g8ed1b From 67941734d146658dc8e284b57f57abd9ad0f7c04 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:15 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'i_IobaseAddon' This member of the private data holds the start address of PCI BAR 2 that is used to access the AMCC Add-On registers. Rename this CamelCase member and fix its type. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 99 ++++++++++------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 4 +- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 133266931ca0..615302c049f2 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -633,13 +633,13 @@ static int apci3120_cancel(struct comedi_device *dev, struct apci3120_private *devpriv = dev->private; /* Disable A2P Fifo write and AMWEN signal */ - outw(0, devpriv->i_IobaseAddon + 4); + outw(0, devpriv->addon + 4); /* Disable Bus Master ADD ON */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); - outw(0, devpriv->i_IobaseAddon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); - outw(0, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); + outw(0, devpriv->addon + 2); + outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); + outw(0, devpriv->addon + 2); /* Disable BUS Master PCI */ outl(0, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); @@ -1039,19 +1039,17 @@ static int apci3120_cyclic_ai(int mode, /* changed since 16 bit interface for add on */ /* ENABLE BUS MASTER */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); /* * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux * driver */ - outw(0x1000, devpriv->i_IobaseAddon + 2); + outw(0x1000, devpriv->addon + 2); /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ /* 2 No change */ @@ -1068,12 +1066,12 @@ static int apci3120_cyclic_ai(int mode, */ /* DMA Start Address Low */ - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); - outw(dmabuf0->hw & 0xffff, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); + outw(dmabuf0->hw & 0xffff, devpriv->addon + 2); /* DMA Start Address High */ - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); - outw((dmabuf0->hw >> 16) & 0xffff, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); + outw((dmabuf0->hw >> 16) & 0xffff, devpriv->addon + 2); /* * 4 @@ -1082,13 +1080,12 @@ static int apci3120_cyclic_ai(int mode, */ /* Nbr of acquisition LOW */ - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); - outw(dmabuf0->use_size & 0xffff, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); + outw(dmabuf0->use_size & 0xffff, devpriv->addon + 2); /* Nbr of acquisition HIGH */ - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); - outw((dmabuf0->use_size >> 16) & 0xffff, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); + outw((dmabuf0->use_size >> 16) & 0xffff, devpriv->addon + 2); /* * 5 @@ -1122,7 +1119,7 @@ static int apci3120_cyclic_ai(int mode, /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ - outw(3, devpriv->i_IobaseAddon + 4); + outw(3, devpriv->addon + 4); /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ /* A2P FIFO RESET */ @@ -1247,37 +1244,33 @@ static void apci3120_interrupt_dma(int irq, void *d) outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, - devpriv->i_IobaseAddon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* 0x1000 is out putted in windows driver */ + outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); + outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); /* 0x1000 is out putted in windows driver */ /* DMA Start Address Low */ - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); - outw(next_dmabuf->hw & 0xffff, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); + outw(next_dmabuf->hw & 0xffff, devpriv->addon + 2); /* DMA Start Address High */ - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); - outw((next_dmabuf->hw >> 16) & 0xffff, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); + outw((next_dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2); /* Nbr of acquisition LOW */ - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); - outw(next_dmabuf->use_size & 0xffff, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); + outw(next_dmabuf->use_size & 0xffff, devpriv->addon + 2); /* Nbr of acquisition HIGH */ - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); - outw((next_dmabuf->use_size > 16) & 0xffff, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); + outw((next_dmabuf->use_size > 16) & 0xffff, devpriv->addon + 2); /* * To configure A2P FIFO * ENABLE A2P FIFO WRITE AND ENABLE AMWEN * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 */ - outw(3, devpriv->i_IobaseAddon + 4); + outw(3, devpriv->addon + 4); /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), @@ -1309,11 +1302,10 @@ static void apci3120_interrupt_dma(int irq, void *d) outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, - devpriv->i_IobaseAddon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); + outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); /* * A2P FIFO MANAGEMENT * A2P fifo reset & transfer control enable @@ -1321,23 +1313,22 @@ static void apci3120_interrupt_dma(int irq, void *d) outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); - outw(dmabuf->hw & 0xffff, devpriv->i_IobaseAddon + 2); - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0); - outw((dmabuf->hw >> 16) & 0xffff, devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); + outw(dmabuf->hw & 0xffff, devpriv->addon + 2); + outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); + outw((dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2); - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0); - outw(dmabuf->use_size & 0xffff, devpriv->i_IobaseAddon + 2); - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0); - outw((dmabuf->use_size >> 16) & 0xffff, - devpriv->i_IobaseAddon + 2); + outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); + outw(dmabuf->use_size & 0xffff, devpriv->addon + 2); + outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); + outw((dmabuf->use_size >> 16) & 0xffff, devpriv->addon + 2); /* * To configure A2P FIFO * ENABLE A2P FIFO WRITE AND ENABLE AMWEN * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 */ - outw(3, devpriv->i_IobaseAddon + 4); + outw(3, devpriv->addon + 4); /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 5a5392fe0bac..e4cbc15e7df2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -39,7 +39,7 @@ struct apci3120_dmabuf { struct apci3120_private { int iobase; int i_IobaseAmcc; - int i_IobaseAddon; + unsigned long addon; unsigned int ui_AiActualScan; unsigned int ui_AiNbrofChannels; unsigned int ui_AiChannelList[32]; @@ -138,7 +138,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, dev->iobase = pci_resource_start(pcidev, 1); devpriv->iobase = dev->iobase; devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); - devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); + devpriv->addon = pci_resource_start(pcidev, 2); if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci3120_interrupt, IRQF_SHARED, -- cgit v1.2.3-59-g8ed1b From 323503bfec1a0e1a310ec8e483b528f5e4b87c2d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:16 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'i_IobaseAmcc' This member of the private data holds the start address of PCI BAR 0 that is used to access the AMCC registers. Rename this CamelCase member and fix its type. Remove an unnecessary local variable, 'ui_Tmp', in apci3120_cyclic_ai() and tidy up the rest of the local variable declarations. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 61 +++++++++++----------- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 +- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 615302c049f2..d6875d96d5c9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -642,7 +642,7 @@ static int apci3120_cancel(struct comedi_device *dev, outw(0, devpriv->addon + 2); /* Disable BUS Master PCI */ - outl(0, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); + outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); /* Disable ext trigger */ apci3120_exttrig_disable(dev); @@ -754,9 +754,13 @@ static int apci3120_cyclic_ai(int mode, struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned char b_Tmp; - unsigned int ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 = - 0, dmalen1 = 0, ui_TimerValue2 = - 0, ui_TimerValue0, ui_ConvertTiming; + unsigned int ui_DelayTiming = 0; + unsigned int ui_TimerValue1 = 0; + unsigned int dmalen0 = 0; + unsigned int dmalen1 = 0; + unsigned int ui_TimerValue2 = 0; + unsigned int ui_TimerValue0; + unsigned int ui_ConvertTiming; unsigned short us_TmpValue; /* Resets the FIFO */ @@ -771,7 +775,7 @@ static int apci3120_cyclic_ai(int mode, /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, - devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_REG_INTCSR); + devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); /* Disables All Timer */ /* Sets PR and PA to 0 */ @@ -1034,8 +1038,8 @@ static int apci3120_cyclic_ai(int mode, * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS * register 1 */ - ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; - outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); + outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + devpriv->amcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ /* ENABLE BUS MASTER */ @@ -1055,8 +1059,8 @@ static int apci3120_cyclic_ai(int mode, /* 2 No change */ /* A2P FIFO MANAGEMENT */ /* A2P fifo reset & transfer control enable */ - outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->i_IobaseAmcc + - APCI3120_AMCC_OP_MCSR); + outl(APCI3120_A2P_FIFO_MANAGEMENT, + devpriv->amcc + APCI3120_AMCC_OP_MCSR); /* * 3 @@ -1090,7 +1094,7 @@ static int apci3120_cyclic_ai(int mode, /* * 5 * To configure A2P FIFO testing outl( - * FIFO_ADVANCE_ON_BYTE_2,devpriv->i_IobaseAmcc+AMCC_OP_REG_INTCSR); + * FIFO_ADVANCE_ON_BYTE_2, devpriv->amcc + AMCC_OP_REG_INTCSR); */ /* A2P FIFO RESET */ @@ -1098,7 +1102,7 @@ static int apci3120_cyclic_ai(int mode, * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux * driver */ - outl(0x04000000UL, devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); + outl(0x04000000UL, devpriv->amcc + AMCC_OP_REG_MCSR); /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ /* @@ -1115,7 +1119,7 @@ static int apci3120_cyclic_ai(int mode, /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT), - devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); + devpriv->amcc + AMCC_OP_REG_INTCSR); /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ @@ -1124,8 +1128,7 @@ static int apci3120_cyclic_ai(int mode, /* A2P FIFO RESET */ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - outl(0x04000000UL, - devpriv->i_IobaseAmcc + APCI3120_AMCC_OP_MCSR); + outl(0x04000000UL, devpriv->amcc + APCI3120_AMCC_OP_MCSR); /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ } @@ -1223,8 +1226,7 @@ static void apci3120_interrupt_dma(int irq, void *d) dmabuf = &devpriv->dmabuf[devpriv->ui_DmaActualBuffer]; - samplesinbuf = dmabuf->use_size - - inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC); + samplesinbuf = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC); if (samplesinbuf < dmabuf->use_size) dev_err(dev->class_dev, "Interrupted DMA transfer!\n"); @@ -1241,7 +1243,7 @@ static void apci3120_interrupt_dma(int irq, void *d) next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; - outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); + outl(ui_Tmp, devpriv->amcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); @@ -1272,9 +1274,9 @@ static void apci3120_interrupt_dma(int irq, void *d) */ outw(3, devpriv->addon + 4); /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ - outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | - APCI3120_ENABLE_WRITE_TC_INT), - devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | + APCI3120_ENABLE_WRITE_TC_INT, + devpriv->amcc + AMCC_OP_REG_INTCSR); } if (samplesinbuf) { @@ -1298,8 +1300,8 @@ static void apci3120_interrupt_dma(int irq, void *d) * restart DMA if is not used double buffering * ADDED REINITIALISE THE DMA */ - ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; - outl(ui_Tmp, devpriv->i_IobaseAmcc + AMCC_OP_REG_AGCSTS); + outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + devpriv->amcc + AMCC_OP_REG_AGCSTS); /* changed since 16 bit interface for add on */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); @@ -1311,7 +1313,7 @@ static void apci3120_interrupt_dma(int irq, void *d) * A2P fifo reset & transfer control enable */ outl(APCI3120_A2P_FIFO_MANAGEMENT, - devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR); + devpriv->amcc + AMCC_OP_REG_MCSR); outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); outw(dmabuf->hw & 0xffff, devpriv->addon + 2); @@ -1330,9 +1332,9 @@ static void apci3120_interrupt_dma(int irq, void *d) */ outw(3, devpriv->addon + 4); /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ - outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | - APCI3120_ENABLE_WRITE_TC_INT), - devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | + APCI3120_ENABLE_WRITE_TC_INT, + devpriv->amcc + AMCC_OP_REG_INTCSR); } } @@ -1373,14 +1375,14 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) ui_Check = 1; int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; /* get IRQ reasons */ - int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* get AMCC int register */ + int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) { dev_err(dev->class_dev, "IRQ from unknown source\n"); return IRQ_NONE; } - outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */ + outl(int_amcc | 0x00ff0000, devpriv->amcc + AMCC_OP_REG_INTCSR); int_daq = (int_daq >> 12) & 0xF; @@ -1515,8 +1517,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, - devpriv->i_IobaseAmcc + - APCI3120_AMCC_OP_REG_INTCSR); + devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); /* Clears the timer status register */ inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e4cbc15e7df2..c6f3bc940d0b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -38,7 +38,7 @@ struct apci3120_dmabuf { struct apci3120_private { int iobase; - int i_IobaseAmcc; + unsigned long amcc; unsigned long addon; unsigned int ui_AiActualScan; unsigned int ui_AiNbrofChannels; @@ -137,7 +137,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, dev->iobase = pci_resource_start(pcidev, 1); devpriv->iobase = dev->iobase; - devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); + devpriv->amcc = pci_resource_start(pcidev, 0); devpriv->addon = pci_resource_start(pcidev, 2); if (pcidev->irq > 0) { -- cgit v1.2.3-59-g8ed1b From 695f34cef33421ac89dd77e5e047e131bb3f36c0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:17 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'iobase' This member of the private data holds the start address of PCI BAR 1 that is used to access the board registers. The start address is also stored in the comedi_device 'iobase' member. Use that instead and remove the private data member. Remove some unnecessary casts when reading the board registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 144 ++++++++++----------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 - 2 files changed, 67 insertions(+), 79 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index d6875d96d5c9..0ba4b79cf515 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -347,8 +347,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, * Testing if board have the new Quartz and calculate the time value * to set in the timer */ - us_TmpValue = - (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS); + us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS); /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ if ((us_TmpValue & 0x00B0) == 0x00B0 @@ -368,7 +367,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* * Testing the interrupt flag and set the EOC bit Clears the FIFO */ - inw(devpriv->iobase + APCI3120_RESET_FIFO); + inw(dev->iobase + APCI3120_RESET_FIFO); /* Initialize the sequence array */ if (!apci3120_setup_chan_list(dev, s, 1, @@ -381,7 +380,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_4; outb(devpriv->b_TimerSelectMode, - devpriv->iobase + APCI3120_TIMER_CRT1); + dev->iobase + APCI3120_TIMER_CRT1); /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */ devpriv->b_ModeSelectRegister = @@ -396,7 +395,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT) | APCI3120_ENABLE_EOC_INT; - inw(devpriv->iobase); + inw(dev->iobase + 0); } else { devpriv->b_ModeSelectRegister = @@ -406,7 +405,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, } outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Sets gate 0 */ devpriv->us_OutputRegister = @@ -414,17 +413,17 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, us_OutputRegister & APCI3120_CLEAR_PA_PR) | APCI3120_ENABLE_TIMER0; outw(devpriv->us_OutputRegister, - devpriv->iobase + APCI3120_WR_ADDRESS); + dev->iobase + APCI3120_WR_ADDRESS); /* Select Timer 0 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ outw(us_ConvertTiming, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); @@ -433,26 +432,25 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, do { /* Waiting for the end of conversion */ - us_TmpValue = - inw(devpriv->iobase + - APCI3120_RD_STATUS); + us_TmpValue = inw(dev->iobase + + APCI3120_RD_STATUS); } while ((us_TmpValue & APCI3120_EOC) == APCI3120_EOC); /* Read the result in FIFO and put it in insn data pointer */ - us_TmpValue = inw(devpriv->iobase + 0); + us_TmpValue = inw(dev->iobase + 0); *data = us_TmpValue; - inw(devpriv->iobase + APCI3120_RESET_FIFO); + inw(dev->iobase + APCI3120_RESET_FIFO); } break; case APCI3120_EOS_MODE: - inw(devpriv->iobase); + inw(dev->iobase + 0); /* Clears the FIFO */ - inw(devpriv->iobase + APCI3120_RESET_FIFO); + inw(dev->iobase + APCI3120_RESET_FIFO); /* clear PA PR and disable timer 0 */ devpriv->us_OutputRegister = @@ -461,7 +459,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, APCI3120_DISABLE_TIMER0; outw(devpriv->us_OutputRegister, - devpriv->iobase + APCI3120_WR_ADDRESS); + dev->iobase + APCI3120_WR_ADDRESS); if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, @@ -474,24 +472,24 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2; outb(devpriv->b_TimerSelectMode, - devpriv->iobase + APCI3120_TIMER_CRT1); + dev->iobase + APCI3120_TIMER_CRT1); /* Select Timer 0 */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ outw(us_ConvertTiming, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); /* Set the scan bit */ devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister | APCI3120_ENABLE_SCAN; outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_WRITE_MODE_SELECT); /* If Interrupt function is loaded */ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { @@ -501,7 +499,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT) | APCI3120_ENABLE_EOS_INT; - inw(devpriv->iobase); + inw(dev->iobase + 0); } else devpriv->b_ModeSelectRegister = @@ -510,34 +508,33 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER; outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_WRITE_MODE_SELECT); - inw(devpriv->iobase + APCI3120_RD_STATUS); + inw(dev->iobase + APCI3120_RD_STATUS); /* Sets gate 0 */ devpriv->us_OutputRegister = devpriv-> us_OutputRegister | APCI3120_ENABLE_TIMER0; outw(devpriv->us_OutputRegister, - devpriv->iobase + APCI3120_WR_ADDRESS); + dev->iobase + APCI3120_WR_ADDRESS); /* Start conversion */ - outw(0, devpriv->iobase + APCI3120_START_CONVERSION); + outw(0, dev->iobase + APCI3120_START_CONVERSION); /* Waiting of end of conversion if interrupt is not installed */ if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) { /* Waiting the end of conversion */ do { - us_TmpValue = - inw(devpriv->iobase + - APCI3120_RD_STATUS); + us_TmpValue = inw(dev->iobase + + APCI3120_RD_STATUS); } while ((us_TmpValue & APCI3120_EOS) != APCI3120_EOS); for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { /* Read the result in FIFO and write them in shared memory */ - us_TmpValue = inw(devpriv->iobase); + us_TmpValue = inw(dev->iobase); data[i] = (unsigned int) us_TmpValue; } @@ -787,7 +784,7 @@ static int apci3120_cyclic_ai(int mode, /* Resets the FIFO */ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - inb(devpriv->iobase + APCI3120_RESET_FIFO); + inb(dev->iobase + APCI3120_RESET_FIFO); /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ devpriv->ui_AiActualScan = 0; @@ -1392,7 +1389,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) devpriv->b_ExttrigEnable = APCI3120_DISABLE; } /* clear the timer 2 interrupt */ - inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); + inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); if (int_amcc & MASTER_ABORT_INT) dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n"); @@ -1405,8 +1402,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* Read the AI Value */ - devpriv->ui_AiReadData[0] = - (unsigned int) inw(devpriv->iobase + 0); + devpriv->ui_AiReadData[0] = inw(dev->iobase + 0); devpriv->b_EocEosInterrupt = APCI3120_DISABLE; send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } else { @@ -1415,8 +1411,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT; outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); - + dev->iobase + APCI3120_WRITE_MODE_SELECT); } } @@ -1440,7 +1435,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) ui_Check = 0; for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { - us_TmpValue = inw(devpriv->iobase + 0); + us_TmpValue = inw(dev->iobase + 0); devpriv->ui_AiReadData[i] = (unsigned int) us_TmpValue; } @@ -1562,7 +1557,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, ui_Timervalue2 = data[1] / 1000; /* convert nano seconds to u seconds */ - us_TmpValue = (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS); + us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS); /* * EL250804: Testing if board APCI3120 have the new Quartz or if it @@ -1580,7 +1575,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ devpriv->us_OutputRegister = devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER2; - outw(devpriv->us_OutputRegister, devpriv->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); /* Disable TIMER Interrupt */ devpriv->b_ModeSelectRegister = @@ -1593,14 +1588,14 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ devpriv->b_TimerSelectMode = (devpriv-> b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_2; outb(devpriv->b_TimerSelectMode, - devpriv->iobase + APCI3120_TIMER_CRT1); + dev->iobase + APCI3120_TIMER_CRT1); /* * Configure the timer 2 for writing the LOW unsigned short of timer @@ -1614,17 +1609,17 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(ui_Timervalue2 & 0xffff, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw((ui_Timervalue2 >> 16) & 0xffff, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); /* timer2 in Timer mode enabled */ devpriv->b_Timer2Mode = APCI3120_TIMER; @@ -1635,7 +1630,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, (devpriv-> b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_5; outb(devpriv->b_TimerSelectMode, - devpriv->iobase + APCI3120_TIMER_CRT1); + dev->iobase + APCI3120_TIMER_CRT1); /* * Configure the timer 2 for writing the LOW unsigned short of timer @@ -1649,18 +1644,18 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(ui_Timervalue2 & 0xffff, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw((ui_Timervalue2 >> 16) & 0xffff, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); /* watchdog enabled */ devpriv->b_Timer2Mode = APCI3120_WATCHDOG; @@ -1715,7 +1710,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, case APCI3120_START: /* Reset FC_TIMER BIT */ - inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); + inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* Enable Timer */ devpriv->b_ModeSelectRegister = @@ -1745,7 +1740,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, APCI3120_DISABLE_TIMER_INT; } outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_WRITE_MODE_SELECT); if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* For Timer mode is Gate2 must be activated timer started */ @@ -1753,7 +1748,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, devpriv-> us_OutputRegister | APCI3120_ENABLE_TIMER2; outw(devpriv->us_OutputRegister, - devpriv->iobase + APCI3120_WR_ADDRESS); + dev->iobase + APCI3120_WR_ADDRESS); } break; @@ -1779,16 +1774,16 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, /* Write above states to register */ outb(devpriv->b_ModeSelectRegister, - devpriv->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Reset Gate 2 */ devpriv->us_OutputRegister = devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER_INT; outw(devpriv->us_OutputRegister, - devpriv->iobase + APCI3120_WR_ADDRESS); + dev->iobase + APCI3120_WR_ADDRESS); /* Reset FC_TIMER BIT */ - inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); + inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); break; @@ -1798,8 +1793,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, "timer2 not configured in TIMER MODE\n"); return -EINVAL; } - us_TmpValue = - (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS); + us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS); /* * EL250804: Testing if board APCI3120 have the new Quartz or if it @@ -1817,19 +1811,19 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(ui_Timervalue2 & 0xffff, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw((ui_Timervalue2 >> 16) & 0xffff, - devpriv->iobase + APCI3120_TIMER_VALUE); + dev->iobase + APCI3120_TIMER_VALUE); break; default: @@ -1866,29 +1860,29 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - us_TmpValue = inw(devpriv->iobase + APCI3120_TIMER_VALUE); + us_TmpValue = inw(dev->iobase + APCI3120_TIMER_VALUE); /* Read the HIGH unsigned short of Timer 2 register */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, devpriv->iobase + APCI3120_TIMER_CRT0); + outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - us_TmpValue_2 = inw(devpriv->iobase + APCI3120_TIMER_VALUE); + us_TmpValue_2 = inw(dev->iobase + APCI3120_TIMER_VALUE); /* combining both words */ data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16)); } else { /* Read watch dog status */ - us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS); + us_StatusValue = inw(dev->iobase + APCI3120_RD_STATUS); us_StatusValue = ((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1; if (us_StatusValue == 1) { /* RESET FC_TIMER BIT */ - inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); + inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); } data[0] = us_StatusValue; /* when data[0] = 1 then the watch dog has rundown */ } @@ -1900,11 +1894,10 @@ static int apci3120_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct apci3120_private *devpriv = dev->private; unsigned int val; /* the input channels are bits 11:8 of the status reg */ - val = inw(devpriv->iobase + APCI3120_RD_STATUS); + val = inw(dev->iobase + APCI3120_RD_STATUS); data[1] = (val >> 8) & 0xf; return insn->n; @@ -1922,7 +1915,7 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, devpriv->b_DigitalOutputRegister = s->state << 4; outb(devpriv->b_DigitalOutputRegister, - devpriv->iobase + APCI3120_DIGITAL_OUTPUT); + dev->iobase + APCI3120_DIGITAL_OUTPUT); } data[1] = s->state; @@ -1935,7 +1928,6 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct apci3120_private *devpriv = dev->private; unsigned int ui_Channel; unsigned short us_TmpValue; @@ -1944,9 +1936,7 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, data[0] = ((((ui_Channel & 0x03) << 14) & 0xC000) | data[0]); do { /* Waiting of DA_READY BIT */ - us_TmpValue = - ((unsigned short) inw(devpriv->iobase + - APCI3120_RD_STATUS)) & 0x0001; + us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS) & 0x0001; } while (us_TmpValue != 0x0001); if (ui_Channel <= 3) @@ -1955,14 +1945,14 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, * typecasted to ushort since word write is to be done */ outw((unsigned short) data[0], - devpriv->iobase + APCI3120_ANALOG_OUTPUT_1); + dev->iobase + APCI3120_ANALOG_OUTPUT_1); else /* * for channel 4-7 out at the register 2 (wrDac5-8) data[i] * typecasted to ushort since word write is to be done */ outw((unsigned short) data[0], - devpriv->iobase + APCI3120_ANALOG_OUTPUT_2); + dev->iobase + APCI3120_ANALOG_OUTPUT_2); return insn->n; } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index c6f3bc940d0b..6b4a51db9c9e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -37,7 +37,6 @@ struct apci3120_dmabuf { }; struct apci3120_private { - int iobase; unsigned long amcc; unsigned long addon; unsigned int ui_AiActualScan; @@ -136,7 +135,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, pci_set_master(pcidev); dev->iobase = pci_resource_start(pcidev, 1); - devpriv->iobase = dev->iobase; devpriv->amcc = pci_resource_start(pcidev, 0); devpriv->addon = pci_resource_start(pcidev, 2); -- cgit v1.2.3-59-g8ed1b From ce987a8a8f86c063c6332da83dfa514a1582c2f3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:18 -0700 Subject: staging: comedi: addi_apci_3120: prevent deadlock in apci3120_ao_insn_write() The DA_READY bit (0x0001) in the status register needs to be set before the analog outputs can be updated. Use comedi_timeout() to prevent a deadlock condition while waiting for the DA_READY bit to get set. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 0ba4b79cf515..b6c11fed957c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1923,21 +1923,34 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, return insn->n; } +static int apci3120_ao_ready(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + APCI3120_RD_STATUS); + if (status & 0x0001) /* waiting for DA_READY */ + return 0; + return -EBUSY; +} + static int apci3120_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { unsigned int ui_Channel; - unsigned short us_TmpValue; + int ret; ui_Channel = CR_CHAN(insn->chanspec); data[0] = ((((ui_Channel & 0x03) << 14) & 0xC000) | data[0]); - do { /* Waiting of DA_READY BIT */ - us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS) & 0x0001; - } while (us_TmpValue != 0x0001); + ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0); + if (ret) + return ret; if (ui_Channel <= 3) /* -- cgit v1.2.3-59-g8ed1b From b9ae204658334a4a34a60dd2de6ba0415b3a79d4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:19 -0700 Subject: staging: comedi: addi_apci_3120: remove analog output reset The apci3120_reset() function is called at the end of the (*auto_attach) and with the (*detach) is called to unload the driver. Part of this function resets all the analog output channels to 0V. There are two problems with this. 1) Only the APCI-3120 has analog outputs, the APCI-3001 does not. 2) The DA_READY bit in the status register needs to be checked before each write to update the analog outputs. It's unknown what the DA_READY bit does on the APCI-3001 board. Just remove the analog output reset to avoid any problems. Also, remove the unnecessary udelay() in apci3120_reset(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b6c11fed957c..fbe17917cea1 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -40,8 +40,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY +----------+-----------+------------------------------------------------+ */ -#include - /* * ADDON RELATED ADDITIONS */ @@ -578,22 +576,6 @@ static int apci3120_reset(struct comedi_device *dev) devpriv->us_OutputRegister = 0; outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - /* - * Code to set the all anolog o/p channel to 0v 8191 is decimal - * value for zero(0 v)volt in bipolar mode(default) - */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 1 */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 2 */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 3 */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 4 */ - - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 5 */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 6 */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 7 */ - outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 8 */ - - udelay(10); - inw(dev->iobase + 0); /* make a dummy read */ inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */ -- cgit v1.2.3-59-g8ed1b From 6174801d7e9ff27b3a589fe766f4cd75de14c31b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:20 -0700 Subject: staging: comedi: addi_apci_3120: fix apci3120_ao_insn_write() The comedi core expects (*insn_write) functions to write insn->n values and return the number of values written or an errno. This function currently returns insn->n but it only writes a single data value. Fix the function to work like the core expects. There are two registers used to update the analog outputs. Offset 0x08 is used to update channels 0-3 and offset 0x0a to update channels 4-7. Bits 14 and 15 in each register set the mux to select which channel to update. The lower 14 bits are the value used to set the DAC. For aesthetics, tidy up the defines used for the register offsets and bits in the registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 45 ++++++---------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 16 ++++++++ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index fbe17917cea1..47b1741758d1 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -96,24 +96,12 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_SET4DIGITALOUTPUTON 1 #define APCI3120_SET4DIGITALOUTPUTOFF 0 -/* analog output SELECT BIT */ -#define APCI3120_ANALOG_OP_CHANNEL_1 0x0000 -#define APCI3120_ANALOG_OP_CHANNEL_2 0x4000 -#define APCI3120_ANALOG_OP_CHANNEL_3 0x8000 -#define APCI3120_ANALOG_OP_CHANNEL_4 0xc000 -#define APCI3120_ANALOG_OP_CHANNEL_5 0x0000 -#define APCI3120_ANALOG_OP_CHANNEL_6 0x4000 -#define APCI3120_ANALOG_OP_CHANNEL_7 0x8000 -#define APCI3120_ANALOG_OP_CHANNEL_8 0xc000 - /* Enable external trigger bit in nWrAddress */ #define APCI3120_ENABLE_EXT_TRIGGER 0x8000 /* ANALOG OUTPUT AND INPUT DEFINE */ #define APCI3120_UNIPOLAR 0x80 #define APCI3120_BIPOLAR 0x00 -#define APCI3120_ANALOG_OUTPUT_1 0x08 -#define APCI3120_ANALOG_OUTPUT_2 0x0a #define APCI3120_1_GAIN 0x00 #define APCI3120_2_GAIN 0x10 #define APCI3120_5_GAIN 0x20 @@ -1923,31 +1911,20 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int ui_Channel; - int ret; - - ui_Channel = CR_CHAN(insn->chanspec); + unsigned int chan = CR_CHAN(insn->chanspec); + int i; - data[0] = ((((ui_Channel & 0x03) << 14) & 0xC000) | data[0]); + for (i = 0; i < insn->n; i++) { + unsigned int val = data[i]; + int ret; - ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0); - if (ret) - return ret; + ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0); + if (ret) + return ret; - if (ui_Channel <= 3) - /* - * for channel 0-3 out at the register 1 (wrDac1-8) data[i] - * typecasted to ushort since word write is to be done - */ - outw((unsigned short) data[0], - dev->iobase + APCI3120_ANALOG_OUTPUT_1); - else - /* - * for channel 4-7 out at the register 2 (wrDac5-8) data[i] - * typecasted to ushort since word write is to be done - */ - outw((unsigned short) data[0], - dev->iobase + APCI3120_ANALOG_OUTPUT_2); + outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val), + dev->iobase + APCI3120_AO_REG(chan)); + } return insn->n; } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 6b4a51db9c9e..abc85bf000ff 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -7,6 +7,22 @@ #include "comedi_fc.h" #include "amcc_s5933.h" +/* + * PCI BAR 0 register map (devpriv->amcc) + * see amcc_s5933.h for register and bit defines + */ + +/* + * PCI BAR 1 register map (dev->iobase) + */ +#define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) +#define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) +#define APCI3120_AO_DATA(x) ((x) << 0) + +/* + * PCI BAR 2 register map (devpriv->addon) + */ + enum apci3120_boardid { BOARD_APCI3120, BOARD_APCI3001, -- cgit v1.2.3-59-g8ed1b From bf34c2262270bc4d7e1d7747a15675942a5dd9c4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:21 -0700 Subject: staging: comedi: addi_apci_3120: provide analog output 'readback' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) function to provide radback of the analog output channels. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 ++ drivers/staging/comedi/drivers/addi_apci_3120.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 47b1741758d1..c093cd4bce3d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1924,6 +1924,8 @@ static int apci3120_ao_insn_write(struct comedi_device *dev, outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val), dev->iobase + APCI3120_AO_REG(chan)); + + s->readback[chan] = val; } return insn->n; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index abc85bf000ff..5db52cd04319 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -195,6 +195,11 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->maxdata = 0x3fff; s->range_table = &range_bipolar10; s->insn_write = apci3120_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From f6dc93082613dbc89f03b85539cf6cf3eda2f073 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:22 -0700 Subject: staging: comedi: addi_apci_3120: tidy up analog output subdevice init For aesthetics, add some white space to the analog output subdevice initialization. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 5db52cd04319..8cd3ef13536e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -186,22 +186,22 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->do_cmd = apci3120_ai_cmd; s->cancel = apci3120_cancel; - /* Allocate and Initialise AO Subdevice Structures */ + /* Analog Output subdevice */ s = &dev->subdevices[1]; if (this_board->has_ao) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 8; - s->maxdata = 0x3fff; - s->range_table = &range_bipolar10; - s->insn_write = apci3120_ao_insn_write; - s->insn_read = comedi_readback_insn_read; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 8; + s->maxdata = 0x3fff; + s->range_table = &range_bipolar10; + s->insn_write = apci3120_ao_insn_write; + s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) return ret; } else { - s->type = COMEDI_SUBD_UNUSED; + s->type = COMEDI_SUBD_UNUSED; } /* Allocate and Initialise DI Subdevice Structures */ -- cgit v1.2.3-59-g8ed1b From dc842931be5a8d8a2a2441e6c762b93b7aaaecbf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:23 -0700 Subject: staging: comedi: addi_apci_3120: tidy up digital input subdevice init For aesthetics, add some white space to the digital input subdevice initialization. Remove the subdev_flags SDF_GROUND and SDF_COMMON. These only apply to analog subdevices. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 8cd3ef13536e..b0d62cd475e1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -204,14 +204,14 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise DI Subdevice Structures */ + /* Digital Input subdevice */ s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = apci3120_di_insn_bits; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci3120_di_insn_bits; /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[3]; -- cgit v1.2.3-59-g8ed1b From 1bed58e3b6c02614aeb14dea58e1f12ec79a9d17 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:24 -0700 Subject: staging: comedi: addi_apci_3120: tidy up digital output subdevice init For aesthetics, add some white space to the digital output subdevice initialization. Remove the subdev_flags SDF_GROUND and SDF_COMMON. These only apply to analog subdevices. Also remove the unnecessary SDF_READABLE subdev_flag. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index b0d62cd475e1..358bfd3f3417 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -213,15 +213,14 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = apci3120_di_insn_bits; - /* Allocate and Initialise DO Subdevice Structures */ + /* Digital Output subdevice */ s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = apci3120_do_insn_bits; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci3120_do_insn_bits; /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[4]; -- cgit v1.2.3-59-g8ed1b From 2a420f408aa73759b61446503adbd83c88e33966 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:25 -0700 Subject: staging: comedi: addi_apci_3120: tidy up analog input subdevice init For aesthetics, add some white space to the analog input subdevice initialization. The async command support in this driver is pretty messed up. I'm not really sure if it actually works yet. Luckly this driver was not setting the SDF_CMD_READ subdev_flag so the command support was not actually getting enabled. The command support only works if an interrupt is available. Refactor the subdevice init so that the command support is only hooked up if we have an interrupt. For now always disable the command support. Once the driver has been cleaned up the command will be enabled. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 358bfd3f3417..cc561788e740 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -168,23 +168,23 @@ static int apci3120_auto_attach(struct comedi_device *dev, if (ret) return ret; - /* Allocate and Initialise AI Subdevice Structures */ + /* Analog Input subdevice */ s = &dev->subdevices[0]; - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = - SDF_READABLE | SDF_COMMON | SDF_GROUND - | SDF_DIFF; - s->n_chan = 16; - s->maxdata = this_board->ai_is_16bit ? 0xffff : 0x0fff; - s->len_chanlist = s->n_chan; - s->range_table = &range_apci3120_ai; - - s->insn_config = apci3120_ai_insn_config; - s->insn_read = apci3120_ai_insn_read; - s->do_cmdtest = apci3120_ai_cmdtest; - s->do_cmd = apci3120_ai_cmd; - s->cancel = apci3120_cancel; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; + s->n_chan = 16; + s->maxdata = this_board->ai_is_16bit ? 0xffff : 0x0fff; + s->range_table = &range_apci3120_ai; + s->insn_config = apci3120_ai_insn_config; + s->insn_read = apci3120_ai_insn_read; + if (0 /* dev->irq */) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = s->n_chan; + s->do_cmdtest = apci3120_ai_cmdtest; + s->do_cmd = apci3120_ai_cmd; + s->cancel = apci3120_cancel; + } /* Analog Output subdevice */ s = &dev->subdevices[1]; -- cgit v1.2.3-59-g8ed1b From 758505199e89de48374ed1c8618f95c218e9cd6f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:26 -0700 Subject: staging: comedi: addi_apci_3120: tidy up timer subdevice init It appears that this subdevice is actually broken. The subdevice functions all violate the comedi API and, it they did work, it appears they would break the analog input async commands. For now just tidy up the subdevice init. Add the SDF_READABLE subdev_flag, this subdevice provides an (*insn_read). Fix the subdevice 'maxdata' initialization. The timer is 24-bits. Remove the 'len_chanlist' initialization. This member is only used by subdevices that support async commands. Also remove the 'range_table' initialization. The core will set it to range_unknown which is appropriate. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index cc561788e740..ec6f89b9e99c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -222,18 +222,15 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = apci3120_do_insn_bits; - /* Allocate and Initialise Timer Subdevice Structures */ + /* Timer subdevice */ s = &dev->subdevices[4]; - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 1; - s->maxdata = 0; - s->len_chanlist = 1; - s->range_table = &range_digital; - - s->insn_write = apci3120_write_insn_timer; - s->insn_read = apci3120_read_insn_timer; - s->insn_config = apci3120_config_insn_timer; + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_READABLE; + s->n_chan = 1; + s->maxdata = 0x00ffffff; + s->insn_write = apci3120_write_insn_timer; + s->insn_read = apci3120_read_insn_timer; + s->insn_config = apci3120_config_insn_timer; apci3120_reset(dev); return 0; -- cgit v1.2.3-59-g8ed1b From 73ef19314649fbd915d39c04de5057ece3b604e4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:27 -0700 Subject: staging: comedi: addi_apci_3120: reset the board before hooking up the interrupt Move the apci3120_reset() call in the (*auto_attach) to ensure that the board is reset before hooking up the interrupt. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ec6f89b9e99c..3b4fa2ebbc85 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -154,6 +154,8 @@ static int apci3120_auto_attach(struct comedi_device *dev, devpriv->amcc = pci_resource_start(pcidev, 0); devpriv->addon = pci_resource_start(pcidev, 2); + apci3120_reset(dev); + if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, apci3120_interrupt, IRQF_SHARED, dev->board_name, dev); @@ -232,7 +234,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->insn_read = apci3120_read_insn_timer; s->insn_config = apci3120_config_insn_timer; - apci3120_reset(dev); return 0; } -- cgit v1.2.3-59-g8ed1b From a2eb0fd71c7729625bd5d7168c01f89a8d51af37 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:28 -0700 Subject: staging: comedi: addi_apci_3120: don't reset board when canceling ai command The analog input (*cancel) stops the async command. There is not reason to also call the board reset function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c093cd4bce3d..10deb72a4b37 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -635,7 +635,7 @@ static int apci3120_cancel(struct comedi_device *dev, devpriv->ai_running = 0; devpriv->b_InterruptMode = APCI3120_EOC_MODE; devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - apci3120_reset(dev); + return 0; } -- cgit v1.2.3-59-g8ed1b From 22be3f81429608aad8229ee60e8f834024291f09 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 Oct 2014 11:34:29 -0700 Subject: staging: comedi: addi_apci_3120: don't reset board when detaching driver The comedi core calls all the subdevice (*cancel) functions before it does the driver (*detach). There is no reason to call the board reset function in the (*detach). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 3b4fa2ebbc85..e5dbbdf33b40 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -239,8 +239,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, static void apci3120_detach(struct comedi_device *dev) { - if (dev->iobase) - apci3120_reset(dev); comedi_pci_detach(dev); apci3120_dma_free(dev); } -- cgit v1.2.3-59-g8ed1b From 4455d7c351dada63ec031a82760fa00d7806139a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:34 -0700 Subject: staging: comedi: comedi_buf: introduce comedi_buf_read_samples() Introduce a generic method to read samples from the async buffer. The number of requested samples is clampled to the number of samples that would fill the async buffer. The size of each sample is determined using the bytes_per_sample() helper. The number of bytes need are then read from the async buffer using comedi_read_array_from_buffer(). This will allow converting all the comedi drivers to use a common method to read data from the async buffer. Since comedi_read_array_from_buffer() sets the COMEDI_CB_BLOCK event after reading the data, those events can be removed from the drivers. In addition, comedi_inc_scan_progress() will automatically detect the end of scan and set the COMEDI_CB_EOS event. Those events can also be removed from the drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 27 +++++++++++++++++++++++++++ drivers/staging/comedi/comedidev.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index c60a45ad12b9..88a7cae97811 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -575,3 +575,30 @@ unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, return num_bytes; } EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer); + +/** + * comedi_buf_read_samples - read sample data from comedi buffer + * @s: comedi_subdevice struct + * @data: destination + * @nsamples: maximum number of samples to read + * + * Reads up to nsamples from the comedi buffer associated with the subdevice, + * marks it as read and updates the acquisition scan progress. + * + * Returns the amount of data read in bytes. + */ +unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, + void *data, unsigned int nsamples) +{ + unsigned int max_samples; + unsigned int nbytes; + + max_samples = s->async->prealloc_bufsz / bytes_per_sample(s); + if (nsamples > max_samples) + nsamples = max_samples; + + nbytes = nsamples * bytes_per_sample(s); + + return comedi_read_array_from_buffer(s, data, nbytes); +} +EXPORT_SYMBOL_GPL(comedi_buf_read_samples); diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index fb8ff84dab35..ba4084bd5ed8 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -453,6 +453,8 @@ unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, unsigned int num_bytes); unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, void *data, unsigned int num_bytes); +unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, + void *data, unsigned int nsamples); /* drivers.c - general comedi driver functions */ -- cgit v1.2.3-59-g8ed1b From bcdbe8848e8dbcd0bee3fcfa86c08f16c9730a15 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:35 -0700 Subject: staging: comedi: amplc_pci224: use comedi_buf_read_samples() Use the new generic method to read the analog output samples from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 9fcf6f77c96e..342779f1f84a 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -514,14 +514,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, { struct pci224_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int bytes_per_scan = comedi_bytes_per_scan(s); unsigned int num_scans; unsigned int room; unsigned short dacstat; unsigned int i, n; /* Determine number of scans available in buffer. */ - num_scans = comedi_buf_read_n_available(s) / bytes_per_scan; + num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s); if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_stop_count) @@ -568,8 +567,8 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, /* Process scans. */ for (n = 0; n < num_scans; n++) { - cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0], - bytes_per_scan); + comedi_buf_read_samples(s, &devpriv->ao_scan_vals[0], + cmd->chanlist_len); for (i = 0; i < cmd->chanlist_len; i++) { outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]], dev->iobase + PCI224_DACDATA); -- cgit v1.2.3-59-g8ed1b From 2cc9854caf92526199935bc29685e253349362bc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:36 -0700 Subject: staging: comedi: cb_pcidas: introduce cb_pcidas_ao_load_fifo() Introduce a helper function to load the analog output FIFO. This fixes a bug in cb_pcidas_ao_inttrig(). That function was writing 'num_bytes' data values to the FIFO instead of 'num_points'. This results in twice the number of data values getting written to the FIFO. Use comedi_buf_read_samples() read the analog output samples from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 54 ++++++++++++------------------ 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index e7ab6bcfa90b..a0d462fecf20 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1134,32 +1134,39 @@ static int cb_pcidas_cancel(struct comedi_device *dev, return 0; } +static void cb_pcidas_ao_load_fifo(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int nsamples) +{ + struct cb_pcidas_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int nbytes; + + if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples) + nsamples = devpriv->ao_count; + + nbytes = comedi_buf_read_samples(s, devpriv->ao_buffer, nsamples); + nsamples = nbytes / bytes_per_sample(s); + if (cmd->stop_src == TRIG_COUNT) + devpriv->ao_count -= nsamples; + + outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, nsamples); +} + static int cb_pcidas_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { const struct cb_pcidas_board *thisboard = dev->board_ptr; struct cb_pcidas_private *devpriv = dev->private; - unsigned int num_bytes, num_points = thisboard->fifo_size; struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_cmd *cmd = &async->cmd; unsigned long flags; if (trig_num != cmd->start_arg) return -EINVAL; - /* load up fifo */ - if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points) - num_points = devpriv->ao_count; - - num_bytes = cfc_read_array_from_buffer(s, devpriv->ao_buffer, - num_points * sizeof(short)); - num_points = num_bytes / sizeof(short); - - if (cmd->stop_src == TRIG_COUNT) - devpriv->ao_count -= num_points; - /* write data to board's fifo */ - outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes); + cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size); /* enable dac half-full and empty interrupts */ spin_lock_irqsave(&dev->spinlock, flags); @@ -1275,8 +1282,6 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) struct comedi_subdevice *s = dev->write_subdev; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned int half_fifo = thisboard->fifo_size / 2; - unsigned int num_points; unsigned long flags; if (status & DAEMI) { @@ -1295,23 +1300,8 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) async->events |= COMEDI_CB_EOA; } } else if (status & DAHFI) { - unsigned int num_bytes; + cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size / 2); - /* figure out how many points we are writing to fifo */ - num_points = half_fifo; - if (cmd->stop_src == TRIG_COUNT && - devpriv->ao_count < num_points) - num_points = devpriv->ao_count; - num_bytes = - cfc_read_array_from_buffer(s, devpriv->ao_buffer, - num_points * sizeof(short)); - num_points = num_bytes / sizeof(short); - - if (cmd->stop_src == TRIG_COUNT) - devpriv->ao_count -= num_points; - /* write data to board's fifo */ - outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, - num_points); /* clear half-full interrupt latch */ spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | DAHFI, -- cgit v1.2.3-59-g8ed1b From 7bd7d905629a8748fa43d20b930213f54ac9177d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:37 -0700 Subject: staging: comedi: cb_pcidas: introduce cb_pcidas64_ao_fill_buffer() Introduce a helper function to read the analog output samples from the async buffer. This fixes a bug in load_ao_dma_buffer(). That function was decrementing the 'ao_count' by the number of bytes, not the number of samples, that were read from the async buffer. Use comedi_buf_read_samples() to read the analog output samples from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 79 +++++++++++++++++----------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index eafbe9f56060..06e846f38992 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2912,32 +2912,46 @@ static void restart_ao_dma(struct comedi_device *dev) dma_start_sync(dev, 0); } +static unsigned int cb_pcidas64_ao_fill_buffer(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned short *dest, + unsigned int max_bytes) +{ + struct pcidas64_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int nsamples = max_bytes / bytes_per_sample(s); + unsigned int actual_bytes; + + if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples) + nsamples = devpriv->ao_count; + + actual_bytes = comedi_buf_read_samples(s, dest, nsamples); + nsamples = actual_bytes / bytes_per_sample(s); + if (cmd->stop_src == TRIG_COUNT) + devpriv->ao_count -= nsamples; + + return nsamples; +} + static unsigned int load_ao_dma_buffer(struct comedi_device *dev, const struct comedi_cmd *cmd) { struct pcidas64_private *devpriv = dev->private; - unsigned int num_bytes, buffer_index, prev_buffer_index; + struct comedi_subdevice *s = dev->write_subdev; + unsigned int buffer_index = devpriv->ao_dma_index; + unsigned int prev_buffer_index = prev_ao_dma_index(dev); + unsigned int nsamples; + unsigned int nbytes; unsigned int next_bits; - buffer_index = devpriv->ao_dma_index; - prev_buffer_index = prev_ao_dma_index(dev); - - num_bytes = comedi_buf_read_n_available(dev->write_subdev); - if (num_bytes > DMA_BUFFER_SIZE) - num_bytes = DMA_BUFFER_SIZE; - if (cmd->stop_src == TRIG_COUNT && num_bytes > devpriv->ao_count) - num_bytes = devpriv->ao_count; - num_bytes -= num_bytes % bytes_in_sample; - - if (num_bytes == 0) + nsamples = cb_pcidas64_ao_fill_buffer(dev, s, + devpriv->ao_buffer[buffer_index], + DMA_BUFFER_SIZE); + if (nsamples == 0) return 0; - num_bytes = cfc_read_array_from_buffer(dev->write_subdev, - devpriv-> - ao_buffer[buffer_index], - num_bytes); - devpriv->ao_dma_desc[buffer_index].transfer_size = - cpu_to_le32(num_bytes); + nbytes = nsamples * bytes_per_sample(s); + devpriv->ao_dma_desc[buffer_index].transfer_size = cpu_to_le32(nbytes); /* set end of chain bit so we catch underruns */ next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next); next_bits |= PLX_END_OF_CHAIN_BIT; @@ -2949,9 +2963,8 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev, devpriv->ao_dma_desc[prev_buffer_index].next = cpu_to_le32(next_bits); devpriv->ao_dma_index = (buffer_index + 1) % AO_DMA_RING_COUNT; - devpriv->ao_count -= num_bytes; - return num_bytes; + return nbytes; } static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) @@ -3191,7 +3204,9 @@ static void set_dac_interval_regs(struct comedi_device *dev, static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) { struct pcidas64_private *devpriv = dev->private; - unsigned int num_bytes; + struct comedi_subdevice *s = dev->write_subdev; + unsigned int nsamples; + unsigned int nbytes; int i; /* clear queue pointer too, since external queue has @@ -3199,22 +3214,22 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG); writew(0, devpriv->main_iobase + DAC_BUFFER_CLEAR_REG); - num_bytes = (DAC_FIFO_SIZE / 2) * bytes_in_sample; - if (cmd->stop_src == TRIG_COUNT && - num_bytes / bytes_in_sample > devpriv->ao_count) - num_bytes = devpriv->ao_count * bytes_in_sample; - num_bytes = cfc_read_array_from_buffer(dev->write_subdev, - devpriv->ao_bounce_buffer, - num_bytes); - for (i = 0; i < num_bytes / bytes_in_sample; i++) { + nsamples = cb_pcidas64_ao_fill_buffer(dev, s, + devpriv->ao_bounce_buffer, + DAC_FIFO_SIZE); + if (nsamples == 0) + return -1; + + for (i = 0; i < nsamples; i++) { writew(devpriv->ao_bounce_buffer[i], devpriv->main_iobase + DAC_FIFO_REG); } - devpriv->ao_count -= num_bytes / bytes_in_sample; + if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count == 0) return 0; - num_bytes = load_ao_dma_buffer(dev, cmd); - if (num_bytes == 0) + + nbytes = load_ao_dma_buffer(dev, cmd); + if (nbytes == 0) return -1; load_ao_dma(dev, cmd); -- cgit v1.2.3-59-g8ed1b From ecb11d8c28aa7fe761467873e69a3c5c66b57aed Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:38 -0700 Subject: staging: comedi: dt282x: introduce dt282x_ao_setup_dma() Introduce a helper function to read the analog output samples from the async buffer and prep the DMA. Use comedi_buf_read_samples() to read the analog output samples from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index f23d883f2544..88b56104d4e7 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -449,13 +449,29 @@ static void dt282x_munge(struct comedi_device *dev, } } +static unsigned int dt282x_ao_setup_dma(struct comedi_device *dev, + struct comedi_subdevice *s, + int cur_dma) +{ + struct dt282x_private *devpriv = dev->private; + void *ptr = devpriv->dma[cur_dma].buf; + unsigned int nsamples = devpriv->dma_maxsize / bytes_per_sample(s); + unsigned int nbytes; + + nbytes = comedi_buf_read_samples(s, ptr, nsamples); + if (nbytes) + dt282x_prep_ao_dma(dev, cur_dma, nbytes); + else + dev_err(dev->class_dev, "AO underrun\n"); + + return nbytes; +} + static void dt282x_ao_dma_interrupt(struct comedi_device *dev, struct comedi_subdevice *s) { struct dt282x_private *devpriv = dev->private; int cur_dma = devpriv->current_dma_index; - void *ptr = devpriv->dma[cur_dma].buf; - int size; outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE, dev->iobase + DT2821_SUPCSR_REG); @@ -464,13 +480,8 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev, devpriv->current_dma_index = 1 - cur_dma; - size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize); - if (size == 0) { - dev_err(dev->class_dev, "AO underrun\n"); + if (!dt282x_ao_setup_dma(dev, s, cur_dma)) s->async->events |= COMEDI_CB_OVERFLOW; - } else { - dt282x_prep_ao_dma(dev, cur_dma, size); - } } static void dt282x_ai_dma_interrupt(struct comedi_device *dev, @@ -916,26 +927,15 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, { struct dt282x_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int size; if (trig_num != cmd->start_src) return -EINVAL; - size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf, - devpriv->dma_maxsize); - if (size == 0) { - dev_err(dev->class_dev, "AO underrun\n"); + if (!dt282x_ao_setup_dma(dev, s, 0)) return -EPIPE; - } - dt282x_prep_ao_dma(dev, 0, size); - size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf, - devpriv->dma_maxsize); - if (size == 0) { - dev_err(dev->class_dev, "AO underrun\n"); + if (!dt282x_ao_setup_dma(dev, s, 1)) return -EPIPE; - } - dt282x_prep_ao_dma(dev, 1, size); outw(devpriv->supcsr | DT2821_SUPCSR_STRIG, dev->iobase + DT2821_SUPCSR_REG); -- cgit v1.2.3-59-g8ed1b From 65ad7c89aa4d376419a134ffe69113db0333d25f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:39 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_read_array_from_buffer() This inline function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index 0f4b360cf9ec..fed0a54e5af6 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -42,13 +42,6 @@ static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *s, return comedi_write_array_to_buffer(s, &data, sizeof(data)); }; -static inline unsigned int -cfc_read_array_from_buffer(struct comedi_subdevice *s, void *data, - unsigned int num_bytes) -{ - return comedi_read_array_from_buffer(s, data, num_bytes); -} - /** * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source * @src: pointer to the trigger source to validate -- cgit v1.2.3-59-g8ed1b From 2b3e13b8605ee0915804ce73d6e5e4e72fc51ba2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:40 -0700 Subject: staging: comedi: comedi_buf: remove export of comedi_read_array_from_buffer() This function is only used internally. Remove the export. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 17 +++-------------- drivers/staging/comedi/comedidev.h | 2 -- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 88a7cae97811..d1303a831462 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -549,19 +549,9 @@ unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer); -/** - * comedi_read_array_from_buffer - read data from comedi buffer - * @s: comedi_subdevice struct - * @data: destination - * @num_bytes: number of bytes to read - * - * Reads up to num_bytes bytes of data from the comedi buffer associated with - * the subdevice, marks it as read and updates the acquisition scan progress. - * - * Returns the amount of data read in bytes. - */ -unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, - void *data, unsigned int num_bytes) +static unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, + void *data, + unsigned int num_bytes) { if (num_bytes == 0) return 0; @@ -574,7 +564,6 @@ unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, return num_bytes; } -EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer); /** * comedi_buf_read_samples - read sample data from comedi buffer diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index ba4084bd5ed8..766387dcab95 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -451,8 +451,6 @@ void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, const void *data, unsigned int num_bytes); -unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, - void *data, unsigned int num_bytes); unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, void *data, unsigned int nsamples); -- cgit v1.2.3-59-g8ed1b From 109bf06e2a88a04607c93d8223e4be0af09ebc8c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:41 -0700 Subject: staging: comedi: comedi_buf: absorb comedi_read_array_from_buffer() This function is only called by comedi_buf_read_samples(). Absorb it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index d1303a831462..9074da2cbe0a 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -549,22 +549,6 @@ unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer); -static unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s, - void *data, - unsigned int num_bytes) -{ - if (num_bytes == 0) - return 0; - - num_bytes = comedi_buf_read_alloc(s, num_bytes); - comedi_buf_memcpy_from(s, 0, data, num_bytes); - comedi_buf_read_free(s, num_bytes); - comedi_inc_scan_progress(s, num_bytes); - s->async->events |= COMEDI_CB_BLOCK; - - return num_bytes; -} - /** * comedi_buf_read_samples - read sample data from comedi buffer * @s: comedi_subdevice struct @@ -587,7 +571,15 @@ unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, nsamples = max_samples; nbytes = nsamples * bytes_per_sample(s); + if (nbytes == 0) + return 0; - return comedi_read_array_from_buffer(s, data, nbytes); + nbytes = comedi_buf_read_alloc(s, nbytes); + comedi_buf_memcpy_from(s, 0, data, nbytes); + comedi_buf_read_free(s, nbytes); + comedi_inc_scan_progress(s, nbytes); + s->async->events |= COMEDI_CB_BLOCK; + + return nbytes; } EXPORT_SYMBOL_GPL(comedi_buf_read_samples); -- cgit v1.2.3-59-g8ed1b From 8de27e7010cbd8c75a4e04a9807adacc7a8d70b2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:42 -0700 Subject: staging: comedi: comedi_buf: make comedi_buf_read_samples() always return full samples A number of drivers currently use comedi_buf_get() to read single samples from the the async buffer. This works but the drivers have to handle the COMEDI_CB_BLOCK and COMEDI_CB_EOS events. Converting those drivers to use comedi_buf_read_samples() moves the handling of those events into the core. Modify comedi_buf_read_samples() so that the async buffer is checked for the number of full samples available. Use that to clamp the number of samples that will be read. This makes sure that only full samples are read from the async buffer making comedi_buf_read_samples() mimic the action of comedi_buf_get() with the added benifit of handling the events. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 9074da2cbe0a..fb2e91a0e724 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -566,15 +566,15 @@ unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, unsigned int max_samples; unsigned int nbytes; - max_samples = s->async->prealloc_bufsz / bytes_per_sample(s); + /* clamp nsamples to the number of full samples available */ + max_samples = comedi_buf_read_n_available(s) / bytes_per_sample(s); if (nsamples > max_samples) nsamples = max_samples; - nbytes = nsamples * bytes_per_sample(s); - if (nbytes == 0) + if (nsamples == 0) return 0; - nbytes = comedi_buf_read_alloc(s, nbytes); + nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s)); comedi_buf_memcpy_from(s, 0, data, nbytes); comedi_buf_read_free(s, nbytes); comedi_inc_scan_progress(s, nbytes); -- cgit v1.2.3-59-g8ed1b From e14c6a60b51eb53f96a91f4650e16e61b4e9c861 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:43 -0700 Subject: staging: comedi: ni_mio_common: use comedi_buf_read_samples() Use comedi_buf_read_samples() to get the single samples from the async buffer. The number of samples in the buffer was validated by the callers so the error checking can be removed. In addition, the core will set the COMEDI_CB_BLOCK event so it can also be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index fa5b25063661..8004e8ac945d 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1132,13 +1132,10 @@ static void ni_ao_fifo_load(struct comedi_device *dev, unsigned short d; u32 packed_data; int range; - int err = 1; chan = async->cur_chan; for (i = 0; i < n; i++) { - err &= comedi_buf_get(s, &d); - if (err == 0) - break; + comedi_buf_read_samples(s, &d, 1); range = CR_RANGE(cmd->chanlist[chan]); @@ -1146,9 +1143,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, packed_data = d & 0xffff; /* 6711 only has 16 bit wide ao fifo */ if (!devpriv->is_6711) { - err &= comedi_buf_get(s, &d); - if (err == 0) - break; + comedi_buf_read_samples(s, &d, 1); chan++; i++; packed_data |= (d << 16) & 0xffff0000; @@ -1161,8 +1156,6 @@ static void ni_ao_fifo_load(struct comedi_device *dev, chan %= cmd->chanlist_len; } async->cur_chan = chan; - if (err == 0) - async->events |= COMEDI_CB_OVERFLOW; } /* @@ -1199,8 +1192,6 @@ static int ni_ao_fifo_half_empty(struct comedi_device *dev, ni_ao_fifo_load(dev, s, n); - s->async->events |= COMEDI_CB_BLOCK; - return 1; } -- cgit v1.2.3-59-g8ed1b From dec1a2668629755b4c926f1473ecd2615d3a3d73 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:44 -0700 Subject: staging: comedi: amplc_pci230: use comedi_buf_read_samples() Use comedi_buf_read_samples() to read the analog output samples from the async buffer. That function will set the COMEDI_CB_BLOCK event when samples are read from the async buffer. In addition, the core will also handle the end-of-scan detection and set the COMEDI_CB_EOS event. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index a3b34d881a08..f9b952f7173e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1075,26 +1075,25 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci230_private *devpriv = dev->private; - unsigned short data; - int i, ret; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; + unsigned short data; + int i; if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0) return; + for (i = 0; i < cmd->chanlist_len; i++) { unsigned int chan = CR_CHAN(cmd->chanlist[i]); - /* Read sample from Comedi's circular buffer. */ - ret = comedi_buf_get(s, &data); - if (ret == 0) { - s->async->events |= COMEDI_CB_OVERFLOW; + if (!comedi_buf_read_samples(s, &data, 1)) { + async->events |= COMEDI_CB_OVERFLOW; return; } pci230_ao_write_nofifo(dev, data, chan); s->readback[chan] = data; } - async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_scan_count--; if (devpriv->ao_scan_count == 0) { @@ -1171,12 +1170,12 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short datum; - comedi_buf_get(s, &datum); + comedi_buf_read_samples(s, &datum, 1); pci230_ao_write_fifo(dev, datum, chan); s->readback[chan] = datum; } } - events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK; + if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_scan_count -= num_scans; if (devpriv->ao_scan_count == 0) { -- cgit v1.2.3-59-g8ed1b From 664ab5d6db57c5805ed3e1bfc06f39aad80ce34e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:45 -0700 Subject: staging: comedi: usbdux: use comedi_buf_read_samples() Use comedi_buf_read_samples() to read the analog output samples from the async buffer. That function will set the COMEDI_CB_BLOCK event when samples are read from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index eae441f3858c..53f1e218d0d9 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -413,7 +413,7 @@ static void usbduxsub_ao_handle_urb(struct comedi_device *dev, unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short val; - if (!comedi_buf_get(s, &val)) { + if (!comedi_buf_read_samples(s, &val, 1)) { dev_err(dev->class_dev, "buffer underflow\n"); async->events |= COMEDI_CB_OVERFLOW; return; @@ -425,7 +425,6 @@ static void usbduxsub_ao_handle_urb(struct comedi_device *dev, *datap++ = chan << 6; s->readback[chan] = val; } - async->events |= COMEDI_CB_BLOCK; } /* if command is still running, resubmit urb for BULK transfer */ -- cgit v1.2.3-59-g8ed1b From e463fbe419b70744c7126ec198c6d6e2cffa5c87 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:46 -0700 Subject: staging: comedi: usbduxsigma: use comedi_buf_read_samples() Use comedi_buf_read_samples() to read the analog output samples from the async buffer. That function will set the COMEDI_CB_BLOCK event when samples are read from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 1d12cc6c1ade..de3fb41b1886 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -374,7 +374,7 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device *dev, unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short val; - if (!comedi_buf_get(s, &val)) { + if (!comedi_buf_read_samples(s, &val, 1)) { dev_err(dev->class_dev, "buffer underflow\n"); async->events |= COMEDI_CB_OVERFLOW; return; @@ -384,7 +384,6 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device *dev, *datap++ = chan; s->readback[chan] = val; } - async->events |= COMEDI_CB_BLOCK; } /* if command is still running, resubmit urb */ -- cgit v1.2.3-59-g8ed1b From 04c4166a22717241c3d5fdf8740c7e4c9a0bdf25 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:47 -0700 Subject: staging: comedi: comedi_buf: remove comedi_buf_get() This function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 14 -------------- drivers/staging/comedi/comedidev.h | 1 - 2 files changed, 15 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index fb2e91a0e724..f7ff420ed612 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -442,20 +442,6 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) } EXPORT_SYMBOL_GPL(comedi_buf_put); -int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x) -{ - struct comedi_async *async = s->async; - unsigned int n = comedi_buf_read_n_available(s); - - if (n < sizeof(short)) - return 0; - comedi_buf_read_alloc(s, sizeof(short)); - *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr); - comedi_buf_read_free(s, sizeof(short)); - return 1; -} -EXPORT_SYMBOL_GPL(comedi_buf_get); - void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, const void *data, unsigned int num_bytes) { diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 766387dcab95..df0209a53206 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -442,7 +442,6 @@ unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); -int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x); void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, const void *source, unsigned int num_bytes); -- cgit v1.2.3-59-g8ed1b From 9e2093d2399a771f3896292b95ca44a147f5ac6e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:48 -0700 Subject: staging: comedi: comedi_buf: dont't export comedi_buf_memcpy_from() This function is only used internally. Remove the export. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 6 +++--- drivers/staging/comedi/comedidev.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index f7ff420ed612..a87b8e66fde0 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -469,8 +469,9 @@ void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, } EXPORT_SYMBOL_GPL(comedi_buf_memcpy_to); -void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, - void *dest, unsigned int nbytes) +static void comedi_buf_memcpy_from(struct comedi_subdevice *s, + unsigned int offset, + void *dest, unsigned int nbytes) { void *src; struct comedi_async *async = s->async; @@ -495,7 +496,6 @@ void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, read_ptr = 0; } } -EXPORT_SYMBOL_GPL(comedi_buf_memcpy_from); /** * comedi_write_array_to_buffer - write data to comedi buffer diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index df0209a53206..ce48828bdae8 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -445,8 +445,7 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, const void *source, unsigned int num_bytes); -void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, - void *destination, unsigned int num_bytes); + unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, const void *data, unsigned int num_bytes); -- cgit v1.2.3-59-g8ed1b From aa26e46b0f1d2c0093ec59a68aec715df3f06715 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:49 -0700 Subject: staging: comedi: comedi_buf: don't export comedi_buf_memcpy_to() This function is only used internally. Remove the export. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 6 +++--- drivers/staging/comedi/comedidev.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index a87b8e66fde0..0e4727dee030 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -442,8 +442,9 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) } EXPORT_SYMBOL_GPL(comedi_buf_put); -void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, - const void *data, unsigned int num_bytes) +static void comedi_buf_memcpy_to(struct comedi_subdevice *s, + unsigned int offset, + const void *data, unsigned int num_bytes) { struct comedi_async *async = s->async; unsigned int write_ptr = async->buf_write_ptr + offset; @@ -467,7 +468,6 @@ void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, write_ptr = 0; } } -EXPORT_SYMBOL_GPL(comedi_buf_memcpy_to); static void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index ce48828bdae8..9f4f9ef2b79a 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -443,9 +443,6 @@ unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); -void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, - const void *source, unsigned int num_bytes); - unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, const void *data, unsigned int num_bytes); -- cgit v1.2.3-59-g8ed1b From 319ad742bddace99d6576e4b6fba1f074f29ed2a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:50 -0700 Subject: staging: comedi: comedi_buf: comedi_buf_memcpy_to() remove 'offset' param This parameter is always passed as '0'. Remove the unnecessary parameter. This allows removing the unnecessary check of the write_ptr overflow. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 0e4727dee030..c60fa1aa2048 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -443,14 +443,10 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) EXPORT_SYMBOL_GPL(comedi_buf_put); static void comedi_buf_memcpy_to(struct comedi_subdevice *s, - unsigned int offset, const void *data, unsigned int num_bytes) { struct comedi_async *async = s->async; - unsigned int write_ptr = async->buf_write_ptr + offset; - - if (write_ptr >= async->prealloc_bufsz) - write_ptr %= async->prealloc_bufsz; + unsigned int write_ptr = async->buf_write_ptr; while (num_bytes) { unsigned int block_size; @@ -526,7 +522,7 @@ unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, return 0; } - comedi_buf_memcpy_to(s, 0, data, num_bytes); + comedi_buf_memcpy_to(s, data, num_bytes); comedi_buf_write_free(s, num_bytes); comedi_inc_scan_progress(s, num_bytes); async->events |= COMEDI_CB_BLOCK; -- cgit v1.2.3-59-g8ed1b From 0ca7f61cd67f7cd581bc6ba968072b4f7b0a2ef8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 14:36:51 -0700 Subject: staging: comedi: comedi_buf: comedi_buf_memcpy_from() remove 'offset' param This parameter is always passed as '0'. Remove the unnecessary parameter. This allows removing the unnecessary check of the read_ptr overflow. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index c60fa1aa2048..1f916072cd93 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -466,15 +466,11 @@ static void comedi_buf_memcpy_to(struct comedi_subdevice *s, } static void comedi_buf_memcpy_from(struct comedi_subdevice *s, - unsigned int offset, void *dest, unsigned int nbytes) { void *src; struct comedi_async *async = s->async; - unsigned int read_ptr = async->buf_read_ptr + offset; - - if (read_ptr >= async->prealloc_bufsz) - read_ptr %= async->prealloc_bufsz; + unsigned int read_ptr = async->buf_read_ptr; while (nbytes) { unsigned int block_size; @@ -557,7 +553,7 @@ unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, return 0; nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s)); - comedi_buf_memcpy_from(s, 0, data, nbytes); + comedi_buf_memcpy_from(s, data, nbytes); comedi_buf_read_free(s, nbytes); comedi_inc_scan_progress(s, nbytes); s->async->events |= COMEDI_CB_BLOCK; -- cgit v1.2.3-59-g8ed1b From 5438da85fc482c63f7a6f93e5b07d7c55fc77135 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:24 -0700 Subject: staging: comedi: comedi_buf: introduce comedi_buf_write_samples() Introduce a generic method to write samples to the async buffer. The number of samples is first checked against the number of samples that would fill the async buffer. The size of each sample is determined using the bytes_per_sample() helper. If all the samples will fit in the async buffer they are written to the buffer using comedi_write_array_to_buffer(). This will allow converting all the comedi drivers to use a common method to write data to the async buffer. Since comedi_write_array_to_buffer() sets the COMEDI_CB_BLOCK event after writing the data, those events can be removed from the drivers. In addition, comedi_inc_scan_progress() will automatically detect the end of scan and set the COMEDI_CB_EOS event. Those events can also be removed from the drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 31 +++++++++++++++++++++++++++++++ drivers/staging/comedi/comedidev.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 1f916072cd93..a41a414bef74 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -527,6 +527,37 @@ unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer); +/** + * comedi_buf_write_samples - write sample data to comedi buffer + * @s: comedi_subdevice struct + * @data: samples + * @nsamples: number of samples + * + * Writes nsamples to the comedi buffer associated with the subdevice, marks + * it as written and updates the acquisition scan progress. + * + * Returns the amount of data written in bytes. + */ +unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, + const void *data, unsigned int nsamples) +{ + unsigned int max_samples; + unsigned int nbytes; + + /* make sure there is enought room in the buffer for all the samples */ + max_samples = comedi_buf_write_n_available(s) / bytes_per_sample(s); + if (nsamples > max_samples) { + dev_warn(s->device->class_dev, "buffer overrun\n"); + s->async->events |= COMEDI_CB_OVERFLOW; + return 0; + } + + nbytes = nsamples * bytes_per_sample(s); + + return comedi_write_array_to_buffer(s, data, nbytes); +} +EXPORT_SYMBOL_GPL(comedi_buf_write_samples); + /** * comedi_buf_read_samples - read sample data from comedi buffer * @s: comedi_subdevice struct diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 9f4f9ef2b79a..eee4dd45a122 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -446,6 +446,8 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, const void *data, unsigned int num_bytes); +unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, + const void *data, unsigned int nsamples); unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, void *data, unsigned int nsamples); -- cgit v1.2.3-59-g8ed1b From ce8bfa275a3c9fabd3bd670ea0da0b2d1d4ba8d2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:25 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_write_long_to_buffer() The inline function 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/comedi_fc.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index fed0a54e5af6..de9331cda600 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -36,12 +36,6 @@ static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *s, return comedi_write_array_to_buffer(s, &data, sizeof(data)); }; -static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *s, - unsigned int data) -{ - return comedi_write_array_to_buffer(s, &data, sizeof(data)); -}; - /** * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source * @src: pointer to the trigger source to validate -- cgit v1.2.3-59-g8ed1b From 88f9662abbedb43ecf9ec4e03ab67500bbf66d7d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:26 -0700 Subject: staging: comedi: comedi_test: use comedi_buf_write_samples() Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the single sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 4d4358ce1710..b8fd4d24b421 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -203,7 +203,7 @@ static void waveform_ai_interrupt(unsigned long arg) devpriv->usec_current + i * devpriv->scan_period + j * devpriv->convert_period); - cfc_write_to_buffer(s, sample); + comedi_buf_write_samples(s, &sample, 1); } } -- cgit v1.2.3-59-g8ed1b From ad9eb43c93d83578674e1da78a0bd792c3a22513 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:27 -0700 Subject: staging: comedi: das800: use comedi_buf_write_samples() Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the single sample to the async buffer. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event from the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index e284d202b7e7..6013099891c0 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -511,12 +511,11 @@ static irqreturn_t das800_interrupt(int irq, void *d) /* if there are more data points to collect */ if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { - /* write data point to buffer */ - cfc_write_to_buffer(s, val & s->maxdata); + val &= s->maxdata; + comedi_buf_write_samples(s, &val, 1); devpriv->count--; } } - async->events |= COMEDI_CB_BLOCK; if (fifo_overflow) { spin_unlock_irqrestore(&dev->spinlock, irq_flags); -- cgit v1.2.3-59-g8ed1b From 7138e892a627215fad394160808d2084b51456d8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:28 -0700 Subject: staging: comedi: ni_at_a2150: use comedi_buf_write_samples() Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the single sample to the async buffer. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index f1fe9efda6df..5c17def29f8d 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -237,7 +237,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d) dpnt = devpriv->dma_buffer[i]; /* convert from 2's complement to unsigned coding */ dpnt ^= 0x8000; - cfc_write_to_buffer(s, dpnt); + comedi_buf_write_samples(s, &dpnt, 1); if (cmd->stop_src == TRIG_COUNT) { if (--devpriv->count == 0) { /* end of acquisition */ async->events |= COMEDI_CB_EOA; @@ -253,8 +253,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d) } release_dma_lock(flags); - async->events |= COMEDI_CB_BLOCK; - comedi_handle_events(dev, s); /* clear interrupt */ -- cgit v1.2.3-59-g8ed1b From 0e017a4bbee454df42d1fc983c3c9eea0981fb30 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:29 -0700 Subject: staging: comedi: s626: use comedi_buf_write_samples() Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the single sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index efd438f0ca62..6976bb098f54 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1493,8 +1493,7 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev) tempdata = s626_ai_reg_to_uint(*readaddr); readaddr++; - /* put data into read buffer */ - cfc_write_to_buffer(s, tempdata); + comedi_buf_write_samples(s, &tempdata, 1); } /* end of scan occurs */ -- cgit v1.2.3-59-g8ed1b From 8d185f52dc3d47ceda9c3f1e7f186a8adc53640c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:30 -0700 Subject: staging: comedi: ni_labpc_common: use comedi_buf_write_samples() Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the single sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 72dc78632cd5..685220369c32 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -818,7 +818,7 @@ static int labpc_drain_fifo(struct comedi_device *dev) devpriv->count--; } data = labpc_read_adc_fifo(dev); - cfc_write_to_buffer(dev->read_subdev, data); + comedi_buf_write_samples(dev->read_subdev, &data, 1); devpriv->stat1 = devpriv->read_byte(dev, STAT1_REG); } if (i == timeout) { -- cgit v1.2.3-59-g8ed1b From b9357cba10f866799516befba2bb374463ccf74d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:31 -0700 Subject: staging: comedi: ni_labpc_isadma: use comedi_buf_write_samples() Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add all the samples to the async buffer in one operation. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_isadma.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index 967202e0635e..6d386050e59d 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -91,7 +91,6 @@ void labpc_drain_dma(struct comedi_device *dev) int status; unsigned long flags; unsigned int max_points, num_points, residue, leftover; - int i; status = devpriv->stat1; @@ -122,9 +121,7 @@ void labpc_drain_dma(struct comedi_device *dev) leftover = max_points; } - /* write data to comedi buffer */ - for (i = 0; i < num_points; i++) - cfc_write_to_buffer(s, devpriv->dma_buffer[i]); + comedi_buf_write_samples(s, devpriv->dma_buffer, num_points); if (cmd->stop_src == TRIG_COUNT) devpriv->count -= num_points; @@ -133,8 +130,6 @@ void labpc_drain_dma(struct comedi_device *dev) set_dma_addr(devpriv->dma_chan, devpriv->dma_addr); set_dma_count(devpriv->dma_chan, leftover * sample_size); release_dma_lock(flags); - - async->events |= COMEDI_CB_BLOCK; } EXPORT_SYMBOL_GPL(labpc_drain_dma); -- cgit v1.2.3-59-g8ed1b From 880f582068ab8dc92c00dcea409c26e7ddaca675 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:32 -0700 Subject: staging: comedi: das1800: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will handle single and multi samples writes by determining the number of bytes to add based on the number of samples and the bytes_per_sample(). Also, remove the unnecessary COMEDI_CB_BLOCK event. comedi_buf_write_samples() will automatically add that event after adding the samples to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 7b0b65e883f6..246a18648223 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -488,8 +488,7 @@ static void das1800_handle_fifo_half_full(struct comedi_device *dev, numPoints = devpriv->count; insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints); munge_data(dev, devpriv->ai_buf0, numPoints); - cfc_write_array_to_buffer(s, devpriv->ai_buf0, - numPoints * sizeof(devpriv->ai_buf0[0])); + comedi_buf_write_samples(s, devpriv->ai_buf0, numPoints); if (cmd->stop_src == TRIG_COUNT) devpriv->count -= numPoints; } @@ -512,7 +511,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev, if (!unipolar) ; dpnt = munge_bipolar_sample(dev, dpnt); - cfc_write_to_buffer(s, dpnt); + comedi_buf_write_samples(s, &dpnt, 1); if (cmd->stop_src == TRIG_COUNT) devpriv->count--; } @@ -543,7 +542,7 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, num_samples = devpriv->count; munge_data(dev, buffer, num_samples); - cfc_write_array_to_buffer(s, buffer, num_bytes); + comedi_buf_write_samples(s, buffer, num_samples); if (cmd->stop_src == TRIG_COUNT) devpriv->count -= num_samples; } @@ -649,7 +648,6 @@ static void das1800_ai_handler(struct comedi_device *dev) das1800_handle_fifo_not_empty(dev, s); } - async->events |= COMEDI_CB_BLOCK; /* if the card's fifo has overflowed */ if (status & OVF) { /* clear OVF interrupt bit */ -- cgit v1.2.3-59-g8ed1b From 8d47c085e855da6ce24fa7d9fe3cbb2868f3d8b2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:33 -0700 Subject: staging: comedi: cb_pcidas: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will handle single and multi samples writes by determining the number of bytes to add based on the number of samples and the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index a0d462fecf20..53afae093c4c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1359,8 +1359,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) } insw(devpriv->adc_fifo + ADCDATA, devpriv->ai_buffer, num_samples); - cfc_write_array_to_buffer(s, devpriv->ai_buffer, - num_samples * sizeof(short)); + comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples); devpriv->count -= num_samples; if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) async->events |= COMEDI_CB_EOA; @@ -1372,11 +1371,14 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) /* else if fifo not empty */ } else if (status & (ADNEI | EOBI)) { for (i = 0; i < timeout; i++) { + unsigned short val; + /* break if fifo is empty */ if ((ADNE & inw(devpriv->control_status + INT_ADCFIFO)) == 0) break; - cfc_write_to_buffer(s, inw(devpriv->adc_fifo)); + val = inw(devpriv->adc_fifo); + comedi_buf_write_samples(s, &val, 1); if (cmd->stop_src == TRIG_COUNT && --devpriv->count == 0) { /* end of acquisition */ -- cgit v1.2.3-59-g8ed1b From 28e8c8984c95202cf09ee3d27becf4d1494350ee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:34 -0700 Subject: staging: comedi: adl_pci9118: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. The number of bytes to add is determined automatically based on the number of samples and the bytes_per_sample(). Change the return type of move_block_from_dma() to void and remove the unnecessary check of the return value of comedi_buf_write_samples(). The callers don't check the return and it's really not necessary. If comedi_buf_write_samples() fails to allocate enough space in the async buffer to add all the samples it sets the COMEDI_CB_OVERFLOW event. This will cause the async command to (*cancel) when the events are handled. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 7b1720f8fb30..cb2c48522efd 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -472,26 +472,21 @@ static unsigned int defragment_dma_buffer(struct comedi_device *dev, return j; } -static int move_block_from_dma(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned short *dma_buffer, - unsigned int num_samples) +static void move_block_from_dma(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned short *dma_buffer, + unsigned int num_samples) { struct pci9118_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int num_bytes; num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples); devpriv->ai_act_scan += (s->async->cur_chan + num_samples) / cmd->scan_end_arg; s->async->cur_chan += num_samples; s->async->cur_chan %= cmd->scan_end_arg; - num_bytes = - cfc_write_array_to_buffer(s, dma_buffer, - num_samples * sizeof(short)); - if (num_bytes < num_samples * sizeof(short)) - return -1; - return 0; + + comedi_buf_write_samples(s, dma_buffer, num_samples); } static void pci9118_exttrg_enable(struct comedi_device *dev, bool enable) @@ -617,7 +612,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, sampl = inl(dev->iobase + PCI9118_AI_FIFO_REG); - cfc_write_to_buffer(s, sampl); + comedi_buf_write_samples(s, &sampl, 1); s->async->cur_chan++; if (s->async->cur_chan >= cmd->scan_end_arg) { /* one scan done */ -- cgit v1.2.3-59-g8ed1b From 7ba38a01444ef99e6ebeeb41167082f32991514e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:35 -0700 Subject: staging: comedi: cb_pcidas64: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will handle single and multi samples writes by determining the number of bytes to add based on the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 06e846f38992..9196680581b8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2689,9 +2689,10 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) } for (i = 0; i < num_samples; i++) { - cfc_write_to_buffer(s, - readw(devpriv->main_iobase + - ADC_FIFO_REG)); + unsigned short val; + + val = readw(devpriv->main_iobase + ADC_FIFO_REG); + comedi_buf_write_samples(s, &val, 1); } } while (read_segment != write_segment); @@ -2722,11 +2723,15 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev) } for (i = 0; read_code != write_code && i < max_transfer;) { + unsigned short val; + fifo_data = readl(dev->mmio + ADC_FIFO_REG); - cfc_write_to_buffer(s, fifo_data & 0xffff); + val = fifo_data & 0xffff; + comedi_buf_write_samples(s, &val, 1); i++; if (i < max_transfer) { - cfc_write_to_buffer(s, (fifo_data >> 16) & 0xffff); + val = (fifo_data >> 16) & 0xffff; + comedi_buf_write_samples(s, &val, 1); i++; } read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) & @@ -2778,10 +2783,9 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) num_samples = devpriv->ai_count; devpriv->ai_count -= num_samples; } - cfc_write_array_to_buffer(dev->read_subdev, - devpriv->ai_buffer[devpriv-> - ai_dma_index], - num_samples * sizeof(uint16_t)); + comedi_buf_write_samples(dev->read_subdev, + devpriv->ai_buffer[devpriv->ai_dma_index], + num_samples); devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) % ai_dma_ring_count(thisboard); } -- cgit v1.2.3-59-g8ed1b From 9caba3296103f41f90f78aa482f0dfaf89a3f260 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:36 -0700 Subject: staging: comedi: ni_mio_common: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will handle single and multi sample writes by determining the number of bytes to add based on the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 63 ++++++++++++-------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8004e8ac945d..18e68cd3ac53 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1226,44 +1226,42 @@ static void ni_ai_fifo_read(struct comedi_device *dev, { struct ni_private *devpriv = dev->private; struct comedi_async *async = s->async; + u32 dl; + unsigned short data; int i; if (devpriv->is_611x) { - unsigned short data[2]; - u32 dl; - for (i = 0; i < n / 2; i++) { dl = ni_readl(dev, ADC_FIFO_Data_611x); /* This may get the hi/lo data in the wrong order */ - data[0] = (dl >> 16) & 0xffff; - data[1] = dl & 0xffff; - cfc_write_array_to_buffer(s, data, sizeof(data)); + data = (dl >> 16) & 0xffff; + comedi_buf_write_samples(s, &data, 1); + data = dl & 0xffff; + comedi_buf_write_samples(s, &data, 1); } /* Check if there's a single sample stuck in the FIFO */ if (n % 2) { dl = ni_readl(dev, ADC_FIFO_Data_611x); - data[0] = dl & 0xffff; - cfc_write_to_buffer(s, data[0]); + data = dl & 0xffff; + comedi_buf_write_samples(s, &data, 1); } } else if (devpriv->is_6143) { - unsigned short data[2]; - u32 dl; - /* This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */ for (i = 0; i < n / 2; i++) { dl = ni_readl(dev, AIFIFO_Data_6143); - data[0] = (dl >> 16) & 0xffff; - data[1] = dl & 0xffff; - cfc_write_array_to_buffer(s, data, sizeof(data)); + data = (dl >> 16) & 0xffff; + comedi_buf_write_samples(s, &data, 1); + data = dl & 0xffff; + comedi_buf_write_samples(s, &data, 1); } if (n % 2) { /* Assume there is a single sample stuck in the FIFO */ /* Get stranded sample into FIFO */ ni_writel(dev, 0x01, AIFIFO_Control_6143); dl = ni_readl(dev, AIFIFO_Data_6143); - data[0] = (dl >> 16) & 0xffff; - cfc_write_to_buffer(s, data[0]); + data = (dl >> 16) & 0xffff; + comedi_buf_write_samples(s, &data, 1); } } else { if (n > sizeof(devpriv->ai_fifo_buffer) / @@ -1277,9 +1275,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev, devpriv->ai_fifo_buffer[i] = ni_readw(dev, ADC_FIFO_Data_Register); } - cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer, - n * - sizeof(devpriv->ai_fifo_buffer[0])); + comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, n); } } @@ -1302,8 +1298,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) { struct ni_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - unsigned short data[2]; u32 dl; + unsigned short data; unsigned short fifo_empty; int i; @@ -1313,9 +1309,10 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) dl = ni_readl(dev, ADC_FIFO_Data_611x); /* This may get the hi/lo data in the wrong order */ - data[0] = (dl >> 16); - data[1] = (dl & 0xffff); - cfc_write_array_to_buffer(s, data, sizeof(data)); + data = dl >> 16; + comedi_buf_write_samples(s, &data, 1); + data = dl & 0xffff; + comedi_buf_write_samples(s, &data, 1); } } else if (devpriv->is_6143) { i = 0; @@ -1323,9 +1320,10 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) dl = ni_readl(dev, AIFIFO_Data_6143); /* This may get the hi/lo data in the wrong order */ - data[0] = (dl >> 16); - data[1] = (dl & 0xffff); - cfc_write_array_to_buffer(s, data, sizeof(data)); + data = dl >> 16; + comedi_buf_write_samples(s, &data, 1); + data = dl & 0xffff; + comedi_buf_write_samples(s, &data, 1); i += 2; } /* Check if stranded sample is present */ @@ -1333,8 +1331,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) /* Get stranded sample into FIFO */ ni_writel(dev, 0x01, AIFIFO_Control_6143); dl = ni_readl(dev, AIFIFO_Data_6143); - data[0] = (dl >> 16) & 0xffff; - cfc_write_to_buffer(s, data[0]); + data = (dl >> 16) & 0xffff; + comedi_buf_write_samples(s, &data, 1); } } else { @@ -1353,10 +1351,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) devpriv->ai_fifo_buffer[i] = ni_readw(dev, ADC_FIFO_Data_Register); } - cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer, - i * - sizeof(devpriv-> - ai_fifo_buffer[0])); + comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, i); } } } @@ -1375,7 +1370,7 @@ static void get_last_sample_611x(struct comedi_device *dev) if (ni_readb(dev, XXX_Status) & 0x80) { dl = ni_readl(dev, ADC_FIFO_Data_611x); data = (dl & 0xffff); - cfc_write_to_buffer(s, data); + comedi_buf_write_samples(s, &data, 1); } } @@ -1397,7 +1392,7 @@ static void get_last_sample_6143(struct comedi_device *dev) /* This may get the hi/lo data in the wrong order */ data = (dl >> 16) & 0xffff; - cfc_write_to_buffer(s, data); + comedi_buf_write_samples(s, &data, 1); } } -- cgit v1.2.3-59-g8ed1b From be591d5c42cdc25cfe8a586082a7e0e3ef0223b1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:37 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_write_to_buffer() The inline function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index de9331cda600..8ecb6bc9b60b 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -30,12 +30,6 @@ static inline unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, return comedi_write_array_to_buffer(s, data, num_bytes); } -static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *s, - unsigned short data) -{ - return comedi_write_array_to_buffer(s, &data, sizeof(data)); -}; - /** * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source * @src: pointer to the trigger source to validate -- cgit v1.2.3-59-g8ed1b From 9fdfe0fd009b261aa51c0226ca261ab039feaf62 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:38 -0700 Subject: staging: comedi: adl_pci9111: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. The number of bytes to add is determined automatically based on the number of samples and the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 076866e121a0..18f5f7fc1bc8 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -477,9 +477,8 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, devpriv->ai_bounce_buffer, samples); if (devpriv->scan_delay < 1) { - total = cfc_write_array_to_buffer(s, - devpriv->ai_bounce_buffer, - samples * sizeof(short)); + total = comedi_buf_write_samples(s, devpriv->ai_bounce_buffer, + samples); } else { unsigned int pos = 0; unsigned int to_read; @@ -492,9 +491,9 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, if (to_read > samples - pos) to_read = samples - pos; - total += cfc_write_array_to_buffer(s, + total += comedi_buf_write_samples(s, devpriv->ai_bounce_buffer + pos, - to_read * sizeof(short)); + to_read); } else { to_read = devpriv->chunk_num_samples - devpriv->chunk_counter; -- cgit v1.2.3-59-g8ed1b From 5759a14d829354aea9dd639d7dc41ac35db11ab5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:39 -0700 Subject: staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will handle the '* sizeof(foo)' calculation to determine the number of bytes to add. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 10deb72a4b37..4959fc663d85 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1172,7 +1172,7 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, s->async->cur_chan += num_samples; s->async->cur_chan %= cmd->scan_end_arg; - cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short)); + comedi_buf_write_samples(s, dma_buffer, num_samples); } /* -- cgit v1.2.3-59-g8ed1b From b45a7beb3bc3c43e6abea5b3da9c8df8377540e8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:40 -0700 Subject: staging: comedi: das16m1: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. The number of bytes to add is determined automatically based on the number of samples and the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index f98bcbe0d72a..54ccffca8497 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -442,8 +442,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) num_samples = FIFO_SIZE; insw(dev->iobase, devpriv->ai_buffer, num_samples); munge_sample_array(devpriv->ai_buffer, num_samples); - cfc_write_array_to_buffer(s, devpriv->ai_buffer, - num_samples * sizeof(short)); + comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples); devpriv->adc_count += num_samples; if (cmd->stop_src == TRIG_COUNT) { -- cgit v1.2.3-59-g8ed1b From 2e7b65e4bbe3b35ece1b8c8179a77071be042c38 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:41 -0700 Subject: staging: comedi: das16: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will determining the number of bytes to add based on the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 5d47d0a1d45f..aa9e3e10d59d 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -541,6 +541,7 @@ static void das16_interrupt(struct comedi_device *dev) struct comedi_cmd *cmd = &async->cmd; unsigned long spin_flags; unsigned long dma_flags; + unsigned int nsamples; int num_bytes, residue; int buffer_index; @@ -583,8 +584,9 @@ static void das16_interrupt(struct comedi_device *dev) spin_unlock_irqrestore(&dev->spinlock, spin_flags); - cfc_write_array_to_buffer(s, - devpriv->dma_buffer[buffer_index], num_bytes); + nsamples = num_bytes / bytes_per_sample(s); + comedi_buf_write_samples(s, devpriv->dma_buffer[buffer_index], + nsamples); comedi_handle_events(dev, s); } -- cgit v1.2.3-59-g8ed1b From d4c2acd233191fe67fddac7bf74e93ddb12bc1f7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:42 -0700 Subject: staging: comedi: dt282x: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will determining the number of bytes to add based on the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 88b56104d4e7..1d9fa371d03c 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -491,6 +491,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev, int cur_dma = devpriv->current_dma_index; void *ptr = devpriv->dma[cur_dma].buf; int size = devpriv->dma[cur_dma].size; + unsigned int nsamples = size / bytes_per_sample(s); int ret; outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE, @@ -501,13 +502,11 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev, devpriv->current_dma_index = 1 - cur_dma; dt282x_munge(dev, s, ptr, size); - ret = cfc_write_array_to_buffer(s, ptr, size); - if (ret != size) { - s->async->events |= COMEDI_CB_OVERFLOW; + ret = comedi_buf_write_samples(s, ptr, nsamples); + if (ret != size) return; - } - devpriv->nread -= size / 2; + devpriv->nread -= nsamples; if (devpriv->nread < 0) { dev_info(dev->class_dev, "nread off by one\n"); devpriv->nread = 0; @@ -566,7 +565,6 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) } #if 0 if (adcsr & DT2821_ADCSR_ADDONE) { - int ret; unsigned short data; data = inw(dev->iobase + DT2821_ADDAT_REG); @@ -574,10 +572,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) if (devpriv->ad_2scomp) data = comedi_offset_munge(s, data); - ret = comedi_buf_put(s, data); - - if (ret == 0) - s->async->events |= COMEDI_CB_OVERFLOW; + comedi_buf_write_samples(s, &data, 1); devpriv->nread--; if (!devpriv->nread) { -- cgit v1.2.3-59-g8ed1b From 60e6644399337185a860552cba977f7c47ac0723 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:43 -0700 Subject: staging: comedi: gsc_hpdi: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will handle the '* sizeof(foo)' calculation to determine the number of bytes to add. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index e99edaa3b9fa..58a99e812818 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -196,8 +196,8 @@ static void gsc_hpdi_drain_dma(struct comedi_device *dev, unsigned int channel) size = devpriv->dio_count; devpriv->dio_count -= size; } - cfc_write_array_to_buffer(s, devpriv->desc_dio_buffer[idx], - size * sizeof(uint32_t)); + comedi_buf_write_samples(s, devpriv->desc_dio_buffer[idx], + size); idx++; idx %= devpriv->num_dma_descriptors; start = le32_to_cpu(devpriv->dma_desc[idx].pci_start_addr); -- cgit v1.2.3-59-g8ed1b From 504d0239f624a8cd65a2dbbcee6230014ada43d5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:44 -0700 Subject: staging: comedi: usbduxsigma: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. That function will determining the number of bytes to add based on the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index de3fb41b1886..7b7698c3ccd2 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -245,8 +245,7 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device *dev, val &= 0x00ffffff; /* strip status byte */ val ^= 0x00800000; /* convert to unsigned */ - if (!cfc_write_array_to_buffer(s, &val, - sizeof(uint32_t))) + if (!comedi_buf_write_samples(s, &val, 1)) return; } } -- cgit v1.2.3-59-g8ed1b From f81ac41b89798a53f03e2204153598b229958660 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:45 -0700 Subject: staging: comedi: usbduxfast: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. That function will determining the number of bytes to add based on the bytes_per_sample(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 95c2ec7ed22a..70ec2f552dfc 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -249,19 +249,17 @@ static void usbduxfast_ai_handle_urb(struct comedi_device *dev, devpriv->ignore--; } else { unsigned int nbytes = urb->actual_length; + unsigned int nsamples = nbytes / bytes_per_sample(s); if (cmd->stop_src == TRIG_COUNT) { - unsigned int nsamples = nbytes / bytes_per_sample(s); - if (devpriv->ai_sample_count < nsamples) { nsamples = devpriv->ai_sample_count; async->events |= COMEDI_CB_EOA; } devpriv->ai_sample_count -= nsamples; - nbytes = nsamples * bytes_per_sample(s); } - cfc_write_array_to_buffer(s, urb->transfer_buffer, nbytes); + comedi_buf_write_samples(s, urb->transfer_buffer, nsamples); } /* if command is still running, resubmit urb for BULK transfer */ -- cgit v1.2.3-59-g8ed1b From f4add8df72e38a41886c35065c0a794f96fc057a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:46 -0700 Subject: staging: comedi: comedi_fc.h: remove cfc_write_array_to_buffer() The inline function is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h index 8ecb6bc9b60b..756be931c1a4 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.h +++ b/drivers/staging/comedi/drivers/comedi_fc.h @@ -23,13 +23,6 @@ #include "../comedidev.h" -static inline unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, - const void *data, - unsigned int num_bytes) -{ - return comedi_write_array_to_buffer(s, data, num_bytes); -} - /** * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source * @src: pointer to the trigger source to validate -- cgit v1.2.3-59-g8ed1b From 6bb45f2b0c868281311e14d9c6fb94c15eabe13a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:47 -0700 Subject: staging: comedi: addi_apci_1032: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1032.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 12601a9337f3..bf14165297b7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -258,8 +258,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d) outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG); s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff; - comedi_buf_put(s, s->state); - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); /* enable the interrupt */ -- cgit v1.2.3-59-g8ed1b From c4a58f281a0c657310541dfccf176d1f40fc1add Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:48 -0700 Subject: staging: comedi: addi_apci_1564: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index cf544ab1fc65..47b63e176c08 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -95,8 +95,7 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG) & 0xffff; - comedi_buf_put(s, s->state); - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); /* enable the interrupt */ -- cgit v1.2.3-59-g8ed1b From 6aec0f9af4c769fd104294745467fd8399548da7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:49 -0700 Subject: staging: comedi: addi_apci_3xxx: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index fe9ac2d72694..db3ee9c429ad 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -371,7 +371,7 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d) writel(status, dev->mmio + 16); val = readl(dev->mmio + 28); - comedi_buf_put(s, val); + comedi_buf_write_samples(s, &val, 1); s->async->events |= COMEDI_CB_EOA; comedi_handle_events(dev, s); -- cgit v1.2.3-59-g8ed1b From a9c3a015c12f5c83773411bf06c6daf3d60ed61d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:50 -0700 Subject: staging: comedi: adv_pci1710: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 5f387fabe1f5..c5422f376927 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -770,7 +770,8 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, break; } - comedi_buf_put(s, val & s->maxdata); + val &= s->maxdata; + comedi_buf_write_samples(s, &val, 1); s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) @@ -814,7 +815,8 @@ static int move_block_from_fifo(struct comedi_device *dev, return ret; } - comedi_buf_put(s, val & s->maxdata); + val &= s->maxdata; + comedi_buf_write_samples(s, &val, 1); s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) { -- cgit v1.2.3-59-g8ed1b From 27913fa08cf56df2c925e2dad7827be87d7644c1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:51 -0700 Subject: staging: comedi: amplc_pc236_common: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pc236_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pc236_common.c b/drivers/staging/comedi/drivers/amplc_pc236_common.c index 04c3d73ec5ba..be87172d1f3f 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236_common.c +++ b/drivers/staging/comedi/drivers/amplc_pc236_common.c @@ -135,8 +135,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d) handled = pc236_intr_check(dev); if (dev->attached && handled) { - comedi_buf_put(s, 0); - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); } return IRQ_RETVAL(handled); -- cgit v1.2.3-59-g8ed1b From 48e08de087ad53b9893cbc44d5ce88e0b8d9f025 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:52 -0700 Subject: staging: comedi: amplc_pci230: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events will set properly by the core. A dev_warn() message will also be output by the core if the buffer overflows. Remove the unnecessary events and dev_err() message in the driver. The core will also add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index f9b952f7173e..44c967f43d9a 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2053,6 +2053,7 @@ static void pci230_handle_ai(struct comedi_device *dev, unsigned int i; unsigned int todo; unsigned int fifoamount; + unsigned short val; /* Determine number of samples to read. */ if (cmd->stop_src != TRIG_COUNT) { @@ -2099,12 +2100,10 @@ static void pci230_handle_ai(struct comedi_device *dev, fifoamount = 1; } } - /* Read sample and store in Comedi's circular buffer. */ - if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) { - events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW; - dev_err(dev->class_dev, "AI buffer overflow\n"); - break; - } + + val = pci230_ai_read(dev); + comedi_buf_write_samples(s, &val, 1); + fifoamount--; devpriv->ai_scan_pos++; if (devpriv->ai_scan_pos == scanlen) { @@ -2117,9 +2116,6 @@ static void pci230_handle_ai(struct comedi_device *dev, if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) { /* End of acquisition. */ events |= COMEDI_CB_EOA; - } else { - /* More samples required, tell Comedi to block. */ - events |= COMEDI_CB_BLOCK; } async->events |= events; if (!(async->events & COMEDI_CB_CANCEL_MASK)) { -- cgit v1.2.3-59-g8ed1b From 9a84a7d2e7111aa77a9f35da5e669423d11e0d37 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:53 -0700 Subject: staging: comedi: comedi_parport: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_parport.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 0bc3844073ee..3bac903c8627 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -225,10 +225,9 @@ static irqreturn_t parport_interrupt(int irq, void *d) if (!(ctrl & PARPORT_CTRL_IRQ_ENA)) return IRQ_NONE; - comedi_buf_put(s, 0); - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); + return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 1700529b24cc99ad5c77ab765da2f290fcd0c92c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:54 -0700 Subject: staging: comedi: dmm32at: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 7e69d317b7ef..fc2c0db73999 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -501,7 +501,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d) /* invert sign bit to make range unsigned */ samp = ((msb ^ 0x0080) << 8) + lsb; - comedi_buf_put(s, samp); + comedi_buf_write_samples(s, &samp, 1); } if (devpriv->ai_scans_left != 0xffffffff) { /* TRIG_COUNT */ -- cgit v1.2.3-59-g8ed1b From aa96f6ef6f8672c6fabd461f6259af73d7f515c6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:55 -0700 Subject: staging: comedi: dt3000: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. The core will set the COMEDi_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event from the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt3000.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 6544f4482740..c2058ba39fa1 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -315,7 +315,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, for (i = 0; i < count; i++) { data = readw(dev->mmio + DPR_ADC_buffer + rear); - comedi_buf_put(s, data); + comedi_buf_write_samples(s, &data, 1); rear++; if (rear >= AI_FIFO_DEPTH) rear = 0; @@ -351,10 +351,8 @@ static irqreturn_t dt3k_interrupt(int irq, void *d) status = readw(dev->mmio + DPR_Intr_Flag); - if (status & DT3000_ADFULL) { + if (status & DT3000_ADFULL) dt3k_ai_empty_fifo(dev, s); - s->async->events |= COMEDI_CB_BLOCK; - } if (status & (DT3000_ADSWERR | DT3000_ADHWERR)) s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; -- cgit v1.2.3-59-g8ed1b From de88924f67d1bd49c742d5ba64d3275e4d6f29d3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:56 -0700 Subject: staging: comedi: me4000: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_OVERFLOW will be set by the core if the async buffer overflows. A dev_warn() message will also be output by the core if the buffer overflows. Remove the unnecessary event and the dev_err() messages in the driver. The core will also add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove these unnecessary events from the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 6516ac0c7b46..97a06749e07d 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1092,8 +1092,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) } else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA) && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA) && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) { - s->async->events |= COMEDI_CB_BLOCK; - c = ME4000_AI_FIFO_COUNT / 2; } else { dev_err(dev->class_dev, @@ -1119,7 +1117,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF; lval ^= 0x8000; - if (!comedi_buf_put(s, lval)) { + if (!comedi_buf_write_samples(s, &lval, 1)) { /* * Buffer overflow, so stop conversion * and disable all interrupts @@ -1128,11 +1126,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ); outl(tmp, dev->iobase + ME4000_AI_CTRL_REG); - - s->async->events |= COMEDI_CB_OVERFLOW; - - dev_err(dev->class_dev, "Buffer overflow\n"); - break; } } @@ -1146,7 +1139,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) & ME4000_IRQ_STATUS_BIT_SC) { - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOA; + s->async->events |= COMEDI_CB_EOA; /* * Acquisition is complete, so stop @@ -1164,11 +1157,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF; lval ^= 0x8000; - if (!comedi_buf_put(s, lval)) { - dev_err(dev->class_dev, "Buffer overflow\n"); - s->async->events |= COMEDI_CB_OVERFLOW; + if (!comedi_buf_write_samples(s, &lval, 1)) break; - } } /* Work is done, so reset the interrupt */ -- cgit v1.2.3-59-g8ed1b From 191db0902606214aed1a90396698c28044d0a753 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:57 -0700 Subject: staging: comedi: ni_6527: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_EOS will automatically be set by the core with the end-of-scan is detected. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_6527.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index b35e1aeb6626..f99847f3999f 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -208,8 +208,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d) return IRQ_NONE; if (status & NI6527_STATUS_EDGE) { - comedi_buf_put(s, 0); - s->async->events |= COMEDI_CB_EOS; + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); } -- cgit v1.2.3-59-g8ed1b From 562de49c526117fac6c78fb1e92dd7f1f1349af6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:58 -0700 Subject: staging: comedi: ni_65xx: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_EOS will automatically be set by the core with the end-of-scan is detected. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_65xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 973f0058a1e4..bcb326e31562 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -508,9 +508,9 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d) writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT, dev->mmio + NI_65XX_CLR_REG); - comedi_buf_put(s, 0); - s->async->events |= COMEDI_CB_EOS; + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); + return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 67fdc3073b78506dc671d49a02f6f47ba7c128d9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:36:59 -0700 Subject: staging: comedi: ni_atmio16d: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_atmio16d.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 24f8bca9ba05..2bac69339202 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -217,10 +217,12 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; + unsigned short val; - comedi_buf_put(s, inw(dev->iobase + AD_FIFO_REG)); - + val = inw(dev->iobase + AD_FIFO_REG); + comedi_buf_write_samples(s, &val, 1); comedi_handle_events(dev, s); + return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 1f44c034de2e1591f4fad38c685dd167e1da7062 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:00 -0700 Subject: staging: comedi: pcl711: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events will set properly by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index b6e7f342935d..48a79b8221fc 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -213,14 +213,12 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); - if (comedi_buf_put(s, data) == 0) { - s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; - } else { - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + if (comedi_buf_write_samples(s, &data, 1)) { if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig)) s->async->events |= COMEDI_CB_EOA; } comedi_handle_events(dev, s); + return IRQ_HANDLED; } -- cgit v1.2.3-59-g8ed1b From 778d695e67ac836130694942026d686995e2ddaa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:01 -0700 Subject: staging: comedi: pcl726: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events will set properly by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl726.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index be43cdaf9479..a1ac567fb192 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -235,8 +235,7 @@ static irqreturn_t pcl726_interrupt(int irq, void *d) if (devpriv->cmd_running) { pcl726_intr_cancel(dev, s); - comedi_buf_put(s, 0); - s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); + comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); } -- cgit v1.2.3-59-g8ed1b From 76cb501924258b222317d15ccd7df8feb057e593 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:02 -0700 Subject: staging: comedi: pcl812: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the nnecessary event in the driver. 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, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 72ae48f4d256..eef646253bf9 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -844,8 +844,6 @@ static bool pcl812_ai_next_chan(struct comedi_device *dev, struct pcl812_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - s->async->events |= COMEDI_CB_BLOCK; - s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; @@ -868,6 +866,7 @@ static void pcl812_handle_eoc(struct comedi_device *dev, { struct comedi_cmd *cmd = &s->async->cmd; unsigned int next_chan; + unsigned short val; if (pcl812_ai_eoc(dev, s, NULL, 0)) { dev_dbg(dev->class_dev, "A/D cmd IRQ without DRDY!\n"); @@ -875,7 +874,8 @@ static void pcl812_handle_eoc(struct comedi_device *dev, return; } - comedi_buf_put(s, pcl812_ai_get_sample(dev, s)); + val = pcl812_ai_get_sample(dev, s); + comedi_buf_write_samples(s, &val, 1); /* Set up next channel. Added by abbotti 2010-01-20, but untested. */ next_chan = s->async->cur_chan + 1; @@ -893,9 +893,11 @@ static void transfer_from_dma_buf(struct comedi_device *dev, unsigned int bufptr, unsigned int len) { unsigned int i; + unsigned short val; for (i = len; i; i--) { - comedi_buf_put(s, ptr[bufptr++]); + val = ptr[bufptr++]; + comedi_buf_write_samples(s, &val, 1); if (!pcl812_ai_next_chan(dev, s)) break; -- cgit v1.2.3-59-g8ed1b From c0491d4eb4b19721331f6986edfd106ce975f63d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:03 -0700 Subject: staging: comedi: pcl816: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. 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, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 65cbafb85698..a471c3df12b4 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -289,8 +289,6 @@ static bool pcl816_ai_next_chan(struct comedi_device *dev, struct pcl816_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - s->async->events |= COMEDI_CB_BLOCK; - s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) { s->async->cur_chan = 0; @@ -313,10 +311,12 @@ static void transfer_from_dma_buf(struct comedi_device *dev, unsigned short *ptr, unsigned int bufptr, unsigned int len) { + unsigned short val; int i; for (i = 0; i < len; i++) { - comedi_buf_put(s, ptr[bufptr++]); + val = ptr[bufptr++]; + comedi_buf_write_samples(s, &val, 1); if (!pcl816_ai_next_chan(dev, s)) return; -- cgit v1.2.3-59-g8ed1b From edf4537bcbf53bb6297678431da12b766fe16610 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:04 -0700 Subject: staging: comedi: pcl818: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. 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, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 9921e1fa7515..e6d897bf5714 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -521,8 +521,6 @@ static bool pcl818_ai_next_chan(struct comedi_device *dev, struct pcl818_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - s->async->events |= COMEDI_CB_BLOCK; - devpriv->act_chanlist_pos++; if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len) devpriv->act_chanlist_pos = 0; @@ -560,7 +558,7 @@ static void pcl818_handle_eoc(struct comedi_device *dev, if (pcl818_ai_dropout(dev, s, chan)) return; - comedi_buf_put(s, val); + comedi_buf_write_samples(s, &val, 1); pcl818_ai_next_chan(dev, s); } @@ -589,7 +587,7 @@ static void pcl818_handle_dma(struct comedi_device *dev, if (pcl818_ai_dropout(dev, s, chan)) break; - comedi_buf_put(s, val); + comedi_buf_write_samples(s, &val, 1); if (!pcl818_ai_next_chan(dev, s)) break; @@ -630,7 +628,7 @@ static void pcl818_handle_fifo(struct comedi_device *dev, if (pcl818_ai_dropout(dev, s, chan)) break; - comedi_buf_put(s, val); + comedi_buf_write_samples(s, &val, 1); if (!pcl818_ai_next_chan(dev, s)) break; -- cgit v1.2.3-59-g8ed1b From a4a68fe2a264778d1452b64964ebf65670ef774d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:05 -0700 Subject: staging: comedi: quatech_daqp_cs: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. The core will add the COMEDI_CB_BLOCK event when data is written to the async buffer. Remove the unnecessary event in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 21e99fdf28ad..f6c678eef8d5 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -221,7 +221,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) data |= inb(dev->iobase + DAQP_FIFO) << 8; data ^= 0x8000; - comedi_buf_put(s, data); + comedi_buf_write_samples(s, &data, 1); /* If there's a limit, decrement it * and stop conversion if zero @@ -245,8 +245,6 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; } - s->async->events |= COMEDI_CB_BLOCK; - comedi_handle_events(dev, s); } return IRQ_HANDLED; -- cgit v1.2.3-59-g8ed1b From 5023a4bb10f5372a8a9d2429d1dcb32b4ed79b80 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:06 -0700 Subject: staging: comedi: rtd520: use comedi_buf_write_samples() For aesthetics, use comedi_buf_write_samples() to add the sample to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 1a62e8f249ae..888238e26073 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -623,7 +623,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, d = comedi_offset_munge(s, d); d &= s->maxdata; - if (!comedi_buf_put(s, d)) + if (!comedi_buf_write_samples(s, &d, 1)) return -1; if (devpriv->ai_count > 0) /* < 0, means read forever */ -- cgit v1.2.3-59-g8ed1b From 290d028e0478c5020d69875d817a8b529439874e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:07 -0700 Subject: staging: comedi: usbdux: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 53f1e218d0d9..579e6bce529d 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -282,10 +282,9 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev, val ^= ((s->maxdata + 1) >> 1); /* transfer data */ - if (!comedi_buf_put(s, val)) + if (!comedi_buf_write_samples(s, &val, 1)) return; } - async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; } /* if command is still running, resubmit urb */ -- cgit v1.2.3-59-g8ed1b From 435efc8a43330d957cf6e8b79f8e98317668a895 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:08 -0700 Subject: staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the samples to the async buffer. The COMEDI_CB_EOS and COMEDI_CB_OVERFLOW events will be automatically handled by the core. Remove the unecessary handling in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 4959fc663d85..975ee5fc93dc 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1313,18 +1313,13 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - int n_chan, i; - int err = 1; - - n_chan = devpriv->ui_AiNbrofChannels; - - for (i = 0; i < n_chan; i++) - err &= comedi_buf_put(s, inw(dev->iobase + 0)); - - s->async->events |= COMEDI_CB_EOS; + unsigned short val; + int i; - if (err == 0) - s->async->events |= COMEDI_CB_OVERFLOW; + for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { + val = inw(dev->iobase + 0); + comedi_buf_write_samples(s, &val, 1); + } return 0; } -- cgit v1.2.3-59-g8ed1b From 4c704690e743200de94526938cb03cf80c5ae0c3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:10 -0700 Subject: staging: comedi: addi_apci_2032: use comedi_buf_write_samples() The dev->read_subdev used in this driver for async commands returns the full scan with each sample so it should have the SDF_PACKED subdev_flag set. Add the missing subdev_flags and use comedi_buf_write_samples() to add the sample to the async buffer. The core sets the async events appropriately. Remove the unnecessary event handling in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_2032.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index ad7529459429..7a5659fafbb3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -211,8 +211,7 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) bits |= (1 << i); } - if (comedi_buf_put(s, bits)) { - s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; + if (comedi_buf_write_samples(s, &bits, 1)) { if (cmd->stop_src == TRIG_COUNT && subpriv->stop_count > 0) { subpriv->stop_count--; @@ -221,8 +220,6 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) s->async->events |= COMEDI_CB_EOA; } } - } else { - s->async->events |= COMEDI_CB_OVERFLOW; } } @@ -299,7 +296,7 @@ static int apci2032_auto_attach(struct comedi_device *dev, return -ENOMEM; spin_lock_init(&subpriv->spinlock); s->private = subpriv; - s->subdev_flags = SDF_READABLE | SDF_CMD_READ; + s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_PACKED; s->len_chanlist = 2; s->do_cmdtest = apci2032_int_cmdtest; s->do_cmd = apci2032_int_cmd; -- cgit v1.2.3-59-g8ed1b From 2a07616cd9d5482c8388b8c4762b51f7ec02ba42 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:11 -0700 Subject: staging: comedi: amplc_dio200_common: use comedi_buf_write_samples() The dev->read_subdev used in this driver for async commands returns the full scan with each sample so it should have the SDF_PACKED subdev_flag set. Add the missing subdev_flags and use comedi_buf_write_samples() to add the sample to the async buffer. The async events will set properly by the core. A dev_warn() message will also be output by the core if the buffer overflows. Remove the unnecessary events and dev_err() message in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 944d454b7a37..c306226790bf 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -267,14 +267,8 @@ static void dio200_read_scan_intr(struct comedi_device *dev, if (triggered & (1U << ch)) val |= (1U << n); } - /* Write the scan to the buffer. */ - if (comedi_buf_put(s, val)) { - s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); - } else { - /* Error! Stop acquisition. */ - s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW; - dev_err(dev->class_dev, "buffer overflow\n"); - } + + comedi_buf_write_samples(s, &val, 1); /* Check for end of acquisition. */ if (cmd->stop_src == TRIG_COUNT) { @@ -463,7 +457,7 @@ static int dio200_subdev_intr_init(struct comedi_device *dev, dio200_write8(dev, subpriv->ofs, 0); s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_CMD_READ; + s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_PACKED; if (board->has_int_sce) { s->n_chan = DIO200_MAX_ISNS; s->len_chanlist = DIO200_MAX_ISNS; -- cgit v1.2.3-59-g8ed1b From dbe81a93f499345499d7f06ba2893af7cc881053 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:12 -0700 Subject: staging: comedi: ni_pcidio: use comedi_buf_write_samples() Use comedi_buf_write_samples() to add the sample to the async buffer. The 32-bit sample size is automatically determined due to the subddev_flag SDF_LSAMPL. The async event COMEDI_CB_BLOCK will be automatically set by the core. Remove the unnecessary event in the driver. This driver also has the SDF_PACKED subdev_flag set so the core will automatically set the COMEDI_CB_EOS event after adding the sample. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_pcidio.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 0bb776366264..db7e8aac67b5 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -384,11 +384,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d) struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; struct mite_struct *mite = devpriv->mite; - - /* int i, j; */ - unsigned int auxdata = 0; - unsigned short data1 = 0; - unsigned short data2 = 0; + unsigned int auxdata; int flags; int status; int work = 0; @@ -451,13 +447,9 @@ static irqreturn_t nidio_interrupt(int irq, void *d) goto out; } auxdata = readl(dev->mmio + Group_1_FIFO); - data1 = auxdata & 0xffff; - data2 = (auxdata & 0xffff0000) >> 16; - comedi_buf_put(s, data1); - comedi_buf_put(s, data2); + comedi_buf_write_samples(s, &auxdata, 1); flags = readb(dev->mmio + Group_1_Flags); } - async->events |= COMEDI_CB_BLOCK; } if (flags & CountExpired) { -- cgit v1.2.3-59-g8ed1b From ff5eb046cf43726f961644b84aa416960e0f2824 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:13 -0700 Subject: staging: comedi: pcmmio: use comedi_buf_write_samples() The dev->read_subdev used in this driver for async commands returns 32-bit samples and should have the SDF_LSAMPL subdev_flag set. It also returns the full scan with each sample so it should have the SDF_PACKED subdev_flag set. Add the missing subdev_flags and use comedi_buf_write_samples() to add the sample to the async buffer. The COMEDI_CB_BLOCK and COMEDI_CB_EOS events will be automatically handled by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 6d60d40733f4..df47967c2650 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -356,10 +356,7 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, val |= (1 << i); } - /* Write the scan to the buffer. */ - if (comedi_buf_put(s, val) && - comedi_buf_put(s, val >> 16)) - s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); + comedi_buf_write_samples(s, &val, 1); /* Check for end of acquisition. */ if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count > 0) { @@ -764,7 +761,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->insn_config = pcmmio_dio_insn_config; if (dev->irq) { dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; + s->subdev_flags |= SDF_CMD_READ | SDF_LSAMPL | SDF_PACKED; s->len_chanlist = s->n_chan; s->cancel = pcmmio_cancel; s->do_cmd = pcmmio_cmd; -- cgit v1.2.3-59-g8ed1b From 7dd1b528c1008f65653b0bdc027a90fd24ddc2eb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:14 -0700 Subject: staging: comedi: pcmuio: use comedi_buf_write_samples() The dev->read_subdev used in this driver for async commands returns 32-bit samples and should have the SDF_LSAMPL subdev_flag set. It also returns the full scan with each sample so it should have the SDF_PACKED subdev_flag set. Add the missing subdev_flags and use comedi_buf_write_samples() to add the sample to the async buffer. The COMEDI_CB_BLOCK and COMEDI_CB_EOS events will be automatically handled by the core. Remove the unnecessary events in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmuio.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 28e659889e4f..18c2ac28e34a 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -336,10 +336,7 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, val |= (1 << i); } - /* Write the scan to the buffer. */ - if (comedi_buf_put(s, val) && - comedi_buf_put(s, val >> 16)) - s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); + comedi_buf_write_samples(s, &val, 1); /* Check for end of acquisition. */ if (cmd->stop_src == TRIG_COUNT) { @@ -604,7 +601,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) if ((i == 0 && dev->irq) || (i == 2 && devpriv->irq2)) { /* setup the interrupt subdevice */ dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; + s->subdev_flags |= SDF_CMD_READ | SDF_LSAMPL | + SDF_PACKED; s->len_chanlist = s->n_chan; s->cancel = pcmuio_cancel; s->do_cmd = pcmuio_cmd; -- cgit v1.2.3-59-g8ed1b From 0ce64e65177e9ddf22e375f0ccbcbfb59cfd6841 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:15 -0700 Subject: staging: comedi: comedi_buf: remove comedi_buf_put() All comedi drivers now use comedi_buf_write_samples() to add the samples to the async buffer. Remove this unused function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 15 --------------- drivers/staging/comedi/comedidev.h | 2 -- 2 files changed, 17 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index a41a414bef74..f4b75d177d7f 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -427,21 +427,6 @@ unsigned int comedi_buf_read_free(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_buf_read_free); -int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) -{ - struct comedi_async *async = s->async; - unsigned int n = __comedi_buf_write_alloc(s, sizeof(short), 1); - - if (n < sizeof(short)) { - async->events |= COMEDI_CB_ERROR; - return 0; - } - *(unsigned short *)(async->prealloc_buf + async->buf_write_ptr) = x; - comedi_buf_write_free(s, sizeof(short)); - return 1; -} -EXPORT_SYMBOL_GPL(comedi_buf_put); - static void comedi_buf_memcpy_to(struct comedi_subdevice *s, const void *data, unsigned int num_bytes) { diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index eee4dd45a122..d60b83c26a28 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -441,8 +441,6 @@ unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s); unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); -int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); - unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, const void *data, unsigned int num_bytes); -- cgit v1.2.3-59-g8ed1b From 8f90726196b60e94e744b58e004064b84ac2d63d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:16 -0700 Subject: staging: comedi: comedi_buf: don't export comedi_write_array_to_buffer() All the comedi drivers have been converted to use comedi_buf_write_samples(). This function is now only used internally by comedi_buf. Remvoe the export. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 19 +++---------------- drivers/staging/comedi/comedidev.h | 3 --- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index f4b75d177d7f..c3152d89e608 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -474,21 +474,9 @@ static void comedi_buf_memcpy_from(struct comedi_subdevice *s, } } -/** - * comedi_write_array_to_buffer - write data to comedi buffer - * @s: comedi_subdevice struct - * @data: destination - * @num_bytes: number of bytes to write - * - * Writes up to num_bytes bytes of data to the comedi buffer associated with - * the subdevice, marks it as written and updates the acquisition scan - * progress. - * - * Returns the amount of data written in bytes. - */ -unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, - const void *data, - unsigned int num_bytes) +static unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, + const void *data, + unsigned int num_bytes) { struct comedi_async *async = s->async; unsigned int retval; @@ -510,7 +498,6 @@ unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, return num_bytes; } -EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer); /** * comedi_buf_write_samples - write sample data to comedi buffer diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d60b83c26a28..f970a8f95cee 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -441,9 +441,6 @@ unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s); unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); -unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, - const void *data, - unsigned int num_bytes); unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, const void *data, unsigned int nsamples); unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, -- cgit v1.2.3-59-g8ed1b From e19a3c97242825d7426758bad9e293068adf16ec Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:17 -0700 Subject: staging: comedi: comedi_buf: absorb comedi_write_array_to_buffer() This function is only called by comedi_buf_write_samples(). Absorb it. The buffer overflow was already checked so the overflow check of comedi_buf_write_alloc() can be removed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index c3152d89e608..23e3bd175caa 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -474,31 +474,6 @@ static void comedi_buf_memcpy_from(struct comedi_subdevice *s, } } -static unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s, - const void *data, - unsigned int num_bytes) -{ - struct comedi_async *async = s->async; - unsigned int retval; - - if (num_bytes == 0) - return 0; - - retval = comedi_buf_write_alloc(s, num_bytes); - if (retval != num_bytes) { - dev_warn(s->device->class_dev, "buffer overrun\n"); - async->events |= COMEDI_CB_OVERFLOW; - return 0; - } - - comedi_buf_memcpy_to(s, data, num_bytes); - comedi_buf_write_free(s, num_bytes); - comedi_inc_scan_progress(s, num_bytes); - async->events |= COMEDI_CB_BLOCK; - - return num_bytes; -} - /** * comedi_buf_write_samples - write sample data to comedi buffer * @s: comedi_subdevice struct @@ -524,9 +499,16 @@ unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, return 0; } - nbytes = nsamples * bytes_per_sample(s); + if (nsamples == 0) + return 0; - return comedi_write_array_to_buffer(s, data, nbytes); + nbytes = comedi_buf_write_alloc(s, nsamples * bytes_per_sample(s)); + comedi_buf_memcpy_to(s, data, nbytes); + comedi_buf_write_free(s, nbytes); + comedi_inc_scan_progress(s, nbytes); + s->async->events |= COMEDI_CB_BLOCK; + + return nbytes; } EXPORT_SYMBOL_GPL(comedi_buf_write_samples); -- cgit v1.2.3-59-g8ed1b From 0cf5efaa4bca230c7b733694932a4355d94dc5e0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 22 Oct 2014 15:37:18 -0700 Subject: staging: comedi: comedi_buf: absorb __comedi_buf_write_alloc() This function is only called by comedi_buf_write_alloc(). Absorb it and remove the unused 'strict' parameter. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 23e3bd175caa..6dd87cb2a8af 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -252,15 +252,15 @@ static unsigned int comedi_buf_write_n_available(struct comedi_subdevice *s) return free_end - async->buf_write_alloc_count; } -static unsigned int __comedi_buf_write_alloc(struct comedi_subdevice *s, - unsigned int nbytes, - int strict) +/* allocates chunk for the writer from free buffer space */ +unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, + unsigned int nbytes) { struct comedi_async *async = s->async; unsigned int available = comedi_buf_write_n_available(s); if (nbytes > available) - nbytes = strict ? 0 : available; + nbytes = available; async->buf_write_alloc_count += nbytes; @@ -272,13 +272,6 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_subdevice *s, return nbytes; } - -/* allocates chunk for the writer from free buffer space */ -unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, - unsigned int nbytes) -{ - return __comedi_buf_write_alloc(s, nbytes, 0); -} EXPORT_SYMBOL_GPL(comedi_buf_write_alloc); /* -- cgit v1.2.3-59-g8ed1b From ac584af599452748187cf6d7865b1607c54ee443 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 23 Oct 2014 12:19:34 -0700 Subject: staging: comedi: me4000: fix firmware downloading Convert this driver to use comedi_load_firmware() to download the firmware to the board. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 93 ++++++++++++++------------------- 1 file changed, 40 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 97a06749e07d..b5115d8d6170 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -44,8 +44,6 @@ broken. #include #include #include -#include -#include #include "../comedidev.h" @@ -53,10 +51,7 @@ broken. #include "8253.h" #include "plx9052.h" -#if 0 -/* file removed due to GPL incompatibility */ -#include "me4000_fw.h" -#endif +#define ME4000_FIRMWARE "me4000_firmware.bin" /* * ME4000 Register map and bit defines @@ -333,27 +328,20 @@ static const struct comedi_lrange me4000_ai_range = { } }; -#define FIRMWARE_NOT_AVAILABLE 1 -#if FIRMWARE_NOT_AVAILABLE -extern unsigned char *xilinx_firm; -#endif - -static int xilinx_download(struct comedi_device *dev) +static int me4000_xilinx_download(struct comedi_device *dev, + const u8 *data, size_t size, + unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct me4000_info *info = dev->private; unsigned long xilinx_iobase = pci_resource_start(pcidev, 5); - u32 value = 0; - wait_queue_head_t queue; - int idx = 0; - int size = 0; - unsigned int intcsr; + unsigned int file_length; + unsigned int val; + unsigned int i; if (!xilinx_iobase) return -ENODEV; - init_waitqueue_head(&queue); - /* * Set PLX local interrupt 2 polarity to high. * Interrupt is thrown by init pin of xilinx. @@ -361,61 +349,58 @@ static int xilinx_download(struct comedi_device *dev) outl(PLX9052_INTCSR_LI2POL, info->plx_regbase + PLX9052_INTCSR); /* Set /CS and /WRITE of the Xilinx */ - value = inl(info->plx_regbase + PLX9052_CNTRL); - value |= PLX9052_CNTRL_UIO2_DATA; - outl(value, info->plx_regbase + PLX9052_CNTRL); + val = inl(info->plx_regbase + PLX9052_CNTRL); + val |= PLX9052_CNTRL_UIO2_DATA; + outl(val, info->plx_regbase + PLX9052_CNTRL); /* Init Xilinx with CS1 */ inb(xilinx_iobase + 0xC8); /* Wait until /INIT pin is set */ udelay(20); - intcsr = inl(info->plx_regbase + PLX9052_INTCSR); - if (!(intcsr & PLX9052_INTCSR_LI2STAT)) { + val = inl(info->plx_regbase + PLX9052_INTCSR); + if (!(val & PLX9052_INTCSR_LI2STAT)) { dev_err(dev->class_dev, "Can't init Xilinx\n"); return -EIO; } /* Reset /CS and /WRITE of the Xilinx */ - value = inl(info->plx_regbase + PLX9052_CNTRL); - value &= ~PLX9052_CNTRL_UIO2_DATA; - outl(value, info->plx_regbase + PLX9052_CNTRL); - if (FIRMWARE_NOT_AVAILABLE) { - dev_err(dev->class_dev, - "xilinx firmware unavailable due to licensing, aborting"); - return -EIO; - } else { - /* Download Xilinx firmware */ - size = (xilinx_firm[0] << 24) + (xilinx_firm[1] << 16) + - (xilinx_firm[2] << 8) + xilinx_firm[3]; - udelay(10); + val = inl(info->plx_regbase + PLX9052_CNTRL); + val &= ~PLX9052_CNTRL_UIO2_DATA; + outl(val, info->plx_regbase + PLX9052_CNTRL); - for (idx = 0; idx < size; idx++) { - outb(xilinx_firm[16 + idx], xilinx_iobase); - udelay(10); + /* Download Xilinx firmware */ + file_length = (((unsigned int)data[0] & 0xff) << 24) + + (((unsigned int)data[1] & 0xff) << 16) + + (((unsigned int)data[2] & 0xff) << 8) + + ((unsigned int)data[3] & 0xff); + udelay(10); - /* Check if BUSY flag is low */ - if (inl(info->plx_regbase + PLX9052_CNTRL) & PLX9052_CNTRL_UIO1_DATA) { - dev_err(dev->class_dev, - "Xilinx is still busy (idx = %d)\n", - idx); - return -EIO; - } + for (i = 0; i < file_length; i++) { + outb(data[16 + i], xilinx_iobase); + udelay(10); + + /* Check if BUSY flag is low */ + val = inl(info->plx_regbase + PLX9052_CNTRL); + if (val & PLX9052_CNTRL_UIO1_DATA) { + dev_err(dev->class_dev, + "Xilinx is still busy (i = %d)\n", i); + return -EIO; } } /* If done flag is high download was successful */ - if (inl(info->plx_regbase + PLX9052_CNTRL) & PLX9052_CNTRL_UIO0_DATA) { - } else { + val = inl(info->plx_regbase + PLX9052_CNTRL); + if (!(val & PLX9052_CNTRL_UIO0_DATA)) { dev_err(dev->class_dev, "DONE flag is not set\n"); dev_err(dev->class_dev, "Download not successful\n"); return -EIO; } /* Set /CS and /WRITE */ - value = inl(info->plx_regbase + PLX9052_CNTRL); - value |= PLX9052_CNTRL_UIO2_DATA; - outl(value, info->plx_regbase + PLX9052_CNTRL); + val = inl(info->plx_regbase + PLX9052_CNTRL); + val |= PLX9052_CNTRL_UIO2_DATA; + outl(val, info->plx_regbase + PLX9052_CNTRL); return 0; } @@ -1386,8 +1371,9 @@ static int me4000_auto_attach(struct comedi_device *dev, if (!info->plx_regbase || !dev->iobase || !info->timer_regbase) return -ENODEV; - result = xilinx_download(dev); - if (result) + result = comedi_load_firmware(dev, &pcidev->dev, ME4000_FIRMWARE, + me4000_xilinx_download, 0); + if (result < 0) return result; me4000_reset(dev); @@ -1550,3 +1536,4 @@ module_comedi_pci_driver(me4000_driver, me4000_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); +MODULE_FIRMWARE(ME4000_FIRMWARE); -- cgit v1.2.3-59-g8ed1b From b3ba2be24cf197cadf3614ee5203ee42ac1109a6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 24 Oct 2014 10:26:04 -0700 Subject: staging: comedi: addi_apci_1564: remove APCI1564_COUNTER[1234] defines These defines don't add any significant clarity to the driver. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 12 ++++-------- drivers/staging/comedi/drivers/addi_apci_1564.c | 8 ++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 98de96953a29..5282f468f36f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -16,10 +16,6 @@ #define ADDIDATA_TIMER 0 #define ADDIDATA_COUNTER 1 #define ADDIDATA_WATCHDOG 2 -#define APCI1564_COUNTER1 0 -#define APCI1564_COUNTER2 1 -#define APCI1564_COUNTER3 2 -#define APCI1564_COUNTER4 3 /* * devpriv->amcc_iobase Register Map @@ -97,13 +93,13 @@ static int apci1564_timer_config(struct comedi_device *dev, outl(0x0, devpriv->amcc_iobase + APCI1564_DO_IRQ_REG); outl(0x0, devpriv->amcc_iobase + APCI1564_WDOG_IRQ_REG); outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER1)); + APCI1564_COUNTER_IRQ_REG(0)); outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER2)); + APCI1564_COUNTER_IRQ_REG(1)); outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER3)); + APCI1564_COUNTER_IRQ_REG(2)); outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(APCI1564_COUNTER4)); + APCI1564_COUNTER_IRQ_REG(3)); } else { /* disable Timer interrupt */ outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 47b63e176c08..61a7b27b37a1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -65,10 +65,10 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_RELOAD_REG); /* Reset the counter registers */ - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER1)); - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER2)); - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER3)); - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(APCI1564_COUNTER4)); + outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(0)); + outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(1)); + outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(2)); + outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(3)); return 0; } -- cgit v1.2.3-59-g8ed1b From 367ff14edd97bbd0d54e5bdfeb10201cbe491d0b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 24 Oct 2014 10:26:06 -0700 Subject: staging: comedi: addi_apci_1564: board has 3 timers According to ADDI-DATA, the APCI-1564 only has 3 timers. There are some customer specific boards with 4 timers but they use out of tree drivers. Now that the timer 'channels' are handled correctly in the subdevice functions, fix the number of timer channels for the subdevice and remove the code that would access a 4th timer. Also, remove the unnecessary initialzation of the subdevice 'len_chanlist'. That member is only used by subdevices that support async commands. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 2 -- drivers/staging/comedi/drivers/addi_apci_1564.c | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 5282f468f36f..45f977236162 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -98,8 +98,6 @@ static int apci1564_timer_config(struct comedi_device *dev, APCI1564_COUNTER_IRQ_REG(1)); outl(0x0, dev->iobase + APCI1564_COUNTER_IRQ_REG(2)); - outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(3)); } else { /* disable Timer interrupt */ outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 61a7b27b37a1..b95da410a8e3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -68,7 +68,6 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(0)); outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(1)); outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(2)); - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(3)); return 0; } @@ -434,9 +433,8 @@ static int apci1564_auto_attach(struct comedi_device *dev, s = &dev->subdevices[3]; s->type = COMEDI_SUBD_TIMER; s->subdev_flags = SDF_WRITEABLE; - s->n_chan = 1; + s->n_chan = 3; s->maxdata = 0; - s->len_chanlist = 1; s->range_table = &range_digital; s->insn_write = apci1564_timer_write; s->insn_read = apci1564_timer_read; -- cgit v1.2.3-59-g8ed1b From 7885b070b83ce5c8fb42bf65047e7dd6388d7b20 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 24 Oct 2014 10:26:05 -0700 Subject: staging: comedi: addi_apci_1564: remove private data 'mode_select_register' This driver currently passes the timer channel as the data[5] element to the timer (*insn_config) function. This is stored in the private data and use in the timer (*insn_read) and (*insn_write) functions to read/write the timer. This is just wrong, comedi passes the channel number in the insn->chanspec. Use that instead and remove the private data member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 24 ++++++++++++---------- drivers/staging/comedi/drivers/addi_apci_1564.c | 1 - 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 45f977236162..ad9949c39eae 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -75,6 +75,7 @@ static int apci1564_timer_config(struct comedi_device *dev, unsigned int *data) { struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int ul_Command1 = 0; devpriv->tsk_current = current; @@ -115,19 +116,18 @@ static int apci1564_timer_config(struct comedi_device *dev, outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); } else if (data[0] == ADDIDATA_COUNTER) { devpriv->timer_select_mode = ADDIDATA_COUNTER; - devpriv->mode_select_register = data[5]; /* First Stop The Counter */ ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; /* Stop The Timer */ outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); /* Set the reload value */ outl(data[3], dev->iobase + - APCI1564_COUNTER_RELOAD_REG(data[5] - 1)); + APCI1564_COUNTER_RELOAD_REG(chan)); /* Set the mode : */ /* - Disable the hardware */ @@ -141,17 +141,17 @@ static int apci1564_timer_config(struct comedi_device *dev, (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (unsigned int) ((unsigned int) data[4] << 16UL); outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); /* Enable or Disable Interrupt */ ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1); outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); /* Set the Up/Down selection */ ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18); outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(data[5] - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -170,6 +170,7 @@ static int apci1564_timer_write(struct comedi_device *dev, unsigned int *data) { struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int ul_Command1 = 0; if (devpriv->timer_select_mode == ADDIDATA_TIMER) { @@ -189,7 +190,7 @@ static int apci1564_timer_write(struct comedi_device *dev, } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); if (data[1] == 1) { /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; @@ -202,7 +203,7 @@ static int apci1564_timer_write(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; } outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_CTRL_REG(chan)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -218,6 +219,7 @@ static int apci1564_timer_read(struct comedi_device *dev, unsigned int *data) { struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int ul_Command1 = 0; if (devpriv->timer_select_mode == ADDIDATA_TIMER) { @@ -230,10 +232,10 @@ static int apci1564_timer_read(struct comedi_device *dev, /* Read the Counter Actual Value. */ data[0] = inl(dev->iobase + - APCI1564_COUNTER_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_REG(chan)); ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_STATUS_REG(devpriv->mode_select_register - 1)); + APCI1564_COUNTER_STATUS_REG(chan)); /* Get the software trigger status */ data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index b95da410a8e3..c328230b85ec 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -37,7 +37,6 @@ struct apci1564_private { unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ unsigned char timer_select_mode; - unsigned char mode_select_register; struct task_struct *tsk_current; }; -- cgit v1.2.3-59-g8ed1b From bf33eb4b4f57d277eac611b5d331976059bcc700 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 23 Oct 2014 13:47:51 +0100 Subject: staging: comedi: introduce some sample size manipulation functions Introduce a few static inline helper functions: `comedi_bytes_per_sample(s)` is the same as the existing `bytes_per_sample(s)` and determines the size of a comedi sample in bytes. (`bytes_per_sample(s)` will be removed.) `comedi_sample_shift(s)` determines the log2 of the comedi sample size, so it can be used in bit-shift operations to multiply or divide by the sample size. `comedi_bytes_to_samples(s, nbytes)` converts a number of bytes to a number of samples (rounding down). `comedi_samples_to_bytes(s, nsamples)` converts a number of samples to a number of bytes. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 63 +++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index f970a8f95cee..d18f70203422 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -413,12 +413,67 @@ static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s, return val ^ s->maxdata ^ (s->maxdata >> 1); } -static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) +/** + * comedi_bytes_per_sample - determine subdevice sample size + * @s: comedi_subdevice struct + * + * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on + * whether the SDF_LSAMPL subdevice flag is set or not. + * + * Returns the subdevice sample size. + */ +static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice *s) { - if (subd->subdev_flags & SDF_LSAMPL) - return sizeof(unsigned int); + return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short); +} - return sizeof(short); +/* to be removed */ +static inline unsigned int bytes_per_sample(struct comedi_subdevice *s) +{ + return comedi_bytes_per_sample(s); +} + +/** + * comedi_sample_shift - determine log2 of subdevice sample size + * @s: comedi_subdevice struct + * + * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on + * whether the SDF_LSAMPL subdevice flag is set or not. The log2 of the + * sample size will be 2 or 1 and can be used as the right operand of a + * bit-shift operator to multiply or divide something by the sample size. + * + * Returns log2 of the subdevice sample size. + */ +static inline unsigned int comedi_sample_shift(struct comedi_subdevice *s) +{ + return s->subdev_flags & SDF_LSAMPL ? 2 : 1; +} + +/** + * comedi_bytes_to_samples - converts a number of bytes to a number of samples + * @s: comedi_subdevice struct + * @nbytes: number of bytes + * + * Returns the number of bytes divided by the subdevice sample size. + */ +static inline unsigned int comedi_bytes_to_samples(struct comedi_subdevice *s, + unsigned int nbytes) +{ + return nbytes >> comedi_sample_shift(s); +} + +/** + * comedi_samples_to_bytes - converts a number of samples to a number of bytes + * @s: comedi_subdevice struct + * @nsamples: number of samples + * + * Returns the number of samples multiplied by the subdevice sample size. + * Does not check for arithmetic overflow. + */ +static inline unsigned int comedi_samples_to_bytes(struct comedi_subdevice *s, + unsigned int nsamples) +{ + return nsamples << comedi_sample_shift(s); } /* -- cgit v1.2.3-59-g8ed1b From 73e0e4dfed4c5c3bd1533321c98f2dac379324f8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 28 Oct 2014 13:07:22 +0000 Subject: staging: comedi: comedi_test: fix timer lock-up Commit 240512474424 ("staging: comedi: comedi_test: use comedi_handle_events()") resulted in the timer routine `waveform_ai_interrupt()` calling `comedi_handle_events()` instead of `comedi_events()`. That had the advantage of automatically stopping the acquisition on overflow/error/end-of-acquisition conditions (by calling the comedi subdevice's "cancel" handler), but currently results in the timer routine locking when one of those conditions occur. This is because the "cancel" handler `waveform_ai_cancel()` calls `del_timer_sync()`. Fix it by adding a bit to the device private data that indicates whether the acquisition is active or not, and changing the "cancel" handler to use `del_timer()` instead of `del_timer_sync()`. The bit is set when starting the acquisition, cleared when ending the acquisition (in the "cancel" handler), and tested in the timer routine, which will do nothing if the acquisition is inactive. Also, make sure any scheduled timeout event gets cancelled when the low-level device gets "detached" from the comedi core by calling `del_timer_sync()` in the "detach" handler `waveform_detach()`. Fixes: 240512474424 ("staging: comedi: comedi_test: use comedi_handle_events()") Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index b8fd4d24b421..8c348bbf9e71 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -56,6 +56,10 @@ zero volts). #define N_CHANS 8 +enum waveform_state_bits { + WAVEFORM_AI_RUNNING = 0 +}; + /* Data unique to this driver */ struct waveform_private { struct timer_list timer; @@ -65,6 +69,7 @@ struct waveform_private { unsigned long usec_current; /* current time (mod waveform period) */ unsigned long usec_remainder; /* usec since last scan */ unsigned long ai_count; /* number of conversions remaining */ + unsigned long state_bits; unsigned int scan_period; /* scan period in usec */ unsigned int convert_period; /* conversion period in usec */ unsigned int ao_loopbacks[N_CHANS]; @@ -175,6 +180,10 @@ static void waveform_ai_interrupt(unsigned long arg) ktime_t now; bool stopping = false; + /* check command is still active */ + if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits)) + return; + now = ktime_get(); elapsed_time = ktime_to_us(ktime_sub(now, devpriv->last)); @@ -322,6 +331,10 @@ static int waveform_ai_cmd(struct comedi_device *dev, devpriv->usec_remainder = 0; devpriv->timer.expires = jiffies + 1; + /* mark command as active */ + smp_mb__before_atomic(); + set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); + smp_mb__after_atomic(); add_timer(&devpriv->timer); return 0; } @@ -331,7 +344,11 @@ static int waveform_ai_cancel(struct comedi_device *dev, { struct waveform_private *devpriv = dev->private; - del_timer_sync(&devpriv->timer); + /* mark command as no longer active */ + clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); + smp_mb__after_atomic(); + /* cannot call del_timer_sync() as may be called from timer routine */ + del_timer(&devpriv->timer); return 0; } @@ -433,7 +450,7 @@ static void waveform_detach(struct comedi_device *dev) struct waveform_private *devpriv = dev->private; if (devpriv) - waveform_ai_cancel(dev, dev->read_subdev); + del_timer_sync(&devpriv->timer); } static struct comedi_driver waveform_driver = { -- cgit v1.2.3-59-g8ed1b From 1bca2822b4420dfc1f7f40bbea5011bbf25e1113 Mon Sep 17 00:00:00 2001 From: Filipe Gonçalves Date: Sat, 11 Oct 2014 22:33:39 +0100 Subject: drivers/staging: Removed unnecessary check for LUSTRE_VERSION_CODE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Given that this code is now part of the kernel tree, the #ifdef directive comparing LUSTRE_VERSION_CODE to the kernel version is no longer needed. As a side effect, this will also remove the sparse error "directive in argument list". Signed-off-by: Filipe Gonçalves Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/layout.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 5b8337187b59..78364ec4fbf0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -980,18 +980,7 @@ EXPORT_SYMBOL(RMF_CONN); struct req_msg_field RMF_CONNECT_DATA = DEFINE_MSGF("cdata", RMF_F_NO_SIZE_CHECK /* we allow extra space for interop */, -#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 7, 50, 0) sizeof(struct obd_connect_data), -#else -/* For interoperability with 1.8 and 2.0 clients/servers. - * The RPC verification code allows larger RPC buffers, but not - * smaller buffers. Until we no longer need to keep compatibility - * with older servers/clients we can only check that the buffer - * size is at least as large as obd_connect_data_v1. That is not - * not in itself harmful, since the chance of just corrupting this - * field is low. See JIRA LU-16 for details. */ - sizeof(struct obd_connect_data_v1), -#endif lustre_swab_connect, NULL); EXPORT_SYMBOL(RMF_CONNECT_DATA); -- cgit v1.2.3-59-g8ed1b From 0237d9dc94b6e5f1e31c0db90bce6301d0884350 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 11 Oct 2014 22:46:52 -0400 Subject: staging/lustre/ptlrpc: get rid of lustre 1.8 compatible checksums Old version of lustre (1.8) calculated RPC checksums differently, but the compat code is no longer important since in-kernel version of lustre is nto compatible with 1.8 lustre servers (that are long deprecated too). Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_net.h | 5 ----- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 26 ---------------------- drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 18 --------------- 3 files changed, 49 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index d4da2431b407..36396d1c94dc 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2627,12 +2627,7 @@ __u32 lustre_msg_get_timeout(struct lustre_msg *msg); __u32 lustre_msg_get_service_time(struct lustre_msg *msg); char *lustre_msg_get_jobid(struct lustre_msg *msg); __u32 lustre_msg_get_cksum(struct lustre_msg *msg); -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) -__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18); -#else -# warning "remove checksum compatibility support for b1_8" __u32 lustre_msg_calc_cksum(struct lustre_msg *msg); -#endif void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle); void lustre_msg_set_type(struct lustre_msg *msg, __u32 type); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 50556db15f79..60552f4e9798 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -1313,43 +1313,17 @@ __u32 lustre_msg_get_cksum(struct lustre_msg *msg) } } -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) -/* - * In 1.6 and 1.8 the checksum was computed only on struct ptlrpc_body as - * it was in 1.6 (88 bytes, smaller than the full size in 1.8). It makes - * more sense to compute the checksum on the full ptlrpc_body, regardless - * of what size it is, but in order to keep interoperability with 1.8 we - * can optionally also checksum only the first 88 bytes (caller decides). */ -# define ptlrpc_body_cksum_size_compat18 88 - -__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18) -#else -# warning "remove checksum compatibility support for b1_8" __u32 lustre_msg_calc_cksum(struct lustre_msg *msg) -#endif { switch (msg->lm_magic) { case LUSTRE_MSG_MAGIC_V2: { struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) - __u32 crc; - unsigned int hsize = 4; - __u32 len = compat18 ? ptlrpc_body_cksum_size_compat18 : - lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF); - LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); - cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb, - len, NULL, 0, (unsigned char *)&crc, - &hsize); - return crc; -#else -# warning "remove checksum compatibility support for b1_8" __u32 crc; unsigned int hsize = 4; cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb, lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF), NULL, 0, (unsigned char *)&crc, &hsize); return crc; -#endif } default: CERROR("incorrect message magic: %08x\n", msg->lm_magic); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 099cec3b669f..4e132435b450 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -101,16 +101,7 @@ int null_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) if (req->rq_early) { cksums = lustre_msg_get_cksum(req->rq_repdata); -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) - if (lustre_msghdr_get_flags(req->rq_reqmsg) & - MSGHDR_CKSUM_INCOMPAT18) - cksumc = lustre_msg_calc_cksum(req->rq_repmsg, 0); - else - cksumc = lustre_msg_calc_cksum(req->rq_repmsg, 1); -#else -# warning "remove checksum compatibility support for b1_8" cksumc = lustre_msg_calc_cksum(req->rq_repmsg); -#endif if (cksumc != cksums) { CDEBUG(D_SEC, "early reply checksum mismatch: %08x != %08x\n", @@ -371,16 +362,7 @@ int null_authorize(struct ptlrpc_request *req) } else { __u32 cksum; -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) - if (lustre_msghdr_get_flags(req->rq_reqmsg) & - MSGHDR_CKSUM_INCOMPAT18) - cksum = lustre_msg_calc_cksum(rs->rs_repbuf, 0); - else - cksum = lustre_msg_calc_cksum(rs->rs_repbuf, 1); -#else -# warning "remove checksum compatibility support for b1_8" cksum = lustre_msg_calc_cksum(rs->rs_repbuf); -#endif lustre_msg_set_cksum(rs->rs_repbuf, cksum); req->rq_reply_off = 0; } -- cgit v1.2.3-59-g8ed1b From 13a7de7bbc7c43dc6c4b16b60034a926aa436277 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 11 Oct 2014 22:46:53 -0400 Subject: staging/lustre: get rid of deprecaed acl mount option code This is long since unused code, so get rid of it. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 74cd4515ac50..afb433a33d25 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -818,25 +818,6 @@ static int ll_options(char *options, int *flags) *flags &= ~tmp; goto next; } -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 5, 50, 0) - tmp = ll_set_opt("acl", s1, LL_SBI_ACL); - if (tmp) { - /* Ignore deprecated mount option. The client will - * always try to mount with ACL support, whether this - * is used depends on whether server supports it. */ - LCONSOLE_ERROR_MSG(0x152, "Ignoring deprecated " - "mount option 'acl'.\n"); - goto next; - } - tmp = ll_set_opt("noacl", s1, LL_SBI_ACL); - if (tmp) { - LCONSOLE_ERROR_MSG(0x152, "Ignoring deprecated " - "mount option 'noacl'.\n"); - goto next; - } -#else -#warning "{no}acl options have been deprecated since 1.8, please remove them" -#endif tmp = ll_set_opt("remote_client", s1, LL_SBI_RMT_CLIENT); if (tmp) { *flags |= tmp; -- cgit v1.2.3-59-g8ed1b From 0017af422bd3edf6dcedc5a87dfb973e3c462db3 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 11 Oct 2014 22:46:54 -0400 Subject: staging/lustre/quota: Get rid of compat quota code Nobody should be using any fo the old lustre 1.8 era tools anymore, so drop compatibility with those. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 58 ---------------------- .../staging/lustre/lustre/llite/llite_internal.h | 18 ------- 2 files changed, 76 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index a07e0fe06207..f9b30cfa23ec 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1693,64 +1693,6 @@ out_poll: OBD_FREE_PTR(check); return rc; } -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) - case LL_IOC_QUOTACTL_18: { - /* copy the old 1.x quota struct for internal use, then copy - * back into old format struct. For 1.8 compatibility. */ - struct if_quotactl_18 *qctl_18; - struct if_quotactl *qctl_20; - - qctl_18 = kzalloc(sizeof(*qctl_18), GFP_NOFS); - if (!qctl_18) - return -ENOMEM; - - qctl_20 = kzalloc(sizeof(*qctl_20), GFP_NOFS); - if (!qctl_20) { - rc = -ENOMEM; - goto out_quotactl_18; - } - - if (copy_from_user(qctl_18, (void *)arg, sizeof(*qctl_18))) { - rc = -ENOMEM; - goto out_quotactl_20; - } - - QCTL_COPY(qctl_20, qctl_18); - qctl_20->qc_idx = 0; - - /* XXX: dqb_valid was borrowed as a flag to mark that - * only mds quota is wanted */ - if (qctl_18->qc_cmd == Q_GETQUOTA && - qctl_18->qc_dqblk.dqb_valid) { - qctl_20->qc_valid = QC_MDTIDX; - qctl_20->qc_dqblk.dqb_valid = 0; - } else if (qctl_18->obd_uuid.uuid[0] != '\0') { - qctl_20->qc_valid = QC_UUID; - qctl_20->obd_uuid = qctl_18->obd_uuid; - } else { - qctl_20->qc_valid = QC_GENERAL; - } - - rc = quotactl_ioctl(sbi, qctl_20); - - if (rc == 0) { - QCTL_COPY(qctl_18, qctl_20); - qctl_18->obd_uuid = qctl_20->obd_uuid; - - if (copy_to_user((void *)arg, qctl_18, - sizeof(*qctl_18))) - rc = -EFAULT; - } - -out_quotactl_20: - OBD_FREE_PTR(qctl_20); -out_quotactl_18: - OBD_FREE_PTR(qctl_18); - return rc; - } -#else -#warning "remove old LL_IOC_QUOTACTL_18 compatibility code" -#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) */ case LL_IOC_QUOTACTL: { struct if_quotactl *qctl; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 36aa0fd147f2..2845aab282ea 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1509,24 +1509,6 @@ static inline void d_lustre_revalidate(struct dentry *dentry) spin_unlock(&dentry->d_lock); } -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) -/* Compatibility for old (1.8) compiled userspace quota code */ -struct if_quotactl_18 { - __u32 qc_cmd; - __u32 qc_type; - __u32 qc_id; - __u32 qc_stat; - struct obd_dqinfo qc_dqinfo; - struct obd_dqblk qc_dqblk; - char obd_type[16]; - struct obd_uuid obd_uuid; -}; -#define LL_IOC_QUOTACTL_18 _IOWR('f', 162, struct if_quotactl_18 *) -/* End compatibility for old (1.8) compiled userspace quota code */ -#else -#warning "remove old LL_IOC_QUOTACTL_18 compatibility code" -#endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) */ - enum { LL_LAYOUT_GEN_NONE = ((__u32)-2), /* layout lock was cancelled */ LL_LAYOUT_GEN_EMPTY = ((__u32)-1) /* for empty layout */ -- cgit v1.2.3-59-g8ed1b From 5a13503ecdf3ee6127b2833ed37dfc5dccb6a3dd Mon Sep 17 00:00:00 2001 From: Anh Le Date: Sun, 12 Oct 2014 16:07:10 +0700 Subject: Staging: lustre: llite: fix some sparse warnings about userspace pointer Add __user macro to the function declarations that accept userspace pointers as arguments. Signed-off-by: Anh Le Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/lprocfs_status.h | 6 +-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 56 +++++++++++++--------- .../lustre/lustre/obdclass/lprocfs_status.c | 4 +- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index ccb6cd42a67d..54c522667228 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -374,8 +374,8 @@ static inline void s2dhms(struct dhms *ts, time_t secs) #define JOBSTATS_PROCNAME_UID "procname_uid" #define JOBSTATS_NODELOCAL "nodelocal" -extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count, - int *val, int mult); +extern int lprocfs_write_frac_helper(const char __user *buffer, + unsigned long count, int *val, int mult); extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult); #if defined (CONFIG_PROC_FS) @@ -647,7 +647,7 @@ extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data); extern int lprocfs_rd_filestotal(struct seq_file *m, void *data); extern int lprocfs_rd_filesfree(struct seq_file *m, void *data); -extern int lprocfs_write_helper(const char *buffer, unsigned long count, +extern int lprocfs_write_helper(const char __user *buffer, unsigned long count, int *val); extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult); extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count, diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index f175c59dc166..4dc1bfa5c1cf 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -227,8 +227,9 @@ static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v) return lprocfs_seq_read_frac_helper(m, pages_number, mult); } -static ssize_t ll_max_readahead_mb_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_max_readahead_mb_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -269,7 +270,7 @@ static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v) } static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file, - const char *buffer, + const char __user *buffer, size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; @@ -313,7 +314,7 @@ static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused) } static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file, - const char *buffer, + const char __user *buffer, size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; @@ -469,8 +470,9 @@ static int ll_checksum_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); } -static ssize_t ll_checksum_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_checksum_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -504,8 +506,9 @@ static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk); } -static ssize_t ll_max_rw_chunk_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_max_rw_chunk_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; int rc, val; @@ -533,8 +536,8 @@ static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type) } } -static int ll_wr_track_id(const char *buffer, unsigned long count, void *data, - enum stats_track_type type) +static int ll_wr_track_id(const char __user *buffer, unsigned long count, + void *data, enum stats_track_type type) { struct super_block *sb = data; int rc, pid; @@ -556,8 +559,9 @@ static int ll_track_pid_seq_show(struct seq_file *m, void *v) return ll_rd_track_id(m, STATS_TRACK_PID); } -static ssize_t ll_track_pid_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_track_pid_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *seq = file->private_data; return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PID); @@ -569,8 +573,9 @@ static int ll_track_ppid_seq_show(struct seq_file *m, void *v) return ll_rd_track_id(m, STATS_TRACK_PPID); } -static ssize_t ll_track_ppid_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_track_ppid_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *seq = file->private_data; return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PPID); @@ -582,8 +587,9 @@ static int ll_track_gid_seq_show(struct seq_file *m, void *v) return ll_rd_track_id(m, STATS_TRACK_GID); } -static ssize_t ll_track_gid_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_track_gid_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *seq = file->private_data; return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_GID); @@ -598,8 +604,9 @@ static int ll_statahead_max_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", sbi->ll_sa_max); } -static ssize_t ll_statahead_max_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_statahead_max_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -628,8 +635,9 @@ static int ll_statahead_agl_seq_show(struct seq_file *m, void *v) sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); } -static ssize_t ll_statahead_agl_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_statahead_agl_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -672,8 +680,9 @@ static int ll_lazystatfs_seq_show(struct seq_file *m, void *v) (sbi->ll_flags & LL_SBI_LAZYSTATFS) ? 1 : 0); } -static ssize_t ll_lazystatfs_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_lazystatfs_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -787,7 +796,8 @@ static int ll_xattr_cache_seq_show(struct seq_file *m, void *v) return rc; } -static ssize_t ll_xattr_cache_seq_write(struct file *file, const char *buffer, +static ssize_t ll_xattr_cache_seq_write(struct file *file, + const char __user *buffer, size_t count, loff_t *off) { struct seq_file *seq = file->private_data; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 61e04af2464f..686bc182a9bb 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -177,7 +177,7 @@ int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, } EXPORT_SYMBOL(lprocfs_read_frac_helper); -int lprocfs_write_frac_helper(const char *buffer, unsigned long count, +int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, int *val, int mult) { char kernbuf[20], *end, *pbuf; @@ -1819,7 +1819,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, } EXPORT_SYMBOL(lprocfs_read_helper); -int lprocfs_write_helper(const char *buffer, unsigned long count, +int lprocfs_write_helper(const char __user *buffer, unsigned long count, int *val) { return lprocfs_write_frac_helper(buffer, count, val, 1); -- cgit v1.2.3-59-g8ed1b From 22e1dd69fec2f0e887103f6b0dc8e310f649c1c1 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 12 Oct 2014 17:55:33 +0200 Subject: staging: lustre: lustre: ptlrpc: sec.c: Replacing strncat with strlcat to avoid overwrite size Changed from using strncat with strlcat to avoid overwrite the max size. Take the opportunity to change a snprint to strlcpy. Signed-off-by: Rickard Strandqvist Acked-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 4ce76852e6ee..6ac8a8330c7c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -209,7 +209,7 @@ EXPORT_SYMBOL(sptlrpc_flavor2name_bulk); char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize) { - snprintf(buf, bufsize, "%s", sptlrpc_flavor2name_base(sf->sf_rpc)); + strlcpy(buf, sptlrpc_flavor2name_base(sf->sf_rpc), bufsize); /* * currently we don't support customized bulk specification for @@ -220,10 +220,9 @@ char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize) bspec[0] = '-'; sptlrpc_flavor2name_bulk(sf, &bspec[1], sizeof(bspec) - 1); - strncat(buf, bspec, bufsize); + strlcat(buf, bspec, bufsize); } - buf[bufsize - 1] = '\0'; return buf; } EXPORT_SYMBOL(sptlrpc_flavor2name); -- cgit v1.2.3-59-g8ed1b From 92a1daba3a11c027e491c4850dc35163f4a142b1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 16 Oct 2014 10:56:25 +0300 Subject: staging: lustre: silence a static checker warning Static checkers warn that if cfs_cpt_table_print() returns an error other than -EFBIG, then it would lead to a double free. This is true but cfs_cpt_table_print() only returns -EFBIG on error so it also won't happen in real life. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index bbe2c68c18a6..83d3f08a37b2 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -365,8 +365,8 @@ static int __proc_cpt_table(void *data, int write, if (rc >= 0) break; - LIBCFS_FREE(buf, len); if (rc == -EFBIG) { + LIBCFS_FREE(buf, len); len <<= 1; continue; } -- cgit v1.2.3-59-g8ed1b From 557732ad671e0a0768062c843f03b8eef5250e3a Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Mon, 20 Oct 2014 10:27:40 -0500 Subject: drivers: staging: lustre: Fix "space prohibited before that close parenthesis ')'" errors Fix checkpatch.pl "space prohibited before that close parenthesis ')'" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_capa.h | 2 +- drivers/staging/lustre/lustre/llite/dir.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 2 +- drivers/staging/lustre/lustre/obdclass/capa.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_capa.h b/drivers/staging/lustre/lustre/include/lustre_capa.h index ab6b9ea98a70..fe19534ebd8f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_capa.h +++ b/drivers/staging/lustre/lustre/include/lustre_capa.h @@ -154,7 +154,7 @@ static inline __u32 capa_expiry(struct lustre_capa *capa) } void _debug_capa(struct lustre_capa *, struct libcfs_debug_msg_data *, - const char *fmt, ... ); + const char *fmt, ...); #define DEBUG_CAPA(level, capa, fmt, args...) \ do { \ if (((level) & D_CANTMASK) != 0 || \ diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index f9b30cfa23ec..661b2cf2f804 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1384,7 +1384,7 @@ lmv_out_free: if (copy_from_user(lumv1, lumv1p, sizeof(*lumv1))) return -EFAULT; - if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) ) { + if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) { if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3))) return -EFAULT; } diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index d3f967a78138..168aafb95f25 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -709,7 +709,7 @@ static int vvp_io_fault_start(const struct lu_env *env, } - if (fio->ft_mkwrite ) { + if (fio->ft_mkwrite) { pgoff_t last_index; /* * Capture the size while holding the lli_trunc_sem from above diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index cd1abce378ea..8d80ea4833c0 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -302,7 +302,7 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ - tfm = crypto_alloc_blkcipher(alg, 0, 0 ); + tfm = crypto_alloc_blkcipher(alg, 0, 0); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); return PTR_ERR(tfm); @@ -355,7 +355,7 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ - tfm = crypto_alloc_blkcipher(alg, 0, 0 ); + tfm = crypto_alloc_blkcipher(alg, 0, 0); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); return PTR_ERR(tfm); @@ -407,7 +407,7 @@ EXPORT_SYMBOL(capa_cpy); void _debug_capa(struct lustre_capa *c, struct libcfs_debug_msg_data *msgdata, - const char *fmt, ... ) + const char *fmt, ...) { va_list args; va_start(args, fmt); -- cgit v1.2.3-59-g8ed1b From e9e2fa6958f13b511346f1c5e6b883a56b1e5c8a Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Mon, 20 Oct 2014 10:58:13 -0500 Subject: drivers: staging: lustre: Fix 'that open brace { should be on the previous line' errors Fix checkpatch.pl 'that open brace { should be on the previous line' errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 3 +-- drivers/staging/lustre/lustre/libcfs/hash.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 3822e0f3faf0..c80c76a6e181 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -1205,8 +1205,7 @@ int ldlm_pools_recalc(ldlm_side_t client) * The rest is given to greedy namespaces. */ list_for_each_entry(ns, ldlm_namespace_list(client), - ns_list_chain) - { + ns_list_chain) { if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY) continue; diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 3b67b7b6428c..32da78357c7e 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1371,8 +1371,7 @@ cfs_hash_lookup(struct cfs_hash *hs, const void *key) EXPORT_SYMBOL(cfs_hash_lookup); static void -cfs_hash_for_each_enter(struct cfs_hash *hs) -{ +cfs_hash_for_each_enter(struct cfs_hash *hs) { LASSERT(!cfs_hash_is_exiting(hs)); if (!cfs_hash_with_rehash(hs)) @@ -1397,8 +1396,7 @@ cfs_hash_for_each_enter(struct cfs_hash *hs) } static void -cfs_hash_for_each_exit(struct cfs_hash *hs) -{ +cfs_hash_for_each_exit(struct cfs_hash *hs) { int remained; int bits; @@ -1429,8 +1427,7 @@ cfs_hash_for_each_exit(struct cfs_hash *hs) */ static __u64 cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, - void *data, int remove_safe) -{ + void *data, int remove_safe) { struct hlist_node *hnode; struct hlist_node *pos; struct cfs_hash_bd bd; @@ -1523,8 +1520,7 @@ EXPORT_SYMBOL(cfs_hash_for_each); void cfs_hash_for_each_safe(struct cfs_hash *hs, - cfs_hash_for_each_cb_t func, void *data) -{ + cfs_hash_for_each_cb_t func, void *data) { cfs_hash_for_each_tight(hs, func, data, 1); } EXPORT_SYMBOL(cfs_hash_for_each_safe); @@ -1572,8 +1568,8 @@ EXPORT_SYMBOL(cfs_hash_size_get); * two cases, so iteration has to be stopped on change. */ static int -cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void *data) -{ +cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, + void *data) { struct hlist_node *hnode; struct hlist_node *tmp; struct cfs_hash_bd bd; @@ -1634,8 +1630,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func, void * int cfs_hash_for_each_nolock(struct cfs_hash *hs, - cfs_hash_for_each_cb_t func, void *data) -{ + cfs_hash_for_each_cb_t func, void *data) { if (cfs_hash_with_no_lock(hs) || cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs)) @@ -1667,8 +1662,7 @@ EXPORT_SYMBOL(cfs_hash_for_each_nolock); */ int cfs_hash_for_each_empty(struct cfs_hash *hs, - cfs_hash_for_each_cb_t func, void *data) -{ + cfs_hash_for_each_cb_t func, void *data) { unsigned i = 0; if (cfs_hash_with_no_lock(hs)) @@ -1726,8 +1720,7 @@ EXPORT_SYMBOL(cfs_hash_hlist_for_each); */ void cfs_hash_for_each_key(struct cfs_hash *hs, const void *key, - cfs_hash_for_each_cb_t func, void *data) -{ + cfs_hash_for_each_cb_t func, void *data) { struct hlist_node *hnode; struct cfs_hash_bd bds[2]; unsigned i; -- cgit v1.2.3-59-g8ed1b From 544426100b66f23cce010bd6e2b386b282a2767c Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Mon, 20 Oct 2014 11:18:12 -0500 Subject: drivers: staging: lustre: Fix "'foo * bar' should be 'foo *bar'" errors Fix checkpatch.pl "'foo * bar' should be 'foo *bar'" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/dt_object.h | 2 +- drivers/staging/lustre/lustre/include/lprocfs_status.h | 2 +- drivers/staging/lustre/lustre/include/lustre_dlm.h | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 8 ++++---- drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/obd_config.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index c2e7622469ca..be4c7d95e788 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -667,7 +667,7 @@ static inline int lu_device_is_dt(const struct lu_device *d) return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_DT); } -static inline struct dt_device * lu2dt_dev(struct lu_device *l) +static inline struct dt_device *lu2dt_dev(struct lu_device *l) { LASSERT(lu_device_is_dt(l)); return container_of0(l, struct dt_device, dd_lu_dev); diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 54c522667228..cfe503b7df62 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -557,7 +557,7 @@ extern void lprocfs_free_obd_stats(struct obd_device *obddev); extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; struct nid_stat; -extern int lprocfs_add_clear_entry(struct obd_device * obd, +extern int lprocfs_add_clear_entry(struct obd_device *obd, struct proc_dir_entry *entry); extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid, int *newnid); diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 14ac46f45fd1..83bc0a9d7d4c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1446,7 +1446,7 @@ static inline void check_res_locked(struct ldlm_resource *res) assert_spin_locked(&res->lr_lock); } -struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock); +struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock); void unlock_res_and_lock(struct ldlm_lock *lock); /* ldlm_pool.c */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index c314e9c2343e..b6592ee54c48 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -524,8 +524,8 @@ void class_obd_list(void) /* Search for a client OBD connected to tgt_uuid. If grp_uuid is specified, then only the client with that uuid is returned, otherwise any client connected to the tgt is returned. */ -struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid, - const char * typ_name, +struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, + const char *typ_name, struct obd_uuid *grp_uuid) { int i; @@ -557,7 +557,7 @@ EXPORT_SYMBOL(class_find_client_obd); searching at *next, and if a device is found, the next index to look at is saved in *next. If next is NULL, then the first matching device will always be returned. */ -struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid, int *next) +struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next) { int i; @@ -1783,7 +1783,7 @@ EXPORT_SYMBOL(kuc_len); * @param p Pointer to payload area * @returns Pointer to kuc header */ -struct kuc_hdr * kuc_ptr(void *p) +struct kuc_hdr *kuc_ptr(void *p) { struct kuc_hdr *lh = ((struct kuc_hdr *)p) - 1; LASSERT(lh->kuc_magic == KUC_MAGIC); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 7eaaaa648dfb..66ceab20c743 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -166,14 +166,14 @@ int obd_ioctl_popdata(void *arg, void *data, int len) EXPORT_SYMBOL(obd_ioctl_popdata); /* opening /dev/obd */ -static int obd_class_open(struct inode * inode, struct file * file) +static int obd_class_open(struct inode *inode, struct file *file) { try_module_get(THIS_MODULE); return 0; } /* closing /dev/obd */ -static int obd_class_release(struct inode * inode, struct file * file) +static int obd_class_release(struct inode *inode, struct file *file) { module_put(THIS_MODULE); return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 5e7b3d7cc984..47213a970e7d 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -835,7 +835,7 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg) LIST_HEAD(lustre_profile_list); -struct lustre_profile *class_get_profile(const char * prof) +struct lustre_profile *class_get_profile(const char *prof) { struct lustre_profile *lprof; -- cgit v1.2.3-59-g8ed1b From 31e7213ab21e2c251a61a13fca4c9548f1f875fd Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Mon, 20 Oct 2014 11:42:36 -0500 Subject: drivers: staging: lustre: Fix "spaces required around that '='" errors Fix checkpatch.pl "spaces required around that '='" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index e61dbed120a3..6aff155651cc 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -162,7 +162,7 @@ static int __init init_lustre_lite(void) /* Nodes with small feet have little entropy * the NID for this node gives the most entropy in the low bits */ - for (i=0; ; i++) { + for (i = 0; ; i++) { if (LNetGetId(i, &lnet_id) == -ENOENT) { break; } diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index b6592ee54c48..ac8db2f98078 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -317,7 +317,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name) result->obd_minor, new_obd_minor); obd_devs[result->obd_minor] = NULL; - result->obd_name[0]='\0'; + result->obd_name[0] = '\0'; } result = ERR_PTR(-EEXIST); break; -- cgit v1.2.3-59-g8ed1b From 85bcfab46955e6f4bcfd08ffb989f941e003da2a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 22 Oct 2014 11:11:39 +0300 Subject: staging: lustre: validate size in lustre_posix_acl_xattr_filter() This is mostly to silence static checker complaints. In theory the problem here is that if size is in the 1-3 range then we don't allocate enough memory for the posix_acl_xattr_header struct and it results in memory corruption. But in reality kmalloc() return values are aligned at sizeof(long) so corrupting this small amount of data is not harmful. The "size" variable should be type size_t. The value of size is checked in setxattr() so we know it is a number between "0 - XATTR_SIZE_MAX". There is no need to check for negative sizes. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_eacl.h | 2 +- drivers/staging/lustre/lustre/obdclass/acl.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h index b94f76a3301b..0f8f76c43ee1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h @@ -74,7 +74,7 @@ typedef struct { extern ext_acl_xattr_header * lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size); extern int -lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, +lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, posix_acl_xattr_header **out); extern void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size); diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 2619bfeceb8b..9a69f6b35a0e 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -171,17 +171,17 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_2ext); /* * Filter out the "nobody" entries in the posix ACL. */ -int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, +int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, posix_acl_xattr_header **out) { int count, i, j, rc = 0; __u32 id; posix_acl_xattr_header *new; - if (unlikely(size < 0)) - return -EINVAL; - else if (!size) + if (!size) return 0; + if (size < sizeof(*new)) + return -EINVAL; OBD_ALLOC(new, size); if (unlikely(new == NULL)) -- cgit v1.2.3-59-g8ed1b From 87ebccf97f54fe20c0a8a86e21164473cc7d57e1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 22 Oct 2014 17:23:07 +0300 Subject: staging: lustre: validate size in ll_setxattr() If size is smaller than the lov_user_md struct then we are reading beyond the end of the buffer. I guess this is an information leak or it could cause an Oops if the memory is not mapped. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/xattr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 252a6194ed9b..3ad979635c60 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -234,6 +234,9 @@ int ll_setxattr(struct dentry *dentry, const char *name, struct lov_user_md *lump = (struct lov_user_md *)value; int rc = 0; + if (size != 0 && size < sizeof(struct lov_user_md)) + return -EINVAL; + /* Attributes that are saved via getxattr will always have * the stripe_offset as 0. Instead, the MDS should be * allowed to pick the starting OST index. b=17846 */ -- cgit v1.2.3-59-g8ed1b From 828ebb8f82d9117762ebc22c6bc0b21d68301d44 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Sat, 25 Oct 2014 03:30:38 +0200 Subject: staging: lustre: Use __init and __exit markers for lifecycle functions Apply __init marker to module's init function and __exit to module's exit function as they both have no other usage. Signed-off-by: Mariusz Gorski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index dc09b4377a2f..3c23677bc280 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -110,7 +110,7 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl); -static int +static int __init init_lnet(void) { int rc; @@ -135,7 +135,7 @@ init_lnet(void) return 0; } -static void +static void __exit fini_lnet(void) { int rc; -- cgit v1.2.3-59-g8ed1b From 24443a244b2ccac0883ddc3f929a8a6ea8457daa Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Fri, 24 Oct 2014 17:29:34 -0500 Subject: staging: skein: Collapses threefish module Collapses threefish module into skein module. Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Kconfig | 22 +++------------------- drivers/staging/skein/Makefile | 11 +++++------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig index b9172bfcdc1b..de8bdd768a7f 100644 --- a/drivers/staging/skein/Kconfig +++ b/drivers/staging/skein/Kconfig @@ -1,8 +1,8 @@ config CRYPTO_SKEIN bool "Skein digest algorithm" depends on (X86 || UML_X86) && 64BIT && CRYPTO - select CRYPTO_THREEFISH select CRYPTO_HASH + select CRYPTO_ALGAPI help Skein secure hash algorithm is one of 5 finalists from the NIST SHA3 competition. @@ -12,21 +12,5 @@ config CRYPTO_SKEIN http://www.skein-hash.info/sites/default/files/skein1.3.pdf - for more information. This module depends on the threefish block - cipher module. - -config CRYPTO_THREEFISH - bool "Threefish tweakable block cipher" - depends on (X86 || UML_X86) && 64BIT && CRYPTO - select CRYPTO_ALGAPI - help - Threefish cipher algorithm is the tweakable block cipher underneath - the Skein family of secure hash algorithms. Skein is one of 5 - finalists from the NIST SHA3 competition. - - Skein is optimized for modern, 64bit processors and is highly - customizable. See: - - http://www.skein-hash.info/sites/default/files/skein1.3.pdf - - for more information. + for more information. This module also contains the threefish block + cipher algorithm. diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile index a14aaddd829c..4b60171c81dd 100644 --- a/drivers/staging/skein/Makefile +++ b/drivers/staging/skein/Makefile @@ -1,9 +1,8 @@ # # Makefile for the skein secure hash algorithm # -obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ - skein_api.o \ - skein_block.o - -obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \ - threefish_api.o +obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ + skein_api.o \ + skein_block.o \ + threefish_block.o \ + threefish_api.o -- cgit v1.2.3-59-g8ed1b From c17cdeb41950a69d3e1f43b39a7e5e59ed59c8f9 Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Fri, 24 Oct 2014 17:32:53 -0500 Subject: staging: skein: Renames skein to skein_base Renames skein.c to skein_base.c and skein.h to skein_base.h in preparation for naming loadable module skein.ko Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Makefile | 2 +- drivers/staging/skein/skein.c | 883 --------------------------------- drivers/staging/skein/skein.h | 346 ------------- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_base.c | 884 ++++++++++++++++++++++++++++++++++ drivers/staging/skein/skein_base.h | 346 +++++++++++++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 2 +- drivers/staging/skein/skein_iv.h | 2 +- drivers/staging/skein/threefish_api.h | 2 +- 10 files changed, 1236 insertions(+), 1235 deletions(-) delete mode 100644 drivers/staging/skein/skein.c delete mode 100644 drivers/staging/skein/skein.h create mode 100644 drivers/staging/skein/skein_base.c create mode 100644 drivers/staging/skein/skein_base.h diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile index 4b60171c81dd..ca746a9eb2ad 100644 --- a/drivers/staging/skein/Makefile +++ b/drivers/staging/skein/Makefile @@ -1,7 +1,7 @@ # # Makefile for the skein secure hash algorithm # -obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ +obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \ skein_api.o \ skein_block.o \ threefish_block.o \ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c deleted file mode 100644 index 8cc83587b1f1..000000000000 --- a/drivers/staging/skein/skein.c +++ /dev/null @@ -1,883 +0,0 @@ -/*********************************************************************** -** -** Implementation of the Skein hash function. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -************************************************************************/ - -#define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ - -#include /* get the memcpy/memset functions */ -#include "skein.h" /* get the Skein API definitions */ -#include "skein_iv.h" /* get precomputed IVs */ -#include "skein_block.h" - -/*****************************************************************/ -/* 256-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) -{ - union { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - - switch (hash_bit_len) { /* use pre-computed values, where available */ - case 256: - memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x)); - break; - case 224: - memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x)); - break; - case 160: - memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x)); - break; - case 128: - memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x)); - break; - default: - /* here if there is no precomputed IV value available */ - /* - * build/process the config block, type == CONFIG (could be - * precomputed) - */ - /* set tweaks: T0=0; T1=CFG | FINAL */ - skein_start_new_type(ctx, CFG_FINAL); - - /* set the schema, version */ - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - /* zero pad config block */ - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); - - /* compute the initial chaining values from config block */ - /* zero the chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - /* The chaining vars ctx->x are now initialized for hash_bit_len. */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a MAC and/or tree hash operation */ -/* [identical to skein_256_init() when key_bytes == 0 && \ - * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes) -{ - union { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); - - /* compute the initial chaining values ctx->x[], based on key */ - if (key_bytes == 0) { /* is there a key? */ - /* no key: use all zeroes as key for config block */ - memset(ctx->x, 0, sizeof(ctx->x)); - } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); - /* do a mini-Init right here */ - /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8*sizeof(ctx->x); - /* set tweaks: T0 = 0; T1 = KEY type */ - skein_start_new_type(ctx, KEY); - /* zero the initial chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - /* hash the key */ - skein_256_update(ctx, key, key_bytes); - /* put result into cfg.b[] */ - skein_256_final_pad(ctx, cfg.b); - /* copy over into ctx->x[] */ - memcpy(ctx->x, cfg.b, sizeof(cfg.b)); - } - /* - * build/process the config block, type == CONFIG (could be - * precomputed for each key) - */ - /* output hash bit count */ - ctx->h.hash_bit_len = hash_bit_len; - skein_start_new_type(ctx, CFG_FINAL); - - /* pre-pad cfg.w[] with zeroes */ - memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = skein_swap64(tree_info); - - skein_show_key(256, &ctx->h, key, key_bytes); - - /* compute the initial chaining values from config block */ - skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->x are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - size_t n; - - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) { - /* finish up any buffered message data */ - if (ctx->h.b_cnt) { - /* # bytes free in buffer b[] */ - n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt; - if (n) { - /* check on our logic here */ - skein_assert(n < msg_byte_cnt); - memcpy(&ctx->b[ctx->h.b_cnt], msg, n); - msg_byte_cnt -= n; - msg += n; - ctx->h.b_cnt += n; - } - skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES); - skein_256_process_block(ctx, ctx->b, 1, - SKEIN_256_BLOCK_BYTES); - ctx->h.b_cnt = 0; - } - /* - * now process any remaining full blocks, directly from input - * message data - */ - if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) { - /* number of full blocks to process */ - n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES; - skein_256_process_block(ctx, msg, n, - SKEIN_256_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES; - msg += n * SKEIN_256_BLOCK_BYTES; - } - skein_assert(ctx->h.b_cnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msg_byte_cnt) { - skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN_256_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); - ctx->h.b_cnt += msg_byte_cnt; - } - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_256_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); - - /* process the final block */ - skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64) i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; - if (n >= SKEIN_256_BLOCK_BYTES) - n = SKEIN_256_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, - n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_256_BLOCK_BYTES); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*****************************************************************/ -/* 512-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) -{ - union { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - - switch (hash_bit_len) { /* use pre-computed values, where available */ - case 512: - memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x)); - break; - case 384: - memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x)); - break; - case 256: - memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x)); - break; - case 224: - memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x)); - break; - default: - /* here if there is no precomputed IV value available */ - /* - * build/process the config block, type == CONFIG (could be - * precomputed) - */ - /* set tweaks: T0=0; T1=CFG | FINAL */ - skein_start_new_type(ctx, CFG_FINAL); - - /* set the schema, version */ - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - /* zero pad config block */ - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); - - /* compute the initial chaining values from config block */ - /* zero the chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - - /* - * The chaining vars ctx->x are now initialized for the given - * hash_bit_len. - */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a MAC and/or tree hash operation */ -/* [identical to skein_512_init() when key_bytes == 0 && \ - * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes) -{ - union { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); - - /* compute the initial chaining values ctx->x[], based on key */ - if (key_bytes == 0) { /* is there a key? */ - /* no key: use all zeroes as key for config block */ - memset(ctx->x, 0, sizeof(ctx->x)); - } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); - /* do a mini-Init right here */ - /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8*sizeof(ctx->x); - /* set tweaks: T0 = 0; T1 = KEY type */ - skein_start_new_type(ctx, KEY); - /* zero the initial chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - /* hash the key */ - skein_512_update(ctx, key, key_bytes); - /* put result into cfg.b[] */ - skein_512_final_pad(ctx, cfg.b); - /* copy over into ctx->x[] */ - memcpy(ctx->x, cfg.b, sizeof(cfg.b)); - } - /* - * build/process the config block, type == CONFIG (could be - * precomputed for each key) - */ - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - skein_start_new_type(ctx, CFG_FINAL); - - /* pre-pad cfg.w[] with zeroes */ - memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = skein_swap64(tree_info); - - skein_show_key(512, &ctx->h, key, key_bytes); - - /* compute the initial chaining values from config block */ - skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->x are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - size_t n; - - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) { - /* finish up any buffered message data */ - if (ctx->h.b_cnt) { - /* # bytes free in buffer b[] */ - n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt; - if (n) { - /* check on our logic here */ - skein_assert(n < msg_byte_cnt); - memcpy(&ctx->b[ctx->h.b_cnt], msg, n); - msg_byte_cnt -= n; - msg += n; - ctx->h.b_cnt += n; - } - skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES); - skein_512_process_block(ctx, ctx->b, 1, - SKEIN_512_BLOCK_BYTES); - ctx->h.b_cnt = 0; - } - /* - * now process any remaining full blocks, directly from input - * message data - */ - if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) { - /* number of full blocks to process */ - n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES; - skein_512_process_block(ctx, msg, n, - SKEIN_512_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES; - msg += n * SKEIN_512_BLOCK_BYTES; - } - skein_assert(ctx->h.b_cnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msg_byte_cnt) { - skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN_512_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); - ctx->h.b_cnt += msg_byte_cnt; - } - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_512_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); - - /* process the final block */ - skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64) i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, - n); - skein_show_final(512, &ctx->h, n, - hash_val+i*SKEIN_512_BLOCK_BYTES); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*****************************************************************/ -/* 1024-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) -{ - union { - u8 b[SKEIN_1024_STATE_BYTES]; - u64 w[SKEIN_1024_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - - switch (hash_bit_len) { /* use pre-computed values, where available */ - case 512: - memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x)); - break; - case 384: - memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x)); - break; - case 1024: - memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x)); - break; - default: - /* here if there is no precomputed IV value available */ - /* - * build/process the config block, type == CONFIG - * (could be precomputed) - */ - /* set tweaks: T0=0; T1=CFG | FINAL */ - skein_start_new_type(ctx, CFG_FINAL); - - /* set the schema, version */ - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - /* zero pad config block */ - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); - - /* compute the initial chaining values from config block */ - /* zero the chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - - /* The chaining vars ctx->x are now initialized for the hash_bit_len. */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a MAC and/or tree hash operation */ -/* [identical to skein_1024_init() when key_bytes == 0 && \ - * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes) -{ - union { - u8 b[SKEIN_1024_STATE_BYTES]; - u64 w[SKEIN_1024_STATE_WORDS]; - } cfg; /* config block */ - - skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); - - /* compute the initial chaining values ctx->x[], based on key */ - if (key_bytes == 0) { /* is there a key? */ - /* no key: use all zeroes as key for config block */ - memset(ctx->x, 0, sizeof(ctx->x)); - } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); - /* do a mini-Init right here */ - /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8*sizeof(ctx->x); - /* set tweaks: T0 = 0; T1 = KEY type */ - skein_start_new_type(ctx, KEY); - /* zero the initial chaining variables */ - memset(ctx->x, 0, sizeof(ctx->x)); - /* hash the key */ - skein_1024_update(ctx, key, key_bytes); - /* put result into cfg.b[] */ - skein_1024_final_pad(ctx, cfg.b); - /* copy over into ctx->x[] */ - memcpy(ctx->x, cfg.b, sizeof(cfg.b)); - } - /* - * build/process the config block, type == CONFIG (could be - * precomputed for each key) - */ - /* output hash bit count */ - ctx->h.hash_bit_len = hash_bit_len; - skein_start_new_type(ctx, CFG_FINAL); - - /* pre-pad cfg.w[] with zeroes */ - memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); - /* hash result length in bits */ - cfg.w[1] = skein_swap64(hash_bit_len); - /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = skein_swap64(tree_info); - - skein_show_key(1024, &ctx->h, key, key_bytes); - - /* compute the initial chaining values from config block */ - skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->x are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - skein_start_new_type(ctx, MSG); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - size_t n; - - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) { - /* finish up any buffered message data */ - if (ctx->h.b_cnt) { - /* # bytes free in buffer b[] */ - n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt; - if (n) { - /* check on our logic here */ - skein_assert(n < msg_byte_cnt); - memcpy(&ctx->b[ctx->h.b_cnt], msg, n); - msg_byte_cnt -= n; - msg += n; - ctx->h.b_cnt += n; - } - skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES); - skein_1024_process_block(ctx, ctx->b, 1, - SKEIN_1024_BLOCK_BYTES); - ctx->h.b_cnt = 0; - } - /* - * now process any remaining full blocks, directly from input - * message data - */ - if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) { - /* number of full blocks to process */ - n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES; - skein_1024_process_block(ctx, msg, n, - SKEIN_1024_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES; - msg += n * SKEIN_1024_BLOCK_BYTES; - } - skein_assert(ctx->h.b_cnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msg_byte_cnt) { - skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN_1024_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); - ctx->h.b_cnt += msg_byte_cnt; - } - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_1024_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); - - /* process the final block */ - skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64) i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; - if (n >= SKEIN_1024_BLOCK_BYTES) - n = SKEIN_1024_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, - n); - skein_show_final(1024, &ctx->h, n, - hash_val+i*SKEIN_1024_BLOCK_BYTES); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/**************** Functions to support MAC/tree hashing ***************/ -/* (this code is identical for Optimized and Reference versions) */ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) -{ - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); - /* process the final block */ - skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) -{ - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); - /* process the final block */ - skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES); - - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) -{ - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* tag as the final block */ - ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; - /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) - memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); - /* process the final block */ - skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); - - /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES); - - return SKEIN_SUCCESS; -} - -#if SKEIN_TREE_HASH -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* just do the OUTPUT stage */ -int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_256_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64) i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; - if (n >= SKEIN_256_BLOCK_BYTES) - n = SKEIN_256_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, - n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_256_BLOCK_BYTES); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* just do the OUTPUT stage */ -int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_512_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64) i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, - n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_512_BLOCK_BYTES); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* just do the OUTPUT stage */ -int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) -{ - size_t i, n, byte_cnt; - u64 x[SKEIN_1024_STATE_WORDS]; - /* catch uninitialized context */ - skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); - - /* now output the result */ - /* total number of output bytes */ - byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; - - /* run Threefish in "counter mode" to generate output */ - /* zero out b[], so it can hold the counter */ - memset(ctx->b, 0, sizeof(ctx->b)); - /* keep a local copy of counter mode "key" */ - memcpy(x, ctx->x, sizeof(x)); - for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { - /* build the counter block */ - ((u64 *)ctx->b)[0] = skein_swap64((u64) i); - skein_start_new_type(ctx, OUT_FINAL); - /* run "counter mode" */ - skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); - /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; - if (n >= SKEIN_1024_BLOCK_BYTES) - n = SKEIN_1024_BLOCK_BYTES; - /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, - n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_1024_BLOCK_BYTES); - /* restore the counter mode key for next time */ - memcpy(ctx->x, x, sizeof(x)); - } - return SKEIN_SUCCESS; -} -#endif diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein.h deleted file mode 100644 index e6669f196e5d..000000000000 --- a/drivers/staging/skein/skein.h +++ /dev/null @@ -1,346 +0,0 @@ -#ifndef _SKEIN_H_ -#define _SKEIN_H_ 1 -/************************************************************************** -** -** Interface declarations and internal definitions for Skein hashing. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -*************************************************************************** -** -** The following compile-time switches may be defined to control some -** tradeoffs between speed, code size, error checking, and security. -** -** The "default" note explains what happens when the switch is not defined. -** -** SKEIN_DEBUG -- make callouts from inside Skein code -** to examine/display intermediate values. -** [default: no callouts (no overhead)] -** -** SKEIN_ERR_CHECK -- how error checking is handled inside Skein -** code. If not defined, most error checking -** is disabled (for performance). Otherwise, -** the switch value is interpreted as: -** 0: use assert() to flag errors -** 1: return SKEIN_FAIL to flag errors -** -***************************************************************************/ - -#ifndef rotl_64 -#define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) -#endif - -/* below two prototype assume we are handed aligned data */ -#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) -#define skein_get64_lsb_first(dst64, src08, w_cnt) \ - memcpy(dst64, src08, 8*(w_cnt)) -#define skein_swap64(w64) (w64) - -enum { - SKEIN_SUCCESS = 0, /* return codes from Skein calls */ - SKEIN_FAIL = 1, - SKEIN_BAD_HASHLEN = 2 -}; - -#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ - -#define SKEIN_256_STATE_WORDS (4) -#define SKEIN_512_STATE_WORDS (8) -#define SKEIN_1024_STATE_WORDS (16) -#define SKEIN_MAX_STATE_WORDS (16) - -#define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS) - -#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) -#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS) - -#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) -#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS) - -struct skein_ctx_hdr { - size_t hash_bit_len; /* size of hash result, in bits */ - size_t b_cnt; /* current byte count in buffer b[] */ - u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */ -}; - -struct skein_256_ctx { /* 256-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 x[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -struct skein_512_ctx { /* 512-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 x[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 x[SKEIN_1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -/* Skein APIs for (incremental) "straight hashing" */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); -int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); -int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len); - -int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); -int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); -int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); - -int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); - -/* -** Skein APIs for "extended" initialization: MAC keys, tree hashing. -** After an init_ext() call, just use update/final calls as with init(). -** -** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. -** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, -** the results of init_ext() are identical to calling init(). -** The function init() may be called once to "precompute" the IV for -** a given hash_bit_len value, then by saving a copy of the context -** the IV computation may be avoided in later calls. -** Similarly, the function init_ext() may be called once per MAC key -** to precompute the MAC IV, then a copy of the context saved and -** reused for each new MAC computation. -**/ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); -int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); - -/* -** Skein APIs for MAC and tree hash: -** final_pad: pad, do final block, but no OUTPUT type -** output: do just the output stage -*/ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val); - -#ifndef SKEIN_TREE_HASH -#define SKEIN_TREE_HASH (1) -#endif -#if SKEIN_TREE_HASH -int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); -#endif - -/***************************************************************** -** "Internal" Skein definitions -** -- not needed for sequential hashing API, but will be -** helpful for other uses of Skein (e.g., tree hash mode). -** -- included here so that they can be shared between -** reference and optimized code. -******************************************************************/ - -/* tweak word tweak[1]: bit field starting positions */ -#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ - -#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ -#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* 119 part. final in byte */ -#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* 120..125 type field `*/ -#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ -#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ - -/* tweak word tweak[1]: flag bit definition(s) */ -#define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) -#define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) -#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) - -/* tweak word tweak[1]: tree level bit field mask */ -#define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) -#define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) - -/* tweak word tweak[1]: block type field */ -#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ -#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ -#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ -#define SKEIN_BLK_TYPE_PK (12) /* pubkey (for digital sigs) */ -#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ -#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ -#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ -#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ -#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ - -#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << \ - SKEIN_T1_POS_BLK_TYPE) -#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* for MAC and KDF */ -#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* config block */ -#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization */ -#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* pubkey (for sigs) */ -#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key ident for KDF */ -#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ -#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ -#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ -#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ - -#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | \ - SKEIN_T1_FLAG_FINAL) -#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | \ - SKEIN_T1_FLAG_FINAL) - -#define SKEIN_VERSION (1) - -#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ -#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ -#endif - -#define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64) (hi32)) << 32)) -#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) -#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) - -#define SKEIN_CFG_STR_LEN (4*8) - -/* bit field definitions in config block tree_info word */ -#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) -#define SKEIN_CFG_TREE_NODE_SIZE_POS (8) -#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) - -#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_LEAF_SIZE_POS) -#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_NODE_SIZE_POS) -#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_MAX_LEVEL_POS) - -#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl) \ - ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) - -/* use as tree_info in InitExt() call for sequential processing */ -#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) - -/* -** Skein macros for getting/setting tweak words, etc. -** These are useful for partial input bytes, hash tree init/update, etc. -**/ -#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) -#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ - (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ - } - -#define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) -#define skein_get_T1(ctx_ptr) skein_get_tweak(ctx_ptr, 1) -#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0) -#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1) - -/* set both tweak words at once */ -#define skein_set_T0_T1(ctx_ptr, T0, T1) \ - { \ - skein_set_T0(ctx_ptr, (T0)); \ - skein_set_T1(ctx_ptr, (T1)); \ - } - -#define skein_set_type(ctx_ptr, BLK_TYPE) \ - skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) - -/* - * setup for starting with a new type: - * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0; - */ -#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ - skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ - SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ - (ctx_ptr)->h.b_cnt = 0; \ - } - -#define skein_clear_first_flag(hdr) { \ - (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \ - } -#define skein_set_bit_pad_flag(hdr) { \ - (hdr).tweak[1] |= SKEIN_T1_FLAG_BIT_PAD; \ - } - -#define skein_set_tree_level(hdr, height) { \ - (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \ - } - -/***************************************************************** -** "Internal" Skein definitions for debugging and error checking -******************************************************************/ -#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ -#include "skein_debug.h" -#else /* default is no callouts */ -#define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) -#define skein_show_round(bits, ctx, r, x) -#define skein_show_r_ptr(bits, ctx, r, x_ptr) -#define skein_show_final(bits, ctx, cnt, out_ptr) -#define skein_show_key(bits, ctx, key, key_bytes) -#endif - -/* ignore all asserts, for performance */ -#define skein_assert_ret(x, ret_code) -#define skein_assert(x) - -/***************************************************************** -** Skein block function constants (shared across Ref and Opt code) -******************************************************************/ -enum { - /* SKEIN_256 round rotation constants */ - R_256_0_0 = 14, R_256_0_1 = 16, - R_256_1_0 = 52, R_256_1_1 = 57, - R_256_2_0 = 23, R_256_2_1 = 40, - R_256_3_0 = 5, R_256_3_1 = 37, - R_256_4_0 = 25, R_256_4_1 = 33, - R_256_5_0 = 46, R_256_5_1 = 12, - R_256_6_0 = 58, R_256_6_1 = 22, - R_256_7_0 = 32, R_256_7_1 = 32, - - /* SKEIN_512 round rotation constants */ - R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, - R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, - R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, - R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, - R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, - R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, - R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, - R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, - - /* SKEIN_1024 round rotation constants */ - R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, - R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, - R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, - R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, - R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, - R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, - R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, - R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, - R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, - R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, - R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, - R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, - R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, - R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, - R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, - R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 -}; - -#ifndef SKEIN_ROUNDS -#define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ -#define SKEIN_512_ROUNDS_TOTAL (72) -#define SKEIN_1024_ROUNDS_TOTAL (80) -#else /* allow command-line define in range 8*(5..14) */ -#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) -#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) -#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) -#endif - -#endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h index e02fa19d9458..171b87549548 100644 --- a/drivers/staging/skein/skein_api.h +++ b/drivers/staging/skein/skein_api.h @@ -79,7 +79,7 @@ OTHER DEALINGS IN THE SOFTWARE. */ #include -#include "skein.h" +#include "skein_base.h" /** * Which Skein size to use diff --git a/drivers/staging/skein/skein_base.c b/drivers/staging/skein/skein_base.c new file mode 100644 index 000000000000..e0994eae5b40 --- /dev/null +++ b/drivers/staging/skein/skein_base.c @@ -0,0 +1,884 @@ +/*********************************************************************** +** +** Implementation of the Skein hash function. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +************************************************************************/ + +#define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ + +#include /* get the memcpy/memset functions */ +#include +#include "skein_base.h" /* get the Skein API definitions */ +#include "skein_iv.h" /* get precomputed IVs */ +#include "skein_block.h" + +/*****************************************************************/ +/* 256-bit Skein */ +/*****************************************************************/ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a straight hashing operation */ +int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) +{ + union { + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; + } cfg; /* config block */ + + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ + + switch (hash_bit_len) { /* use pre-computed values, where available */ + case 256: + memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x)); + break; + case 224: + memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x)); + break; + case 160: + memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x)); + break; + case 128: + memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x)); + break; + default: + /* here if there is no precomputed IV value available */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed) + */ + /* set tweaks: T0=0; T1=CFG | FINAL */ + skein_start_new_type(ctx, CFG_FINAL); + + /* set the schema, version */ + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = skein_swap64(hash_bit_len); + cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); + + /* compute the initial chaining values from config block */ + /* zero the chaining variables */ + memset(ctx->x, 0, sizeof(ctx->x)); + skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + break; + } + /* The chaining vars ctx->x are now initialized for hash_bit_len. */ + /* Set up to process the data message portion of the hash (default) */ + skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a MAC and/or tree hash operation */ +/* [identical to skein_256_init() when key_bytes == 0 && \ + * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes) +{ + union { + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; + } cfg; /* config block */ + + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); + + /* compute the initial chaining values ctx->x[], based on key */ + if (key_bytes == 0) { /* is there a key? */ + /* no key: use all zeroes as key for config block */ + memset(ctx->x, 0, sizeof(ctx->x)); + } else { /* here to pre-process a key */ + skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); + /* do a mini-Init right here */ + /* set output hash bit count = state size */ + ctx->h.hash_bit_len = 8*sizeof(ctx->x); + /* set tweaks: T0 = 0; T1 = KEY type */ + skein_start_new_type(ctx, KEY); + /* zero the initial chaining variables */ + memset(ctx->x, 0, sizeof(ctx->x)); + /* hash the key */ + skein_256_update(ctx, key, key_bytes); + /* put result into cfg.b[] */ + skein_256_final_pad(ctx, cfg.b); + /* copy over into ctx->x[] */ + memcpy(ctx->x, cfg.b, sizeof(cfg.b)); + } + /* + * build/process the config block, type == CONFIG (could be + * precomputed for each key) + */ + /* output hash bit count */ + ctx->h.hash_bit_len = hash_bit_len; + skein_start_new_type(ctx, CFG_FINAL); + + /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = skein_swap64(hash_bit_len); + /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + cfg.w[2] = skein_swap64(tree_info); + + skein_show_key(256, &ctx->h, key, key_bytes); + + /* compute the initial chaining values from config block */ + skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->x are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + skein_start_new_type(ctx, MSG); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* process the input bytes */ +int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt) +{ + size_t n; + + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + + /* process full blocks, if any */ + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) { + /* finish up any buffered message data */ + if (ctx->h.b_cnt) { + /* # bytes free in buffer b[] */ + n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt; + if (n) { + /* check on our logic here */ + skein_assert(n < msg_byte_cnt); + memcpy(&ctx->b[ctx->h.b_cnt], msg, n); + msg_byte_cnt -= n; + msg += n; + ctx->h.b_cnt += n; + } + skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES); + skein_256_process_block(ctx, ctx->b, 1, + SKEIN_256_BLOCK_BYTES); + ctx->h.b_cnt = 0; + } + /* + * now process any remaining full blocks, directly from input + * message data + */ + if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) { + /* number of full blocks to process */ + n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES; + skein_256_process_block(ctx, msg, n, + SKEIN_256_BLOCK_BYTES); + msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES; + msg += n * SKEIN_256_BLOCK_BYTES; + } + skein_assert(ctx->h.b_cnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msg_byte_cnt) { + skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN_256_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); + ctx->h.b_cnt += msg_byte_cnt; + } + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the result */ +int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) +{ + size_t i, n, byte_cnt; + u64 x[SKEIN_256_STATE_WORDS]; + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + + /* tag as the final block */ + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); + + /* process the final block */ + skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); + + /* now output the result */ + /* total number of output bytes */ + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; + + /* run Threefish in "counter mode" to generate output */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(x, ctx->x, sizeof(x)); + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { + /* build the counter block */ + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); + /* run "counter mode" */ + skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; + if (n >= SKEIN_256_BLOCK_BYTES) + n = SKEIN_256_BLOCK_BYTES; + /* "output" the ctr mode bytes */ + skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, + n); + skein_show_final(256, &ctx->h, n, + hash_val+i*SKEIN_256_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->x, x, sizeof(x)); + } + return SKEIN_SUCCESS; +} + +/*****************************************************************/ +/* 512-bit Skein */ +/*****************************************************************/ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a straight hashing operation */ +int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) +{ + union { + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; + } cfg; /* config block */ + + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ + + switch (hash_bit_len) { /* use pre-computed values, where available */ + case 512: + memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x)); + break; + case 384: + memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x)); + break; + case 256: + memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x)); + break; + case 224: + memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x)); + break; + default: + /* here if there is no precomputed IV value available */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed) + */ + /* set tweaks: T0=0; T1=CFG | FINAL */ + skein_start_new_type(ctx, CFG_FINAL); + + /* set the schema, version */ + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = skein_swap64(hash_bit_len); + cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); + + /* compute the initial chaining values from config block */ + /* zero the chaining variables */ + memset(ctx->x, 0, sizeof(ctx->x)); + skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + break; + } + + /* + * The chaining vars ctx->x are now initialized for the given + * hash_bit_len. + */ + /* Set up to process the data message portion of the hash (default) */ + skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a MAC and/or tree hash operation */ +/* [identical to skein_512_init() when key_bytes == 0 && \ + * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes) +{ + union { + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; + } cfg; /* config block */ + + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); + + /* compute the initial chaining values ctx->x[], based on key */ + if (key_bytes == 0) { /* is there a key? */ + /* no key: use all zeroes as key for config block */ + memset(ctx->x, 0, sizeof(ctx->x)); + } else { /* here to pre-process a key */ + skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); + /* do a mini-Init right here */ + /* set output hash bit count = state size */ + ctx->h.hash_bit_len = 8*sizeof(ctx->x); + /* set tweaks: T0 = 0; T1 = KEY type */ + skein_start_new_type(ctx, KEY); + /* zero the initial chaining variables */ + memset(ctx->x, 0, sizeof(ctx->x)); + /* hash the key */ + skein_512_update(ctx, key, key_bytes); + /* put result into cfg.b[] */ + skein_512_final_pad(ctx, cfg.b); + /* copy over into ctx->x[] */ + memcpy(ctx->x, cfg.b, sizeof(cfg.b)); + } + /* + * build/process the config block, type == CONFIG (could be + * precomputed for each key) + */ + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ + skein_start_new_type(ctx, CFG_FINAL); + + /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = skein_swap64(hash_bit_len); + /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + cfg.w[2] = skein_swap64(tree_info); + + skein_show_key(512, &ctx->h, key, key_bytes); + + /* compute the initial chaining values from config block */ + skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->x are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + skein_start_new_type(ctx, MSG); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* process the input bytes */ +int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt) +{ + size_t n; + + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + + /* process full blocks, if any */ + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) { + /* finish up any buffered message data */ + if (ctx->h.b_cnt) { + /* # bytes free in buffer b[] */ + n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt; + if (n) { + /* check on our logic here */ + skein_assert(n < msg_byte_cnt); + memcpy(&ctx->b[ctx->h.b_cnt], msg, n); + msg_byte_cnt -= n; + msg += n; + ctx->h.b_cnt += n; + } + skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES); + skein_512_process_block(ctx, ctx->b, 1, + SKEIN_512_BLOCK_BYTES); + ctx->h.b_cnt = 0; + } + /* + * now process any remaining full blocks, directly from input + * message data + */ + if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) { + /* number of full blocks to process */ + n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES; + skein_512_process_block(ctx, msg, n, + SKEIN_512_BLOCK_BYTES); + msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES; + msg += n * SKEIN_512_BLOCK_BYTES; + } + skein_assert(ctx->h.b_cnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msg_byte_cnt) { + skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN_512_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); + ctx->h.b_cnt += msg_byte_cnt; + } + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the result */ +int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) +{ + size_t i, n, byte_cnt; + u64 x[SKEIN_512_STATE_WORDS]; + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + + /* tag as the final block */ + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); + + /* process the final block */ + skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); + + /* now output the result */ + /* total number of output bytes */ + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; + + /* run Threefish in "counter mode" to generate output */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(x, ctx->x, sizeof(x)); + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { + /* build the counter block */ + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); + /* run "counter mode" */ + skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; + if (n >= SKEIN_512_BLOCK_BYTES) + n = SKEIN_512_BLOCK_BYTES; + /* "output" the ctr mode bytes */ + skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, + n); + skein_show_final(512, &ctx->h, n, + hash_val+i*SKEIN_512_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->x, x, sizeof(x)); + } + return SKEIN_SUCCESS; +} + +/*****************************************************************/ +/* 1024-bit Skein */ +/*****************************************************************/ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a straight hashing operation */ +int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) +{ + union { + u8 b[SKEIN_1024_STATE_BYTES]; + u64 w[SKEIN_1024_STATE_WORDS]; + } cfg; /* config block */ + + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ + + switch (hash_bit_len) { /* use pre-computed values, where available */ + case 512: + memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x)); + break; + case 384: + memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x)); + break; + case 1024: + memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x)); + break; + default: + /* here if there is no precomputed IV value available */ + /* + * build/process the config block, type == CONFIG + * (could be precomputed) + */ + /* set tweaks: T0=0; T1=CFG | FINAL */ + skein_start_new_type(ctx, CFG_FINAL); + + /* set the schema, version */ + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = skein_swap64(hash_bit_len); + cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); + + /* compute the initial chaining values from config block */ + /* zero the chaining variables */ + memset(ctx->x, 0, sizeof(ctx->x)); + skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + break; + } + + /* The chaining vars ctx->x are now initialized for the hash_bit_len. */ + /* Set up to process the data message portion of the hash (default) */ + skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a MAC and/or tree hash operation */ +/* [identical to skein_1024_init() when key_bytes == 0 && \ + * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes) +{ + union { + u8 b[SKEIN_1024_STATE_BYTES]; + u64 w[SKEIN_1024_STATE_WORDS]; + } cfg; /* config block */ + + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); + + /* compute the initial chaining values ctx->x[], based on key */ + if (key_bytes == 0) { /* is there a key? */ + /* no key: use all zeroes as key for config block */ + memset(ctx->x, 0, sizeof(ctx->x)); + } else { /* here to pre-process a key */ + skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); + /* do a mini-Init right here */ + /* set output hash bit count = state size */ + ctx->h.hash_bit_len = 8*sizeof(ctx->x); + /* set tweaks: T0 = 0; T1 = KEY type */ + skein_start_new_type(ctx, KEY); + /* zero the initial chaining variables */ + memset(ctx->x, 0, sizeof(ctx->x)); + /* hash the key */ + skein_1024_update(ctx, key, key_bytes); + /* put result into cfg.b[] */ + skein_1024_final_pad(ctx, cfg.b); + /* copy over into ctx->x[] */ + memcpy(ctx->x, cfg.b, sizeof(cfg.b)); + } + /* + * build/process the config block, type == CONFIG (could be + * precomputed for each key) + */ + /* output hash bit count */ + ctx->h.hash_bit_len = hash_bit_len; + skein_start_new_type(ctx, CFG_FINAL); + + /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = skein_swap64(hash_bit_len); + /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + cfg.w[2] = skein_swap64(tree_info); + + skein_show_key(1024, &ctx->h, key, key_bytes); + + /* compute the initial chaining values from config block */ + skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->x are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + skein_start_new_type(ctx, MSG); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* process the input bytes */ +int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt) +{ + size_t n; + + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); + + /* process full blocks, if any */ + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) { + /* finish up any buffered message data */ + if (ctx->h.b_cnt) { + /* # bytes free in buffer b[] */ + n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt; + if (n) { + /* check on our logic here */ + skein_assert(n < msg_byte_cnt); + memcpy(&ctx->b[ctx->h.b_cnt], msg, n); + msg_byte_cnt -= n; + msg += n; + ctx->h.b_cnt += n; + } + skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES); + skein_1024_process_block(ctx, ctx->b, 1, + SKEIN_1024_BLOCK_BYTES); + ctx->h.b_cnt = 0; + } + /* + * now process any remaining full blocks, directly from input + * message data + */ + if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) { + /* number of full blocks to process */ + n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES; + skein_1024_process_block(ctx, msg, n, + SKEIN_1024_BLOCK_BYTES); + msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES; + msg += n * SKEIN_1024_BLOCK_BYTES; + } + skein_assert(ctx->h.b_cnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msg_byte_cnt) { + skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN_1024_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); + ctx->h.b_cnt += msg_byte_cnt; + } + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the result */ +int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) +{ + size_t i, n, byte_cnt; + u64 x[SKEIN_1024_STATE_WORDS]; + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); + + /* tag as the final block */ + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); + + /* process the final block */ + skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); + + /* now output the result */ + /* total number of output bytes */ + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; + + /* run Threefish in "counter mode" to generate output */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(x, ctx->x, sizeof(x)); + for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { + /* build the counter block */ + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); + /* run "counter mode" */ + skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; + if (n >= SKEIN_1024_BLOCK_BYTES) + n = SKEIN_1024_BLOCK_BYTES; + /* "output" the ctr mode bytes */ + skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, + n); + skein_show_final(1024, &ctx->h, n, + hash_val+i*SKEIN_1024_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->x, x, sizeof(x)); + } + return SKEIN_SUCCESS; +} + +/**************** Functions to support MAC/tree hashing ***************/ +/* (this code is identical for Optimized and Reference versions) */ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the block, no OUTPUT stage */ +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) +{ + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + + /* tag as the final block */ + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); + /* process the final block */ + skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); + + /* "output" the state bytes */ + skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the block, no OUTPUT stage */ +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) +{ + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + + /* tag as the final block */ + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); + /* process the final block */ + skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); + + /* "output" the state bytes */ + skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the block, no OUTPUT stage */ +int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) +{ + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); + + /* tag as the final block */ + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); + /* process the final block */ + skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); + + /* "output" the state bytes */ + skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES); + + return SKEIN_SUCCESS; +} + +#if SKEIN_TREE_HASH +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* just do the OUTPUT stage */ +int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) +{ + size_t i, n, byte_cnt; + u64 x[SKEIN_256_STATE_WORDS]; + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + + /* now output the result */ + /* total number of output bytes */ + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; + + /* run Threefish in "counter mode" to generate output */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(x, ctx->x, sizeof(x)); + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { + /* build the counter block */ + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); + /* run "counter mode" */ + skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; + if (n >= SKEIN_256_BLOCK_BYTES) + n = SKEIN_256_BLOCK_BYTES; + /* "output" the ctr mode bytes */ + skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, + n); + skein_show_final(256, &ctx->h, n, + hash_val+i*SKEIN_256_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->x, x, sizeof(x)); + } + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* just do the OUTPUT stage */ +int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) +{ + size_t i, n, byte_cnt; + u64 x[SKEIN_512_STATE_WORDS]; + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + + /* now output the result */ + /* total number of output bytes */ + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; + + /* run Threefish in "counter mode" to generate output */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(x, ctx->x, sizeof(x)); + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { + /* build the counter block */ + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); + /* run "counter mode" */ + skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; + if (n >= SKEIN_512_BLOCK_BYTES) + n = SKEIN_512_BLOCK_BYTES; + /* "output" the ctr mode bytes */ + skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, + n); + skein_show_final(256, &ctx->h, n, + hash_val+i*SKEIN_512_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->x, x, sizeof(x)); + } + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* just do the OUTPUT stage */ +int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) +{ + size_t i, n, byte_cnt; + u64 x[SKEIN_1024_STATE_WORDS]; + /* catch uninitialized context */ + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); + + /* now output the result */ + /* total number of output bytes */ + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; + + /* run Threefish in "counter mode" to generate output */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(x, ctx->x, sizeof(x)); + for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { + /* build the counter block */ + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); + /* run "counter mode" */ + skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; + if (n >= SKEIN_1024_BLOCK_BYTES) + n = SKEIN_1024_BLOCK_BYTES; + /* "output" the ctr mode bytes */ + skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, + n); + skein_show_final(256, &ctx->h, n, + hash_val+i*SKEIN_1024_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->x, x, sizeof(x)); + } + return SKEIN_SUCCESS; +} +#endif diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h new file mode 100644 index 000000000000..e6669f196e5d --- /dev/null +++ b/drivers/staging/skein/skein_base.h @@ -0,0 +1,346 @@ +#ifndef _SKEIN_H_ +#define _SKEIN_H_ 1 +/************************************************************************** +** +** Interface declarations and internal definitions for Skein hashing. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +*************************************************************************** +** +** The following compile-time switches may be defined to control some +** tradeoffs between speed, code size, error checking, and security. +** +** The "default" note explains what happens when the switch is not defined. +** +** SKEIN_DEBUG -- make callouts from inside Skein code +** to examine/display intermediate values. +** [default: no callouts (no overhead)] +** +** SKEIN_ERR_CHECK -- how error checking is handled inside Skein +** code. If not defined, most error checking +** is disabled (for performance). Otherwise, +** the switch value is interpreted as: +** 0: use assert() to flag errors +** 1: return SKEIN_FAIL to flag errors +** +***************************************************************************/ + +#ifndef rotl_64 +#define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) +#endif + +/* below two prototype assume we are handed aligned data */ +#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) +#define skein_get64_lsb_first(dst64, src08, w_cnt) \ + memcpy(dst64, src08, 8*(w_cnt)) +#define skein_swap64(w64) (w64) + +enum { + SKEIN_SUCCESS = 0, /* return codes from Skein calls */ + SKEIN_FAIL = 1, + SKEIN_BAD_HASHLEN = 2 +}; + +#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ + +#define SKEIN_256_STATE_WORDS (4) +#define SKEIN_512_STATE_WORDS (8) +#define SKEIN_1024_STATE_WORDS (16) +#define SKEIN_MAX_STATE_WORDS (16) + +#define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) +#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS) + +#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) +#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS) + +#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) +#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS) + +struct skein_ctx_hdr { + size_t hash_bit_len; /* size of hash result, in bits */ + size_t b_cnt; /* current byte count in buffer b[] */ + u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */ +}; + +struct skein_256_ctx { /* 256-bit Skein hash context structure */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 x[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ +}; + +struct skein_512_ctx { /* 512-bit Skein hash context structure */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 x[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ +}; + +struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 x[SKEIN_1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ +}; + +/* Skein APIs for (incremental) "straight hashing" */ +int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); +int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); +int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len); + +int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); +int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); +int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); + +int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); + +/* +** Skein APIs for "extended" initialization: MAC keys, tree hashing. +** After an init_ext() call, just use update/final calls as with init(). +** +** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. +** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, +** the results of init_ext() are identical to calling init(). +** The function init() may be called once to "precompute" the IV for +** a given hash_bit_len value, then by saving a copy of the context +** the IV computation may be avoided in later calls. +** Similarly, the function init_ext() may be called once per MAC key +** to precompute the MAC IV, then a copy of the context saved and +** reused for each new MAC computation. +**/ +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); +int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); + +/* +** Skein APIs for MAC and tree hash: +** final_pad: pad, do final block, but no OUTPUT type +** output: do just the output stage +*/ +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val); + +#ifndef SKEIN_TREE_HASH +#define SKEIN_TREE_HASH (1) +#endif +#if SKEIN_TREE_HASH +int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); +#endif + +/***************************************************************** +** "Internal" Skein definitions +** -- not needed for sequential hashing API, but will be +** helpful for other uses of Skein (e.g., tree hash mode). +** -- included here so that they can be shared between +** reference and optimized code. +******************************************************************/ + +/* tweak word tweak[1]: bit field starting positions */ +#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ + +#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ +#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* 119 part. final in byte */ +#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* 120..125 type field `*/ +#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ +#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ + +/* tweak word tweak[1]: flag bit definition(s) */ +#define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) +#define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) +#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) + +/* tweak word tweak[1]: tree level bit field mask */ +#define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) +#define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) + +/* tweak word tweak[1]: block type field */ +#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ +#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ +#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ +#define SKEIN_BLK_TYPE_PK (12) /* pubkey (for digital sigs) */ +#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ +#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ +#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ +#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ +#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ + +#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << \ + SKEIN_T1_POS_BLK_TYPE) +#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* for MAC and KDF */ +#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* config block */ +#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization */ +#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* pubkey (for sigs) */ +#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key ident for KDF */ +#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ +#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ +#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ +#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ + +#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | \ + SKEIN_T1_FLAG_FINAL) +#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | \ + SKEIN_T1_FLAG_FINAL) + +#define SKEIN_VERSION (1) + +#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ +#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ +#endif + +#define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64) (hi32)) << 32)) +#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) +#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) + +#define SKEIN_CFG_STR_LEN (4*8) + +/* bit field definitions in config block tree_info word */ +#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) +#define SKEIN_CFG_TREE_NODE_SIZE_POS (8) +#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) + +#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_LEAF_SIZE_POS) +#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_NODE_SIZE_POS) +#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_MAX_LEVEL_POS) + +#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl) \ + ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ + (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ + (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) + +/* use as tree_info in InitExt() call for sequential processing */ +#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) + +/* +** Skein macros for getting/setting tweak words, etc. +** These are useful for partial input bytes, hash tree init/update, etc. +**/ +#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) +#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ + (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ + } + +#define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) +#define skein_get_T1(ctx_ptr) skein_get_tweak(ctx_ptr, 1) +#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0) +#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1) + +/* set both tweak words at once */ +#define skein_set_T0_T1(ctx_ptr, T0, T1) \ + { \ + skein_set_T0(ctx_ptr, (T0)); \ + skein_set_T1(ctx_ptr, (T1)); \ + } + +#define skein_set_type(ctx_ptr, BLK_TYPE) \ + skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) + +/* + * setup for starting with a new type: + * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0; + */ +#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ + skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ + SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ + (ctx_ptr)->h.b_cnt = 0; \ + } + +#define skein_clear_first_flag(hdr) { \ + (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \ + } +#define skein_set_bit_pad_flag(hdr) { \ + (hdr).tweak[1] |= SKEIN_T1_FLAG_BIT_PAD; \ + } + +#define skein_set_tree_level(hdr, height) { \ + (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \ + } + +/***************************************************************** +** "Internal" Skein definitions for debugging and error checking +******************************************************************/ +#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ +#include "skein_debug.h" +#else /* default is no callouts */ +#define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) +#define skein_show_round(bits, ctx, r, x) +#define skein_show_r_ptr(bits, ctx, r, x_ptr) +#define skein_show_final(bits, ctx, cnt, out_ptr) +#define skein_show_key(bits, ctx, key, key_bytes) +#endif + +/* ignore all asserts, for performance */ +#define skein_assert_ret(x, ret_code) +#define skein_assert(x) + +/***************************************************************** +** Skein block function constants (shared across Ref and Opt code) +******************************************************************/ +enum { + /* SKEIN_256 round rotation constants */ + R_256_0_0 = 14, R_256_0_1 = 16, + R_256_1_0 = 52, R_256_1_1 = 57, + R_256_2_0 = 23, R_256_2_1 = 40, + R_256_3_0 = 5, R_256_3_1 = 37, + R_256_4_0 = 25, R_256_4_1 = 33, + R_256_5_0 = 46, R_256_5_1 = 12, + R_256_6_0 = 58, R_256_6_1 = 22, + R_256_7_0 = 32, R_256_7_1 = 32, + + /* SKEIN_512 round rotation constants */ + R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, + R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, + R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, + R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, + R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, + R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, + R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, + R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, + + /* SKEIN_1024 round rotation constants */ + R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, + R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, + R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, + R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, + R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, + R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, + R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, + R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, + R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, + R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, + R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, + R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, + R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, + R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, + R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, + R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 +}; + +#ifndef SKEIN_ROUNDS +#define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ +#define SKEIN_512_ROUNDS_TOTAL (72) +#define SKEIN_1024_ROUNDS_TOTAL (80) +#else /* allow command-line define in range 8*(5..14) */ +#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) +#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) +#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) +#endif + +#endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 88bc718ae5b6..36b0b400acf3 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -15,7 +15,7 @@ ************************************************************************/ #include -#include "skein.h" +#include "skein_base.h" #include "skein_block.h" #ifndef SKEIN_USE_ASM diff --git a/drivers/staging/skein/skein_block.h b/drivers/staging/skein/skein_block.h index bd7bdc35df29..9d40f4a5267b 100644 --- a/drivers/staging/skein/skein_block.h +++ b/drivers/staging/skein/skein_block.h @@ -10,7 +10,7 @@ #ifndef _SKEIN_BLOCK_H_ #define _SKEIN_BLOCK_H_ -#include "skein.h" /* get the Skein API definitions */ +#include "skein_base.h" /* get the Skein API definitions */ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add); diff --git a/drivers/staging/skein/skein_iv.h b/drivers/staging/skein/skein_iv.h index d9dc1d5ed551..8a06314d0ed4 100644 --- a/drivers/staging/skein/skein_iv.h +++ b/drivers/staging/skein/skein_iv.h @@ -1,7 +1,7 @@ #ifndef _SKEIN_IV_H_ #define _SKEIN_IV_H_ -#include "skein.h" /* get Skein macros and types */ +#include "skein_base.h" /* get Skein macros and types */ /* ***************** Pre-computed Skein IVs ******************* diff --git a/drivers/staging/skein/threefish_api.h b/drivers/staging/skein/threefish_api.h index 8d5ddf8b3a9b..8e0a0b77ecce 100644 --- a/drivers/staging/skein/threefish_api.h +++ b/drivers/staging/skein/threefish_api.h @@ -29,7 +29,7 @@ */ #include -#include "skein.h" +#include "skein_base.h" #define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L -- cgit v1.2.3-59-g8ed1b From f96d8ced8ec6e37b8c128bd9c7c65919cc273711 Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Fri, 24 Oct 2014 17:33:15 -0500 Subject: staging: skein: Adds CryptoAPI Support Adds CryptoAPI support to the Skein Hashing Algorithm driver. Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Makefile | 3 +- drivers/staging/skein/skein_base.h | 5 + drivers/staging/skein/skein_generic.c | 199 ++++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/skein/skein_generic.c diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile index ca746a9eb2ad..d8177cccf3f0 100644 --- a/drivers/staging/skein/Makefile +++ b/drivers/staging/skein/Makefile @@ -5,4 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \ skein_api.o \ skein_block.o \ threefish_block.o \ - threefish_api.o + threefish_api.o \ + skein_generic.o diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h index e6669f196e5d..9f10af910f41 100644 --- a/drivers/staging/skein/skein_base.h +++ b/drivers/staging/skein/skein_base.h @@ -28,6 +28,11 @@ ** ***************************************************************************/ +/*Skein digest sizes for crypto api*/ +#define SKEIN256_DIGEST_BIT_SIZE 256 +#define SKEIN512_DIGEST_BIT_SIZE 512 +#define SKEIN1024_DIGEST_BIT_SIZE 1024 + #ifndef rotl_64 #define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) #endif diff --git a/drivers/staging/skein/skein_generic.c b/drivers/staging/skein/skein_generic.c new file mode 100644 index 000000000000..f2d6dfbc66a4 --- /dev/null +++ b/drivers/staging/skein/skein_generic.c @@ -0,0 +1,199 @@ +/* + * Cryptographic API. + * + * Skein256 Hash Algorithm. + * + * Derived from cryptoapi implementation, adapted for in-place + * scatterlist interface. + * + * Copyright (c) Eric Rost + * + * 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 "skein_base.h" + + +static int skein256_init(struct shash_desc *desc) +{ + return skein_256_init((struct skein_256_ctx *) shash_desc_ctx(desc), + SKEIN256_DIGEST_BIT_SIZE); +} + +int skein256_update(struct shash_desc *desc, const u8 *data, + unsigned int len) +{ + return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc), + data, len); +} + +static int skein256_final(struct shash_desc *desc, u8 *out) +{ + return skein_256_final((struct skein_256_ctx *)shash_desc_ctx(desc), + out); +} + +static int skein256_export(struct shash_desc *desc, void *out) +{ + struct skein_256_ctx *sctx = shash_desc_ctx(desc); + + memcpy(out, sctx, sizeof(*sctx)); + return 0; +} + +static int skein256_import(struct shash_desc *desc, const void *in) +{ + struct skein_256_ctx *sctx = shash_desc_ctx(desc); + + memcpy(sctx, in, sizeof(*sctx)); + return 0; +} + +static int skein512_init(struct shash_desc *desc) +{ + return skein_512_init((struct skein_512_ctx *)shash_desc_ctx(desc), + SKEIN512_DIGEST_BIT_SIZE); +} + +int skein512_update(struct shash_desc *desc, const u8 *data, + unsigned int len) +{ + return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc), + data, len); +} + +static int skein512_final(struct shash_desc *desc, u8 *out) +{ + return skein_512_final((struct skein_512_ctx *)shash_desc_ctx(desc), + out); +} + +static int skein512_export(struct shash_desc *desc, void *out) +{ + struct skein_512_ctx *sctx = shash_desc_ctx(desc); + + memcpy(out, sctx, sizeof(*sctx)); + return 0; +} + +static int skein512_import(struct shash_desc *desc, const void *in) +{ + struct skein_512_ctx *sctx = shash_desc_ctx(desc); + + memcpy(sctx, in, sizeof(*sctx)); + return 0; +} + +static int skein1024_init(struct shash_desc *desc) +{ + return skein_1024_init((struct skein_1024_ctx *)shash_desc_ctx(desc), + SKEIN1024_DIGEST_BIT_SIZE); +} + +int skein1024_update(struct shash_desc *desc, const u8 *data, + unsigned int len) +{ + return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc), + data, len); +} + +static int skein1024_final(struct shash_desc *desc, u8 *out) +{ + return skein_1024_final((struct skein_1024_ctx *)shash_desc_ctx(desc), + out); +} + +static int skein1024_export(struct shash_desc *desc, void *out) +{ + struct skein_1024_ctx *sctx = shash_desc_ctx(desc); + + memcpy(out, sctx, sizeof(*sctx)); + return 0; +} + +static int skein1024_import(struct shash_desc *desc, const void *in) +{ + struct skein_1024_ctx *sctx = shash_desc_ctx(desc); + + memcpy(sctx, in, sizeof(*sctx)); + return 0; +} + +static struct shash_alg alg256 = { + .digestsize = (SKEIN256_DIGEST_BIT_SIZE / 8), + .init = skein256_init, + .update = skein256_update, + .final = skein256_final, + .export = skein256_export, + .import = skein256_import, + .descsize = sizeof(struct skein_256_ctx), + .statesize = sizeof(struct skein_256_ctx), + .base = { + .cra_name = "skein256", + .cra_driver_name = "skein", + .cra_flags = CRYPTO_ALG_TYPE_SHASH, + .cra_blocksize = SKEIN_256_BLOCK_BYTES, + } +}; + +static struct shash_alg alg512 = { + .digestsize = (SKEIN512_DIGEST_BIT_SIZE / 8), + .init = skein512_init, + .update = skein512_update, + .final = skein512_final, + .export = skein512_export, + .import = skein512_import, + .descsize = sizeof(struct skein_512_ctx), + .statesize = sizeof(struct skein_512_ctx), + .base = { + .cra_name = "skein512", + .cra_driver_name = "skein", + .cra_flags = CRYPTO_ALG_TYPE_SHASH, + .cra_blocksize = SKEIN_512_BLOCK_BYTES, + } +}; + +static struct shash_alg alg1024 = { + .digestsize = (SKEIN1024_DIGEST_BIT_SIZE / 8), + .init = skein1024_init, + .update = skein1024_update, + .final = skein1024_final, + .export = skein1024_export, + .import = skein1024_import, + .descsize = sizeof(struct skein_1024_ctx), + .statesize = sizeof(struct skein_1024_ctx), + .base = { + .cra_name = "skein1024", + .cra_driver_name = "skein", + .cra_flags = CRYPTO_ALG_TYPE_SHASH, + .cra_blocksize = SKEIN_1024_BLOCK_BYTES, + } +}; + +static int __init skein_generic_init(void) +{ + if (crypto_register_shash(&alg256)) + goto out; + if (crypto_register_shash(&alg512)) + goto unreg256; + if (crypto_register_shash(&alg1024)) + goto unreg512; + + return 0; + + +unreg512: + crypto_unregister_shash(&alg512); +unreg256: + crypto_unregister_shash(&alg256); +out: + return -1; +} + +device_initcall(skein_generic_init); -- cgit v1.2.3-59-g8ed1b From 075c267566a49680f77119d04066339ee354678b Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Fri, 24 Oct 2014 17:33:41 -0500 Subject: staging: skein: Adds Loadable Module Support Adds loadable module support to the Skein Hashing Algorithm driver. Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Kconfig | 2 +- drivers/staging/skein/Makefile | 13 +++++++------ drivers/staging/skein/skein_generic.c | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig index de8bdd768a7f..012a8233376e 100644 --- a/drivers/staging/skein/Kconfig +++ b/drivers/staging/skein/Kconfig @@ -1,5 +1,5 @@ config CRYPTO_SKEIN - bool "Skein digest algorithm" + tristate "Skein digest algorithm" depends on (X86 || UML_X86) && 64BIT && CRYPTO select CRYPTO_HASH select CRYPTO_ALGAPI diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile index d8177cccf3f0..b7f947fb98f0 100644 --- a/drivers/staging/skein/Makefile +++ b/drivers/staging/skein/Makefile @@ -1,9 +1,10 @@ # # Makefile for the skein secure hash algorithm # -obj-$(CONFIG_CRYPTO_SKEIN) += skein_base.o \ - skein_api.o \ - skein_block.o \ - threefish_block.o \ - threefish_api.o \ - skein_generic.o +obj-$(CONFIG_CRYPTO_SKEIN) += skein.o +skein-y := skein_base.o \ + skein_api.o \ + skein_block.o \ + threefish_block.o \ + threefish_api.o \ + skein_generic.o diff --git a/drivers/staging/skein/skein_generic.c b/drivers/staging/skein/skein_generic.c index f2d6dfbc66a4..60d16b639b91 100644 --- a/drivers/staging/skein/skein_generic.c +++ b/drivers/staging/skein/skein_generic.c @@ -16,6 +16,7 @@ */ #include #include +#include #include #include "skein_base.h" @@ -139,6 +140,7 @@ static struct shash_alg alg256 = { .cra_driver_name = "skein", .cra_flags = CRYPTO_ALG_TYPE_SHASH, .cra_blocksize = SKEIN_256_BLOCK_BYTES, + .cra_module = THIS_MODULE, } }; @@ -156,6 +158,7 @@ static struct shash_alg alg512 = { .cra_driver_name = "skein", .cra_flags = CRYPTO_ALG_TYPE_SHASH, .cra_blocksize = SKEIN_512_BLOCK_BYTES, + .cra_module = THIS_MODULE, } }; @@ -173,6 +176,7 @@ static struct shash_alg alg1024 = { .cra_driver_name = "skein", .cra_flags = CRYPTO_ALG_TYPE_SHASH, .cra_blocksize = SKEIN_1024_BLOCK_BYTES, + .cra_module = THIS_MODULE, } }; @@ -196,4 +200,17 @@ out: return -1; } -device_initcall(skein_generic_init); +static void __exit skein_generic_fini(void) +{ + crypto_unregister_shash(&alg256); + crypto_unregister_shash(&alg512); + crypto_unregister_shash(&alg1024); +} + +module_init(skein_generic_init); +module_exit(skein_generic_fini); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Skein Hash Algorithm"); + +MODULE_ALIAS("skein"); -- cgit v1.2.3-59-g8ed1b From c4597c4426265667c225140ffc84032aae6d937e Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Fri, 24 Oct 2014 17:34:13 -0500 Subject: staging: skein: Inlines rotl_64 Inlines the rotl_64 macro. Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_base.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h index 9f10af910f41..0111fa426b32 100644 --- a/drivers/staging/skein/skein_base.h +++ b/drivers/staging/skein/skein_base.h @@ -33,10 +33,6 @@ #define SKEIN512_DIGEST_BIT_SIZE 512 #define SKEIN1024_DIGEST_BIT_SIZE 1024 -#ifndef rotl_64 -#define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) -#endif - /* below two prototype assume we are handed aligned data */ #define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) #define skein_get64_lsb_first(dst64, src08, w_cnt) \ @@ -49,12 +45,12 @@ enum { SKEIN_BAD_HASHLEN = 2 }; -#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ +#define SKEIN_MODIFIER_WORDS 2 /* number of modifier (tweak) words */ -#define SKEIN_256_STATE_WORDS (4) -#define SKEIN_512_STATE_WORDS (8) -#define SKEIN_1024_STATE_WORDS (16) -#define SKEIN_MAX_STATE_WORDS (16) +#define SKEIN_256_STATE_WORDS 4 +#define SKEIN_512_STATE_WORDS 8 +#define SKEIN_1024_STATE_WORDS 16 +#define SKEIN_MAX_STATE_WORDS 16 #define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) #define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) @@ -92,6 +88,11 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; +static inline int rotl_64(int x, int N) +{ + return (x << N) | (x >> (64 - N)); +} + /* Skein APIs for (incremental) "straight hashing" */ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); -- cgit v1.2.3-59-g8ed1b From 71077bb2fced15764a2d091c79dad74788771db3 Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Fri, 24 Oct 2014 17:34:37 -0500 Subject: staging: skein: Removes unneeded #define Removes unneeded #define SKEIN_PORT_CODE since skein_port.h is nonexistent. Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_base.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/skein/skein_base.c b/drivers/staging/skein/skein_base.c index e0994eae5b40..ebc436a1098f 100644 --- a/drivers/staging/skein/skein_base.c +++ b/drivers/staging/skein/skein_base.c @@ -8,8 +8,6 @@ ** ************************************************************************/ -#define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ - #include /* get the memcpy/memset functions */ #include #include "skein_base.h" /* get the Skein API definitions */ -- cgit v1.2.3-59-g8ed1b From 7d95983735889d8f97356fb875a490b55bfd744e Mon Sep 17 00:00:00 2001 From: Koray Gulcu Date: Sun, 12 Oct 2014 19:46:50 +0100 Subject: staging: rtl8192u: Fix sparse warnings of r8182U_core This patch fixes the following endianness warnings found by sparse running with CF=-D__CHECK_ENDIAN__: drivers/staging/rtl8192u/r8192U_core.c:1794:10: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1794:10: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1794:10: got int drivers/staging/rtl8192u/r8192U_core.c:1794:13: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1794:13: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1794:13: got int drivers/staging/rtl8192u/r8192U_core.c:1794:16: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1794:16: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1794:16: got int drivers/staging/rtl8192u/r8192U_core.c:1794:19: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1794:19: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1794:19: got int drivers/staging/rtl8192u/r8192U_core.c:1795:10: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1795:10: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1795:10: got int drivers/staging/rtl8192u/r8192U_core.c:1795:13: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1795:13: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1795:13: got int drivers/staging/rtl8192u/r8192U_core.c:1795:16: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1795:16: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1795:16: got int drivers/staging/rtl8192u/r8192U_core.c:1795:19: warning: incorrect type in initializer (different base types) drivers/staging/rtl8192u/r8192U_core.c:1795:19: expected restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1795:19: got int drivers/staging/rtl8192u/r8192U_core.c:1838:34: warning: cast from restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1839:34: warning: cast from restricted __le16 drivers/staging/rtl8192u/r8192U_core.c:1840:34: warning: cast from restricted __le16 Signed-off-by: Koray Gulcu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 929ac29197cc..49b40eabd819 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1791,8 +1791,8 @@ static void rtl8192_link_change(struct net_device *dev) } static struct ieee80211_qos_parameters def_qos_parameters = { - {3, 3, 3, 3},/* cw_min */ - {7, 7, 7, 7},/* cw_max */ + {cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3)}, + {cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7)}, {2, 2, 2, 2},/* aifs */ {0, 0, 0, 0},/* flags */ {0, 0, 0, 0} /* tx_op_limit */ @@ -1835,9 +1835,9 @@ static void rtl8192_qos_activate(struct work_struct *work) for (i = 0; i < QOS_QUEUE_NUM; i++) { //Mode G/A: slotTimeTimer = 9; Mode B: 20 u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| + u4bAcParam = ((((u32)(le16_to_cpu(qos_parameters->tx_op_limit[i]))) << AC_PARAM_TXOP_LIMIT_OFFSET)| + (((u32)(le16_to_cpu(qos_parameters->cw_max[i]))) << AC_PARAM_ECW_MAX_OFFSET)| + (((u32)(le16_to_cpu(qos_parameters->cw_min[i]))) << AC_PARAM_ECW_MIN_OFFSET)| ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); -- cgit v1.2.3-59-g8ed1b From 7efa16c3b04e53e1a1c2ddecfcfb9b3aaafb71b5 Mon Sep 17 00:00:00 2001 From: Koray Gulcu Date: Sun, 12 Oct 2014 19:46:51 +0100 Subject: staging: rtl8192u: Fix checkpatch.pl warnings This patch fixes "line over 80 characters" warnings found in the first patch by breaking u4bAcParam's calculation down into a few steps. Signed-off-by: Koray Gulcu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 49b40eabd819..e031a253e2ae 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1821,8 +1821,11 @@ static void rtl8192_qos_activate(struct work_struct *work) struct net_device *dev = priv->ieee80211->dev; struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; u8 mode = priv->ieee80211->current_network.mode; - u8 u1bAIFS; + u32 u1bAIFS; u32 u4bAcParam; + u32 op_limit; + u32 cw_max; + u32 cw_min; int i; mutex_lock(&priv->mutex); @@ -1835,11 +1838,14 @@ static void rtl8192_qos_activate(struct work_struct *work) for (i = 0; i < QOS_QUEUE_NUM; i++) { //Mode G/A: slotTimeTimer = 9; Mode B: 20 u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; - u4bAcParam = ((((u32)(le16_to_cpu(qos_parameters->tx_op_limit[i]))) << AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(le16_to_cpu(qos_parameters->cw_max[i]))) << AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(le16_to_cpu(qos_parameters->cw_min[i]))) << AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); - + u1bAIFS <<= AC_PARAM_AIFS_OFFSET; + op_limit = (u32)le16_to_cpu(qos_parameters->tx_op_limit[i]); + op_limit <<= AC_PARAM_TXOP_LIMIT_OFFSET; + cw_max = (u32)le16_to_cpu(qos_parameters->cw_max[i]); + cw_max <<= AC_PARAM_ECW_MAX_OFFSET; + cw_min = (u32)le16_to_cpu(qos_parameters->cw_min[i]); + cw_min <<= AC_PARAM_ECW_MIN_OFFSET; + u4bAcParam = op_limit | cw_max | cw_min | u1bAIFS; write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); } -- cgit v1.2.3-59-g8ed1b From 422caed999f9d596dd5f51c62dcf7e2d97ca8df3 Mon Sep 17 00:00:00 2001 From: Paul McQuade Date: Mon, 27 Oct 2014 16:13:29 +0000 Subject: staging: rtl8188eu: hal: space required ERROR: space required before the open brace '{' Signed-off-by: Paul McQuade Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/bb_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c b/drivers/staging/rtl8188eu/hal/bb_cfg.c index 80e8cc92c10a..c2d166fa0a7f 100644 --- a/drivers/staging/rtl8188eu/hal/bb_cfg.c +++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c @@ -173,7 +173,7 @@ static bool set_baseband_agc_config(struct adapter *adapt) u32 v1 = array[i]; u32 v2 = array[i+1]; - if (v1 < 0xCDCDCDCD){ + if (v1 < 0xCDCDCDCD) { phy_set_bb_reg(adapt, v1, bMaskDWord, v2); udelay(1); } -- cgit v1.2.3-59-g8ed1b From d59d6f5d38962caf82536b393db2bdf7578a0719 Mon Sep 17 00:00:00 2001 From: Greg Donald Date: Sun, 26 Oct 2014 15:19:22 -0500 Subject: staging: rtl8192u: Fix "space prohibited after that open parenthesis '('" errors Fix checkpatch.pl "space prohibited after that open parenthesis '('" errors Signed-off-by: Greg Donald Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 22 +++++++++------------- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 11 ++++------- .../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 3 +-- .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 16 ++++++---------- .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 11 ++++------- 6 files changed, 25 insertions(+), 40 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 73de9e9669f6..d401dbf4c7c6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -713,8 +713,8 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, while(!list_empty(&pTS->RxPendingPktList)) { IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); - if( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) + if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { /* This protect buffer from overflow. */ if(index >= REORDER_WIN_SIZE) { @@ -800,9 +800,8 @@ static u8 parse_subframe(struct sk_buff *skb, // Null packet, don't indicate it to upper layer ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ - if( skb->len <= ChkLength ) { + if (skb->len <= ChkLength) return 0; - } skb_pull(skb, LLCOffset); @@ -1035,10 +1034,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, { // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc)); - if( (fc & (1<<11)) && - (frag == pRxTS->RxLastFragNum) && - (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) ) - { + if ((fc & (1<<11)) && + (frag == pRxTS->RxLastFragNum) && + (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { goto rx_dropped; } else @@ -2456,7 +2454,7 @@ static inline void ieee80211_process_probe_response( // then wireless adapter should do active scan from ch1~11 and // passive scan from ch12~14 - if( !IsLegalChannel(ieee, network.channel) ) + if (!IsLegalChannel(ieee, network.channel)) return; if(ieee->bGlobalDomain) { @@ -2465,8 +2463,7 @@ static inline void ieee80211_process_probe_response( // Case 1: Country code if(IS_COUNTRY_IE_VALID(ieee) ) { - if( !IsLegalChannel(ieee, network.channel) ) - { + if (!IsLegalChannel(ieee, network.channel)) { printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network.channel); return; } @@ -2487,8 +2484,7 @@ static inline void ieee80211_process_probe_response( // Case 1: Country code if(IS_COUNTRY_IE_VALID(ieee) ) { - if( !IsLegalChannel(ieee, network.channel) ) - { + if (!IsLegalChannel(ieee, network.channel)) { printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network.channel); return; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index a1c745b1cf99..9b874086766f 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1043,10 +1043,9 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco { ccxrm_ie_len = 6+2; } - if( beacon->BssCcxVerNumber >= 2 ) - { + if (beacon->BssCcxVerNumber >= 2) cxvernum_ie_len = 5+2; - } + #ifdef THOMAS_TURBO len = sizeof(struct ieee80211_assoc_request_frame)+ 2 + beacon->ssid_len//essid tagged val @@ -1118,8 +1117,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco ieee80211_MFIE_Brate(ieee, &tag); ieee80211_MFIE_Grate(ieee, &tag); // For CCX 1 S13, CKIP. Added by Annie, 2006-08-14. - if( beacon->bCkipSupported ) - { + if (beacon->bCkipSupported) { static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; // "4500-client" u8 CcxAironetBuf[30]; OCTET_STRING osCcxAironetIE; @@ -1158,8 +1156,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco tag += osCcxRmCap.Length; } - if( beacon->BssCcxVerNumber >= 2 ) - { + if (beacon->BssCcxVerNumber >= 2) { u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; OCTET_STRING osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 82ea533a0cf4..644368df6342 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -374,7 +374,7 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info goto out; } - if ( ieee->state == IEEE80211_LINKED){ + if (ieee->state == IEEE80211_LINKED) { queue_work(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 57bef219687b..fca73c7c9fbe 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -529,8 +529,7 @@ static void ieee80211_query_protectionmode(struct ieee80211_device *ieee, } } // For test , CTS replace with RTS - if( 0 ) - { + if (0) { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index a95508d9820e..cd196cec0dd9 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -342,8 +342,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; PRX_TS_RECORD pTS = NULL; - if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9) - { + if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len, @@ -444,8 +443,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) PBA_PARAM_SET pBaParamSet = NULL; u16 ReasonCode; - if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9) - { + if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len, @@ -463,10 +461,9 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) // Check the capability // Since we can always receive A-MPDU, we just check if it is under HT mode. - if( ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false ) - { + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false || + ieee->pHTInfo->bCurrentAMPDUEnable == false) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; @@ -577,8 +574,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) u16 *pReasonCode = NULL; u8 *dst = NULL; - if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6) - { + if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 6) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len, diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 1ea2cd392670..e60d926a3973 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -602,8 +602,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u // TODO: Nedd to take care of this part IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); - if( IsEncrypt) - { + if (IsEncrypt) { pCapELE->MPDUDensity = 7; // 8us pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K } @@ -951,8 +950,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily - if( pHTInfo->bCurrentHTSupport == false ) - { + if (pHTInfo->bCurrentHTSupport == false) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); return; } @@ -1043,7 +1041,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily if (ieee->current_network.bssht.bdRT2RTAggregation) { - if( ieee->pairwise_key_type != KEY_TYPE_NA) + if (ieee->pairwise_key_type != KEY_TYPE_NA) // Realtek may set 32k in security mode and 64k for others pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; else @@ -1332,8 +1330,7 @@ u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame) { if(ieee->pHTInfo->bCurrentHTSupport) { - if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) - { + if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) { IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n"); return true; } -- cgit v1.2.3-59-g8ed1b From c42645a2c54ffd82817e7a11fa05fffde08463a3 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 21 Oct 2014 17:00:24 +0200 Subject: staging: vt6655: Remove redundant cast Both sides have type const struct iw_handler_def*, so the cast is unnecessary and confusing. Signed-off-by: Rasmus Villemoes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c8f262f58c7b..ef848e2f0585 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -932,7 +932,7 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) dev->irq = pcid->irq; dev->netdev_ops = &device_netdev_ops; - dev->wireless_handlers = (struct iw_handler_def *)&iwctl_handler_def; + dev->wireless_handlers = &iwctl_handler_def; rc = register_netdev(dev); if (rc) { -- cgit v1.2.3-59-g8ed1b From 79bffc5344f1fa35e8a0656e7beac593a99a7034 Mon Sep 17 00:00:00 2001 From: Nicky Chorley Date: Sun, 26 Oct 2014 06:30:29 +0000 Subject: Staging: vt6655: Remove C99 comments This patch fixes the following errors identified by checkpatch.pl: ERROR: do not use C99 // comments 36: FILE: card.h:36: // ERROR: do not use C99 // comments 37: FILE: card.h:37: // Loopback mode ERROR: do not use C99 // comments 38: FILE: card.h:38: // ERROR: do not use C99 // comments 39: FILE: card.h:39: // LOBYTE is MAC LB mode, HIBYTE is MII LB mode ERROR: do not use C99 // comments 41: FILE: card.h:41: #define CARD_LB_MAC MAKEWORD(MAC_LB_INTERNAL, 0) // PHY must ISO, avoid MAC loopback packet go out ERROR: do not use C99 // comments 44: FILE: card.h:44: #define DEFAULT_MSDU_LIFETIME 512 // ms ERROR: do not use C99 // comments 45: FILE: card.h:45: #define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us ERROR: do not use C99 // comments 47: FILE: card.h:47: #define DEFAULT_MGN_LIFETIME 8 // ms ERROR: do not use C99 // comments 48: FILE: card.h:48: #define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us ERROR: do not use C99 // comments 175: FILE: card.h:175: #endif // __CARD_H__ Signed-off-by: Nicky Chorley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 96f5b6c46e82..e5bde0920553 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -33,19 +33,20 @@ #include #include -// -// Loopback mode -// -// LOBYTE is MAC LB mode, HIBYTE is MII LB mode +/* + * Loopback mode + * + * LOBYTE is MAC LB mode, HIBYTE is MII LB mode + */ #define CARD_LB_NONE MAKEWORD(MAC_LB_NONE, 0) -#define CARD_LB_MAC MAKEWORD(MAC_LB_INTERNAL, 0) // PHY must ISO, avoid MAC loopback packet go out +#define CARD_LB_MAC MAKEWORD(MAC_LB_INTERNAL, 0) /* PHY must ISO, avoid MAC loopback packet go out */ #define CARD_LB_PHY MAKEWORD(MAC_LB_EXT, 0) -#define DEFAULT_MSDU_LIFETIME 512 // ms -#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us +#define DEFAULT_MSDU_LIFETIME 512 /* ms */ +#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 /* 64us */ -#define DEFAULT_MGN_LIFETIME 8 // ms -#define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us +#define DEFAULT_MGN_LIFETIME 8 /* ms */ +#define DEFAULT_MGN_LIFETIME_RES_64us 125 /* 64us */ #define CB_MAX_CHANNEL_24G 14 #define CB_MAX_CHANNEL_5G 42 @@ -172,4 +173,4 @@ CARDbyGetTransmitPower( struct vnt_private * ); -#endif // __CARD_H__ +#endif /* __CARD_H__ */ -- cgit v1.2.3-59-g8ed1b From 4baa70f69d842a04fc247b5ba4d2778306668f54 Mon Sep 17 00:00:00 2001 From: Soren Brinkmann Date: Mon, 20 Oct 2014 13:20:08 -0700 Subject: staging: clocking-wizard: Contain macro argument in parenthesis A macro doing some arithmetic to calculate a register offset, did not contain an argument to the macro in parentheses, potentially leading to unexpected results when using that macro with arithmetic expressions as argument. Signed-off-by: Soren Brinkmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c index b8d89525bffd..7202d8e889aa 100644 --- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c +++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c @@ -29,7 +29,7 @@ #define WZRD_NUM_OUTPUTS 7 #define WZRD_ACLK_MAX_FREQ 250000000UL -#define WZRD_CLK_CFG_REG(n) (0x200 + 4 * n) +#define WZRD_CLK_CFG_REG(n) (0x200 + 4 * (n)) #define WZRD_CLkOUT0_FRAC_EN BIT(18) #define WZRD_CLkFBOUT_FRAC_EN BIT(26) -- cgit v1.2.3-59-g8ed1b From b7da2d68bb72b9565747bf4b5e785428867b4165 Mon Sep 17 00:00:00 2001 From: Chen Weixiang Date: Sun, 19 Oct 2014 20:59:44 +0800 Subject: staging: ft1000: do not initialise statics to 0 or NULL Remove following checkpatch.pl error from ft1000/ft1000-usb/ft1000_debug.c ERROR: do not initialise statics to 0 or NULL Signed-off-by: Chen Weixiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 4672c4d56205..4397ada1e387 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -38,7 +38,7 @@ #include #include "ft1000_usb.h" -static int ft1000_flarion_cnt = 0; +static int ft1000_flarion_cnt; static int ft1000_open(struct inode *inode, struct file *file); static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait); -- cgit v1.2.3-59-g8ed1b From 5d069c8886fe80ce001dd6bdfadee1d42a6c8efa Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 19 Oct 2014 21:30:02 +0200 Subject: Staging: rts5208: helper function to manage aspm during reset Define the helper function rtsx_reset_aspm to shorten the rtsx_reset_chip code and get rid of the LONG_LINE checkpatch warnings. Signed-off-by: Fabio Falzoi Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 70 +++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index ffcf5deb49b2..ea6cfd1f7282 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -227,6 +227,42 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip) } #endif +static int rtsx_reset_aspm(struct rtsx_chip *chip) +{ + int ret; + + if (chip->dynamic_aspm) { + if (!CHK_SDIO_EXIST(chip) || !CHECK_PID(chip, 0x5288)) + return STATUS_SUCCESS; + + ret = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, + chip->aspm_l0s_l1_en); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + return STATUS_SUCCESS; + } + + if (CHECK_PID(chip, 0x5208)) + RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, 0xFF, 0x3F); + ret = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + chip->aspm_level[0] = chip->aspm_l0s_l1_en; + if (CHK_SDIO_EXIST(chip)) { + chip->aspm_level[1] = chip->aspm_l0s_l1_en; + ret = rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1, + 0xC0, 0xFF, chip->aspm_l0s_l1_en); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + } + + chip->aspm_enabled = 1; + + return STATUS_SUCCESS; +} + int rtsx_reset_chip(struct rtsx_chip *chip) { int retval; @@ -289,37 +325,9 @@ int rtsx_reset_chip(struct rtsx_chip *chip) /* Enable ASPM */ if (chip->aspm_l0s_l1_en) { - if (chip->dynamic_aspm) { - if (CHK_SDIO_EXIST(chip) && CHECK_PID(chip, 0x5288)) { - retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, - chip->aspm_l0s_l1_en); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } - } else { - if (CHECK_PID(chip, 0x5208)) - RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, - 0xFF, 0x3F); - - retval = rtsx_write_config_byte(chip, LCTLR, - chip->aspm_l0s_l1_en); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - chip->aspm_level[0] = chip->aspm_l0s_l1_en; - if (CHK_SDIO_EXIST(chip)) { - chip->aspm_level[1] = chip->aspm_l0s_l1_en; - retval = rtsx_write_cfg_dw(chip, - CHECK_PID(chip, 0x5288) ? 2 : 1, - 0xC0, 0xFF, - chip->aspm_l0s_l1_en); - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } - - chip->aspm_enabled = 1; - } + retval = rtsx_reset_aspm(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); } else { if (chip->asic_code && CHECK_PID(chip, 0x5208)) { retval = rtsx_write_phy_register(chip, 0x07, 0x0129); -- cgit v1.2.3-59-g8ed1b From 506fe17daee8040f642150df504db09a4573214e Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Sun, 19 Oct 2014 21:30:03 +0200 Subject: Staging: rts5208: helper function to enable interrupts during reset Define the helper function rtsx_enable_pcie_intr to shorten the rtsx_reset_chip code and get rid of the LONG_LINE checkpatch warnings. Signed-off-by: Fabio Falzoi Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 95 +++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index ea6cfd1f7282..9593d8132938 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -263,6 +263,51 @@ static int rtsx_reset_aspm(struct rtsx_chip *chip) return STATUS_SUCCESS; } +static int rtsx_enable_pcie_intr(struct rtsx_chip *chip) +{ + int ret; + + if (!chip->asic_code || !CHECK_PID(chip, 0x5208)) { + rtsx_enable_bus_int(chip); + return STATUS_SUCCESS; + } + + if (chip->phy_debug_mode) { + RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0); + rtsx_disable_bus_int(chip); + } else { + rtsx_enable_bus_int(chip); + } + + if (chip->ic_version >= IC_VER_D) { + u16 reg; + + ret = rtsx_read_phy_register(chip, 0x00, ®); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + reg &= 0xFE7F; + reg |= 0x80; + ret = rtsx_write_phy_register(chip, 0x00, reg); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + ret = rtsx_read_phy_register(chip, 0x1C, ®); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + + reg &= 0xFFF7; + ret = rtsx_write_phy_register(chip, 0x1C, reg); + if (ret != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); + } + + if (chip->driver_first_load && (chip->ic_version < IC_VER_C)) + rtsx_calibration(chip); + + return STATUS_SUCCESS; +} + int rtsx_reset_chip(struct rtsx_chip *chip) { int retval; @@ -367,53 +412,9 @@ int rtsx_reset_chip(struct rtsx_chip *chip) RTSX_WRITE_REG(chip, PERST_GLITCH_WIDTH, 0xFF, 0x80); - /* Enable PCIE interrupt */ - if (chip->asic_code) { - if (CHECK_PID(chip, 0x5208)) { - if (chip->phy_debug_mode) { - RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0); - rtsx_disable_bus_int(chip); - } else { - rtsx_enable_bus_int(chip); - } - - if (chip->ic_version >= IC_VER_D) { - u16 reg; - - retval = rtsx_read_phy_register(chip, 0x00, - ®); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - reg &= 0xFE7F; - reg |= 0x80; - retval = rtsx_write_phy_register(chip, 0x00, - reg); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - retval = rtsx_read_phy_register(chip, 0x1C, - ®); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - reg &= 0xFFF7; - retval = rtsx_write_phy_register(chip, 0x1C, - reg); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } - - if (chip->driver_first_load && - (chip->ic_version < IC_VER_C)) - rtsx_calibration(chip); - - } else { - rtsx_enable_bus_int(chip); - } - } else { - rtsx_enable_bus_int(chip); - } + retval = rtsx_enable_pcie_intr(chip); + if (retval != STATUS_SUCCESS) + TRACE_RET(chip, STATUS_FAIL); chip->need_reset = 0; -- cgit v1.2.3-59-g8ed1b From 0c05a5d66397d7c3d4ac05075a3ba7ecef1e1978 Mon Sep 17 00:00:00 2001 From: Brian Vandre Date: Tue, 21 Oct 2014 17:56:47 -0500 Subject: Staging: iio: adc: fix line over 80 characters This fixes the 2 checkpatch.pl warnings: WARNING: line over 80 characters Signed-off-by: Brian Vandre Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/mxs-lradc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 32a19264a170..62449a67ebd6 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -455,7 +455,8 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) * SoC's delay unit and start the conversion later * and automatically. */ - mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */ + mxs_lradc_reg_wrt(lradc, + LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */ LRADC_DELAY_TRIGGER_DELAYS(1 << 3) | /* trigger DELAY unit#3 */ LRADC_DELAY_KICK | LRADC_DELAY_DELAY(lradc->settling_delay), @@ -513,7 +514,8 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1, * SoC's delay unit and start the conversion later * and automatically. */ - mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */ + mxs_lradc_reg_wrt(lradc, + LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */ LRADC_DELAY_TRIGGER_DELAYS(1 << 3) | /* trigger DELAY unit#3 */ LRADC_DELAY_KICK | LRADC_DELAY_DELAY(lradc->settling_delay), LRADC_DELAY(2)); -- cgit v1.2.3-59-g8ed1b From eecc515a1b5ed6188562471f41a78988290376e6 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Wed, 22 Oct 2014 23:22:27 +0200 Subject: staging: rtl8712: Remove redundant cast struct firmware::data has type const u8*, as does *ppmappedfw, so the cast to u8* is unnecessary and slightly confusing. Signed-off-by: Rasmus Villemoes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 1d6ade05fa18..83f93412c154 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -86,7 +86,7 @@ static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw) (int)padapter->fw->size); return 0; } - *ppmappedfw = (u8 *)((*praw)->data); + *ppmappedfw = (*praw)->data; return (*praw)->size; } -- cgit v1.2.3-59-g8ed1b From e29d3ebcda3ebc0193fb98c53c6c3ca6fa2fc030 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Mon, 27 Oct 2014 17:42:25 +0530 Subject: staging: rtl8712: remove unused variables unused variables are removed. These variables were only assigned some values and after that they were never being used. So they are safe to be removed , and it has been build tested. I left a call to r8712_read32(padapter, TCR) and r8712_read8(padapter, SDIO_HCPWM) . r8712_read32() and r8712_read8() is ultimately calling usb_read32() and usb_read8() respectively. and they are again calling r8712_usbctrl_vendorreq(). this r8712_usbctrl_vendorreq() is communicating through the usb bus and is sending and receiving the control msg. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 9 ++------- drivers/staging/rtl8712/ieee80211.c | 3 +-- drivers/staging/rtl8712/rtl8712_cmd.c | 13 +------------ drivers/staging/rtl8712/rtl8712_efuse.c | 3 +-- drivers/staging/rtl8712/rtl8712_recv.c | 15 ++------------- drivers/staging/rtl8712/rtl871x_cmd.c | 2 -- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 19 +++++-------------- drivers/staging/rtl8712/rtl871x_ioctl_set.c | 4 ---- drivers/staging/rtl8712/rtl871x_mlme.c | 23 +++++++---------------- drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 3 --- drivers/staging/rtl8712/rtl871x_pwrctrl.c | 4 +--- drivers/staging/rtl8712/rtl871x_recv.c | 19 +------------------ drivers/staging/rtl8712/rtl871x_recv.h | 3 --- drivers/staging/rtl8712/rtl871x_security.c | 10 ++-------- drivers/staging/rtl8712/rtl871x_sta_mgt.c | 11 +---------- drivers/staging/rtl8712/rtl871x_xmit.c | 13 ++++--------- drivers/staging/rtl8712/usb_intf.c | 6 ------ drivers/staging/rtl8712/usb_ops_linux.c | 3 +-- drivers/staging/rtl8712/xmit_linux.c | 4 +--- 19 files changed, 30 insertions(+), 137 deletions(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 83f93412c154..324da34383ea 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -136,15 +136,10 @@ static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw) static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength) { u32 fwhdrsz, fw_sz; - u8 intf, rfconf; /* check signature */ if ((pfwhdr->signature != 0x8712) && (pfwhdr->signature != 0x8192)) return _FAIL; - /* check interface */ - intf = (u8)((pfwhdr->version&0x3000) >> 12); - /* check rf_conf */ - rfconf = (u8)((pfwhdr->version&0xC000) >> 14); /* check fw_priv_sze & sizeof(struct fw_priv) */ if (pfwhdr->fw_priv_sz != sizeof(struct fw_priv)) return _FAIL; @@ -162,7 +157,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) sint i; u8 tmp8, tmp8_a; u16 tmp16; - u32 maxlen = 0, tmp32; /* for compare usage */ + u32 maxlen = 0; /* for compare usage */ uint dump_imem_sz, imem_sz, dump_emem_sz, emem_sz; /* max = 49152; */ struct fw_hdr fwhdr; u32 ulfilelength; /* FW file size */ @@ -262,7 +257,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) if (tmp8_a != (tmp8|BIT(2))) goto exit_fail; - tmp32 = r8712_read32(padapter, TCR); + r8712_read32(padapter, TCR); /* 4.polling IMEM Ready */ i = 100; diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index eb23b08cb7fd..57868085ce58 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -368,13 +368,12 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { - u8 authmode, sec_idx; + u8 authmode; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; /*Search required WPA or WPA2 IE and copy to sec_ie[ ]*/ cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); - sec_idx = 0; while (cnt < in_len) { authmode = in_ie[cnt]; if ((authmode == _WPA_IE_ID_) && diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index 720e8a15db96..62e53cc1d8b9 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -157,10 +157,8 @@ static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) { u32 val; void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct readBB_parm *prdbbparm; struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - prdbbparm = (struct readBB_parm *)pcmd->parmbuf; if (pcmd->rsp && pcmd->rspsz > 0) memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz); pcmd_callback = cmd_callback[pcmd->cmdcode].callback; @@ -174,10 +172,8 @@ static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) static u8 write_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) { void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct writeBB_parm *pwritebbparm; struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - pwritebbparm = (struct writeBB_parm *)pcmd->parmbuf; pcmd_callback = cmd_callback[pcmd->cmdcode].callback; if (pcmd_callback == NULL) r8712_free_cmd_obj(pcmd); @@ -190,10 +186,8 @@ static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf) { u32 val; void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct readRF_parm *prdrfparm; struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - prdrfparm = (struct readRF_parm *)pcmd->parmbuf; if (pcmd->rsp && pcmd->rspsz > 0) memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz); pcmd_callback = cmd_callback[pcmd->cmdcode].callback; @@ -207,10 +201,8 @@ static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf) static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf) { void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct writeRF_parm *pwriterfparm; struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - pwriterfparm = (struct writeRF_parm *)pcmd->parmbuf; pcmd_callback = cmd_callback[pcmd->cmdcode].callback; if (pcmd_callback == NULL) r8712_free_cmd_obj(pcmd); @@ -222,9 +214,7 @@ static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf) static u8 sys_suspend_hdl(struct _adapter *padapter, u8 *pbuf) { struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - struct usb_suspend_parm *psetusbsuspend; - psetusbsuspend = (struct usb_suspend_parm *)pcmd->parmbuf; r8712_free_cmd_obj(pcmd); return H2C_SUCCESS; } @@ -320,7 +310,7 @@ void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag) int r8712_cmd_thread(void *context) { struct cmd_obj *pcmd; - unsigned int cmdsz, wr_sz, *pcmdbuf, *prspbuf; + unsigned int cmdsz, wr_sz, *pcmdbuf; struct tx_desc *pdesc; void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); struct _adapter *padapter = (struct _adapter *)context; @@ -342,7 +332,6 @@ _next: continue; } pcmdbuf = (unsigned int *)pcmdpriv->cmd_buf; - prspbuf = (unsigned int *)pcmdpriv->rsp_buf; pdesc = (struct tx_desc *)pcmdbuf; memset(pdesc, 0, TXDESC_SIZE); pcmd = cmd_hdl_filter(padapter, pcmd); diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c index 97b78392e6c8..d95716999498 100644 --- a/drivers/staging/rtl8712/rtl8712_efuse.c +++ b/drivers/staging/rtl8712/rtl8712_efuse.c @@ -219,13 +219,12 @@ u16 r8712_efuse_get_current_size(struct _adapter *padapter) { int bContinual = true; u16 efuse_addr = 0; - u8 hoffset = 0, hworden = 0; + u8 hworden = 0; u8 efuse_data, word_cnts = 0; while (bContinual && efuse_one_byte_read(padapter, efuse_addr, &efuse_data) && (efuse_addr < efuse_available_max_size)) { if (efuse_data != 0xFF) { - hoffset = (efuse_data >> 4) & 0x0F; hworden = efuse_data & 0x0F; word_cnts = calculate_word_cnts(hworden); /* read next header */ diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index b27806209268..27f38acc2d62 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -158,8 +158,6 @@ int r8712_free_recvframe(union recv_frame *precvframe, static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, struct recv_stat *prxstat) { - u32 *pphy_info; - struct phy_stat *pphy_stat; u16 drvinfo_sz = 0; drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16; @@ -189,10 +187,6 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, /*Offset 16*/ /*Offset 20*/ /*phy_info*/ - if (drvinfo_sz) { - pphy_stat = (struct phy_stat *)(prxstat+1); - pphy_info = (u32 *)prxstat+1; - } } /*perform defrag*/ @@ -200,7 +194,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter, struct __queue *defrag_q) { struct list_head *plist, *phead; - u8 *data, wlanhdr_offset; + u8 wlanhdr_offset; u8 curfragnum; struct recv_frame_hdr *pfhdr, *pnfhdr; union recv_frame *prframe, *pnextrframe; @@ -223,7 +217,6 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter, curfragnum++; plist = &defrag_q->queue; plist = plist->next; - data = get_recvframe_data(prframe); while (end_of_queue_search(phead, plist) == false) { pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); pnfhdr = &pnextrframe->u.hdr; @@ -436,13 +429,11 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf) { uint voffset; u8 *poffset; - u16 pkt_len, cmd_len, drvinfo_sz; - u8 eid, cmd_seq; + u16 cmd_len, drvinfo_sz; struct recv_stat *prxstat; poffset = (u8 *)prxcmdbuf; voffset = *(uint *)poffset; - pkt_len = le32_to_cpu(voffset) & 0x00003fff; prxstat = (struct recv_stat *)prxcmdbuf; drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16); drvinfo_sz = drvinfo_sz << 3; @@ -450,8 +441,6 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf) do { voffset = *(uint *)poffset; cmd_len = (u16)(le32_to_cpu(voffset) & 0xffff); - cmd_seq = (u8)((le32_to_cpu(voffset) >> 24) & 0x7f); - eid = (u8)((le32_to_cpu(voffset) >> 16) & 0xff); r8712_event_handle(padapter, (uint *)poffset); poffset += (cmd_len + 8);/*8 bytes alignment*/ } while (le32_to_cpu(voffset) & BIT(31)); diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 92101b98c49a..fe5e315319f7 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -470,7 +470,6 @@ u8 r8712_createbss_cmd(struct _adapter *padapter) u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) { - u8 *auth; uint t_len = 0; struct ndis_wlan_bssid_ex *psecnetwork; struct cmd_obj *pcmd; @@ -517,7 +516,6 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) return _FAIL; } memcpy(psecnetwork, &pnetwork->network, t_len); - auth = &psecuritypriv->authenticator_ie[0]; psecuritypriv->authenticator_ie[0] = (unsigned char) psecnetwork->IELength; if ((psecnetwork->IELength-12) < (256 - 1)) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index b4ffc0e31110..73b7d864ccbd 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -170,7 +170,7 @@ static inline char *translate_scan(struct _adapter *padapter, s8 *p; u32 i = 0, ht_ielen = 0; u16 cap, ht_cap = false, mcs_rate; - u8 rssi, bw_40MHz = 0, short_GI = 0; + u8 rssi; if ((pnetwork->network.Configuration.DSConfig < 1) || (pnetwork->network.Configuration.DSConfig > 14)) { @@ -197,10 +197,6 @@ static inline char *translate_scan(struct _adapter *padapter, ht_cap = true; pht_capie = (struct ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate , pht_capie->supp_mcs_set, 2); - bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH) - ? 1 : 0; - short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; @@ -287,12 +283,10 @@ static inline char *translate_scan(struct _adapter *padapter, u8 wpa_ie[255], rsn_ie[255]; u16 wpa_len = 0, rsn_len = 0; int n; - sint out_len = 0; - out_len = r8712_get_sec_ie(pnetwork->network.IEs, - pnetwork->network. - IELength, rsn_ie, &rsn_len, - wpa_ie, &wpa_len); + r8712_get_sec_ie(pnetwork->network.IEs, + pnetwork->network.IELength, rsn_ie, &rsn_len, + wpa_ie, &wpa_len); if (wpa_len > 0) { memset(buf, 0, MAX_WPA_IE_LEN); n = sprintf(buf, "wpa_ie="); @@ -512,7 +506,7 @@ exit: static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, unsigned short ielen) { - u8 *buf = NULL, *pos = NULL; + u8 *buf = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; @@ -522,7 +516,6 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, buf = kmemdup(pie, ielen, GFP_ATOMIC); if (buf == NULL) return -ENOMEM; - pos = buf; if (ielen < RSN_HEADER_LEN) { ret = -EINVAL; goto exit; @@ -1133,13 +1126,11 @@ static int r871x_wx_set_mlme(struct net_device *dev, union iwreq_data *wrqu, char *extra) { int ret = 0; - u16 reason; struct _adapter *padapter = (struct _adapter *)netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *) extra; if (mlme == NULL) return -1; - reason = cpu_to_le16(mlme->reason_code); switch (mlme->cmd) { case IW_MLME_DEAUTH: if (!r8712_set_802_11_disassociate(padapter)) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index a240b6389683..6318a0e65e6e 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -343,13 +343,9 @@ u8 r8712_set_802_11_authentication_mode(struct _adapter *padapter, u8 r8712_set_802_11_add_wep(struct _adapter *padapter, struct NDIS_802_11_WEP *wep) { - u8 bdefaultkey; - u8 btransmitkey; sint keyid; struct security_priv *psecuritypriv = &padapter->securitypriv; - bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; - btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; keyid = wep->KeyIndex & 0x3fffffff; if (keyid >= WEP_KEYS) return false; diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 4b602fe1dba1..b7462e8145d6 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -1372,7 +1372,7 @@ static int SecIsInPMKIDList(struct _adapter *Adapter, u8 *bssid) sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { - u8 authmode = 0, securitytype, match; + u8 authmode = 0, match; u8 sec_ie[255], uncst_oui[4], bkup_ie[255]; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint ielength, cnt, remove_cnt; @@ -1399,21 +1399,17 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, switch (ndissecuritytype) { case Ndis802_11Encryption1Enabled: case Ndis802_11Encryption1KeyAbsent: - securitytype = _WEP40_; uncst_oui[3] = 0x1; break; case Ndis802_11Encryption2Enabled: case Ndis802_11Encryption2KeyAbsent: - securitytype = _TKIP_; uncst_oui[3] = 0x2; break; case Ndis802_11Encryption3Enabled: case Ndis802_11Encryption3KeyAbsent: - securitytype = _AES_; uncst_oui[3] = 0x4; break; default: - securitytype = _NO_PRIVACY_; break; } /*Search required WPA or WPA2 IE and copy to sec_ie[] */ @@ -1705,7 +1701,7 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len) { u32 ielen, out_len; - unsigned char *p, *pframe; + unsigned char *p; struct ieee80211_ht_cap ht_capie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1717,10 +1713,8 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, if (p && (ielen > 0)) { if (pqospriv->qos_option == 0) { out_len = *pout_len; - pframe = r8712_set_ie(out_ie+out_len, - _VENDOR_SPECIFIC_IE_, - _WMM_IE_Length_, - WMM_IE, pout_len); + r8712_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + _WMM_IE_Length_, WMM_IE, pout_len); pqospriv->qos_option = 1; } out_len = *pout_len; @@ -1733,9 +1727,9 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, IEEE80211_HT_CAP_DSSSCCK40; ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); - pframe = r8712_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, - sizeof(struct ieee80211_ht_cap), - (unsigned char *)&ht_capie, pout_len); + r8712_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, + sizeof(struct ieee80211_ht_cap), + (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = 1; } return phtpriv->ht_option; @@ -1748,7 +1742,6 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) int i, len; struct sta_info *bmc_sta, *psta; struct ieee80211_ht_cap *pht_capie; - struct ieee80211_ht_addt_info *pht_addtinfo; struct recv_reorder_ctrl *preorder_ctrl; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -1801,8 +1794,6 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) p = r8712_get_ie(pie + sizeof(struct NDIS_802_11_FIXED_IEs), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct NDIS_802_11_FIXED_IEs)); - if (p && len > 0) - pht_addtinfo = (struct ieee80211_ht_addt_info *)(p + 2); } void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority) diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 9827ff8143b2..a16f15e91992 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -1431,11 +1431,8 @@ unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) /*-------------------------------------------------------------------------*/ uint oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) { - u8 bpwrup; - if (poid_par_priv->type_of_oid != SET_OID) return RNDIS_STATUS_NOT_ACCEPTED; - bpwrup = *(u8 *)poid_par_priv->information_buf; /*CALL the power_down function*/ return RNDIS_STATUS_SUCCESS; } diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c index 51dcf5555b62..ed2844d2b02a 100644 --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c @@ -156,11 +156,9 @@ static void rpwm_workitem_callback(struct work_struct *work) struct pwrctrl_priv, rpwm_workitem); struct _adapter *padapter = container_of(pwrpriv, struct _adapter, pwrctrlpriv); - u8 cpwm = pwrpriv->cpwm; - if (pwrpriv->cpwm != pwrpriv->rpwm) { _enter_pwrlock(&pwrpriv->lock); - cpwm = r8712_read8(padapter, SDIO_HCPWM); + r8712_read8(padapter, SDIO_HCPWM); pwrpriv->rpwm_retry = 1; r8712_set_rpwm(padapter, pwrpriv->rpwm); up(&pwrpriv->lock); diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index 9b99a71670f3..06f15f81c4d8 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -601,7 +601,7 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) { /*remove the wlanhdr and add the eth_hdr*/ sint rmv_len; - u16 eth_type, len; + u16 len; u8 bsnaphdr; u8 *psnap_type; struct ieee80211_snap_hdr *psnap; @@ -635,7 +635,6 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) ptr += rmv_len; *ptr = 0x87; *(ptr+1) = 0x12; - eth_type = 0x8712; /* append rx status for mp test packets */ ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + 2) - 24); @@ -658,27 +657,11 @@ s32 r8712_recv_entry(union recv_frame *precvframe) { struct _adapter *padapter; struct recv_priv *precvpriv; - struct mlme_priv *pmlmepriv; - struct recv_stat *prxstat; - struct dvobj_priv *pdev; - u8 *phead, *pdata, *ptail, *pend; - struct __queue *pfree_recv_queue, *ppending_recv_queue; s32 ret = _SUCCESS; - struct intf_hdl *pintfhdl; padapter = precvframe->u.hdr.adapter; - pintfhdl = &padapter->pio_queue->intf; - pmlmepriv = &padapter->mlmepriv; precvpriv = &(padapter->recvpriv); - pdev = &padapter->dvobjpriv; - pfree_recv_queue = &(precvpriv->free_recv_queue); - ppending_recv_queue = &(precvpriv->recv_pending_queue); - phead = precvframe->u.hdr.rx_head; - pdata = precvframe->u.hdr.rx_data; - ptail = precvframe->u.hdr.rx_tail; - pend = precvframe->u.hdr.rx_end; - prxstat = (struct recv_stat *)phead; padapter->ledpriv.LedControlHandler(padapter, LED_CTL_RX); diff --git a/drivers/staging/rtl8712/rtl871x_recv.h b/drivers/staging/rtl8712/rtl871x_recv.h index 92ca8997e5bc..77487bb9d3c0 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.h +++ b/drivers/staging/rtl8712/rtl871x_recv.h @@ -170,11 +170,8 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz) /* used for append sz bytes from ptr to rx_tail, update rx_tail and * return the updated rx_tail to the caller * after putting, rx_tail must be still larger than rx_end. */ - unsigned char *prev_rx_tail; - if (precvframe == NULL) return NULL; - prev_rx_tail = precvframe->u.hdr.rx_tail; precvframe->u.hdr.rx_tail += sz; if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) { precvframe->u.hdr.rx_tail -= sz; diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 8faf22bb7c90..c653ad6854b4 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -578,7 +578,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe) u8 ttkey[16]; u8 crc[4]; struct arc4context mycontext; - u32 curfragnum, length, prwskeylen; + u32 curfragnum, length; u8 *pframe, *payload, *iv, *prwskey; union pn48 txpn; @@ -600,7 +600,6 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe) &pattrib->ra[0]); if (stainfo != NULL) { prwskey = &stainfo->x_UncstKey.skey[0]; - prwskeylen = 16; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { iv = pframe + pattrib->hdrlen; @@ -655,7 +654,7 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe) u8 ttkey[16]; u8 crc[4]; struct arc4context mycontext; - u32 length, prwskeylen; + u32 length; u8 *pframe, *payload, *iv, *prwskey, idx = 0; union pn48 txpn; struct sta_info *stainfo; @@ -683,7 +682,6 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe) return _FAIL; } else prwskey = &stainfo->x_UncstKey.skey[0]; - prwskeylen = 16; GET_TKIP_PN(iv, txpn); pnl = (u16)(txpn.val); pnh = (u32)(txpn.val >> 16); @@ -1154,7 +1152,6 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe) { /* exclude ICV */ /* Intermediate Buffers */ sint curfragnum, length; - u32 prwskeylen; u8 *pframe, *prwskey; struct sta_info *stainfo; struct pkt_attrib *pattrib = &((struct xmit_frame *) @@ -1174,7 +1171,6 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe) &pattrib->ra[0]); if (stainfo != NULL) { prwskey = &stainfo->x_UncstKey.skey[0]; - prwskeylen = 16; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { if ((curfragnum + 1) == pattrib->nr_frags) { @@ -1363,7 +1359,6 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe) { /* exclude ICV */ /* Intermediate Buffers */ sint length; - u32 prwskeylen; u8 *pframe, *prwskey, *iv, idx; struct sta_info *stainfo; struct rx_pkt_attrib *prxattrib = &((union recv_frame *) @@ -1387,7 +1382,6 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe) } else prwskey = &stainfo->x_UncstKey.skey[0]; - prwskeylen = 16; length = ((union recv_frame *)precvframe)-> u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; aes_decipher(prwskey, prxattrib->hdrlen, pframe, diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index e769bb5c5fb8..4c9b98e8210e 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -79,13 +79,11 @@ static void mfree_all_stainfo(struct sta_priv *pstapriv) { unsigned long irqL; struct list_head *plist, *phead; - struct sta_info *psta = NULL; spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL); phead = &pstapriv->free_sta_queue.queue; plist = phead->next; while ((end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, list); plist = plist->next; } @@ -109,7 +107,6 @@ u32 _r8712_free_sta_priv(struct sta_priv *pstapriv) struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { - uint tmp_aid; s32 index; struct list_head *phash_list; struct sta_info *psta; @@ -127,7 +124,6 @@ struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) psta = LIST_CONTAINOR(pfree_sta_queue->queue.next, struct sta_info, list); list_del_init(&(psta->list)); - tmp_aid = psta->aid; _init_stainfo(psta); memcpy(psta->hwaddr, hwaddr, ETH_ALEN); index = wifi_mac_hash(hwaddr); @@ -267,15 +263,10 @@ struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) void r8712_init_bcmc_stainfo(struct _adapter *padapter) { - struct sta_info *psta; - struct tx_servq *ptxservq; unsigned char bcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sta_priv *pstapriv = &padapter->stapriv; - psta = r8712_alloc_stainfo(pstapriv, bcast_addr); - if (psta == NULL) - return; - ptxservq = &(psta->sta_xmitpriv.be_q); + r8712_alloc_stainfo(pstapriv, bcast_addr); } struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter) diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 9d26fd26d0d4..62a377e7fdc7 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -184,7 +184,6 @@ void _free_xmit_priv(struct xmit_priv *pxmitpriv) sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, struct pkt_attrib *pattrib) { - uint i; struct pkt_file pktfile; struct sta_info *psta = NULL; struct ethhdr etherhdr; @@ -199,7 +198,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, _r8712_open_pktfile(pkt, &pktfile); - i = _r8712_pktfile_read(&pktfile, (unsigned char *)ðerhdr, ETH_HLEN); + _r8712_pktfile_read(&pktfile, (unsigned char *)ðerhdr, ETH_HLEN); pattrib->ether_type = ntohs(etherhdr.h_proto); @@ -236,7 +235,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, /* for mp storing the txcmd per packet, * according to the info of txcmd to update pattrib */ /*get MP_TXDESC_SIZE bytes txcmd per packet*/ - i = _r8712_pktfile_read(&pktfile, (u8 *)&txdesc, TXDESC_SIZE); + _r8712_pktfile_read(&pktfile, (u8 *)&txdesc, TXDESC_SIZE); memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); memcpy(pattrib->ta, pattrib->src, ETH_ALEN); pattrib->pctrl = 1; @@ -347,7 +346,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, static sint xmitframe_addmic(struct _adapter *padapter, struct xmit_frame *pxmitframe) { - u32 curfragnum, length, datalen; + u32 curfragnum, length; u8 *pframe, *payload, mic[8]; struct mic_data micdata; struct sta_info *stainfo; @@ -369,7 +368,6 @@ static sint xmitframe_addmic(struct _adapter *padapter, u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; - datalen = pattrib->pktlen - pattrib->hdrlen; pframe = pxmitframe->buf_addr + TXDESC_OFFSET; if (bmcst) { if (!memcmp(psecuritypriv->XGrptxmickey @@ -825,16 +823,13 @@ void r8712_free_xmitframe(struct xmit_priv *pxmitpriv, unsigned long irqL; struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; struct _adapter *padapter = pxmitpriv->adapter; - struct sk_buff *pndis_pkt = NULL; if (pxmitframe == NULL) return; spin_lock_irqsave(&pfree_xmit_queue->lock, irqL); list_del_init(&pxmitframe->list); - if (pxmitframe->pkt) { - pndis_pkt = pxmitframe->pkt; + if (pxmitframe->pkt) pxmitframe->pkt = NULL; - } list_add_tail(&pxmitframe->list, &pfree_xmit_queue->queue); pxmitpriv->free_xmitframe_cnt++; spin_unlock_irqrestore(&pfree_xmit_queue->lock, irqL); diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index da3856dda728..7d0d1719b136 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -255,9 +255,6 @@ static struct drv_priv drvpriv = { static uint r8712_usb_dvobj_init(struct _adapter *padapter) { uint status = _SUCCESS; - struct usb_device_descriptor *pdev_desc; - struct usb_host_config *phost_conf; - struct usb_config_descriptor *pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; struct dvobj_priv *pdvobjpriv = &padapter->dvobjpriv; @@ -265,9 +262,6 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter) pdvobjpriv->padapter = padapter; padapter->EepromAddressSize = 6; - pdev_desc = &pusbd->descriptor; - phost_conf = pusbd->actconfig; - pconf_desc = &phost_conf->desc; phost_iface = &pintf->altsetting[0]; piface_desc = &phost_iface->desc; pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index e0a155a4fac1..c3a4e3f26b40 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -168,7 +168,6 @@ static void usb_write_mem_complete(struct urb *purb) void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) { unsigned int pipe; - int status; struct _adapter *padapter = (struct _adapter *)pintfhdl->adapter; struct intf_priv *pintfpriv = pintfhdl->pintfpriv; struct io_queue *pio_queue = (struct io_queue *)padapter->pio_queue; @@ -186,7 +185,7 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) usb_fill_bulk_urb(piorw_urb, pusbd, pipe, wmem, cnt, usb_write_mem_complete, pio_queue); - status = usb_submit_urb(piorw_urb, GFP_ATOMIC); + usb_submit_urb(piorw_urb, GFP_ATOMIC); _down_sema(&pintfpriv->io_retevt); } diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 0ac9130faf6c..039b598152bc 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -79,7 +79,6 @@ sint r8712_endofpktfile(struct pkt_file *pfile) void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) { - int i; struct ethhdr etherhdr; struct iphdr ip_hdr; u16 UserPriority = 0; @@ -89,8 +88,7 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) /* get UserPriority from IP hdr*/ if (pattrib->ether_type == 0x0800) { - i = _r8712_pktfile_read(ppktfile, (u8 *)&ip_hdr, - sizeof(ip_hdr)); + _r8712_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); /*UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3 ;*/ UserPriority = ip_hdr.tos >> 5; } else { -- cgit v1.2.3-59-g8ed1b From 92bf93f1260402f17552f91599474bb9ead2a1b2 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Sat, 25 Oct 2014 02:01:54 +0530 Subject: staging: gs_fpgaboot: cleanup in gs_fpgaboot_init function the error path is cleanup to return the correct (function call return value) error code. Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index 0c18c4c311b4..bf2f898d3853 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -344,43 +344,38 @@ err_out1: static int __init gs_fpgaboot_init(void) { - int err, r; - - r = -1; + int err; pr_info("FPGA DOWNLOAD --->\n"); pr_info("FPGA image file name: %s\n", file); err = init_driver(); - if (err != 0) { + if (err) { pr_err("FPGA DRIVER INIT FAIL!!\n"); - return r; + return err; } 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; + return 0; errout: finish_driver(); - return r; + return err; } static void __exit gs_fpgaboot_exit(void) -- cgit v1.2.3-59-g8ed1b From a5841ff372c3c79c266ef383e7faee8206f0f757 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Sat, 25 Oct 2014 02:01:55 +0530 Subject: staging: gs_fpgpaboot: fix compiler warning with make W=1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the following compiler warning has been fixed: drivers/staging/gs_fpgaboot/gs_fpgaboot.c: In function ‘gs_read_bitstream’: drivers/staging/gs_fpgaboot/gs_fpgaboot.c:160:6: warning: variable ‘size’ set but not used [-Wunused-but-set-variable] CC drivers/staging/gs_fpgaboot/io.o LD drivers/staging/gs_fpgaboot/gs_fpga.o LD drivers/staging/gs_fpgaboot/built-in.o by removing the size variable. Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index bf2f898d3853..31caa7464597 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -136,12 +136,10 @@ static void gs_print_header(struct fpgaimage *fimage) 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); -- cgit v1.2.3-59-g8ed1b From 84e9cd6b5c42d021cc0a2dac7d6e49e9d9dfa037 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Sat, 25 Oct 2014 02:01:56 +0530 Subject: staging: gs_fpgaboot: fix a compiler warning with make W=2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The below warning is fixed: drivers/staging/gs_fpgaboot/gs_fpgaboot.c: In function ‘gs_load_image’: drivers/staging/gs_fpgaboot/gs_fpgaboot.c:196:58: warning: declaration of ‘file’ shadows a global declaration [-Wshadow] drivers/staging/gs_fpgaboot/gs_fpgaboot.c:45:14: warning: shadowed declaration is here [-Wshadow] by renaming file function argument of gs_load_image with fw_file. Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index 31caa7464597..6da72858d28c 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -172,15 +172,15 @@ static int gs_read_image(struct fpgaimage *fimage) return 0; } -static int gs_load_image(struct fpgaimage *fimage, char *file) +static int gs_load_image(struct fpgaimage *fimage, char *fw_file) { int err; - pr_info("load fpgaimage %s\n", file); + pr_info("load fpgaimage %s\n", fw_file); - err = request_firmware(&fimage->fw_entry, file, &firmware_pdev->dev); + err = request_firmware(&fimage->fw_entry, fw_file, &firmware_pdev->dev); if (err != 0) { - pr_err("firmware %s is missing, cannot continue.\n", file); + pr_err("firmware %s is missing, cannot continue.\n", fw_file); return err; } -- cgit v1.2.3-59-g8ed1b From 086241e6d01e627ad40831b76a1bdb9ec7028a51 Mon Sep 17 00:00:00 2001 From: Nicky Chorley Date: Sun, 26 Oct 2014 06:21:04 +0000 Subject: Staging: ft1000: ft1000-pcmcia: Fix whitespace issues This patch fixes the following errors and warnings identified by checkpatch.pl: WARNING: please, no spaces at the start of a line 814: FILE: ft1000_hw.c:814: tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);$ WARNING: please, no spaces at the start of a line 815: FILE: ft1000_hw.c:815: i=0;$ ERROR: spaces required around that '=' (ctx:VxV) 815: FILE: ft1000_hw.c:815: i=0; WARNING: please, no spaces at the start of a line 816: FILE: ft1000_hw.c:816: while (tempword & FT1000_DB_DPRAM_TX) {$ ERROR: code indent should use tabs where possible 817: FILE: ft1000_hw.c:817: mdelay(10);$ WARNING: please, no spaces at the start of a line 817: FILE: ft1000_hw.c:817: mdelay(10);$ ERROR: code indent should use tabs where possible 818: FILE: ft1000_hw.c:818: i++;$ WARNING: please, no spaces at the start of a line 818: FILE: ft1000_hw.c:818: i++;$ ERROR: code indent should use tabs where possible 819: FILE: ft1000_hw.c:819: if (i==10) {$ WARNING: please, no spaces at the start of a line 819: FILE: ft1000_hw.c:819: if (i==10) {$ WARNING: suspect code indent for conditional statements (8, 12) 819: FILE: ft1000_hw.c:819: if (i==10) { spin_unlock_irqrestore(&info->dpram_lock, flags); ERROR: spaces required around that '==' (ctx:VxV) 819: FILE: ft1000_hw.c:819: if (i==10) { ERROR: code indent should use tabs where possible 820: FILE: ft1000_hw.c:820: spin_unlock_irqrestore(&info->dpram_lock, flags);$ WARNING: please, no spaces at the start of a line 820: FILE: ft1000_hw.c:820: spin_unlock_irqrestore(&info->dpram_lock, flags);$ ERROR: code indent should use tabs where possible 821: FILE: ft1000_hw.c:821: return;$ WARNING: please, no spaces at the start of a line 821: FILE: ft1000_hw.c:821: return;$ ERROR: code indent should use tabs where possible 822: FILE: ft1000_hw.c:822: }$ WARNING: please, no spaces at the start of a line 822: FILE: ft1000_hw.c:822: }$ ERROR: code indent should use tabs where possible 823: FILE: ft1000_hw.c:823: tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);$ WARNING: please, no spaces at the start of a line 823: FILE: ft1000_hw.c:823: tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);$ WARNING: please, no spaces at the start of a line 824: FILE: ft1000_hw.c:824: }$ Signed-off-by: Nicky Chorley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index a9bcb9e1af78..9de308906054 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -810,18 +810,18 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, */ spin_lock_irqsave(&info->dpram_lock, flags); - /* Make sure SLOWQ doorbell is clear */ - tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); - i=0; - while (tempword & FT1000_DB_DPRAM_TX) { - mdelay(10); - i++; - if (i==10) { - spin_unlock_irqrestore(&info->dpram_lock, flags); - return; - } - tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); - } + /* Make sure SLOWQ doorbell is clear */ + tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); + i = 0; + while (tempword & FT1000_DB_DPRAM_TX) { + mdelay(10); + i++; + if (i == 10) { + spin_unlock_irqrestore(&info->dpram_lock, flags); + return; + } + tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); + } if (info->AsicID == ELECTRABUZZ_ID) { ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, -- cgit v1.2.3-59-g8ed1b From 5689de903e3131b0e501ec9bdb67d1a5bec4392e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 27 Oct 2014 14:18:12 -0400 Subject: staging: unisys: fix CamelCase in net_adap_info Fix the CamelCase member name in this structure: zoneGuid => zone_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 4 ++-- drivers/staging/unisys/virtpci/virtpci.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 6fa8caf5381e..1616109408a4 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -363,7 +363,7 @@ static int add_vhba(struct add_virt_guestpart *addparams) chanptr)->vnic.num_rcv_bufs); \ net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \ chanptr)->vnic.mtu); \ - memcpy_fromio(&net.zoneGuid, \ + memcpy_fromio(&net.zone_uuid, \ &((struct spar_io_channel_protocol __iomem *)\ chanptr)->vnic.zone_uuid, \ sizeof(uuid_le)); \ @@ -395,7 +395,7 @@ add_vnic(struct add_virt_guestpart *addparams) LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], net.mac_addr[4], net.mac_addr[5], net.num_rcv_bufs, net.mtu, - addparams->chanptr, &net.zoneGuid); + addparams->chanptr, &net.zone_uuid); i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net); if (i) { LOGINF("Added vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index 8a0d43947596..de2182f37914 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -42,7 +42,7 @@ struct net_adap_info { u8 mac_addr[MAX_MACADDR_LEN]; int num_rcv_bufs; unsigned mtu; - uuid_le zoneGuid; + uuid_le zone_uuid; }; typedef enum { -- cgit v1.2.3-59-g8ed1b From 2a73a82d13bfb742f85f80069cb53ef5202d8a91 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 27 Oct 2014 14:18:13 -0400 Subject: staging: unisys: get rid of typedef for VIRTPCI_DEV_TYPE Remove the typedef and use enum virtpc_dev_type instead. Update references. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 3 ++- drivers/staging/unisys/virtpci/virtpci.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 1616109408a4..430ad6c83e9a 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -614,7 +614,8 @@ static void delete_all(void) /* deletes all vnics or vhbas * returns 0 failure, 1 success, */ -static int delete_all_virt(VIRTPCI_DEV_TYPE devtype, struct del_vbus_guestpart *delparams) +static int delete_all_virt(enum virtpci_dev_type devtype, + struct del_vbus_guestpart *delparams) { int i; unsigned char busid[BUS_ID_SIZE]; diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index de2182f37914..49025458a1d6 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -45,14 +45,14 @@ struct net_adap_info { uuid_le zone_uuid; }; -typedef enum { +enum virtpci_dev_type { VIRTHBA_TYPE = 0, VIRTNIC_TYPE = 1, VIRTBUS_TYPE = 6, -} VIRTPCI_DEV_TYPE; +}; struct virtpci_dev { - VIRTPCI_DEV_TYPE devtype; /* indicates type of the + enum virtpci_dev_type devtype; /* indicates type of the * virtual pci device */ struct virtpci_driver *mydriver; /* which driver has allocated * this device */ -- cgit v1.2.3-59-g8ed1b From 55f714cd487900c914a7efdf259a9b0a7cda7900 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 27 Oct 2014 14:18:14 -0400 Subject: staging: unisys: fix CamelCase members of virtpci_dev Fix CamelCase names in this structure: busNo => bus_no deviceNo => device_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virthba/virthba.c | 28 ++++++++++++++-------------- drivers/staging/unisys/virtpci/virtpci.c | 15 +++++++++------ drivers/staging/unisys/virtpci/virtpci.h | 4 ++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index ee1be5a83e39..04d3c213205f 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -466,12 +466,12 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id) u64 mask; LOGVER("entering virthba_probe...\n"); - LOGVER("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo, - virtpcidev->deviceNo); + LOGVER("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, + virtpcidev->device_no); LOGINF("entering virthba_probe...\n"); - LOGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo, - virtpcidev->deviceNo); + LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, + virtpcidev->device_no); POSTCODE_LINUX_2(VHBA_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO); /* call scsi_host_alloc to register a scsi host adapter * instance - this virthba that has just been created is an @@ -649,8 +649,8 @@ virthba_remove(struct virtpci_dev *virtpcidev) struct Scsi_Host *scsihost = (struct Scsi_Host *) virtpcidev->scsi.scsihost; - LOGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo, - virtpcidev->deviceNo); + LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, + virtpcidev->device_no); virthbainfo = (struct virthba_info *) scsihost->hostdata; if (virthbainfo->interrupt_vector != -1) free_irq(virthbainfo->interrupt_vector, virthbainfo); @@ -1482,8 +1482,8 @@ virthba_serverup(struct virtpci_dev *virtpcidev) (struct virthba_info *) ((struct Scsi_Host *) virtpcidev->scsi. scsihost)->hostdata; - DBGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo, - virtpcidev->deviceNo); + DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, + virtpcidev->device_no); if (!virthbainfo->serverdown) { DBGINF("Server up message received while server is already up.\n"); @@ -1573,13 +1573,13 @@ virthba_serverdown_complete(struct work_struct *work) virtpcidev = virthbainfo->virtpcidev; - DBGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo, - virtpcidev->deviceNo); + DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, + virtpcidev->device_no); virthbainfo->serverdown = true; virthbainfo->serverchangingstate = false; /* Return the ServerDown response to Command */ - visorchipset_device_pause_response(virtpcidev->busNo, - virtpcidev->deviceNo, 0); + visorchipset_device_pause_response(virtpcidev->bus_no, + virtpcidev->device_no, 0); } /* As per VirtpciFunc returns 1 for success and 0 for failure */ @@ -1591,8 +1591,8 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state) scsihost)->hostdata; DBGINF("virthba_serverdown"); - DBGINF("virtpcidev busNo<<%d>>devNo<<%d>>", virtpcidev->busNo, - virtpcidev->deviceNo); + DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no, + virtpcidev->device_no); if (!virthbainfo->serverdown && !virthbainfo->serverchangingstate) { virthbainfo->serverchangingstate = true; diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 430ad6c83e9a..52ec69f06b92 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -843,7 +843,7 @@ static int virtpci_device_probe(struct device *dev) */ error = virtpcidrv->probe(virtpcidev, id); if (!error) { - fix_vbus_devInfo(dev, virtpcidev->deviceNo, + fix_vbus_devInfo(dev, virtpcidev->device_no, virtpcidev->device, virtpcidrv); virtpcidev->mydriver = virtpcidrv; POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC, @@ -940,8 +940,8 @@ static int virtpci_device_add(struct device *parentbus, int devtype, virtpcidev->net = *net; } virtpcidev->vendor = PCI_VENDOR_ID_UNISYS; - virtpcidev->busNo = addparams->bus_no; - virtpcidev->deviceNo = addparams->device_no; + virtpcidev->bus_no = addparams->bus_no; + virtpcidev->device_no = addparams->device_no; virtpcidev->queueinfo.chan = addparams->chanptr; virtpcidev->queueinfo.send_int_if_needed = NULL; @@ -1173,7 +1173,8 @@ static int virtpci_device_serverup(struct device *parentbus, * ever have a bus that contains NO devices, since we * would never even get here in that case. */ - fix_vbus_devInfo(&tmpvpcidev->generic_dev, tmpvpcidev->deviceNo, + fix_vbus_devInfo(&tmpvpcidev->generic_dev, + tmpvpcidev->device_no, tmpvpcidev->device, vpcidriver); rc = vpcidriver->resume(tmpvpcidev); } @@ -1458,7 +1459,8 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, if (tmpvpcidev->devtype == VIRTHBA_TYPE) { str_pos += scnprintf(vbuf + str_pos, len - str_pos, "[%d:%d] VHba:%08x:%08x max-config:%d-%d-%d-%d", - tmpvpcidev->busNo, tmpvpcidev->deviceNo, + tmpvpcidev->bus_no, + tmpvpcidev->device_no, tmpvpcidev->scsi.wwnn.wwnn1, tmpvpcidev->scsi.wwnn.wwnn2, tmpvpcidev->scsi.max.max_channel, @@ -1468,7 +1470,8 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, } else { str_pos += scnprintf(vbuf + str_pos, len - str_pos, "[%d:%d] VNic:%02x:%02x:%02x:%02x:%02x:%02x num_rcv_bufs:%d mtu:%d", - tmpvpcidev->busNo, tmpvpcidev->deviceNo, + tmpvpcidev->bus_no, + tmpvpcidev->device_no, tmpvpcidev->net.mac_addr[0], tmpvpcidev->net.mac_addr[1], tmpvpcidev->net.mac_addr[2], diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index 49025458a1d6..42a98de47e1d 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -58,8 +58,8 @@ struct virtpci_dev { * this device */ unsigned short vendor; /* vendor id for device */ unsigned short device; /* device id for device */ - u32 busNo; /* number of bus on which device exists */ - u32 deviceNo; /* device's number on the bus */ + u32 bus_no; /* number of bus on which device exists */ + u32 device_no; /* device's number on the bus */ struct irq_info intr; /* interrupt info */ struct device generic_dev; /* generic device */ union { -- cgit v1.2.3-59-g8ed1b From 61b27ac8372f30aacb317e48834ef2c5cfeffe5a Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 27 Oct 2014 14:18:15 -0400 Subject: staging: unisys: fix alignment in virtpci.h Clean up misaligned indentation in virtpci.h. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index 42a98de47e1d..9d85f55e8169 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -80,15 +80,15 @@ struct virtpci_driver { const struct pci_device_id *id_table; /* must be non-NULL for probe * to be called */ int (*probe)(struct virtpci_dev *dev, - const struct pci_device_id *id); /* device inserted */ + const struct pci_device_id *id); /* device inserted */ void (*remove)(struct virtpci_dev *dev); /* Device removed (NULL if * not a hot-plug capable * driver) */ int (*suspend)(struct virtpci_dev *dev, - u32 state); /* Device suspended */ + u32 state); /* Device suspended */ int (*resume)(struct virtpci_dev *dev); /* Device woken up */ int (*enable_wake)(struct virtpci_dev *dev, - u32 state, int enable); /* Enable wake event */ + u32 state, int enable); /* Enable wake event */ struct device_driver core_driver; /* VIRTPCI core fills this in */ }; -- cgit v1.2.3-59-g8ed1b From 2aef999ba0e6dc9e253e547c0b32f6658aa1393d Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 28 Oct 2014 09:36:28 -0400 Subject: staging: unisys: fix macro spacing in uisutils.h Add some space between the macros in uisutils.h for readability. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/uisutils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 20758ae2bf26..7414220676d3 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -179,11 +179,14 @@ struct chaninfo { set_current_state(TASK_INTERRUPTIBLE); \ schedule_timeout(msecs_to_jiffies(x)); \ } + #define UIS_THREAD_WAIT_USEC(x) { \ set_current_state(TASK_INTERRUPTIBLE); \ schedule_timeout(usecs_to_jiffies(x)); \ } + #define UIS_THREAD_WAIT UIS_THREAD_WAIT_MSEC(5) + #define UIS_THREAD_WAIT_SEC(x) { \ set_current_state(TASK_INTERRUPTIBLE); \ schedule_timeout((x)*HZ); \ -- cgit v1.2.3-59-g8ed1b From 33b1c8c13fb8c9c3c5320345258a4d33806262f4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:36 +0000 Subject: staging: vt6655: mac80211 conversion: add new rx functions vnt_receive_frame which replaces device_receive_frame and vnt_rx_data which handles mac80211 rx data structures ieee80211_hw, ieee80211_vif and variable rx_rate are added in structure vnt_private Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 6 +- drivers/staging/vt6655/device_main.c | 13 ++-- drivers/staging/vt6655/dpc.c | 123 +++++++++++++++++++++++++++++++++++ drivers/staging/vt6655/dpc.h | 2 + 4 files changed, 137 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index d769d092fb87..82e18455501c 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -56,6 +56,7 @@ #include #include /* Include Wireless Extension definition and check version - Jean II */ +#include #include #include /* New driver API */ @@ -319,7 +320,9 @@ typedef struct __device_opt { struct vnt_private { struct pci_dev *pcid; - + /* mac80211 */ + struct ieee80211_hw *hw; + struct ieee80211_vif *vif; /* netdev */ struct net_device *dev; @@ -378,6 +381,7 @@ struct vnt_private { u32 flags; u32 rx_buf_sz; + u8 rx_rate; int multicast_limit; pid_t MLMEThr_pid; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index ef848e2f0585..84a35d7d01e8 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1336,7 +1336,7 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx) pRD = pRD->next) { if (works++ > 15) break; - if (device_receive_frame(pDevice, pRD)) { + if (vnt_receive_frame(pDevice, pRD)) { if (!device_alloc_rx_buf(pDevice, pRD)) { dev_err(&pDevice->pcid->dev, "can not allocate rx buf\n"); @@ -1344,7 +1344,6 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx) } } pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC; - pDevice->dev->last_rx = jiffies; } pDevice->pCurrRD[uIdx] = pRD; @@ -1360,9 +1359,12 @@ static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD) if (pRDInfo->skb == NULL) return false; ASSERT(pRDInfo->skb); - pRDInfo->skb->dev = pDevice->dev; - pRDInfo->skb_dma = pci_map_single(pDevice->pcid, skb_tail_pointer(pRDInfo->skb), - pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE); + + pRDInfo->skb_dma = + pci_map_single(pDevice->pcid, + skb_put(pRDInfo->skb, skb_tailroom(pRDInfo->skb)), + pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE); + *((unsigned int *)&(pRD->m_rd0RD0)) = 0; /* FIX cast */ pRD->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz); @@ -1380,7 +1382,6 @@ bool device_alloc_frag_buf(struct vnt_private *pDevice, if (pDeF->skb == NULL) return false; ASSERT(pDeF->skb); - pDeF->skb->dev = pDevice->dev; return true; } diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 67cadeaf2f7d..036bbb0f4824 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -1321,3 +1321,126 @@ static bool s_bAPModeRxData( return true; } + +static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, + u16 bytes_received) +{ + struct ieee80211_hw *hw = priv->hw; + struct ieee80211_supported_band *sband; + struct ieee80211_rx_status rx_status = { 0 }; + struct ieee80211_hdr *hdr; + __le16 fc; + u8 *rsr, *new_rsr, *rssi; + __le64 *tsf_time; + u16 frame_size; + int ii, r; + u8 *rx_sts, *rx_rate, *sq; + u8 *skb_data; + u8 rate_idx = 0; + u8 rate[MAX_RATE] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108}; + long rx_dbm; + + /* [31:16]RcvByteCount ( not include 4-byte Status ) */ + frame_size = le16_to_cpu(*((__le16 *)(skb->data + 2))); + if (frame_size > 2346 || frame_size < 14) { + dev_dbg(&priv->pcid->dev, "------- WRONG Length 1\n"); + return false; + } + + skb_data = (u8 *)skb->data; + + rx_sts = skb_data; + rx_rate = skb_data + 1; + + sband = hw->wiphy->bands[hw->conf.chandef.chan->band]; + + for (r = RATE_1M; r < MAX_RATE; r++) { + if (*rx_rate == rate[r]) + break; + } + + priv->rx_rate = r; + + for (ii = 0; ii < sband->n_bitrates; ii++) { + if (sband->bitrates[ii].hw_value == r) { + rate_idx = ii; + break; + } + } + + if (ii == sband->n_bitrates) { + dev_dbg(&priv->pcid->dev, "Wrong RxRate %x\n", *rx_rate); + return false; + } + + tsf_time = (__le64 *)(skb_data + bytes_received - 12); + sq = skb_data + bytes_received - 4; + new_rsr = skb_data + bytes_received - 3; + rssi = skb_data + bytes_received - 2; + rsr = skb_data + bytes_received - 1; + + RFvRSSITodBm(priv, *rssi, &rx_dbm); + + priv->byBBPreEDRSSI = (u8)rx_dbm + 1; + priv->uCurrRSSI = priv->byBBPreEDRSSI; + + skb_pull(skb, 4); + skb_trim(skb, frame_size); + + rx_status.mactime = le64_to_cpu(*tsf_time); + rx_status.band = hw->conf.chandef.chan->band; + rx_status.signal = rx_dbm; + rx_status.flag = 0; + rx_status.freq = hw->conf.chandef.chan->center_freq; + + hdr = (struct ieee80211_hdr *)(skb->data); + fc = hdr->frame_control; + + rx_status.rate_idx = rate_idx; + + if (ieee80211_has_protected(fc)) { + if (priv->byLocalID > REV_ID_VT3253_A1) + rx_status.flag = RX_FLAG_DECRYPTED; + } + + if (priv->vif && priv->bDiversityEnable) { + if (ieee80211_is_data(fc) && + (frame_size > 50) && priv->vif->bss_conf.assoc) + BBvAntennaDiversity(priv, priv->rx_rate, 0); + } + + memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); + + ieee80211_rx_irqsafe(priv->hw, skb); + + return true; +} + +bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd) +{ + PDEVICE_RD_INFO rd_info = curr_rd->pRDInfo; + struct sk_buff *skb; + u16 frame_size; + + skb = rd_info->skb; + + pci_unmap_single(priv->pcid, rd_info->skb_dma, + priv->rx_buf_sz, PCI_DMA_FROMDEVICE); + + frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount) + - cpu_to_le16(curr_rd->m_rd0RD0.wResCount); + + if ((frame_size > 2364) || (frame_size < 33)) { + /* Frame Size error drop this packet.*/ + dev_dbg(&priv->pcid->dev, "Wrong frame size %d\n", frame_size); + dev_kfree_skb_irq(skb); + return true; + } + + if (vnt_rx_data(priv, skb, frame_size)) + return true; + + dev_kfree_skb_irq(skb); + + return true; +} diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h index e97e32811916..dd48e4125477 100644 --- a/drivers/staging/vt6655/dpc.h +++ b/drivers/staging/vt6655/dpc.h @@ -39,4 +39,6 @@ device_receive_frame( PSRxDesc pCurrRD ); +bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd); + #endif /* __RXTX_H__ */ -- cgit v1.2.3-59-g8ed1b From fee7506a121a4666aa42b22bcdc2172752b9f65b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:37 +0000 Subject: staging: vt6655: mac80211 conversion: add new key functions vnt_key_init_table to initialize the table vnt_set_keys to set the keys Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 1 + drivers/staging/vt6655/key.c | 136 ++++++++++++++++++++++++++++++++++++++++ drivers/staging/vt6655/key.h | 17 +++++ 3 files changed, 154 insertions(+) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 82e18455501c..bc9b81ad5185 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -323,6 +323,7 @@ struct vnt_private { /* mac80211 */ struct ieee80211_hw *hw; struct ieee80211_vif *vif; + unsigned long key_entry_inuse; /* netdev */ struct net_device *dev; diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 02caffb06e59..b2fa8125e29d 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -790,3 +790,139 @@ bool KeybSetAllGroupKey( } return true; } + +int vnt_key_init_table(struct vnt_private *priv) +{ + u32 i; + + for (i = 0; i < MAX_KEY_TABLE; i++) + MACvDisableKeyEntry(priv->PortOffset, i); + + return 0; +} + +static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr, + struct ieee80211_key_conf *key, u32 key_type, u32 mode, + bool onfly_latch) +{ + struct vnt_private *priv = hw->priv; + u8 broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u16 key_mode = 0; + u32 entry = 0; + u8 *bssid; + u8 key_inx = key->keyidx; + u8 i; + + if (mac_addr) + bssid = mac_addr; + else + bssid = &broadcast[0]; + + if (key_type != VNT_KEY_DEFAULTKEY) { + for (i = 0; i < (MAX_KEY_TABLE - 1); i++) { + if (!test_bit(i, &priv->key_entry_inuse)) { + set_bit(i, &priv->key_entry_inuse); + + key->hw_key_idx = i; + entry = key->hw_key_idx; + break; + } + } + } + + switch (key_type) { + /* fallthrough */ + case VNT_KEY_DEFAULTKEY: + /* default key last entry */ + entry = MAX_KEY_TABLE - 1; + key->hw_key_idx = entry; + case VNT_KEY_ALLGROUP: + key_mode |= VNT_KEY_ALLGROUP; + if (onfly_latch) + key_mode |= VNT_KEY_ONFLY_ALL; + case VNT_KEY_GROUP_ADDRESS: + key_mode |= mode; + case VNT_KEY_GROUP: + key_mode |= (mode << 4); + key_mode |= VNT_KEY_GROUP; + break; + case VNT_KEY_PAIRWISE: + key_mode |= mode; + key_inx = 4; + break; + default: + return -EINVAL; + } + + if (onfly_latch) + key_mode |= VNT_KEY_ONFLY; + + if (mode == KEY_CTL_WEP) { + if (key->keylen == WLAN_KEY_LEN_WEP40) + key->key[15] &= 0x7f; + if (key->keylen == WLAN_KEY_LEN_WEP104) + key->key[15] |= 0x80; + } + + MACvSetKeyEntry(priv->PortOffset, key_mode, entry, key_inx, + bssid, (u32 *)key->key, priv->byLocalID); + + return 0; +} + +int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta, + struct ieee80211_vif *vif, struct ieee80211_key_conf *key) +{ + struct ieee80211_bss_conf *conf = &vif->bss_conf; + struct vnt_private *priv = hw->priv; + u8 *mac_addr = NULL; + u8 key_dec_mode = 0; + int ret = 0; + u32 u; + + if (sta) + mac_addr = &sta->addr[0]; + + switch (key->cipher) { + case 0: + for (u = 0 ; u < MAX_KEY_TABLE; u++) + MACvDisableKeyEntry(priv->PortOffset, u); + return ret; + + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + for (u = 0; u < MAX_KEY_TABLE; u++) + MACvDisableKeyEntry(priv->PortOffset, u); + + vnt_set_keymode(hw, mac_addr, + key, VNT_KEY_DEFAULTKEY, KEY_CTL_WEP, true); + + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + + return ret; + case WLAN_CIPHER_SUITE_TKIP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + + key_dec_mode = KEY_CTL_TKIP; + + break; + case WLAN_CIPHER_SUITE_CCMP: + key_dec_mode = KEY_CTL_CCMP; + + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + } + + if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { + vnt_set_keymode(hw, mac_addr, + key, VNT_KEY_PAIRWISE, key_dec_mode, true); + } else { + vnt_set_keymode(hw, mac_addr, + key, VNT_KEY_DEFAULTKEY, key_dec_mode, true); + + vnt_set_keymode(hw, (u8 *)conf->bssid, + key, VNT_KEY_GROUP_ADDRESS, key_dec_mode, true); + } + + return 0; +} diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 44efe18315af..d70ffd6fe728 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -30,6 +30,8 @@ #ifndef __KEY_H__ #define __KEY_H__ +#include + #include "ttype.h" #include "tether.h" #include "80211mgr.h" @@ -53,6 +55,14 @@ #define KEY_CTL_CCMP 0x03 #define KEY_CTL_INVALID 0xFF +#define VNT_KEY_DEFAULTKEY 0x1 +#define VNT_KEY_GROUP_ADDRESS 0x2 +#define VNT_KEY_ALLGROUP 0x4 +#define VNT_KEY_GROUP 0x40 +#define VNT_KEY_PAIRWISE 0x00 +#define VNT_KEY_ONFLY 0x8000 +#define VNT_KEY_ONFLY_ALL 0x4000 + typedef struct tagSKeyItem { bool bKeyValid; unsigned long uKeyLength; @@ -173,4 +183,11 @@ bool KeybSetAllGroupKey( unsigned char byLocalID ); +struct vnt_private; + +int vnt_key_init_table(struct vnt_private *); + +int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta, + struct ieee80211_vif *vif, struct ieee80211_key_conf *key); + #endif // __KEY_H__ -- cgit v1.2.3-59-g8ed1b From 01eec153ab38a476f0f16d849fba77bbf0f95edf Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:38 +0000 Subject: staging: vt6655: mac8021 conversion: add new tx functions vnt_fill_txkey a mac80211 repacement for s_vFillTxKey vnt_generate_fifo_header mac80211 replacement for vGenerateFIFOHeader vnt_beacon_make for making and despatching beacon. vnt_beacon_enable to enabling beacon struct vnt_tx_fifo_head is also added to replace typedef struct tagSTxBufHead that will be removed later. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 1 + drivers/staging/vt6655/rxtx.c | 311 ++++++++++++++++++++++++++++++++++++++++++ drivers/staging/vt6655/rxtx.h | 14 ++ 3 files changed, 326 insertions(+) diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index 8f510c69cee1..9068c3ed696f 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -287,6 +287,7 @@ typedef struct tagTDES1 { STDES1; typedef struct tagDEVICE_TD_INFO { + void *mic_hdr; struct sk_buff *skb; unsigned char *buf; dma_addr_t skb_dma; diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index da7c0a8674b6..99ce5a3d4ece 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -2994,3 +2994,314 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb, // Poll Transmit the adapter MACvTransmit0(pDevice->PortOffset); } + +static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer, + struct ieee80211_key_conf *tx_key, + struct sk_buff *skb, u16 payload_len, + struct vnt_mic_hdr *mic_hdr) +{ + struct ieee80211_key_seq seq; + u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb)); + + /* strip header and icv len from payload */ + payload_len -= ieee80211_get_hdrlen_from_skb(skb); + payload_len -= tx_key->icv_len; + + switch (tx_key->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + memcpy(key_buffer, iv, 3); + memcpy(key_buffer + 3, tx_key->key, tx_key->keylen); + + if (tx_key->keylen == WLAN_KEY_LEN_WEP40) { + memcpy(key_buffer + 8, iv, 3); + memcpy(key_buffer + 11, + tx_key->key, WLAN_KEY_LEN_WEP40); + } + + break; + case WLAN_CIPHER_SUITE_TKIP: + ieee80211_get_tkip_p2k(tx_key, skb, key_buffer); + + break; + case WLAN_CIPHER_SUITE_CCMP: + + if (!mic_hdr) + return; + + mic_hdr->id = 0x59; + mic_hdr->payload_len = cpu_to_be16(payload_len); + ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2); + + ieee80211_get_key_tx_seq(tx_key, &seq); + + memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN); + + if (ieee80211_has_a4(hdr->frame_control)) + mic_hdr->hlen = cpu_to_be16(28); + else + mic_hdr->hlen = cpu_to_be16(22); + + ether_addr_copy(mic_hdr->addr1, hdr->addr1); + ether_addr_copy(mic_hdr->addr2, hdr->addr2); + ether_addr_copy(mic_hdr->addr3, hdr->addr3); + + mic_hdr->frame_control = cpu_to_le16( + le16_to_cpu(hdr->frame_control) & 0xc78f); + mic_hdr->seq_ctrl = cpu_to_le16( + le16_to_cpu(hdr->seq_ctrl) & 0xf); + + if (ieee80211_has_a4(hdr->frame_control)) + ether_addr_copy(mic_hdr->addr4, hdr->addr4); + + memcpy(key_buffer, tx_key->key, WLAN_KEY_LEN_CCMP); + + break; + default: + break; + } +} + +int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, + PSTxDesc head_td, struct sk_buff *skb) +{ + PDEVICE_TD_INFO td_info = head_td->pTDInfo; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_tx_rate *tx_rate = &info->control.rates[0]; + struct ieee80211_rate *rate; + struct ieee80211_key_conf *tx_key; + struct ieee80211_hdr *hdr; + struct vnt_tx_fifo_head *tx_buffer_head = + (struct vnt_tx_fifo_head *)td_info->buf; + u32 frag; + u16 tx_body_size = skb->len, current_rate; + u8 pkt_type; + bool is_pspoll = false; + + memset(tx_buffer_head, 0, sizeof(*tx_buffer_head)); + + hdr = (struct ieee80211_hdr *)(skb->data); + + rate = ieee80211_get_tx_rate(priv->hw, info); + + current_rate = rate->hw_value; + if (priv->wCurrentRate != current_rate && + !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { + priv->wCurrentRate = current_rate; + + RFbSetPower(priv, priv->wCurrentRate, + priv->hw->conf.chandef.chan->hw_value); + } + + if (current_rate > RATE_11M) + pkt_type = (u8)priv->byPacketType; + else + pkt_type = PK_TYPE_11B; + + /*Set fifo controls */ + if (pkt_type == PK_TYPE_11A) + tx_buffer_head->fifo_ctl = 0; + else if (pkt_type == PK_TYPE_11B) + tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11B); + else if (pkt_type == PK_TYPE_11GB) + tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GB); + else if (pkt_type == PK_TYPE_11GA) + tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GA); + + /* generate interrupt */ + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT); + + if (!ieee80211_is_data(hdr->frame_control)) { + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_TMOEN); + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_ISDMA0); + tx_buffer_head->time_stamp = + cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); + } else { + tx_buffer_head->time_stamp = + cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us); + } + + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_NEEDACK); + + if (ieee80211_has_retry(hdr->frame_control)) + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY); + + if (tx_rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) + priv->byPreambleType = PREAMBLE_SHORT; + else + priv->byPreambleType = PREAMBLE_LONG; + + if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS); + + if (ieee80211_has_a4(hdr->frame_control)) { + tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD); + priv->bLongHeader = true; + } + + if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) + is_pspoll = true; + + tx_buffer_head->frag_ctl = + cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10); + + if (info->control.hw_key) { + tx_key = info->control.hw_key; + + switch (info->control.hw_key->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_LEGACY); + break; + case WLAN_CIPHER_SUITE_TKIP: + tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_TKIP); + break; + case WLAN_CIPHER_SUITE_CCMP: + tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES); + default: + break; + } + } + + tx_buffer_head->current_rate = cpu_to_le16(current_rate); + + /* legacy rates TODO use ieee80211_tx_rate */ + if (current_rate >= RATE_18M && ieee80211_is_data(hdr->frame_control)) { + if (priv->byAutoFBCtrl == AUTO_FB_0) + tx_buffer_head->fifo_ctl |= + cpu_to_le16(FIFOCTL_AUTO_FB_0); + else if (priv->byAutoFBCtrl == AUTO_FB_1) + tx_buffer_head->fifo_ctl |= + cpu_to_le16(FIFOCTL_AUTO_FB_1); + + } + + tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG); + + s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, skb->len, + dma_idx, head_td, NULL, (u8 *)skb->data, + false, NULL, is_pspoll, &frag); + + if (info->control.hw_key) { + tx_key = info->control.hw_key; + if (tx_key->keylen > 0) + vnt_fill_txkey(hdr, tx_buffer_head->tx_key, + tx_key, skb, tx_body_size, td_info->mic_hdr); + } + + return 0; +} + +static int vnt_beacon_xmit(struct vnt_private *priv, + struct sk_buff *skb) +{ + struct vnt_tx_short_buf_head *short_head = + (struct vnt_tx_short_buf_head *)priv->tx_beacon_bufs; + struct ieee80211_mgmt *mgmt_hdr = (struct ieee80211_mgmt *) + (priv->tx_beacon_bufs + sizeof(*short_head)); + struct ieee80211_tx_info *info; + u32 frame_size = skb->len + 4; + u16 current_rate; + + memset(priv->tx_beacon_bufs, 0, sizeof(*short_head)); + + if (priv->byBBType == BB_TYPE_11A) { + current_rate = RATE_6M; + + /* Get SignalField,ServiceField,Length */ + vnt_get_phy_field(priv, frame_size, current_rate, + PK_TYPE_11A, &short_head->ab); + + /* Get Duration and TimeStampOff */ + short_head->duration = + cpu_to_le16((u16)s_uGetDataDuration(priv, DATADUR_B, + frame_size, PK_TYPE_11A, current_rate, + false, 0, 0, 1, AUTO_FB_NONE)); + + short_head->time_stamp_off = + vnt_time_stamp_off(priv, current_rate); + } else { + current_rate = RATE_1M; + short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B); + + /* Get SignalField,ServiceField,Length */ + vnt_get_phy_field(priv, frame_size, current_rate, + PK_TYPE_11B, &short_head->ab); + + /* Get Duration and TimeStampOff */ + short_head->duration = + cpu_to_le16((u16)s_uGetDataDuration(priv, DATADUR_B, + frame_size, PK_TYPE_11B, current_rate, + false, 0, 0, 1, AUTO_FB_NONE)); + + short_head->time_stamp_off = + vnt_time_stamp_off(priv, current_rate); + } + + short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT); + + /* Copy Beacon */ + memcpy(mgmt_hdr, skb->data, skb->len); + + /* time stamp always 0 */ + mgmt_hdr->u.beacon.timestamp = 0; + + info = IEEE80211_SKB_CB(skb); + if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)mgmt_hdr; + + hdr->duration_id = 0; + hdr->seq_ctrl = cpu_to_le16(priv->wSeqCounter << 4); + } + + priv->wSeqCounter++; + if (priv->wSeqCounter > 0x0fff) + priv->wSeqCounter = 0; + + priv->wBCNBufLen = sizeof(*short_head) + skb->len; + + MACvSetCurrBCNTxDescAddr(priv->PortOffset, priv->tx_beacon_dma); + + MACvSetCurrBCNLength(priv->PortOffset, priv->wBCNBufLen); + /* Set auto Transmit on */ + MACvRegBitsOn(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); + /* Poll Transmit the adapter */ + MACvTransmitBCN(priv->PortOffset); + + return 0; +} + +int vnt_beacon_make(struct vnt_private *priv, struct ieee80211_vif *vif) +{ + struct sk_buff *beacon; + + beacon = ieee80211_beacon_get(priv->hw, vif); + if (!beacon) + return -ENOMEM; + + if (vnt_beacon_xmit(priv, beacon)) { + ieee80211_free_txskb(priv->hw, beacon); + return -ENODEV; + } + + return 0; +} + +int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif, + struct ieee80211_bss_conf *conf) +{ + int ret; + + VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); + + VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); + + CARDvSetFirstNextTBTT(priv->PortOffset, conf->beacon_int); + + CARDbSetBeaconPeriod(priv, conf->beacon_int); + + ret = vnt_beacon_make(priv, vif); + + return ret; +} diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index 8ee62887dee5..145713dc4110 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -173,6 +173,14 @@ struct vnt_cts_fb { u16 reserved2; } __packed; +struct vnt_tx_fifo_head { + u8 tx_key[WLAN_KEY_LEN_CCMP]; + __le16 fifo_ctl; + __le16 time_stamp; + __le16 frag_ctl; + __le16 current_rate; +} __packed; + struct vnt_tx_short_buf_head { __le16 fifo_ctl; u16 time_stamp; @@ -215,4 +223,10 @@ void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb, CMD_STATUS csMgmt_xmit(struct vnt_private *, PSTxMgmtPacket pPacket); CMD_STATUS csBeacon_xmit(struct vnt_private *, PSTxMgmtPacket pPacket); +int vnt_generate_fifo_header(struct vnt_private *, u32, + PSTxDesc head_td, struct sk_buff *); +int vnt_beacon_make(struct vnt_private *, struct ieee80211_vif *); +int vnt_beacon_enable(struct vnt_private *, struct ieee80211_vif *, + struct ieee80211_bss_conf *); + #endif // __RXTX_H__ -- cgit v1.2.3-59-g8ed1b From cfd9f0d6b173a3410370e9e0d82f56bb795fcf64 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:39 +0000 Subject: staging: vt6655: mac80211 conversion: s_cbFillTxBufHead Covert to handle mac80211 sk_buff data removing fragmentation processing via s_vFillFragParameter and calls to vGenerateMACHeader and s_vSWencryption fragmentation is now handled by mac80211. There is still more todos with this function when legacy net device code have been remove from driver. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 583 ++++-------------------------------------- 1 file changed, 46 insertions(+), 537 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 99ce5a3d4ece..b114a603bfe3 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -144,7 +144,7 @@ s_vGenerateTxParameter( unsigned int cbFrameSize, bool bNeedACK, unsigned int uDMAIdx, - PSEthernetHeader psEthHeader, + void *psEthHeader, unsigned short wCurrentRate ); @@ -1176,7 +1176,7 @@ s_vGenerateTxParameter( unsigned int cbFrameSize, bool bNeedACK, unsigned int uDMAIdx, - PSEthernetHeader psEthHeader, + void *psEthHeader, unsigned short wCurrentRate ) { @@ -1301,46 +1301,26 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, unsigned char *pPacket, bool bNeedEncrypt, PSKeyItem pTransmitKey, - unsigned int uNodeIndex, unsigned int *puMACfragNum) + unsigned int is_pspoll, unsigned int *puMACfragNum) { - unsigned int cbMACHdLen; + PDEVICE_TD_INFO td_info = pHeadTD->pTDInfo; + struct sk_buff *skb = td_info->skb; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct vnt_tx_fifo_head *tx_buffer_head = + (struct vnt_tx_fifo_head *)td_info->buf; + u16 fifo_ctl = le16_to_cpu(tx_buffer_head->fifo_ctl); unsigned int cbFrameSize; - unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS - unsigned int cbFragPayloadSize; - unsigned int cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS - unsigned int cbLastFragPayloadSize; - unsigned int uFragIdx; - unsigned char *pbyPayloadHead; - unsigned char *pbyIVHead; - unsigned char *pbyMacHdr; - unsigned short wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last __le16 uDuration; unsigned char *pbyBuffer; - unsigned int cbIVlen = 0; - unsigned int cbICVlen = 0; - unsigned int cbMIClen = 0; - unsigned int cbFCSlen = 4; - unsigned int cb802_1_H_len = 0; unsigned int uLength = 0; - unsigned int uTmpLen = 0; unsigned int cbMICHDR = 0; - u32 dwMICKey0, dwMICKey1; - u32 dwMIC_Priority; - u32 *pdwMIC_L; - u32 *pdwMIC_R; - u32 dwSafeMIC_L, dwSafeMIC_R; /* Fix "Last Frag Size" < "MIC length". */ - bool bMIC2Frag = false; - unsigned int uMICFragLen = 0; unsigned int uMACfragNum = 1; unsigned int uPadding = 0; unsigned int cbReqCount = 0; - - bool bNeedACK; - bool bRTS; - bool bIsAdhoc; - unsigned char *pbyType; + bool bNeedACK = (bool)(fifo_ctl & FIFOCTL_NEEDACK); + bool bRTS = (bool)(fifo_ctl & FIFOCTL_RTS); PSTxDesc ptdCurr; - PSTxBufHead psTxBufHd = (PSTxBufHead) pbyTxBufferAddr; unsigned int cbHeaderLength = 0; void *pvRrvTime; struct vnt_mic_hdr *pMICHDR; @@ -1348,72 +1328,35 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, void *pvCTS; void *pvTxDataHd; unsigned short wTxBufSize; // FFinfo size - unsigned int uTotalCopyLength = 0; unsigned char byFBOption = AUTO_FB_NONE; - bool bIsWEP256 = false; - PSMgmtObject pMgmt = pDevice->pMgmt; pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) - bNeedACK = false; - else - bNeedACK = true; - bIsAdhoc = true; - } else { - // MSDUs in Infra mode always need ACK - bNeedACK = true; - bIsAdhoc = false; - } - - if (pDevice->bLongHeader) - cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; - else - cbMACHdLen = WLAN_HDR_ADDR3_LEN; + cbFrameSize = skb->len + 4; - if ((bNeedEncrypt == true) && (pTransmitKey != NULL)) { - if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { - cbIVlen = 4; - cbICVlen = 4; - if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) - bIsWEP256 = true; - } - if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - } - if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC + if (info->control.hw_key) { + switch (info->control.hw_key->cipher) { + case WLAN_CIPHER_SUITE_CCMP: cbMICHDR = sizeof(struct vnt_mic_hdr); + default: + break; } + + cbFrameSize += info->control.hw_key->icv_len; + if (pDevice->byLocalID > REV_ID_VT3253_A1) { //MAC Header should be padding 0 to DW alignment. - uPadding = 4 - (cbMACHdLen%4); + uPadding = 4 - (ieee80211_get_hdrlen_from_skb(skb) % 4); uPadding %= 4; } } - cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; - - if ((bNeedACK == false) || - (cbFrameSize < pDevice->wRTSThreshold) || - ((cbFrameSize >= pDevice->wFragmentationThreshold) && (pDevice->wFragmentationThreshold <= pDevice->wRTSThreshold)) -) { - bRTS = false; - } else { - bRTS = true; - psTxBufHd->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY); - } // // Use for AUTO FALL BACK // - if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0) + if (fifo_ctl & FIFOCTL_AUTO_FB_0) byFBOption = AUTO_FB_0; - else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1) + else if (fifo_ctl & FIFOCTL_AUTO_FB_1) byFBOption = AUTO_FB_1; ////////////////////////////////////////////////////// @@ -1507,471 +1450,37 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, } } // Auto Fall Back } - memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize)); - -////////////////////////////////////////////////////////////////// - if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); - } else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) { - dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); - } else { - dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[24]); - dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[28]); - } - // DO Software Michael - MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((unsigned char *)&(psEthHeader->abyDstAddr[0]), 12); - dwMIC_Priority = 0; - MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); - pr_debug("MIC KEY: %X, %X\n", dwMICKey0, dwMICKey1); - } - -/////////////////////////////////////////////////////////////////// - - pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderLength); - pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen); - pbyIVHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding); - - if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == true) && (bIsWEP256 == false)) { - // Fragmentation - // FragThreshold = Fragment size(Hdr+(IV)+fragment payload+(MIC)+(ICV)+FCS) - cbFragmentSize = pDevice->wFragmentationThreshold; - cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen; - //FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS))) - uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize); - cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize; - if (cbLastFragPayloadSize == 0) - cbLastFragPayloadSize = cbFragPayloadSize; - else - uMACfragNum++; - - //[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS] - cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen; - - for (uFragIdx = 0; uFragIdx < uMACfragNum; uFragIdx++) { - if (uFragIdx == 0) { - //========================= - // Start Fragmentation - //========================= - pr_debug("Start Fragmentation...\n"); - wFragType = FRAGCTL_STAFRAG; - - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, - cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); - //Fill DataHead - uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK, - uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate); - // Generate TX MAC Header - vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, - wFragType, uDMAIdx, uFragIdx); - - if (bNeedEncrypt == true) { - //Fill TXKEY - s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (unsigned short)cbFragPayloadSize, (unsigned char *)pMICHDR); - //Fill IV(ExtIV,RSNHDR) - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - } - - // 802.1H - if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { - if ((psEthHeader->wType == TYPE_PKT_IPX) || - (psEthHeader->wType == cpu_to_le16(0xF380))) { - memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); - } else { - memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); - } - pbyType = (unsigned char *)(pbyPayloadHead + 6); - memcpy(pbyType, &(psEthHeader->wType), sizeof(unsigned short)); - cb802_1_H_len = 8; - } - cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize; - //--------------------------- - // S/W or H/W Encryption - //--------------------------- - pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; + td_info->mic_hdr = pMICHDR; - uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len; - //copy TxBufferHeader + MacHeader to desc - memcpy(pbyBuffer, (void *)psTxBufHd, uLength); - - // Copy the Packet into a tx Buffer - memcpy((pbyBuffer + uLength), (pPacket + 14), (cbFragPayloadSize - cb802_1_H_len)); - - uTotalCopyLength += cbFragPayloadSize - cb802_1_H_len; - - if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - pr_debug("Start MIC: %d\n", - cbFragPayloadSize); - MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFragPayloadSize); - - } - - //--------------------------- - // S/W Encryption - //--------------------------- - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { - if (bNeedEncrypt) { - s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), (unsigned short)cbFragPayloadSize); - cbReqCount += cbICVlen; - } - } - - ptdCurr = (PSTxDesc)pHeadTD; - //-------------------- - //1.Set TSR1 & ReqCount in TxDescHead - //2.Set FragCtl in TxBufferHead - //3.Set Frame Control - //4.Set Sequence Control - //5.Get S/W generate FCS - //-------------------- - s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount); - - ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; - ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; - ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; - ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); - pDevice->iTDUsed[uDMAIdx]++; - pHeadTD = ptdCurr->next; - } else if (uFragIdx == (uMACfragNum-1)) { - //========================= - // Last Fragmentation - //========================= - pr_debug("Last Fragmentation...\n"); - - wFragType = FRAGCTL_ENDFRAG; - - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, - cbLastFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); - //Fill DataHead - uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbLastFragmentSize, uDMAIdx, bNeedACK, - uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate); - - // Generate TX MAC Header - vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, - wFragType, uDMAIdx, uFragIdx); - - if (bNeedEncrypt == true) { - //Fill TXKEY - s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (unsigned short)cbLastFragPayloadSize, (unsigned char *)pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - - } - - cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbLastFragPayloadSize; - //--------------------------- - // S/W or H/W Encryption - //--------------------------- - - pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; - - uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; - - //copy TxBufferHeader + MacHeader to desc - memcpy(pbyBuffer, (void *)psTxBufHd, uLength); - - // Copy the Packet into a tx Buffer - if (bMIC2Frag == false) { - memcpy((pbyBuffer + uLength), - (pPacket + 14 + uTotalCopyLength), - (cbLastFragPayloadSize - cbMIClen) -); - //TODO check uTmpLen ! - uTmpLen = cbLastFragPayloadSize - cbMIClen; - - } - if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - pr_debug("LAST: uMICFragLen:%d, cbLastFragPayloadSize:%d, uTmpLen:%d\n", - uMICFragLen, - cbLastFragPayloadSize, - uTmpLen); - - if (bMIC2Frag == false) { - if (uTmpLen != 0) - MIC_vAppend((pbyBuffer + uLength), uTmpLen); - pdwMIC_L = (u32 *)(pbyBuffer + uLength + uTmpLen); - pdwMIC_R = (u32 *)(pbyBuffer + uLength + uTmpLen + 4); - MIC_vGetMIC(pdwMIC_L, pdwMIC_R); - pr_debug("Last MIC:%X, %X\n", - *pdwMIC_L, *pdwMIC_R); - } else { - if (uMICFragLen >= 4) { - memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)), - (cbMIClen - uMICFragLen)); - pr_debug("LAST: uMICFragLen >= 4: %X, %d\n", - *(unsigned char *)((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)), - (cbMIClen - uMICFragLen)); - - } else { - memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_L + uMICFragLen), - (4 - uMICFragLen)); - memcpy((pbyBuffer + uLength + (4 - uMICFragLen)), &dwSafeMIC_R, 4); - pr_debug("LAST: uMICFragLen < 4: %X, %d\n", - *(unsigned char *)((unsigned char *)&dwSafeMIC_R + uMICFragLen - 4), - (cbMIClen - uMICFragLen)); - } - } - MIC_vUnInit(); - } else { - ASSERT(uTmpLen == (cbLastFragPayloadSize - cbMIClen)); - } - - //--------------------------- - // S/W Encryption - //--------------------------- - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { - if (bNeedEncrypt) { - s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (unsigned short)cbLastFragPayloadSize); - cbReqCount += cbICVlen; - } - } - - ptdCurr = (PSTxDesc)pHeadTD; - - //-------------------- - //1.Set TSR1 & ReqCount in TxDescHead - //2.Set FragCtl in TxBufferHead - //3.Set Frame Control - //4.Set Sequence Control - //5.Get S/W generate FCS - //-------------------- - - s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount); - - ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; - ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; - ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; - ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); - pDevice->iTDUsed[uDMAIdx]++; - pHeadTD = ptdCurr->next; - - } else { - //========================= - // Middle Fragmentation - //========================= - pr_debug("Middle Fragmentation...\n"); - - wFragType = FRAGCTL_MIDFRAG; - - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, - cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); - //Fill DataHead - uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK, - uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate); - - // Generate TX MAC Header - vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, - wFragType, uDMAIdx, uFragIdx); - - if (bNeedEncrypt == true) { - //Fill TXKEY - s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (unsigned short)cbFragPayloadSize, (unsigned char *)pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - } - - cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize; - //--------------------------- - // S/W or H/W Encryption - //--------------------------- - - pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; - uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; - - //copy TxBufferHeader + MacHeader to desc - memcpy(pbyBuffer, (void *)psTxBufHd, uLength); - - // Copy the Packet into a tx Buffer - memcpy((pbyBuffer + uLength), - (pPacket + 14 + uTotalCopyLength), - cbFragPayloadSize -); - uTmpLen = cbFragPayloadSize; - - uTotalCopyLength += uTmpLen; - - if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - MIC_vAppend((pbyBuffer + uLength), uTmpLen); - - if (uTmpLen < cbFragPayloadSize) { - bMIC2Frag = true; - uMICFragLen = cbFragPayloadSize - uTmpLen; - ASSERT(uMICFragLen < cbMIClen); - - pdwMIC_L = (u32 *)(pbyBuffer + uLength + uTmpLen); - pdwMIC_R = (u32 *)(pbyBuffer + uLength + uTmpLen + 4); - MIC_vGetMIC(pdwMIC_L, pdwMIC_R); - dwSafeMIC_L = *pdwMIC_L; - dwSafeMIC_R = *pdwMIC_R; - - pr_debug("MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d\n", - uMICFragLen, - cbFragPayloadSize, - uTmpLen); - pr_debug("Fill MIC in Middle frag [%d]\n", - uMICFragLen); - pr_debug("Get MIC:%X, %X\n", - *pdwMIC_L, *pdwMIC_R); - } - pr_debug("Middle frag len: %d\n", - uTmpLen); - - } else { - ASSERT(uTmpLen == (cbFragPayloadSize)); - } - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { - if (bNeedEncrypt) { - s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (unsigned short)cbFragPayloadSize); - cbReqCount += cbICVlen; - } - } - - ptdCurr = (PSTxDesc)pHeadTD; - - //-------------------- - //1.Set TSR1 & ReqCount in TxDescHead - //2.Set FragCtl in TxBufferHead - //3.Set Frame Control - //4.Set Sequence Control - //5.Get S/W generate FCS - //-------------------- - - s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount); - - ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; - ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; - ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; - ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); - pDevice->iTDUsed[uDMAIdx]++; - pHeadTD = ptdCurr->next; - } - } // for (uMACfragNum) - } else { - //========================= - // No Fragmentation - //========================= - wFragType = FRAGCTL_NONFRAG; - - //Set FragCtl in TxBufferHead - psTxBufHd->wFragCtl |= (unsigned short)wFragType; - - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, - cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); - //Fill DataHead - uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, - 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate); - - // Generate TX MAC Header - vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, - wFragType, uDMAIdx, 0); - - if (bNeedEncrypt == true) { - //Fill TXKEY - s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (unsigned short)cbFrameBodySize, (unsigned char *)pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - } - - // 802.1H - if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { - if ((psEthHeader->wType == TYPE_PKT_IPX) || - (psEthHeader->wType == cpu_to_le16(0xF380))) { - memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); - } else { - memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); - } - pbyType = (unsigned char *)(pbyPayloadHead + 6); - memcpy(pbyType, &(psEthHeader->wType), sizeof(unsigned short)); - cb802_1_H_len = 8; - } - - cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen); - //--------------------------- - // S/W or H/W Encryption - //--------------------------- - pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; - uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len; - - //copy TxBufferHeader + MacHeader to desc - memcpy(pbyBuffer, (void *)psTxBufHd, uLength); - - // Copy the Packet into a tx Buffer - memcpy((pbyBuffer + uLength), - (pPacket + 14), - cbFrameBodySize - cb802_1_H_len -); - - if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - pr_debug("Length:%d, %d\n", - cbFrameBodySize - cb802_1_H_len, uLength); - - MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFrameBodySize); - - pdwMIC_L = (u32 *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize); - pdwMIC_R = (u32 *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4); - - MIC_vGetMIC(pdwMIC_L, pdwMIC_R); - MIC_vUnInit(); - - if (pDevice->bTxMICFail == true) { - *pdwMIC_L = 0; - *pdwMIC_R = 0; - pDevice->bTxMICFail = false; - } + memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize)); - pr_debug("uLength: %d, %d\n", uLength, cbFrameBodySize); - pr_debug("cbReqCount:%d, %d, %d, %d\n", - cbReqCount, cbHeaderLength, uPadding, cbIVlen); - pr_debug("MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R); + /* Fill FIFO,RrvTime,RTS,and CTS */ + s_vGenerateTxParameter(pDevice, byPktType, tx_buffer_head, pvRrvTime, pvRTS, pvCTS, + cbFrameSize, bNeedACK, uDMAIdx, hdr, pDevice->wCurrentRate); + /* Fill DataHead */ + uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, + 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate); - } + hdr->duration_id = uDuration; - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { - if (bNeedEncrypt) { - s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), - (unsigned short)(cbFrameBodySize + cbMIClen)); - cbReqCount += cbICVlen; - } - } + cbReqCount = cbHeaderLength + uPadding + cbFrameBodySize; + pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; + uLength = cbHeaderLength + uPadding; - ptdCurr = (PSTxDesc)pHeadTD; + /* Copy the Packet into a tx Buffer */ + memcpy((pbyBuffer + uLength), pPacket, cbFrameBodySize); - ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; - ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; - ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; - ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); - //Set TSR1 & ReqCount in TxDescHead - ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); - ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); + ptdCurr = (PSTxDesc)pHeadTD; - pDevice->iTDUsed[uDMAIdx]++; + ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; + ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; + ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; + ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); + /* Set TSR1 & ReqCount in TxDescHead */ + ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); + ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - } *puMACfragNum = uMACfragNum; return cbHeaderLength; -- cgit v1.2.3-59-g8ed1b From 9c71cb32099a5a3441503555918cf36f5716275d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:40 +0000 Subject: staging: vt6655: dead code remove s_vFillFragParameter. s_vFillFragParameter is nolonger used. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 47 ------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index b114a603bfe3..09df536d9be0 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -148,15 +148,6 @@ s_vGenerateTxParameter( unsigned short wCurrentRate ); -static void s_vFillFragParameter( - struct vnt_private *pDevice, - unsigned char *pbyBuffer, - unsigned int uTxType, - void *pvtdCurr, - unsigned short wFragType, - unsigned int cbReqCount -); - static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, @@ -1257,44 +1248,6 @@ s_vGenerateTxParameter( } } -static -void -s_vFillFragParameter( - struct vnt_private *pDevice, - unsigned char *pbyBuffer, - unsigned int uTxType, - void *pvtdCurr, - unsigned short wFragType, - unsigned int cbReqCount -) -{ - PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer; - - if (uTxType == TYPE_SYNCDMA) { - PSTxSyncDesc ptdCurr = (PSTxSyncDesc)pvtdCurr; - - //Set FIFOCtl & TimeStamp in TxSyncDesc - ptdCurr->m_wFIFOCtl = pTxBufHead->wFIFOCtl; - ptdCurr->m_wTimeStamp = pTxBufHead->wTimeStamp; - //Set TSR1 & ReqCount in TxDescHead - ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation - ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); - else - ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); - } else { - PSTxDesc ptdCurr = (PSTxDesc)pvtdCurr; - //Set TSR1 & ReqCount in TxDescHead - ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation - ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); - else - ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); - } - - pTxBufHead->wFragCtl |= (unsigned short)wFragType;//0x0001; //0000 0000 0000 0001 -} - static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, -- cgit v1.2.3-59-g8ed1b From 7c0496d19159df8b5a537154194a75dcdfca873a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:41 +0000 Subject: staging: vt6655: mac80211 conversion: s_vFillRTSHead convert to using struct ieee80211_hdr Removing PSEthernetHeader Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 91 ++++++------------------------------------- 1 file changed, 12 insertions(+), 79 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 09df536d9be0..a1a594fa10d5 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -127,7 +127,7 @@ s_vFillRTSHead( unsigned int cbFrameLength, bool bNeedAck, bool bDisCRC, - PSEthernetHeader psEthHeader, + struct ieee80211_hdr *hdr, unsigned short wCurrentRate, unsigned char byFBOption ); @@ -789,7 +789,7 @@ s_vFillRTSHead( unsigned int cbFrameLength, bool bNeedAck, bool bDisCRC, - PSEthernetHeader psEthHeader, + struct ieee80211_hdr *hdr, unsigned short wCurrentRate, unsigned char byFBOption ) @@ -841,22 +841,8 @@ s_vFillRTSHead( cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); - - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - ether_addr_copy(buf->data.ra, - psEthHeader->abyDstAddr); - } else { - ether_addr_copy(buf->data.ra, - pDevice->abyBSSID); - } - if (pDevice->op_mode == NL80211_IFTYPE_AP) - ether_addr_copy(buf->data.ta, - pDevice->abyBSSID); - else - ether_addr_copy(buf->data.ta, - psEthHeader->abySrcAddr); - + ether_addr_copy(buf->data.ra, hdr->addr1); + ether_addr_copy(buf->data.ta, hdr->addr2); } else { struct vnt_rts_g_fb *buf = pvRTS; /* Get SignalField, ServiceField & Length */ @@ -909,23 +895,8 @@ s_vFillRTSHead( cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); - - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - ether_addr_copy(buf->data.ra, - psEthHeader->abyDstAddr); - } else { - ether_addr_copy(buf->data.ra, - pDevice->abyBSSID); - } - - if (pDevice->op_mode == NL80211_IFTYPE_AP) - ether_addr_copy(buf->data.ta, - pDevice->abyBSSID); - else - ether_addr_copy(buf->data.ta, - psEthHeader->abySrcAddr); - + ether_addr_copy(buf->data.ra, hdr->addr1); + ether_addr_copy(buf->data.ta, hdr->addr2); } // if (byFBOption == AUTO_FB_NONE) } else if (byPktType == PK_TYPE_11A) { if (byFBOption == AUTO_FB_NONE) { @@ -946,23 +917,8 @@ s_vFillRTSHead( cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); - - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - ether_addr_copy(buf->data.ra, - psEthHeader->abyDstAddr); - } else { - ether_addr_copy(buf->data.ra, - pDevice->abyBSSID); - } - - if (pDevice->op_mode == NL80211_IFTYPE_AP) - ether_addr_copy(buf->data.ta, - pDevice->abyBSSID); - else - ether_addr_copy(buf->data.ta, - psEthHeader->abySrcAddr); - + ether_addr_copy(buf->data.ra, hdr->addr1); + ether_addr_copy(buf->data.ta, hdr->addr2); } else { struct vnt_rts_a_fb *buf = pvRTS; /* Get SignalField, ServiceField & Length */ @@ -991,20 +947,8 @@ s_vFillRTSHead( cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - ether_addr_copy(buf->data.ra, - psEthHeader->abyDstAddr); - } else { - ether_addr_copy(buf->data.ra, - pDevice->abyBSSID); - } - if (pDevice->op_mode == NL80211_IFTYPE_AP) - ether_addr_copy(buf->data.ta, - pDevice->abyBSSID); - else - ether_addr_copy(buf->data.ta, - psEthHeader->abySrcAddr); + ether_addr_copy(buf->data.ra, hdr->addr1); + ether_addr_copy(buf->data.ta, hdr->addr2); } } else if (byPktType == PK_TYPE_11B) { struct vnt_rts_ab *buf = pvRTS; @@ -1023,19 +967,8 @@ s_vFillRTSHead( buf->data.frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - ether_addr_copy(buf->data.ra, - psEthHeader->abyDstAddr); - } else { - ether_addr_copy(buf->data.ra, pDevice->abyBSSID); - } - - if (pDevice->op_mode == NL80211_IFTYPE_AP) - ether_addr_copy(buf->data.ta, pDevice->abyBSSID); - else - ether_addr_copy(buf->data.ta, - psEthHeader->abySrcAddr); + ether_addr_copy(buf->data.ra, hdr->addr1); + ether_addr_copy(buf->data.ta, hdr->addr2); } } -- cgit v1.2.3-59-g8ed1b From 89cf9be6e6e128d64cf0c914ec71db1d25427524 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:42 +0000 Subject: staging: vt6655: mac80211 conversion: s_uFillDataHead add power saving poll Replace variable wCurrentRate with is_pspoll. add current_aid to structure vnt_private which is to be used by mac80211 operations. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 1 + drivers/staging/vt6655/rxtx.c | 64 +++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index bc9b81ad5185..7d521c63a55f 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -324,6 +324,7 @@ struct vnt_private { struct ieee80211_hw *hw; struct ieee80211_vif *vif; unsigned long key_entry_inuse; + u16 current_aid; /* netdev */ struct net_device *dev; diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index a1a594fa10d5..23ee3799e86e 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -169,7 +169,8 @@ s_uFillDataHead( unsigned int cbLastFragmentSize, unsigned int uMACfragNum, unsigned char byFBOption, - unsigned short wCurrentRate + unsigned short wCurrentRate, + bool is_pspoll ); /*--------------------- Export Variables --------------------------*/ @@ -674,7 +675,8 @@ s_uFillDataHead( unsigned int cbLastFragmentSize, unsigned int uMACfragNum, unsigned char byFBOption, - unsigned short wCurrentRate + unsigned short wCurrentRate, + bool is_pspoll ) { @@ -693,15 +695,24 @@ s_uFillDataHead( pDevice->byTopCCKBasicRate, PK_TYPE_11B, &buf->b); - /* Get Duration and TimeStamp */ - buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, - byPktType, wCurrentRate, bNeedAck, uFragIdx, - cbLastFragmentSize, uMACfragNum, - byFBOption)); - buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, - PK_TYPE_11B, pDevice->byTopCCKBasicRate, - bNeedAck, uFragIdx, cbLastFragmentSize, - uMACfragNum, byFBOption)); + if (is_pspoll) { + __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); + + buf->duration_a = dur; + buf->duration_b = dur; + } else { + /* Get Duration and TimeStamp */ + buf->duration_a = + cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, + byPktType, wCurrentRate, bNeedAck, uFragIdx, + cbLastFragmentSize, uMACfragNum, + byFBOption)); + buf->duration_b = + cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, + PK_TYPE_11B, pDevice->byTopCCKBasicRate, + bNeedAck, uFragIdx, cbLastFragmentSize, + uMACfragNum, byFBOption)); + } buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); @@ -755,11 +766,18 @@ s_uFillDataHead( vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, byPktType, &buf->ab); - /* Get Duration and TimeStampOff */ - buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, + if (is_pspoll) { + __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); + + buf->duration = dur; + } else { + /* Get Duration and TimeStampOff */ + buf->duration = + cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); + } buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); return buf->duration; @@ -769,17 +787,27 @@ s_uFillDataHead( /* Get SignalField, ServiceField & Length */ vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, byPktType, &buf->ab); - /* Get Duration and TimeStampOff */ - buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, + + if (is_pspoll) { + __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); + + buf->duration = dur; + } else { + /* Get Duration and TimeStampOff */ + buf->duration = + cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); + } + buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); return buf->duration; } return 0; } + static void s_vFillRTSHead( @@ -1346,7 +1374,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, cbFrameSize, bNeedACK, uDMAIdx, hdr, pDevice->wCurrentRate); /* Fill DataHead */ uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, - 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate); + 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate, is_pspoll); hdr->duration_id = uDuration; @@ -1750,7 +1778,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket) //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, - 0, 0, 1, AUTO_FB_NONE, wCurrentRate); + 0, 0, 1, AUTO_FB_NONE, wCurrentRate, false); pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); @@ -2245,7 +2273,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb, //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, - 0, 0, 1, AUTO_FB_NONE, wCurrentRate); + 0, 0, 1, AUTO_FB_NONE, wCurrentRate, false); pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); -- cgit v1.2.3-59-g8ed1b From 67013f2c0e5811a4fd60c51e3233e1f027d1c1e0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:43 +0000 Subject: staging: vt6655: mac80211 conversion add main mac80211 functions Replace existing vt6655_probe with one converted to mac80211 with the following operations vnt_tx_80211 vnt_start vnt_stop vnt_add_interface vnt_remove_interface vnt_config vnt_bss_info_changed vnt_prepare_multicast vnt_configure vnt_set_key vnt_get_tsf vnt_set_tsf vnt_reset_tsf The following variables are also added. basic_rates mc_list_count mac_hw Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 3 + drivers/staging/vt6655/device_main.c | 754 ++++++++++++++++++++++++++++------- 2 files changed, 621 insertions(+), 136 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 7d521c63a55f..17a36dc4eda1 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -324,7 +324,10 @@ struct vnt_private { struct ieee80211_hw *hw; struct ieee80211_vif *vif; unsigned long key_entry_inuse; + u32 basic_rates; u16 current_aid; + int mc_list_count; + u8 mac_hw; /* netdev */ struct net_device *dev; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 84a35d7d01e8..23d934400783 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -809,142 +809,6 @@ static const struct net_device_ops device_netdev_ops = { .ndo_set_rx_mode = device_set_multi, }; -static int -vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) -{ - static bool bFirst = true; - struct net_device *dev = NULL; - PCHIP_INFO pChip_info = (PCHIP_INFO)ent->driver_data; - struct vnt_private *pDevice; - int rc; - - dev = alloc_etherdev(sizeof(*pDevice)); - - pDevice = netdev_priv(dev); - - if (dev == NULL) { - pr_err(DEVICE_NAME ": allocate net device failed\n"); - return -ENOMEM; - } - - // Chain it all together - SET_NETDEV_DEV(dev, &pcid->dev); - - if (bFirst) { - pr_notice("%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION); - pr_notice("Copyright (c) 2003 VIA Networking Technologies, Inc.\n"); - bFirst = false; - } - - vt6655_init_info(pcid, &pDevice, pChip_info); - pDevice->dev = dev; - - if (pci_enable_device(pcid)) { - device_free_info(pDevice); - return -ENODEV; - } - dev->irq = pcid->irq; - -#ifdef DEBUG - pr_debug("Before get pci_info memaddr is %x\n", pDevice->memaddr); -#endif - if (!device_get_pci_info(pDevice, pcid)) { - pr_err(DEVICE_NAME ": Failed to find PCI device.\n"); - device_free_info(pDevice); - return -ENODEV; - } - -#ifdef DEBUG - - pr_debug("after get pci_info memaddr is %x, io addr is %x,io_size is %d\n", pDevice->memaddr, pDevice->ioaddr, pDevice->io_size); - { - int i; - u32 bar, len; - u32 address[] = { - PCI_BASE_ADDRESS_0, - PCI_BASE_ADDRESS_1, - PCI_BASE_ADDRESS_2, - PCI_BASE_ADDRESS_3, - PCI_BASE_ADDRESS_4, - PCI_BASE_ADDRESS_5, - 0}; - for (i = 0; address[i]; i++) { - pci_read_config_dword(pcid, address[i], &bar); - pr_debug("bar %d is %x\n", i, bar); - if (!bar) { - pr_debug("bar %d not implemented\n", i); - continue; - } - if (bar & PCI_BASE_ADDRESS_SPACE_IO) { - /* This is IO */ - - len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF); - len = len & ~(len - 1); - - pr_debug("IO space: len in IO %x, BAR %d\n", len, i); - } else { - len = bar & 0xFFFFFFF0; - len = ~len + 1; - - pr_debug("len in MEM %x, BAR %d\n", len, i); - } - } - } -#endif - - pDevice->PortOffset = ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size); - - if (pDevice->PortOffset == NULL) { - pr_err(DEVICE_NAME ": Failed to IO remapping ..\n"); - device_free_info(pDevice); - return -ENODEV; - } - - rc = pci_request_regions(pcid, DEVICE_NAME); - if (rc) { - pr_err(DEVICE_NAME ": Failed to find PCI device\n"); - device_free_info(pDevice); - return -ENODEV; - } - - dev->base_addr = pDevice->ioaddr; - // do reset - if (!MACbSoftwareReset(pDevice->PortOffset)) { - pr_err(DEVICE_NAME ": Failed to access MAC hardware..\n"); - device_free_info(pDevice); - return -ENODEV; - } - // initial to reload eeprom - MACvInitialize(pDevice->PortOffset); - MACvReadEtherAddress(pDevice->PortOffset, dev->dev_addr); - - device_get_options(pDevice); - device_set_options(pDevice); - //Mask out the options cannot be set to the chip - pDevice->sOpts.flags &= pChip_info->flags; - - //Enable the chip specified capabilities - pDevice->flags = pDevice->sOpts.flags | (pChip_info->flags & 0xFF000000UL); - pDevice->tx_80211 = device_dma0_tx_80211; - pDevice->sMgmtObj.pAdapter = (void *)pDevice; - pDevice->pMgmt = &(pDevice->sMgmtObj); - - dev->irq = pcid->irq; - dev->netdev_ops = &device_netdev_ops; - - dev->wireless_handlers = &iwctl_handler_def; - - rc = register_netdev(dev); - if (rc) { - pr_err(DEVICE_NAME " Failed to register netdev\n"); - device_free_info(pDevice); - return -ENODEV; - } - device_print_info(pDevice); - pci_set_drvdata(pcid, pDevice); - return 0; -} - static void device_print_info(struct vnt_private *pDevice) { struct net_device *dev = pDevice->dev; @@ -2996,6 +2860,624 @@ static int ethtool_ioctl(struct net_device *dev, void __user *useraddr) return -EOPNOTSUPP; } +static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + PSTxDesc head_td; + u32 dma_idx = TYPE_AC0DMA; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + + if (!ieee80211_is_data(hdr->frame_control)) + dma_idx = TYPE_TXDMA0; + + if (AVAIL_TD(priv, dma_idx) < 1) { + spin_unlock_irqrestore(&priv->lock, flags); + return -ENOMEM; + } + + head_td = priv->apCurrTD[dma_idx]; + + head_td->m_td1TD1.byTCR = (TCR_EDP|TCR_STP); + + head_td->pTDInfo->skb = skb; + + priv->iTDUsed[dma_idx]++; + + /* Take ownership */ + wmb(); + head_td->m_td0TD0.f1Owner = OWNED_BY_NIC; + + /* get Next */ + wmb(); + priv->apCurrTD[dma_idx] = head_td->next; + + spin_unlock_irqrestore(&priv->lock, flags); + + vnt_generate_fifo_header(priv, dma_idx, head_td, skb); + + if (MACbIsRegBitsOn(priv->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) + MACbPSWakeup(priv->PortOffset); + + spin_lock_irqsave(&priv->lock, flags); + + priv->bPWBitOn = false; + + head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB; + + if (dma_idx == TYPE_AC0DMA) + MACvTransmitAC0(priv->PortOffset); + else + MACvTransmit0(priv->PortOffset); + + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static void vnt_tx_80211(struct ieee80211_hw *hw, + struct ieee80211_tx_control *control, + struct sk_buff *skb) +{ + struct vnt_private *priv = hw->priv; + + ieee80211_stop_queues(hw); + + if (vnt_tx_packet(priv, skb)) { + ieee80211_free_txskb(hw, skb); + + ieee80211_wake_queues(hw); + } +} + +static int vnt_start(struct ieee80211_hw *hw) +{ + struct vnt_private *priv = hw->priv; + int ret; + + priv->rx_buf_sz = PKT_BUF_SZ; + if (!device_init_rings(priv)) + return -ENOMEM; + + ret = request_irq(priv->pcid->irq, &device_intr, + IRQF_SHARED, "vt6655", priv); + if (ret) { + dev_dbg(&priv->pcid->dev, "failed to start irq\n"); + return ret; + } + + dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n"); + device_init_rd0_ring(priv); + device_init_rd1_ring(priv); + device_init_defrag_cb(priv); + device_init_td0_ring(priv); + device_init_td1_ring(priv); + + device_init_registers(priv); + + dev_dbg(&priv->pcid->dev, "call MACvIntEnable\n"); + MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE); + + ieee80211_wake_queues(hw); + + return 0; +} + +static void vnt_stop(struct ieee80211_hw *hw) +{ + struct vnt_private *priv = hw->priv; + + ieee80211_stop_queues(hw); + + MACbShutdown(priv->PortOffset); + MACbSoftwareReset(priv->PortOffset); + CARDbRadioPowerOff(priv); + + device_free_td0_ring(priv); + device_free_td1_ring(priv); + device_free_rd0_ring(priv); + device_free_rd1_ring(priv); + device_free_frag_buf(priv); + device_free_rings(priv); + + free_irq(priv->pcid->irq, priv); +} + +static int vnt_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct vnt_private *priv = hw->priv; + + priv->vif = vif; + + switch (vif->type) { + case NL80211_IFTYPE_STATION: + if (priv->bDiversityRegCtlON) + device_init_diversity_timer(priv); + break; + case NL80211_IFTYPE_ADHOC: + MACvRegBitsOff(priv->PortOffset, MAC_REG_RCR, RCR_UNICAST); + + MACvRegBitsOn(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); + + break; + case NL80211_IFTYPE_AP: + MACvRegBitsOff(priv->PortOffset, MAC_REG_RCR, RCR_UNICAST); + + MACvRegBitsOn(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); + + break; + default: + return -EOPNOTSUPP; + } + + priv->op_mode = vif->type; + + return 0; +} + +static void vnt_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct vnt_private *priv = hw->priv; + + switch (vif->type) { + case NL80211_IFTYPE_STATION: + if (priv->bDiversityRegCtlON) { + del_timer(&priv->TimerSQ3Tmax1); + del_timer(&priv->TimerSQ3Tmax2); + del_timer(&priv->TimerSQ3Tmax3); + } + break; + case NL80211_IFTYPE_ADHOC: + MACvRegBitsOff(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); + MACvRegBitsOff(priv->PortOffset, + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); + MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); + break; + case NL80211_IFTYPE_AP: + MACvRegBitsOff(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); + MACvRegBitsOff(priv->PortOffset, + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); + MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); + break; + default: + break; + } + + priv->op_mode = NL80211_IFTYPE_UNSPECIFIED; +} + + +static int vnt_config(struct ieee80211_hw *hw, u32 changed) +{ + struct vnt_private *priv = hw->priv; + struct ieee80211_conf *conf = &hw->conf; + u8 bb_type; + + if (changed & IEEE80211_CONF_CHANGE_PS) { + if (conf->flags & IEEE80211_CONF_PS) + PSvEnablePowerSaving(priv, conf->listen_interval); + else + PSvDisablePowerSaving(priv); + } + + if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || + (conf->flags & IEEE80211_CONF_OFFCHANNEL)) { + set_channel(priv, conf->chandef.chan->hw_value); + + if (conf->chandef.chan->band == IEEE80211_BAND_5GHZ) + bb_type = BB_TYPE_11A; + else + bb_type = BB_TYPE_11G; + + if (priv->byBBType != bb_type) { + priv->byBBType = bb_type; + + CARDbSetPhyParameter(priv, + priv->byBBType, 0, 0, NULL, NULL); + } + } + + if (changed & IEEE80211_CONF_CHANGE_POWER) { + if (priv->byBBType == BB_TYPE_11B) + priv->wCurrentRate = RATE_1M; + else + priv->wCurrentRate = RATE_54M; + + RFbSetPower(priv, priv->wCurrentRate, + conf->chandef.chan->hw_value); + } + + return 0; +} + +static void vnt_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, struct ieee80211_bss_conf *conf, + u32 changed) +{ + struct vnt_private *priv = hw->priv; + + priv->current_aid = conf->aid; + + if (changed & BSS_CHANGED_BSSID) + MACvWriteBSSIDAddress(priv->PortOffset, (u8 *)conf->bssid); + + if (changed & BSS_CHANGED_BASIC_RATES) { + priv->basic_rates = conf->basic_rates; + + CARDvUpdateBasicTopRate(priv); + + dev_dbg(&priv->pcid->dev, + "basic rates %x\n", conf->basic_rates); + } + + if (changed & BSS_CHANGED_ERP_PREAMBLE) { + if (conf->use_short_preamble) { + MACvEnableBarkerPreambleMd(priv->PortOffset); + priv->byPreambleType = true; + } else { + MACvDisableBarkerPreambleMd(priv->PortOffset); + priv->byPreambleType = false; + } + } + + if (changed & BSS_CHANGED_ERP_CTS_PROT) { + if (conf->use_cts_prot) + MACvEnableProtectMD(priv->PortOffset); + else + MACvDisableProtectMD(priv->PortOffset); + } + + if (changed & BSS_CHANGED_ERP_SLOT) { + if (conf->use_short_slot) + priv->bShortSlotTime = true; + else + priv->bShortSlotTime = false; + + vUpdateIFS(priv); + CARDbSetPhyParameter(priv, priv->byBBType, 0, 0, NULL, NULL); + BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]); + } + + if (changed & BSS_CHANGED_TXPOWER) + RFbSetPower(priv, priv->wCurrentRate, + conf->chandef.chan->hw_value); + + if (changed & BSS_CHANGED_BEACON_ENABLED) { + dev_dbg(&priv->pcid->dev, + "Beacon enable %d\n", conf->enable_beacon); + + if (conf->enable_beacon) { + vnt_beacon_enable(priv, vif, conf); + + MACvRegBitsOn(priv, MAC_REG_TCR, TCR_AUTOBCNTX); + } else { + MACvRegBitsOff(priv, MAC_REG_TCR, TCR_AUTOBCNTX); + } + } + + if (changed & BSS_CHANGED_ASSOC && priv->op_mode != NL80211_IFTYPE_AP) { + if (conf->assoc) { + CARDbUpdateTSF(priv, conf->beacon_rate->hw_value, + conf->sync_device_ts, conf->sync_tsf); + + CARDbSetBeaconPeriod(priv, conf->beacon_int); + + CARDvSetFirstNextTBTT(priv->PortOffset, + conf->beacon_int); + } + } +} + +static u64 vnt_prepare_multicast(struct ieee80211_hw *hw, + struct netdev_hw_addr_list *mc_list) +{ + struct vnt_private *priv = hw->priv; + struct netdev_hw_addr *ha; + u64 mc_filter = 0; + u32 bit_nr = 0; + + netdev_hw_addr_list_for_each(ha, mc_list) { + bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + + mc_filter |= 1ULL << (bit_nr & 0x3f); + } + + priv->mc_list_count = mc_list->count; + + return mc_filter; +} + +static void vnt_configure(struct ieee80211_hw *hw, + unsigned int changed_flags, unsigned int *total_flags, u64 multicast) +{ + struct vnt_private *priv = hw->priv; + u8 rx_mode = 0; + + *total_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC; + + VNSvInPortB(priv->PortOffset + MAC_REG_RCR, &rx_mode); + + dev_dbg(&priv->pcid->dev, "rx mode in = %x\n", rx_mode); + + if (changed_flags & FIF_PROMISC_IN_BSS) { + /* unconditionally log net taps */ + if (*total_flags & FIF_PROMISC_IN_BSS) + rx_mode |= RCR_UNICAST; + else + rx_mode &= ~RCR_UNICAST; + } + + if (changed_flags & FIF_ALLMULTI) { + if (*total_flags & FIF_ALLMULTI) { + if (priv->mc_list_count > 2) { + MACvSelectPage1(priv->PortOffset); + + VNSvOutPortD(priv->PortOffset + + MAC_REG_MAR0, 0xffffffff); + VNSvOutPortD(priv->PortOffset + + MAC_REG_MAR0 + 4, 0xffffffff); + + MACvSelectPage0(priv->PortOffset); + } else { + MACvSelectPage1(priv->PortOffset); + + VNSvOutPortD(priv->PortOffset + + MAC_REG_MAR0, (u32)multicast); + VNSvOutPortD(priv->PortOffset + + MAC_REG_MAR0 + 4, + (u32)(multicast >> 32)); + + MACvSelectPage0(priv->PortOffset); + } + + rx_mode |= RCR_MULTICAST | RCR_BROADCAST; + } else { + rx_mode &= ~(RCR_MULTICAST | RCR_BROADCAST); + } + } + + if (changed_flags & (FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC)) { + rx_mode |= RCR_MULTICAST | RCR_BROADCAST; + + if (*total_flags & (FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC)) + rx_mode &= ~RCR_BSSID; + else + rx_mode |= RCR_BSSID; + } + + VNSvOutPortB(priv->PortOffset + MAC_REG_RCR, rx_mode); + + dev_dbg(&priv->pcid->dev, "rx mode out= %x\n", rx_mode); +} + +static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct vnt_private *priv = hw->priv; + + switch (cmd) { + case SET_KEY: + if (vnt_set_keys(hw, sta, vif, key)) + return -EOPNOTSUPP; + break; + case DISABLE_KEY: + if (test_bit(key->hw_key_idx, &priv->key_entry_inuse)) + clear_bit(key->hw_key_idx, &priv->key_entry_inuse); + default: + break; + } + + return 0; +} + +static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct vnt_private *priv = hw->priv; + u64 tsf; + + CARDbGetCurrentTSF(priv->PortOffset, &tsf); + + return tsf; +} + +static void vnt_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u64 tsf) +{ + struct vnt_private *priv = hw->priv; + + CARDvUpdateNextTBTT(priv->PortOffset, tsf, vif->bss_conf.beacon_int); +} + +static void vnt_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct vnt_private *priv = hw->priv; + + /* reset TSF counter */ + VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); +} + +static const struct ieee80211_ops vnt_mac_ops = { + .tx = vnt_tx_80211, + .start = vnt_start, + .stop = vnt_stop, + .add_interface = vnt_add_interface, + .remove_interface = vnt_remove_interface, + .config = vnt_config, + .bss_info_changed = vnt_bss_info_changed, + .prepare_multicast = vnt_prepare_multicast, + .configure_filter = vnt_configure, + .set_key = vnt_set_key, + .get_tsf = vnt_get_tsf, + .set_tsf = vnt_set_tsf, + .reset_tsf = vnt_reset_tsf, +}; + +int vnt_init(struct vnt_private *priv) +{ + SET_IEEE80211_PERM_ADDR(priv->hw, priv->abyCurrentNetAddr); + + if (ieee80211_register_hw(priv->hw)) + return -ENODEV; + + priv->mac_hw = true; + + CARDbRadioPowerOff(priv); + + return 0; +} + +static int +vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) +{ + PCHIP_INFO pChip_info = (PCHIP_INFO)ent->driver_data; + struct vnt_private *priv; + struct ieee80211_hw *hw; + struct wiphy *wiphy; + int rc; + + dev_notice(&pcid->dev, + "%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION); + + dev_notice(&pcid->dev, + "Copyright (c) 2003 VIA Networking Technologies, Inc.\n"); + + hw = ieee80211_alloc_hw(sizeof(*priv), &vnt_mac_ops); + if (!hw) { + dev_err(&pcid->dev, "could not register ieee80211_hw\n"); + return -ENOMEM; + } + + priv = hw->priv; + + vt6655_init_info(pcid, &priv, pChip_info); + + priv->hw = hw; + + SET_IEEE80211_DEV(priv->hw, &pcid->dev); + + if (pci_enable_device(pcid)) { + device_free_info(priv); + return -ENODEV; + } + + dev_dbg(&pcid->dev, + "Before get pci_info memaddr is %x\n", priv->memaddr); + + if (!device_get_pci_info(priv, pcid)) { + dev_err(&pcid->dev, ": Failed to find PCI device.\n"); + device_free_info(priv); + return -ENODEV; + } + +#ifdef DEBUG + dev_dbg(&pcid->dev, + "after get pci_info memaddr is %x, io addr is %x,io_size is %d\n", + priv->memaddr, priv->ioaddr, priv->io_size); + { + int i; + u32 bar, len; + u32 address[] = { + PCI_BASE_ADDRESS_0, + PCI_BASE_ADDRESS_1, + PCI_BASE_ADDRESS_2, + PCI_BASE_ADDRESS_3, + PCI_BASE_ADDRESS_4, + PCI_BASE_ADDRESS_5, + 0}; + for (i = 0; address[i]; i++) { + pci_read_config_dword(pcid, address[i], &bar); + + dev_dbg(&pcid->dev, "bar %d is %x\n", i, bar); + + if (!bar) { + dev_dbg(&pcid->dev, + "bar %d not implemented\n", i); + continue; + } + + if (bar & PCI_BASE_ADDRESS_SPACE_IO) { + /* This is IO */ + + len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xffff); + len = len & ~(len - 1); + + dev_dbg(&pcid->dev, + "IO space: len in IO %x, BAR %d\n", + len, i); + } else { + len = bar & 0xfffffff0; + len = ~len + 1; + + dev_dbg(&pcid->dev, + "len in MEM %x, BAR %d\n", len, i); + } + } + } +#endif + + priv->PortOffset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK, + priv->io_size); + if (!priv->PortOffset) { + dev_err(&pcid->dev, ": Failed to IO remapping ..\n"); + device_free_info(priv); + return -ENODEV; + } + + rc = pci_request_regions(pcid, DEVICE_NAME); + if (rc) { + dev_err(&pcid->dev, ": Failed to find PCI device\n"); + device_free_info(priv); + return -ENODEV; + } + + /* do reset */ + if (!MACbSoftwareReset(priv->PortOffset)) { + dev_err(&pcid->dev, ": Failed to access MAC hardware..\n"); + device_free_info(priv); + return -ENODEV; + } + /* initial to reload eeprom */ + MACvInitialize(priv->PortOffset); + MACvReadEtherAddress(priv->PortOffset, priv->abyCurrentNetAddr); + + device_get_options(priv); + device_set_options(priv); + /* Mask out the options cannot be set to the chip */ + priv->sOpts.flags &= pChip_info->flags; + + /* Enable the chip specified capabilities */ + priv->flags = priv->sOpts.flags | (pChip_info->flags & 0xff000000UL); + priv->tx_80211 = device_dma0_tx_80211; + priv->sMgmtObj.pAdapter = (void *)priv; + priv->pMgmt = &(priv->sMgmtObj); + + wiphy = priv->hw->wiphy; + + wiphy->frag_threshold = FRAG_THRESH_DEF; + wiphy->rts_threshold = RTS_THRESH_DEF; + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP); + + priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | + IEEE80211_HW_REPORTS_TX_ACK_STATUS | + IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_TIMING_BEACON_ONLY; + + priv->hw->max_signal = 100; + + if (vnt_init(priv)) + return -ENODEV; + + device_print_info(priv); + pci_set_drvdata(pcid, priv); + + return 0; +} + /*------------------------------------------------------------------*/ MODULE_DEVICE_TABLE(pci, vt6655_pci_id_table); -- cgit v1.2.3-59-g8ed1b From 3d75b9e235e4cd99cbf44e3d5084c6066299e53d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:44 +0000 Subject: staging: vt6655: mac80211 conversion add channel bands Add rates and channels according to rf type for vnt_init_bands which is a mac80211 replacement for init_channel_table. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 140 +++++++++++++++++++++++++++++++++++ drivers/staging/vt6655/channel.h | 2 + drivers/staging/vt6655/device_main.c | 2 + 3 files changed, 144 insertions(+) diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index a19965fbcc97..4b3c798ff444 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -352,6 +352,146 @@ static struct /*--------------------- Export Functions --------------------------*/ +static struct ieee80211_rate vnt_rates_bg[] = { + { .bitrate = 10, .hw_value = RATE_1M }, + { .bitrate = 20, .hw_value = RATE_2M }, + { .bitrate = 55, .hw_value = RATE_5M }, + { .bitrate = 110, .hw_value = RATE_11M }, + { .bitrate = 60, .hw_value = RATE_6M }, + { .bitrate = 90, .hw_value = RATE_9M }, + { .bitrate = 120, .hw_value = RATE_12M }, + { .bitrate = 180, .hw_value = RATE_18M }, + { .bitrate = 240, .hw_value = RATE_24M }, + { .bitrate = 360, .hw_value = RATE_36M }, + { .bitrate = 480, .hw_value = RATE_48M }, + { .bitrate = 540, .hw_value = RATE_54M }, +}; + +static struct ieee80211_rate vnt_rates_a[] = { + { .bitrate = 60, .hw_value = RATE_6M }, + { .bitrate = 90, .hw_value = RATE_9M }, + { .bitrate = 120, .hw_value = RATE_12M }, + { .bitrate = 180, .hw_value = RATE_18M }, + { .bitrate = 240, .hw_value = RATE_24M }, + { .bitrate = 360, .hw_value = RATE_36M }, + { .bitrate = 480, .hw_value = RATE_48M }, + { .bitrate = 540, .hw_value = RATE_54M }, +}; + +static struct ieee80211_channel vnt_channels_2ghz[] = { + { .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 vnt_channels_5ghz[] = { + { .center_freq = 4915, .hw_value = 15 }, + { .center_freq = 4920, .hw_value = 16 }, + { .center_freq = 4925, .hw_value = 17 }, + { .center_freq = 4935, .hw_value = 18 }, + { .center_freq = 4940, .hw_value = 19 }, + { .center_freq = 4945, .hw_value = 20 }, + { .center_freq = 4960, .hw_value = 21 }, + { .center_freq = 4980, .hw_value = 22 }, + { .center_freq = 5035, .hw_value = 23 }, + { .center_freq = 5040, .hw_value = 24 }, + { .center_freq = 5045, .hw_value = 25 }, + { .center_freq = 5055, .hw_value = 26 }, + { .center_freq = 5060, .hw_value = 27 }, + { .center_freq = 5080, .hw_value = 28 }, + { .center_freq = 5170, .hw_value = 29 }, + { .center_freq = 5180, .hw_value = 30 }, + { .center_freq = 5190, .hw_value = 31 }, + { .center_freq = 5200, .hw_value = 32 }, + { .center_freq = 5210, .hw_value = 33 }, + { .center_freq = 5220, .hw_value = 34 }, + { .center_freq = 5230, .hw_value = 35 }, + { .center_freq = 5240, .hw_value = 36 }, + { .center_freq = 5260, .hw_value = 37 }, + { .center_freq = 5280, .hw_value = 38 }, + { .center_freq = 5300, .hw_value = 39 }, + { .center_freq = 5320, .hw_value = 40 }, + { .center_freq = 5500, .hw_value = 41 }, + { .center_freq = 5520, .hw_value = 42 }, + { .center_freq = 5540, .hw_value = 43 }, + { .center_freq = 5560, .hw_value = 44 }, + { .center_freq = 5580, .hw_value = 45 }, + { .center_freq = 5600, .hw_value = 46 }, + { .center_freq = 5620, .hw_value = 47 }, + { .center_freq = 5640, .hw_value = 48 }, + { .center_freq = 5660, .hw_value = 49 }, + { .center_freq = 5680, .hw_value = 50 }, + { .center_freq = 5700, .hw_value = 51 }, + { .center_freq = 5745, .hw_value = 52 }, + { .center_freq = 5765, .hw_value = 53 }, + { .center_freq = 5785, .hw_value = 54 }, + { .center_freq = 5805, .hw_value = 55 }, + { .center_freq = 5825, .hw_value = 56 } +}; + +static struct ieee80211_supported_band vnt_supported_2ghz_band = { + .channels = vnt_channels_2ghz, + .n_channels = ARRAY_SIZE(vnt_channels_2ghz), + .bitrates = vnt_rates_bg, + .n_bitrates = ARRAY_SIZE(vnt_rates_bg), +}; + +static struct ieee80211_supported_band vnt_supported_5ghz_band = { + .channels = vnt_channels_5ghz, + .n_channels = ARRAY_SIZE(vnt_channels_5ghz), + .bitrates = vnt_rates_a, + .n_bitrates = ARRAY_SIZE(vnt_rates_a), +}; + +void vnt_init_bands(struct vnt_private *priv) +{ + struct ieee80211_channel *ch; + int i; + + switch (priv->byRFType) { + case RF_AIROHA7230: + case RF_UW2452: + case RF_NOTHING: + default: + ch = vnt_channels_5ghz; + + for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) { + ch[i].max_power = 0x3f; + ch[i].flags = IEEE80211_CHAN_NO_HT40; + } + + priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &vnt_supported_5ghz_band; + /* fallthrough */ + case RF_RFMD2959: + case RF_AIROHA: + case RF_AL2230S: + case RF_UW2451: + case RF_VT3226: + ch = vnt_channels_2ghz; + + for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) { + ch[i].max_power = 0x3f; + ch[i].flags = IEEE80211_CHAN_NO_HT40; + } + + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &vnt_supported_2ghz_band; + break; + } +} + /** * is_channel_valid() - Is Country Channel Valid * @ChanneIndex: defined as VT3253 MAC channel: diff --git a/drivers/staging/vt6655/channel.h b/drivers/staging/vt6655/channel.h index 4f44c8a3d3cf..0d3e1f121759 100644 --- a/drivers/staging/vt6655/channel.h +++ b/drivers/staging/vt6655/channel.h @@ -33,6 +33,8 @@ typedef struct tagSChannelTblElement { unsigned char byMAP; } SChannelTblElement, *PSChannelTblElement; +void vnt_init_bands(struct vnt_private *); + bool is_channel_valid(unsigned int CountryCode); void init_channel_table(void *pDeviceHandler); unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 23d934400783..054841b0663a 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -3320,6 +3320,8 @@ int vnt_init(struct vnt_private *priv) { SET_IEEE80211_PERM_ADDR(priv->hw, priv->abyCurrentNetAddr); + vnt_init_bands(priv); + if (ieee80211_register_hw(priv->hw)) return -ENODEV; -- cgit v1.2.3-59-g8ed1b From 000fe0f53433a4dea2738c3cb34e19d2ef952092 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:45 +0000 Subject: staging: vt6655: mac80211 conversion replace suspend resume functions add vt6655_suspend and vt6655_resume remove viawget_suspend and viawget_resume. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 104 ++++++++++++----------------------- 1 file changed, 34 insertions(+), 70 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 054841b0663a..b0f94a804ceb 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -274,8 +274,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); #ifdef CONFIG_PM static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); -static int viawget_suspend(struct pci_dev *pcid, pm_message_t state); -static int viawget_resume(struct pci_dev *pcid); static struct notifier_block device_notifier = { .notifier_call = device_notify_reboot, .next = NULL, @@ -3482,6 +3480,37 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) /*------------------------------------------------------------------*/ +#ifdef CONFIG_PM +static int vt6655_suspend(struct pci_dev *pcid, pm_message_t state) +{ + struct vnt_private *priv = pci_get_drvdata(pcid); + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + + pci_save_state(pcid); + + MACbShutdown(priv->PortOffset); + + pci_disable_device(pcid); + pci_set_power_state(pcid, pci_choose_state(pcid, state)); + + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static int vt6655_resume(struct pci_dev *pcid) +{ + + pci_set_power_state(pcid, PCI_D0); + pci_enable_wake(pcid, PCI_D0, 0); + pci_restore_state(pcid); + + return 0; +} +#endif + MODULE_DEVICE_TABLE(pci, vt6655_pci_id_table); static struct pci_driver device_driver = { @@ -3490,8 +3519,8 @@ static struct pci_driver device_driver = { .probe = vt6655_probe, .remove = vt6655_remove, #ifdef CONFIG_PM - .suspend = viawget_suspend, - .resume = viawget_resume, + .suspend = vt6655_suspend, + .resume = vt6655_resume, #endif }; @@ -3532,75 +3561,10 @@ device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p) for_each_pci_dev(pdev) { if (pci_dev_driver(pdev) == &device_driver) { if (pci_get_drvdata(pdev)) - viawget_suspend(pdev, PMSG_HIBERNATE); + vt6655_suspend(pdev, PMSG_HIBERNATE); } } } return NOTIFY_DONE; } - -static int -viawget_suspend(struct pci_dev *pcid, pm_message_t state) -{ - int power_status; // to silence the compiler - - struct vnt_private *pDevice = pci_get_drvdata(pcid); - PSMgmtObject pMgmt = pDevice->pMgmt; - - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - pci_save_state(pcid); - del_timer(&pDevice->sTimerCommand); - del_timer(&pMgmt->sTimerSecondCallback); - pDevice->cbFreeCmdQueue = CMD_Q_SIZE; - pDevice->uCmdDequeueIdx = 0; - pDevice->uCmdEnqueueIdx = 0; - pDevice->bCmdRunning = false; - MACbShutdown(pDevice->PortOffset); - MACvSaveContext(pDevice->PortOffset, pDevice->abyMacContext); - pDevice->bLinkPass = false; - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; - pci_disable_device(pcid); - power_status = pci_set_power_state(pcid, pci_choose_state(pcid, state)); - spin_unlock_irq(&pDevice->lock); - return 0; -} - -static int -viawget_resume(struct pci_dev *pcid) -{ - struct vnt_private *pDevice = pci_get_drvdata(pcid); - PSMgmtObject pMgmt = pDevice->pMgmt; - int power_status; // to silence the compiler - - power_status = pci_set_power_state(pcid, PCI_D0); - power_status = pci_enable_wake(pcid, PCI_D0, 0); - pci_restore_state(pcid); - if (netif_running(pDevice->dev)) { - spin_lock_irq(&pDevice->lock); - MACvRestoreContext(pDevice->PortOffset, pDevice->abyMacContext); - device_init_registers(pDevice); - if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS - pMgmt->sNodeDBTable[0].bActive = false; - pDevice->bLinkPass = false; - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - // In Adhoc, BSS state set back to started. - pMgmt->eCurrState = WMAC_STATE_STARTED; - } else { - pMgmt->eCurrMode = WMAC_MODE_STANDBY; - pMgmt->eCurrState = WMAC_STATE_IDLE; - } - } - init_timer(&pMgmt->sTimerSecondCallback); - init_timer(&pDevice->sTimerCommand); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); - spin_unlock_irq(&pDevice->lock); - } - return 0; -} - #endif -- cgit v1.2.3-59-g8ed1b From bc5d431c9b11f39c81dea25748e18014f3e210f4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:46 +0000 Subject: staging: vt6655: mac80211 conversion: device_print_info remove netdevice. use dev_info for device name and pcid->irq for irq number. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index b0f94a804ceb..5ece18401ed4 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -809,12 +809,11 @@ static const struct net_device_ops device_netdev_ops = { static void device_print_info(struct vnt_private *pDevice) { - struct net_device *dev = pDevice->dev; + dev_info(&pDevice->pcid->dev, "%s\n", get_chip_name(pDevice->chip_id)); - pr_info("%s: %s\n", dev->name, get_chip_name(pDevice->chip_id)); - pr_info("%s: MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n", - dev->name, dev->dev_addr, (unsigned long)pDevice->ioaddr, - (unsigned long)pDevice->PortOffset, pDevice->dev->irq); + dev_info(&pDevice->pcid->dev, "MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n", + pDevice->abyCurrentNetAddr, (unsigned long)pDevice->ioaddr, + (unsigned long)pDevice->PortOffset, pDevice->pcid->irq); } static void vt6655_init_info(struct pci_dev *pcid, -- cgit v1.2.3-59-g8ed1b From e70abceb05a36665c3378619217c35acffb14ca4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:47 +0000 Subject: staging: vt6655: mac80211 conversion: changes to device_intr Remove net device code. Remove current measure code and function s_vCompleteCurrentMeasure and switch code which are now handled by mac80211 Change beaconing to mac80211. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 175 ++--------------------------------- 1 file changed, 8 insertions(+), 167 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 5ece18401ed4..69c98c2989c4 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -400,45 +400,6 @@ device_set_options(struct vnt_private *pDevice) (int)pDevice->bDiversityRegCtlON); } -static void s_vCompleteCurrentMeasure(struct vnt_private *pDevice, - unsigned char byResult) -{ - unsigned int ii; - unsigned long dwDuration = 0; - unsigned char byRPI0 = 0; - - for (ii = 1; ii < 8; ii++) { - pDevice->dwRPIs[ii] *= 255; - dwDuration |= *((unsigned short *)(pDevice->pCurrMeasureEID->sReq.abyDuration)); - dwDuration <<= 10; - pDevice->dwRPIs[ii] /= dwDuration; - pDevice->abyRPIs[ii] = (unsigned char)pDevice->dwRPIs[ii]; - byRPI0 += pDevice->abyRPIs[ii]; - } - pDevice->abyRPIs[0] = (0xFF - byRPI0); - - if (pDevice->uNumOfMeasureEIDs == 0) { - VNTWIFIbMeasureReport(pDevice->pMgmt, - true, - pDevice->pCurrMeasureEID, - byResult, - pDevice->byBasicMap, - pDevice->byCCAFraction, - pDevice->abyRPIs - ); - } else { - VNTWIFIbMeasureReport(pDevice->pMgmt, - false, - pDevice->pCurrMeasureEID, - byResult, - pDevice->byBasicMap, - pDevice->byCCAFraction, - pDevice->abyRPIs - ); - CARDbStartMeasure(pDevice, pDevice->pCurrMeasureEID++, pDevice->uNumOfMeasureEIDs); - } -} - // // Initialisation of MAC & BBP registers // @@ -2056,14 +2017,11 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { static irqreturn_t device_intr(int irq, void *dev_instance) { - struct net_device *dev = dev_instance; - struct vnt_private *pDevice = netdev_priv(dev); + struct vnt_private *pDevice = dev_instance; int max_count = 0; unsigned long dwMIBCounter = 0; - PSMgmtObject pMgmt = pDevice->pMgmt; unsigned char byOrgPageSel = 0; int handled = 0; - unsigned char byData = 0; int ii = 0; unsigned long flags; @@ -2106,94 +2064,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) device_error(pDevice, pDevice->dwIsr); } - if (pDevice->byLocalID > REV_ID_VT3253_B1) { - if (pDevice->dwIsr & ISR_MEASURESTART) { - // 802.11h measure start - pDevice->byOrgChannel = pDevice->byCurrentCh; - VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byOrgRCR)); - VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, (RCR_RXALLTYPE | RCR_UNICAST | RCR_BROADCAST | RCR_MULTICAST | RCR_WPAERR)); - MACvSelectPage1(pDevice->PortOffset); - VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR0, &(pDevice->dwOrgMAR0)); - VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR4, &(pDevice->dwOrgMAR4)); - MACvSelectPage0(pDevice->PortOffset); - //xxxx - if (set_channel(pDevice, pDevice->pCurrMeasureEID->sReq.byChannel)) { - pDevice->bMeasureInProgress = true; - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_READY); - MACvSelectPage0(pDevice->PortOffset); - pDevice->byBasicMap = 0; - pDevice->byCCAFraction = 0; - for (ii = 0; ii < 8; ii++) - pDevice->dwRPIs[ii] = 0; - - } else { - // can not measure because set channel fail - // clear measure control - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); - s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_INCAPABLE); - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); - MACvSelectPage0(pDevice->PortOffset); - } - } - if (pDevice->dwIsr & ISR_MEASUREEND) { - // 802.11h measure end - pDevice->bMeasureInProgress = false; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR); - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4); - VNSvInPortB(pDevice->PortOffset + MAC_REG_MSRBBSTS, &byData); - pDevice->byBasicMap |= (byData >> 4); - VNSvInPortB(pDevice->PortOffset + MAC_REG_CCAFRACTION, &pDevice->byCCAFraction); - VNSvInPortB(pDevice->PortOffset + MAC_REG_MSRCTL, &byData); - // clear measure control - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); - MACvSelectPage0(pDevice->PortOffset); - set_channel(pDevice, pDevice->byOrgChannel); - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); - MACvSelectPage0(pDevice->PortOffset); - if (byData & MSRCTL_FINISH) { - // measure success - s_vCompleteCurrentMeasure(pDevice, 0); - } else { - // can not measure because not ready before end of measure time - s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_LATE); - } - } - if (pDevice->dwIsr & ISR_QUIETSTART) { - do { - ; - } while (!CARDbStartQuiet(pDevice)); - } - } - if (pDevice->dwIsr & ISR_TBTT) { - if (pDevice->bEnableFirstQuiet) { - pDevice->byQuietStartCount--; - if (pDevice->byQuietStartCount == 0) { - pDevice->bEnableFirstQuiet = false; - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); - MACvSelectPage0(pDevice->PortOffset); - } - } - if (pDevice->bChannelSwitch && - (pDevice->op_mode == NL80211_IFTYPE_STATION)) { - pDevice->byChannelSwitchCount--; - if (pDevice->byChannelSwitchCount == 0) { - pDevice->bChannelSwitch = false; - set_channel(pDevice, pDevice->byNewChannel); - VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel); - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); - MACvSelectPage0(pDevice->PortOffset); - CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL); - - } - } if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) { if ((pDevice->bUpdateBBVGA) && pDevice->bLinkPass && (pDevice->uCurrRSSI != 0)) { long ldBm; @@ -2234,10 +2105,11 @@ static irqreturn_t device_intr(int irq, void *dev_instance) if (pDevice->bEnablePSMode) PSbIsNextTBTTWakeUp((void *)pDevice); - if ((pDevice->op_mode == NL80211_IFTYPE_AP) || - (pDevice->op_mode == NL80211_IFTYPE_ADHOC)) { + if ((pDevice->op_mode == NL80211_IFTYPE_AP || + pDevice->op_mode == NL80211_IFTYPE_ADHOC) && + pDevice->vif->bss_conf.enable_beacon) { MACvOneShotTimer1MicroSec(pDevice->PortOffset, - (pMgmt->wIBSSBeaconPeriod - MAKE_BEACON_RESERVED) << 10); + (pDevice->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10); } /* TODO: adhoc PS mode */ @@ -2250,34 +2122,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) pDevice->cbBeaconBufReadySetCnt = 0; } - if (pDevice->op_mode == NL80211_IFTYPE_AP) { - if (pMgmt->byDTIMCount > 0) { - pMgmt->byDTIMCount--; - pMgmt->sNodeDBTable[0].bRxPSPoll = false; - } else { - if (pMgmt->byDTIMCount == 0) { - // check if mutltcast tx bufferring - pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1; - pMgmt->sNodeDBTable[0].bRxPSPoll = true; - bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL); - } - } - } pDevice->bBeaconSent = true; - - if (pDevice->bChannelSwitch) { - pDevice->byChannelSwitchCount--; - if (pDevice->byChannelSwitchCount == 0) { - pDevice->bChannelSwitch = false; - set_channel(pDevice, pDevice->byNewChannel); - VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel); - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); - MACvSelectPage0(pDevice->PortOffset); - CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL); - } - } - } if (pDevice->dwIsr & ISR_RXDMA0) @@ -2293,14 +2138,10 @@ static irqreturn_t device_intr(int irq, void *dev_instance) max_count += device_tx_srv(pDevice, TYPE_AC0DMA); if (pDevice->dwIsr & ISR_SOFTTIMER1) { - if (pDevice->op_mode == NL80211_IFTYPE_AP) { - if (pDevice->bShortSlotTime) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); - else - pMgmt->wCurrCapInfo &= ~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1)); + if (pDevice->vif) { + if (pDevice->vif->bss_conf.enable_beacon) + vnt_beacon_make(pDevice, pDevice->vif); } - bMgrPrepareBeaconToSend(pDevice, pMgmt); - pDevice->byCntMeasure = 0; } MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); -- cgit v1.2.3-59-g8ed1b From 59918beada362e47de3b7a7467573ab001528077 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:48 +0000 Subject: staging: vt6655: mac80211 conversion: device_tx_srv tx and add report rates vnt_int_report_rate reports backs tx rate and is replacment for STAvUpdateTDStatCounter and BSSvUpdateNodeTxCounter. Replacing existing code. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 166 ++++++++++++++++++----------------- 1 file changed, 85 insertions(+), 81 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 69c98c2989c4..a888c268042d 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1208,19 +1208,84 @@ bool device_alloc_frag_buf(struct vnt_private *pDevice, return true; } +static const u8 fallback_rate0[5][5] = { + {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M}, + {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M}, + {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M}, + {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M}, + {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M} +}; + +static const u8 fallback_rate1[5][5] = { + {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M}, + {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M}, + {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M}, + {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M}, + {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M} +}; + +static int vnt_int_report_rate(struct vnt_private *priv, + PDEVICE_TD_INFO context, u8 tsr0, u8 tsr1) +{ + struct vnt_tx_fifo_head *fifo_head; + struct ieee80211_tx_info *info; + struct ieee80211_rate *rate; + u16 fb_option; + u8 tx_retry = (tsr0 & TSR0_NCR); + s8 idx; + + if (!context) + return -ENOMEM; + + if (!context->skb) + return -EINVAL; + + fifo_head = (struct vnt_tx_fifo_head *)context->buf; + fb_option = (le16_to_cpu(fifo_head->fifo_ctl) & + (FIFOCTL_AUTO_FB_0 | FIFOCTL_AUTO_FB_1)); + + info = IEEE80211_SKB_CB(context->skb); + idx = info->control.rates[0].idx; + + if (fb_option && !(tsr1 & TSR1_TERR)) { + u8 tx_rate; + u8 retry = tx_retry; + + rate = ieee80211_get_tx_rate(priv->hw, info); + tx_rate = rate->hw_value - RATE_18M; + + if (retry > 4) + retry = 4; + + if (fb_option & FIFOCTL_AUTO_FB_0) + tx_rate = fallback_rate0[tx_rate][retry]; + else if (fb_option & FIFOCTL_AUTO_FB_1) + tx_rate = fallback_rate1[tx_rate][retry]; + + if (info->band == IEEE80211_BAND_5GHZ) + idx = tx_rate - RATE_6M; + else + idx = tx_rate; + } + + ieee80211_tx_info_clear_status(info); + + info->status.rates[0].count = tx_retry; + + if (!(tsr1 & TSR1_TERR)) { + info->status.rates[0].idx = idx; + info->flags |= IEEE80211_TX_STAT_ACK; + } + + return 0; +} + static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) { PSTxDesc pTD; - bool bFull = false; int works = 0; unsigned char byTsr0; unsigned char byTsr1; - unsigned int uFrameSize, uFIFOHeaderSize; - PSTxBufHead pTxBufHead; - struct net_device_stats *pStats = &pDevice->dev->stats; - struct sk_buff *skb; - unsigned int uNodeIndex; - PSMgmtObject pMgmt = pDevice->pMgmt; for (pTD = pDevice->apTailTD[uIdx]; pDevice->iTDUsed[uIdx] > 0; pTD = pTD->next) { if (pTD->m_td0TD0.f1Owner == OWNED_BY_NIC) @@ -1234,22 +1299,8 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) //Only the status of first TD in the chain is correct if (pTD->m_td1TD1.byTCR & TCR_STP) { if ((pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) { - uFIFOHeaderSize = pTD->pTDInfo->dwHeaderLength; - uFrameSize = pTD->pTDInfo->dwReqCount - uFIFOHeaderSize; - pTxBufHead = (PSTxBufHead) (pTD->pTDInfo->buf); - // Update the statistics based on the Transmit status - // now, we DONT check TSR0_CDH - - STAvUpdateTDStatCounter(&pDevice->scStatistic, - byTsr0, byTsr1, - (unsigned char *)(pTD->pTDInfo->buf + uFIFOHeaderSize), - uFrameSize, uIdx); - - BSSvUpdateNodeTxCounter(pDevice, - byTsr0, byTsr1, - (unsigned char *)(pTD->pTDInfo->buf), - uFIFOHeaderSize - ); + + vnt_int_report_rate(pDevice, pTD->pTDInfo, byTsr0, byTsr1); if (!(byTsr1 & TSR1_TERR)) { if (byTsr0 != 0) { @@ -1257,28 +1308,9 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) (int)uIdx, byTsr1, byTsr0); } - if ((pTxBufHead->wFragCtl & FRAGCTL_ENDFRAG) != FRAGCTL_NONFRAG) - pDevice->s802_11Counter.TransmittedFragmentCount++; - - pStats->tx_packets++; - pStats->tx_bytes += pTD->pTDInfo->skb->len; } else { pr_debug(" Tx[%d] dropped & tsr1[%02X] tsr0[%02X]\n", (int)uIdx, byTsr1, byTsr0); - pStats->tx_errors++; - pStats->tx_dropped++; - } - } - - if ((pTD->pTDInfo->byFlags & TD_FLAGS_PRIV_SKB) != 0) { - if (pDevice->bEnableHostapd) { - pr_debug("tx call back netif..\n"); - skb = pTD->pTDInfo->skb; - skb->dev = pDevice->apdev; - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); } } @@ -1287,47 +1319,14 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) pr_debug(" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X]\n", (int)uIdx, byTsr1, byTsr0); } - - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && - (pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)) { - unsigned short wAID; - unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - - skb = pTD->pTDInfo->skb; - if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data), &uNodeIndex)) { - if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) { - skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb); - pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++; - // set tx map - wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID; - pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; - pTD->pTDInfo->byFlags &= ~(TD_FLAGS_NETIF_SKB); - pr_debug("tx_srv:tx fail re-queue sta index= %d, QueCnt= %d\n", - (int)uNodeIndex, - pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt); - pStats->tx_errors--; - pStats->tx_dropped--; - } - } - } } device_free_tx_buf(pDevice, pTD); pDevice->iTDUsed[uIdx]--; - } - } - - if (uIdx == TYPE_AC0DMA) { - // RESERV_AC0DMA reserved for relay - if (AVAIL_TD(pDevice, uIdx) < RESERV_AC0DMA) { - bFull = true; - pr_debug(" AC0DMA is Full = %d\n", - pDevice->iTDUsed[uIdx]); + /* Make sure queue is available */ + if (AVAIL_TD(pDevice, uIdx)) + ieee80211_wake_queues(pDevice->hw); } - if (netif_queue_stopped(pDevice->dev) && !bFull) - netif_wake_queue(pDevice->dev); - } pDevice->apTailTD[uIdx] = pTD; @@ -1360,7 +1359,9 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc) PCI_DMA_TODEVICE); } - if ((pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) + if (pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) + ieee80211_tx_status_irqsafe(pDevice->hw, skb); + else dev_kfree_skb_irq(skb); pTDInfo->skb_dma = 0; @@ -2065,8 +2066,11 @@ static irqreturn_t device_intr(int irq, void *dev_instance) } if (pDevice->dwIsr & ISR_TBTT) { - if (pDevice->op_mode != NL80211_IFTYPE_ADHOC) { - if ((pDevice->bUpdateBBVGA) && pDevice->bLinkPass && (pDevice->uCurrRSSI != 0)) { + if (pDevice->vif && + pDevice->op_mode != NL80211_IFTYPE_ADHOC) { + if (pDevice->bUpdateBBVGA && + pDevice->vif->bss_conf.assoc && + pDevice->uCurrRSSI) { long ldBm; RFvRSSITodBm(pDevice, (unsigned char) pDevice->uCurrRSSI, &ldBm); -- cgit v1.2.3-59-g8ed1b From b956374239481f62014bfb27f7ecb0f804e5029b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:49 +0000 Subject: staging: vt6655: mac80211 conversion: changes to set channel Remove call to sChannelTbl, the channel under mac80211 is always valid. CARDbSetPhyParameter is nolonger set here. RFbSetPower is now set on byBBType Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 4b3c798ff444..237969673f2e 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -665,16 +665,6 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) if (pDevice->byCurrentCh == uConnectionChannel) return bResult; - if (!sChannelTbl[uConnectionChannel].bValid) - return false; - - if ((uConnectionChannel > CB_MAX_CHANNEL_24G) && - (pDevice->eCurrentPHYType != PHY_TYPE_11A)) { - CARDbSetPhyParameter(pDevice, PHY_TYPE_11A, 0, 0, NULL, NULL); - } else if ((uConnectionChannel <= CB_MAX_CHANNEL_24G) && - (pDevice->eCurrentPHYType == PHY_TYPE_11A)) { - CARDbSetPhyParameter(pDevice, PHY_TYPE_11G, 0, 0, NULL, NULL); - } /* clear NAV */ MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV); @@ -702,7 +692,7 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) MACvSelectPage0(pDevice->PortOffset); } - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) + if (pDevice->byBBType == BB_TYPE_11B) RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh); else RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh); -- cgit v1.2.3-59-g8ed1b From e99d357c6f87c8ab0c118150e533443be8e4988b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:50 +0000 Subject: staging: vt6655: mac80211 conversion: enable power saving Convert PSvEnablePowerSaving and PSvEnablePowerSaving Remove mgmt->wCurrAID and use pDevice->current_aid We nolonger send the PSbSendNullPacket. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/power.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 08241b917777..fe33bb2fd7ff 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -73,8 +73,7 @@ PSvEnablePowerSaving( ) { struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned short wAID = pMgmt->wCurrAID | BIT14 | BIT15; + u16 wAID = pDevice->current_aid | BIT(14) | BIT(15); // set period of power up before TBTT VNSvOutPortW(pDevice->PortOffset + MAC_REG_PWBT, C_PWBT); @@ -83,7 +82,9 @@ PSvEnablePowerSaving( VNSvOutPortW(pDevice->PortOffset + MAC_REG_AIDATIM, wAID); } else { // set ATIM Window +#if 0 /* TODO atim window */ MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow); +#endif } // Set AutoSleep MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCFG, PSCFG_AUTOSLEEP); @@ -95,22 +96,15 @@ PSvEnablePowerSaving( MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN); // first time set listen next beacon MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN); - pMgmt->wCountToWakeUp = wListenInterval; } else { // always listen beacon MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN); - pMgmt->wCountToWakeUp = 0; } // enable power saving hw function MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN); pDevice->bEnablePSMode = true; - /* We don't send null pkt in ad hoc mode since beacon will handle this. */ - if (pDevice->op_mode != NL80211_IFTYPE_ADHOC && - pDevice->op_mode == NL80211_IFTYPE_STATION) - PSbSendNullPacket(pDevice); - pDevice->bPWBitOn = true; pr_debug("PS:Power Saving Mode Enable...\n"); } @@ -143,9 +137,6 @@ PSvDisablePowerSaving( pDevice->bEnablePSMode = false; - if (pDevice->op_mode == NL80211_IFTYPE_STATION) - PSbSendNullPacket(pDevice); - pDevice->bPWBitOn = false; } -- cgit v1.2.3-59-g8ed1b From 0614a0e84d3f4c3c6180b8c5ec91bb40954015f3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:51 +0000 Subject: staging: vt6655: mac80211 conversion: changes to CARDbSetPhyParameter CARDbSetPhyParameter appears to use two different strutures to find supported rates. Remove PWLAN_IE_SUPP_RATES and use basic_rates to find rates supported. mac80211 now sets bShortSlotTime, bBarkerPreambleMd and byPreambleType remove these. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 61 ++++++++----------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index eae67897a615..090c28618ec9 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -74,15 +74,6 @@ #define WAIT_BEACON_TX_DOWN_TMO 3 /* Times */ -/* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M */ -static unsigned char abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; -/* 6M, 9M, 12M, 48M */ -static unsigned char abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; -/* 6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M */ -static unsigned char abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; -/* 1M, 2M, 5M, 11M, */ -static unsigned char abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - /*--------------------- Static Variables --------------------------*/ static const unsigned short cwRXBCNTSFOff[MAX_RATE] = @@ -384,14 +375,10 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, unsigned char bySIFS = 0; unsigned char byDIFS = 0; unsigned char byData; - PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs; - PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs; + int i; /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ if (ePHYType == PHY_TYPE_11A) { - if (pSupportRates == NULL) - pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA; - if (pDevice->byRFType == RF_AIROHA7230) { /* AL7230 use single PAPE and connect to PAPE_2.4G */ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); @@ -419,9 +406,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, byDIFS = C_SIFS_A + 2*C_SLOT_SHORT; byCWMaxMin = 0xA4; } else if (ePHYType == PHY_TYPE_11B) { - if (pSupportRates == NULL) - pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB; - MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B); if (pDevice->byRFType == RF_AIROHA7230) { pDevice->abyBBVGA[0] = 0x1C; @@ -445,10 +429,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; byCWMaxMin = 0xA5; } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ - if (pSupportRates == NULL) { - pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG; - pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG; - } MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); if (pDevice->byRFType == RF_AIROHA7230) { pDevice->abyBBVGA[0] = 0x1C; @@ -468,32 +448,22 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, } BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x08); bySIFS = C_SIFS_BG; - if (VNTWIFIbIsShortSlotTime(wCapInfo)) { + + if (pDevice->bShortSlotTime) { bySlot = C_SLOT_SHORT; byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT; } else { bySlot = C_SLOT_LONG; byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; } - if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) - byCWMaxMin = 0xA4; - else - byCWMaxMin = 0xA5; - if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) { - pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField); - if (pDevice->bProtectMode) - MACvEnableProtectMD(pDevice->PortOffset); - else - MACvDisableProtectMD(pDevice->PortOffset); + byCWMaxMin = 0xa4; - } - if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) { - pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField); - if (pDevice->bBarkerPreambleMd) - MACvEnableBarkerPreambleMd(pDevice->PortOffset); - else - MACvDisableBarkerPreambleMd(pDevice->PortOffset); + for (i = RATE_54M; i >= RATE_6M; i--) { + if (pDevice->basic_rates & ((u32)(0x1 << i))) { + byCWMaxMin |= 0x1; + break; + } } } @@ -526,10 +496,6 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, if (pDevice->bySlot != bySlot) { pDevice->bySlot = bySlot; VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot); - if (pDevice->bySlot == C_SLOT_SHORT) - pDevice->bShortSlotTime = true; - else - pDevice->bShortSlotTime = false; BBvSetShortSlotTime(pDevice); } @@ -537,14 +503,9 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->byCWMaxMin = byCWMaxMin; VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin); } - if (VNTWIFIbIsShortPreamble(wCapInfo)) - pDevice->byPreambleType = pDevice->byShortPreamble; - else - pDevice->byPreambleType = 0; - s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates); - pDevice->eCurrentPHYType = ePHYType; - /* set for NDIS OID_802_11SUPPORTED_RATES */ + s_vSetRSPINF(pDevice, ePHYType, NULL, NULL); + return true; } -- cgit v1.2.3-59-g8ed1b From c01ef29e38362518e269e35c3bce090a3d60fa5b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:52 +0000 Subject: staging: vt6655: mac80211 conversion: card.c use basic_rates Use basic_rates to find cck and ofdm rates. wBasicRate will be removed later. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 090c28618ec9..a1330bce63ff 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -1457,7 +1457,7 @@ static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice, unsigned int ui = (unsigned int) wRateIdx; while (ui > RATE_1M) { - if (pDevice->wBasicRate & ((unsigned short)1 << ui)) + if (pDevice->basic_rates & ((u32)0x1 << ui)) return (unsigned short)ui; ui--; @@ -1482,7 +1482,7 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, { unsigned int ui = (unsigned int) wRateIdx; - pr_debug("BASIC RATE: %X\n", pDevice->wBasicRate); + pr_debug("BASIC RATE: %X\n", pDevice->basic_rates); if (!CARDbIsOFDMinBasicRate((void *)pDevice)) { pr_debug("CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); @@ -1491,7 +1491,7 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, return wRateIdx; } while (ui > RATE_11M) { - if (pDevice->wBasicRate & ((unsigned short)1 << ui)) { + if (pDevice->basic_rates & ((u32)0x1 << ui)) { pr_debug("CARDwGetOFDMControlRate : %d\n", ui); return (unsigned short)ui; } -- cgit v1.2.3-59-g8ed1b From 3fbbb75f55ffeb0d37dd27c55ea88f6d9514dac4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:53 +0000 Subject: staging: vt6655: CARDbSetPhyParameter replace s_vSetRSPINF with CARDvSetRSPINF Removing s_vSetRSPINF Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 120 +----------------------------------------- 1 file changed, 1 insertion(+), 119 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index a1330bce63ff..72896c1b842d 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -198,124 +198,6 @@ s_vCalculateOFDMRParameter( } } -/* - * Description: Set RSPINF - * - * Parameters: - * In: - * pDevice - The adapter to be set - * Out: - * none - * - * Return Value: None. - */ -static -void -s_vSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, - void *pvSupportRateIEs, void *pvExtSupportRateIEs) -{ - union vnt_phy_field_swap phy; - unsigned char byTxRate = 0, byRsvTime = 0; /* For OFDM */ - - /* Set to Page1 */ - MACvSelectPage1(pDevice->PortOffset); - - /* RSPINF_b_1 */ - vnt_get_phy_field(pDevice, - 14, - VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs), - PK_TYPE_11B, - &phy.field_read); - - /* swap over to get correct write order */ - swap(phy.swap[0], phy.swap[1]); - - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, phy.field_write); - - /* RSPINF_b_2 */ - vnt_get_phy_field(pDevice, 14, - VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs), - PK_TYPE_11B, &phy.field_read); - - swap(phy.swap[0], phy.swap[1]); - - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, phy.field_write); - - /* RSPINF_b_5 */ - vnt_get_phy_field(pDevice, 14, - VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs), - PK_TYPE_11B, &phy.field_read); - - swap(phy.swap[0], phy.swap[1]); - - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, phy.field_write); - - /* RSPINF_b_11 */ - vnt_get_phy_field(pDevice, 14, - VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs), - PK_TYPE_11B, &phy.field_read); - - swap(phy.swap[0], phy.swap[1]); - - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write); - - /* RSPINF_a_6 */ - s_vCalculateOFDMRParameter(RATE_6M, - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_9 */ - s_vCalculateOFDMRParameter(RATE_9M, - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_12 */ - s_vCalculateOFDMRParameter(RATE_12M, - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_18 */ - s_vCalculateOFDMRParameter(RATE_18M, - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_24 */ - s_vCalculateOFDMRParameter(RATE_24M, - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_36 */ - s_vCalculateOFDMRParameter( - VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs), - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_48 */ - s_vCalculateOFDMRParameter( - VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs), - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_54 */ - s_vCalculateOFDMRParameter( - VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs), - ePHYType, - &byTxRate, - &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); - /* RSPINF_a_72 */ - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); - /* Set to Page0 */ - MACvSelectPage0(pDevice->PortOffset); -} - /*--------------------- Export Functions --------------------------*/ /* @@ -504,7 +386,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin); } - s_vSetRSPINF(pDevice, ePHYType, NULL, NULL); + CARDvSetRSPINF(pDevice, ePHYType); return true; } -- cgit v1.2.3-59-g8ed1b From 1d6d3c1a62012653df86979658db3b86ef94b63b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:54 +0000 Subject: staging: vt6655: mac80211 conversion: device_init_registers remove legacy code Remove pMgmt, byCurrentCh, VNTWIFIbConfigPhyMode, eEncryptionStatus and netif_stop_queue. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index a888c268042d..77d81b339158 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -412,7 +412,6 @@ static void device_init_registers(struct vnt_private *pDevice) unsigned char byCCKPwrdBm = 0; unsigned char byOFDMPwrdBm = 0; int zonetype = 0; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); MACbShutdown(pDevice->PortOffset); BBvSoftwareReset(pDevice->PortOffset); @@ -616,8 +615,6 @@ static void device_init_registers(struct vnt_private *pDevice) (unsigned char)(ii + EEP_OFS_OFDMA_PWR_dBm)); } - init_channel_table((void *)pDevice); - if (pDevice->byLocalID > REV_ID_VT3253_B1) { MACvSelectPage1(pDevice->PortOffset); @@ -652,8 +649,6 @@ static void device_init_registers(struct vnt_private *pDevice) BBvSetRxAntennaMode(pDevice->PortOffset, pDevice->byRxAntennaMode); BBvSetTxAntennaMode(pDevice->PortOffset, pDevice->byTxAntennaMode); - pDevice->byCurrentCh = 0; - /* Set BB and packet type at the same time. */ /* Set Short Slot Time, xIFS, and RSPINF. */ if (pDevice->uConnectionRate == RATE_AUTO) @@ -661,10 +656,6 @@ static void device_init_registers(struct vnt_private *pDevice) else pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - /* default G Mode */ - VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_11G); - VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_AUTO); - pDevice->bRadioOff = false; pDevice->byRadioCtl = SROMbyReadEmbedded(pDevice->PortOffset, @@ -685,8 +676,6 @@ static void device_init_registers(struct vnt_private *pDevice) if (pDevice->bHWRadioOff || pDevice->bRadioControlOff) CARDbRadioPowerOff(pDevice); - pMgmt->eScanType = WMAC_SCAN_PASSIVE; - /* get Permanent network address */ SROMvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr); pr_debug("Network address = %pM\n", pDevice->abyCurrentNetAddr); @@ -699,16 +688,12 @@ static void device_init_registers(struct vnt_private *pDevice) if (pDevice->byLocalID <= REV_ID_VT3253_A1) MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_WPAERR); - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - /* Turn On Rx DMA */ MACvReceive0(pDevice->PortOffset); MACvReceive1(pDevice->PortOffset); /* start the adapter */ MACvStart(pDevice->PortOffset); - - netif_stop_queue(pDevice->dev); } static void device_init_diversity_timer(struct vnt_private *pDevice) -- cgit v1.2.3-59-g8ed1b From 14e5300631fa504058315cc74da66ce18ed41e11 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:55 +0000 Subject: staging: vt6655: mac80211 conversion: device_free_info Remove net device code and add mac80211 unregister code. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 77d81b339158..451b608ca1f1 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -806,31 +806,20 @@ static bool device_get_pci_info(struct vnt_private *pDevice, static void device_free_info(struct vnt_private *pDevice) { - struct net_device *dev = pDevice->dev; - - ASSERT(pDevice); -//2008-0714-01by chester - device_release_WPADEV(pDevice); - -//2008-07-21-01by MikeLiu -//unregister wpadev - if (wpa_set_wpadev(pDevice, 0) != 0) - pr_err("unregister wpadev fail?\n"); + if (!pDevice) + return; -#ifdef HOSTAP - if (dev) - vt6655_hostap_set_hostapd(pDevice, 0, 0); -#endif - if (dev) - unregister_netdev(dev); + if (pDevice->mac_hw) + ieee80211_unregister_hw(pDevice->hw); if (pDevice->PortOffset) iounmap(pDevice->PortOffset); if (pDevice->pcid) pci_release_regions(pDevice->pcid); - if (dev) - free_netdev(dev); + + if (pDevice->hw) + ieee80211_free_hw(pDevice->hw); } static bool device_init_rings(struct vnt_private *pDevice) -- cgit v1.2.3-59-g8ed1b From 1f7a081abfc1a5e452a40d727fa35f1402fe705e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:56 +0000 Subject: staging: vt6655: switch driver over to mac80211 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Kconfig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/Kconfig b/drivers/staging/vt6655/Kconfig index c3ba693a8cad..77cfc708c516 100644 --- a/drivers/staging/vt6655/Kconfig +++ b/drivers/staging/vt6655/Kconfig @@ -1,8 +1,6 @@ config VT6655 tristate "VIA Technologies VT6655 support" - depends on PCI && WLAN && m - select WIRELESS_EXT - select WEXT_PRIV + depends on PCI && MAC80211 && m ---help--- This is a vendor-written driver for VIA VT6655. -- cgit v1.2.3-59-g8ed1b From 64fea6e455fe5b5d939df73dee078087be40f4d3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:57 +0000 Subject: staging: vt6655: phy type same as bb type To maintain functionality typedef enum _CARD_PHY_TYPE should have the same values as typedef enum _VIA_PKT_TYPE TODO both these types need merging. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index e5bde0920553..cb95a0de5bf6 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -53,10 +53,10 @@ #define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G) typedef enum _CARD_PHY_TYPE { - PHY_TYPE_AUTO, + PHY_TYPE_11A = 0, PHY_TYPE_11B, PHY_TYPE_11G, - PHY_TYPE_11A + PHY_TYPE_AUTO } CARD_PHY_TYPE, *PCARD_PHY_TYPE; typedef enum _CARD_PKT_TYPE { -- cgit v1.2.3-59-g8ed1b From 7e5d88d89b22baa3fa69b0f92e1780d1a9e865d6 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:58 +0000 Subject: staging: vt6655: mac80211 conversion: device_error remove legacy functions Remove netif_stop_queue, bCmdRunning and timer functions Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 451b608ca1f1..0bd2ca8b49b5 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1313,10 +1313,6 @@ static void device_error(struct vnt_private *pDevice, unsigned short status) if (status & ISR_FETALERR) { dev_err(&pDevice->pcid->dev, "Hardware fatal error\n"); - netif_stop_queue(pDevice->dev); - del_timer(&pDevice->sTimerCommand); - del_timer(&(pDevice->pMgmt->sTimerSecondCallback)); - pDevice->bCmdRunning = false; MACbShutdown(pDevice->PortOffset); return; } -- cgit v1.2.3-59-g8ed1b From b4bdf94d7dfb0146241185abafb26c3920cb7b33 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:43:59 +0000 Subject: staging: vt6655: vt6655_probe remove management pointers All these pointers are now dead. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 0bd2ca8b49b5..d7dd002f8daf 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -3266,8 +3266,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) /* Enable the chip specified capabilities */ priv->flags = priv->sOpts.flags | (pChip_info->flags & 0xff000000UL); priv->tx_80211 = device_dma0_tx_80211; - priv->sMgmtObj.pAdapter = (void *)priv; - priv->pMgmt = &(priv->sMgmtObj); wiphy = priv->hw->wiphy; -- cgit v1.2.3-59-g8ed1b From e24c235b5d5edf55a4d9413c01bc08f2138c4f42 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:00 +0000 Subject: staging: vt6655: mac80211 conversion: PSbIsNextTBTTWakeUp convert to mac80211 Wake up to listen to next beacon when struct ieee80211_conf -> listen_interval == 1 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/power.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index fe33bb2fd7ff..53718026910c 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -327,21 +327,14 @@ PSbIsNextTBTTWakeUp( ) { struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; + struct ieee80211_hw *hw = pDevice->hw; + struct ieee80211_conf *conf = &hw->conf; bool bWakeUp = false; - if (pMgmt->wListenInterval >= 2) { - if (pMgmt->wCountToWakeUp == 0) - pMgmt->wCountToWakeUp = pMgmt->wListenInterval; - - pMgmt->wCountToWakeUp--; - - if (pMgmt->wCountToWakeUp == 1) { - // Turn on wake up to listen next beacon - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN); - bWakeUp = true; - } - + if (conf->listen_interval == 1) { + /* Turn on wake up to listen next beacon */ + MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN); + bWakeUp = true; } return bWakeUp; -- cgit v1.2.3-59-g8ed1b From b0a08a8a73ce698e5d8d0b724a1e88aa1c2becff Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:01 +0000 Subject: staging: vt6655: MACvSetDefaultKeyEntry replace WLAN_WEP104_KEYLEN with WLAN_KEY_LEN_WEP40 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index e3b0b7f7ca85..a347f3963934 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -1526,7 +1526,7 @@ void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen, VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); } dwData = *pdwKey; - if (uKeyLen == WLAN_WEP104_KEYLEN) + if (uKeyLen == WLAN_KEY_LEN_WEP40) dwData |= 0x80000000; VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+3); -- cgit v1.2.3-59-g8ed1b From 837a38f71b40c9dcb86facbd08dc7d683bd675f1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:02 +0000 Subject: staging: vt6655: baseband.c replace BIT0 with BIT(0) Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index b8a64c07b97a..8adeea4da0ec 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2116,7 +2116,7 @@ bool BBbVT3253Init(struct vnt_private *pDevice) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]); VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23); - MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); + MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0)); } pDevice->abyBBVGA[0] = 0x18; pDevice->abyBBVGA[1] = 0x0A; @@ -2149,7 +2149,7 @@ bool BBbVT3253Init(struct vnt_private *pDevice) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); - MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); + MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0)); pDevice->abyBBVGA[0] = 0x14; pDevice->abyBBVGA[1] = 0x0A; @@ -2455,7 +2455,7 @@ BBvPowerSaveModeON(void __iomem *dwIoBase) unsigned char byOrgData; BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); - byOrgData |= BIT0; + byOrgData |= BIT(0); BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData); } @@ -2477,7 +2477,7 @@ BBvPowerSaveModeOFF(void __iomem *dwIoBase) unsigned char byOrgData; BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); - byOrgData &= ~(BIT0); + byOrgData &= ~(BIT(0)); BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData); } -- cgit v1.2.3-59-g8ed1b From f038ad0e72614970ddcc088a7685f93d27d373b6 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:03 +0000 Subject: staging: vt6655: s_vGenerateTxParameter remove unused cbMACHdLen Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 23ee3799e86e..9beabea88b3f 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1132,7 +1132,6 @@ s_vGenerateTxParameter( unsigned short wCurrentRate ) { - unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24 unsigned short wFifoCtl; bool bDisCRC = false; unsigned char byFBOption = AUTO_FB_NONE; @@ -1150,9 +1149,6 @@ s_vGenerateTxParameter( else if (wFifoCtl & FIFOCTL_AUTO_FB_1) byFBOption = AUTO_FB_1; - if (pDevice->bLongHeader) - cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; - if (!pvRrvTime) return; -- cgit v1.2.3-59-g8ed1b From 10d6f1b743961b191ff6347d3a5b5f8801a638fe Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:04 +0000 Subject: staging: vt6655: device_init_registers replace spin lock Use spin_lock_irqsave and spin_unlock_irqrestore. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index d7dd002f8daf..c5eca1075d3a 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -406,6 +406,7 @@ device_set_options(struct vnt_private *pDevice) static void device_init_registers(struct vnt_private *pDevice) { + unsigned long flags; unsigned int ii; unsigned char byValue; unsigned char byValue1; @@ -439,11 +440,11 @@ static void device_init_registers(struct vnt_private *pDevice) /* Get Local ID */ VNSvInPortB(pDevice->PortOffset + MAC_REG_LOCALID, &pDevice->byLocalID); - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); SROMvReadAllContents(pDevice->PortOffset, pDevice->abyEEPROM); - spin_unlock_irq(&pDevice->lock); + spin_unlock_irqrestore(&pDevice->lock, flags); /* Get Channel range */ pDevice->byMinChannel = 1; -- cgit v1.2.3-59-g8ed1b From a9c049b86d937fb1be9eb485353b44e47b4fc41c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:05 +0000 Subject: staging: vt6655: baseband.c timers replace spin lock Use spin_lock_irqsave and spin_unlock_irqrestore in functions TimerSQ3CallBack and TimerState1CallBack Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 8adeea4da0ec..c7ad927084d7 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2786,9 +2786,11 @@ TimerSQ3CallBack( ) { struct vnt_private *pDevice = hDeviceContext; + unsigned long flags; pr_debug("TimerSQ3CallBack...\n"); - spin_lock_irq(&pDevice->lock); + + spin_lock_irqsave(&pDevice->lock, flags); pr_debug("3.[%08x][%08x], %d\n", (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1, @@ -2803,7 +2805,7 @@ TimerSQ3CallBack( add_timer(&pDevice->TimerSQ3Tmax3); add_timer(&pDevice->TimerSQ3Tmax2); - spin_unlock_irq(&pDevice->lock); + spin_unlock_irqrestore(&pDevice->lock, flags); } /*+ @@ -2830,10 +2832,12 @@ TimerState1CallBack( ) { struct vnt_private *pDevice = hDeviceContext; + unsigned long flags; pr_debug("TimerState1CallBack...\n"); - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); + if (pDevice->uDiversityCnt < pDevice->ulDiversityMValue/100) { s_vChangeAntenna(pDevice); pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); @@ -2864,5 +2868,6 @@ TimerState1CallBack( } pDevice->byAntennaState = 0; BBvClearAntDivSQ3Value(pDevice); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); } -- cgit v1.2.3-59-g8ed1b From 9aa5bedaa0e154cca34aba853589dbc0ceb272bb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:06 +0000 Subject: staging: vt6655: fifo & frag control remove big endian values Endian conversion now happens at run time only little endian values are valid. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index 9068c3ed696f..b59405bca606 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -118,37 +118,7 @@ */ #define CB_MAX_TX_ABORT_RETRY 3 -#ifdef __BIG_ENDIAN - /* WMAC definition FIFO Control */ -#define FIFOCTL_AUTO_FB_1 0x0010 -#define FIFOCTL_AUTO_FB_0 0x0008 -#define FIFOCTL_GRPACK 0x0004 -#define FIFOCTL_11GA 0x0003 -#define FIFOCTL_11GB 0x0002 -#define FIFOCTL_11B 0x0001 -#define FIFOCTL_11A 0x0000 -#define FIFOCTL_RTS 0x8000 -#define FIFOCTL_ISDMA0 0x4000 -#define FIFOCTL_GENINT 0x2000 -#define FIFOCTL_TMOEN 0x1000 -#define FIFOCTL_LRETRY 0x0800 -#define FIFOCTL_CRCDIS 0x0400 -#define FIFOCTL_NEEDACK 0x0200 -#define FIFOCTL_LHEAD 0x0100 - -/* WMAC definition Frag Control */ -#define FRAGCTL_AES 0x0003 -#define FRAGCTL_TKIP 0x0002 -#define FRAGCTL_LEGACY 0x0001 -#define FRAGCTL_NONENCRYPT 0x0000 -#define FRAGCTL_ENDFRAG 0x0300 -#define FRAGCTL_MIDFRAG 0x0200 -#define FRAGCTL_STAFRAG 0x0100 -#define FRAGCTL_NONFRAG 0x0000 - -#else - #define FIFOCTL_AUTO_FB_1 0x1000 #define FIFOCTL_AUTO_FB_0 0x0800 #define FIFOCTL_GRPACK 0x0400 @@ -175,8 +145,6 @@ #define FRAGCTL_STAFRAG 0x0001 #define FRAGCTL_NONFRAG 0x0000 -#endif - #define TYPE_TXDMA0 0 #define TYPE_AC0DMA 1 #define TYPE_ATIMDMA 2 -- cgit v1.2.3-59-g8ed1b From f218f40d48bf0e5e1968c7ecaa44a2d1a7dc61c8 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:07 +0000 Subject: staging: vt6655: vnt_rx_data: uCurrRSSI should have the value of *rssi Fixes issue of byBBVGANew is wrong in device_intr Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 036bbb0f4824..11153ef0dd95 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -1382,7 +1382,7 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, RFvRSSITodBm(priv, *rssi, &rx_dbm); priv->byBBPreEDRSSI = (u8)rx_dbm + 1; - priv->uCurrRSSI = priv->byBBPreEDRSSI; + priv->uCurrRSSI = *rssi; skb_pull(skb, 4); skb_trim(skb, frame_size); -- cgit v1.2.3-59-g8ed1b From d855802b8d45cf36622a640b71b58437cfee41d0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:08 +0000 Subject: staging: vt6655: don't update bUpdateBBVGA when off channel Check flag conf IEEE80211_CONF_OFFCHANNEL so that RSSI doesn't swing wildly on scanning. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c5eca1075d3a..968ea9aa0efb 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -2040,6 +2040,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) if (pDevice->vif && pDevice->op_mode != NL80211_IFTYPE_ADHOC) { if (pDevice->bUpdateBBVGA && + !(pDevice->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) && pDevice->vif->bss_conf.assoc && pDevice->uCurrRSSI) { long ldBm; -- cgit v1.2.3-59-g8ed1b From c7b14ea09632cb92658d7b1f758de2abd71c00f3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:44:09 +0000 Subject: staging: vt6655: reset tsf on dissociation Ensuring that tsf counter does not run while idle. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 968ea9aa0efb..07d2101613d8 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -2980,6 +2980,11 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, CARDvSetFirstNextTBTT(priv->PortOffset, conf->beacon_int); + } else { + VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, + TFTCTL_TSFCNTRST); + VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, + TFTCTL_TSFCNTREN); } } } -- cgit v1.2.3-59-g8ed1b From f4cf678fd783b7ed6c423b3ac8c1c6faded95986 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:19 +0000 Subject: staging: vt6655: deadcode remove zone file operations and vntconfiguration.dat These are now all handled by mac80211. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 - drivers/staging/vt6655/device_main.c | 113 +--------------------------- drivers/staging/vt6655/vntconfiguration.dat | 1 - 3 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 drivers/staging/vt6655/vntconfiguration.dat diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 17a36dc4eda1..214f73fc9def 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -750,6 +750,4 @@ bool device_dma0_xmit(struct vnt_private *pDevice, struct sk_buff *skb, unsigned int uNodeIndex); bool device_alloc_frag_buf(struct vnt_private *pDevice, PSDeFragControlBlock pDeF); -int Config_FileOperation(struct vnt_private *pDevice, - bool fwrite, unsigned char *Parameter); #endif diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 07d2101613d8..12fa63c73f01 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -303,8 +303,6 @@ static void device_free_rd0_ring(struct vnt_private *pDevice); static void device_free_rd1_ring(struct vnt_private *pDevice); static void device_free_rings(struct vnt_private *pDevice); static void device_free_frag_buf(struct vnt_private *pDevice); -static int Config_FileGetParameter(unsigned char *string, - unsigned char *dest, unsigned char *source); /*--------------------- Export Variables --------------------------*/ @@ -412,7 +410,6 @@ static void device_init_registers(struct vnt_private *pDevice) unsigned char byValue1; unsigned char byCCKPwrdBm = 0; unsigned char byOFDMPwrdBm = 0; - int zonetype = 0; MACbShutdown(pDevice->PortOffset); BBvSoftwareReset(pDevice->PortOffset); @@ -517,41 +514,6 @@ static void device_init_registers(struct vnt_private *pDevice) /* zonetype initial */ pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; - zonetype = Config_FileOperation(pDevice, false, NULL); - - if (zonetype >= 0) { - if ((zonetype == 0) && - (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] != 0x00)) { - /* for USA */ - pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0; - pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B; - - pr_debug("Init Zone Type :USA\n"); - } else if ((zonetype == 1) && - (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] != 0x01)) { - /* for Japan */ - pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01; - pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; - } else if ((zonetype == 2) && - (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] != 0x02)) { - /* for Europe */ - pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02; - pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; - - pr_debug("Init Zone Type :Europe\n"); - } else { - if (zonetype != pDevice->abyEEPROM[EEP_OFS_ZONETYPE]) - pr_debug("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n", - zonetype, - pDevice->abyEEPROM[EEP_OFS_ZONETYPE]); - else - pr_debug("Read Zonetype file success,use default zonetype setting[%02x]\n", - zonetype); - } - } else { - pr_debug("Read Zonetype file fail,use default zonetype setting[%02x]\n", - SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ZONETYPE)); - } /* Get RFType */ pDevice->byRFType = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_RFTYPE); @@ -595,14 +557,9 @@ static void device_init_registers(struct vnt_private *pDevice) } /* recover 12,13 ,14channel for EUROPE by 11 channel */ - if (((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) || - (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe)) && - (pDevice->byOriginalZonetype == ZoneType_USA)) { - for (ii = 11; ii < 14; ii++) { - pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10]; - pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10]; - - } + for (ii = 11; ii < 14; ii++) { + pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10]; + pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10]; } /* Load OFDM A Power Table */ @@ -2139,70 +2096,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) return IRQ_RETVAL(handled); } -//2008-8-4 by chester -static int Config_FileGetParameter(unsigned char *string, - unsigned char *dest, unsigned char *source) -{ - unsigned char buf1[100]; - int source_len = strlen(source); - - memset(buf1, 0, 100); - strcat(buf1, string); - strcat(buf1, "="); - source += strlen(buf1); - - memcpy(dest, source, source_len - strlen(buf1)); - return true; -} - -int Config_FileOperation(struct vnt_private *pDevice, - bool fwrite, unsigned char *Parameter) -{ - unsigned char *buffer = kmalloc(1024, GFP_KERNEL); - unsigned char tmpbuffer[20]; - struct file *file; - int result = 0; - - if (!buffer) { - pr_err("allocate mem for file fail?\n"); - return -1; - } - file = filp_open(CONFIG_PATH, O_RDONLY, 0); - if (IS_ERR(file)) { - kfree(buffer); - pr_err("Config_FileOperation:open file fail?\n"); - return -1; - } - - if (kernel_read(file, 0, buffer, 1024) < 0) { - pr_err("read file error?\n"); - result = -1; - goto error1; - } - - if (Config_FileGetParameter("ZONETYPE", tmpbuffer, buffer) != true) { - pr_err("get parameter error?\n"); - result = -1; - goto error1; - } - - if (memcmp(tmpbuffer, "USA", 3) == 0) { - result = ZoneType_USA; - } else if (memcmp(tmpbuffer, "JAPAN", 5) == 0) { - result = ZoneType_Japan; - } else if (memcmp(tmpbuffer, "EUROPE", 5) == 0) { - result = ZoneType_Europe; - } else { - result = -1; - pr_err("Unknown Zonetype[%s]?\n", tmpbuffer); - } - -error1: - kfree(buffer); - fput(file); - return result; -} - static void device_set_multi(struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); PSMgmtObject pMgmt = pDevice->pMgmt; diff --git a/drivers/staging/vt6655/vntconfiguration.dat b/drivers/staging/vt6655/vntconfiguration.dat deleted file mode 100644 index 0064ddce7c11..000000000000 --- a/drivers/staging/vt6655/vntconfiguration.dat +++ /dev/null @@ -1 +0,0 @@ -ZONETYPE=EUROPE \ No newline at end of file -- cgit v1.2.3-59-g8ed1b From 3f9aceeddb95d7349148a085a834b8f544d2328f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:20 +0000 Subject: staging: vt6655: dead code remove zones and channel table elements emply functions will be deleted later Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 605 +-------------------------------------- drivers/staging/vt6655/channel.h | 8 - 2 files changed, 2 insertions(+), 611 deletions(-) diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 237969673f2e..a7b39d4c18c5 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -26,332 +26,6 @@ #include "device.h" #include "rf.h" -/*--------------------- Static Definitions -------------------------*/ - -#define CARD_MAX_CHANNEL_TBL 56 - -/*--------------------- Static Variables --------------------------*/ - -static SChannelTblElement sChannelTbl[CARD_MAX_CHANNEL_TBL + 1] = -{ - {0, 0, false, 0}, - {1, 2412, true, 0}, - {2, 2417, true, 0}, - {3, 2422, true, 0}, - {4, 2427, true, 0}, - {5, 2432, true, 0}, - {6, 2437, true, 0}, - {7, 2442, true, 0}, - {8, 2447, true, 0}, - {9, 2452, true, 0}, - {10, 2457, true, 0}, - {11, 2462, true, 0}, - {12, 2467, true, 0}, - {13, 2472, true, 0}, - {14, 2484, true, 0}, - {183, 4915, true, 0}, - {184, 4920, true, 0}, - {185, 4925, true, 0}, - {187, 4935, true, 0}, - {188, 4940, true, 0}, - {189, 4945, true, 0}, - {192, 4960, true, 0}, - {196, 4980, true, 0}, - {7, 5035, true, 0}, - {8, 5040, true, 0}, - {9, 5045, true, 0}, - {11, 5055, true, 0}, - {12, 5060, true, 0}, - {16, 5080, true, 0}, - {34, 5170, true, 0}, - {36, 5180, true, 0}, - {38, 5190, true, 0}, - {40, 5200, true, 0}, - {42, 5210, true, 0}, - {44, 5220, true, 0}, - {46, 5230, true, 0}, - {48, 5240, true, 0}, - {52, 5260, true, 0}, - {56, 5280, true, 0}, - {60, 5300, true, 0}, - {64, 5320, true, 0}, - {100, 5500, true, 0}, - {104, 5520, true, 0}, - {108, 5540, true, 0}, - {112, 5560, true, 0}, - {116, 5580, true, 0}, - {120, 5600, true, 0}, - {124, 5620, true, 0}, - {128, 5640, true, 0}, - {132, 5660, true, 0}, - {136, 5680, true, 0}, - {140, 5700, true, 0}, - {149, 5745, true, 0}, - {153, 5765, true, 0}, - {157, 5785, true, 0}, - {161, 5805, true, 0}, - {165, 5825, true, 0} -}; - -/************************************************************************ - * The Radar regulation rules for each country - ************************************************************************/ -static struct -{ - unsigned char byChannelCountryCode; /* The country code */ - char chCountryCode[2]; - unsigned char bChannelIdxList[CB_MAX_CHANNEL]; /* Available channels Index */ - unsigned char byPower[CB_MAX_CHANNEL]; -} ChannelRuleTab[] = -{ -/************************************************************************ - * This table is based on Athero driver rules - ************************************************************************/ -/* Country Available channels, ended with 0 */ -/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */ - {CCODE_FCC, {'U' , 'S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_TELEC, {'J' , 'P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 23, 0, 0, 23, 0, 23, 23, 0, 23, 0, 0, 23, 23, 23, 0, 23, 0, 23, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ETSI, {'E' , 'U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_RESV3, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESV4, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESV5, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESV6, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESV7, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESV8, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESV9, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESVa, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESVb, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESVc, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESVd, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RESVe, {' ' , ' '}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ALLBAND, {' ' , ' '}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ALBANIA, {'A' , 'L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ALGERIA, {'D' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ARGENTINA, {'A' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0} }, - {CCODE_ARMENIA, {'A' , 'M'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_AUSTRALIA, {'A' , 'U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_AUSTRIA, {'A' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 15, 0, 15, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_AZERBAIJAN, {'A' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_BAHRAIN, {'B' , 'H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_BELARUS, {'B' , 'Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_BELGIUM, {'B' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_BELIZE, {'B' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_BOLIVIA, {'B' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_BRAZIL, {'B' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_BRUNEI_DARUSSALAM, {'B' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_BULGARIA, {'B' , 'G'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0} }, - {CCODE_CANADA, {'C' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_CHILE, {'C' , 'L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17} }, - {CCODE_CHINA, {'C' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_COLOMBIA, {'C' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_COSTA_RICA, {'C' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_CROATIA, {'H' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_CYPRUS, {'C' , 'Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_CZECH, {'C' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_DENMARK, {'D' , 'K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_DOMINICAN_REPUBLIC, {'D' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_ECUADOR, {'E' , 'C'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_EGYPT, {'E' , 'G'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_EL_SALVADOR, {'S' , 'V'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ESTONIA, {'E' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_FINLAND, {'F' , 'I'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_FRANCE, {'F' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_GERMANY, {'D' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_GREECE, {'G' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_GEORGIA, {'G' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_GUATEMALA, {'G' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_HONDURAS, {'H' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_HONG_KONG, {'H' , 'K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_HUNGARY, {'H' , 'U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ICELAND, {'I' , 'S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_INDIA, {'I' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_INDONESIA, {'I' , 'D'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_IRAN, {'I' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_IRELAND, {'I' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_ITALY, {'I' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_ISRAEL, {'I' , 'L'}, { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_JAPAN, {'J' , 'P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_JORDAN, {'J' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_KAZAKHSTAN, {'K' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_KUWAIT, {'K' , 'W'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_LATVIA, {'L' , 'V'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_LEBANON, {'L' , 'B'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_LEICHTENSTEIN, {'L' , 'I'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_LITHUANIA, {'L' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_LUXEMBURG, {'L' , 'U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_MACAU, {'M' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_MACEDONIA, {'M' , 'K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_MALTA, {'M' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} }, - {CCODE_MALAYSIA, {'M' , 'Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_MEXICO, {'M' , 'X'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_MONACO, {'M' , 'C'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_MOROCCO, {'M' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_NETHERLANDS, {'N' , 'L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_NEW_ZEALAND, {'N' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_NORTH_KOREA, {'K' , 'P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} }, - {CCODE_NORWAY, {'N' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_OMAN, {'O' , 'M'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_PAKISTAN, {'P' , 'K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_PANAMA, {'P' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_PERU, {'P' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_PHILIPPINES, {'P' , 'H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_POLAND, {'P' , 'L'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_PORTUGAL, {'P' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_PUERTO_RICO, {'P' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_QATAR, {'Q' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ROMANIA, {'R' , 'O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_RUSSIA, {'R' , 'U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_SAUDI_ARABIA, {'S' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_SINGAPORE, {'S' , 'G'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20} }, - {CCODE_SLOVAKIA, {'S' , 'K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} }, - {CCODE_SLOVENIA, {'S' , 'I'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_SOUTH_AFRICA, {'Z' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_SOUTH_KOREA, {'K' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} }, - {CCODE_SPAIN, {'E' , 'S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} }, - {CCODE_SWEDEN, {'S' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_SWITZERLAND, {'C' , 'H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_SYRIA, {'S' , 'Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_TAIWAN, {'T' , 'W'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0} }, - {CCODE_THAILAND, {'T' , 'H'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} }, - {CCODE_TRINIDAD_TOBAGO, {'T' , 'T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 0, 18, 0, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_TUNISIA, {'T' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_TURKEY, {'T' , 'R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_UK, {'G' , 'B'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} }, - {CCODE_UKRAINE, {'U' , 'A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_UNITED_ARAB_EMIRATES, {'A' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_UNITED_STATES, {'U' , 'S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} - , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} }, - {CCODE_URUGUAY, {'U' , 'Y'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} }, - {CCODE_UZBEKISTAN, {'U' , 'Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_VENEZUELA, {'V' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0} - , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} }, - {CCODE_VIETNAM, {'V' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_YEMEN, {'Y' , 'E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_ZIMBABWE, {'Z' , 'W'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_JAPAN_W52_W53, {'J' , 'J'}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, - {CCODE_MAX, {'U' , 'N'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} - , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} } -/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */ -}; - -/*--------------------- Export Functions --------------------------*/ - static struct ieee80211_rate vnt_rates_bg[] = { { .bitrate = 10, .hw_value = RATE_1M }, { .bitrate = 20, .hw_value = RATE_2M }, @@ -521,9 +195,6 @@ bool is_channel_valid(unsigned int ChannelIndex) bValid = false; goto exit; } - - bValid = sChannelTbl[ChannelIndex].bValid; - exit: return bValid; } @@ -542,110 +213,17 @@ exit: bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable) { - if (uCountryCodeIdx >= CCODE_MAX) - return false; - - memcpy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL); - return true; } -void init_channel_table(void *pDeviceHandler) -{ - struct vnt_private *pDevice = pDeviceHandler; - bool bMultiBand = false; - unsigned int ii; - - for (ii = 1; ii <= CARD_MAX_CHANNEL_TBL; ii++) - sChannelTbl[ii].bValid = false; - - switch (pDevice->byRFType) { - case RF_RFMD2959: - case RF_AIROHA: - case RF_AL2230S: - case RF_UW2451: - case RF_VT3226: - bMultiBand = false; - break; - case RF_AIROHA7230: - case RF_UW2452: - case RF_NOTHING: - default: - bMultiBand = true; - break; - } - - if ((pDevice->dwDiagRefCount != 0) || pDevice->b11hEnable) { - if (bMultiBand) { - for (ii = 0; ii < CARD_MAX_CHANNEL_TBL; ii++) { - sChannelTbl[ii + 1].bValid = true; - pDevice->abyRegPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1]; - pDevice->abyLocalPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1]; - } - for (ii = 0; ii < CHANNEL_MAX_24G; ii++) { - pDevice->abyRegPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1]; - pDevice->abyLocalPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1]; - } - } else { - for (ii = 0; ii < CHANNEL_MAX_24G; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii + 1].bValid = true; - pDevice->abyRegPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1]; - pDevice->abyLocalPwr[ii + 1] = pDevice->abyCCKDefaultPwr[ii + 1]; - } - } - } - } else if (pDevice->byZoneType <= CCODE_MAX) { - if (bMultiBand) { - for (ii = 0; ii < CARD_MAX_CHANNEL_TBL; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii + 1].bValid = true; - pDevice->abyRegPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - pDevice->abyLocalPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - } - } - } else { - for (ii = 0; ii < CHANNEL_MAX_24G; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii + 1].bValid = true; - pDevice->abyRegPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - pDevice->abyLocalPwr[ii + 1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - } - } - } - } - - pr_info("Zone=[%d][%c][%c]!!\n", - pDevice->byZoneType, - ChannelRuleTab[pDevice->byZoneType].chCountryCode[0], - ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]); - - for (ii = 0; ii < CARD_MAX_CHANNEL_TBL; ii++) { - if (pDevice->abyRegPwr[ii + 1] == 0) - pDevice->abyRegPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1]; - if (pDevice->abyLocalPwr[ii + 1] == 0) - pDevice->abyLocalPwr[ii + 1] = pDevice->abyOFDMDefaultPwr[ii + 1]; - } -} - unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType) { - unsigned int ii; - - if ((ePhyType == PHY_TYPE_11B) || (ePhyType == PHY_TYPE_11G)) - return byChannelNumber; - - for (ii = (CB_MAX_CHANNEL_24G + 1); ii <= CB_MAX_CHANNEL;) { - if (sChannelTbl[ii].byChannelNumber == byChannelNumber) - return (unsigned char) ii; - ii++; - } return 0; } unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex) { - return sChannelTbl[byChannelIndex].byChannelNumber; + return 0; } /** @@ -709,41 +287,6 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE) { - struct vnt_private *pDevice = pDeviceHandler; - unsigned int ii = 0; - unsigned int uu = 0; - unsigned int step = 0; - unsigned int uNumOfCountryInfo = 0; - unsigned char byCh = 0; - PWLAN_IE_COUNTRY pIE_Country = (PWLAN_IE_COUNTRY) pIE; - - uNumOfCountryInfo = (pIE_Country->len - 3); - uNumOfCountryInfo /= 3; - - if (ePHYType == PHY_TYPE_11A) { - pDevice->bCountryInfo5G = true; - for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CARD_MAX_CHANNEL_TBL; ii++) - sChannelTbl[ii].bValid = false; - - step = 4; - } else { - pDevice->bCountryInfo24G = true; - for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) - sChannelTbl[ii].bValid = false; - - step = 1; - } - pDevice->abyCountryCode[0] = pIE_Country->abyCountryString[0]; - pDevice->abyCountryCode[1] = pIE_Country->abyCountryString[1]; - pDevice->abyCountryCode[2] = pIE_Country->abyCountryString[2]; - - for (ii = 0; ii < uNumOfCountryInfo; ii++) { - for (uu = 0; uu < pIE_Country->abyCountryInfo[ii*3+1]; uu++) { - byCh = get_channel_mapping(pDevice, (unsigned char)(pIE_Country->abyCountryInfo[ii*3]+step*uu), ePHYType); - sChannelTbl[byCh].bValid = true; - pDevice->abyRegPwr[byCh] = pIE_Country->abyCountryInfo[ii*3+2]; - } - } } /** @@ -758,176 +301,32 @@ void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE) unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) { - struct vnt_private *pDevice = pDeviceHandler; - unsigned int ii; - unsigned char byCount; - PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs; - unsigned char *pbyChTupple; unsigned char byLen = 0; - - pIE->byElementID = WLAN_EID_SUPP_CH; - pIE->len = 0; - pbyChTupple = pIE->abyChannelTuple; - byLen = 2; - /* lower band */ - byCount = 0; - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == true) { - for (ii = 28; ii < 36; ii += 2) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) - byCount++; - } - - *pbyChTupple++ = 34; - *pbyChTupple++ = byCount; - byLen += 2; - } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[29] == true) { - for (ii = 29; ii < 36; ii += 2) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) - byCount++; - } - - *pbyChTupple++ = 36; - *pbyChTupple++ = byCount; - byLen += 2; - } - /* middle band */ - byCount = 0; - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == true) { - for (ii = 36; ii < 40; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) - byCount++; - } - - *pbyChTupple++ = 52; - *pbyChTupple++ = byCount; - byLen += 2; - } - /* higher band */ - byCount = 0; - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == true) { - for (ii = 40; ii < 51; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) - byCount++; - } - - *pbyChTupple++ = 100; - *pbyChTupple++ = byCount; - byLen += 2; - } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == true) { - for (ii = 51; ii < 56; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) - byCount++; - } - - *pbyChTupple++ = 149; - *pbyChTupple++ = byCount; - byLen += 2; - } - pIE->len += (byLen - 2); return byLen; } void set_country_IE(void *pDeviceHandler, void *pIE) { - struct vnt_private *pDevice = pDeviceHandler; - unsigned int ii; - PWLAN_IE_COUNTRY pIECountry = (PWLAN_IE_COUNTRY) pIE; - - pIECountry->byElementID = WLAN_EID_COUNTRY; - pIECountry->len = 0; - pIECountry->abyCountryString[0] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[0]; - pIECountry->abyCountryString[1] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]; - pIECountry->abyCountryString[2] = ' '; - for (ii = CB_MAX_CHANNEL_24G; ii < CB_MAX_CHANNEL; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { - pIECountry->abyCountryInfo[pIECountry->len++] = sChannelTbl[ii + 1].byChannelNumber; - pIECountry->abyCountryInfo[pIECountry->len++] = 1; - pIECountry->abyCountryInfo[pIECountry->len++] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - } - } - pIECountry->len += 3; } bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, unsigned char *pbyChannelNumber, unsigned char *pbyMap) { - if (uChannelIndex > CB_MAX_CHANNEL) - return false; - - *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber; - *pbyMap = sChannelTbl[uChannelIndex].byMAP; - return sChannelTbl[uChannelIndex].bValid; + return 0; } void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, unsigned char byMap) { - if (uChannelIndex > CB_MAX_CHANNEL) - return; - - sChannelTbl[uChannelIndex].byMAP |= byMap; } void clear_channel_map_info(void *pDeviceHandler) { - unsigned int ii = 0; - for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) - sChannelTbl[ii].byMAP = 0; } unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType) { - unsigned int ii = 0; unsigned char byOptionChannel = 0; - int aiWeight[CB_MAX_CHANNEL_24G + 1] = {-1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - - if (ePHYType == PHY_TYPE_11A) { - for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CB_MAX_CHANNEL; ii++) { - if (sChannelTbl[ii].bValid) { - if (byOptionChannel == 0) - byOptionChannel = (unsigned char) ii; - - if (sChannelTbl[ii].byMAP == 0) - return (unsigned char) ii; - else if (!(sChannelTbl[ii].byMAP & 0x08)) - byOptionChannel = (unsigned char) ii; - } - } - } else { - byOptionChannel = 0; - for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) { - if (sChannelTbl[ii].bValid) { - if (sChannelTbl[ii].byMAP == 0) { - aiWeight[ii] += 100; - } else if (sChannelTbl[ii].byMAP & 0x01) { - if (ii > 3) - aiWeight[ii - 3] -= 10; - - if (ii > 2) - aiWeight[ii - 2] -= 20; - - if (ii > 1) - aiWeight[ii - 1] -= 40; - - aiWeight[ii] -= 80; - if (ii < CB_MAX_CHANNEL_24G) - aiWeight[ii + 1] -= 40; - - if (ii < (CB_MAX_CHANNEL_24G - 1)) - aiWeight[ii+2] -= 20; - - if (ii < (CB_MAX_CHANNEL_24G - 2)) - aiWeight[ii+3] -= 10; - } - } - } - for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) { - if (sChannelTbl[ii].bValid && - (aiWeight[ii] > aiWeight[byOptionChannel])) { - byOptionChannel = (unsigned char) ii; - } - } - } return byOptionChannel; } diff --git a/drivers/staging/vt6655/channel.h b/drivers/staging/vt6655/channel.h index 0d3e1f121759..78ab642738ed 100644 --- a/drivers/staging/vt6655/channel.h +++ b/drivers/staging/vt6655/channel.h @@ -26,17 +26,9 @@ #include "ttype.h" #include "card.h" -typedef struct tagSChannelTblElement { - unsigned char byChannelNumber; - unsigned int uFrequency; - bool bValid; - unsigned char byMAP; -} SChannelTblElement, *PSChannelTblElement; - void vnt_init_bands(struct vnt_private *); bool is_channel_valid(unsigned int CountryCode); -void init_channel_table(void *pDeviceHandler); unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType); bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable); unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex); -- cgit v1.2.3-59-g8ed1b From 7af1ead431ec82b64de511fa28ac54b3cc5b66ca Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:21 +0000 Subject: staging: vt6655: dead code remove net device code All functions are dead and nolonger of use. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 - drivers/staging/vt6655/device_main.c | 1176 ---------------------------------- drivers/staging/vt6655/wcmd.c | 4 - 3 files changed, 1182 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 214f73fc9def..6729d237a6ae 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -746,8 +746,6 @@ static inline PDEVICE_TD_INFO alloc_td_info(void) /*--------------------- Export Functions --------------------------*/ -bool device_dma0_xmit(struct vnt_private *pDevice, - struct sk_buff *skb, unsigned int uNodeIndex); bool device_alloc_frag_buf(struct vnt_private *pDevice, PSDeFragControlBlock pDeF); #endif diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 12fa63c73f01..870016ae9905 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -32,20 +32,12 @@ * device_free_info - device structure resource free function * device_get_pci_info - get allocated pci io/mem resource * device_print_info - print out resource - * device_open - allocate dma/descripter resource & initial mac/bbp function - * device_xmit - asynchrous data tx function * device_intr - interrupt handle function - * device_set_multi - set mac filter - * device_ioctl - ioctl entry - * device_close - shutdown mac/bbp & free dma/descripter resource * device_rx_srv - rx service function - * device_receive_frame - rx data function * device_alloc_rx_buf - rx buffer pre-allocated function * device_alloc_frag_buf - rx fragement pre-allocated function * device_free_tx_buf - free tx buffer function * device_free_frag_buf- free de-fragement buffer - * device_dma0_tx_80211- tx 802.11 frame via dma0 - * device_dma0_xmit- tx PS bufferred frame via dma0 * device_init_rd0_ring- initial rd dma0 ring * device_init_rd1_ring- initial rd dma1 ring * device_init_td0_ring- initial tx dma0 ring buffer @@ -265,12 +257,7 @@ static void device_free_info(struct vnt_private *pDevice); static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid); static void device_print_info(struct vnt_private *pDevice); static void device_init_diversity_timer(struct vnt_private *pDevice); -static int device_open(struct net_device *dev); -static int device_xmit(struct sk_buff *skb, struct net_device *dev); static irqreturn_t device_intr(int irq, void *dev_instance); -static void device_set_multi(struct net_device *dev); -static int device_close(struct net_device *dev); -static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); #ifdef CONFIG_PM static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); @@ -287,11 +274,6 @@ static void device_init_defrag_cb(struct vnt_private *pDevice); static void device_init_td0_ring(struct vnt_private *pDevice); static void device_init_td1_ring(struct vnt_private *pDevice); -static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev); -//2008-0714by Mike Liu -static bool device_release_WPADEV(struct vnt_private *pDevice); - -static int ethtool_ioctl(struct net_device *dev, void __user *useraddr); static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx); static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx); static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pDesc); @@ -672,45 +654,6 @@ static void device_init_diversity_timer(struct vnt_private *pDevice) pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ); } -static bool device_release_WPADEV(struct vnt_private *pDevice) -{ - viawget_wpa_header *wpahdr; - int ii = 0; - - //send device close to wpa_supplicnat layer - if (pDevice->bWPADEVUp) { - wpahdr = (viawget_wpa_header *)pDevice->skb->data; - wpahdr->type = VIAWGET_DEVICECLOSE_MSG; - wpahdr->resp_ie_len = 0; - wpahdr->req_ie_len = 0; - skb_put(pDevice->skb, sizeof(viawget_wpa_header)); - pDevice->skb->dev = pDevice->wpadev; - skb_reset_mac_header(pDevice->skb); - pDevice->skb->pkt_type = PACKET_HOST; - pDevice->skb->protocol = htons(ETH_P_802_2); - memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); - netif_rx(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - - while (pDevice->bWPADEVUp) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); //wait 50ms - ii++; - if (ii > 20) - break; - } - } - return true; -} - -static const struct net_device_ops device_netdev_ops = { - .ndo_open = device_open, - .ndo_stop = device_close, - .ndo_do_ioctl = device_ioctl, - .ndo_start_xmit = device_xmit, - .ndo_set_rx_mode = device_set_multi, -}; - static void device_print_info(struct vnt_private *pDevice) { dev_info(&pDevice->pcid->dev, "%s\n", get_chip_name(pDevice->chip_id)); @@ -1297,653 +1240,6 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc) pTDInfo->byFlags = 0; } -static int device_open(struct net_device *dev) -{ - struct vnt_private *pDevice = netdev_priv(dev); - int i; - - pDevice->rx_buf_sz = PKT_BUF_SZ; - if (!device_init_rings(pDevice)) - return -ENOMEM; - -//2008-5-13 by chester - i = request_irq(pDevice->pcid->irq, &device_intr, IRQF_SHARED, dev->name, dev); - if (i) - return i; - -#ifdef WPA_SM_Transtatus - pDevice->fWPA_Authened = false; -#endif - pr_debug("call device init rd0 ring\n"); - device_init_rd0_ring(pDevice); - device_init_rd1_ring(pDevice); - device_init_defrag_cb(pDevice); - device_init_td0_ring(pDevice); - device_init_td1_ring(pDevice); - - if (pDevice->bDiversityRegCtlON) - device_init_diversity_timer(pDevice); - - vMgrObjectInit(pDevice); - vMgrTimerInit(pDevice); - - pr_debug("call device_init_registers\n"); - device_init_registers(pDevice); - - MACvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr); - ether_addr_copy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr); - device_set_multi(pDevice->dev); - - // Init for Key Management - KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); - add_timer(&(pDevice->pMgmt->sTimerSecondCallback)); - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - pDevice->bwextcount = 0; - pDevice->bWPASuppWextEnabled = false; -#endif - pDevice->byReAssocCount = 0; - pDevice->bWPADEVUp = false; - // Patch: if WEP key already set by iwconfig but device not yet open - if (pDevice->bEncryptionEnable && pDevice->bTransmitKey) { - KeybSetDefaultKey(&(pDevice->sKey), - (unsigned long)(pDevice->byKeyIndex | (1 << 31)), - pDevice->uKeyLength, - NULL, - pDevice->abyKey, - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID - ); - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - } - - pr_debug("call MACvIntEnable\n"); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - - if (pDevice->pMgmt->eConfigMode == WMAC_CONFIG_AP) { - bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); - } else { - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); - } - pDevice->flags |= DEVICE_FLAGS_OPENED; - - pr_debug("device_open success..\n"); - return 0; -} - -static int device_close(struct net_device *dev) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = pDevice->pMgmt; -//2007-1121-02by EinsnLiu - if (pDevice->bLinkPass) { - bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); - mdelay(30); - } - - del_timer(&pDevice->sTimerTxData); - del_timer(&pDevice->sTimerCommand); - del_timer(&pMgmt->sTimerSecondCallback); - if (pDevice->bDiversityRegCtlON) { - del_timer(&pDevice->TimerSQ3Tmax1); - del_timer(&pDevice->TimerSQ3Tmax2); - del_timer(&pDevice->TimerSQ3Tmax3); - } - - netif_stop_queue(dev); - pDevice->bCmdRunning = false; - MACbShutdown(pDevice->PortOffset); - MACbSoftwareReset(pDevice->PortOffset); - CARDbRadioPowerOff(pDevice); - - pDevice->bLinkPass = false; - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; - device_free_td0_ring(pDevice); - device_free_td1_ring(pDevice); - device_free_rd0_ring(pDevice); - device_free_rd1_ring(pDevice); - device_free_frag_buf(pDevice); - device_free_rings(pDevice); - BSSvClearNodeDBTable(pDevice, 0); - free_irq(dev->irq, dev); - pDevice->flags &= (~DEVICE_FLAGS_OPENED); - //2008-0714-01by chester - device_release_WPADEV(pDevice); - - pr_debug("device_close..\n"); - return 0; -} - -static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) -{ - struct vnt_private *pDevice = netdev_priv(dev); - unsigned char *pbMPDU; - unsigned int cbMPDULen = 0; - - pr_debug("device_dma0_tx_80211\n"); - spin_lock_irq(&pDevice->lock); - - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) { - pr_debug("device_dma0_tx_80211, td0 <=0\n"); - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - - if (pDevice->bStopTx0Pkt) { - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - - cbMPDULen = skb->len; - pbMPDU = skb->data; - - vDMA0_tx_80211(pDevice, skb, pbMPDU, cbMPDULen); - - spin_unlock_irq(&pDevice->lock); - - return 0; -} - -bool device_dma0_xmit(struct vnt_private *pDevice, - struct sk_buff *skb, unsigned int uNodeIndex) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - PSTxDesc pHeadTD, pLastTD; - unsigned int cbFrameBodySize; - unsigned int uMACfragNum; - unsigned char byPktType; - bool bNeedEncryption = false; - PSKeyItem pTransmitKey = NULL; - unsigned int cbHeaderSize; - unsigned int ii; - SKeyItem STempKey; - - if (pDevice->bStopTx0Pkt) { - dev_kfree_skb_irq(skb); - return false; - } - - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) { - dev_kfree_skb_irq(skb); - pr_debug("device_dma0_xmit, td0 <=0\n"); - return false; - } - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (pDevice->uAssocCount == 0) { - dev_kfree_skb_irq(skb); - pr_debug("device_dma0_xmit, assocCount = 0\n"); - return false; - } - } - - pHeadTD = pDevice->apCurrTD[TYPE_TXDMA0]; - - pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP); - - memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN); - cbFrameBodySize = skb->len - ETH_HLEN; - - // 802.1H - if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) - cbFrameBodySize += 8; - - uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader); - - if (uMACfragNum > AVAIL_TD(pDevice, TYPE_TXDMA0)) { - dev_kfree_skb_irq(skb); - return false; - } - byPktType = (unsigned char)pDevice->byPacketType; - - if (pDevice->bFixRate) { - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) - pDevice->wCurrentRate = RATE_11M; - else - pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - } else { - if (pDevice->uConnectionRate >= RATE_54M) - pDevice->wCurrentRate = RATE_54M; - else - pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - } - } else { - pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; - } - - //preamble type - if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) - pDevice->byPreambleType = pDevice->byShortPreamble; - else - pDevice->byPreambleType = PREAMBLE_LONG; - - pr_debug("dma0: pDevice->wCurrentRate = %d\n", pDevice->wCurrentRate); - - if (pDevice->wCurrentRate <= RATE_11M) { - byPktType = PK_TYPE_11B; - } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { - byPktType = PK_TYPE_11A; - } else { - if (pDevice->bProtectMode) - byPktType = PK_TYPE_11GB; - else - byPktType = PK_TYPE_11GA; - } - - if (pDevice->bEncryptionEnable) - bNeedEncryption = true; - - if (pDevice->bEnableHostWEP) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, bNeedEncryption, - cbFrameBodySize, TYPE_TXDMA0, pHeadTD, - &pDevice->sTxEthHeader, (unsigned char *)skb->data, pTransmitKey, uNodeIndex, - &uMACfragNum, - &cbHeaderSize - ); - - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { - // Disable PS - MACbPSWakeup(pDevice->PortOffset); - } - - pDevice->bPWBitOn = false; - - pLastTD = pHeadTD; - for (ii = 0; ii < uMACfragNum; ii++) { - // Poll Transmit the adapter - wmb(); - pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC; - wmb(); - if (ii == (uMACfragNum - 1)) - pLastTD = pHeadTD; - pHeadTD = pHeadTD->next; - } - - // Save the information needed by the tx interrupt handler - // to complete the Send request - pLastTD->pTDInfo->skb = skb; - pLastTD->pTDInfo->byFlags = 0; - pLastTD->pTDInfo->byFlags |= TD_FLAGS_NETIF_SKB; - - pDevice->apCurrTD[TYPE_TXDMA0] = pHeadTD; - - MACvTransmit0(pDevice->PortOffset); - - return true; -} - -//TYPE_AC0DMA data tx -static int device_xmit(struct sk_buff *skb, struct net_device *dev) { - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = pDevice->pMgmt; - PSTxDesc pHeadTD, pLastTD; - unsigned int uNodeIndex = 0; - unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - unsigned short wAID; - unsigned int uMACfragNum = 1; - unsigned int cbFrameBodySize; - unsigned char byPktType; - unsigned int cbHeaderSize; - bool bNeedEncryption = false; - PSKeyItem pTransmitKey = NULL; - SKeyItem STempKey; - unsigned int ii; - bool bTKIP_UseGTK = false; - bool bNeedDeAuth = false; - unsigned char *pbyBSSID; - bool bNodeExist = false; - - spin_lock_irq(&pDevice->lock); - if (!pDevice->bLinkPass) { - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - - if (pDevice->bStopDataPkt) { - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (pDevice->uAssocCount == 0) { - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - if (is_multicast_ether_addr((unsigned char *)(skb->data))) { - uNodeIndex = 0; - bNodeExist = true; - if (pMgmt->sNodeDBTable[0].bPSEnable) { - skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb); - pMgmt->sNodeDBTable[0].wEnQueueCnt++; - // set tx map - pMgmt->abyPSTxMap[0] |= byMask[0]; - spin_unlock_irq(&pDevice->lock); - return 0; - } - } else { - if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data), &uNodeIndex)) { - if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) { - skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb); - pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++; - // set tx map - wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID; - pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; - pr_debug("Set:pMgmt->abyPSTxMap[%d]= %d\n", - (wAID >> 3), - pMgmt->abyPSTxMap[wAID >> 3]); - spin_unlock_irq(&pDevice->lock); - return 0; - } - - if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) - pDevice->byPreambleType = pDevice->byShortPreamble; - else - pDevice->byPreambleType = PREAMBLE_LONG; - - bNodeExist = true; - - } - } - - if (!bNodeExist) { - pr_debug("Unknown STA not found in node DB\n"); - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - } - - pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA]; - - pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP); - - memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN); - cbFrameBodySize = skb->len - ETH_HLEN; - // 802.1H - if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) - cbFrameBodySize += 8; - - if (pDevice->bEncryptionEnable) { - bNeedEncryption = true; - // get Transmit key - do { - if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && - (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - pbyBSSID = pDevice->abyBSSID; - // get pairwise key - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { - // get group key - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { - bTKIP_UseGTK = true; - pr_debug("Get GTK\n"); - break; - } - } else { - pr_debug("Get PTK\n"); - break; - } - } else if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - pbyBSSID = pDevice->sTxEthHeader.abyDstAddr; //TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1 - pr_debug("IBSS Serach Key:\n"); - for (ii = 0; ii < 6; ii++) - pr_debug("%x\n", *(pbyBSSID+ii)); - pr_debug("\n"); - - // get pairwise key - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == true) - break; - } - // get group key - pbyBSSID = pDevice->abyBroadcastAddr; - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { - pTransmitKey = NULL; - if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - pr_debug("IBSS and KEY is NULL. [%d]\n", - pDevice->pMgmt->eCurrMode); - else - pr_debug("NOT IBSS and KEY is NULL. [%d]\n", - pDevice->pMgmt->eCurrMode); - } else { - bTKIP_UseGTK = true; - pr_debug("Get GTK\n"); - } - } while (false); - } - - if (pDevice->bEnableHostWEP) { - pr_debug("acdma0: STA index %d\n", uNodeIndex); - if (pDevice->bEncryptionEnable) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - } - - uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader); - - if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA)) { - pr_debug("uMACfragNum > AVAIL_TD(TYPE_AC0DMA) = %d\n", - uMACfragNum); - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - - if (pTransmitKey != NULL) { - if ((pTransmitKey->byCipherSuite == KEY_CTL_WEP) && - (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN)) { - uMACfragNum = 1; //WEP256 doesn't support fragment - } - } - - byPktType = (unsigned char)pDevice->byPacketType; - - if (pDevice->bFixRate) { - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) - pDevice->wCurrentRate = RATE_11M; - else - pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - } else { - if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) && - (pDevice->uConnectionRate <= RATE_6M)) { - pDevice->wCurrentRate = RATE_6M; - } else { - if (pDevice->uConnectionRate >= RATE_54M) - pDevice->wCurrentRate = RATE_54M; - else - pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - - } - } - pDevice->byACKRate = (unsigned char) pDevice->wCurrentRate; - pDevice->byTopCCKBasicRate = RATE_1M; - pDevice->byTopOFDMBasicRate = RATE_6M; - } else { - //auto rate - if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) { - if (pDevice->eCurrentPHYType != PHY_TYPE_11A) { - pDevice->wCurrentRate = RATE_1M; - pDevice->byACKRate = RATE_1M; - pDevice->byTopCCKBasicRate = RATE_1M; - pDevice->byTopOFDMBasicRate = RATE_6M; - } else { - pDevice->wCurrentRate = RATE_6M; - pDevice->byACKRate = RATE_6M; - pDevice->byTopCCKBasicRate = RATE_1M; - pDevice->byTopOFDMBasicRate = RATE_6M; - } - } else { - VNTWIFIvGetTxRate(pDevice->pMgmt, - pDevice->sTxEthHeader.abyDstAddr, - &(pDevice->wCurrentRate), - &(pDevice->byACKRate), - &(pDevice->byTopCCKBasicRate), - &(pDevice->byTopOFDMBasicRate)); - - } - } - - - if (pDevice->wCurrentRate <= RATE_11M) { - byPktType = PK_TYPE_11B; - } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { - byPktType = PK_TYPE_11A; - } else { - if (pDevice->bProtectMode) - byPktType = PK_TYPE_11GB; - else - byPktType = PK_TYPE_11GA; - } - - if (bNeedEncryption) { - pr_debug("ntohs Pkt Type=%04x\n", - ntohs(pDevice->sTxEthHeader.wType)); - if ((pDevice->sTxEthHeader.wType) == TYPE_PKT_802_1x) { - bNeedEncryption = false; - pr_debug("Pkt Type=%04x\n", - (pDevice->sTxEthHeader.wType)); - if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - if (pTransmitKey == NULL) { - pr_debug("Don't Find TX KEY\n"); - } else { - if (bTKIP_UseGTK) { - pr_debug("error: KEY is GTK!!~~\n"); - } else { - pr_debug("Find PTK [%lX]\n", - pTransmitKey->dwKeyIndex); - bNeedEncryption = true; - } - } - } - - if (pDevice->byCntMeasure == 2) { - bNeedDeAuth = true; - pDevice->s802_11Counter.TKIPCounterMeasuresInvoked++; - } - - if (pDevice->bEnableHostWEP) { - if ((uNodeIndex != 0) && - (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) { - pr_debug("Find PTK [%lX]\n", - pTransmitKey->dwKeyIndex); - bNeedEncryption = true; - } - } - } else { - if (pTransmitKey == NULL) { - pr_debug("return no tx key\n"); - dev_kfree_skb_irq(skb); - spin_unlock_irq(&pDevice->lock); - return 0; - } - } - } - - vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, bNeedEncryption, - cbFrameBodySize, TYPE_AC0DMA, pHeadTD, - &pDevice->sTxEthHeader, (unsigned char *)skb->data, pTransmitKey, uNodeIndex, - &uMACfragNum, - &cbHeaderSize - ); - - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { - // Disable PS - MACbPSWakeup(pDevice->PortOffset); - } - pDevice->bPWBitOn = false; - - pLastTD = pHeadTD; - for (ii = 0; ii < uMACfragNum; ii++) { - // Poll Transmit the adapter - wmb(); - pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC; - wmb(); - if (ii == uMACfragNum - 1) - pLastTD = pHeadTD; - pHeadTD = pHeadTD->next; - } - - // Save the information needed by the tx interrupt handler - // to complete the Send request - pLastTD->pTDInfo->skb = skb; - pLastTD->pTDInfo->byFlags = 0; - pLastTD->pTDInfo->byFlags |= TD_FLAGS_NETIF_SKB; - pDevice->nTxDataTimeCout = 0; //2008-8-21 chester for send null packet - - if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 1) - netif_stop_queue(dev); - - pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD; - - if (pDevice->bFixRate) - pr_debug("FixRate:Rate is %d,TxPower is %d\n", pDevice->wCurrentRate, pDevice->byCurPwr); - - { - unsigned char Protocol_Version; //802.1x Authentication - unsigned char Packet_Type; //802.1x Authentication - unsigned char Descriptor_type; - unsigned short Key_info; - bool bTxeapol_key = false; - - Protocol_Version = skb->data[ETH_HLEN]; - Packet_Type = skb->data[ETH_HLEN+1]; - Descriptor_type = skb->data[ETH_HLEN+1+1+2]; - Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]); - if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) { - if (((Protocol_Version == 1) || (Protocol_Version == 2)) && - (Packet_Type == 3)) { //802.1x OR eapol-key challenge frame transfer - bTxeapol_key = true; - if ((Descriptor_type == 254) || (Descriptor_type == 2)) { //WPA or RSN - if (!(Key_info & BIT3) && //group-key challenge - (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key - pDevice->fWPA_Authened = true; - if (Descriptor_type == 254) - pr_debug("WPA "); - else - pr_debug("WPA2 "); - pr_debug("Authentication completed!!\n"); - } - } - } - } - } - - MACvTransmitAC0(pDevice->PortOffset); - - dev->trans_start = jiffies; - - spin_unlock_irq(&pDevice->lock); - return 0; -} - static irqreturn_t device_intr(int irq, void *dev_instance) { struct vnt_private *pDevice = dev_instance; @@ -2096,477 +1392,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) return IRQ_RETVAL(handled); } -static void device_set_multi(struct net_device *dev) { - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = pDevice->pMgmt; - u32 mc_filter[2]; - struct netdev_hw_addr *ha; - - VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode)); - - if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ - pr_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)) { - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, 0xffffffff); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0 + 4, 0xffffffff); - MACvSelectPage0(pDevice->PortOffset); - 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)); - } - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, mc_filter[0]); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0 + 4, mc_filter[1]); - MACvSelectPage0(pDevice->PortOffset); - pDevice->byRxMode &= ~(RCR_UNICAST); - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - } - - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - // If AP mode, don't enable RCR_UNICAST. Since hw only compare addr1 with local mac. - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - pDevice->byRxMode &= ~(RCR_UNICAST); - } - - VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byRxMode); - pr_debug("pDevice->byRxMode = %x\n", pDevice->byRxMode); -} - -static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct vnt_private *pDevice = netdev_priv(dev); - struct iwreq *wrq = (struct iwreq *)rq; - int rc = 0; - PSMgmtObject pMgmt = pDevice->pMgmt; - PSCmdRequest pReq; - - if (pMgmt == NULL) { - rc = -EFAULT; - return rc; - } - - switch (cmd) { - case SIOCGIWNAME: - rc = iwctl_giwname(dev, NULL, (char *)&(wrq->u.name), NULL); - break; - - case SIOCGIWNWID: //0x8b03 support - rc = -EOPNOTSUPP; - break; - - // Set frequency/channel - case SIOCSIWFREQ: - rc = iwctl_siwfreq(dev, NULL, &(wrq->u.freq), NULL); - break; - - // Get frequency/channel - case SIOCGIWFREQ: - rc = iwctl_giwfreq(dev, NULL, &(wrq->u.freq), NULL); - break; - - // Set desired network name (ESSID) - case SIOCSIWESSID: - - { - char essid[IW_ESSID_MAX_SIZE+1]; - - if (wrq->u.essid.length > IW_ESSID_MAX_SIZE) { - rc = -E2BIG; - break; - } - if (copy_from_user(essid, wrq->u.essid.pointer, - wrq->u.essid.length)) { - rc = -EFAULT; - break; - } - rc = iwctl_siwessid(dev, NULL, - &(wrq->u.essid), essid); - } - break; - - // Get current network name (ESSID) - case SIOCGIWESSID: - - { - char essid[IW_ESSID_MAX_SIZE+1]; - - if (wrq->u.essid.pointer) - rc = iwctl_giwessid(dev, NULL, - &(wrq->u.essid), essid); - if (copy_to_user(wrq->u.essid.pointer, - essid, - wrq->u.essid.length)) - rc = -EFAULT; - } - break; - - case SIOCSIWAP: - - rc = iwctl_siwap(dev, NULL, &(wrq->u.ap_addr), NULL); - break; - - // Get current Access Point (BSSID) - case SIOCGIWAP: - rc = iwctl_giwap(dev, NULL, &(wrq->u.ap_addr), NULL); - break; - - // Set desired station name - case SIOCSIWNICKN: - pr_debug(" SIOCSIWNICKN\n"); - rc = -EOPNOTSUPP; - break; - - // Get current station name - case SIOCGIWNICKN: - pr_debug(" SIOCGIWNICKN\n"); - rc = -EOPNOTSUPP; - break; - - // Set the desired bit-rate - case SIOCSIWRATE: - rc = iwctl_siwrate(dev, NULL, &(wrq->u.bitrate), NULL); - break; - - // Get the current bit-rate - case SIOCGIWRATE: - - rc = iwctl_giwrate(dev, NULL, &(wrq->u.bitrate), NULL); - break; - - // Set the desired RTS threshold - case SIOCSIWRTS: - - rc = iwctl_siwrts(dev, NULL, &(wrq->u.rts), NULL); - break; - - // Get the current RTS threshold - case SIOCGIWRTS: - - rc = iwctl_giwrts(dev, NULL, &(wrq->u.rts), NULL); - break; - - // Set the desired fragmentation threshold - case SIOCSIWFRAG: - - rc = iwctl_siwfrag(dev, NULL, &(wrq->u.frag), NULL); - break; - - // Get the current fragmentation threshold - case SIOCGIWFRAG: - - rc = iwctl_giwfrag(dev, NULL, &(wrq->u.frag), NULL); - break; - - // Set mode of operation - case SIOCSIWMODE: - rc = iwctl_siwmode(dev, NULL, &(wrq->u.mode), NULL); - break; - - // Get mode of operation - case SIOCGIWMODE: - rc = iwctl_giwmode(dev, NULL, &(wrq->u.mode), NULL); - break; - - // Set WEP keys and mode - case SIOCSIWENCODE: { - char abyKey[WLAN_WEP232_KEYLEN]; - - if (wrq->u.encoding.pointer) { - if (wrq->u.encoding.length > WLAN_WEP232_KEYLEN) { - rc = -E2BIG; - break; - } - memset(abyKey, 0, WLAN_WEP232_KEYLEN); - if (copy_from_user(abyKey, - wrq->u.encoding.pointer, - wrq->u.encoding.length)) { - rc = -EFAULT; - break; - } - } else if (wrq->u.encoding.length != 0) { - rc = -EINVAL; - break; - } - rc = iwctl_siwencode(dev, NULL, &(wrq->u.encoding), abyKey); - } - break; - - // Get the WEP keys and mode - case SIOCGIWENCODE: - - if (!capable(CAP_NET_ADMIN)) { - rc = -EPERM; - break; - } - { - char abyKey[WLAN_WEP232_KEYLEN]; - - rc = iwctl_giwencode(dev, NULL, &(wrq->u.encoding), abyKey); - if (rc != 0) - break; - if (wrq->u.encoding.pointer) { - if (copy_to_user(wrq->u.encoding.pointer, - abyKey, - wrq->u.encoding.length)) - rc = -EFAULT; - } - } - break; - - // Get the current Tx-Power - case SIOCGIWTXPOW: - pr_debug(" SIOCGIWTXPOW\n"); - rc = -EOPNOTSUPP; - break; - - case SIOCSIWTXPOW: - pr_debug(" SIOCSIWTXPOW\n"); - rc = -EOPNOTSUPP; - break; - - case SIOCSIWRETRY: - - rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL); - break; - - case SIOCGIWRETRY: - - rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL); - break; - - // Get range of parameters - case SIOCGIWRANGE: - - { - struct iw_range range; - - rc = iwctl_giwrange(dev, NULL, &(wrq->u.data), (char *)&range); - if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range))) - rc = -EFAULT; - } - - break; - - case SIOCGIWPOWER: - - rc = iwctl_giwpower(dev, NULL, &(wrq->u.power), NULL); - break; - - case SIOCSIWPOWER: - - rc = iwctl_siwpower(dev, NULL, &(wrq->u.power), NULL); - break; - - case SIOCGIWSENS: - - rc = iwctl_giwsens(dev, NULL, &(wrq->u.sens), NULL); - break; - - case SIOCSIWSENS: - pr_debug(" SIOCSIWSENS\n"); - rc = -EOPNOTSUPP; - break; - - case SIOCGIWAPLIST: { - char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))]; - - if (wrq->u.data.pointer) { - rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer); - if (rc == 0) { - if (copy_to_user(wrq->u.data.pointer, - buffer, - (wrq->u.data.length * (sizeof(struct sockaddr) + sizeof(struct iw_quality))) - )) - rc = -EFAULT; - } - } - } - break; - -#ifdef WIRELESS_SPY - // Set the spy list - case SIOCSIWSPY: - - pr_debug(" SIOCSIWSPY\n"); - rc = -EOPNOTSUPP; - break; - - // Get the spy list - case SIOCGIWSPY: - - pr_debug(" SIOCGIWSPY\n"); - rc = -EOPNOTSUPP; - break; - -#endif // WIRELESS_SPY - - case SIOCGIWPRIV: - pr_debug(" SIOCGIWPRIV\n"); - rc = -EOPNOTSUPP; - break; - -//2008-0409-07, by Einsn Liu -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - case SIOCSIWAUTH: - pr_debug(" SIOCSIWAUTH\n"); - rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL); - break; - - case SIOCGIWAUTH: - pr_debug(" SIOCGIWAUTH\n"); - rc = iwctl_giwauth(dev, NULL, &(wrq->u.param), NULL); - break; - - case SIOCSIWGENIE: - pr_debug(" SIOCSIWGENIE\n"); - rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer); - break; - - case SIOCGIWGENIE: - pr_debug(" SIOCGIWGENIE\n"); - rc = iwctl_giwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer); - break; - - case SIOCSIWENCODEEXT: { - char extra[sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1]; - - pr_debug(" SIOCSIWENCODEEXT\n"); - if (wrq->u.encoding.pointer) { - memset(extra, 0, sizeof(struct iw_encode_ext)+MAX_KEY_LEN + 1); - if (wrq->u.encoding.length > (sizeof(struct iw_encode_ext) + MAX_KEY_LEN)) { - rc = -E2BIG; - break; - } - if (copy_from_user(extra, wrq->u.encoding.pointer, wrq->u.encoding.length)) { - rc = -EFAULT; - break; - } - } else if (wrq->u.encoding.length != 0) { - rc = -EINVAL; - break; - } - rc = iwctl_siwencodeext(dev, NULL, &(wrq->u.encoding), extra); - } - break; - - case SIOCGIWENCODEEXT: - pr_debug(" SIOCGIWENCODEEXT\n"); - rc = iwctl_giwencodeext(dev, NULL, &(wrq->u.encoding), NULL); - break; - - case SIOCSIWMLME: - pr_debug(" SIOCSIWMLME\n"); - rc = iwctl_siwmlme(dev, NULL, &(wrq->u.data), wrq->u.data.pointer); - break; - -#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -//End Add -- //2008-0409-07, by Einsn Liu - - case IOCTL_CMD_TEST: - - if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { - rc = -EFAULT; - break; - } - rc = 0; - pReq = (PSCmdRequest)rq; - pReq->wResult = MAGIC_CODE; - break; - - case IOCTL_CMD_SET: - - if (!(pDevice->flags & DEVICE_FLAGS_OPENED) && - (((PSCmdRequest)rq)->wCmdCode != WLAN_CMD_SET_WPA)) { - rc = -EFAULT; - break; - } - rc = 0; - - if (test_and_set_bit(0, (void *)&(pMgmt->uCmdBusy))) - return -EBUSY; - - rc = private_ioctl(pDevice, rq); - clear_bit(0, (void *)&(pMgmt->uCmdBusy)); - break; - - case IOCTL_CMD_HOSTAPD: - - rc = vt6655_hostap_ioctl(pDevice, &wrq->u.data); - break; - - case IOCTL_CMD_WPA: - - rc = wpa_ioctl(pDevice, &wrq->u.data); - break; - - case SIOCETHTOOL: - return ethtool_ioctl(dev, rq->ifr_data); - // All other calls are currently unsupported - - default: - rc = -EOPNOTSUPP; - pr_debug("Ioctl command not support..%x\n", cmd); - - } - - if (pDevice->bCommit) { - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); - spin_unlock_irq(&pDevice->lock); - } else { - pr_debug("Commit the settings\n"); - spin_lock_irq(&pDevice->lock); - pDevice->bLinkPass = false; - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; - netif_stop_queue(pDevice->dev); -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - pMgmt->eScanType = WMAC_SCAN_ACTIVE; - if (!pDevice->bWPASuppWextEnabled) -#endif - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); - spin_unlock_irq(&pDevice->lock); - } - pDevice->bCommit = false; - } - - return rc; -} - -static int ethtool_ioctl(struct net_device *dev, void __user *useraddr) -{ - u32 ethcmd; - - if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd))) - return -EFAULT; - - switch (ethcmd) { - case ETHTOOL_GDRVINFO: { - struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO}; - - strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1); - strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1); - if (copy_to_user(useraddr, &info, sizeof(info))) - return -EFAULT; - return 0; - } - - } - - return -EOPNOTSUPP; -} - static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; @@ -3165,7 +1990,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) /* Enable the chip specified capabilities */ priv->flags = priv->sOpts.flags | (pChip_info->flags & 0xff000000UL); - priv->tx_80211 = device_dma0_tx_80211; wiphy = priv->hw->wiphy; diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 7302196eda03..53f81f1fefdc 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -723,8 +723,6 @@ vCommandTimer( } else { pDevice->bMoreData = true; } - if (!device_dma0_xmit(pDevice, skb, 0)) - pr_debug("Multicast ps tx fail\n"); pMgmt->sNodeDBTable[0].wEnQueueCnt--; } @@ -746,8 +744,6 @@ vCommandTimer( } else { pDevice->bMoreData = true; } - if (!device_dma0_xmit(pDevice, skb, ii)) - pr_debug("sta ps tx fail\n"); pMgmt->sNodeDBTable[ii].wEnQueueCnt--; // check if sta ps enabled, and wait next pspoll. -- cgit v1.2.3-59-g8ed1b From 0d24c97093f304fdca68af48e38e91d5ad01daf0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:22 +0000 Subject: staging: vt6655: dead code remove iwctl.c/h The iw handler and functions are nolonger required. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/iwctl.c | 1858 ---------------------------------- drivers/staging/vt6655/iwctl.h | 206 ---- 4 files changed, 2066 deletions(-) delete mode 100644 drivers/staging/vt6655/iwctl.c delete mode 100644 drivers/staging/vt6655/iwctl.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index f7544a6cb63e..455f088d54cb 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -29,7 +29,6 @@ vt6655_stage-y += device_main.o \ michael.o \ wroute.o \ rf.o \ - iwctl.o \ wpactl.o \ wpa2.o \ aes_ccmp.o \ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 870016ae9905..51b20f3d8e1b 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -71,7 +71,6 @@ #include "hostap.h" #include "wpactl.h" #include "ioctl.h" -#include "iwctl.h" #include "dpc.h" #include "datarate.h" #include "rf.h" diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c deleted file mode 100644 index cbcb152a4a0b..000000000000 --- a/drivers/staging/vt6655/iwctl.c +++ /dev/null @@ -1,1858 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: iwctl.c - * - * Purpose: wireless ext & ioctl functions - * - * Author: Lyndon Chen - * - * Date: July 5, 2006 - * - * Functions: - * - * Revision History: - * - */ - -#include "device.h" -#include "ioctl.h" -#include "iocmd.h" -#include "iwctl.h" -#include "mac.h" -#include "card.h" -#include "hostap.h" -#include "power.h" -#include "rf.h" - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -#include "iowpa.h" -#include "wpactl.h" -#endif - -#include -extern unsigned short TxRate_iwconfig; - -/*--------------------- Static Definitions -------------------------*/ - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -#define SUPPORTED_WIRELESS_EXT 18 -#else -#define SUPPORTED_WIRELESS_EXT 17 -#endif - -static const long frequency_list[] = { - 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, - 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980, - 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240, - 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, - 5700, 5745, 5765, 5785, 5805, 5825 -}; - -/*--------------------- Static Classes ----------------------------*/ -/*--------------------- Static Variables --------------------------*/ -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) -{ - struct vnt_private *pDevice = netdev_priv(dev); - long ldBm; - - pDevice->wstats.status = pDevice->op_mode; -#ifdef Calcu_LinkQual - if (pDevice->scStatistic.LinkQuality > 100) - pDevice->scStatistic.LinkQuality = 100; - pDevice->wstats.qual.qual = (unsigned char)pDevice->scStatistic.LinkQuality; -#else - pDevice->wstats.qual.qual = pDevice->byCurrSQ; -#endif - RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm); - pDevice->wstats.qual.level = ldBm; - pDevice->wstats.qual.noise = 0; - pDevice->wstats.qual.updated = 1; - pDevice->wstats.discard.nwid = 0; - pDevice->wstats.discard.code = 0; - pDevice->wstats.discard.fragment = 0; - pDevice->wstats.discard.retries = (unsigned long)pDevice->scStatistic.dwTsrErr; - pDevice->wstats.discard.misc = 0; - pDevice->wstats.miss.beacon = 0; - - return &pDevice->wstats; -} - -/*------------------------------------------------------------------*/ - -static int iwctl_commit(struct net_device *dev, - struct iw_request_info *info, - void *wrq, - char *extra) -{ - pr_debug(" SIOCSIWCOMMIT\n"); - - return 0; -} - -/* Wireless Handler : get protocol name */ -int iwctl_giwname(struct net_device *dev, - struct iw_request_info *info, - char *wrq, - char *extra) -{ - strcpy(wrq, "802.11-a/b/g"); - return 0; -} - -/* Wireless Handler : set scan */ -static int iwctl_siwscan(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - struct iw_scan_req *req = (struct iw_scan_req *)extra; - unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - PWLAN_IE_SSID pItemSSID = NULL; - - pr_debug(" SIOCSIWSCAN\n"); - - if (pDevice->byReAssocCount > 0) { /* reject scan when re-associating! */ -/* send scan event to wpa_Supplicant */ - union iwreq_data wrqu; - - PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n"); - memset(&wrqu, 0, sizeof(wrqu)); - wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL); - return 0; - } - - spin_lock_irq(&pDevice->lock); - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); - -/* active scan OR passive scan OR desire_ssid scan */ - if (wrq->length == sizeof(struct iw_scan_req)) { - if (wrq->flags & IW_SCAN_THIS_ESSID) { /* desire_ssid scan */ - memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - pItemSSID = (PWLAN_IE_SSID)abyScanSSID; - pItemSSID->byElementID = WLAN_EID_SSID; - memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len); - if (pItemSSID->abySSID[req->essid_len - 1] == '\0') { - if (req->essid_len > 0) - pItemSSID->len = req->essid_len - 1; - } else - pItemSSID->len = req->essid_len; - pMgmt->eScanType = WMAC_SCAN_PASSIVE; - PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID, - ((PWLAN_IE_SSID)abyScanSSID)->len); - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); - spin_unlock_irq(&pDevice->lock); - - return 0; - } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { /* passive scan */ - pMgmt->eScanType = WMAC_SCAN_PASSIVE; - } - } else { /* active scan */ - pMgmt->eScanType = WMAC_SCAN_ACTIVE; - } - - pMgmt->eScanType = WMAC_SCAN_PASSIVE; - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - spin_unlock_irq(&pDevice->lock); - - return 0; -} - -/* Wireless Handler : get scan results */ -static int iwctl_giwscan(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - int ii, jj, kk; - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PKnownBSS pBSS; - PWLAN_IE_SSID pItemSSID; - PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates; - char *current_ev = extra; - char *end_buf = extra + IW_SCAN_MAX_DATA; - char *current_val = NULL; - struct iw_event iwe; - long ldBm; - char buf[MAX_WPA_IE_LEN * 2 + 30]; - - pr_debug(" SIOCGIWSCAN\n"); - - if (pMgmt->eScanState == WMAC_IS_SCANNING) { - /* In scanning.. */ - return -EAGAIN; - } - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0, jj = 0; jj < MAX_BSS_NUM; jj++) { - if (current_ev >= end_buf) - break; - pBSS = &(pMgmt->sBSSList[jj]); - if (pBSS->bActive) { - /* ADD mac address */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWAP; - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN); - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); - /* ADD ssid */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWESSID; - pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; - iwe.u.data.length = pItemSSID->len; - iwe.u.data.flags = 1; - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID); - /* ADD mode */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWMODE; - if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) - iwe.u.mode = IW_MODE_INFRA; - else - iwe.u.mode = IW_MODE_ADHOC; - - iwe.len = IW_EV_UINT_LEN; - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); - /* ADD frequency */ - pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates; - pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWFREQ; - iwe.u.freq.m = pBSS->uChannel; - iwe.u.freq.e = 0; - iwe.u.freq.i = 0; - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); - { - int f = (int)pBSS->uChannel - 1; - - if (f < 0)f = 0; - iwe.u.freq.m = frequency_list[f] * 100000; - iwe.u.freq.e = 1; - } - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); - /* ADD quality */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVQUAL; - RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); - iwe.u.qual.level = ldBm; - iwe.u.qual.noise = 0; - if (-ldBm < 50) - iwe.u.qual.qual = 100; - else if (-ldBm > 90) - iwe.u.qual.qual = 0; - else - iwe.u.qual.qual = (40 - (-ldBm - 50)) * 100 / 40; - - iwe.u.qual.updated = 7; - - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWENCODE; - iwe.u.data.length = 0; - if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - else - iwe.u.data.flags = IW_ENCODE_DISABLED; - - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWRATE; - iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; - current_val = current_ev + IW_EV_LCP_LEN; - - for (kk = 0; kk < 12; kk++) { - if (pSuppRates->abyRates[kk] == 0) - break; - /* Bit rate given in 500 kb/s units (+ 0x80) */ - iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000); - current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); - } - for (kk = 0; kk < 8; kk++) { - if (pExtSuppRates->abyRates[kk] == 0) - break; - /* Bit rate given in 500 kb/s units (+ 0x80) */ - iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000); - current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); - } - - if ((current_val - current_ev) > IW_EV_LCP_LEN) - current_ev = current_val; - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval); - iwe.u.data.length = strlen(buf); - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, buf); - - if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) { - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = pBSS->wWPALen; - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pBSS->byWPAIE); - } - - if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) { - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = pBSS->wRSNLen; - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pBSS->byRSNIE); - } - - } - } - - wrq->length = current_ev - extra; - return 0; -} - -/* Wireless Handler : set frequency or channel */ -int iwctl_siwfreq(struct net_device *dev, - struct iw_request_info *info, - struct iw_freq *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - int rc = 0; - - pr_debug(" SIOCSIWFREQ\n"); - - /* If setting by frequency, convert to a channel */ - if ((wrq->e == 1) && - (wrq->m >= (int) 2.412e8) && - (wrq->m <= (int) 2.487e8)) { - int f = wrq->m / 100000; - int c = 0; - - while ((c < 14) && (f != frequency_list[c])) - c++; - wrq->e = 0; - wrq->m = c + 1; - } - /* Setting by channel number */ - if ((wrq->m > 14) || (wrq->e > 0)) - rc = -EOPNOTSUPP; - else { - int channel = wrq->m; - - if ((channel < 1) || (channel > 14)) { - pr_debug("%s: New channel value of %d is invalid!\n", - dev->name, wrq->m); - rc = -EINVAL; - } else { - /* Yes ! We can set it !!! */ - pr_debug(" Set to channel = %d\n", channel); - pDevice->uChannel = channel; - /* Make change effect at once */ - pDevice->bCommit = true; - } - } - - return rc; -} - -/* Wireless Handler : get frequency or channel */ -int iwctl_giwfreq(struct net_device *dev, - struct iw_request_info *info, - struct iw_freq *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - pr_debug(" SIOCGIWFREQ\n"); - -#ifdef WEXT_USECHANNELS - wrq->m = (int)pMgmt->uCurrChannel; - wrq->e = 0; -#else - { - int f = (int)pMgmt->uCurrChannel - 1; - - if (f < 0) - f = 0; - wrq->m = frequency_list[f] * 100000; - wrq->e = 1; - } -#endif - - return 0; -} - -/* Wireless Handler : set operation mode */ -int iwctl_siwmode(struct net_device *dev, - struct iw_request_info *info, - __u32 *wmode, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int rc = 0; - - pr_debug(" SIOCSIWMODE\n"); - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) { - pr_debug("Can't set operation mode, hostapd is running\n"); - return rc; - } - - switch (*wmode) { - case IW_MODE_ADHOC: - if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { - pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - - } - pr_debug("set mode to ad-hoc\n"); - break; - case IW_MODE_AUTO: - case IW_MODE_INFRA: - if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) { - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - - } - pr_debug("set mode to infrastructure\n"); - break; - case IW_MODE_MASTER: - - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - rc = -EOPNOTSUPP; - break; - - case IW_MODE_REPEAT: - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - rc = -EOPNOTSUPP; - break; - default: - rc = -EINVAL; - } - - return rc; -} - -/* Wireless Handler : get operation mode */ -int iwctl_giwmode(struct net_device *dev, - struct iw_request_info *info, - __u32 *wmode, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - pr_debug(" SIOCGIWMODE\n"); - /* If not managed, assume it's ad-hoc */ - switch (pMgmt->eConfigMode) { - case WMAC_CONFIG_ESS_STA: - *wmode = IW_MODE_INFRA; - break; - case WMAC_CONFIG_IBSS_STA: - *wmode = IW_MODE_ADHOC; - break; - case WMAC_CONFIG_AUTO: - *wmode = IW_MODE_INFRA; - break; - case WMAC_CONFIG_AP: - *wmode = IW_MODE_MASTER; - break; - default: - *wmode = IW_MODE_ADHOC; - } - - return 0; -} - -/* Wireless Handler : get capability range */ -int iwctl_giwrange(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct iw_range *range = (struct iw_range *)extra; - int i, k; - unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; - - pr_debug(" SIOCGIWRANGE\n"); - if (wrq->pointer) { - wrq->length = sizeof(struct iw_range); - memset(range, 0, sizeof(struct iw_range)); - range->min_nwid = 0x0000; - range->max_nwid = 0x0000; - range->num_channels = 14; - /* - * Should be based on cap_rid.country to give only - * what the current card supports - */ - k = 0; - for (i = 0; i < 14; i++) { - range->freq[k].i = i + 1; /* List index */ - range->freq[k].m = frequency_list[i] * 100000; - range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ - } - range->num_frequency = k; - /* Hum... Should put the right values there */ -#ifdef Calcu_LinkQual - range->max_qual.qual = 100; -#else - range->max_qual.qual = 255; -#endif - range->max_qual.level = 0; - range->max_qual.noise = 0; - range->sensitivity = 255; - - for (i = 0; i < 13; i++) { - range->bitrate[i] = abySupportedRates[i] * 500000; - if (range->bitrate[i] == 0) - break; - } - range->num_bitrates = i; - - /* - * Set an indication of the max TCP throughput in bit/s that we - * can expect using this interface. May be used for QoS stuff - */ - if (i > 2) - range->throughput = 5 * 1000 * 1000; - else - range->throughput = 1.5 * 1000 * 1000; - - range->min_rts = 0; - range->max_rts = 2312; - range->min_frag = 256; - range->max_frag = 2312; - - /* the encoding capabilities */ - range->num_encoding_sizes = 3; - /* 64(40) bits WEP */ - range->encoding_size[0] = 5; - /* 128(104) bits WEP */ - range->encoding_size[1] = 13; - /* 256 bits for WPA-PSK */ - range->encoding_size[2] = 32; - /* 4 keys are allowed */ - range->max_encoding_tokens = 4; - - range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | - IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; - - range->min_pmp = 0; - range->max_pmp = 1000000; /* 1 secs */ - range->min_pmt = 0; - range->max_pmt = 1000000; /* 1 secs */ - range->pmp_flags = IW_POWER_PERIOD; - range->pmt_flags = IW_POWER_TIMEOUT; - range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; - - /* Transmit Power - values are in mW */ - - range->txpower[0] = 100; - range->num_txpower = 1; - range->txpower_capa = IW_TXPOW_MWATT; - range->we_version_source = SUPPORTED_WIRELESS_EXT; - range->we_version_compiled = WIRELESS_EXT; - range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; - range->retry_flags = IW_RETRY_LIMIT; - range->r_time_flags = IW_RETRY_LIFETIME; - range->min_retry = 1; - range->max_retry = 65535; - range->min_r_time = 1024; - range->max_r_time = 65535 * 1024; - /* - * Experimental measurements - boundary 11/5.5 Mb/s - * Note : with or without the (local->rssi), results - * are somewhat different. - Jean II - */ - range->avg_qual.qual = 6; - range->avg_qual.level = 176; /* -80 dBm */ - range->avg_qual.noise = 0; - } - - return 0; -} - -/* Wireless Handler : set ap mac address */ -int iwctl_siwap(struct net_device *dev, - struct iw_request_info *info, - struct sockaddr *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int rc = 0; - unsigned char ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - pr_debug(" SIOCSIWAP\n"); - if (pMgmt->eScanState == WMAC_IS_SCANNING) { - /* In scanning.. */ - pr_debug("SIOCSIWAP(??)-->In scanning..\n"); - } - if (wrq->sa_family != ARPHRD_ETHER) - rc = -EINVAL; - else { - memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6); - if ((pDevice->bLinkPass == true) && - (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6) == 0)) { - return rc; - } - if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) || - (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)) { - PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n"); - return rc; - } - /* if desired AP is hidden ssid(there are two same BSSID in - * list), then ignore,because you don't known which one - * to be connected with?? - */ - { - unsigned int ii, uSameBssidNum = 0; - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - if (pMgmt->sBSSList[ii].bActive && - ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, - pMgmt->abyDesireBSSID)) { - uSameBssidNum++; - } - } - if (uSameBssidNum >= 2) { /* hit: desired AP is in hidden ssid mode!!! */ - PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n"); - return rc; - } - } - - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - - } - return rc; -} - -/* Wireless Handler : get ap mac address */ -int iwctl_giwap(struct net_device *dev, - struct iw_request_info *info, - struct sockaddr *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - pr_debug(" SIOCGIWAP\n"); - - memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); - if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) - memset(wrq->sa_data, 0, 6); - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) - memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); - - wrq->sa_family = ARPHRD_ETHER; - - return 0; -} - -/* Wireless Handler : get ap list */ -int iwctl_giwaplist(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - int ii, jj, rc = 0; - struct sockaddr *sock = NULL; - struct sockaddr *s = NULL; - struct iw_quality *qual = NULL; - struct iw_quality *q = NULL; - PKnownBSS pBSS = NULL; - - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - pr_debug(" SIOCGIWAPLIST\n"); - - if (!capable(CAP_NET_ADMIN)) { - rc = -EPERM; - goto exit; - } - - if (!wrq->pointer) - goto exit; - - sock = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL); - if (!sock) { - rc = -ENOMEM; - goto exit; - } - - qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL); - if (!qual) { - rc = -ENOMEM; - goto exit; - } - - for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - - if (!pBSS->bActive) - continue; - if (jj >= IW_MAX_AP) - break; - - s = &sock[jj]; - q = &qual[jj]; - - memcpy(s->sa_data, pBSS->abyBSSID, 6); - s->sa_family = ARPHRD_ETHER; - q->level = pBSS->uRSSI; - q->qual = 0; - q->noise = 0; - q->updated = 2; - jj++; - } - - wrq->flags = 1; /* Should be define'd */ - wrq->length = jj; - memcpy(extra, sock, sizeof(struct sockaddr) * jj); - memcpy(extra + sizeof(struct sockaddr) * jj, - qual, - sizeof(struct iw_quality) * jj); -exit: - kfree(sock); - kfree(qual); - return rc; -} - -/* Wireless Handler : set essid */ -int iwctl_siwessid(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PWLAN_IE_SSID pItemSSID; - unsigned char len; - - pr_debug(" SIOCSIWESSID\n"); - pDevice->fWPA_Authened = false; - if (pMgmt->eScanState == WMAC_IS_SCANNING) { - /* In scanning.. */ - pr_debug("SIOCSIWESSID(??)-->In scanning..\n"); - } - /* Check if we asked for 'any' */ - if (wrq->flags == 0) { - /* Just send an empty SSID list */ - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memset(pMgmt->abyDesireBSSID, 0xFF, 6); - PRINT_K("set essid to 'any'\n"); -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - return 0; -#endif - } else { - /* Set the SSID */ - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; - pItemSSID->byElementID = WLAN_EID_SSID; - - memcpy(pItemSSID->abySSID, extra, wrq->length); - if (pItemSSID->abySSID[wrq->length - 1] == '\0') { - if (wrq->length > 0) - pItemSSID->len = wrq->length - 1; - } else - pItemSSID->len = wrq->length; - pr_debug("set essid to %s\n", pItemSSID->abySSID); - len = (pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) ? pItemSSID->len : ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len; - if ((pDevice->bLinkPass == true) && - (memcmp(pItemSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, len) == 0)) - return 0; - - /* need clear desiredBSSID */ - if (pItemSSID->len == 0) { - memset(pMgmt->abyDesireBSSID, 0xFF, 6); - return 0; - } - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - /* - * Wext wil order another command of siwap to link with desired - * AP, so here need not associate?? - */ - if (pDevice->bWPASuppWextEnabled == true) { - /*******search if in hidden ssid mode ****/ - { - PKnownBSS pCurr = NULL; - unsigned char abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - unsigned int ii, uSameBssidNum = 0; - - memcpy(abyTmpDesireSSID, pMgmt->abyDesireSSID, sizeof(abyTmpDesireSSID)); - pCurr = BSSpSearchBSSList(pDevice, - NULL, - abyTmpDesireSSID, - pMgmt->eConfigPHYMode -); - - if (pCurr == NULL) { - PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n"); - vResetCommandTimer((void *)pDevice); - pMgmt->eScanType = WMAC_SCAN_ACTIVE; - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID); - } else { /* - * to find out if that desired SSID - * is a hidden-ssid AP, by means of - * judging if there are two same - * BSSID exist in list ? - */ - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - if (pMgmt->sBSSList[ii].bActive && - ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, - pCurr->abyBSSID)) { - uSameBssidNum++; - } - } - if (uSameBssidNum >= 2) { /* hit: desired AP is in hidden ssid mode!!! */ - pr_debug("SIOCSIWESSID:hidden ssid directly associate.......\n"); - vResetCommandTimer((void *)pDevice); - pMgmt->eScanType = WMAC_SCAN_PASSIVE; /* this scan type, you'll submit scan result! */ - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID); - } - } - } - return 0; - } -#endif - - pr_debug("set essid = %s\n", pItemSSID->abySSID); - } - - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - - return 0; -} - -/* Wireless Handler : get essid */ -int iwctl_giwessid(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - PWLAN_IE_SSID pItemSSID; - - pr_debug(" SIOCGIWESSID\n"); - - /* - * Note : if wrq->u.data.flags != 0, we should get the relevant SSID - * from the SSID list... - */ - - /* Get the current SSID */ - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - memcpy(extra, pItemSSID->abySSID , pItemSSID->len); - extra[pItemSSID->len] = '\0'; - wrq->length = pItemSSID->len + 1; - wrq->length = pItemSSID->len; - wrq->flags = 1; /* active */ - - return 0; -} - -/* Wireless Handler : set data rate */ -int iwctl_siwrate(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - int rc = 0; - u8 brate = 0; - int i; - unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; - - pr_debug(" SIOCSIWRATE\n"); - if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { - rc = -EINVAL; - return rc; - } - - /* First : get a valid bit rate value */ - - /* Which type of value */ - if ((wrq->value < 13) && - (wrq->value >= 0)) { - /* Setting by rate index, Find value in the magic rate table */ - brate = wrq->value; - } else { - /* Setting by frequency value */ - u8 normvalue = (u8) (wrq->value/500000); - - /* Check if rate is valid */ - for (i = 0; i < 13; i++) { - if (normvalue == abySupportedRates[i]) { - brate = i; - break; - } - } - } - /* -1 designed the max rate (mostly auto mode) */ - if (wrq->value == -1) { - /* Get the highest available rate */ - for (i = 0; i < 13; i++) { - if (abySupportedRates[i] == 0) - break; - } - if (i != 0) - brate = i - 1; - - } - /* Check that it is valid, brate is index of abySupportedRates[] */ - if (brate > 13) { - rc = -EINVAL; - return rc; - } - - /* Now, check if we want a fixed or auto value */ - if (wrq->fixed != 0) { - /* Fixed mode, One rate, fixed */ - pr_debug("Rate Fix\n"); - pDevice->bFixRate = true; - if ((pDevice->byBBType == BB_TYPE_11B) && (brate > 3)) { - pDevice->uConnectionRate = 3; - } else { - pDevice->uConnectionRate = brate; - pr_debug("Fixed to Rate %d\n", - pDevice->uConnectionRate); - } - - } else { - pDevice->bFixRate = false; - pDevice->uConnectionRate = 13; - pr_debug("auto rate:connection_rate is 13\n"); - } - - return rc; -} - -/* Wireless Handler : get data rate */ -int iwctl_giwrate(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); -/* Mark the unnecessary sentences. */ - pr_debug(" SIOCGIWRATE\n"); - { - unsigned char abySupportedRates[13] = {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; - int brate = 0; - if (pDevice->bLinkPass) { - if (pDevice->bFixRate == true) { - if (pDevice->uConnectionRate < 13) { - brate = abySupportedRates[pDevice->uConnectionRate]; - } else { - if (pDevice->byBBType == BB_TYPE_11B) - brate = 0x16; - if (pDevice->byBBType == BB_TYPE_11G) - brate = 0x6C; - if (pDevice->byBBType == BB_TYPE_11A) - brate = 0x6C; - } - } else { - brate = abySupportedRates[TxRate_iwconfig]; - } - } else brate = 0; - - wrq->value = brate * 500000; - /* If more than one rate, set auto */ - if (pDevice->bFixRate == true) - wrq->fixed = true; - } - - return 0; -} - -/* Wireless Handler : set rts threshold */ -int iwctl_siwrts(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - int rc = 0; - - pr_debug(" SIOCSIWRTS\n"); - - { - int rthr = wrq->value; - - if (wrq->disabled) - rthr = 2312; - - if ((rthr < 0) || (rthr > 2312)) - rc = -EINVAL; - else - pDevice->wRTSThreshold = rthr; - } - - return 0; -} - -/* Wireless Handler : get rts */ -int iwctl_giwrts(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - - pr_debug(" SIOCGIWRTS\n"); - wrq->value = pDevice->wRTSThreshold; - wrq->disabled = (wrq->value >= 2312); - wrq->fixed = 1; - - return 0; -} - -/* Wireless Handler : set fragment threshold */ -int iwctl_siwfrag(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - int rc = 0; - int fthr = wrq->value; - - pr_debug(" SIOCSIWFRAG\n"); - - if (wrq->disabled) - fthr = 2312; - if ((fthr < 256) || (fthr > 2312)) { - rc = -EINVAL; - } else { - fthr &= ~0x1; /* Get an even value */ - pDevice->wFragmentationThreshold = (u16)fthr; - } - - return rc; -} - -/* Wireless Handler : get fragment threshold */ -int iwctl_giwfrag(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - - pr_debug(" SIOCGIWFRAG\n"); - wrq->value = pDevice->wFragmentationThreshold; - wrq->disabled = (wrq->value >= 2312); - wrq->fixed = 1; - - return 0; -} - -/* Wireless Handler : set retry threshold */ -int iwctl_siwretry(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - int rc = 0; - - pr_debug(" SIOCSIWRETRY\n"); - - if (wrq->disabled) { - rc = -EINVAL; - return rc; - } - - if (wrq->flags & IW_RETRY_LIMIT) { - if (wrq->flags & IW_RETRY_MAX) - pDevice->byLongRetryLimit = wrq->value; - else if (wrq->flags & IW_RETRY_MIN) - pDevice->byShortRetryLimit = wrq->value; - else { - /* No modifier : set both */ - pDevice->byShortRetryLimit = wrq->value; - pDevice->byLongRetryLimit = wrq->value; - } - } - if (wrq->flags & IW_RETRY_LIFETIME) - pDevice->wMaxTransmitMSDULifetime = wrq->value; - - return rc; -} - -/* Wireless Handler : get retry threshold */ -int iwctl_giwretry(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - - pr_debug(" SIOCGIWRETRY\n"); - wrq->disabled = 0; /* Can't be disabled */ - - /* Note : by default, display the min retry number */ - if ((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - wrq->flags = IW_RETRY_LIFETIME; - wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; /* ms */ - } else if ((wrq->flags & IW_RETRY_MAX)) { - wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; - wrq->value = (int)pDevice->byLongRetryLimit; - } else { - wrq->flags = IW_RETRY_LIMIT; - wrq->value = (int)pDevice->byShortRetryLimit; - if ((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit) - wrq->flags |= IW_RETRY_MIN; - } - - return 0; -} - -/* Wireless Handler : set encode mode */ -int iwctl_siwencode(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - unsigned long dwKeyIndex = (unsigned long)(wrq->flags & IW_ENCODE_INDEX); - int ii, uu, rc = 0; - int index = (wrq->flags & IW_ENCODE_INDEX); - -/* - * There are some problems when using iwconfig encode/key command to set the - * WEP key. I almost rewrite this function. Now it supports: (assume the - * wireless interface's name is eth0) - * iwconfig eth0 key [1] 1122334455 open -> set key stirng to index 1, and - driver using key index is set to 1 - * iwconfig eth0 key [3] -> set driver using key index to 3,the key string no change - * iwconfig eth0 key 1122334455 -> set key string to driver using index - * iwconfig eth0 key restricted -> enable share key - */ - - PSKeyTable pkeytab; - - pr_debug(" SIOCSIWENCODE\n"); - - if ((wrq->flags & IW_ENCODE_DISABLED) == 0) { - /* Not disable encryption */ - - if (dwKeyIndex > WLAN_WEP_NKEYS) { - rc = -EINVAL; - return rc; - } - - if (dwKeyIndex < 1 && ((wrq->flags & IW_ENCODE_NOKEY) == 0)) { /* set default key */ - if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) - dwKeyIndex = pDevice->byKeyIndex; - else - dwKeyIndex = 0; - } else { - dwKeyIndex--; - } - - /* Check the size of the key */ - if (wrq->length > WLAN_WEP232_KEYLEN) { - rc = -EINVAL; - return rc; - } - - if (wrq->length > 0) { /* have key */ - - if (wrq->length == WLAN_WEP232_KEYLEN) { - pr_debug("Set 232 bit wep key\n"); - } else if (wrq->length == WLAN_WEP104_KEYLEN) { - pr_debug("Set 104 bit wep key\n"); - } else if (wrq->length == WLAN_WEP40_KEYLEN) { - pr_debug("Set 40 bit wep key, index= %d\n", - (int)dwKeyIndex); - } else { /* no support length */ - rc = -EINVAL; - return rc; - } - memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN); - memcpy(pDevice->abyKey, extra, wrq->length); - - pr_debug("abyKey: "); - for (ii = 0; ii < wrq->length; ii++) - pr_debug("%02x ", pDevice->abyKey[ii]); - - if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); - KeybSetDefaultKey(&(pDevice->sKey), - (unsigned long)(dwKeyIndex | (1 << 31)), - wrq->length, - NULL, - pDevice->abyKey, - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID -); - spin_unlock_irq(&pDevice->lock); - } - pDevice->byKeyIndex = (unsigned char)dwKeyIndex; - pDevice->uKeyLength = wrq->length; - pDevice->bTransmitKey = true; - pDevice->bEncryptionEnable = true; - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - - } else if (index > 0) { - /* - * when the length is 0 the request only changes the - * default transmit key index, check the new key if it - * has a non zero length - */ - if (pDevice->bEncryptionEnable == false) { - rc = -EINVAL; - return rc; - } - pr_debug("Just set Default key Index:\n"); - pkeytab = &(pDevice->sKey.KeyTable[MAX_KEY_TABLE - 1]); - if (pkeytab->GroupKey[(unsigned char)dwKeyIndex].uKeyLength == 0) { - pr_debug("Default key len is 0\n"); - rc = -EINVAL; - return rc; - } - pDevice->byKeyIndex = (unsigned char)dwKeyIndex; - pkeytab->dwGTKeyIndex = dwKeyIndex | (1 << 31); - pkeytab->GroupKey[(unsigned char)dwKeyIndex].dwKeyIndex = dwKeyIndex | (1 << 31); - } - - } else { /* disable the key */ - pr_debug("Disable WEP function\n"); - if (pDevice->bEncryptionEnable == false) - return 0; - pMgmt->bShareKeyAlgorithm = false; - pDevice->bEncryptionEnable = false; - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); - for (uu = 0; uu < MAX_KEY_TABLE; uu++) - MACvDisableKeyEntry(pDevice->PortOffset, uu); - spin_unlock_irq(&pDevice->lock); - } - } - - if (wrq->flags & IW_ENCODE_RESTRICTED) { - pr_debug("Enable WEP & ShareKey System\n"); - pMgmt->bShareKeyAlgorithm = true; - } - if (wrq->flags & IW_ENCODE_OPEN) { - pr_debug("Enable WEP & Open System\n"); - pMgmt->bShareKeyAlgorithm = false; - } - return rc; -} - -int iwctl_giwencode(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - char abyKey[WLAN_WEP232_KEYLEN]; - - unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX); - PSKeyItem pKey = NULL; - - pr_debug(" SIOCGIWENCODE\n"); - - if (index > WLAN_WEP_NKEYS) - return -EINVAL; - - if (index < 1) { /* get default key */ - if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) - index = pDevice->byKeyIndex; - else - index = 0; - } else { - index--; - } - - memset(abyKey, 0, WLAN_WEP232_KEYLEN); - /* Check encryption mode */ - wrq->flags = IW_ENCODE_NOKEY; - /* Is WEP enabled ??? */ - if (pDevice->bEncryptionEnable) - wrq->flags |= IW_ENCODE_ENABLED; - else - wrq->flags |= IW_ENCODE_DISABLED; - - if (pMgmt->bShareKeyAlgorithm) - wrq->flags |= IW_ENCODE_RESTRICTED; - else - wrq->flags |= IW_ENCODE_OPEN; - wrq->length = 0; - - if ((index == 0) && (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled || - pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)) { /* get wpa pairwise key */ - if (KeybGetKey(&(pDevice->sKey), pMgmt->abyCurrBSSID, 0xffffffff, &pKey)) { - wrq->length = pKey->uKeyLength; - memcpy(abyKey, pKey->abyKey, pKey->uKeyLength); - memcpy(extra, abyKey, WLAN_WEP232_KEYLEN); - } - } else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)) { - wrq->length = pKey->uKeyLength; - memcpy(abyKey, pKey->abyKey, pKey->uKeyLength); - memcpy(extra, abyKey, WLAN_WEP232_KEYLEN); - } - - wrq->flags |= index+1; - - return 0; -} - -/* Wireless Handler : set power mode */ -int iwctl_siwpower(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int rc = 0; - - pr_debug(" SIOCSIWPOWER\n"); - - if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { - rc = -EINVAL; - return rc; - } - - if (wrq->disabled) { - pDevice->ePSMode = WMAC_POWER_CAM; - PSvDisablePowerSaving(pDevice); - return rc; - } - if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { - pDevice->ePSMode = WMAC_POWER_FAST; - PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval); - - } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { - pDevice->ePSMode = WMAC_POWER_FAST; - PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval); - } - switch (wrq->flags & IW_POWER_MODE) { - case IW_POWER_UNICAST_R: - pr_debug(" SIOCSIWPOWER: IW_POWER_UNICAST_R\n"); - rc = -EINVAL; - break; - case IW_POWER_ALL_R: - pr_debug(" SIOCSIWPOWER: IW_POWER_ALL_R\n"); - rc = -EINVAL; - case IW_POWER_ON: - pr_debug(" SIOCSIWPOWER: IW_POWER_ON\n"); - break; - default: - rc = -EINVAL; - } - - return rc; -} - -/* Wireless Handler : get power mode */ -int iwctl_giwpower(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int mode = pDevice->ePSMode; - - pr_debug(" SIOCGIWPOWER\n"); - - wrq->disabled = (mode == WMAC_POWER_CAM); - if (wrq->disabled) - return 0; - - if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { - wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10); - wrq->flags = IW_POWER_TIMEOUT; - } else { - wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10); - wrq->flags = IW_POWER_PERIOD; - } - wrq->flags |= IW_POWER_ALL_R; - - return 0; -} - -/* Wireless Handler : get Sensitivity */ -int iwctl_giwsens(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - long ldBm; - - pr_debug(" SIOCGIWSENS\n"); - if (pDevice->bLinkPass == true) { - RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm); - wrq->value = ldBm; - } else { - wrq->value = 0; - } - wrq->disabled = (wrq->value == 0); - wrq->fixed = 1; - - return 0; -} - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - -int iwctl_siwauth(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int ret = 0; - static int wpa_version = 0; /* must be static to save the last value */ - static int pairwise = 0; - - pr_debug(" SIOCSIWAUTH\n"); - switch (wrq->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: - wpa_version = wrq->value; - if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED) - PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n"); - else if (wrq->value == IW_AUTH_WPA_VERSION_WPA) - PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n"); - else - PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n"); - - break; - case IW_AUTH_CIPHER_PAIRWISE: - pairwise = wrq->value; - if (pairwise == IW_AUTH_CIPHER_CCMP) - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - else if (pairwise == IW_AUTH_CIPHER_TKIP) - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - else if (pairwise == IW_AUTH_CIPHER_WEP40 || pairwise == IW_AUTH_CIPHER_WEP104) - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - else if (pairwise == IW_AUTH_CIPHER_NONE) - ; /* do nothing */ - else - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - - break; - case IW_AUTH_CIPHER_GROUP: - if (wpa_version == IW_AUTH_WPA_VERSION_DISABLED) - break; - if (pairwise == IW_AUTH_CIPHER_NONE) { - if (wrq->value == IW_AUTH_CIPHER_CCMP) - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - else - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - } - break; - case IW_AUTH_KEY_MGMT: - - if (wpa_version == IW_AUTH_WPA_VERSION_WPA2) { - if (wrq->value == IW_AUTH_KEY_MGMT_PSK) - pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; - else - pMgmt->eAuthenMode = WMAC_AUTH_WPA2; - } else if (wpa_version == IW_AUTH_WPA_VERSION_WPA) { - if (wrq->value == 0) - pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; - else if (wrq->value == IW_AUTH_KEY_MGMT_PSK) - pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; - else - pMgmt->eAuthenMode = WMAC_AUTH_WPA; - } - - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - break; /* FIXME */ - case IW_AUTH_DROP_UNENCRYPTED: - break; - case IW_AUTH_80211_AUTH_ALG: - if (wrq->value == IW_AUTH_ALG_OPEN_SYSTEM) - pMgmt->bShareKeyAlgorithm = false; - else if (wrq->value == IW_AUTH_ALG_SHARED_KEY) - pMgmt->bShareKeyAlgorithm = true; - - break; - case IW_AUTH_WPA_ENABLED: - break; - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - break; - case IW_AUTH_ROAMING_CONTROL: - ret = -EOPNOTSUPP; - break; - case IW_AUTH_PRIVACY_INVOKED: - pDevice->bEncryptionEnable = !!wrq->value; - if (pDevice->bEncryptionEnable == false) { - wpa_version = 0; - pairwise = 0; - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - pMgmt->bShareKeyAlgorithm = false; - pMgmt->eAuthenMode = false; - } - - break; - default: - ret = -EOPNOTSUPP; - break; - } - - return ret; -} - -int iwctl_giwauth(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra) -{ - return -EOPNOTSUPP; -} - -int iwctl_siwgenie(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char __user *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int ret = 0; - char length; - - if (wrq->length) { - if (wrq->length < 2) - return -EINVAL; - - ret = get_user(length, extra + 1); - if (ret) - return ret; - - if (length + 2 != wrq->length) - return -EINVAL; - - if (wrq->length > MAX_WPA_IE_LEN) { - ret = -ENOMEM; - goto out; - } - memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN); - if (copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)) { - ret = -EFAULT; - goto out; - } - pMgmt->wWPAIELen = wrq->length; - } else { - memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN); - pMgmt->wWPAIELen = 0; - } - -out: /* not completely ...not necessary in wpa_supplicant 0.5.8 */ - return ret; -} - -int iwctl_giwgenie(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char __user *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int ret = 0; - int space = wrq->length; - - wrq->length = 0; - if (pMgmt->wWPAIELen > 0) { - wrq->length = pMgmt->wWPAIELen; - if (pMgmt->wWPAIELen <= space) { - if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)) - ret = -EFAULT; - - } else { - ret = -E2BIG; - } - } - - return ret; -} - -int iwctl_siwencodeext(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - struct viawget_wpa_param *param = NULL; -/* original member */ - enum wpa_alg alg_name; - u8 addr[6]; - int key_idx, set_tx = 0; - u8 seq[IW_ENCODE_SEQ_MAX_SIZE]; - u8 key[64]; - size_t seq_len = 0, key_len = 0; - - u8 key_array[64]; - int ret = 0; - - PRINT_K("SIOCSIWENCODEEXT......\n"); - - param = kzalloc(sizeof(*param), GFP_KERNEL); - if (param == NULL) - return -ENOMEM; - -/* recover alg_name */ - switch (ext->alg) { - case IW_ENCODE_ALG_NONE: - alg_name = WPA_ALG_NONE; - break; - case IW_ENCODE_ALG_WEP: - alg_name = WPA_ALG_WEP; - break; - case IW_ENCODE_ALG_TKIP: - alg_name = WPA_ALG_TKIP; - break; - case IW_ENCODE_ALG_CCMP: - alg_name = WPA_ALG_CCMP; - break; - default: - PRINT_K("Unknown alg = %d\n", ext->alg); - ret = -ENOMEM; - goto error; - } -/* recover addr */ - ether_addr_copy(addr, ext->addr.sa_data); -/* recover key_idx */ - key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1; -/* recover set_tx */ - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) - set_tx = 1; -/* recover seq,seq_len */ - if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { - seq_len = IW_ENCODE_SEQ_MAX_SIZE; - memcpy(seq, ext->rx_seq, seq_len); - } -/* recover key,key_len */ - if (ext->key_len) { - key_len = ext->key_len; - memcpy(key, &ext->key[0], key_len); - } - - memset(key_array, 0, 64); - if (key_len > 0) { - memcpy(key_array, key, key_len); - if (key_len == 32) { - /* notice ! the oder */ - memcpy(&key_array[16], &key[24], 8); - memcpy(&key_array[24], &key[16], 8); - } - } - -/**************Translate iw_encode_ext to viawget_wpa_param****************/ - ether_addr_copy(param->addr, addr); - param->u.wpa_key.alg_name = (int)alg_name; - param->u.wpa_key.set_tx = set_tx; - param->u.wpa_key.key_index = key_idx; - param->u.wpa_key.key_len = key_len; - param->u.wpa_key.key = (u8 *)key_array; - param->u.wpa_key.seq = (u8 *)seq; - param->u.wpa_key.seq_len = seq_len; - -/* - * set if current action is Network Manager count?? this method is so - * foolish,but there is no other way??? - */ - if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { - if (param->u.wpa_key.key_index == 0) - pDevice->bwextcount++; - - if ((pDevice->bwextcount == 1) && (param->u.wpa_key.key_index == 1)) - pDevice->bwextcount++; - - if ((pDevice->bwextcount == 2) && (param->u.wpa_key.key_index == 2)) - pDevice->bwextcount++; - - if ((pDevice->bwextcount == 3) && (param->u.wpa_key.key_index == 3)) - pDevice->bwextcount++; - - } - if (pDevice->bwextcount == 4) { - pr_debug("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n"); - pDevice->bwextcount = 0; - pDevice->bWPASuppWextEnabled = true; - } - - spin_lock_irq(&pDevice->lock); - ret = wpa_set_keys(pDevice, param, true); - spin_unlock_irq(&pDevice->lock); - -error: - kfree(param); - return ret; -} - -int iwctl_giwencodeext(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) -{ - return -EOPNOTSUPP; -} - -int iwctl_siwmlme(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char __user *extra) -{ - struct vnt_private *pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - struct iw_mlme mime; - - int ret = 0; - - ret = copy_from_user(&mime, extra, sizeof(mime)); - if (ret) - return -EFAULT; - - if (memcmp(pMgmt->abyCurrBSSID, mime.addr.sa_data, ETH_ALEN)) { - ret = -EINVAL; - return ret; - } - switch (mime.cmd) { - case IW_MLME_DEAUTH: - /* - * this command seems to be not complete,please test it --einsnliu - * bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason); - */ - break; - case IW_MLME_DISASSOC: - if (pDevice->bLinkPass == true) { - pr_debug("iwctl_siwmlme--->send DISASSOCIATE\n"); - /* clear related flags */ - memset(pMgmt->abyDesireBSSID, 0xFF, 6); - KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); - bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); - } - break; - default: - ret = -EOPNOTSUPP; - } - - return ret; -} - -#endif - -/* Structures to export the Wireless Handlers */ -static const iw_handler iwctl_handler[] = -{ - (iw_handler) iwctl_commit, /* SIOCSIWCOMMIT */ - (iw_handler) NULL, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) NULL, /* SIOCSIWFREQ */ - (iw_handler) NULL, /* SIOCGIWFREQ */ - (iw_handler) NULL, /* SIOCSIWMODE */ - (iw_handler) NULL, /* SIOCGIWMODE */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ - (iw_handler) NULL, /* SIOCSIWRANGE */ - (iw_handler) iwctl_giwrange, /* SIOCGIWRANGE */ - (iw_handler) NULL, /* SIOCSIWPRIV */ - (iw_handler) NULL, /* SIOCGIWPRIV */ - (iw_handler) NULL, /* SIOCSIWSTATS */ - (iw_handler) NULL, /* SIOCGIWSTATS */ - (iw_handler) NULL, /* SIOCSIWSPY */ - (iw_handler) NULL, /* SIOCGIWSPY */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWAP */ - (iw_handler) NULL, /* SIOCGIWAP */ - (iw_handler) NULL, /* -- hole -- 0x16 */ - (iw_handler) NULL, /* SIOCGIWAPLIST */ - (iw_handler) iwctl_siwscan, /* SIOCSIWSCAN */ - (iw_handler) iwctl_giwscan, /* SIOCGIWSCAN */ - (iw_handler) NULL, /* SIOCSIWESSID */ - (iw_handler) NULL, /* SIOCGIWESSID */ - (iw_handler) NULL, /* SIOCSIWNICKN */ - (iw_handler) NULL, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWRATE 0x20 */ - (iw_handler) NULL, /* SIOCGIWRATE */ - (iw_handler) NULL, /* SIOCSIWRTS */ - (iw_handler) NULL, /* SIOCGIWRTS */ - (iw_handler) NULL, /* SIOCSIWFRAG */ - (iw_handler) NULL, /* SIOCGIWFRAG */ - (iw_handler) NULL, /* SIOCSIWTXPOW */ - (iw_handler) NULL, /* SIOCGIWTXPOW */ - (iw_handler) NULL, /* SIOCSIWRETRY */ - (iw_handler) NULL, /* SIOCGIWRETRY */ - (iw_handler) NULL, /* SIOCSIWENCODE */ - (iw_handler) NULL, /* SIOCGIWENCODE */ - (iw_handler) NULL, /* SIOCSIWPOWER */ - (iw_handler) NULL, /* SIOCGIWPOWER */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWGENIE */ - (iw_handler) NULL, /* SIOCGIWGENIE */ - (iw_handler) NULL, /* SIOCSIWAUTH */ - (iw_handler) NULL, /* SIOCGIWAUTH */ - (iw_handler) NULL, /* SIOCSIWENCODEEXT */ - (iw_handler) NULL, /* SIOCGIWENCODEEXT */ - (iw_handler) NULL, /* SIOCSIWPMKSA */ - (iw_handler) NULL, /* -- hole -- */ -}; - -static const iw_handler iwctl_private_handler[] = -{ - NULL, /* SIOCIWFIRSTPRIV */ -}; - -struct iw_priv_args iwctl_private_args[] = { - { IOCTL_CMD_SET, - IW_PRIV_TYPE_CHAR | 1024, 0, - "set"}, -}; - -const struct iw_handler_def iwctl_handler_def = -{ - .get_wireless_stats = &iwctl_get_wireless_stats, - .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler), - .num_private = 0, - .num_private_args = 0, - .standard = (iw_handler *)iwctl_handler, - .private = NULL, - .private_args = NULL, -}; diff --git a/drivers/staging/vt6655/iwctl.h b/drivers/staging/vt6655/iwctl.h deleted file mode 100644 index 7dd63102182d..000000000000 --- a/drivers/staging/vt6655/iwctl.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: iwctl.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: May 21, 2004 - * - */ - -#ifndef __IWCTL_H__ -#define __IWCTL_H__ - -#include "device.h" - -/*--------------------- Export Definitions -------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev); - -int iwctl_siwap(struct net_device *dev, - struct iw_request_info *info, - struct sockaddr *wrq, - char *extra); - -int iwctl_giwrange(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_giwmode(struct net_device *dev, - struct iw_request_info *info, - __u32 *wmode, - char *extra); - -int iwctl_siwmode(struct net_device *dev, - struct iw_request_info *info, - __u32 *wmode, - char *extra); - -int iwctl_giwfreq(struct net_device *dev, - struct iw_request_info *info, - struct iw_freq *wrq, - char *extra); - -int iwctl_siwfreq(struct net_device *dev, - struct iw_request_info *info, - struct iw_freq *wrq, - char *extra); - -int iwctl_giwname(struct net_device *dev, - struct iw_request_info *info, - char *wrq, - char *extra); - -int iwctl_giwsens(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwap(struct net_device *dev, - struct iw_request_info *info, - struct sockaddr *wrq, - char *extra); - -int iwctl_giwaplist(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_siwessid(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_giwessid(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_siwrate(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwrate(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_siwrts(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwrts(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_siwfrag(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwfrag(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_siwretry(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwretry(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_siwencode(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_giwencode(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_siwpower(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwpower(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -//2008-0409-07, by Einsn Liu -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -int iwctl_siwauth(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_giwauth(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *wrq, - char *extra); - -int iwctl_siwgenie(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char __user *extra); - -int iwctl_giwgenie(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char __user *extra); - -int iwctl_siwencodeext(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_giwencodeext(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra); - -int iwctl_siwmlme(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char __user *extra); -#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -//End Add -- //2008-0409-07, by Einsn Liu - -extern const struct iw_handler_def iwctl_handler_def; -extern struct iw_priv_args iwctl_private_args[]; - -#endif // __IWCTL_H__ -- cgit v1.2.3-59-g8ed1b From ae1927eb348908ea92eb9ce8c452e053a4830adf Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:23 +0000 Subject: staging: vt6655: dead code remove ioctl.c/h The driver nolonger supports these io functions Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/ioctl.c | 582 ----------------------------------- drivers/staging/vt6655/ioctl.h | 36 --- 4 files changed, 620 deletions(-) delete mode 100644 drivers/staging/vt6655/ioctl.c delete mode 100644 drivers/staging/vt6655/ioctl.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 455f088d54cb..6e9349976174 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -21,7 +21,6 @@ vt6655_stage-y += device_main.o \ rc4.o \ tether.o \ tcrc.o \ - ioctl.o \ hostap.o \ wpa.o \ key.o \ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 51b20f3d8e1b..5b54cabdc863 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -70,7 +70,6 @@ #include "bssdb.h" #include "hostap.h" #include "wpactl.h" -#include "ioctl.h" #include "dpc.h" #include "datarate.h" #include "rf.h" diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c deleted file mode 100644 index c2b6763c8ab9..000000000000 --- a/drivers/staging/vt6655/ioctl.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: ioctl.c - * - * Purpose: private ioctl functions - * - * Author: Lyndon Chen - * - * Date: Auguest 20, 2003 - * - * Functions: - * - * Revision History: - * - */ - -#include "ioctl.h" -#include "iocmd.h" -#include "mac.h" -#include "card.h" -#include "hostap.h" -#include "wpactl.h" -#include "rf.h" - -int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq) -{ - PSCmdRequest pReq = (PSCmdRequest)rq; - PSMgmtObject pMgmt = pDevice->pMgmt; - int result = 0; - PWLAN_IE_SSID pItemSSID; - SCmdBSSJoin sJoinCmd; - SCmdScan sScanCmd; - SCmdStartAP sStartAPCmd; - SCmdSetWEP sWEPCmd; - SCmdValue sValue; - SBSSIDList sList; - SNodeList sNodeList; - PSBSSIDList pList; - PSNodeList pNodeList; - unsigned int cbListCount; - PKnownBSS pBSS; - PKnownNodeDB pNode; - unsigned int ii, jj; - unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - unsigned long dwKeyIndex = 0; - unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - long ldBm; - - pReq->wResult = 0; - - switch (pReq->wCmdCode) { - case WLAN_CMD_BSS_SCAN: - pr_debug("WLAN_CMD_BSS_SCAN..begin\n"); - if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { - result = -EFAULT; - break; - } - - pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; - if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) - return -EINVAL; - if (pItemSSID->len != 0) { - memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - } - - if (pDevice->bMACSuspend == true) { - if (pDevice->bRadioOff == true) - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - pDevice->bMACSuspend = false; - } - spin_lock_irq(&pDevice->lock); - if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) - BSSvClearBSSList((void *)pDevice, false); - else - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); - - if (pItemSSID->len != 0) - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); - else - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_ZONETYPE_SET: - /* mike add :can't support. */ - result = -EOPNOTSUPP; - break; - - case WLAN_CMD_BSS_JOIN: - if (pDevice->bMACSuspend == true) { - if (pDevice->bRadioOff == true) - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - pDevice->bMACSuspend = false; - } - - if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { - result = -EFAULT; - break; - } - - pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; - if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) - return -EINVAL; - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - if (sJoinCmd.wBSSType == ADHOC) { - pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; - pr_debug("ioct set to adhoc mode\n"); - } else { - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - pr_debug("ioct set to STA mode\n"); - } - if (sJoinCmd.bPSEnable == true) { - pDevice->ePSMode = WMAC_POWER_FAST; - pMgmt->wListenInterval = 2; - pr_debug("Power Saving On\n"); - } else { - pDevice->ePSMode = WMAC_POWER_CAM; - pMgmt->wListenInterval = 1; - pr_debug("Power Saving Off\n"); - } - - if (sJoinCmd.bShareKeyAuth == true) { - pMgmt->bShareKeyAlgorithm = true; - pr_debug("Share Key\n"); - } else { - pMgmt->bShareKeyAlgorithm = false; - pr_debug("Open System\n"); - } - pDevice->uChannel = sJoinCmd.uChannel; - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - pMgmt->eCurrState = WMAC_STATE_IDLE; - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_SET_WEP: - pr_debug("WLAN_CMD_SET_WEP Key\n"); - memset(&sWEPCmd, 0, sizeof(SCmdSetWEP)); - if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { - result = -EFAULT; - break; - } - if (sWEPCmd.bEnableWep != true) { - pDevice->bEncryptionEnable = false; - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - MACvDisableDefaultKey(pDevice->PortOffset); - pr_debug("WEP function disable\n"); - break; - } - - for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) { - if (sWEPCmd.bWepKeyAvailable[ii]) { - if (ii == sWEPCmd.byKeyIndex) - dwKeyIndex = ii | (1 << 31); - else - dwKeyIndex = ii; - - KeybSetDefaultKey(&(pDevice->sKey), - dwKeyIndex, - sWEPCmd.auWepKeyLength[ii], - NULL, - (unsigned char *)&sWEPCmd.abyWepKey[ii][0], - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID); - } - } - pDevice->byKeyIndex = sWEPCmd.byKeyIndex; - pDevice->bTransmitKey = true; - pDevice->bEncryptionEnable = true; - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - break; - - case WLAN_CMD_GET_LINK: { - SCmdLinkStatus sLinkStatus; - - pr_debug("WLAN_CMD_GET_LINK status\n"); - - memset(&sLinkStatus, 0, sizeof(sLinkStatus)); - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - sLinkStatus.wBSSType = ADHOC; - else - sLinkStatus.wBSSType = INFRA; - - if (pMgmt->eCurrState == WMAC_STATE_JOINTED) - sLinkStatus.byState = ADHOC_JOINTED; - else - sLinkStatus.byState = ADHOC_STARTED; - - sLinkStatus.uChannel = pMgmt->uCurrChannel; - if (pDevice->bLinkPass == true) { - sLinkStatus.bLink = true; - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); - memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; - pr_debug(" Link Success!\n"); - } else { - sLinkStatus.bLink = false; - sLinkStatus.uLinkRate = 0; - } - if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { - result = -EFAULT; - break; - } - break; - } - case WLAN_CMD_GET_LISTLEN: - cbListCount = 0; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - cbListCount++; - } - sList.uItem = cbListCount; - if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { - result = -EFAULT; - break; - } - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_LIST: - if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { - result = -EFAULT; - break; - } - if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) { - result = -EINVAL; - break; - } - pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), - GFP_ATOMIC); - if (pList == NULL) { - result = -ENOMEM; - break; - } - pList->uItem = sList.uItem; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0, jj = 0; jj < MAX_BSS_NUM; jj++) { - pBSS = &(pMgmt->sBSSList[jj]); - if (pBSS->bActive) { - pList->sBSSIDList[ii].uChannel = pBSS->uChannel; - pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; - pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; - RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); - pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm; - memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); - pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; - memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); - memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); - if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) - pList->sBSSIDList[ii].byNetType = INFRA; - else - pList->sBSSIDList[ii].byNetType = ADHOC; - - if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) - pList->sBSSIDList[ii].bWEPOn = true; - else - pList->sBSSIDList[ii].bWEPOn = false; - - ii++; - if (ii >= pList->uItem) - break; - } - } - - if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { - result = -EFAULT; - break; - } - kfree(pList); - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_MIB: - if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { - result = -EFAULT; - break; - } - break; - - case WLAN_CMD_GET_STAT: - if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { - result = -EFAULT; - break; - } - break; - - case WLAN_CMD_STOP_MAC: - pr_debug("WLAN_CMD_STOP_MAC\n"); - netif_stop_queue(pDevice->dev); - - spin_lock_irq(&pDevice->lock); - if (pDevice->bRadioOff == false) - CARDbRadioPowerOff(pDevice); - - pDevice->bLinkPass = false; - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; - del_timer(&pDevice->sTimerCommand); - del_timer(&pMgmt->sTimerSecondCallback); - pDevice->bCmdRunning = false; - pDevice->bMACSuspend = true; - MACvIntDisable(pDevice->PortOffset); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_START_MAC: - pr_debug("WLAN_CMD_START_MAC\n"); - - if (pDevice->bMACSuspend == true) { - if (pDevice->bRadioOff == true) - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - pDevice->bMACSuspend = false; - } - break; - - case WLAN_CMD_SET_HOSTAPD: - pr_debug("WLAN_CMD_SET_HOSTAPD\n"); - - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - if (sValue.dwValue == 1) { - if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) { - pr_debug("Enable HOSTAP\n"); - } else { - result = -EFAULT; - break; - } - } else { - vt6655_hostap_set_hostapd(pDevice, 0, 1); - pr_debug("Disable HOSTAP\n"); - } - break; - - case WLAN_CMD_SET_HOSTAPD_STA: - pr_debug("WLAN_CMD_SET_HOSTAPD_STA\n"); - break; - - case WLAN_CMD_SET_802_1X: - pr_debug("WLAN_CMD_SET_802_1X\n"); - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - - if (sValue.dwValue == 1) { - pDevice->bEnable8021x = true; - pr_debug("Enable 802.1x\n"); - } else { - pDevice->bEnable8021x = false; - pr_debug("Disable 802.1x\n"); - } - break; - - case WLAN_CMD_SET_HOST_WEP: - pr_debug("WLAN_CMD_SET_HOST_WEP\n"); - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - - if (sValue.dwValue == 1) { - pDevice->bEnableHostWEP = true; - pr_debug("Enable HostWEP\n"); - } else { - pDevice->bEnableHostWEP = false; - pr_debug("Disable HostWEP\n"); - } - break; - - case WLAN_CMD_SET_WPA: - pr_debug("WLAN_CMD_SET_WPA\n"); - - if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { - result = -EFAULT; - break; - } - if (sValue.dwValue == 1) { - pr_debug("up wpadev\n"); - eth_hw_addr_inherit(pDevice->wpadev, pDevice->dev); - pDevice->bWPADEVUp = true; - } else { - pr_debug("close wpadev\n"); - pDevice->bWPADEVUp = false; - } - break; - - case WLAN_CMD_AP_START: - pr_debug("WLAN_CMD_AP_START\n"); - if (pDevice->bRadioOff == true) { - CARDbRadioPowerOn(pDevice); - vMgrTimerInit(pDevice); - MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); - add_timer(&pMgmt->sTimerSecondCallback); - } - if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { - result = -EFAULT; - break; - } - - if (sStartAPCmd.wBSSType == AP) { - pMgmt->eConfigMode = WMAC_CONFIG_AP; - pr_debug("ioct set to AP mode\n"); - } else { - pr_debug("ioct BSS type not set to AP mode\n"); - result = -EFAULT; - break; - } - - if (sStartAPCmd.wBBPType == PHY80211g) - pMgmt->byAPBBType = PHY_TYPE_11G; - else if (sStartAPCmd.wBBPType == PHY80211a) - pMgmt->byAPBBType = PHY_TYPE_11A; - else - pMgmt->byAPBBType = PHY_TYPE_11B; - - pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; - if (pItemSSID->len > WLAN_SSID_MAXLEN + 1) - return -EINVAL; - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); - - if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14)) - pDevice->uChannel = sStartAPCmd.uChannel; - - if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) - pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; - else - pMgmt->wIBSSBeaconPeriod = 100; - - if (sStartAPCmd.bShareKeyAuth == true) { - pMgmt->bShareKeyAlgorithm = true; - pr_debug("Share Key\n"); - } else { - pMgmt->bShareKeyAlgorithm = false; - pr_debug("Open System\n"); - } - memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); - - if (sStartAPCmd.byBasicRate & BIT3) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - pMgmt->abyIBSSSuppRates[4] |= BIT7; - pMgmt->abyIBSSSuppRates[5] |= BIT7; - } else if (sStartAPCmd.byBasicRate & BIT2) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - pMgmt->abyIBSSSuppRates[4] |= BIT7; - } else if (sStartAPCmd.byBasicRate & BIT1) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - } else if (sStartAPCmd.byBasicRate & BIT1) { - pMgmt->abyIBSSSuppRates[2] |= BIT7; - } else { - /* default 1,2M */ - pMgmt->abyIBSSSuppRates[2] |= BIT7; - pMgmt->abyIBSSSuppRates[3] |= BIT7; - } - - pr_debug("Support Rate= %*ph\n", - 4, pMgmt->abyIBSSSuppRates + 2); - - netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); - bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL); - spin_unlock_irq(&pDevice->lock); - break; - - case WLAN_CMD_GET_NODE_CNT: - cbListCount = 0; - pNode = &(pMgmt->sNodeDBTable[0]); - for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { - pNode = &(pMgmt->sNodeDBTable[ii]); - if (!pNode->bActive) - continue; - cbListCount++; - } - - sNodeList.uItem = cbListCount; - if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { - result = -EFAULT; - break; - } - pReq->wResult = 0; - break; - - case WLAN_CMD_GET_NODE_LIST: - if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { - result = -EFAULT; - break; - } - if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) { - result = -EINVAL; - break; - } - pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), - GFP_ATOMIC); - if (pNodeList == NULL) { - result = -ENOMEM; - break; - } - pNodeList->uItem = sNodeList.uItem; - pNode = &(pMgmt->sNodeDBTable[0]); - for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { - pNode = &(pMgmt->sNodeDBTable[ii]); - if (pNode->bActive) { - pNodeList->sNodeList[jj].wAID = pNode->wAID; - memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); - pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; - pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount; - pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt; - pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags; - pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; - pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; - pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; - memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); - pr_debug("key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - pNodeList->sNodeList[jj].abyWepKey[0], - pNodeList->sNodeList[jj].abyWepKey[1], - pNodeList->sNodeList[jj].abyWepKey[2], - pNodeList->sNodeList[jj].abyWepKey[3], - pNodeList->sNodeList[jj].abyWepKey[4]); - pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; - pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; - pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; - pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio; - jj++; - if (jj >= pNodeList->uItem) - break; - } - } - if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { - result = -EFAULT; - break; - } - kfree(pNodeList); - pReq->wResult = 0; - break; - - default: - pr_debug("Private command not support..\n"); - } - - return result; -} diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h deleted file mode 100644 index 1b5d19495fad..000000000000 --- a/drivers/staging/vt6655/ioctl.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: May 21, 2003 - * - */ - -#ifndef __IOCTL_H__ -#define __IOCTL_H__ - -#include "device.h" - -int private_ioctl(struct vnt_private *, struct ifreq *rq); - -#endif /* __IOCTL_H__ */ -- cgit v1.2.3-59-g8ed1b From ee1464902c25e22c15d7eda41f00a8a40acc7ec9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:24 +0000 Subject: staging: vt6655: dead code remove legacy hostap.c/h hoatap is now supported by mac80211 in nl80211 mode Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/dpc.c | 1 - drivers/staging/vt6655/hostap.c | 764 ----------------------------------- drivers/staging/vt6655/hostap.h | 58 --- drivers/staging/vt6655/rxtx.c | 1 - 6 files changed, 826 deletions(-) delete mode 100644 drivers/staging/vt6655/hostap.c delete mode 100644 drivers/staging/vt6655/hostap.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 6e9349976174..2d534504c456 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -21,7 +21,6 @@ vt6655_stage-y += device_main.o \ rc4.o \ tether.o \ tcrc.o \ - hostap.o \ wpa.o \ key.o \ tkip.o \ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 5b54cabdc863..3a90401ab7aa 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -68,7 +68,6 @@ #include "rxtx.h" #include "wroute.h" #include "bssdb.h" -#include "hostap.h" #include "wpactl.h" #include "dpc.h" #include "datarate.h" diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 11153ef0dd95..6842baf73ed1 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -50,7 +50,6 @@ #include "tcrc.h" #include "wctl.h" #include "wroute.h" -#include "hostap.h" #include "rf.h" #include "iowpa.h" #include "aes_ccmp.h" diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c deleted file mode 100644 index 2db08df0656d..000000000000 --- a/drivers/staging/vt6655/hostap.c +++ /dev/null @@ -1,764 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.c - * - * Purpose: handle hostap deamon ioctl input/out functions - * - * Author: Lyndon Chen - * - * Date: Oct. 20, 2003 - * - * Functions: - * - * Revision History: - * - */ - -#include "hostap.h" -#include "iocmd.h" -#include "mac.h" -#include "card.h" -#include "baseband.h" -#include "wpactl.h" -#include "key.h" - -#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024 -#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0 -#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3 -#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5 - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/* - * Description: - * register net_device (AP) for hostap deamon - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked) -{ - struct vnt_private *apdev_priv; - struct net_device *dev = pDevice->dev; - int ret; - const struct net_device_ops apdev_netdev_ops = { - .ndo_start_xmit = pDevice->tx_80211, - }; - - pr_debug("%s: Enabling hostapd mode\n", dev->name); - - pDevice->apdev = alloc_etherdev(sizeof(*apdev_priv)); - if (pDevice->apdev == NULL) - return -ENOMEM; - - apdev_priv = netdev_priv(pDevice->apdev); - *apdev_priv = *pDevice; - eth_hw_addr_inherit(pDevice->apdev, dev); - - pDevice->apdev->netdev_ops = &apdev_netdev_ops; - - pDevice->apdev->type = ARPHRD_IEEE80211; - - pDevice->apdev->base_addr = dev->base_addr; - pDevice->apdev->irq = dev->irq; - pDevice->apdev->mem_start = dev->mem_start; - pDevice->apdev->mem_end = dev->mem_end; - sprintf(pDevice->apdev->name, "%sap", dev->name); - if (rtnl_locked) - ret = register_netdevice(pDevice->apdev); - else - ret = register_netdev(pDevice->apdev); - if (ret) { - pr_debug("%s: register_netdevice(AP) failed!\n", - dev->name); - free_netdev(pDevice->apdev); - pDevice->apdev = NULL; - return -1; - } - - pr_debug("%s: Registered netdevice %s for AP management\n", - dev->name, pDevice->apdev->name); - - KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); - - return 0; -} - -/* - * Description: - * unregister net_device(AP) - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked) -{ - pr_debug("%s: disabling hostapd mode\n", pDevice->dev->name); - - if (pDevice->apdev && pDevice->apdev->name && pDevice->apdev->name[0]) { - if (rtnl_locked) - unregister_netdevice(pDevice->apdev); - else - unregister_netdev(pDevice->apdev); - pr_debug("%s: Netdevice %s unregistered\n", - pDevice->dev->name, pDevice->apdev->name); - } - if (pDevice->apdev) - free_netdev(pDevice->apdev); - pDevice->apdev = NULL; - pDevice->bEnable8021x = false; - pDevice->bEnableHostWEP = false; - pDevice->bEncryptionEnable = false; - -/* 4.2007-0118-03, by EinsnLiu */ -/* execute some clear work */ - pDevice->pMgmt->byCSSPK = KEY_CTL_NONE; - pDevice->pMgmt->byCSSGK = KEY_CTL_NONE; - KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); - - return 0; -} - -/* - * Description: - * Set enable/disable hostapd mode - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -int vt6655_hostap_set_hostapd(struct vnt_private *pDevice, - int val, int rtnl_locked) -{ - if (val < 0 || val > 1) - return -EINVAL; - - if (pDevice->bEnableHostapd == val) - return 0; - - pDevice->bEnableHostapd = val; - - if (val) - return hostap_enable_hostapd(pDevice, rtnl_locked); - return hostap_disable_hostapd(pDevice, rtnl_locked); -} - -/* - * Description: - * remove station function supported for hostap deamon - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_remove_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - unsigned int uNodeIndex; - - if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex)) - BSSvRemoveOneNode(pDevice, uNodeIndex); - else - return -ENOENT; - - return 0; -} - -/* - * Description: - * add a station from hostap deamon - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_add_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uNodeIndex; - - if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) - BSSvCreateOneNode(pDevice, &uNodeIndex); - - memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; - pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability; -/* TODO listenInterval */ - pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates; - - /* set max tx rate */ - pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; - /* set max basic rate */ - pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate = RATE_2M; - /* Todo: check sta preamble, if ap can't support, set status code */ - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = - WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt->sNodeDBTable[uNodeIndex].wCapInfo); - - pMgmt->sNodeDBTable[uNodeIndex].wAID = (unsigned short)param->u.add_sta.aid; - - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies; - - pr_debug("Add STA AID= %d\n", pMgmt->sNodeDBTable[uNodeIndex].wAID); - pr_debug("MAC=%pM\n", param->sta_addr); - pr_debug("Max Support rate = %d\n", - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); - - return 0; -} - -/* - * Description: - * get station info - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int hostap_get_info_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uNodeIndex; - - if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { - param->u.get_info_sta.inactive_sec = - (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ; - } else { - return -ENOENT; - } - - return 0; -} - -/* - * Description: - * set station flag - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_flags_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uNodeIndex; - - if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { - pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or; - pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and; - pr_debug(" dwFlags = %x\n", - (unsigned int)pMgmt->sNodeDBTable[uNodeIndex].dwFlags); - } else { - return -ENOENT; - } - - return 0; -} - -/* - * Description: - * set generic element (wpa ie) - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_generic_element(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - - if (param->u.generic_elem.len > sizeof(pMgmt->abyWPAIE)) - return -EINVAL; - - memcpy(pMgmt->abyWPAIE, - param->u.generic_elem.data, - param->u.generic_elem.len - ); - - pMgmt->wWPAIELen = param->u.generic_elem.len; - - pr_debug("pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen); - - /* disable wpa */ - if (pMgmt->wWPAIELen == 0) { - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - pr_debug(" No WPAIE, Disable WPA\n"); - } else { - /* enable wpa */ - if ((pMgmt->abyWPAIE[0] == WLAN_EID_RSN_WPA) || - (pMgmt->abyWPAIE[0] == WLAN_EID_RSN)) { - pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; - pr_debug("Set WPAIE enable WPA\n"); - } else - return -EINVAL; - } - - return 0; -} - -/* - * Description: - * flush station nodes table. - * - * Parameters: - * In: - * pDevice - - * Out: - * - * Return Value: - * - */ - -static void hostap_flush_sta(struct vnt_private *pDevice) -{ - /* reserved node index =0 for multicast node. */ - BSSvClearNodeDBTable(pDevice, 1); - pDevice->uAssocCount = 0; -} - -/* - * Description: - * set each stations encryption key - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_encryption(struct vnt_private *pDevice, - struct viawget_hostapd_param *param, - int param_len) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned long dwKeyIndex = 0; - unsigned char abyKey[MAX_KEY_LEN]; - unsigned char abySeq[MAX_KEY_LEN]; - u64 KeyRSC; - unsigned char byKeyDecMode = KEY_CTL_WEP; - int iNodeIndex = -1; - int ii; - bool bKeyTableFull = false; - unsigned short wKeyCtl = 0; - - param->u.crypt.err = 0; - - if (param->u.crypt.alg > WPA_ALG_CCMP) - return -EINVAL; - - if ((param->u.crypt.idx > 3) || (param->u.crypt.key_len > MAX_KEY_LEN)) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED; - pr_debug(" HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n"); - return -EINVAL; - } - - if (is_broadcast_ether_addr(param->sta_addr)) { - if (param->u.crypt.idx >= MAX_GROUP_KEY) - return -EINVAL; - iNodeIndex = 0; - - } else { - if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == false) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; - pr_debug(" HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); - return -EINVAL; - } - } - pr_debug(" hostap_set_encryption: sta_index %d\n", iNodeIndex); - pr_debug(" hostap_set_encryption: alg %d\n", param->u.crypt.alg); - - if (param->u.crypt.alg == WPA_ALG_NONE) { - if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly) { - if (!KeybRemoveKey(&(pDevice->sKey), - param->sta_addr, - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex, - pDevice->PortOffset)) { - pr_debug("KeybRemoveKey fail\n"); - } - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - } - pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0; - pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = 0; - pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = 0; - pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; - pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = 0; - memset(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - 0, - MAX_KEY_LEN -); - - return 0; - } - - memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len); - /* copy to node key tbl */ - pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = param->u.crypt.idx; - pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = param->u.crypt.key_len; - memcpy(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - param->u.crypt.key, - param->u.crypt.key_len -); - - dwKeyIndex = (unsigned long)(param->u.crypt.idx); - if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) { - pDevice->byKeyIndex = (unsigned char)dwKeyIndex; - pDevice->bTransmitKey = true; - dwKeyIndex |= (1 << 31); - } - - if (param->u.crypt.alg == WPA_ALG_WEP) { - if ((pDevice->bEnable8021x == false) || (iNodeIndex == 0)) { - KeybSetDefaultKey(&(pDevice->sKey), - dwKeyIndex & ~(BIT30 | USE_KEYRSC), - param->u.crypt.key_len, - NULL, - abyKey, - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID); - - } else { - /* 8021x enable, individual key */ - dwKeyIndex |= (1 << 30); /* set pairwise key */ - if (KeybSetKey(&(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex & ~(USE_KEYRSC), - param->u.crypt.key_len, - (u64 *) &KeyRSC, - (unsigned char *)abyKey, - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID)) { - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - /* Key Table Full */ - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - bKeyTableFull = true; - } - } - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pDevice->bEncryptionEnable = true; - pMgmt->byCSSPK = KEY_CTL_WEP; - pMgmt->byCSSGK = KEY_CTL_WEP; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - return 0; - } - - if (param->u.crypt.seq) { - memcpy(&abySeq, param->u.crypt.seq, 8); - for (ii = 0; ii < 8; ii++) - KeyRSC |= (u64)abySeq[ii] << (ii * 8); - - dwKeyIndex |= 1 << 29; - pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC; - } - - if (param->u.crypt.alg == WPA_ALG_TKIP) { - if (param->u.crypt.key_len != MAX_KEY_LEN) - return -EINVAL; - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - byKeyDecMode = KEY_CTL_TKIP; - pMgmt->byCSSPK = KEY_CTL_TKIP; - pMgmt->byCSSGK = KEY_CTL_TKIP; - } - - if (param->u.crypt.alg == WPA_ALG_CCMP) { - if ((param->u.crypt.key_len != AES_KEY_LEN) || - (pDevice->byLocalID <= REV_ID_VT3253_A1)) - return -EINVAL; - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - byKeyDecMode = KEY_CTL_CCMP; - pMgmt->byCSSPK = KEY_CTL_CCMP; - pMgmt->byCSSGK = KEY_CTL_CCMP; - } - - if (iNodeIndex == 0) { - KeybSetDefaultKey(&(pDevice->sKey), - dwKeyIndex, - param->u.crypt.key_len, - (u64 *) &KeyRSC, - abyKey, - byKeyDecMode, - pDevice->PortOffset, - pDevice->byLocalID); - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - dwKeyIndex |= (1 << 30); /* set pairwise key */ - if (KeybSetKey(&(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex, - param->u.crypt.key_len, - (u64 *) &KeyRSC, - (unsigned char *)abyKey, - byKeyDecMode, - pDevice->PortOffset, - pDevice->byLocalID)) { - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - /* Key Table Full */ - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - bKeyTableFull = true; - pr_debug(" Key Table Full\n"); - } - - } - - if (bKeyTableFull) { - wKeyCtl &= 0x7F00; /* clear all key control filed */ - wKeyCtl |= (byKeyDecMode << 4); - wKeyCtl |= (byKeyDecMode); - wKeyCtl |= 0x0044; /* use group key for all address */ - wKeyCtl |= 0x4000; /* disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int */ - MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID); - } - - pr_debug(" Set key sta_index= %d\n", iNodeIndex); - pr_debug(" tx_index=%d len=%d\n", - param->u.crypt.idx, param->u.crypt.key_len); - pr_debug(" key=%x-%x-%x-%x-%x-xxxxx\n", - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[1], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[2], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[3], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[4]); - - /* set wep key */ - pDevice->bEncryptionEnable = true; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; - pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - - return 0; -} - -/* - * Description: - * get each stations encryption key - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_get_encryption(struct vnt_private *pDevice, - struct viawget_hostapd_param *param, - int param_len) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - int ii; - int iNodeIndex = 0; - - param->u.crypt.err = 0; - - if (is_broadcast_ether_addr(param->sta_addr)) { - iNodeIndex = 0; - } else { - if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &iNodeIndex) == false) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; - pr_debug("hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); - return -EINVAL; - } - } - pr_debug("hostap_get_encryption: %d\n", iNodeIndex); - memset(param->u.crypt.seq, 0, 8); - for (ii = 0; ii < 8; ii++) - param->u.crypt.seq[ii] = (unsigned char)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8); - - return 0; -} - -/* - * Description: - * vt6655_hostap_ioctl main function supported for hostap deamon. - * - * Parameters: - * In: - * pDevice - - * iw_point - - * Out: - * - * Return Value: - * - */ -int vt6655_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) -{ - struct viawget_hostapd_param *param; - int ret = 0; - int ap_ioctl = 0; - - if (p->length < sizeof(struct viawget_hostapd_param) || - p->length > VIAWGET_HOSTAPD_MAX_BUF_SIZE || !p->pointer) - return -EINVAL; - - param = kmalloc((int)p->length, GFP_KERNEL); - if (param == NULL) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - ret = -EFAULT; - goto out; - } - - switch (param->cmd) { - case VIAWGET_HOSTAPD_SET_ENCRYPTION: - pr_debug("VIAWGET_HOSTAPD_SET_ENCRYPTION\n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_set_encryption(pDevice, param, p->length); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_GET_ENCRYPTION: - pr_debug("VIAWGET_HOSTAPD_GET_ENCRYPTION\n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_get_encryption(pDevice, param, p->length); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR: - pr_debug("VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR\n"); - ret = -EOPNOTSUPP; - goto out; - case VIAWGET_HOSTAPD_FLUSH: - pr_debug("VIAWGET_HOSTAPD_FLUSH\n"); - spin_lock_irq(&pDevice->lock); - hostap_flush_sta(pDevice); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_ADD_STA: - pr_debug("VIAWGET_HOSTAPD_ADD_STA\n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_add_sta(pDevice, param); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_REMOVE_STA: - pr_debug("VIAWGET_HOSTAPD_REMOVE_STA\n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_remove_sta(pDevice, param); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_GET_INFO_STA: - pr_debug("VIAWGET_HOSTAPD_GET_INFO_STA\n"); - ret = hostap_get_info_sta(pDevice, param); - ap_ioctl = 1; - break; - case VIAWGET_HOSTAPD_SET_FLAGS_STA: - pr_debug("VIAWGET_HOSTAPD_SET_FLAGS_STA\n"); - ret = hostap_set_flags_sta(pDevice, param); - break; - case VIAWGET_HOSTAPD_MLME: - pr_debug("VIAWGET_HOSTAPD_MLME\n"); - ret = -EOPNOTSUPP; - goto out; - case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT: - pr_debug("VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT\n"); - ret = hostap_set_generic_element(pDevice, param); - break; - case VIAWGET_HOSTAPD_SCAN_REQ: - pr_debug("VIAWGET_HOSTAPD_SCAN_REQ\n"); - ret = -EOPNOTSUPP; - goto out; - case VIAWGET_HOSTAPD_STA_CLEAR_STATS: - pr_debug("VIAWGET_HOSTAPD_STA_CLEAR_STATS\n"); - ret = -EOPNOTSUPP; - goto out; - default: - pr_debug("vt6655_hostap_ioctl: unknown cmd=%d\n", - (int)param->cmd); - ret = -EOPNOTSUPP; - goto out; - } - - if ((ret == 0) && ap_ioctl) { - if (copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - } - -out: - kfree(param); - return ret; -} diff --git a/drivers/staging/vt6655/hostap.h b/drivers/staging/vt6655/hostap.h deleted file mode 100644 index fc5f9ed4674b..000000000000 --- a/drivers/staging/vt6655/hostap.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: May 21, 2003 - * - */ - -#ifndef __HOSTAP_H__ -#define __HOSTAP_H__ - -#include "device.h" - -#define WLAN_RATE_1M BIT0 -#define WLAN_RATE_2M BIT1 -#define WLAN_RATE_5M5 BIT2 -#define WLAN_RATE_11M BIT3 -#define WLAN_RATE_6M BIT4 -#define WLAN_RATE_9M BIT5 -#define WLAN_RATE_12M BIT6 -#define WLAN_RATE_18M BIT7 -#define WLAN_RATE_24M BIT8 -#define WLAN_RATE_36M BIT9 -#define WLAN_RATE_48M BIT10 -#define WLAN_RATE_54M BIT11 - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif /* ETH_P_PAE */ - -#ifndef ARPHRD_IEEE80211 -#define ARPHRD_IEEE80211 801 -#endif - -int vt6655_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked); -int vt6655_hostap_ioctl(struct vnt_private *, struct iw_point *p); - -#endif /* __HOSTAP_H__ */ diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 9beabea88b3f..aa7e454cd9d3 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -60,7 +60,6 @@ #include "tcrc.h" #include "wctl.h" #include "wroute.h" -#include "hostap.h" #include "rf.h" /*--------------------- Static Definitions -------------------------*/ -- cgit v1.2.3-59-g8ed1b From 2759e2172de880c9aa6b2cd68abdca0f769a6b53 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:25 +0000 Subject: staging: vt6655: dead code remove wpactl.c/h All these functions are now dead. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/wpactl.c | 893 ----------------------------------- drivers/staging/vt6655/wpactl.h | 64 --- 4 files changed, 959 deletions(-) delete mode 100644 drivers/staging/vt6655/wpactl.c delete mode 100644 drivers/staging/vt6655/wpactl.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 2d534504c456..2cad0d09cdd0 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -27,7 +27,6 @@ vt6655_stage-y += device_main.o \ michael.o \ wroute.o \ rf.o \ - wpactl.o \ wpa2.o \ aes_ccmp.o \ vntwifi.o \ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 3a90401ab7aa..991a276f1ecf 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -68,7 +68,6 @@ #include "rxtx.h" #include "wroute.h" #include "bssdb.h" -#include "wpactl.h" #include "dpc.h" #include "datarate.h" #include "rf.h" diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c deleted file mode 100644 index cc39829cbacc..000000000000 --- a/drivers/staging/vt6655/wpactl.c +++ /dev/null @@ -1,893 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wpactl.c - * - * Purpose: handle wpa supplicant ioctl input/out functions - * - * Author: Lyndon Chen - * - * Date: Oct. 20, 2003 - * - * Functions: - * - * Revision History: - * - */ - -#include "wpactl.h" -#include "key.h" -#include "mac.h" -#include "device.h" -#include "wmgr.h" -#include "iocmd.h" -#include "iowpa.h" -#include "rf.h" - -/*--------------------- Static Definitions -------------------------*/ - -#define VIAWGET_WPA_MAX_BUF_SIZE 1024 - -static const int frequency_list[] = { - 2412, 2417, 2422, 2427, 2432, 2437, 2442, - 2447, 2452, 2457, 2462, 2467, 2472, 2484 -}; -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ -static void wpadev_setup(struct net_device *dev) -{ - dev->type = ARPHRD_IEEE80211; - dev->hard_header_len = ETH_HLEN; - dev->mtu = 2048; - dev->addr_len = ETH_ALEN; - dev->tx_queue_len = 1000; - - memset(dev->broadcast, 0xFF, ETH_ALEN); - - dev->flags = IFF_BROADCAST|IFF_MULTICAST; -} - -/* - * Description: - * register netdev for wpa supplicant daemon - * - * Parameters: - * In: - * pDevice - - * enable - - * Out: - * - * Return Value: - * - */ - -static int wpa_init_wpadev(struct vnt_private *pDevice) -{ - struct vnt_private *wpadev_priv; - struct net_device *dev = pDevice->dev; - int ret = 0; - - pDevice->wpadev = alloc_netdev(sizeof(*wpadev_priv), "vntwpa", - NET_NAME_UNKNOWN, wpadev_setup); - if (pDevice->wpadev == NULL) - return -ENOMEM; - - wpadev_priv = netdev_priv(pDevice->wpadev); - *wpadev_priv = *pDevice; - eth_hw_addr_inherit(pDevice->wpadev, dev); - pDevice->wpadev->base_addr = dev->base_addr; - pDevice->wpadev->irq = dev->irq; - pDevice->wpadev->mem_start = dev->mem_start; - pDevice->wpadev->mem_end = dev->mem_end; - ret = register_netdev(pDevice->wpadev); - if (ret) { - pr_debug("%s: register_netdev(WPA) failed!\n", dev->name); - free_netdev(pDevice->wpadev); - return -1; - } - - if (pDevice->skb == NULL) { - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - if (pDevice->skb == NULL) - return -ENOMEM; - } - - pr_debug("%s: Registered netdev %s for WPA management\n", - dev->name, pDevice->wpadev->name); - - return 0; -} - -/* - * Description: - * unregister net_device (wpadev) - * - * Parameters: - * In: - * pDevice - - * Out: - * - * Return Value: - * - */ - -static int wpa_release_wpadev(struct vnt_private *pDevice) -{ - if (pDevice->skb) { - dev_kfree_skb(pDevice->skb); - pDevice->skb = NULL; - } - - if (pDevice->wpadev) { - pr_debug("%s: Netdevice %s unregistered\n", - pDevice->dev->name, pDevice->wpadev->name); - unregister_netdev(pDevice->wpadev); - free_netdev(pDevice->wpadev); - pDevice->wpadev = NULL; - } - - return 0; -} - -/* - * Description: - * Set enable/disable dev for wpa supplicant daemon - * - * Parameters: - * In: - * pDevice - - * val - - * Out: - * - * Return Value: - * - */ - -int wpa_set_wpadev(struct vnt_private *pDevice, int val) -{ - if (val) - return wpa_init_wpadev(pDevice); - else - return wpa_release_wpadev(pDevice); -} - -/* - * Description: - * Set WPA algorithm & keys - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -int wpa_set_keys(struct vnt_private *pDevice, void *ctx, - bool fcpfkernel) __must_hold(&pDevice->lock) -{ - struct viawget_wpa_param *param = ctx; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned long dwKeyIndex = 0; - unsigned char abyKey[MAX_KEY_LEN]; - unsigned char abySeq[MAX_KEY_LEN]; - u64 KeyRSC; - unsigned char byKeyDecMode = KEY_CTL_WEP; - int ret = 0; - int uu, ii; - - if (param->u.wpa_key.alg_name > WPA_ALG_CCMP || - param->u.wpa_key.key_len > MAX_KEY_LEN || - param->u.wpa_key.seq_len > MAX_KEY_LEN) - return -EINVAL; - - pr_debug("param->u.wpa_key.alg_name = %d\n", param->u.wpa_key.alg_name); - if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - pDevice->bEncryptionEnable = false; - pDevice->byKeyIndex = 0; - pDevice->bTransmitKey = false; - KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset); - for (uu = 0; uu < MAX_KEY_TABLE; uu++) - MACvDisableKeyEntry(pDevice->PortOffset, uu); - - return ret; - } - - if (param->u.wpa_key.key && fcpfkernel) { - memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len); - } else { - spin_unlock_irq(&pDevice->lock); - if (param->u.wpa_key.key && - copy_from_user(&abyKey[0], - (void __user *)param->u.wpa_key.key, - param->u.wpa_key.key_len)) { - spin_lock_irq(&pDevice->lock); - return -EINVAL; - } - spin_lock_irq(&pDevice->lock); - } - - dwKeyIndex = (unsigned long)(param->u.wpa_key.key_index); - - if (param->u.wpa_key.alg_name == WPA_ALG_WEP) { - if (dwKeyIndex > 3) { - return -EINVAL; - } else { - if (param->u.wpa_key.set_tx) { - pDevice->byKeyIndex = (unsigned char)dwKeyIndex; - pDevice->bTransmitKey = true; - dwKeyIndex |= (1 << 31); - } - KeybSetDefaultKey(&(pDevice->sKey), - dwKeyIndex & ~(BIT30 | USE_KEYRSC), - param->u.wpa_key.key_len, - NULL, - abyKey, - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID); - - } - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pDevice->bEncryptionEnable = true; - return ret; - } - - if (param->u.wpa_key.seq && fcpfkernel) { - memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len); - } else { - spin_unlock_irq(&pDevice->lock); - if (param->u.wpa_key.seq && - copy_from_user(&abySeq[0], - (void __user *)param->u.wpa_key.seq, - param->u.wpa_key.seq_len)) { - spin_lock_irq(&pDevice->lock); - return -EINVAL; - } - spin_lock_irq(&pDevice->lock); - } - - if (param->u.wpa_key.seq_len > 0) { - for (ii = 0; ii < param->u.wpa_key.seq_len; ii++) { - if (ii < 4) - KeyRSC |= (u64)(abySeq[ii] << (ii * 8)); - else - KeyRSC |= (u64)(abySeq[ii] << ((ii-4) * 8)); - } - dwKeyIndex |= 1 << 29; - } - - if (param->u.wpa_key.key_index >= MAX_GROUP_KEY) { - pr_debug("return dwKeyIndex > 3\n"); - return -EINVAL; - } - - if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - - if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - - if (param->u.wpa_key.set_tx) - dwKeyIndex |= (1 << 31); - - if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) - byKeyDecMode = KEY_CTL_CCMP; - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) - byKeyDecMode = KEY_CTL_TKIP; - else - byKeyDecMode = KEY_CTL_WEP; - - /* Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled */ - if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - if (param->u.wpa_key.key_len == MAX_KEY_LEN) - byKeyDecMode = KEY_CTL_TKIP; - else if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN) - byKeyDecMode = KEY_CTL_WEP; - else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN) - byKeyDecMode = KEY_CTL_WEP; - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN) - byKeyDecMode = KEY_CTL_WEP; - else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN) - byKeyDecMode = KEY_CTL_WEP; - } - - /* Check TKIP key length */ - if ((byKeyDecMode == KEY_CTL_TKIP) && - (param->u.wpa_key.key_len != MAX_KEY_LEN)) { - /* TKIP Key must be 256 bits */ - pr_debug("return- TKIP Key must be 256 bits!\n"); - return -EINVAL; - } - /* Check AES key length */ - if ((byKeyDecMode == KEY_CTL_CCMP) && - (param->u.wpa_key.key_len != AES_KEY_LEN)) { - /* AES Key must be 128 bits */ - return -EINVAL; - } - - /* spin_lock_irq(&pDevice->lock); */ - if (is_broadcast_ether_addr(¶m->addr[0]) || (param->addr == NULL)) { - /* If is_broadcast_ether_addr, set the key as every key entry's group key. */ - pr_debug("Groupe Key Assign\n"); - - if (KeybSetAllGroupKey(&(pDevice->sKey), - dwKeyIndex, - param->u.wpa_key.key_len, - (u64 *) &KeyRSC, - (unsigned char *)abyKey, - byKeyDecMode, - pDevice->PortOffset, - pDevice->byLocalID) && - KeybSetDefaultKey(&(pDevice->sKey), - dwKeyIndex, - param->u.wpa_key.key_len, - (u64 *) &KeyRSC, - (unsigned char *)abyKey, - byKeyDecMode, - pDevice->PortOffset, - pDevice->byLocalID)) { - pr_debug("GROUP Key Assign\n"); - - } else { - return -EINVAL; - } - - } else { - pr_debug("Pairwise Key Assign\n"); - /* BSSID not 0xffffffffffff */ - /* Pairwise Key can't be WEP */ - if (byKeyDecMode == KEY_CTL_WEP) { - pr_debug("Pairwise Key can't be WEP\n"); - return -EINVAL; - } - - dwKeyIndex |= (1 << 30); /* set pairwise key */ - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) - return -EINVAL; - - if (KeybSetKey(&(pDevice->sKey), - ¶m->addr[0], - dwKeyIndex, - param->u.wpa_key.key_len, - (u64 *) &KeyRSC, - (unsigned char *)abyKey, - byKeyDecMode, - pDevice->PortOffset, - pDevice->byLocalID)) { - pr_debug("Pairwise Key Set\n"); - - } else { - /* Key Table Full */ - return -EINVAL; - } - } /* BSSID not 0xffffffffffff */ - if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) { - pDevice->byKeyIndex = (unsigned char)param->u.wpa_key.key_index; - pDevice->bTransmitKey = true; - } - pDevice->bEncryptionEnable = true; - - return ret; -} - -/* - * Description: - * enable wpa auth & mode - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_set_wpa(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - pMgmt->bShareKeyAlgorithm = false; - - return 0; -} - -/* - * Description: - * set disassociate - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_set_disassociate(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - - spin_lock_irq(&pDevice->lock); - if (pDevice->bLinkPass) { - if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6)) - bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); - } - spin_unlock_irq(&pDevice->lock); - - return 0; -} - -/* - * Description: - * enable scan process - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_set_scan(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - spin_lock_irq(&pDevice->lock); - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - spin_unlock_irq(&pDevice->lock); - - return 0; -} - -/* - * Description: - * get bssid - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_get_bssid(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - - memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6); - - return 0; -} - -/* - * Description: - * get bssid - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_get_ssid(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - PWLAN_IE_SSID pItemSSID; - - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - - memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len); - param->u.wpa_associate.ssid_len = pItemSSID->len; - - return 0; -} - -/* - * Description: - * get scan results - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_get_scan(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - struct viawget_scan_result *scan_buf; - PSMgmtObject pMgmt = pDevice->pMgmt; - PWLAN_IE_SSID pItemSSID; - PKnownBSS pBSS; - unsigned char *pBuf; - int ret = 0; - u16 count = 0; - u16 ii, jj; - unsigned char *ptempBSS; - - ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC); - - if (ptempBSS == NULL) { - pr_err("bubble sort kmalloc memory fail@@@\n"); - - ret = -ENOMEM; - - return ret; - - } - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - for (jj = 0; jj < MAX_BSS_NUM - ii - 1; jj++) { - if ((pMgmt->sBSSList[jj].bActive != true) || - - ((pMgmt->sBSSList[jj].uRSSI > pMgmt->sBSSList[jj + 1].uRSSI) && (pMgmt->sBSSList[jj + 1].bActive != false))) { - memcpy(ptempBSS, &pMgmt->sBSSList[jj], sizeof(KnownBSS)); - - memcpy(&pMgmt->sBSSList[jj], &pMgmt->sBSSList[jj + 1], sizeof(KnownBSS)); - - memcpy(&pMgmt->sBSSList[jj + 1], ptempBSS, sizeof(KnownBSS)); - - } - - } - - } - - kfree(ptempBSS); - -//******mike:bubble sort by stronger RSSI*****// - - count = 0; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - count++; - } - - pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC); - - if (pBuf == NULL) { - ret = -ENOMEM; - return ret; - } - scan_buf = (struct viawget_scan_result *)pBuf; - pBSS = &(pMgmt->sBSSList[0]); - for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (pBSS->bActive) { - if (jj >= count) - break; - memcpy(scan_buf->bssid, pBSS->abyBSSID, WLAN_BSSID_LEN); - pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; - memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len); - scan_buf->ssid_len = pItemSSID->len; - scan_buf->freq = frequency_list[pBSS->uChannel-1]; - scan_buf->caps = pBSS->wCapInfo; - - if (pBSS->wWPALen != 0) { - scan_buf->wpa_ie_len = pBSS->wWPALen; - memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen); - } - if (pBSS->wRSNLen != 0) { - scan_buf->rsn_ie_len = pBSS->wRSNLen; - memcpy(scan_buf->rsn_ie, pBSS->byRSNIE, pBSS->wRSNLen); - } - scan_buf = (struct viawget_scan_result *)((unsigned char *)scan_buf + sizeof(struct viawget_scan_result)); - jj++; - } - } - - if (jj < count) - count = jj; - - if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) - ret = -EFAULT; - - param->u.scan_results.scan_count = count; - pr_debug(" param->u.scan_results.scan_count = %d\n", count); - - kfree(pBuf); - return ret; -} - -/* - * Description: - * set associate with AP - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int wpa_set_associate(struct vnt_private *pDevice, - struct viawget_wpa_param *param) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - PWLAN_IE_SSID pItemSSID; - unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - unsigned char abyWPAIE[64]; - bool bWepEnabled = false; - - /* set key type & algorithm */ - pr_debug("pairwise_suite = %d\n", - param->u.wpa_associate.pairwise_suite); - pr_debug("group_suite = %d\n", param->u.wpa_associate.group_suite); - pr_debug("key_mgmt_suite = %d\n", - param->u.wpa_associate.key_mgmt_suite); - pr_debug("auth_alg = %d\n", param->u.wpa_associate.auth_alg); - pr_debug("mode = %d\n", param->u.wpa_associate.mode); - pr_debug("wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len); - - if (param->u.wpa_associate.wpa_ie_len) { - if (!param->u.wpa_associate.wpa_ie) - return -EINVAL; - if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE)) - return -EINVAL; - if (copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, param->u.wpa_associate.wpa_ie_len)) - return -EFAULT; - } - - if (param->u.wpa_associate.mode == 1) - pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; - else - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - /* set ssid */ - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; - pItemSSID->byElementID = WLAN_EID_SSID; - pItemSSID->len = param->u.wpa_associate.ssid_len; - memcpy(pItemSSID->abySSID, param->u.wpa_associate.ssid, pItemSSID->len); - /* set bssid */ - if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0) - memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6); - else - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID); - - if (param->u.wpa_associate.wpa_ie_len == 0) { - if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY) - pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY; - else - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - } else if (abyWPAIE[0] == RSN_INFO_ELEM) { - if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK) - pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; - else - pMgmt->eAuthenMode = WMAC_AUTH_WPA2; - } else { - if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_WPA_NONE) - pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; - else if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK) - pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; - else - pMgmt->eAuthenMode = WMAC_AUTH_WPA; - } - - switch (param->u.wpa_associate.pairwise_suite) { - case CIPHER_CCMP: - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - break; - case CIPHER_TKIP: - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - break; - case CIPHER_WEP40: - case CIPHER_WEP104: - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - bWepEnabled = true; - break; - case CIPHER_NONE: - if (param->u.wpa_associate.group_suite == CIPHER_CCMP) - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - else - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - break; - default: - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - } - -//DavidWang add for WPA_supplicant support open/share mode - - if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pMgmt->bShareKeyAlgorithm = true; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) { - if (!bWepEnabled) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - } -//mike save old encryption status - pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus; - - if (pDevice->eEncryptionStatus != Ndis802_11EncryptionDisabled) - pDevice->bEncryptionEnable = true; - else - pDevice->bEncryptionEnable = false; - if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) || - ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && bWepEnabled))) //DavidWang //20080717-06, by chester//Not to initial WEP - KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); - spin_lock_irq(&pDevice->lock); - pDevice->bLinkPass = false; - memset(pMgmt->abyCurrBSSID, 0, 6); - pMgmt->eCurrState = WMAC_STATE_IDLE; - netif_stop_queue(pDevice->dev); - //20080701-02, by Mike Liu -/*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/ - { - PKnownBSS pCurr = NULL; - - pCurr = BSSpSearchBSSList(pDevice, - pMgmt->abyDesireBSSID, - pMgmt->abyDesireSSID, - pMgmt->eConfigPHYMode -); - - if (pCurr == NULL) { - pr_debug("wpa_set_associate---->hidden mode site survey before associate.......\n"); - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - } - } -/****************************************************************/ - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); - spin_unlock_irq(&pDevice->lock); - - return 0; -} - -/* - * Description: - * wpa_ioctl main function supported for wpa supplicant - * - * Parameters: - * In: - * pDevice - - * iw_point - - * Out: - * - * Return Value: - * - */ - -int wpa_ioctl(struct vnt_private *pDevice, struct iw_point *p) -{ - struct viawget_wpa_param *param; - int ret = 0; - int wpa_ioctl = 0; - - if (p->length < sizeof(struct viawget_wpa_param) || - p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer) - return -EINVAL; - - param = kmalloc((int)p->length, GFP_KERNEL); - if (param == NULL) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - ret = -EFAULT; - goto out; - } - - switch (param->cmd) { - case VIAWGET_SET_WPA: - ret = wpa_set_wpa(pDevice, param); - pr_debug("VIAWGET_SET_WPA\n"); - break; - - case VIAWGET_SET_KEY: - pr_debug("VIAWGET_SET_KEY\n"); - spin_lock_irq(&pDevice->lock); - ret = wpa_set_keys(pDevice, param, false); - spin_unlock_irq(&pDevice->lock); - break; - - case VIAWGET_SET_SCAN: - pr_debug("VIAWGET_SET_SCAN\n"); - ret = wpa_set_scan(pDevice, param); - break; - - case VIAWGET_GET_SCAN: - pr_debug("VIAWGET_GET_SCAN\n"); - ret = wpa_get_scan(pDevice, param); - wpa_ioctl = 1; - break; - - case VIAWGET_GET_SSID: - pr_debug("VIAWGET_GET_SSID\n"); - ret = wpa_get_ssid(pDevice, param); - wpa_ioctl = 1; - break; - - case VIAWGET_GET_BSSID: - pr_debug("VIAWGET_GET_BSSID\n"); - ret = wpa_get_bssid(pDevice, param); - wpa_ioctl = 1; - break; - - case VIAWGET_SET_ASSOCIATE: - pr_debug("VIAWGET_SET_ASSOCIATE\n"); - ret = wpa_set_associate(pDevice, param); - break; - - case VIAWGET_SET_DISASSOCIATE: - pr_debug("VIAWGET_SET_DISASSOCIATE\n"); - ret = wpa_set_disassociate(pDevice, param); - break; - - case VIAWGET_SET_DROP_UNENCRYPT: - pr_debug("VIAWGET_SET_DROP_UNENCRYPT\n"); - break; - - case VIAWGET_SET_DEAUTHENTICATE: - pr_debug("VIAWGET_SET_DEAUTHENTICATE\n"); - break; - - default: - pr_debug("wpa_ioctl: unknown cmd=%d\n", - param->cmd); - ret = -EOPNOTSUPP; - goto out; - } - - if ((ret == 0) && wpa_ioctl) { - if (copy_to_user(p->pointer, param, p->length)) { - ret = -EFAULT; - goto out; - } - } - -out: - kfree(param); - - return ret; -} diff --git a/drivers/staging/vt6655/wpactl.h b/drivers/staging/vt6655/wpactl.h deleted file mode 100644 index c1b4a7292061..000000000000 --- a/drivers/staging/vt6655/wpactl.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wpactl.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: March 1, 2005 - * - */ - -#ifndef __WPACTL_H__ -#define __WPACTL_H__ - -#include "device.h" -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -#include "iowpa.h" -#endif - -/*--------------------- Export Definitions -------------------------*/ - -//WPA related - -enum wpa_alg { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP }; -enum wpa_cipher { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, - CIPHER_WEP104 }; -enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_CCKM, KEY_MGMT_PSK, KEY_MGMT_NONE, - KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE }; - -#define AUTH_ALG_OPEN_SYSTEM 0x01 -#define AUTH_ALG_SHARED_KEY 0x02 -#define AUTH_ALG_LEAP 0x04 - -#define GENERIC_INFO_ELEM 0xdd -#define RSN_INFO_ELEM 0x30 - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -int wpa_set_wpadev(struct vnt_private *, int val); -int wpa_ioctl(struct vnt_private *, struct iw_point *p); -int wpa_set_keys(struct vnt_private *, void *ctx, bool fcpfkernel); - -#endif // __WPACL_H__ -- cgit v1.2.3-59-g8ed1b From 01b8979244ee164dd90958521ed9aecec9dafe3f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:26 +0000 Subject: staging: vt6655: dpc.c/h remove dead functions s_byGetRateIdx s_vGetDASA s_vProcessRxMACHeader s_bAPModeRxCtl s_bAPModeRxData s_bHandleRxEncryption s_bHostWepRxEncryption s_vProcessRxMACHeader s_byGetRateIdx s_vGetDASA device_receive_frame s_bAPModeRxCtl Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.c | 1286 ------------------------------------------ drivers/staging/vt6655/dpc.h | 8 - 2 files changed, 1294 deletions(-) diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 6842baf73ed1..977683cb7391 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -25,1302 +25,16 @@ * Date: May 20, 2003 * * Functions: - * device_receive_frame - Rcv 802.11 frame function - * s_bAPModeRxCtl- AP Rcv frame filer Ctl. - * s_bAPModeRxData- AP Rcv data frame handle - * s_bHandleRxEncryption- Rcv decrypted data via on-fly - * s_bHostWepRxEncryption- Rcv encrypted data via host - * s_byGetRateIdx- get rate index - * s_vGetDASA- get data offset - * s_vProcessRxMACHeader- Rcv 802.11 and translate to 802.3 * * Revision History: * */ #include "device.h" -#include "rxtx.h" -#include "tether.h" -#include "card.h" -#include "bssdb.h" -#include "mac.h" #include "baseband.h" -#include "michael.h" -#include "tkip.h" -#include "tcrc.h" -#include "wctl.h" -#include "wroute.h" #include "rf.h" -#include "iowpa.h" -#include "aes_ccmp.h" #include "dpc.h" -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ -static const unsigned char acbyRxRate[MAX_RATE] = -{2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108}; - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -static unsigned char s_byGetRateIdx(unsigned char byRate); - -static void -s_vGetDASA(unsigned char *pbyRxBufferAddr, unsigned int *pcbHeaderSize, - PSEthernetHeader psEthHeader); - -static void -s_vProcessRxMACHeader(struct vnt_private *pDevice, unsigned char *pbyRxBufferAddr, - unsigned int cbPacketSize, bool bIsWEP, bool bExtIV, - unsigned int *pcbHeadSize); - -static bool s_bAPModeRxCtl( - struct vnt_private *pDevice, - unsigned char *pbyFrame, - int iSANodeIndex -); - -static bool s_bAPModeRxData( - struct vnt_private *pDevice, - struct sk_buff *skb, - unsigned int FrameSize, - unsigned int cbHeaderOffset, - int iSANodeIndex, - int iDANodeIndex -); - -static bool s_bHandleRxEncryption( - struct vnt_private *pDevice, - unsigned char *pbyFrame, - unsigned int FrameSize, - unsigned char *pbyRsr, - unsigned char *pbyNewRsr, - PSKeyItem *pKeyOut, - bool *pbExtIV, - unsigned short *pwRxTSC15_0, - unsigned long *pdwRxTSC47_16 -); - -static bool s_bHostWepRxEncryption( - - struct vnt_private *pDevice, - unsigned char *pbyFrame, - unsigned int FrameSize, - unsigned char *pbyRsr, - bool bOnFly, - PSKeyItem pKey, - unsigned char *pbyNewRsr, - bool *pbExtIV, - unsigned short *pwRxTSC15_0, - unsigned long *pdwRxTSC47_16 - -); - -/*--------------------- Export Variables --------------------------*/ - -/*+ - * - * Description: - * Translate Rcv 802.11 header to 802.3 header with Rx buffer - * - * Parameters: - * In: - * pDevice - * dwRxBufferAddr - Address of Rcv Buffer - * cbPacketSize - Rcv Packet size - * bIsWEP - If Rcv with WEP - * Out: - * pcbHeaderSize - 802.11 header size - * - * Return Value: None - * - -*/ -static void -s_vProcessRxMACHeader(struct vnt_private *pDevice, - unsigned char *pbyRxBufferAddr, - unsigned int cbPacketSize, bool bIsWEP, bool bExtIV, - unsigned int *pcbHeadSize) -{ - unsigned char *pbyRxBuffer; - unsigned int cbHeaderSize = 0; - unsigned short *pwType; - PS802_11Header pMACHeader; - int ii; - - pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize); - - s_vGetDASA((unsigned char *)pMACHeader, &cbHeaderSize, &pDevice->sRxEthHeader); - - if (bIsWEP) { - if (bExtIV) { - /* strip IV&ExtIV, add 8 byte */ - cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 8); - } else { - /* strip IV, add 4 byte */ - cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 4); - } - } else { - cbHeaderSize += WLAN_HDR_ADDR3_LEN; - } - - pbyRxBuffer = (unsigned char *)(pbyRxBufferAddr + cbHeaderSize); - if (ether_addr_equal(pbyRxBuffer, pDevice->abySNAP_Bridgetunnel)) { - cbHeaderSize += 6; - } else if (ether_addr_equal(pbyRxBuffer, pDevice->abySNAP_RFC1042)) { - cbHeaderSize += 6; - pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); - if ((*pwType != TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) { - } else { - cbHeaderSize -= 8; - pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); - if (bIsWEP) { - if (bExtIV) - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); /* 8 is IV&ExtIV */ - else - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); /* 4 is IV */ - - } else { - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN); - } - } - } else { - cbHeaderSize -= 2; - pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); - if (bIsWEP) { - if (bExtIV) - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); /* 8 is IV&ExtIV */ - else - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); /* 4 is IV */ - - } else { - *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN); - } - } - - cbHeaderSize -= (ETH_ALEN * 2); - pbyRxBuffer = (unsigned char *)(pbyRxBufferAddr + cbHeaderSize); - for (ii = 0; ii < ETH_ALEN; ii++) - *pbyRxBuffer++ = pDevice->sRxEthHeader.abyDstAddr[ii]; - for (ii = 0; ii < ETH_ALEN; ii++) - *pbyRxBuffer++ = pDevice->sRxEthHeader.abySrcAddr[ii]; - - *pcbHeadSize = cbHeaderSize; -} - -static unsigned char s_byGetRateIdx(unsigned char byRate) -{ - unsigned char byRateIdx; - - for (byRateIdx = 0; byRateIdx < MAX_RATE; byRateIdx++) { - if (acbyRxRate[byRateIdx % MAX_RATE] == byRate) - return byRateIdx; - } - - return 0; -} - -static void -s_vGetDASA(unsigned char *pbyRxBufferAddr, unsigned int *pcbHeaderSize, - PSEthernetHeader psEthHeader) -{ - unsigned int cbHeaderSize = 0; - PS802_11Header pMACHeader; - int ii; - - pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize); - - if ((pMACHeader->wFrameCtl & FC_TODS) == 0) { - if (pMACHeader->wFrameCtl & FC_FROMDS) { - for (ii = 0; ii < ETH_ALEN; ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii]; - } - } else { - /* IBSS mode */ - for (ii = 0; ii < ETH_ALEN; ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii]; - } - } - } else { - /* Is AP mode.. */ - if (pMACHeader->wFrameCtl & FC_FROMDS) { - for (ii = 0; ii < ETH_ALEN; ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr4[ii]; - cbHeaderSize += 6; - } - } else { - for (ii = 0; ii < ETH_ALEN; ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii]; - } - } - } - *pcbHeaderSize = cbHeaderSize; -} - -bool -device_receive_frame( - struct vnt_private *pDevice, - PSRxDesc pCurrRD -) -{ - PDEVICE_RD_INFO pRDInfo = pCurrRD->pRDInfo; - struct net_device_stats *pStats = &pDevice->dev->stats; - struct sk_buff *skb; - PSMgmtObject pMgmt = pDevice->pMgmt; - PSRxMgmtPacket pRxPacket = &(pDevice->pMgmt->sRxPacket); - PS802_11Header p802_11Header; - unsigned char *pbyRsr; - unsigned char *pbyNewRsr; - unsigned char *pbyRSSI; - __le64 *pqwTSFTime; - unsigned short *pwFrameSize; - unsigned char *pbyFrame; - bool bDeFragRx = false; - bool bIsWEP = false; - unsigned int cbHeaderOffset; - unsigned int FrameSize; - unsigned short wEtherType = 0; - int iSANodeIndex = -1; - int iDANodeIndex = -1; - unsigned int ii; - unsigned int cbIVOffset; - bool bExtIV = false; - unsigned char *pbyRxSts; - unsigned char *pbyRxRate; - unsigned char *pbySQ; - unsigned int cbHeaderSize; - PSKeyItem pKey = NULL; - unsigned short wRxTSC15_0 = 0; - unsigned long dwRxTSC47_16 = 0; - SKeyItem STempKey; - /* 802.11h RPI */ - unsigned long dwDuration = 0; - long ldBm = 0; - long ldBmThreshold = 0; - PS802_11Header pMACHeader; - bool bRxeapol_key = false; - - skb = pRDInfo->skb; - - pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma, - pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE); - - pwFrameSize = (unsigned short *)(skb->data + 2); - FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount); - - /* - * Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR - * Min (ACK): 10HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR - */ - if ((FrameSize > 2364) || (FrameSize <= 32)) { - /* Frame Size error drop this packet. */ - pr_debug("---------- WRONG Length 1\n"); - return false; - } - - pbyRxSts = (unsigned char *)(skb->data); - pbyRxRate = (unsigned char *)(skb->data + 1); - pbyRsr = (unsigned char *)(skb->data + FrameSize - 1); - pbyRSSI = (unsigned char *)(skb->data + FrameSize - 2); - pbyNewRsr = (unsigned char *)(skb->data + FrameSize - 3); - pbySQ = (unsigned char *)(skb->data + FrameSize - 4); - pqwTSFTime = (__le64 *)(skb->data + FrameSize - 12); - pbyFrame = (unsigned char *)(skb->data + 4); - - /* get packet size */ - FrameSize = cpu_to_le16(*pwFrameSize); - - if ((FrameSize > 2346)|(FrameSize < 14)) { /* - * Max: 2312Payload + 30HD +4CRC - * Min: 14 bytes ACK - */ - pr_debug("---------- WRONG Length 2\n"); - return false; - } - - /* update receive statistic counter */ - STAvUpdateRDStatCounter(&pDevice->scStatistic, - *pbyRsr, - *pbyNewRsr, - *pbyRxRate, - pbyFrame, - FrameSize); - - pMACHeader = (PS802_11Header)((unsigned char *)(skb->data) + 8); - - if (pDevice->bMeasureInProgress) { - if ((*pbyRsr & RSR_CRCOK) != 0) - pDevice->byBasicMap |= 0x01; - - dwDuration = FrameSize << 4; - dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE]; - if (*pbyRxRate <= RATE_11M) { - if (*pbyRxSts & 0x01) { - /* long preamble */ - dwDuration += 192; - } else { - /* short preamble */ - dwDuration += 96; - } - } else { - dwDuration += 16; - } - RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm); - ldBmThreshold = -57; - for (ii = 7; ii > 0;) { - if (ldBm > ldBmThreshold) - break; - - ldBmThreshold -= 5; - ii--; - } - pDevice->dwRPIs[ii] += dwDuration; - return false; - } - - if (!is_multicast_ether_addr(pbyFrame)) { - if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header)(skb->data + 4))) { - pDevice->s802_11Counter.FrameDuplicateCount++; - return false; - } - } - - /* Use for TKIP MIC */ - s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader); - - /* filter packet send from myself */ - if (ether_addr_equal(pDevice->sRxEthHeader.abySrcAddr, - pDevice->abyCurrentNetAddr)) - return false; - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { - if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { - p802_11Header = (PS802_11Header)(pbyFrame); - /* get SA NodeIndex */ - if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(p802_11Header->abyAddr2), &iSANodeIndex)) { - pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies; - pMgmt->sNodeDBTable[iSANodeIndex].uInActiveCount = 0; - } - } - } - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex)) - return false; - } - - if (IS_FC_WEP(pbyFrame)) { - bool bRxDecryOK = false; - - pr_debug("rx WEP pkt\n"); - bIsWEP = true; - if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) { - pKey = &STempKey; - pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite; - pKey->dwKeyIndex = pMgmt->sNodeDBTable[iSANodeIndex].dwKeyIndex; - pKey->uKeyLength = pMgmt->sNodeDBTable[iSANodeIndex].uWepKeyLength; - pKey->dwTSC47_16 = pMgmt->sNodeDBTable[iSANodeIndex].dwTSC47_16; - pKey->wTSC15_0 = pMgmt->sNodeDBTable[iSANodeIndex].wTSC15_0; - memcpy(pKey->abyKey, - &pMgmt->sNodeDBTable[iSANodeIndex].abyWepKey[0], - pKey->uKeyLength -); - - bRxDecryOK = s_bHostWepRxEncryption(pDevice, - pbyFrame, - FrameSize, - pbyRsr, - pMgmt->sNodeDBTable[iSANodeIndex].bOnFly, - pKey, - pbyNewRsr, - &bExtIV, - &wRxTSC15_0, - &dwRxTSC47_16); - } else { - bRxDecryOK = s_bHandleRxEncryption(pDevice, - pbyFrame, - FrameSize, - pbyRsr, - pbyNewRsr, - &pKey, - &bExtIV, - &wRxTSC15_0, - &dwRxTSC47_16); - } - - if (bRxDecryOK) { - if ((*pbyNewRsr & NEWRSR_DECRYPTOK) == 0) { - pr_debug("ICV Fail\n"); - if ((pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA) || - (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || - (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) || - (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || - (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) - pDevice->s802_11Counter.TKIPICVErrors++; - else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) - pDevice->s802_11Counter.CCMPDecryptErrors++; - } - return false; - } - } else { - pr_debug("WEP Func Fail\n"); - return false; - } - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) - FrameSize -= 8; /* Message Integrity Code */ - else - FrameSize -= 4; /* 4 is ICV */ - } - - /* RX OK, remove the CRC length */ - FrameSize -= ETH_FCS_LEN; - - if ((!(*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI))) && /* unicast address */ - (IS_FRAGMENT_PKT((skb->data+4))) -) { - /* defragment */ - bDeFragRx = WCTLbHandleFragment(pDevice, (PS802_11Header)(skb->data+4), FrameSize, bIsWEP, bExtIV); - pDevice->s802_11Counter.ReceivedFragmentCount++; - if (bDeFragRx) { - /* defrag complete */ - skb = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb; - FrameSize = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength; - - } else { - return false; - } - } - -/* Management & Control frame Handle */ - if ((IS_TYPE_DATA((skb->data+4))) == false) { - /* Handle Control & Manage Frame */ - - if (IS_TYPE_MGMT((skb->data+4))) { - unsigned char *pbyData1; - unsigned char *pbyData2; - - pRxPacket->p80211Header = (PUWLAN_80211HDR)(skb->data+4); - pRxPacket->cbMPDULen = FrameSize; - pRxPacket->uRSSI = *pbyRSSI; - pRxPacket->bySQ = *pbySQ; - pRxPacket->qwLocalTSF = le64_to_cpu(*pqwTSFTime); - if (bIsWEP) { - /* strip IV */ - pbyData1 = WLAN_HDR_A3_DATA_PTR(skb->data+4); - pbyData2 = WLAN_HDR_A3_DATA_PTR(skb->data+4) + 4; - for (ii = 0; ii < (FrameSize - 4); ii++) { - *pbyData1 = *pbyData2; - pbyData1++; - pbyData2++; - } - } - pRxPacket->byRxRate = s_byGetRateIdx(*pbyRxRate); - pRxPacket->byRxChannel = (*pbyRxSts) >> 2; - - vMgrRxManagePacket((void *)pDevice, pDevice->pMgmt, pRxPacket); - - /* hostap Deamon handle 802.11 management */ - if (pDevice->bEnableHostapd) { - skb->dev = pDevice->apdev; - skb->data += 4; - skb->tail += 4; - skb_put(skb, FrameSize); - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); - return true; - } - } - - return false; - } else { - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - /* In AP mode, hw only check addr1(BSSID or RA) if equal to local MAC. */ - if (!(*pbyRsr & RSR_BSSIDOK)) { - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - pr_err("%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - } else { - /* discard DATA packet while not associate || BSSID error */ - if (!pDevice->bLinkPass || !(*pbyRsr & RSR_BSSIDOK)) { - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - pr_err("%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - { - unsigned char Protocol_Version; /* 802.1x Authentication */ - unsigned char Packet_Type; /* 802.1x Authentication */ - - if (bIsWEP) - cbIVOffset = 8; - else - cbIVOffset = 0; - wEtherType = (skb->data[cbIVOffset + 8 + 24 + 6] << 8) | - skb->data[cbIVOffset + 8 + 24 + 6 + 1]; - Protocol_Version = skb->data[cbIVOffset + 8 + 24 + 6 + 1 + 1]; - Packet_Type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 + 1 + 1]; - if (wEtherType == ETH_P_PAE) { /* Protocol Type in LLC-Header */ - if (((Protocol_Version == 1) || (Protocol_Version == 2)) && - (Packet_Type == 3)) { /*802.1x OR eapol-key challenge frame receive */ - bRxeapol_key = true; - } - } - } - } - } - -/* Data frame Handle */ - - if (pDevice->bEnablePSMode) { - if (!IS_FC_MOREDATA((skb->data+4))) { - if (pDevice->pMgmt->bInTIMWake == true) - pDevice->pMgmt->bInTIMWake = false; - } - } - - /* Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps */ - if (pDevice->bDiversityEnable && (FrameSize > 50) && - (pDevice->op_mode == NL80211_IFTYPE_STATION) && - pDevice->bLinkPass) { - BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0); - } - - if (pDevice->byLocalID != REV_ID_VT3253_B1) - pDevice->uCurrRSSI = *pbyRSSI; - - pDevice->byCurrSQ = *pbySQ; - - if ((*pbyRSSI != 0) && - (pMgmt->pCurrBSS != NULL)) { - RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm); - /* Monitor if RSSI is too strong. */ - pMgmt->pCurrBSS->byRSSIStatCnt++; - pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT; - pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm; - for (ii = 0; ii < RSSI_STAT_COUNT; ii++) - if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0) - pMgmt->pCurrBSS->ldBmMAX = max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm); - - } - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnable8021x) { - unsigned char abyMacHdr[24]; - - /* Only 802.1x packet incoming allowed */ - if (bIsWEP) - cbIVOffset = 8; - else - cbIVOffset = 0; - wEtherType = (skb->data[cbIVOffset + 4 + 24 + 6] << 8) | - skb->data[cbIVOffset + 4 + 24 + 6 + 1]; - - pr_debug("wEtherType = %04x\n", wEtherType); - if (wEtherType == ETH_P_PAE) { - skb->dev = pDevice->apdev; - - if (bIsWEP) { - /* strip IV header(8) */ - memcpy(&abyMacHdr[0], (skb->data + 4), 24); - memcpy((skb->data + 4 + cbIVOffset), &abyMacHdr[0], 24); - } - skb->data += (cbIVOffset + 4); - skb->tail += (cbIVOffset + 4); - skb_put(skb, FrameSize); - skb_reset_mac_header(skb); - - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); - return true; - - } - /* check if 802.1x authorized */ - if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED)) - return false; - } - - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { - if (bIsWEP) - FrameSize -= 8; /* MIC */ - } - - /* Soft MIC */ - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { - if (bIsWEP) { - __le32 *pdwMIC_L; - __le32 *pdwMIC_R; - __le32 dwMIC_Priority; - __le32 dwMICKey0 = 0, dwMICKey1 = 0; - u32 dwLocalMIC_L = 0; - u32 dwLocalMIC_R = 0; - viawget_wpa_header *wpahdr; - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[24])); - dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[28])); - } else { - if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[16])); - dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[20])); - } else if ((pKey->dwKeyIndex & BIT28) == 0) { - dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[16])); - dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[20])); - } else { - dwMICKey0 = cpu_to_le32(*(u32 *)(&pKey->abyKey[24])); - dwMICKey1 = cpu_to_le32(*(u32 *)(&pKey->abyKey[28])); - } - } - - MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((unsigned char *)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12); - dwMIC_Priority = 0; - MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); - /* 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV. */ - MIC_vAppend((unsigned char *)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8), - FrameSize - WLAN_HDR_ADDR3_LEN - 8); - MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R); - MIC_vUnInit(); - - pdwMIC_L = (__le32 *)(skb->data + 4 + FrameSize); - pdwMIC_R = (__le32 *)(skb->data + 4 + FrameSize + 4); - - if ((le32_to_cpu(*pdwMIC_L) != dwLocalMIC_L) || - (le32_to_cpu(*pdwMIC_R) != dwLocalMIC_R) || - pDevice->bRxMICFail) { - pr_debug("MIC comparison is fail!\n"); - pDevice->bRxMICFail = false; - pDevice->s802_11Counter.TKIPLocalMICFailures++; - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - pr_err("%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - /* send event to wpa_supplicant */ - { - union iwreq_data wrqu; - struct iw_michaelmicfailure ev; - int keyidx = pbyFrame[cbHeaderSize+3] >> 6; /* top two-bits */ - - memset(&ev, 0, sizeof(ev)); - ev.flags = keyidx & IW_MICFAILURE_KEY_ID; - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && - (pMgmt->eCurrState == WMAC_STATE_ASSOC) && - (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) { - ev.flags |= IW_MICFAILURE_PAIRWISE; - } else { - ev.flags |= IW_MICFAILURE_GROUP; - } - - ev.src_addr.sa_family = ARPHRD_ETHER; - ether_addr_copy(ev.src_addr.sa_data, - pMACHeader->abyAddr2); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = sizeof(ev); - wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); - - } -#endif - - if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) { - wpahdr = (viawget_wpa_header *)pDevice->skb->data; - if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && - (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC) && - (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) { - wpahdr->type = VIAWGET_PTK_MIC_MSG; - } else { - wpahdr->type = VIAWGET_GTK_MIC_MSG; - } - wpahdr->resp_ie_len = 0; - wpahdr->req_ie_len = 0; - skb_put(pDevice->skb, sizeof(viawget_wpa_header)); - pDevice->skb->dev = pDevice->wpadev; - skb_reset_mac_header(pDevice->skb); - pDevice->skb->pkt_type = PACKET_HOST; - pDevice->skb->protocol = htons(ETH_P_802_2); - memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); - netif_rx(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - } - - return false; - - } - } - } - - /* ++++++++++ Reply Counter Check +++++++++++++ */ - if ((pKey != NULL) && ((pKey->byCipherSuite == KEY_CTL_TKIP) || - (pKey->byCipherSuite == KEY_CTL_CCMP))) { - if (bIsWEP) { - unsigned short wLocalTSC15_0 = 0; - unsigned long dwLocalTSC47_16 = 0; - unsigned long long RSC = 0; - /* endian issues */ - RSC = *((unsigned long long *)&(pKey->KeyRSC)); - wLocalTSC15_0 = (unsigned short)RSC; - dwLocalTSC47_16 = (unsigned long)(RSC>>16); - - RSC = dwRxTSC47_16; - RSC <<= 16; - RSC += wRxTSC15_0; - pKey->KeyRSC = RSC; - - if ((pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) && - (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) { - /* check RSC */ - if ((wRxTSC15_0 < wLocalTSC15_0) && - (dwRxTSC47_16 <= dwLocalTSC47_16) && - !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) { - pr_debug("TSC is illegal~~!\n "); - if (pKey->byCipherSuite == KEY_CTL_TKIP) - pDevice->s802_11Counter.TKIPReplays++; - else - pDevice->s802_11Counter.CCMPReplays++; - - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - pr_err("%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - } - } - } - - s_vProcessRxMACHeader(pDevice, (unsigned char *)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset); - FrameSize -= cbHeaderOffset; - cbHeaderOffset += 4; /* 4 is Rcv buffer header */ - - /* Null data, framesize = 14 */ - if (FrameSize < 15) - return false; - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (!s_bAPModeRxData(pDevice, - skb, - FrameSize, - cbHeaderOffset, - iSANodeIndex, - iDANodeIndex -)) { - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - pr_err("%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - } - - skb->data += cbHeaderOffset; - skb->tail += cbHeaderOffset; - skb_put(skb, FrameSize); - skb->protocol = eth_type_trans(skb, skb->dev); - - /* drop frame not met IEEE 802.3 */ - - skb->ip_summed = CHECKSUM_NONE; - pStats->rx_bytes += skb->len; - pStats->rx_packets++; - netif_rx(skb); - - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - pr_err("%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - return false; - } - - return true; -} - -static bool s_bAPModeRxCtl( - struct vnt_private *pDevice, - unsigned char *pbyFrame, - int iSANodeIndex -) -{ - PS802_11Header p802_11Header; - CMD_STATUS Status; - PSMgmtObject pMgmt = pDevice->pMgmt; - - if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { - p802_11Header = (PS802_11Header)(pbyFrame); - if (!IS_TYPE_MGMT(pbyFrame)) { - /* Data & PS-Poll packet, check frame class */ - if (iSANodeIndex > 0) { - /* frame class 3 fliter & checking */ - if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) { - /* - * send deauth notification - * reason = (6) class 2 received from nonauth sta - */ - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - (unsigned char *)(p802_11Header->abyAddr2), - (WLAN_MGMT_REASON_CLASS2_NONAUTH), - &Status -); - pr_debug("dpc: send vMgrDeAuthenBeginSta 1\n"); - return true; - } - if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) { - /* - * send deassoc notification - * reason = (7) class 3 received from nonassoc sta - */ - vMgrDisassocBeginSta(pDevice, - pMgmt, - (unsigned char *)(p802_11Header->abyAddr2), - (WLAN_MGMT_REASON_CLASS3_NONASSOC), - &Status -); - pr_debug("dpc: send vMgrDisassocBeginSta 2\n"); - return true; - } - - if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) { - /* delcare received ps-poll event */ - if (IS_CTL_PSPOLL(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL); - pr_debug("dpc: WLAN_CMD_RX_PSPOLL 1\n"); - } else { - /* - * check Data PS state - * if PW bit off, send out all PS bufferring packets. - */ - if (!IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL); - pr_debug("dpc: WLAN_CMD_RX_PSPOLL 2\n"); - } - } - } else { - if (IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = true; - /* Once if STA in PS state, enable multicast bufferring */ - pMgmt->sNodeDBTable[0].bPSEnable = true; - } else { - /* clear all pending PS frame. */ - if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL); - pr_debug("dpc: WLAN_CMD_RX_PSPOLL 3\n"); - - } - } - } - } else { - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - (unsigned char *)(p802_11Header->abyAddr2), - (WLAN_MGMT_REASON_CLASS2_NONAUTH), - &Status -); - pr_debug("dpc: send vMgrDeAuthenBeginSta 3\n"); - pr_debug("BSSID:%pM\n", - p802_11Header->abyAddr3); - pr_debug("ADDR2:%pM\n", - p802_11Header->abyAddr2); - pr_debug("ADDR1:%pM\n", - p802_11Header->abyAddr1); - pr_debug("dpc: wFrameCtl= %x\n", - p802_11Header->wFrameCtl); - VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode)); - pr_debug("dpc:pDevice->byRxMode = %x\n", - pDevice->byRxMode); - return true; - } - } - } - return false; -} - -static bool s_bHandleRxEncryption( - struct vnt_private *pDevice, - unsigned char *pbyFrame, - unsigned int FrameSize, - unsigned char *pbyRsr, - unsigned char *pbyNewRsr, - PSKeyItem *pKeyOut, - bool *pbExtIV, - unsigned short *pwRxTSC15_0, - unsigned long *pdwRxTSC47_16 -) -{ - unsigned int PayloadLen = FrameSize; - unsigned char *pbyIV; - unsigned char byKeyIdx; - PSKeyItem pKey = NULL; - unsigned char byDecMode = KEY_CTL_WEP; - PSMgmtObject pMgmt = pDevice->pMgmt; - - *pwRxTSC15_0 = 0; - *pdwRxTSC47_16 = 0; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && - WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) { - pbyIV += 6; /* 6 is 802.11 address4 */ - PayloadLen -= 6; - } - byKeyIdx = (*(pbyIV+3) & 0xc0); - byKeyIdx >>= 6; - pr_debug("\nKeyIdx: %d\n", byKeyIdx); - - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { - if (((*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) && - (pDevice->pMgmt->byCSSPK != KEY_CTL_NONE)) { - /* unicast pkt use pairwise key */ - pr_debug("unicast pkt\n"); - if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == true) { - if (pDevice->pMgmt->byCSSPK == KEY_CTL_TKIP) - byDecMode = KEY_CTL_TKIP; - else if (pDevice->pMgmt->byCSSPK == KEY_CTL_CCMP) - byDecMode = KEY_CTL_CCMP; - } - pr_debug("unicast pkt: %d, %p\n", byDecMode, pKey); - } else { - /* use group key */ - KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, byKeyIdx, &pKey); - if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP) - byDecMode = KEY_CTL_TKIP; - else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP) - byDecMode = KEY_CTL_CCMP; - pr_debug("group pkt: %d, %d, %p\n", - byKeyIdx, byDecMode, pKey); - } - } - /* our WEP only support Default Key */ - if (pKey == NULL) { - /* use default group key */ - KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, byKeyIdx, &pKey); - if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP) - byDecMode = KEY_CTL_TKIP; - else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP) - byDecMode = KEY_CTL_CCMP; - } - *pKeyOut = pKey; - - pr_debug("AES:%d %d %d\n", - pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode); - - if (pKey == NULL) { - pr_debug("pKey == NULL\n"); - - return false; - } - if (byDecMode != pKey->byCipherSuite) { - - *pKeyOut = NULL; - return false; - } - if (byDecMode == KEY_CTL_WEP) { - /* handle WEP */ - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || - (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true)) { - /* - * Software WEP - * 1. 3253A - * 2. WEP 256 - */ - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); /* 24 is 802.11 header,4 is IV, 4 is crc */ - memcpy(pDevice->abyPRNG, pbyIV, 3); - memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); - rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen); - - if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) - *pbyNewRsr |= NEWRSR_DECRYPTOK; - - } - } else if ((byDecMode == KEY_CTL_TKIP) || - (byDecMode == KEY_CTL_CCMP)) { - /* TKIP/AES */ - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); /* 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc */ - *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); - pr_debug("ExtIV: %lx\n", *pdwRxTSC47_16); - if (byDecMode == KEY_CTL_TKIP) - *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV + 2), *pbyIV)); - else - *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV); - - pr_debug("TSC0_15: %x\n", *pwRxTSC15_0); - - if ((byDecMode == KEY_CTL_TKIP) && - (pDevice->byLocalID <= REV_ID_VT3253_A1)) { - /* - * Software TKIP - * 1. 3253 A - */ - PS802_11Header pMACHeader = (PS802_11Header)(pbyFrame); - - TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); - rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen); - if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - pr_debug("ICV OK!\n"); - } else { - pr_debug("ICV FAIL!!!\n"); - pr_debug("PayloadLen = %d\n", PayloadLen); - } - } - } - - if ((*(pbyIV+3) & 0x20) != 0) - *pbExtIV = true; - return true; -} - -static bool s_bHostWepRxEncryption( - struct vnt_private *pDevice, - unsigned char *pbyFrame, - unsigned int FrameSize, - unsigned char *pbyRsr, - bool bOnFly, - PSKeyItem pKey, - unsigned char *pbyNewRsr, - bool *pbExtIV, - unsigned short *pwRxTSC15_0, - unsigned long *pdwRxTSC47_16 -) -{ - unsigned int PayloadLen = FrameSize; - unsigned char *pbyIV; - unsigned char byKeyIdx; - unsigned char byDecMode = KEY_CTL_WEP; - PS802_11Header pMACHeader; - - *pwRxTSC15_0 = 0; - *pdwRxTSC47_16 = 0; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && - WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) { - pbyIV += 6; /* 6 is 802.11 address4 */ - PayloadLen -= 6; - } - byKeyIdx = (*(pbyIV+3) & 0xc0); - byKeyIdx >>= 6; - pr_debug("\nKeyIdx: %d\n", byKeyIdx); - - if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP) - byDecMode = KEY_CTL_TKIP; - else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP) - byDecMode = KEY_CTL_CCMP; - - pr_debug("AES:%d %d %d\n", - pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode); - - if (byDecMode != pKey->byCipherSuite) - return false; - - if (byDecMode == KEY_CTL_WEP) { - /* handle WEP */ - pr_debug("byDecMode == KEY_CTL_WEP\n"); - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || - (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true) || - !bOnFly) { - /* - * Software WEP - * 1. 3253A - * 2. WEP 256 - * 3. NotOnFly - */ - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); /* 24 is 802.11 header,4 is IV, 4 is crc */ - memcpy(pDevice->abyPRNG, pbyIV, 3); - memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); - rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen); - - if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) - *pbyNewRsr |= NEWRSR_DECRYPTOK; - - } - } else if ((byDecMode == KEY_CTL_TKIP) || - (byDecMode == KEY_CTL_CCMP)) { - /* TKIP/AES */ - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); /* 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc */ - *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); - pr_debug("ExtIV: %lx\n", *pdwRxTSC47_16); - - if (byDecMode == KEY_CTL_TKIP) - *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); - else - *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV); - - pr_debug("TSC0_15: %x\n", *pwRxTSC15_0); - - if (byDecMode == KEY_CTL_TKIP) { - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || !bOnFly) { - /* - * Software TKIP - * 1. 3253 A - * 2. NotOnFly - */ - pr_debug("soft KEY_CTL_TKIP\n"); - pMACHeader = (PS802_11Header)(pbyFrame); - TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); - rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen); - if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - pr_debug("ICV OK!\n"); - } else { - pr_debug("ICV FAIL!!!\n"); - pr_debug("PayloadLen = %d\n", - PayloadLen); - } - } - } - - if (byDecMode == KEY_CTL_CCMP) { - if (!bOnFly) { - /* - * Software CCMP - * NotOnFly - */ - pr_debug("soft KEY_CTL_CCMP\n"); - if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - pr_debug("CCMP MIC compare OK!\n"); - } else { - pr_debug("CCMP MIC fail!\n"); - } - } - } - - } - - if ((*(pbyIV+3) & 0x20) != 0) - *pbExtIV = true; - return true; -} - -static bool s_bAPModeRxData( - struct vnt_private *pDevice, - struct sk_buff *skb, - unsigned int FrameSize, - unsigned int cbHeaderOffset, - int iSANodeIndex, - int iDANodeIndex -) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - bool bRelayAndForward = false; - bool bRelayOnly = false; - unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - unsigned short wAID; - - struct sk_buff *skbcpy = NULL; - - if (FrameSize > CB_MAX_BUF_SIZE) - return false; - /* check DA */ - if (is_multicast_ether_addr((unsigned char *)(skb->data+cbHeaderOffset))) { - if (pMgmt->sNodeDBTable[0].bPSEnable) { - skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz); - - /* if any node in PS mode, buffer packet until DTIM. */ - if (skbcpy == NULL) { - pr_info("relay multicast no skb available\n"); - } else { - skbcpy->dev = pDevice->dev; - skbcpy->len = FrameSize; - memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize); - skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy); - - pMgmt->sNodeDBTable[0].wEnQueueCnt++; - /* set tx map */ - pMgmt->abyPSTxMap[0] |= byMask[0]; - } - } else { - bRelayAndForward = true; - } - } else { - /* check if relay */ - if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data+cbHeaderOffset), &iDANodeIndex)) { - if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) { - if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) { - /* queue this skb until next PS tx, and then release. */ - - skb->data += cbHeaderOffset; - skb->tail += cbHeaderOffset; - skb_put(skb, FrameSize); - skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb); - pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++; - wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID; - pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; - pr_debug("relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n", - iDANodeIndex, (wAID >> 3), - pMgmt->abyPSTxMap[wAID >> 3]); - return true; - } else { - bRelayOnly = true; - } - } - } - } - - if (bRelayOnly || bRelayAndForward) { - /* relay this packet right now */ - if (bRelayAndForward) - iDANodeIndex = 0; - - if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) - ROUTEbRelay(pDevice, (unsigned char *)(skb->data + cbHeaderOffset), FrameSize, (unsigned int)iDANodeIndex); - - if (bRelayOnly) - return false; - } - /* none associate, don't forward */ - if (pDevice->uAssocCount == 0) - return false; - - return true; -} - static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, u16 bytes_received) { diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h index dd48e4125477..ad495719a251 100644 --- a/drivers/staging/vt6655/dpc.h +++ b/drivers/staging/vt6655/dpc.h @@ -29,15 +29,7 @@ #ifndef __DPC_H__ #define __DPC_H__ -#include "ttype.h" #include "device.h" -#include "wcmd.h" - -bool -device_receive_frame( - struct vnt_private *, - PSRxDesc pCurrRD -); bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd); -- cgit v1.2.3-59-g8ed1b From 55340d6bb898ed6993ed79a79cb6f3e14dfb4aad Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:27 +0000 Subject: staging: vt6655: remove dead functions in power.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/power.c | 171 ----------------------------------------- drivers/staging/vt6655/power.h | 16 ---- drivers/staging/vt6655/wcmd.c | 2 - drivers/staging/vt6655/wmgr.c | 6 -- 4 files changed, 195 deletions(-) diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 53718026910c..040484e204e3 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -43,7 +43,6 @@ #include "wmgr.h" #include "power.h" #include "wcmd.h" -#include "rxtx.h" #include "card.h" /*--------------------- Static Definitions -------------------------*/ @@ -140,176 +139,6 @@ PSvDisablePowerSaving( pDevice->bPWBitOn = false; } -/*+ - * - * Routine Description: - * Consider to power down when no more packets to tx or rx. - * - * Return Value: - * true, if power down success - * false, if fail - -*/ - -bool -PSbConsiderPowerDown( - void *hDeviceContext, - bool bCheckRxDMA, - bool bCheckCountToWakeUp -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uIdx; - - // check if already in Doze mode - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) - return true; - - if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { - // check if in TIM wake period - if (pMgmt->bInTIMWake) - return false; - } - - // check scan state - if (pDevice->bCmdRunning) - return false; - - // Force PSEN on - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN); - - // check if all TD are empty, - for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) { - if (pDevice->iTDUsed[uIdx] != 0) - return false; - } - - // check if rx isr is clear - if (bCheckRxDMA && - ((pDevice->dwIsr & ISR_RXDMA0) != 0) && - ((pDevice->dwIsr & ISR_RXDMA1) != 0)) { - return false; - } - - if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { - if (bCheckCountToWakeUp && - (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) { - return false; - } - } - - // no Tx, no Rx isr, now go to Doze - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE); - pr_debug("Go to Doze ZZZZZZZZZZZZZZZ\n"); - return true; -} - -/*+ - * - * Routine Description: - * Send PS-POLL packet - * - * Return Value: - * None. - * - -*/ - -void -PSvSendPSPOLL( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - PSTxMgmtPacket pTxPacket = NULL; - - memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN); - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PSPOLL) | - WLAN_SET_FC_PWRMGT(0) -)); - pTxPacket->p80211Header->sA2.wDurationID = pMgmt->wCurrAID | BIT14 | BIT15; - memcpy(pTxPacket->p80211Header->sA2.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); - memcpy(pTxPacket->p80211Header->sA2.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - pTxPacket->cbMPDULen = WLAN_HDR_ADDR2_LEN; - pTxPacket->cbPayloadLen = 0; - // send the frame - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) - pr_debug("Send PS-Poll packet failed..\n"); -} - -/*+ - * - * Routine Description: - * Send NULL packet to AP for notification power state of STA - * - * Return Value: - * None. - * - -*/ -bool -PSbSendNullPacket( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSTxMgmtPacket pTxPacket = NULL; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uIdx; - - if (!pDevice->bLinkPass) - return false; - - if (!pDevice->bEnablePSMode && !pDevice->fTxDataInSleep) - return false; - - if (pDevice->bEnablePSMode) { - for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) { - if (pDevice->iTDUsed[uIdx] != 0) - return false; - } - } - - memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN); - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - - if (pDevice->bEnablePSMode) { - pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) | - WLAN_SET_FC_PWRMGT(1) -)); - } else { - pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL) | - WLAN_SET_FC_PWRMGT(0) -)); - } - - if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) - pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_TODS(1)); - - memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); - memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN; - pTxPacket->cbPayloadLen = 0; - // send the frame - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { - pr_debug("Send Null Packet failed !\n"); - return false; - } - - return true; -} /*+ * diff --git a/drivers/staging/vt6655/power.h b/drivers/staging/vt6655/power.h index 936f171a6b19..1083341b2a47 100644 --- a/drivers/staging/vt6655/power.h +++ b/drivers/staging/vt6655/power.h @@ -33,13 +33,6 @@ #define PS_FAST_INTERVAL 1 // Fast power saving listen interval #define PS_MAX_INTERVAL 4 // MAX power saving listen interval -bool -PSbConsiderPowerDown( - void *hDeviceContext, - bool bCheckRxDMA, - bool bCheckCountToWakeUp -); - void PSvDisablePowerSaving( void *hDeviceContext @@ -51,15 +44,6 @@ PSvEnablePowerSaving( unsigned short wListenInterval ); -void -PSvSendPSPOLL( - void *hDeviceContext -); - -bool -PSbSendNullPacket( - void *hDeviceContext -); bool PSbIsNextTBTTWakeUp( diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 53f81f1fefdc..33ee84f4c5a8 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -646,7 +646,6 @@ vCommandTimer( bClearBSSID_SCAN(pDevice); if (pDevice->byFOETuning) { BBvSetFOE(pDevice->PortOffset); - PSbSendNullPacket(pDevice); } if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); @@ -1009,7 +1008,6 @@ BSSvSecondTxData( if ((pDevice->bLinkPass && (pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || pDevice->fWPA_Authened) { /* wpa linking */ pDevice->fTxDataInSleep = true; - PSbSendNullPacket(pDevice); /* send null packet */ pDevice->fTxDataInSleep = false; } diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index a1bada1173f3..72906b0d1d45 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -2025,19 +2025,13 @@ s_vMgrRxBeacon( pMgmt->bInTIMWake = true; // send out ps-poll packet - if (pMgmt->bInTIM) - PSvSendPSPOLL(pDevice); } else { pMgmt->bInTIMWake = false; pr_debug("BCN: Not In TIM..\n"); if (!pDevice->bPWBitOn) { pr_debug("BCN: Send Null Packet\n"); - if (PSbSendNullPacket(pDevice)) - pDevice->bPWBitOn = true; } - if (PSbConsiderPowerDown(pDevice, false, false)) - pr_debug("BCN: Power down now...\n"); } } -- cgit v1.2.3-59-g8ed1b From 185cb4e6ced612a987cd7e5995339271d885cdfe Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:28 +0000 Subject: staging: vt6655: dead code remove wmgr.c Remove all functions Header will be deleted later Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/bssdb.c | 1 - drivers/staging/vt6655/wcmd.c | 60 - drivers/staging/vt6655/wmgr.c | 4597 --------------------------------------- drivers/staging/vt6655/wmgr.h | 103 - 5 files changed, 4762 deletions(-) delete mode 100644 drivers/staging/vt6655/wmgr.c diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 2cad0d09cdd0..fa154ef10edc 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -10,7 +10,6 @@ vt6655_stage-y += device_main.o \ wctl.o \ 80211mgr.o \ wcmd.o \ - wmgr.o \ bssdb.o \ rxtx.o \ dpc.o \ diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 996d3302ce3d..2b508ff5f492 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -443,7 +443,6 @@ BSSbInsertToBSSList( } if (bIs802_1x && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) && (!memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) { - bAdd_PMKID_Candidate((void *)pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj); if (pDevice->bLinkPass && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { if (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) || diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 33ee84f4c5a8..3c980806a515 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -244,37 +244,10 @@ s_MgrMakeProbeRequest( ) { PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_PROBEREQ sFrame; pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN); pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_PROBEREQ_FR_MAXLEN; - vMgrEncodeProbeRequest(&sFrame); - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN); - // Copy the SSID, pSSID->len=0 indicate broadcast SSID - sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); - sFrame.len += pSSID->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); - // Copy the extension rate set - if (pDevice->eCurrentPHYType == PHY_TYPE_11G) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN); - } - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; return pTxPacket; } @@ -304,7 +277,6 @@ vCommandTimer( PSMgmtObject pMgmt = pDevice->pMgmt; PWLAN_IE_SSID pItemSSID; PWLAN_IE_SSID pItemSSIDCurr; - CMD_STATUS Status; unsigned int ii; unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; struct sk_buff *skb; @@ -456,7 +428,6 @@ vCommandTimer( } else { pr_debug("Send Disassociation Packet..\n"); // reason = 8 : disassoc because sta has left - vMgrDisassocBeginSta((void *)pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status); pDevice->bLinkPass = false; // unlock command busy pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; @@ -530,24 +501,12 @@ vCommandTimer( PSvDisablePowerSaving((void *)pDevice); BSSvClearNodeDBTable(pDevice, 0); - vMgrJoinBSSBegin((void *)pDevice, &Status); // if Infra mode if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) { // Call mgr to begin the deauthentication // reason = (3) because sta has left ESS - if (pMgmt->eCurrState >= WMAC_STATE_AUTH) - vMgrDeAuthenBeginSta((void *)pDevice, pMgmt, pMgmt->abyCurrBSSID, (3), &Status); // Call mgr to begin the authentication - vMgrAuthenBeginSta((void *)pDevice, pMgmt, &Status); - if (Status == CMD_STATUS_SUCCESS) { - pDevice->byLinkWaitCount = 0; - pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT; - vCommandTimerWait((void *)pDevice, AUTHENTICATE_TIMEOUT); - spin_unlock_irq(&pDevice->lock); - pr_debug(" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n"); - return; - } } // if Adhoc mode else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { @@ -562,9 +521,6 @@ vCommandTimer( bClearBSSID_SCAN(pDevice); } else { // start own IBSS - vMgrCreateOwnIBSS((void *)pDevice, &Status); - if (Status != CMD_STATUS_SUCCESS) - pr_debug(" WLAN_CMD_IBSS_CREATE fail !\n"); BSSvAddMulticastNode(pDevice); } @@ -574,9 +530,6 @@ vCommandTimer( if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA || pMgmt->eConfigMode == WMAC_CONFIG_AUTO) { // start own IBSS - vMgrCreateOwnIBSS((void *)pDevice, &Status); - if (Status != CMD_STATUS_SUCCESS) - pr_debug(" WLAN_CMD_IBSS_CREATE fail !\n"); BSSvAddMulticastNode(pDevice); if (netif_queue_stopped(pDevice->dev)) @@ -607,15 +560,6 @@ vCommandTimer( // Call mgr to begin the association pDevice->byLinkWaitCount = 0; pr_debug("eCurrState == WMAC_STATE_AUTH\n"); - vMgrAssocBeginSta((void *)pDevice, pMgmt, &Status); - if (Status == CMD_STATUS_SUCCESS) { - pDevice->byLinkWaitCount = 0; - pr_debug("eCommandState = WLAN_ASSOCIATE_WAIT\n"); - pDevice->eCommandState = WLAN_ASSOCIATE_WAIT; - vCommandTimerWait((void *)pDevice, ASSOCIATE_TIMEOUT); - spin_unlock_irq(&pDevice->lock); - return; - } } else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) { @@ -694,10 +638,6 @@ vCommandTimer( pMgmt->eCurrState = WMAC_STATE_IDLE; pDevice->bFixRate = false; - vMgrCreateOwnIBSS((void *)pDevice, &Status); - if (Status != CMD_STATUS_SUCCESS) - pr_debug(" vMgrCreateOwnIBSS fail !\n"); - // alway turn off unicast bit MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST); pDevice->byRxMode &= ~RCR_UNICAST; diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c deleted file mode 100644 index 72906b0d1d45..000000000000 --- a/drivers/staging/vt6655/wmgr.c +++ /dev/null @@ -1,4597 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wmgr.c - * - * Purpose: Handles the 802.11 management functions - * - * Author: Lyndon Chen - * - * Date: May 8, 2002 - * - * Functions: - * nsMgrObjectInitial - Initialize Management Object data structure - * vMgrObjectReset - Reset Management Object data structure - * vMgrAssocBeginSta - Start associate function - * vMgrReAssocBeginSta - Start reassociate function - * vMgrDisassocBeginSta - Start disassociate function - * s_vMgrRxAssocRequest - Handle Rcv associate_request - * s_vMgrRxAssocResponse - Handle Rcv associate_response - * vMrgAuthenBeginSta - Start authentication function - * vMgrDeAuthenDeginSta - Start deauthentication function - * s_vMgrRxAuthentication - Handle Rcv authentication - * s_vMgrRxAuthenSequence_1 - Handle Rcv authentication sequence 1 - * s_vMgrRxAuthenSequence_2 - Handle Rcv authentication sequence 2 - * s_vMgrRxAuthenSequence_3 - Handle Rcv authentication sequence 3 - * s_vMgrRxAuthenSequence_4 - Handle Rcv authentication sequence 4 - * s_vMgrRxDisassociation - Handle Rcv disassociation - * s_vMgrRxBeacon - Handle Rcv Beacon - * vMgrCreateOwnIBSS - Create ad_hoc IBSS or AP BSS - * vMgrJoinBSSBegin - Join BSS function - * s_vMgrSynchBSS - Synch & adopt BSS parameters - * s_MgrMakeBeacon - Create Baecon frame - * s_MgrMakeProbeResponse - Create Probe Response frame - * s_MgrMakeAssocRequest - Create Associate Request frame - * s_MgrMakeReAssocRequest - Create ReAssociate Request frame - * s_vMgrRxProbeResponse - Handle Rcv probe_response - * s_vMrgRxProbeRequest - Handle Rcv probe_request - * bMgrPrepareBeaconToSend - Prepare Beacon frame - * s_vMgrLogStatus - Log 802.11 Status - * vMgrRxManagePacket - Rcv management frame dispatch function - * s_vMgrFormatTIM- Assembler TIM field of beacon - * vMgrTimerInit- Initial 1-sec and command call back funtions - * - * Revision History: - * - */ - -#include "tmacro.h" -#include "desc.h" -#include "device.h" -#include "card.h" -#include "channel.h" -#include "80211hdr.h" -#include "80211mgr.h" -#include "wmgr.h" -#include "wcmd.h" -#include "mac.h" -#include "bssdb.h" -#include "power.h" -#include "datarate.h" -#include "baseband.h" -#include "rxtx.h" -#include "wpa.h" -#include "rf.h" -#include "iowpa.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ -//2008-8-4 by chester -static bool ChannelExceedZoneType( - struct vnt_private *pDevice, - unsigned char byCurrChannel -); - -// Association/diassociation functions -static -PSTxMgmtPacket -s_MgrMakeAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned char *pDAddr, - unsigned short wCurrCapInfo, - unsigned short wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -); - -static -void -s_vMgrRxAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - unsigned int uNodeIndex -); - -static -PSTxMgmtPacket -s_MgrMakeReAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned char *pDAddr, - unsigned short wCurrCapInfo, - unsigned short wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -); - -static -void -s_vMgrRxAssocResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - bool bReAssocType -); - -static -void -s_vMgrRxDisassociation( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -); - -// Authentication/deauthen functions -static -void -s_vMgrRxAuthenSequence_1( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -); - -static -void -s_vMgrRxAuthenSequence_2( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -); - -static -void -s_vMgrRxAuthenSequence_3( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -); - -static -void -s_vMgrRxAuthenSequence_4( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -); - -static -void -s_vMgrRxAuthentication( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -); - -static -void -s_vMgrRxDeauthentication( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -); - -// Scan functions -// probe request/response functions -static -void -s_vMgrRxProbeRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -); - -static -void -s_vMgrRxProbeResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -); - -// beacon functions -static -void -s_vMgrRxBeacon( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - bool bInScan -); - -static -void -s_vMgrFormatTIM( - PSMgmtObject pMgmt, - PWLAN_IE_TIM pTIM -); - -static -PSTxMgmtPacket -s_MgrMakeBeacon( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wCurrBeaconPeriod, - unsigned int uCurrChannel, - unsigned short wCurrATIMWinodw, - PWLAN_IE_SSID pCurrSSID, - unsigned char *pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -); - -// Association response -static -PSTxMgmtPacket -s_MgrMakeAssocResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wAssocStatus, - unsigned short wAssocAID, - unsigned char *pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -); - -// ReAssociation response -static -PSTxMgmtPacket -s_MgrMakeReAssocResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wAssocStatus, - unsigned short wAssocAID, - unsigned char *pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -); - -// Probe response -static -PSTxMgmtPacket -s_MgrMakeProbeResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wCurrBeaconPeriod, - unsigned int uCurrChannel, - unsigned short wCurrATIMWinodw, - unsigned char *pDstAddr, - PWLAN_IE_SSID pCurrSSID, - unsigned char *pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates, - unsigned char byPHYType -); - -// received status -static -void -s_vMgrLogStatus( - PSMgmtObject pMgmt, - unsigned short wStatus -); - -static -void -s_vMgrSynchBSS( - struct vnt_private *pDevice, - unsigned int uBSSMode, - PKnownBSS pCurr, - PCMD_STATUS pStatus -); - -static bool -s_bCipherMatch( - PKnownBSS pBSSNode, - NDIS_802_11_ENCRYPTION_STATUS EncStatus, - unsigned char *pbyCCSPK, - unsigned char *pbyCCSGK -); - -static void Encyption_Rebuild( - struct vnt_private *pDevice, - PKnownBSS pCurr -); - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/*+ - * - * Routine Description: - * Allocates and initializes the Management object. - * - * Return Value: - * Ndis_staus. - * - -*/ - -void -vMgrObjectInit( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - int ii; - - pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0]; - pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0]; - pMgmt->uCurrChannel = pDevice->uChannel; - for (ii = 0; ii < WLAN_BSSID_LEN; ii++) - pMgmt->abyDesireBSSID[ii] = 0xFF; - - pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); - pMgmt->byCSSPK = KEY_CTL_NONE; - pMgmt->byCSSGK = KEY_CTL_NONE; - pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI; - BSSvClearBSSList((void *)pDevice, false); -} - -/*+ - * - * Routine Description: - * Initializes timer object - * - * Return Value: - * Ndis_staus. - * - -*/ - -void -vMgrTimerInit( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - - init_timer(&pMgmt->sTimerSecondCallback); - pMgmt->sTimerSecondCallback.data = (unsigned long) pDevice; - pMgmt->sTimerSecondCallback.function = (TimerFunction)BSSvSecondCallBack; - pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ); - - init_timer(&pDevice->sTimerCommand); - pDevice->sTimerCommand.data = (unsigned long) pDevice; - pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; - pDevice->sTimerCommand.expires = RUN_AT(HZ); - - init_timer(&pDevice->sTimerTxData); - pDevice->sTimerTxData.data = (unsigned long) pDevice; - pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; - pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback - pDevice->fTxDataInSleep = false; - pDevice->IsTxDataTrigger = false; - pDevice->nTxDataTimeCout = 0; - - pDevice->cbFreeCmdQueue = CMD_Q_SIZE; - pDevice->uCmdDequeueIdx = 0; - pDevice->uCmdEnqueueIdx = 0; -} - -/*+ - * - * Routine Description: - * Reset the management object structure. - * - * Return Value: - * None. - * - -*/ - -void -vMgrObjectReset( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - - pMgmt->eCurrMode = WMAC_MODE_STANDBY; - pMgmt->eCurrState = WMAC_STATE_IDLE; - pDevice->bEnablePSMode = false; - // TODO: timer -} - -/*+ - * - * Routine Description: - * Start the station association procedure. Namely, send an - * association request frame to the AP. - * - * Return Value: - * None. - * - -*/ - -void -vMgrAssocBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSTxMgmtPacket pTxPacket; - - pMgmt->wCurrCapInfo = 0; - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); - if (pDevice->bEncryptionEnable) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (pMgmt->wListenInterval == 0) - pMgmt->wListenInterval = 1; // at least one. - - // ERP Phy (802.11g) should support short preamble. - if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (CARDbIsShorSlotTime(pMgmt->pAdapter)) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); - } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { - if (CARDbIsShortPreamble(pMgmt->pAdapter)) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - } - if (pMgmt->b11hEnable) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); - - /* build an assocreq frame and send it */ - pTxPacket = s_MgrMakeAssocRequest - ( - pDevice, - pMgmt, - pMgmt->abyCurrBSSID, - pMgmt->wCurrCapInfo, - pMgmt->wListenInterval, - (PWLAN_IE_SSID)pMgmt->abyCurrSSID, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates -); - - if (pTxPacket != NULL) { - /* send the frame */ - *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus == CMD_STATUS_PENDING) { - pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING; - *pStatus = CMD_STATUS_SUCCESS; - } - } else { - *pStatus = CMD_STATUS_RESOURCES; - } -} - -/*+ - * - * Routine Description: - * Start the station re-association procedure. - * - * Return Value: - * None. - * - -*/ - -void -vMgrReAssocBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSTxMgmtPacket pTxPacket; - - pMgmt->wCurrCapInfo = 0; - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); - if (pDevice->bEncryptionEnable) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - - if (pMgmt->wListenInterval == 0) - pMgmt->wListenInterval = 1; // at least one. - - // ERP Phy (802.11g) should support short preamble. - if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (CARDbIsShorSlotTime(pMgmt->pAdapter)) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); - } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { - if (CARDbIsShortPreamble(pMgmt->pAdapter)) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - } - - if (pMgmt->b11hEnable) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); - - pTxPacket = s_MgrMakeReAssocRequest - ( - pDevice, - pMgmt, - pMgmt->abyCurrBSSID, - pMgmt->wCurrCapInfo, - pMgmt->wListenInterval, - (PWLAN_IE_SSID)pMgmt->abyCurrSSID, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates -); - - if (pTxPacket != NULL) { - /* send the frame */ - *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus != CMD_STATUS_PENDING) - pr_debug("Mgt:Reassociation tx failed\n"); - else - pr_debug("Mgt:Reassociation tx sending\n"); - } -} - -/*+ - * - * Routine Description: - * Send an dis-association request frame to the AP. - * - * Return Value: - * None. - * - -*/ - -void -vMgrDisassocBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - unsigned char *abyDestAddress, - unsigned short wReason, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_DISASSOC sFrame; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - - // Setup the sFrame structure - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_DISASSOC_FR_MAXLEN; - - // format fixed field frame structure - vMgrEncodeDisassociation(&sFrame); - - // Setup the header - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC) -)); - - memcpy(sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - // Set reason code - *(sFrame.pwReason) = cpu_to_le16(wReason); - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - // send the frame - *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus == CMD_STATUS_PENDING) { - pMgmt->eCurrState = WMAC_STATE_IDLE; - *pStatus = CMD_STATUS_SUCCESS; - } -} - -/*+ - * - * Routine Description:(AP function) - * Handle incoming station association request frames. - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - unsigned int uNodeIndex -) -{ - WLAN_FR_ASSOCREQ sFrame; - CMD_STATUS Status; - PSTxMgmtPacket pTxPacket; - unsigned short wAssocStatus = 0; - unsigned short wAssocAID = 0; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - - if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) - return; - // node index not found - if (!uNodeIndex) - return; - - //check if node is authenticated - //decode the frame - memset(&sFrame, 0, sizeof(WLAN_FR_ASSOCREQ)); - memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - - vMgrDecodeAssocRequest(&sFrame); - - if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) { - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; - pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval); - pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = - WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; - // Todo: check sta basic rate, if ap can't support, set status code - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) - uRateLen = WLAN_RATES_MAXLEN_11B; - - abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; - abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, - (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, - uRateLen); - abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; - if (pDevice->eCurrentPHYType == PHY_TYPE_11G) - abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates, - (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, - uRateLen); - else - abyCurrExtSuppRates[1] = 0; - - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, - false, // do not change our basic rate - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) -); - - // set max tx rate - pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; - - pr_debug("RxAssocRequest:wTxDataRate is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate); - - // Todo: check sta preamble, if ap can't support, set status code - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = - WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = - WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].wAID = (unsigned short)uNodeIndex; - wAssocStatus = WLAN_MGMT_STATUS_SUCCESS; - wAssocAID = (unsigned short)uNodeIndex; - // check if ERP support - if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) - pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; - - if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) { - // B only STA join - pDevice->bProtectMode = true; - pDevice->bNonERPPresent = true; - } - if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) - pDevice->bBarkerPreambleMd = true; - - pr_info("Associate AID= %d\n", wAssocAID); - pr_info("MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - sFrame.pHdr->sA3.abyAddr2[0], - sFrame.pHdr->sA3.abyAddr2[1], - sFrame.pHdr->sA3.abyAddr2[2], - sFrame.pHdr->sA3.abyAddr2[3], - sFrame.pHdr->sA3.abyAddr2[4], - sFrame.pHdr->sA3.abyAddr2[5] - ); - pr_info("Max Support rate = %d\n", - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); - } else { - /* TODO: received STA under state1 handle */ - return; - } - - // assoc response reply.. - pTxPacket = s_MgrMakeAssocResponse - ( - pDevice, - pMgmt, - pMgmt->wCurrCapInfo, - wAssocStatus, - wAssocAID, - sFrame.pHdr->sA3.abyAddr2, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates -); - if (pTxPacket != NULL) { - if (pDevice->bEnableHostapd) - return; - - /* send the frame */ - Status = csMgmt_xmit(pDevice, pTxPacket); - if (Status != CMD_STATUS_PENDING) - pr_debug("Mgt:Assoc response tx failed\n"); - else - pr_debug("Mgt:Assoc response tx sending..\n"); - } -} - -/*+ - * - * Description:(AP function) - * Handle incoming station re-association request frames. - * - * Parameters: - * In: - * pMgmt - Management Object structure - * pRxPacket - Received Packet - * Out: - * none - * - * Return Value: None. - * - -*/ - -static -void -s_vMgrRxReAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - unsigned int uNodeIndex -) -{ - WLAN_FR_REASSOCREQ sFrame; - CMD_STATUS Status; - PSTxMgmtPacket pTxPacket; - unsigned short wAssocStatus = 0; - unsigned short wAssocAID = 0; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - - if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) - return; - // node index not found - if (!uNodeIndex) - return; - //check if node is authenticated - //decode the frame - memset(&sFrame, 0, sizeof(WLAN_FR_REASSOCREQ)); - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - vMgrDecodeReassocRequest(&sFrame); - - if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) { - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; - pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval); - pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = - WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; - // Todo: check sta basic rate, if ap can't support, set status code - - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) - uRateLen = WLAN_RATES_MAXLEN_11B; - - abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; - abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, - (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, - uRateLen); - abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; - if (pDevice->eCurrentPHYType == PHY_TYPE_11G) { - abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates, - (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, - uRateLen); - } else { - abyCurrExtSuppRates[1] = 0; - } - - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, - false, // do not change our basic rate - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) -); - - // set max tx rate - pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; - - pr_debug("RxReAssocRequest:TxDataRate is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate); - - // Todo: check sta preamble, if ap can't support, set status code - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = - WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = - WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].wAID = (unsigned short)uNodeIndex; - wAssocStatus = WLAN_MGMT_STATUS_SUCCESS; - wAssocAID = (unsigned short)uNodeIndex; - - // if suppurt ERP - if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) - pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; - - if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) { - // B only STA join - pDevice->bProtectMode = true; - pDevice->bNonERPPresent = true; - } - if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) - pDevice->bBarkerPreambleMd = true; - - pr_info("Rx ReAssociate AID= %d\n", wAssocAID); - pr_info("MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - sFrame.pHdr->sA3.abyAddr2[0], - sFrame.pHdr->sA3.abyAddr2[1], - sFrame.pHdr->sA3.abyAddr2[2], - sFrame.pHdr->sA3.abyAddr2[3], - sFrame.pHdr->sA3.abyAddr2[4], - sFrame.pHdr->sA3.abyAddr2[5] - ); - pr_info("Max Support rate = %d\n", - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); - - } - - // assoc response reply.. - pTxPacket = s_MgrMakeReAssocResponse - ( - pDevice, - pMgmt, - pMgmt->wCurrCapInfo, - wAssocStatus, - wAssocAID, - sFrame.pHdr->sA3.abyAddr2, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates - ); - - if (pTxPacket != NULL) { - /* send the frame */ - if (pDevice->bEnableHostapd) - return; - - Status = csMgmt_xmit(pDevice, pTxPacket); - if (Status != CMD_STATUS_PENDING) - pr_debug("Mgt:ReAssoc response tx failed\n"); - else - pr_debug("Mgt:ReAssoc response tx sending..\n"); - } -} - -/*+ - * - * Routine Description: - * Handle incoming association response frames. - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxAssocResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - bool bReAssocType -) -{ - WLAN_FR_ASSOCRESP sFrame; - PWLAN_IE_SSID pItemSSID; - unsigned char *pbyIEs; - viawget_wpa_header *wpahdr; - - if (pMgmt->eCurrState == WMAC_STATE_ASSOCPENDING || - pMgmt->eCurrState == WMAC_STATE_ASSOC) { - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - // decode the frame - vMgrDecodeAssocResponse(&sFrame); - if ((sFrame.pwCapInfo == NULL) || - (sFrame.pwStatus == NULL) || - (sFrame.pwAid == NULL) || - (sFrame.pSuppRates == NULL)) { - DBG_PORT80(0xCC); - return; - } - - pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo); - pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus); - pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.AssociationId = *(sFrame.pwAid); - pMgmt->sAssocInfo.AssocInfo.AvailableResponseFixedIEs |= 0x07; - - pMgmt->sAssocInfo.AssocInfo.ResponseIELength = sFrame.len - 24 - 6; - pMgmt->sAssocInfo.AssocInfo.OffsetResponseIEs = pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs + pMgmt->sAssocInfo.AssocInfo.RequestIELength; - pbyIEs = pMgmt->sAssocInfo.abyIEs; - pbyIEs += pMgmt->sAssocInfo.AssocInfo.RequestIELength; - memcpy(pbyIEs, (sFrame.pBuf + 24 + 6), pMgmt->sAssocInfo.AssocInfo.ResponseIELength); - - // save values and set current BSS state - if (cpu_to_le16((*(sFrame.pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { - // set AID - pMgmt->wCurrAID = cpu_to_le16((*(sFrame.pwAid))); - if ((pMgmt->wCurrAID >> 14) != (BIT0 | BIT1)) - pr_debug("AID from AP, has two msb clear\n"); - - pr_info("Association Successful, AID=%d\n", - pMgmt->wCurrAID & ~(BIT14 | BIT15)); - pMgmt->eCurrState = WMAC_STATE_ASSOC; - BSSvUpdateAPNode((void *)pDevice, sFrame.pwCapInfo, sFrame.pSuppRates, sFrame.pExtSuppRates); - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - pr_info("Link with AP(SSID): %s\n", pItemSSID->abySSID); - pDevice->bLinkPass = true; - pDevice->uBBVGADiffCount = 0; - if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) { - if (skb_tailroom(pDevice->skb) < (sizeof(viawget_wpa_header) + pMgmt->sAssocInfo.AssocInfo.ResponseIELength + - pMgmt->sAssocInfo.AssocInfo.RequestIELength)) { //data room not enough - dev_kfree_skb(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - } - wpahdr = (viawget_wpa_header *)pDevice->skb->data; - wpahdr->type = VIAWGET_ASSOC_MSG; - wpahdr->resp_ie_len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength; - wpahdr->req_ie_len = pMgmt->sAssocInfo.AssocInfo.RequestIELength; - memcpy(pDevice->skb->data + sizeof(viawget_wpa_header), pMgmt->sAssocInfo.abyIEs, wpahdr->req_ie_len); - memcpy(pDevice->skb->data + sizeof(viawget_wpa_header) + wpahdr->req_ie_len, - pbyIEs, - wpahdr->resp_ie_len -); - skb_put(pDevice->skb, sizeof(viawget_wpa_header) + wpahdr->resp_ie_len + wpahdr->req_ie_len); - pDevice->skb->dev = pDevice->wpadev; - skb_reset_mac_header(pDevice->skb); - pDevice->skb->pkt_type = PACKET_HOST; - pDevice->skb->protocol = htons(ETH_P_802_2); - memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); - netif_rx(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - } - -//2008-0409-07, by Einsn Liu -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - { - unsigned char buf[512]; - size_t len; - union iwreq_data wrqu; - int we_event; - - memset(buf, 0, 512); - - len = pMgmt->sAssocInfo.AssocInfo.RequestIELength; - if (len) { - memcpy(buf, pMgmt->sAssocInfo.abyIEs, len); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = len; - we_event = IWEVASSOCREQIE; - wireless_send_event(pDevice->dev, we_event, &wrqu, buf); - } - - memset(buf, 0, 512); - len = pMgmt->sAssocInfo.AssocInfo.ResponseIELength; - - if (len) { - memcpy(buf, pbyIEs, len); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = len; - we_event = IWEVASSOCRESPIE; - wireless_send_event(pDevice->dev, we_event, &wrqu, buf); - } - - memset(&wrqu, 0, sizeof(wrqu)); - ether_addr_copy(wrqu.ap_addr.sa_data, - &pMgmt->abyCurrBSSID[0]); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } -#endif //#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -//End Add -- //2008-0409-07, by Einsn Liu - } else { - if (bReAssocType) { - pMgmt->eCurrState = WMAC_STATE_IDLE; - } else { - // jump back to the auth state and indicate the error - pMgmt->eCurrState = WMAC_STATE_AUTH; - } - s_vMgrLogStatus(pMgmt, cpu_to_le16((*(sFrame.pwStatus)))); - } - - } - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -//need clear flags related to Networkmanager - - pDevice->bwextcount = 0; - pDevice->bWPASuppWextEnabled = false; -#endif - - if (pMgmt->eCurrState == WMAC_STATE_ASSOC) - timer_expire(pDevice->sTimerCommand, 0); -} - -/*+ - * - * Routine Description: - * Start the station authentication procedure. Namely, send an - * authentication frame to the AP. - * - * Return Value: - * None. - * - -*/ - -void -vMgrAuthenBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - WLAN_FR_AUTHEN sFrame; - PSTxMgmtPacket pTxPacket = NULL; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_AUTHEN_FR_MAXLEN; - vMgrEncodeAuthen(&sFrame); - /* insert values */ - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - if (pMgmt->bShareKeyAlgorithm) - *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_SHAREDKEY); - else - *(sFrame.pwAuthAlgorithm) = cpu_to_le16(WLAN_AUTH_ALG_OPENSYSTEM); - - *(sFrame.pwAuthSequence) = cpu_to_le16(1); - /* Adjust the length fields */ - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus == CMD_STATUS_PENDING) { - pMgmt->eCurrState = WMAC_STATE_AUTHPENDING; - *pStatus = CMD_STATUS_SUCCESS; - } -} - -/*+ - * - * Routine Description: - * Start the station(AP) deauthentication procedure. Namely, send an - * deauthentication frame to the AP or Sta. - * - * Return Value: - * None. - * - -*/ - -void -vMgrDeAuthenBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - unsigned char *abyDestAddress, - unsigned short wReason, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - WLAN_FR_DEAUTHEN sFrame; - PSTxMgmtPacket pTxPacket = NULL; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DEAUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN; - vMgrEncodeDeauthen(&sFrame); - /* insert values */ - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DEAUTHEN) -)); - - memcpy(sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - *(sFrame.pwReason) = cpu_to_le16(wReason); // deauthen. bcs left BSS - /* Adjust the length fields */ - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus == CMD_STATUS_PENDING) - *pStatus = CMD_STATUS_SUCCESS; -} - -/*+ - * - * Routine Description: - * Handle incoming authentication frames. - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxAuthentication( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -) -{ - WLAN_FR_AUTHEN sFrame; - - // we better be an AP or a STA in AUTHPENDING otherwise ignore - if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP || - pMgmt->eCurrState == WMAC_STATE_AUTHPENDING)) { - return; - } - - // decode the frame - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - vMgrDecodeAuthen(&sFrame); - switch (cpu_to_le16((*(sFrame.pwAuthSequence)))) { - case 1: - //AP function - s_vMgrRxAuthenSequence_1(pDevice, pMgmt, &sFrame); - break; - case 2: - s_vMgrRxAuthenSequence_2(pDevice, pMgmt, &sFrame); - break; - case 3: - //AP function - s_vMgrRxAuthenSequence_3(pDevice, pMgmt, &sFrame); - break; - case 4: - s_vMgrRxAuthenSequence_4(pDevice, pMgmt, &sFrame); - break; - default: - pr_debug("Auth Sequence error, seq = %d\n", - cpu_to_le16((*(sFrame.pwAuthSequence)))); - break; - } -} - -/*+ - * - * Routine Description: - * Handles incoming authen frames with sequence 1. Currently - * assumes we're an AP. So far, no one appears to use authentication - * in Ad-Hoc mode. - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxAuthenSequence_1( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -) -{ - PSTxMgmtPacket pTxPacket = NULL; - unsigned int uNodeIndex; - WLAN_FR_AUTHEN sFrame; - PSKeyItem pTransmitKey; - - // Insert a Node entry - if (!BSSDBbIsSTAInNodeDB(pMgmt, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) { - BSSvCreateOneNode(pDevice, &uNodeIndex); - memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, pFrame->pHdr->sA3.abyAddr2, - WLAN_ADDR_LEN); - } - - if (pMgmt->bShareKeyAlgorithm) { - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_KNOWN; - pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 1; - } else { - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH; - } - - // send auth reply - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_AUTHEN_FR_MAXLEN; - // format buffer structure - vMgrEncodeAuthen(&sFrame); - // insert values - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)| - WLAN_SET_FC_ISWEP(0) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm); - *(sFrame.pwAuthSequence) = cpu_to_le16(2); - - if (cpu_to_le16(*(pFrame->pwAuthAlgorithm)) == WLAN_AUTH_ALG_SHAREDKEY) { - if (pMgmt->bShareKeyAlgorithm) - *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS); - else - *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG); - } else { - if (pMgmt->bShareKeyAlgorithm) - *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG); - else - *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS); - } - - if (pMgmt->bShareKeyAlgorithm && - (cpu_to_le16(*(sFrame.pwStatus)) == WLAN_MGMT_STATUS_SUCCESS)) { - sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len); - sFrame.len += WLAN_CHALLENGE_IE_LEN; - sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE; - sFrame.pChallenge->len = WLAN_CHALLENGE_LEN; - memset(pMgmt->abyChallenge, 0, WLAN_CHALLENGE_LEN); - // get group key - if (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, GROUP_KEY, &pTransmitKey) == true) { - rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength+3); - rc4_encrypt(&pDevice->SBox, pMgmt->abyChallenge, pMgmt->abyChallenge, WLAN_CHALLENGE_LEN); - } - memcpy(sFrame.pChallenge->abyChallenge, pMgmt->abyChallenge , WLAN_CHALLENGE_LEN); - } - - /* Adjust the length fields */ - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - // send the frame - if (pDevice->bEnableHostapd) - return; - - pr_debug("Mgt:Authreq_reply sequence_1 tx..\n"); - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) - pr_debug("Mgt:Authreq_reply sequence_1 tx failed\n"); -} - -/*+ - * - * Routine Description: - * Handles incoming auth frames with sequence number 2. Currently - * assumes we're a station. - * - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxAuthenSequence_2( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -) -{ - WLAN_FR_AUTHEN sFrame; - PSTxMgmtPacket pTxPacket = NULL; - - switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm)))) { - case WLAN_AUTH_ALG_OPENSYSTEM: - if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { - pr_info("802.11 Authen (OPEN) Successful\n"); - pMgmt->eCurrState = WMAC_STATE_AUTH; - timer_expire(pDevice->sTimerCommand, 0); - } else { - pr_info("802.11 Authen (OPEN) Failed\n"); - s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); - pMgmt->eCurrState = WMAC_STATE_IDLE; - } - - break; - - case WLAN_AUTH_ALG_SHAREDKEY: - - if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_AUTHEN_FR_MAXLEN; - // format buffer structure - vMgrEncodeAuthen(&sFrame); - // insert values - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)| - WLAN_SET_FC_ISWEP(1) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm); - *(sFrame.pwAuthSequence) = cpu_to_le16(3); - *(sFrame.pwStatus) = cpu_to_le16(WLAN_MGMT_STATUS_SUCCESS); - sFrame.pChallenge = (PWLAN_IE_CHALLENGE)(sFrame.pBuf + sFrame.len); - sFrame.len += WLAN_CHALLENGE_IE_LEN; - sFrame.pChallenge->byElementID = WLAN_EID_CHALLENGE; - sFrame.pChallenge->len = WLAN_CHALLENGE_LEN; - memcpy(sFrame.pChallenge->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN); - // Adjust the length fields - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - // send the frame - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) - pr_debug("Mgt:Auth_reply sequence_2 tx failed\n"); - - pr_debug("Mgt:Auth_reply sequence_2 tx ...\n"); - } else { - pr_debug("Mgt:rx Auth_reply sequence_2 status error ...\n"); - s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); - } - break; - default: - pr_debug("Mgt: rx auth.seq = 2 unknown AuthAlgorithm=%d\n", - cpu_to_le16((*(pFrame->pwAuthAlgorithm)))); - break; - } -} - -/*+ - * - * Routine Description: - * Handles incoming authen frames with sequence 3. Currently - * assumes we're an AP. This function assumes the frame has - * already been successfully decrypted. - * - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxAuthenSequence_3( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -) -{ - PSTxMgmtPacket pTxPacket = NULL; - unsigned int uStatusCode = 0; - unsigned int uNodeIndex = 0; - WLAN_FR_AUTHEN sFrame; - - if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) { - uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL; - goto reply; - } - if (BSSDBbIsSTAInNodeDB(pMgmt, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) { - if (pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence != 1) { - uStatusCode = WLAN_MGMT_STATUS_RX_AUTH_NOSEQ; - goto reply; - } - if (memcmp(pMgmt->abyChallenge, pFrame->pChallenge->abyChallenge, WLAN_CHALLENGE_LEN) != 0) { - uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL; - goto reply; - } - } else { - uStatusCode = WLAN_MGMT_STATUS_UNSPEC_FAILURE; - goto reply; - } - - if (uNodeIndex) { - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_AUTH; - pMgmt->sNodeDBTable[uNodeIndex].byAuthSequence = 0; - } - uStatusCode = WLAN_MGMT_STATUS_SUCCESS; - pr_debug("Challenge text check ok..\n"); - -reply: - // send auth reply - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_AUTHEN_FR_MAXLEN; - // format buffer structure - vMgrEncodeAuthen(&sFrame); - /* insert values */ - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_AUTHEN)| - WLAN_SET_FC_ISWEP(0) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pFrame->pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - *(sFrame.pwAuthAlgorithm) = *(pFrame->pwAuthAlgorithm); - *(sFrame.pwAuthSequence) = cpu_to_le16(4); - *(sFrame.pwStatus) = cpu_to_le16(uStatusCode); - - /* Adjust the length fields */ - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - // send the frame - if (pDevice->bEnableHostapd) - return; - - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) - pr_debug("Mgt:Authreq_reply sequence_4 tx failed\n"); -} - -/*+ - * - * Routine Description: - * Handles incoming authen frames with sequence 4 - * - * - * Return Value: - * None. - * - -*/ -static -void -s_vMgrRxAuthenSequence_4( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PWLAN_FR_AUTHEN pFrame -) -{ - if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { - pr_info("802.11 Authen (SHAREDKEY) Successful\n"); - pMgmt->eCurrState = WMAC_STATE_AUTH; - timer_expire(pDevice->sTimerCommand, 0); - } else{ - pr_info("802.11 Authen (SHAREDKEY) Failed\n"); - s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); - pMgmt->eCurrState = WMAC_STATE_IDLE; - } -} - -/*+ - * - * Routine Description: - * Handles incoming disassociation frames - * - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxDisassociation( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -) -{ - WLAN_FR_DISASSOC sFrame; - unsigned int uNodeIndex = 0; - viawget_wpa_header *wpahdr; - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - // if is acting an AP.. - // a STA is leaving this BSS.. - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) - BSSvRemoveOneNode(pDevice, uNodeIndex); - else - pr_debug("Rx disassoc, sta not found\n"); - - } else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - vMgrDecodeDisassociation(&sFrame); - pr_info("AP disassociated me, reason=%d\n", - cpu_to_le16(*(sFrame.pwReason))); - //TODO: do something let upper layer know or - //try to send associate packet again because of inactivity timeout - if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) { - wpahdr = (viawget_wpa_header *)pDevice->skb->data; - wpahdr->type = VIAWGET_DISASSOC_MSG; - wpahdr->resp_ie_len = 0; - wpahdr->req_ie_len = 0; - skb_put(pDevice->skb, sizeof(viawget_wpa_header)); - pDevice->skb->dev = pDevice->wpadev; - skb_reset_mac_header(pDevice->skb); - - pDevice->skb->pkt_type = PACKET_HOST; - pDevice->skb->protocol = htons(ETH_P_802_2); - memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); - netif_rx(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - } - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - { - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - pr_debug("wireless_send_event--->SIOCGIWAP(disassociated)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } -#endif - } - /* else, ignore it */ -} - -/*+ - * - * Routine Description: - * Handles incoming deauthentication frames - * - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxDeauthentication( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -) -{ - WLAN_FR_DEAUTHEN sFrame; - unsigned int uNodeIndex = 0; - viawget_wpa_header *wpahdr; - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - //Todo: - // if is acting an AP.. - // a STA is leaving this BSS.. - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) - BSSvRemoveOneNode(pDevice, uNodeIndex); - else - pr_info("Rx deauth, sta not found\n"); - } else { - if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - vMgrDecodeDeauthen(&sFrame); - pr_info("AP deauthed me, reason=%d\n", - cpu_to_le16((*(sFrame.pwReason)))); - // TODO: update BSS list for specific BSSID if pre-authentication case - if (ether_addr_equal(sFrame.pHdr->sA3.abyAddr3, - pMgmt->abyCurrBSSID)) { - if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) { - pMgmt->sNodeDBTable[0].bActive = false; - pMgmt->eCurrMode = WMAC_MODE_STANDBY; - pMgmt->eCurrState = WMAC_STATE_IDLE; - netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = false; - } - } - - if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) { - wpahdr = (viawget_wpa_header *)pDevice->skb->data; - wpahdr->type = VIAWGET_DISASSOC_MSG; - wpahdr->resp_ie_len = 0; - wpahdr->req_ie_len = 0; - skb_put(pDevice->skb, sizeof(viawget_wpa_header)); - pDevice->skb->dev = pDevice->wpadev; - skb_reset_mac_header(pDevice->skb); - pDevice->skb->pkt_type = PACKET_HOST; - pDevice->skb->protocol = htons(ETH_P_802_2); - memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); - netif_rx(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - } - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - { - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - PRINT_K("wireless_send_event--->SIOCGIWAP(disauthen)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } -#endif - - } - /* else, ignore it. TODO: IBSS authentication service - would be implemented here */ - } -} - -//2008-8-4 by chester -/*+ - * - * Routine Description: - * check if current channel is match ZoneType. - *for USA:1~11; - * Japan:1~13; - * Europe:1~13 - * Return Value: - * True:exceed; - * False:normal case - -*/ -static bool -ChannelExceedZoneType( - struct vnt_private *pDevice, - unsigned char byCurrChannel -) -{ - bool exceed = false; - - switch (pDevice->byZoneType) { - case 0x00: //USA:1~11 - if ((byCurrChannel < 1) || (byCurrChannel > 11)) - exceed = true; - break; - case 0x01: //Japan:1~13 - case 0x02: //Europe:1~13 - if ((byCurrChannel < 1) || (byCurrChannel > 13)) - exceed = true; - break; - default: //reserve for other zonetype - break; - } - - return exceed; -} - -/*+ - * - * Routine Description: - * Handles and analysis incoming beacon frames. - * - * - * Return Value: - * None. - * - -*/ - -static -void -s_vMgrRxBeacon( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket, - bool bInScan -) -{ - PKnownBSS pBSSList; - WLAN_FR_BEACON sFrame; - u64 qwTSFOffset; - bool bIsBSSIDEqual = false; - bool bIsSSIDEqual = false; - bool bTSFLargeDiff = false; - bool bTSFOffsetPostive = false; - bool bUpdateTSF = false; - bool bIsAPBeacon = false; - bool bIsChannelEqual = false; - unsigned int uLocateByteIndex; - unsigned char byTIMBitOn = 0; - unsigned short wAIDNumber = 0; - unsigned int uNodeIndex; - u64 qwTimestamp, qwLocalTSF; - u64 qwCurrTSF; - unsigned short wStartIndex = 0; - unsigned short wAIDIndex = 0; - unsigned char byCurrChannel = pRxPacket->byRxChannel; - ERPObject sERP; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - bool bChannelHit = false; - bool bUpdatePhyParameter = false; - unsigned char byIEChannel = 0; - - memset(&sFrame, 0, sizeof(WLAN_FR_BEACON)); - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - - // decode the beacon frame - vMgrDecodeBeacon(&sFrame); - - if ((sFrame.pwBeaconInterval == NULL) || - (sFrame.pwCapInfo == NULL) || - (sFrame.pSSID == NULL) || - (sFrame.pSuppRates == NULL)) { - pr_debug("Rx beacon frame error\n"); - return; - } - - if (sFrame.pDSParms != NULL) { - if (byCurrChannel > CB_MAX_CHANNEL_24G) { - // channel remapping to - byIEChannel = get_channel_mapping(pDevice, sFrame.pDSParms->byCurrChannel, PHY_TYPE_11A); - } else { - byIEChannel = sFrame.pDSParms->byCurrChannel; - } - if (byCurrChannel != byIEChannel) { - // adjust channel info. bcs we rcv adjacent channel packets - bChannelHit = false; - byCurrChannel = byIEChannel; - } - } else { - // no DS channel info - bChannelHit = true; - } -//2008-0730-01by MikeLiu - if (ChannelExceedZoneType(pDevice, byCurrChannel)) - return; - - if (sFrame.pERP != NULL) { - sERP.byERP = sFrame.pERP->byContext; - sERP.bERPExist = true; - - } else { - sERP.bERPExist = false; - sERP.byERP = 0; - } - - pBSSList = BSSpAddrIsInBSSList((void *)pDevice, sFrame.pHdr->sA3.abyAddr3, sFrame.pSSID); - if (pBSSList == NULL) { - pr_debug("Beacon/insert: RxChannel = : %d\n", byCurrChannel); - BSSbInsertToBSSList((void *)pDevice, - sFrame.pHdr->sA3.abyAddr3, - *sFrame.pqwTimestamp, - *sFrame.pwBeaconInterval, - *sFrame.pwCapInfo, - byCurrChannel, - sFrame.pSSID, - sFrame.pSuppRates, - sFrame.pExtSuppRates, - &sERP, - sFrame.pRSN, - sFrame.pRSNWPA, - sFrame.pIE_Country, - sFrame.pIE_Quiet, - sFrame.len - WLAN_HDR_ADDR3_LEN, - sFrame.pHdr->sA4.abyAddr4, // payload of beacon - (void *)pRxPacket -); - } else { - BSSbUpdateToBSSList((void *)pDevice, - *sFrame.pqwTimestamp, - *sFrame.pwBeaconInterval, - *sFrame.pwCapInfo, - byCurrChannel, - bChannelHit, - sFrame.pSSID, - sFrame.pSuppRates, - sFrame.pExtSuppRates, - &sERP, - sFrame.pRSN, - sFrame.pRSNWPA, - sFrame.pIE_Country, - sFrame.pIE_Quiet, - pBSSList, - sFrame.len - WLAN_HDR_ADDR3_LEN, - sFrame.pHdr->sA4.abyAddr4, // payload of probresponse - (void *)pRxPacket -); - - } - - if (bInScan) - return; - - if (byCurrChannel == (unsigned char)pMgmt->uCurrChannel) - bIsChannelEqual = true; - - if (bIsChannelEqual && (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { - // if rx beacon without ERP field - if (sERP.bERPExist) { - if (WLAN_GET_ERP_USE_PROTECTION(sERP.byERP)) { - pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); - pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD; - } - } else { - pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); - pDevice->wUseProtectCntDown = USE_PROTECT_PERIOD; - } - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - if (!WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo)) - pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1); - if (!sERP.bERPExist) - pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1); - } - - // set to MAC&BBP - if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) { - if (!pDevice->bProtectMode) { - MACvEnableProtectMD(pDevice->PortOffset); - pDevice->bProtectMode = true; - } - } - } - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) - return; - - // check if BSSID the same - if (memcmp(sFrame.pHdr->sA3.abyAddr3, - pMgmt->abyCurrBSSID, - WLAN_BSSID_LEN) == 0) { - bIsBSSIDEqual = true; - -// 2008-05-21 by Richardtai - pDevice->uCurrRSSI = pRxPacket->uRSSI; - pDevice->byCurrSQ = pRxPacket->bySQ; - - if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) - pMgmt->sNodeDBTable[0].uInActiveCount = 0; - } - // check if SSID the same - if (sFrame.pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) { - if (memcmp(sFrame.pSSID->abySSID, - ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, - sFrame.pSSID->len -) == 0) { - bIsSSIDEqual = true; - } - } - - if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo) && - bIsBSSIDEqual && - bIsSSIDEqual && - (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && - (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - // add state check to prevent reconnect fail since we'll receive Beacon - - bIsAPBeacon = true; - - if (pBSSList != NULL) { - // Compare PHY parameter setting - if (pMgmt->wCurrCapInfo != pBSSList->wCapInfo) { - bUpdatePhyParameter = true; - pMgmt->wCurrCapInfo = pBSSList->wCapInfo; - } - if (sFrame.pERP != NULL) { - if ((sFrame.pERP->byElementID == WLAN_EID_ERP) && - (pMgmt->byERPContext != sFrame.pERP->byContext)) { - bUpdatePhyParameter = true; - pMgmt->byERPContext = sFrame.pERP->byContext; - } - } - // - // Basic Rate Set may change dynamically - // - if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B) - uRateLen = WLAN_RATES_MAXLEN_11B; - - pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abySuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - uRateLen); - pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abyExtSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - uRateLen); - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - true, - &(pMgmt->sNodeDBTable[0].wMaxBasicRate), - &(pMgmt->sNodeDBTable[0].wMaxSuppRate), - &(pMgmt->sNodeDBTable[0].wSuppRate), - &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) - ); - if (bUpdatePhyParameter) { - CARDbSetPhyParameter(pMgmt->pAdapter, - pMgmt->eCurrentPHYMode, - pMgmt->wCurrCapInfo, - pMgmt->byERPContext, - pMgmt->abyCurrSuppRates, - pMgmt->abyCurrExtSuppRates - ); - } - if (sFrame.pIE_PowerConstraint != NULL) { - CARDvSetPowerConstraint(pMgmt->pAdapter, - (unsigned char) pBSSList->uChannel, - sFrame.pIE_PowerConstraint->byPower -); - } - if (sFrame.pIE_CHSW != NULL) { - CARDbChannelSwitch(pMgmt->pAdapter, - sFrame.pIE_CHSW->byMode, - get_channel_mapping(pMgmt->pAdapter, sFrame.pIE_CHSW->byMode, pMgmt->eCurrentPHYMode), - sFrame.pIE_CHSW->byCount - ); - - } else if (!bIsChannelEqual) { - set_channel(pMgmt->pAdapter, pBSSList->uChannel); - } - } - } - -// pr_debug("Beacon 2\n"); - // check if CF field exists - if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) { - if (sFrame.pCFParms->wCFPDurRemaining > 0) { - // TODO: deal with CFP period to set NAV - } - } - - qwTimestamp = le64_to_cpu(*sFrame.pqwTimestamp); - qwLocalTSF = pRxPacket->qwLocalTSF; - - // check if beacon TSF larger or small than our local TSF - if (qwTimestamp >= qwLocalTSF) - bTSFOffsetPostive = true; - else - bTSFOffsetPostive = false; - - if (bTSFOffsetPostive) - qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF)); - else - qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp)); - - if (qwTSFOffset > TRIVIAL_SYNC_DIFFERENCE) - bTSFLargeDiff = true; - - // if infra mode - if (bIsAPBeacon) { - // Infra mode: Local TSF always follow AP's TSF if Difference huge. - if (bTSFLargeDiff) - bUpdateTSF = true; - - if (pDevice->bEnablePSMode && (sFrame.pTIM != NULL)) { - // deal with DTIM, analysis TIM - pMgmt->bMulticastTIM = WLAN_MGMT_IS_MULTICAST_TIM(sFrame.pTIM->byBitMapCtl) ? true : false; - pMgmt->byDTIMCount = sFrame.pTIM->byDTIMCount; - pMgmt->byDTIMPeriod = sFrame.pTIM->byDTIMPeriod; - wAIDNumber = pMgmt->wCurrAID & ~(BIT14|BIT15); - - // check if AID in TIM field bit on - // wStartIndex = N1 - wStartIndex = WLAN_MGMT_GET_TIM_OFFSET(sFrame.pTIM->byBitMapCtl) << 1; - // AIDIndex = N2 - wAIDIndex = (wAIDNumber >> 3); - if ((wAIDNumber > 0) && (wAIDIndex >= wStartIndex)) { - uLocateByteIndex = wAIDIndex - wStartIndex; - // len = byDTIMCount + byDTIMPeriod + byDTIMPeriod + byVirtBitMap[0~250] - if (sFrame.pTIM->len >= (uLocateByteIndex + 4)) { - byTIMBitOn = (0x01) << ((wAIDNumber) % 8); - pMgmt->bInTIM = sFrame.pTIM->byVirtBitMap[uLocateByteIndex] & byTIMBitOn ? true : false; - } else { - pMgmt->bInTIM = false; - } - } else { - pMgmt->bInTIM = false; - } - - if (pMgmt->bInTIM || - (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) { - pMgmt->bInTIMWake = true; - // send out ps-poll packet - - - } else { - pMgmt->bInTIMWake = false; - pr_debug("BCN: Not In TIM..\n"); - if (!pDevice->bPWBitOn) { - pr_debug("BCN: Send Null Packet\n"); - } - } - - } - - } - // if adhoc mode - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && !bIsAPBeacon && bIsChannelEqual) { - if (bIsBSSIDEqual) { - // Use sNodeDBTable[0].uInActiveCount as IBSS beacons received count. - if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) - pMgmt->sNodeDBTable[0].uInActiveCount = 0; - - // adhoc mode:TSF updated only when beacon larger than local TSF - if (bTSFLargeDiff && bTSFOffsetPostive && - (pMgmt->eCurrState == WMAC_STATE_JOINTED)) - bUpdateTSF = true; - - // During dpc, already in spinlocked. - if (BSSDBbIsSTAInNodeDB(pMgmt, sFrame.pHdr->sA3.abyAddr2, &uNodeIndex)) { - // Update the STA, (Technically the Beacons of all the IBSS nodes - // should be identical, but that's not happening in practice. - pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - WLAN_RATES_MAXLEN_11B); - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - NULL, - true, - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) - ); - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0; - } else { - // Todo, initial Node content - BSSvCreateOneNode(pDevice, &uNodeIndex); - - pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - WLAN_RATES_MAXLEN_11B); - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - NULL, - true, - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate) - ); - - memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, sFrame.pHdr->sA3.abyAddr2, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo); - pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; - { - pr_debug("s_vMgrRxBeacon:TxDataRate is %d,Index is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate, uNodeIndex); - } - } - - // if other stations joined, indicate connection to upper layer.. - if (pMgmt->eCurrState == WMAC_STATE_STARTED) { - pr_debug("Current IBSS State: [Started]........to: [Jointed]\n"); - pMgmt->eCurrState = WMAC_STATE_JOINTED; - pDevice->bLinkPass = true; - if (netif_queue_stopped(pDevice->dev)) - netif_wake_queue(pDevice->dev); - - pMgmt->sNodeDBTable[0].bActive = true; - pMgmt->sNodeDBTable[0].uInActiveCount = 0; - - } - } else if (bIsSSIDEqual) { - // See other adhoc sta with the same SSID but BSSID is different. - // adpot this vars only when TSF larger then us. - if (bTSFLargeDiff && bTSFOffsetPostive) { - // we don't support ATIM under adhoc mode - // if (sFrame.pIBSSParms->wATIMWindow == 0) { - // adpot this vars - // TODO: check sFrame cap if privacy on, and support rate syn - memcpy(pMgmt->abyCurrBSSID, sFrame.pHdr->sA3.abyAddr3, WLAN_BSSID_LEN); - memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - pMgmt->wCurrATIMWindow = cpu_to_le16(sFrame.pIBSSParms->wATIMWindow); - pMgmt->wCurrBeaconPeriod = cpu_to_le16(*sFrame.pwBeaconInterval); - pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - WLAN_RATES_MAXLEN_11B); - // set HW beacon interval and re-synchronizing.... - pr_debug("Rejoining to Other Adhoc group with same SSID........\n"); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, pMgmt->wCurrBeaconPeriod); - CARDbUpdateTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, qwLocalTSF); - CARDvUpdateNextTBTT(pDevice->PortOffset, qwTimestamp, pMgmt->wCurrBeaconPeriod); - // Turn off bssid filter to avoid filter others adhoc station which bssid is different. - MACvWriteBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID); - - CARDbSetPhyParameter(pMgmt->pAdapter, - pMgmt->eCurrentPHYMode, - pMgmt->wCurrCapInfo, - pMgmt->byERPContext, - pMgmt->abyCurrSuppRates, - pMgmt->abyCurrExtSuppRates); - - // Prepare beacon frame - bMgrPrepareBeaconToSend((void *)pDevice, pMgmt); - } - } - } - // endian issue ??? - // Update TSF -if (bUpdateTSF) { - CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF); - CARDbUpdateTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, pRxPacket->qwLocalTSF); - CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF); - CARDvUpdateNextTBTT(pDevice->PortOffset, qwTimestamp, pMgmt->wCurrBeaconPeriod); - } -} - -/*+ - * - * Routine Description: - * Instructs the hw to create a bss using the supplied - * attributes. Note that this implementation only supports Ad-Hoc - * BSS creation. - * - * - * Return Value: - * CMD_STATUS - * - -*/ -void -vMgrCreateOwnIBSS( - void *hDeviceContext, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned short wMaxBasicRate; - unsigned short wMaxSuppRate; - unsigned char byTopCCKBasicRate; - unsigned char byTopOFDMBasicRate; - u64 qwCurrTSF; - unsigned int ii; - unsigned char abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60}; - unsigned char abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96}; - unsigned char abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; - unsigned short wSuppRate; - - pr_debug("Create Basic Service Set .......\n"); - - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) && - (pDevice->eEncryptionStatus != Ndis802_11Encryption2Enabled) && - (pDevice->eEncryptionStatus != Ndis802_11Encryption3Enabled)) { - // encryption mode error - *pStatus = CMD_STATUS_FAILURE; - return; - } - } - - pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; - pMgmt->abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; - - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - pMgmt->eCurrentPHYMode = pMgmt->byAPBBType; - } else { - if (pDevice->byBBType == BB_TYPE_11G) - pMgmt->eCurrentPHYMode = PHY_TYPE_11G; - if (pDevice->byBBType == BB_TYPE_11B) - pMgmt->eCurrentPHYMode = PHY_TYPE_11B; - if (pDevice->byBBType == BB_TYPE_11A) - pMgmt->eCurrentPHYMode = PHY_TYPE_11A; - } - - if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) { - pMgmt->abyCurrSuppRates[1] = WLAN_RATES_MAXLEN_11B; - pMgmt->abyCurrExtSuppRates[1] = 0; - for (ii = 0; ii < 4; ii++) - pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii]; - } else { - pMgmt->abyCurrSuppRates[1] = 8; - pMgmt->abyCurrExtSuppRates[1] = 0; - for (ii = 0; ii < 8; ii++) - pMgmt->abyCurrSuppRates[2+ii] = abyRATE[ii]; - } - - if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { - pMgmt->abyCurrSuppRates[1] = 8; - pMgmt->abyCurrExtSuppRates[1] = 4; - for (ii = 0; ii < 4; ii++) - pMgmt->abyCurrSuppRates[2+ii] = abyCCK_RATE[ii]; - for (ii = 4; ii < 8; ii++) - pMgmt->abyCurrSuppRates[2+ii] = abyOFDM_RATE[ii-4]; - for (ii = 0; ii < 4; ii++) - pMgmt->abyCurrExtSuppRates[2+ii] = abyOFDM_RATE[ii+4]; - } - - // Disable Protect Mode - pDevice->bProtectMode = false; - MACvDisableProtectMD(pDevice->PortOffset); - - pDevice->bBarkerPreambleMd = false; - MACvDisableBarkerPreambleMd(pDevice->PortOffset); - - // Kyle Test 2003.11.04 - - // set HW beacon interval - if (pMgmt->wIBSSBeaconPeriod == 0) - pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI; - - CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF); - // clear TSF counter - VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); - // enable TSF counter - VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); - - // set Next TBTT - CARDvSetFirstNextTBTT(pDevice->PortOffset, pMgmt->wIBSSBeaconPeriod); - - pMgmt->uIBSSChannel = pDevice->uChannel; - - if (pMgmt->uIBSSChannel == 0) - pMgmt->uIBSSChannel = DEFAULT_IBSS_CHANNEL; - - // set basic rate - - RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, true, - &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, - &byTopCCKBasicRate, &byTopOFDMBasicRate); - - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) - pMgmt->eCurrMode = WMAC_MODE_ESS_AP; - - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { - memcpy(pMgmt->abyIBSSDFSOwner, pDevice->abyCurrentNetAddr, 6); - pMgmt->byIBSSDFSRecovery = 10; - pMgmt->eCurrMode = WMAC_MODE_IBSS_STA; - } - - // Adopt pre-configured IBSS vars to current vars - pMgmt->eCurrState = WMAC_STATE_STARTED; - pMgmt->wCurrBeaconPeriod = pMgmt->wIBSSBeaconPeriod; - pMgmt->uCurrChannel = pMgmt->uIBSSChannel; - pMgmt->wCurrATIMWindow = pMgmt->wIBSSATIMWindow; - MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow); - pDevice->uCurrRSSI = 0; - pDevice->byCurrSQ = 0; - memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyCurrSSID, - pMgmt->abyDesireSSID, - ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN -); - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - // AP mode BSSID = MAC addr - memcpy(pMgmt->abyCurrBSSID, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - pr_info("AP beacon created BSSID:%pM\n", - pMgmt->abyCurrBSSID); - } - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - // BSSID selected must be randomized as spec 11.1.3 - pMgmt->abyCurrBSSID[5] = (u8) (qwCurrTSF & 0x000000ff); - pMgmt->abyCurrBSSID[4] = (u8) ((qwCurrTSF & 0x0000ff00) >> 8); - pMgmt->abyCurrBSSID[3] = (u8) ((qwCurrTSF & 0x00ff0000) >> 16); - pMgmt->abyCurrBSSID[2] = (u8) ((qwCurrTSF & 0x00000ff0) >> 4); - pMgmt->abyCurrBSSID[1] = (u8) ((qwCurrTSF & 0x000ff000) >> 12); - pMgmt->abyCurrBSSID[0] = (u8) ((qwCurrTSF & 0x0ff00000) >> 20); - pMgmt->abyCurrBSSID[5] ^= pMgmt->abyMACAddr[0]; - pMgmt->abyCurrBSSID[4] ^= pMgmt->abyMACAddr[1]; - pMgmt->abyCurrBSSID[3] ^= pMgmt->abyMACAddr[2]; - pMgmt->abyCurrBSSID[2] ^= pMgmt->abyMACAddr[3]; - pMgmt->abyCurrBSSID[1] ^= pMgmt->abyMACAddr[4]; - pMgmt->abyCurrBSSID[0] ^= pMgmt->abyMACAddr[5]; - pMgmt->abyCurrBSSID[0] &= ~IEEE_ADDR_GROUP; - pMgmt->abyCurrBSSID[0] |= IEEE_ADDR_UNIVERSAL; - - pr_info("Adhoc beacon created bssid:%pM\n", - pMgmt->abyCurrBSSID); - } - - // Set Capability Info - pMgmt->wCurrCapInfo = 0; - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); - pMgmt->byDTIMPeriod = DEFAULT_DTIM_PERIOD; - pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1; - } - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1); - - if (pDevice->bEncryptionEnable) { - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - pMgmt->byCSSPK = KEY_CTL_CCMP; - pMgmt->byCSSGK = KEY_CTL_CCMP; - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - pMgmt->byCSSPK = KEY_CTL_TKIP; - pMgmt->byCSSGK = KEY_CTL_TKIP; - } else { - pMgmt->byCSSPK = KEY_CTL_NONE; - pMgmt->byCSSGK = KEY_CTL_WEP; - } - } else { - pMgmt->byCSSPK = KEY_CTL_WEP; - pMgmt->byCSSGK = KEY_CTL_WEP; - } - } - - pMgmt->byERPContext = 0; - - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_AP); - } else { - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_ADHOC); - } - - CARDbSetPhyParameter(pMgmt->pAdapter, - pMgmt->eCurrentPHYMode, - pMgmt->wCurrCapInfo, - pMgmt->byERPContext, - pMgmt->abyCurrSuppRates, - pMgmt->abyCurrExtSuppRates - ); - - CARDbSetBeaconPeriod(pMgmt->pAdapter, pMgmt->wIBSSBeaconPeriod); - // set channel and clear NAV - set_channel(pMgmt->pAdapter, pMgmt->uIBSSChannel); - pMgmt->uCurrChannel = pMgmt->uIBSSChannel; - - if (CARDbIsShortPreamble(pMgmt->pAdapter)) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - else - pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1)); - - if (pMgmt->b11hEnable && - (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) { - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); - } else { - pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SPECTRUMMNG(1)); - } - - pMgmt->eCurrState = WMAC_STATE_STARTED; - // Prepare beacon to send - if (bMgrPrepareBeaconToSend((void *)pDevice, pMgmt)) - *pStatus = CMD_STATUS_SUCCESS; -} - -/*+ - * - * Routine Description: - * Instructs wmac to join a bss using the supplied attributes. - * The arguments may the BSSID or SSID and the rest of the - * attributes are obtained from the scan result of known bss list. - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrJoinBSSBegin( - void *hDeviceContext, - PCMD_STATUS pStatus -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - PKnownBSS pCurr = NULL; - unsigned int ii, uu; - PWLAN_IE_SUPP_RATES pItemRates = NULL; - PWLAN_IE_SUPP_RATES pItemExtRates = NULL; - PWLAN_IE_SSID pItemSSID; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - unsigned short wMaxBasicRate = RATE_1M; - unsigned short wMaxSuppRate = RATE_1M; - unsigned short wSuppRate; - unsigned char byTopCCKBasicRate = RATE_1M; - unsigned char byTopOFDMBasicRate = RATE_1M; - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - if (pMgmt->sBSSList[ii].bActive) - break; - } - - if (ii == MAX_BSS_NUM) { - *pStatus = CMD_STATUS_RESOURCES; - pr_info("BSS finding:BSS list is empty\n"); - return; - } - - // Search known BSS list for prefer BSSID or SSID - - pCurr = BSSpSearchBSSList(pDevice, - pMgmt->abyDesireBSSID, - pMgmt->abyDesireSSID, - pMgmt->eConfigPHYMode -); - - if (pCurr == NULL) { - *pStatus = CMD_STATUS_RESOURCES; - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; - pr_info("Scanning [%s] not found, disconnected !\n", - pItemSSID->abySSID); - return; - } - - pr_info("AP(BSS) finding:Found a AP(BSS)..\n"); - if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))) { - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) { - // patch for CISCO migration mode - } - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - Encyption_Rebuild(pDevice, pCurr); -#endif - // Infrastructure BSS - s_vMgrSynchBSS(pDevice, - WMAC_MODE_ESS_STA, - pCurr, - pStatus -); - - if (*pStatus == CMD_STATUS_SUCCESS) { - // Adopt this BSS state vars in Mgmt Object - pMgmt->uCurrChannel = pCurr->uChannel; - - memset(pMgmt->abyCurrSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - memset(pMgmt->abyCurrExtSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - - if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) - uRateLen = WLAN_RATES_MAXLEN_11B; - - pItemRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates; - pItemExtRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates; - - // Parse Support Rate IE - pItemRates->byElementID = WLAN_EID_SUPP_RATES; - pItemRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates, - pItemRates, - uRateLen); - - // Parse Extension Support Rate IE - pItemExtRates->byElementID = WLAN_EID_EXTSUPP_RATES; - pItemExtRates->len = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abyExtSuppRates, - pItemExtRates, - uRateLen); - // Stuffing Rate IE - if ((pItemExtRates->len > 0) && (pItemRates->len < 8)) { - for (ii = 0; ii < (unsigned int)(8 - pItemRates->len);) { - pItemRates->abyRates[pItemRates->len + ii] = pItemExtRates->abyRates[ii]; - ii++; - if (pItemExtRates->len <= ii) - break; - } - pItemRates->len += (unsigned char)ii; - if (pItemExtRates->len - ii > 0) { - pItemExtRates->len -= (unsigned char)ii; - for (uu = 0; uu < pItemExtRates->len; uu++) - pItemExtRates->abyRates[uu] = pItemExtRates->abyRates[uu + ii]; - } else { - pItemExtRates->len = 0; - } - } - - RATEvParseMaxRate((void *)pDevice, pItemRates, pItemExtRates, true, - &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, - &byTopCCKBasicRate, &byTopOFDMBasicRate); - - // TODO: deal with if wCapInfo the privacy is on, but station WEP is off - // TODO: deal with if wCapInfo the PS-Pollable is on. - pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval; - memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); - memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - - pMgmt->eCurrMode = WMAC_MODE_ESS_STA; - - pMgmt->eCurrState = WMAC_STATE_JOINTED; - - // Add current BSS to Candidate list - // This should only works for WPA2 BSS, and WPA2 BSS check must be done before. - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { - bool bResult = bAdd_PMKID_Candidate((void *)pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj); - - pr_debug("bAdd_PMKID_Candidate: 1(%d)\n", - bResult); - if (!bResult) { - vFlush_PMKID_Candidate((void *)pDevice); - pr_debug("vFlush_PMKID_Candidate: 4\n"); - bAdd_PMKID_Candidate((void *)pDevice, pMgmt->abyCurrBSSID, &pCurr->sRSNCapObj); - } - } - - // Preamble type auto-switch: if AP can receive short-preamble cap, - // we can turn on too. - - pr_debug("Join ESS\n"); - - pr_debug("End of Join AP -- A/B/G Action\n"); - } else { - pMgmt->eCurrState = WMAC_STATE_IDLE; - } - - } else { - // ad-hoc mode BSS - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - if (!WPA_SearchRSN(0, WPA_TKIP, pCurr)) { - // encryption mode error - pMgmt->eCurrState = WMAC_STATE_IDLE; - return; - } - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - if (!WPA_SearchRSN(0, WPA_AESCCMP, pCurr)) { - // encryption mode error - pMgmt->eCurrState = WMAC_STATE_IDLE; - return; - } - } else { - // encryption mode error - pMgmt->eCurrState = WMAC_STATE_IDLE; - return; - } - } - - s_vMgrSynchBSS(pDevice, - WMAC_MODE_IBSS_STA, - pCurr, - pStatus -); - - if (*pStatus == CMD_STATUS_SUCCESS) { - // Adopt this BSS state vars in Mgmt Object - // TODO: check if CapInfo privacy on, but we don't.. - pMgmt->uCurrChannel = pCurr->uChannel; - - // Parse Support Rate IE - pMgmt->abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; - pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pCurr->abySuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - WLAN_RATES_MAXLEN_11B); - // set basic rate - RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - NULL, true, &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, - &byTopCCKBasicRate, &byTopOFDMBasicRate); - - pMgmt->wCurrCapInfo = pCurr->wCapInfo; - pMgmt->wCurrBeaconPeriod = pCurr->wBeaconInterval; - memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN); - memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); - memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN); - MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow); - pMgmt->eCurrMode = WMAC_MODE_IBSS_STA; - - pMgmt->eCurrState = WMAC_STATE_STARTED; - - pr_debug("Join IBSS ok:%pM\n", - pMgmt->abyCurrBSSID); - // Preamble type auto-switch: if AP can receive short-preamble cap, - // and if registry setting is short preamble we can turn on too. - - // Prepare beacon - bMgrPrepareBeaconToSend((void *)pDevice, pMgmt); - } else { - pMgmt->eCurrState = WMAC_STATE_IDLE; - } - } -} - -/*+ - * - * Routine Description: - * Set HW to synchronize a specific BSS from known BSS list. - * - * - * Return Value: - * PCM_STATUS - * - -*/ -static -void -s_vMgrSynchBSS( - struct vnt_private *pDevice, - unsigned int uBSSMode, - PKnownBSS pCurr, - PCMD_STATUS pStatus -) -{ - CARD_PHY_TYPE ePhyType = PHY_TYPE_11B; - PSMgmtObject pMgmt = pDevice->pMgmt; - - //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M - unsigned char abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; - unsigned char abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; - //6M, 9M, 12M, 48M - unsigned char abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; - unsigned char abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - - *pStatus = CMD_STATUS_FAILURE; - - if (!s_bCipherMatch(pCurr, - pDevice->eEncryptionStatus, - &(pMgmt->byCSSPK), - &(pMgmt->byCSSGK))) { - pr_debug("s_bCipherMatch Fail .......\n"); - return; - } - - pMgmt->pCurrBSS = pCurr; - - // if previous mode is IBSS. - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_BCNDMACTL, BEACON_READY); - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); - } - - // Init the BSS informations - pDevice->bProtectMode = false; - MACvDisableProtectMD(pDevice->PortOffset); - pDevice->bBarkerPreambleMd = false; - MACvDisableBarkerPreambleMd(pDevice->PortOffset); - pDevice->bNonERPPresent = false; - pDevice->byPreambleType = 0; - pDevice->wBasicRate = 0; - // Set Basic Rate - CARDbAddBasicRate((void *)pDevice, RATE_1M); - // calculate TSF offset - // TSF Offset = Received Timestamp TSF - Marked Local's TSF - CARDbUpdateTSF(pDevice, pCurr->byRxRate, pCurr->qwBSSTimestamp, pCurr->qwLocalTSF); - - CARDbSetBeaconPeriod(pDevice, pCurr->wBeaconInterval); - - // set Next TBTT - // Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval - CARDvSetFirstNextTBTT(pDevice->PortOffset, pCurr->wBeaconInterval); - - // set BSSID - MACvWriteBSSIDAddress(pDevice->PortOffset, pCurr->abyBSSID); - - MACvReadBSSIDAddress(pDevice->PortOffset, pMgmt->abyCurrBSSID); - - pr_debug("Sync:set CurrBSSID address = %pM\n", pMgmt->abyCurrBSSID); - - if (pCurr->eNetworkTypeInUse == PHY_TYPE_11A) { - if ((pMgmt->eConfigPHYMode == PHY_TYPE_11A) || - (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) { - ePhyType = PHY_TYPE_11A; - } else { - return; - } - } else if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) { - if ((pMgmt->eConfigPHYMode == PHY_TYPE_11B) || - (pMgmt->eConfigPHYMode == PHY_TYPE_11G) || - (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) { - ePhyType = PHY_TYPE_11B; - } else { - return; - } - } else { - if ((pMgmt->eConfigPHYMode == PHY_TYPE_11G) || - (pMgmt->eConfigPHYMode == PHY_TYPE_AUTO)) { - ePhyType = PHY_TYPE_11G; - } else if (pMgmt->eConfigPHYMode == PHY_TYPE_11B) { - ePhyType = PHY_TYPE_11B; - } else { - return; - } - } - - if (ePhyType == PHY_TYPE_11A) { - memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA)); - pMgmt->abyCurrExtSuppRates[1] = 0; - } else if (ePhyType == PHY_TYPE_11B) { - memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesB[0], sizeof(abyCurrSuppRatesB)); - pMgmt->abyCurrExtSuppRates[1] = 0; - } else { - memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesG[0], sizeof(abyCurrSuppRatesG)); - memcpy(pMgmt->abyCurrExtSuppRates, &abyCurrExtSuppRatesG[0], sizeof(abyCurrExtSuppRatesG)); - } - - if (WLAN_GET_CAP_INFO_ESS(pCurr->wCapInfo)) { - CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, NL80211_IFTYPE_STATION); - // Add current BSS to Candidate list - // This should only works for WPA2 BSS, and WPA2 BSS check must be done before. - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) - CARDbAdd_PMKID_Candidate(pMgmt->pAdapter, pMgmt->abyCurrBSSID, pCurr->sRSNCapObj.bRSNCapExist, pCurr->sRSNCapObj.wRSNCap); - } else { - CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, NL80211_IFTYPE_ADHOC); - } - - if (!CARDbSetPhyParameter(pMgmt->pAdapter, - ePhyType, - pCurr->wCapInfo, - pCurr->sERP.byERP, - pMgmt->abyCurrSuppRates, - pMgmt->abyCurrExtSuppRates)) { - pr_debug("<----s_bSynchBSS Set Phy Mode Fail [%d]\n", ePhyType); - return; - } - // set channel and clear NAV - if (!set_channel(pMgmt->pAdapter, pCurr->uChannel)) { - pr_debug("<----s_bSynchBSS Set Channel [%d]\n", - pCurr->uChannel); - return; - } - - pMgmt->uCurrChannel = pCurr->uChannel; - pMgmt->eCurrentPHYMode = ePhyType; - pMgmt->byERPContext = pCurr->sERP.byERP; - pr_debug("Sync:Set to channel = [%d]\n", (int)pCurr->uChannel); - - *pStatus = CMD_STATUS_SUCCESS; - - return; -}; - -//mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption -// ,need reset eAuthenMode and eEncryptionStatus -static void Encyption_Rebuild( - struct vnt_private *pDevice, - PKnownBSS pCurr -) -{ - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || //networkmanager 0.7.0 does not give the pairwise-key selection, - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { // so we need re-select it according to real pairwise-key info. - if (pCurr->bWPAValid) { //WPA-PSK - pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; - if (pCurr->abyPKType[0] == WPA_TKIP) { - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP - PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n"); - } else if (pCurr->abyPKType[0] == WPA_AESCCMP) { - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES - PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-AES]\n"); - } - } else if (pCurr->bWPA2Valid) { //WPA2-PSK - pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; - if (pCurr->abyCSSPK[0] == WLAN_11i_CSS_TKIP) { - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; //TKIP - PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n"); - } else if (pCurr->abyCSSPK[0] == WLAN_11i_CSS_CCMP) { - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES - PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-AES]\n"); - } - } - } -} - -/*+ - * - * Routine Description: - * Format TIM field - * - * - * Return Value: - * void - * - -*/ - -static -void -s_vMgrFormatTIM( - PSMgmtObject pMgmt, - PWLAN_IE_TIM pTIM -) -{ - unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - unsigned char byMap; - unsigned int ii, jj; - bool bStartFound = false; - bool bMulticast = false; - unsigned short wStartIndex = 0; - unsigned short wEndIndex = 0; - - // Find size of partial virtual bitmap - for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { - byMap = pMgmt->abyPSTxMap[ii]; - if (!ii) { - // Mask out the broadcast bit which is indicated separately. - bMulticast = (byMap & byMask[0]) != 0; - if (bMulticast) - pMgmt->sNodeDBTable[0].bRxPSPoll = true; - - byMap = 0; - } - if (byMap) { - if (!bStartFound) { - bStartFound = true; - wStartIndex = ii; - } - wEndIndex = ii; - } - } - - // Round start index down to nearest even number - wStartIndex &= ~BIT0; - - // Round end index up to nearest even number - wEndIndex = ((wEndIndex + 1) & ~BIT0); - - // Size of element payload - - pTIM->len = 3 + (wEndIndex - wStartIndex) + 1; - - // Fill in the Fixed parts of the TIM - pTIM->byDTIMCount = pMgmt->byDTIMCount; - pTIM->byDTIMPeriod = pMgmt->byDTIMPeriod; - pTIM->byBitMapCtl = (bMulticast ? TIM_MULTICAST_MASK : 0) | - (((wStartIndex >> 1) << 1) & TIM_BITMAPOFFSET_MASK); - - // Append variable part of TIM - - for (ii = wStartIndex, jj = 0; ii <= wEndIndex; ii++, jj++) - pTIM->byVirtBitMap[jj] = pMgmt->abyPSTxMap[ii]; - - // Aid = 0 don't used. - pTIM->byVirtBitMap[0] &= ~BIT0; -} - -/*+ - * - * Routine Description: - * Constructs an Beacon frame(Ad-hoc mode) - * - * - * Return Value: - * PTR to frame; or NULL on allocation failure - * - -*/ - -static -PSTxMgmtPacket -s_MgrMakeBeacon( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wCurrBeaconPeriod, - unsigned int uCurrChannel, - unsigned short wCurrATIMWinodw, - PWLAN_IE_SSID pCurrSSID, - unsigned char *pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -) -{ - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_BEACON sFrame; - unsigned char abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - unsigned char *pbyBuffer; - unsigned int uLength = 0; - PWLAN_IE_IBSS_DFS pIBSSDFS = NULL; - unsigned int ii; - - // prepare beacon frame - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_BEACON_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - // Setup the sFrame structure. - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_BEACON_FR_MAXLEN; - vMgrEncodeBeacon(&sFrame); - // Setup the header - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON) -)); - - if (pDevice->bEnablePSMode) - sFrame.pHdr->sA3.wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_PWRMGT(1)); - - memcpy(sFrame.pHdr->sA3.abyAddr1, abyBroadcastAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN); - *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod); - *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); - // Copy SSID - sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSSID, - pCurrSSID, - ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN -); - // Copy the rate set - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, - pCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN -); - // DS parameter - if (pDevice->eCurrentPHYType != PHY_TYPE_11A) { - sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len); - sFrame.len += (1) + WLAN_IEHDR_LEN; - sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS; - sFrame.pDSParms->len = 1; - sFrame.pDSParms->byCurrChannel = (unsigned char)uCurrChannel; - } - // TIM field - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - sFrame.pTIM = (PWLAN_IE_TIM)(sFrame.pBuf + sFrame.len); - sFrame.pTIM->byElementID = WLAN_EID_TIM; - s_vMgrFormatTIM(pMgmt, sFrame.pTIM); - sFrame.len += (WLAN_IEHDR_LEN + sFrame.pTIM->len); - } - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - // IBSS parameter - sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len); - sFrame.len += (2) + WLAN_IEHDR_LEN; - sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS; - sFrame.pIBSSParms->len = 2; - sFrame.pIBSSParms->wATIMWindow = wCurrATIMWinodw; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - /* RSN parameter */ - sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len); - sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA; - sFrame.pRSNWPA->len = 12; - sFrame.pRSNWPA->abyOUI[0] = 0x00; - sFrame.pRSNWPA->abyOUI[1] = 0x50; - sFrame.pRSNWPA->abyOUI[2] = 0xf2; - sFrame.pRSNWPA->abyOUI[3] = 0x01; - sFrame.pRSNWPA->wVersion = 1; - sFrame.pRSNWPA->abyMulticast[0] = 0x00; - sFrame.pRSNWPA->abyMulticast[1] = 0x50; - sFrame.pRSNWPA->abyMulticast[2] = 0xf2; - if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) - sFrame.pRSNWPA->abyMulticast[3] = 0x04;//AES - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) - sFrame.pRSNWPA->abyMulticast[3] = 0x02;//TKIP - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) - sFrame.pRSNWPA->abyMulticast[3] = 0x01;//WEP40 - else - sFrame.pRSNWPA->abyMulticast[3] = 0x00;//NONE - - // Pairwise Key Cipher Suite - sFrame.pRSNWPA->wPKCount = 0; - // Auth Key Management Suite - *((unsigned short *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len)) = 0; - sFrame.pRSNWPA->len += 2; - - // RSN Capabilities - *((unsigned short *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len)) = 0; - sFrame.pRSNWPA->len += 2; - sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - } - } - - if (pMgmt->b11hEnable && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) { - // Country IE - pbyBuffer = (unsigned char *)(sFrame.pBuf + sFrame.len); - set_country_IE(pMgmt->pAdapter, pbyBuffer); - set_country_info(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer); - uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN; - pbyBuffer += (((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN); - // Power Constrain IE - ((PWLAN_IE_PW_CONST) pbyBuffer)->byElementID = WLAN_EID_PWR_CONSTRAINT; - ((PWLAN_IE_PW_CONST) pbyBuffer)->len = 1; - ((PWLAN_IE_PW_CONST) pbyBuffer)->byPower = 0; - pbyBuffer += (1) + WLAN_IEHDR_LEN; - uLength += (1) + WLAN_IEHDR_LEN; - if (pMgmt->bSwitchChannel) { - // Channel Switch IE - ((PWLAN_IE_CH_SW) pbyBuffer)->byElementID = WLAN_EID_CH_SWITCH; - ((PWLAN_IE_CH_SW) pbyBuffer)->len = 3; - ((PWLAN_IE_CH_SW) pbyBuffer)->byMode = 1; - ((PWLAN_IE_CH_SW) pbyBuffer)->byChannel = get_channel_number(pMgmt->pAdapter, pMgmt->byNewChannel); - ((PWLAN_IE_CH_SW) pbyBuffer)->byCount = 0; - pbyBuffer += (3) + WLAN_IEHDR_LEN; - uLength += (3) + WLAN_IEHDR_LEN; - } - // TPC report - ((PWLAN_IE_TPC_REP) pbyBuffer)->byElementID = WLAN_EID_TPC_REP; - ((PWLAN_IE_TPC_REP) pbyBuffer)->len = 2; - ((PWLAN_IE_TPC_REP) pbyBuffer)->byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter); - ((PWLAN_IE_TPC_REP) pbyBuffer)->byLinkMargin = 0; - pbyBuffer += (2) + WLAN_IEHDR_LEN; - uLength += (2) + WLAN_IEHDR_LEN; - // IBSS DFS - if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) { - pIBSSDFS = (PWLAN_IE_IBSS_DFS) pbyBuffer; - pIBSSDFS->byElementID = WLAN_EID_IBSS_DFS; - pIBSSDFS->len = 7; - memcpy(pIBSSDFS->abyDFSOwner, - pMgmt->abyIBSSDFSOwner, - 6); - pIBSSDFS->byDFSRecovery = pMgmt->byIBSSDFSRecovery; - pbyBuffer += (7) + WLAN_IEHDR_LEN; - uLength += (7) + WLAN_IEHDR_LEN; - for (ii = CB_MAX_CHANNEL_24G+1; ii <= CB_MAX_CHANNEL; ii++) { - if (get_channel_map_info(pMgmt->pAdapter, ii, pbyBuffer, pbyBuffer+1)) { - pbyBuffer += 2; - uLength += 2; - pIBSSDFS->len += 2; - } - } - } - sFrame.len += uLength; - } - - if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { - sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len); - sFrame.len += 1 + WLAN_IEHDR_LEN; - sFrame.pERP->byElementID = WLAN_EID_ERP; - sFrame.pERP->len = 1; - sFrame.pERP->byContext = 0; - if (pDevice->bProtectMode) - sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION; - if (pDevice->bNonERPPresent) - sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT; - if (pDevice->bBarkerPreambleMd) - sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE; - } - if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, - pCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN -); - } - // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnableHostapd) { - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pMgmt->wWPAIELen != 0) { - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); - sFrame.len += pMgmt->wWPAIELen; - } - } - } - - /* Adjust the length fields */ - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - return pTxPacket; -} - -/*+ - * - * Routine Description: - * Constructs an Prob-response frame - * - * - * Return Value: - * PTR to frame; or NULL on allocation failure - * - -*/ - -static PSTxMgmtPacket -s_MgrMakeProbeResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wCurrBeaconPeriod, - unsigned int uCurrChannel, - unsigned short wCurrATIMWinodw, - unsigned char *pDstAddr, - PWLAN_IE_SSID pCurrSSID, - unsigned char *pCurrBSSID, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates, - unsigned char byPHYType -) -{ - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_PROBERESP sFrame; - unsigned char *pbyBuffer; - unsigned int uLength = 0; - PWLAN_IE_IBSS_DFS pIBSSDFS = NULL; - unsigned int ii; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBERESP_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - // Setup the sFrame structure. - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_PROBERESP_FR_MAXLEN; - vMgrEncodeProbeResponse(&sFrame); - // Setup the header - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBERESP) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pCurrBSSID, WLAN_BSSID_LEN); - *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod); - *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); - - if (byPHYType == BB_TYPE_11B) - *sFrame.pwCapInfo &= cpu_to_le16((unsigned short)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1))); - - // Copy SSID - sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSSID, - pCurrSSID, - ((PWLAN_IE_SSID)pCurrSSID)->len + WLAN_IEHDR_LEN -); - // Copy the rate set - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, - pCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN -); - - // DS parameter - if (pDevice->eCurrentPHYType != PHY_TYPE_11A) { - sFrame.pDSParms = (PWLAN_IE_DS_PARMS)(sFrame.pBuf + sFrame.len); - sFrame.len += (1) + WLAN_IEHDR_LEN; - sFrame.pDSParms->byElementID = WLAN_EID_DS_PARMS; - sFrame.pDSParms->len = 1; - sFrame.pDSParms->byCurrChannel = (unsigned char)uCurrChannel; - } - - if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) { - // IBSS parameter - sFrame.pIBSSParms = (PWLAN_IE_IBSS_PARMS)(sFrame.pBuf + sFrame.len); - sFrame.len += (2) + WLAN_IEHDR_LEN; - sFrame.pIBSSParms->byElementID = WLAN_EID_IBSS_PARMS; - sFrame.pIBSSParms->len = 2; - sFrame.pIBSSParms->wATIMWindow = 0; - } - if (pDevice->eCurrentPHYType == PHY_TYPE_11G) { - sFrame.pERP = (PWLAN_IE_ERP)(sFrame.pBuf + sFrame.len); - sFrame.len += 1 + WLAN_IEHDR_LEN; - sFrame.pERP->byElementID = WLAN_EID_ERP; - sFrame.pERP->len = 1; - sFrame.pERP->byContext = 0; - if (pDevice->bProtectMode) - sFrame.pERP->byContext |= WLAN_EID_ERP_USE_PROTECTION; - if (pDevice->bNonERPPresent) - sFrame.pERP->byContext |= WLAN_EID_ERP_NONERP_PRESENT; - if (pDevice->bBarkerPreambleMd) - sFrame.pERP->byContext |= WLAN_EID_ERP_BARKER_MODE; - } - - if (pMgmt->b11hEnable && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) { - // Country IE - pbyBuffer = (unsigned char *)(sFrame.pBuf + sFrame.len); - set_country_IE(pMgmt->pAdapter, pbyBuffer); - set_country_info(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer); - uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN; - pbyBuffer += (((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN); - // Power Constrain IE - ((PWLAN_IE_PW_CONST) pbyBuffer)->byElementID = WLAN_EID_PWR_CONSTRAINT; - ((PWLAN_IE_PW_CONST) pbyBuffer)->len = 1; - ((PWLAN_IE_PW_CONST) pbyBuffer)->byPower = 0; - pbyBuffer += (1) + WLAN_IEHDR_LEN; - uLength += (1) + WLAN_IEHDR_LEN; - if (pMgmt->bSwitchChannel) { - // Channel Switch IE - ((PWLAN_IE_CH_SW) pbyBuffer)->byElementID = WLAN_EID_CH_SWITCH; - ((PWLAN_IE_CH_SW) pbyBuffer)->len = 3; - ((PWLAN_IE_CH_SW) pbyBuffer)->byMode = 1; - ((PWLAN_IE_CH_SW) pbyBuffer)->byChannel = get_channel_number(pMgmt->pAdapter, pMgmt->byNewChannel); - ((PWLAN_IE_CH_SW) pbyBuffer)->byCount = 0; - pbyBuffer += (3) + WLAN_IEHDR_LEN; - uLength += (3) + WLAN_IEHDR_LEN; - } - // TPC report - ((PWLAN_IE_TPC_REP) pbyBuffer)->byElementID = WLAN_EID_TPC_REP; - ((PWLAN_IE_TPC_REP) pbyBuffer)->len = 2; - ((PWLAN_IE_TPC_REP) pbyBuffer)->byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter); - ((PWLAN_IE_TPC_REP) pbyBuffer)->byLinkMargin = 0; - pbyBuffer += (2) + WLAN_IEHDR_LEN; - uLength += (2) + WLAN_IEHDR_LEN; - // IBSS DFS - if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP) { - pIBSSDFS = (PWLAN_IE_IBSS_DFS) pbyBuffer; - pIBSSDFS->byElementID = WLAN_EID_IBSS_DFS; - pIBSSDFS->len = 7; - memcpy(pIBSSDFS->abyDFSOwner, - pMgmt->abyIBSSDFSOwner, - 6); - pIBSSDFS->byDFSRecovery = pMgmt->byIBSSDFSRecovery; - pbyBuffer += (7) + WLAN_IEHDR_LEN; - uLength += (7) + WLAN_IEHDR_LEN; - for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CB_MAX_CHANNEL; ii++) { - if (get_channel_map_info(pMgmt->pAdapter, ii, pbyBuffer, pbyBuffer+1)) { - pbyBuffer += 2; - uLength += 2; - pIBSSDFS->len += 2; - } - } - } - sFrame.len += uLength; - } - - if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, - pCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN -); - } - - // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && pDevice->bEnableHostapd) { - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pMgmt->wWPAIELen != 0) { - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); - sFrame.len += pMgmt->wWPAIELen; - } - } - } - - // Adjust the length fields - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - return pTxPacket; -} - -/*+ - * - * Routine Description: - * Constructs an association request frame - * - * - * Return Value: - * A ptr to frame or NULL on allocation failure - * - -*/ - -static PSTxMgmtPacket -s_MgrMakeAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned char *pDAddr, - unsigned short wCurrCapInfo, - unsigned short wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -) -{ - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_ASSOCREQ sFrame; - unsigned char *pbyIEs; - unsigned char *pbyRSN; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - // Setup the sFrame structure. - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN; - // format fixed field frame structure - vMgrEncodeAssocRequest(&sFrame); - // Setup the header - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCREQ) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - // Set the capability and listen interval - *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo); - *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval); - - // sFrame.len point to end of fixed field - sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); - - pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN; - pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); - pbyIEs = pMgmt->sAssocInfo.abyIEs; - memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); - pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN; - - // Copy the rate set - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - if ((pDevice->eCurrentPHYType == PHY_TYPE_11B) && (pCurrRates->len > 4)) - sFrame.len += 4 + WLAN_IEHDR_LEN; - else - sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); - - // Copy the extension rate set - if ((pDevice->eCurrentPHYType == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN); - } - - pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN; - memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); - pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN; - - // for 802.11h - if (pMgmt->b11hEnable) { - if (sFrame.pCurrPowerCap == NULL) { - sFrame.pCurrPowerCap = (PWLAN_IE_PW_CAP)(sFrame.pBuf + sFrame.len); - sFrame.len += (2 + WLAN_IEHDR_LEN); - sFrame.pCurrPowerCap->byElementID = WLAN_EID_PWR_CAPABILITY; - sFrame.pCurrPowerCap->len = 2; - CARDvGetPowerCapability(pMgmt->pAdapter, - &(sFrame.pCurrPowerCap->byMinPower), - &(sFrame.pCurrPowerCap->byMaxPower) -); - } - if (sFrame.pCurrSuppCh == NULL) { - sFrame.pCurrSuppCh = (PWLAN_IE_SUPP_CH)(sFrame.pBuf + sFrame.len); - sFrame.len += set_support_channels(pMgmt->pAdapter, (unsigned char *)sFrame.pCurrSuppCh); - } - } - - if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) && - (pMgmt->pCurrBSS != NULL)) { - /* WPA IE */ - sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len); - sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA; - sFrame.pRSNWPA->len = 16; - sFrame.pRSNWPA->abyOUI[0] = 0x00; - sFrame.pRSNWPA->abyOUI[1] = 0x50; - sFrame.pRSNWPA->abyOUI[2] = 0xf2; - sFrame.pRSNWPA->abyOUI[3] = 0x01; - sFrame.pRSNWPA->wVersion = 1; - //Group Key Cipher Suite - sFrame.pRSNWPA->abyMulticast[0] = 0x00; - sFrame.pRSNWPA->abyMulticast[1] = 0x50; - sFrame.pRSNWPA->abyMulticast[2] = 0xf2; - if (pMgmt->byCSSGK == KEY_CTL_WEP) - sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType; - else if (pMgmt->byCSSGK == KEY_CTL_TKIP) - sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP; - else - sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE; - - // Pairwise Key Cipher Suite - sFrame.pRSNWPA->wPKCount = 1; - sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00; - sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50; - sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) - sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP; - else if (pMgmt->byCSSPK == KEY_CTL_CCMP) - sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP; - else - sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; - - // Auth Key Management Suite - pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); - *pbyRSN++ = 0x01; - *pbyRSN++ = 0x00; - *pbyRSN++ = 0x00; - - *pbyRSN++ = 0x50; - *pbyRSN++ = 0xf2; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) - *pbyRSN++ = WPA_AUTH_PSK; - else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) - *pbyRSN++ = WPA_AUTH_IEEE802_1X; - else - *pbyRSN++ = WPA_NONE; - - sFrame.pRSNWPA->len += 6; - - // RSN Capabilities - - *pbyRSN++ = 0x00; - *pbyRSN++ = 0x00; - sFrame.pRSNWPA->len += 2; - - sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION - pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN); - pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - - } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && - (pMgmt->pCurrBSS != NULL)) { - unsigned int ii; - unsigned short *pwPMKID; - - // WPA IE - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - sFrame.pRSN->byElementID = WLAN_EID_RSN; - sFrame.pRSN->len = 6; //Version(2)+GK(4) - sFrame.pRSN->wVersion = 1; - //Group Key Cipher Suite - sFrame.pRSN->abyRSN[0] = 0x00; - sFrame.pRSN->abyRSN[1] = 0x0F; - sFrame.pRSN->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) - sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - else if (pMgmt->byCSSGK == KEY_CTL_TKIP) - sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP; - else - sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - - // Pairwise Key Cipher Suite - sFrame.pRSN->abyRSN[4] = 1; - sFrame.pRSN->abyRSN[5] = 0; - sFrame.pRSN->abyRSN[6] = 0x00; - sFrame.pRSN->abyRSN[7] = 0x0F; - sFrame.pRSN->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP; - else if (pMgmt->byCSSPK == KEY_CTL_CCMP) - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP; - else if (pMgmt->byCSSPK == KEY_CTL_NONE) - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - else - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - - sFrame.pRSN->len += 6; - - // Auth Key Management Suite - sFrame.pRSN->abyRSN[10] = 1; - sFrame.pRSN->abyRSN[11] = 0; - sFrame.pRSN->abyRSN[12] = 0x00; - sFrame.pRSN->abyRSN[13] = 0x0F; - sFrame.pRSN->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) - sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK; - else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) - sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - else - sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - - sFrame.pRSN->len += 6; - - // RSN Capabilities - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist) { - memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); - } else { - sFrame.pRSN->abyRSN[16] = 0; - sFrame.pRSN->abyRSN[17] = 0; - } - sFrame.pRSN->len += 2; - - if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && pDevice->bRoaming && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { - // RSN PMKID - pbyRSN = &sFrame.pRSN->abyRSN[18]; - pwPMKID = (unsigned short *)pbyRSN; // Point to PMKID count - *pwPMKID = 0; // Initialize PMKID count - pbyRSN += 2; // Point to PMKID list - for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { - if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, ETH_ALEN)) { - (*pwPMKID)++; - memcpy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16); - pbyRSN += 16; - } - } - if (*pwPMKID != 0) - sFrame.pRSN->len += (2 + (*pwPMKID)*16); - } - - sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN; - // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION - pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN; - memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN); - pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN; - } - - // Adjust the length fields - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - return pTxPacket; -} - -/*+ - * - * Routine Description: - * Constructs an re-association request frame - * - * - * Return Value: - * A ptr to frame or NULL on allocation failure - * - -*/ - -static PSTxMgmtPacket -s_MgrMakeReAssocRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned char *pDAddr, - unsigned short wCurrCapInfo, - unsigned short wListenInterval, - PWLAN_IE_SSID pCurrSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -) -{ - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_REASSOCREQ sFrame; - unsigned char *pbyIEs; - unsigned char *pbyRSN; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_REASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - /* Setup the sFrame structure. */ - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN; - - // format fixed field frame structure - vMgrEncodeReassocRequest(&sFrame); - - /* Setup the header */ - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCREQ) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pDAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - /* Set the capability and listen interval */ - *(sFrame.pwCapInfo) = cpu_to_le16(wCurrCapInfo); - *(sFrame.pwListenInterval) = cpu_to_le16(wListenInterval); - - memcpy(sFrame.pAddrCurrAP, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - /* Copy the SSID */ - /* sFrame.len point to end of fixed field */ - sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrSSID->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSSID, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); - - pMgmt->sAssocInfo.AssocInfo.RequestIELength = pCurrSSID->len + WLAN_IEHDR_LEN; - pMgmt->sAssocInfo.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); - pbyIEs = pMgmt->sAssocInfo.abyIEs; - memcpy(pbyIEs, pCurrSSID, pCurrSSID->len + WLAN_IEHDR_LEN); - pbyIEs += pCurrSSID->len + WLAN_IEHDR_LEN; - - /* Copy the rate set */ - /* sFrame.len point to end of SSID */ - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); - - // Copy the extension rate set - if ((pMgmt->eCurrentPHYMode == PHY_TYPE_11G) && (pCurrExtSuppRates->len > 0)) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN); - } - - pMgmt->sAssocInfo.AssocInfo.RequestIELength += pCurrRates->len + WLAN_IEHDR_LEN; - memcpy(pbyIEs, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN); - pbyIEs += pCurrRates->len + WLAN_IEHDR_LEN; - - if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE)) && - (pMgmt->pCurrBSS != NULL)) { - /* WPA IE */ - sFrame.pRSNWPA = (PWLAN_IE_RSN_EXT)(sFrame.pBuf + sFrame.len); - sFrame.pRSNWPA->byElementID = WLAN_EID_RSN_WPA; - sFrame.pRSNWPA->len = 16; - sFrame.pRSNWPA->abyOUI[0] = 0x00; - sFrame.pRSNWPA->abyOUI[1] = 0x50; - sFrame.pRSNWPA->abyOUI[2] = 0xf2; - sFrame.pRSNWPA->abyOUI[3] = 0x01; - sFrame.pRSNWPA->wVersion = 1; - //Group Key Cipher Suite - sFrame.pRSNWPA->abyMulticast[0] = 0x00; - sFrame.pRSNWPA->abyMulticast[1] = 0x50; - sFrame.pRSNWPA->abyMulticast[2] = 0xf2; - if (pMgmt->byCSSGK == KEY_CTL_WEP) - sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType; - else if (pMgmt->byCSSGK == KEY_CTL_TKIP) - sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP; - else - sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE; - - // Pairwise Key Cipher Suite - sFrame.pRSNWPA->wPKCount = 1; - sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00; - sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50; - sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) - sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP; - else if (pMgmt->byCSSPK == KEY_CTL_CCMP) - sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP; - else - sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; - - // Auth Key Management Suite - pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); - *pbyRSN++ = 0x01; - *pbyRSN++ = 0x00; - *pbyRSN++ = 0x00; - - *pbyRSN++ = 0x50; - *pbyRSN++ = 0xf2; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) - *pbyRSN++ = WPA_AUTH_PSK; - else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) - *pbyRSN++ = WPA_AUTH_IEEE802_1X; - else - *pbyRSN++ = WPA_NONE; - - sFrame.pRSNWPA->len += 6; - - // RSN Capabilities - *pbyRSN++ = 0x00; - *pbyRSN++ = 0x00; - sFrame.pRSNWPA->len += 2; - - sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION - pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - memcpy(pbyIEs, sFrame.pRSNWPA, sFrame.pRSNWPA->len + WLAN_IEHDR_LEN); - pbyIEs += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; - - } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && - (pMgmt->pCurrBSS != NULL)) { - unsigned int ii; - unsigned short *pwPMKID; - - /* WPA IE */ - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - sFrame.pRSN->byElementID = WLAN_EID_RSN; - sFrame.pRSN->len = 6; //Version(2)+GK(4) - sFrame.pRSN->wVersion = 1; - //Group Key Cipher Suite - sFrame.pRSN->abyRSN[0] = 0x00; - sFrame.pRSN->abyRSN[1] = 0x0F; - sFrame.pRSN->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) - sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - else if (pMgmt->byCSSGK == KEY_CTL_TKIP) - sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP; - else - sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - - // Pairwise Key Cipher Suite - sFrame.pRSN->abyRSN[4] = 1; - sFrame.pRSN->abyRSN[5] = 0; - sFrame.pRSN->abyRSN[6] = 0x00; - sFrame.pRSN->abyRSN[7] = 0x0F; - sFrame.pRSN->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP; - else if (pMgmt->byCSSPK == KEY_CTL_CCMP) - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP; - else if (pMgmt->byCSSPK == KEY_CTL_NONE) - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - else - sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - - sFrame.pRSN->len += 6; - - // Auth Key Management Suite - sFrame.pRSN->abyRSN[10] = 1; - sFrame.pRSN->abyRSN[11] = 0; - sFrame.pRSN->abyRSN[12] = 0x00; - sFrame.pRSN->abyRSN[13] = 0x0F; - sFrame.pRSN->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) - sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK; - else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) - sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - else - sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - - sFrame.pRSN->len += 6; - - // RSN Capabilities - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist) { - memcpy(&sFrame.pRSN->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); - } else { - sFrame.pRSN->abyRSN[16] = 0; - sFrame.pRSN->abyRSN[17] = 0; - } - sFrame.pRSN->len += 2; - - if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && pDevice->bRoaming && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { - // RSN PMKID - pbyRSN = &sFrame.pRSN->abyRSN[18]; - pwPMKID = (unsigned short *)pbyRSN; // Point to PMKID count - *pwPMKID = 0; // Initialize PMKID count - pbyRSN += 2; // Point to PMKID list - for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { - if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, ETH_ALEN)) { - (*pwPMKID)++; - memcpy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16); - pbyRSN += 16; - } - } - - if (*pwPMKID != 0) - sFrame.pRSN->len += (2 + (*pwPMKID) * 16); - } - - sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN; - // copy to AssocInfo. for OID_802_11_ASSOCIATION_INFORMATION - pMgmt->sAssocInfo.AssocInfo.RequestIELength += sFrame.pRSN->len + WLAN_IEHDR_LEN; - memcpy(pbyIEs, sFrame.pRSN, sFrame.pRSN->len + WLAN_IEHDR_LEN); - pbyIEs += sFrame.pRSN->len + WLAN_IEHDR_LEN; - } - - /* Adjust the length fields */ - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - return pTxPacket; -} - -/*+ - * - * Routine Description: - * Constructs an assoc-response frame - * - * - * Return Value: - * PTR to frame; or NULL on allocation failure - * - -*/ - -static PSTxMgmtPacket -s_MgrMakeAssocResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wAssocStatus, - unsigned short wAssocAID, - unsigned char *pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -) -{ - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_ASSOCRESP sFrame; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - // Setup the sFrame structure - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; - vMgrEncodeAssocResponse(&sFrame); - // Setup the header - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ASSOCRESP) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); - *sFrame.pwStatus = cpu_to_le16(wAssocStatus); - *sFrame.pwAid = cpu_to_le16((unsigned short)(wAssocAID | BIT14 | BIT15)); - - // Copy the rate set - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, - pCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN -); - - if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, - pCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN -); - } - - // Adjust the length fields - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - return pTxPacket; -} - -/*+ - * - * Routine Description: - * Constructs an reassoc-response frame - * - * - * Return Value: - * PTR to frame; or NULL on allocation failure - * - -*/ - -static PSTxMgmtPacket -s_MgrMakeReAssocResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned short wCurrCapInfo, - unsigned short wAssocStatus, - unsigned short wAssocAID, - unsigned char *pDstAddr, - PWLAN_IE_SUPP_RATES pCurrSuppRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -) -{ - PSTxMgmtPacket pTxPacket = NULL; - WLAN_FR_REASSOCRESP sFrame; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - // Setup the sFrame structure - sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; - sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; - vMgrEncodeReassocResponse(&sFrame); - // Setup the header - sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( - ( - WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_REASSOCRESP) -)); - memcpy(sFrame.pHdr->sA3.abyAddr1, pDstAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); - memcpy(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); - *sFrame.pwStatus = cpu_to_le16(wAssocStatus); - *sFrame.pwAid = cpu_to_le16((unsigned short)(wAssocAID | BIT14 | BIT15)); - - // Copy the rate set - sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pSuppRates, - pCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrSuppRates)->len + WLAN_IEHDR_LEN -); - - if (((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len != 0) { - sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len); - sFrame.len += ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - memcpy(sFrame.pExtSuppRates, - pCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN -); - } - - // Adjust the length fields - pTxPacket->cbMPDULen = sFrame.len; - pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; - - return pTxPacket; -} - -/*+ - * - * Routine Description: - * Handles probe response management frames. - * - * - * Return Value: - * none. - * - -*/ - -static -void -s_vMgrRxProbeResponse( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -) -{ - PKnownBSS pBSSList = NULL; - WLAN_FR_PROBERESP sFrame; - unsigned char byCurrChannel = pRxPacket->byRxChannel; - ERPObject sERP; - unsigned char byIEChannel = 0; - bool bChannelHit = true; - - memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP)); - // decode the frame - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - vMgrDecodeProbeResponse(&sFrame); - - if ((sFrame.pqwTimestamp == NULL) || - (sFrame.pwBeaconInterval == NULL) || - (sFrame.pwCapInfo == NULL) || - (sFrame.pSSID == NULL) || - (sFrame.pSuppRates == NULL)) { - pr_debug("Probe resp:Fail addr:[%p]\n", - pRxPacket->p80211Header); - DBG_PORT80(0xCC); - return; - } - - if (sFrame.pSSID->len == 0) - pr_debug("Rx Probe resp: SSID len = 0\n"); - - if (sFrame.pDSParms != NULL) { - if (byCurrChannel > CB_MAX_CHANNEL_24G) { - // channel remapping to - byIEChannel = get_channel_mapping(pMgmt->pAdapter, sFrame.pDSParms->byCurrChannel, PHY_TYPE_11A); - } else { - byIEChannel = sFrame.pDSParms->byCurrChannel; - } - if (byCurrChannel != byIEChannel) { - // adjust channel info. bcs we rcv adjacent channel packets - bChannelHit = false; - byCurrChannel = byIEChannel; - } - } else { - // no DS channel info - bChannelHit = true; - } - -//2008-0730-01by MikeLiu - if (ChannelExceedZoneType(pDevice, byCurrChannel)) - return; - - if (sFrame.pERP != NULL) { - sERP.byERP = sFrame.pERP->byContext; - sERP.bERPExist = true; - } else { - sERP.bERPExist = false; - sERP.byERP = 0; - } - - // update or insert the bss - pBSSList = BSSpAddrIsInBSSList((void *)pDevice, sFrame.pHdr->sA3.abyAddr3, sFrame.pSSID); - if (pBSSList) { - BSSbUpdateToBSSList((void *)pDevice, - *sFrame.pqwTimestamp, - *sFrame.pwBeaconInterval, - *sFrame.pwCapInfo, - byCurrChannel, - bChannelHit, - sFrame.pSSID, - sFrame.pSuppRates, - sFrame.pExtSuppRates, - &sERP, - sFrame.pRSN, - sFrame.pRSNWPA, - sFrame.pIE_Country, - sFrame.pIE_Quiet, - pBSSList, - sFrame.len - WLAN_HDR_ADDR3_LEN, - sFrame.pHdr->sA4.abyAddr4, // payload of probresponse - (void *)pRxPacket -); - } else { - pr_debug("Probe resp/insert: RxChannel = : %d\n", - byCurrChannel); - BSSbInsertToBSSList((void *)pDevice, - sFrame.pHdr->sA3.abyAddr3, - *sFrame.pqwTimestamp, - *sFrame.pwBeaconInterval, - *sFrame.pwCapInfo, - byCurrChannel, - sFrame.pSSID, - sFrame.pSuppRates, - sFrame.pExtSuppRates, - &sERP, - sFrame.pRSN, - sFrame.pRSNWPA, - sFrame.pIE_Country, - sFrame.pIE_Quiet, - sFrame.len - WLAN_HDR_ADDR3_LEN, - sFrame.pHdr->sA4.abyAddr4, // payload of beacon - (void *)pRxPacket -); - } -} - -/*+ - * - * Routine Description:(AP)or(Ad-hoc STA) - * Handles probe request management frames. - * - * - * Return Value: - * none. - * - -*/ - -static -void -s_vMgrRxProbeRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -) -{ - WLAN_FR_PROBEREQ sFrame; - CMD_STATUS Status; - PSTxMgmtPacket pTxPacket; - unsigned char byPHYType = BB_TYPE_11B; - - // STA in Ad-hoc mode: when latest TBTT beacon transmit success, - // STA have to response this request. - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || - ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && pDevice->bBeaconSent)) { - memset(&sFrame, 0, sizeof(WLAN_FR_PROBEREQ)); - // decode the frame - sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - vMgrDecodeProbeRequest(&sFrame); - - if (sFrame.pSSID->len != 0) { - if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) - return; - if (memcmp(sFrame.pSSID->abySSID, - ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, - ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) != 0) { - return; - } - } - - if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL)) - byPHYType = BB_TYPE_11G; - - // Probe response reply.. - pTxPacket = s_MgrMakeProbeResponse - ( - pDevice, - pMgmt, - pMgmt->wCurrCapInfo, - pMgmt->wCurrBeaconPeriod, - pMgmt->uCurrChannel, - 0, - sFrame.pHdr->sA3.abyAddr2, - (PWLAN_IE_SSID)pMgmt->abyCurrSSID, - (unsigned char *)pMgmt->abyCurrBSSID, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - byPHYType -); - if (pTxPacket != NULL) { - /* send the frame */ - Status = csMgmt_xmit(pDevice, pTxPacket); - if (Status != CMD_STATUS_PENDING) - pr_debug("Mgt:Probe response tx failed\n"); - } - } -} - -/*+ - * - * Routine Description: - * - * Entry point for the reception and handling of 802.11 management - * frames. Makes a determination of the frame type and then calls - * the appropriate function. - * - * - * Return Value: - * none. - * - -*/ - -void -vMgrRxManagePacket( - void *hDeviceContext, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -) -{ - struct vnt_private *pDevice = hDeviceContext; - bool bInScan = false; - unsigned int uNodeIndex = 0; - NODE_STATE eNodeState = 0; - CMD_STATUS Status; - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) - eNodeState = pMgmt->sNodeDBTable[uNodeIndex].eNodeState; - } - - switch (WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl))) { - case WLAN_FSTYPE_ASSOCREQ: - // Frame Clase = 2 - pr_debug("rx assocreq\n"); - if (eNodeState < NODE_AUTH) { - // send deauth notification - // reason = (6) class 2 received from nonauth sta - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - pRxPacket->p80211Header->sA3.abyAddr2, - (6), - &Status -); - pr_debug("wmgr: send vMgrDeAuthenBeginSta 1\n"); - } else { - s_vMgrRxAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex); - } - break; - - case WLAN_FSTYPE_ASSOCRESP: - // Frame Clase = 2 - pr_debug("rx assocresp1\n"); - s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, false); - pr_debug("rx assocresp2\n"); - break; - - case WLAN_FSTYPE_REASSOCREQ: - // Frame Clase = 2 - pr_debug("rx reassocreq\n"); - // Todo: reassoc - if (eNodeState < NODE_AUTH) { - // send deauth notification - // reason = (6) class 2 received from nonauth sta - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - pRxPacket->p80211Header->sA3.abyAddr2, - (6), - &Status -); - pr_debug("wmgr: send vMgrDeAuthenBeginSta 2\n"); - - } - s_vMgrRxReAssocRequest(pDevice, pMgmt, pRxPacket, uNodeIndex); - break; - - case WLAN_FSTYPE_REASSOCRESP: - // Frame Clase = 2 - pr_debug("rx reassocresp\n"); - s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, true); - break; - - case WLAN_FSTYPE_PROBEREQ: - // Frame Clase = 0 - s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket); - break; - - case WLAN_FSTYPE_PROBERESP: - // Frame Clase = 0 - pr_debug("rx proberesp\n"); - - s_vMgrRxProbeResponse(pDevice, pMgmt, pRxPacket); - break; - - case WLAN_FSTYPE_BEACON: - // Frame Clase = 0 - if (pMgmt->eScanState != WMAC_NO_SCANNING) - bInScan = true; - - s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan); - break; - - case WLAN_FSTYPE_ATIM: - // Frame Clase = 1 - pr_debug("rx atim\n"); - break; - - case WLAN_FSTYPE_DISASSOC: - // Frame Clase = 2 - pr_debug("rx disassoc\n"); - if (eNodeState < NODE_AUTH) { - // send deauth notification - // reason = (6) class 2 received from nonauth sta - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - pRxPacket->p80211Header->sA3.abyAddr2, - (6), - &Status -); - pr_debug("wmgr: send vMgrDeAuthenBeginSta 3\n"); - } - s_vMgrRxDisassociation(pDevice, pMgmt, pRxPacket); - break; - - case WLAN_FSTYPE_AUTHEN: - // Frame Clase = 1 - pr_debug("rx authen\n"); - s_vMgrRxAuthentication(pDevice, pMgmt, pRxPacket); - break; - - case WLAN_FSTYPE_DEAUTHEN: - // Frame Clase = 1 - pr_debug("rx deauthen\n"); - s_vMgrRxDeauthentication(pDevice, pMgmt, pRxPacket); - break; - - default: - pr_debug("rx unknown mgmt\n"); - } -} - -/*+ - * - * Routine Description: - * - * - * Prepare beacon to send - * - * Return Value: - * true if success; false if failed. - * - -*/ -bool -bMgrPrepareBeaconToSend( - void *hDeviceContext, - PSMgmtObject pMgmt -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSTxMgmtPacket pTxPacket; - - if (pDevice->bEncryptionEnable || pDevice->bEnable8021x) - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - else - pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); - - pTxPacket = s_MgrMakeBeacon - ( - pDevice, - pMgmt, - pMgmt->wCurrCapInfo, - pMgmt->wCurrBeaconPeriod, - pMgmt->uCurrChannel, - pMgmt->wCurrATIMWindow, - (PWLAN_IE_SSID)pMgmt->abyCurrSSID, - (unsigned char *)pMgmt->abyCurrBSSID, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates -); - - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && - (pMgmt->abyCurrBSSID[0] == 0)) - return false; - - csBeacon_xmit(pDevice, pTxPacket); - - return true; -} - -/*+ - * - * Routine Description: - * - * Log a warning message based on the contents of the Status - * Code field of an 802.11 management frame. Defines are - * derived from 802.11-1997 SPEC. - * - * Return Value: - * none. - * - -*/ -static -void -s_vMgrLogStatus( - PSMgmtObject pMgmt, - unsigned short wStatus -) -{ - switch (wStatus) { - case WLAN_MGMT_STATUS_UNSPEC_FAILURE: - pr_info("Status code == Unspecified error\n"); - break; - case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED: - pr_info("Status code == Can't support all requested capabilities\n"); - break; - case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC: - pr_info("Status code == Reassoc denied, can't confirm original Association\n"); - break; - case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC: - pr_info("Status code == Assoc denied, undefine in spec\n"); - break; - case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG: - pr_info("Status code == Peer doesn't support authen algorithm\n"); - break; - case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ: - pr_info("Status code == Authen frame received out of sequence\n"); - break; - case WLAN_MGMT_STATUS_CHALLENGE_FAIL: - pr_info("Status code == Authen rejected, challenge failure\n"); - break; - case WLAN_MGMT_STATUS_AUTH_TIMEOUT: - pr_info("Status code == Authen rejected, timeout waiting for next frame\n"); - break; - case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY: - pr_info("Status code == Assoc denied, AP too busy\n"); - break; - case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES: - pr_info("Status code == Assoc denied, we haven't enough basic rates\n"); - break; - case WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE: - pr_info("Status code == Assoc denied, we do not support short preamble\n"); - break; - case WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC: - pr_info("Status code == Assoc denied, we do not support PBCC\n"); - break; - case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY: - pr_info("Status code == Assoc denied, we do not support channel agility\n"); - break; - default: - pr_info("Unknown status code %d\n", wStatus); - break; - } -} - -/* - * - * Description: - * Add BSSID in PMKID Candidate list. - * - * Parameters: - * In: - * hDeviceContext - device structure point - * pbyBSSID - BSSID address for adding - * wRSNCap - BSS's RSN capability - * Out: - * none - * - * Return Value: none. - * - -*/ -bool -bAdd_PMKID_Candidate( - void *hDeviceContext, - unsigned char *pbyBSSID, - PSRSNCapObject psRSNCapObj -) -{ - struct vnt_private *pDevice = hDeviceContext; - struct pmkid_candidate *pCandidateList; - unsigned int ii = 0; - - pr_debug("bAdd_PMKID_Candidate START: (%d)\n", - (int)pDevice->gsPMKIDCandidate.NumCandidates); - - if ((pDevice == NULL) || (pbyBSSID == NULL) || (psRSNCapObj == NULL)) - return false; - - if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) - return false; - - // Update Old Candidate - for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { - pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; - if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { - if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0)) - pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - else - pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - - return true; - } - } - - // New Candidate - pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; - if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0)) - pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - else - pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - - ether_addr_copy(pCandidateList->BSSID, pbyBSSID); - pDevice->gsPMKIDCandidate.NumCandidates++; - pr_debug("NumCandidates:%d\n", - (int)pDevice->gsPMKIDCandidate.NumCandidates); - return true; -} - -/* - * - * Description: - * Flush PMKID Candidate list. - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - * - -*/ -void -vFlush_PMKID_Candidate( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - - if (pDevice == NULL) - return; - - memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); -} - -static bool -s_bCipherMatch( - PKnownBSS pBSSNode, - NDIS_802_11_ENCRYPTION_STATUS EncStatus, - unsigned char *pbyCCSPK, - unsigned char *pbyCCSGK -) -{ - unsigned char byMulticastCipher = KEY_CTL_INVALID; - unsigned char byCipherMask = 0x00; - int i; - - if (pBSSNode == NULL) - return false; - - // check cap. of BSS - if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && - (EncStatus == Ndis802_11Encryption1Enabled)) { - // default is WEP only - byMulticastCipher = KEY_CTL_WEP; - } - - if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && - pBSSNode->bWPA2Valid && - //20080123-01, by Einsn Liu - ((EncStatus == Ndis802_11Encryption3Enabled) || (EncStatus == Ndis802_11Encryption2Enabled))) { - //WPA2 - // check Group Key Cipher - if ((pBSSNode->byCSSGK == WLAN_11i_CSS_WEP40) || - (pBSSNode->byCSSGK == WLAN_11i_CSS_WEP104)) { - byMulticastCipher = KEY_CTL_WEP; - } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_TKIP) { - byMulticastCipher = KEY_CTL_TKIP; - } else if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) { - byMulticastCipher = KEY_CTL_CCMP; - } else { - byMulticastCipher = KEY_CTL_INVALID; - } - - // check Pairwise Key Cipher - for (i = 0; i < pBSSNode->wCSSPKCount; i++) { - if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) || - (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) { - // this should not happen as defined 802.11i - byCipherMask |= 0x01; - } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) { - byCipherMask |= 0x02; - } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) { - byCipherMask |= 0x04; - } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) { - // use group key only ignore all others - byCipherMask = 0; - i = pBSSNode->wCSSPKCount; - } - } - - } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && - pBSSNode->bWPAValid && - ((EncStatus == Ndis802_11Encryption3Enabled) || (EncStatus == Ndis802_11Encryption2Enabled))) { - //WPA - // check Group Key Cipher - if ((pBSSNode->byGKType == WPA_WEP40) || - (pBSSNode->byGKType == WPA_WEP104)) { - byMulticastCipher = KEY_CTL_WEP; - } else if (pBSSNode->byGKType == WPA_TKIP) { - byMulticastCipher = KEY_CTL_TKIP; - } else if (pBSSNode->byGKType == WPA_AESCCMP) { - byMulticastCipher = KEY_CTL_CCMP; - } else { - byMulticastCipher = KEY_CTL_INVALID; - } - - // check Pairwise Key Cipher - for (i = 0; i < pBSSNode->wPKCount; i++) { - if (pBSSNode->abyPKType[i] == WPA_TKIP) { - byCipherMask |= 0x02; - } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) { - byCipherMask |= 0x04; - } else if (pBSSNode->abyPKType[i] == WPA_NONE) { - // use group key only ignore all others - byCipherMask = 0; - i = pBSSNode->wPKCount; - } - } - } - - pr_debug("%d, %d, %d, %d, EncStatus:%d\n", - byMulticastCipher, byCipherMask, - pBSSNode->bWPAValid, pBSSNode->bWPA2Valid, EncStatus); - - // mask our cap. with BSS - if (EncStatus == Ndis802_11Encryption1Enabled) { - // For supporting Cisco migration mode, don't care pairwise key cipher - if ((byMulticastCipher == KEY_CTL_WEP) && - (byCipherMask == 0)) { - *pbyCCSGK = KEY_CTL_WEP; - *pbyCCSPK = KEY_CTL_NONE; - return true; - } else { - return false; - } - - } else if (EncStatus == Ndis802_11Encryption2Enabled) { - if ((byMulticastCipher == KEY_CTL_TKIP) && - (byCipherMask == 0)) { - *pbyCCSGK = KEY_CTL_TKIP; - *pbyCCSPK = KEY_CTL_NONE; - return true; - } else if ((byMulticastCipher == KEY_CTL_WEP) && - ((byCipherMask & 0x02) != 0)) { - *pbyCCSGK = KEY_CTL_WEP; - *pbyCCSPK = KEY_CTL_TKIP; - return true; - } else if ((byMulticastCipher == KEY_CTL_TKIP) && - ((byCipherMask & 0x02) != 0)) { - *pbyCCSGK = KEY_CTL_TKIP; - *pbyCCSPK = KEY_CTL_TKIP; - return true; - } else { - return false; - } - } else if (EncStatus == Ndis802_11Encryption3Enabled) { - if ((byMulticastCipher == KEY_CTL_CCMP) && - (byCipherMask == 0)) { - // When CCMP is enable, "Use group cipher suite" shall not be a valid option. - return false; - } else if ((byMulticastCipher == KEY_CTL_WEP) && - ((byCipherMask & 0x04) != 0)) { - *pbyCCSGK = KEY_CTL_WEP; - *pbyCCSPK = KEY_CTL_CCMP; - return true; - } else if ((byMulticastCipher == KEY_CTL_TKIP) && - ((byCipherMask & 0x04) != 0)) { - *pbyCCSGK = KEY_CTL_TKIP; - *pbyCCSPK = KEY_CTL_CCMP; - return true; - } else if ((byMulticastCipher == KEY_CTL_CCMP) && - ((byCipherMask & 0x04) != 0)) { - *pbyCCSGK = KEY_CTL_CCMP; - *pbyCCSPK = KEY_CTL_CCMP; - return true; - } else { - return false; - } - } - return true; -} diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index a00652bfec4e..4b7196bd1607 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -314,107 +314,4 @@ typedef struct tagSMgmtObject { struct sk_buff skb; } SMgmtObject, *PSMgmtObject; -/*--------------------- Export Macros ------------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -void -vMgrObjectInit( - void *hDeviceContext -); - -void -vMgrTimerInit( - void *hDeviceContext -); - -void -vMgrObjectReset( - void *hDeviceContext -); - -void -vMgrAssocBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus -); - -void -vMgrReAssocBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus -); - -void -vMgrDisassocBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - unsigned char *abyDestAddress, - unsigned short wReason, - PCMD_STATUS pStatus -); - -void -vMgrAuthenBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - PCMD_STATUS pStatus -); - -void -vMgrCreateOwnIBSS( - void *hDeviceContext, - PCMD_STATUS pStatus -); - -void -vMgrJoinBSSBegin( - void *hDeviceContext, - PCMD_STATUS pStatus -); - -void -vMgrRxManagePacket( - void *hDeviceContext, - PSMgmtObject pMgmt, - PSRxMgmtPacket pRxPacket -); - -/* - void - vMgrScanBegin( - void *hDeviceContext, - PCMD_STATUS pStatus -); -*/ - -void -vMgrDeAuthenBeginSta( - void *hDeviceContext, - PSMgmtObject pMgmt, - unsigned char *abyDestAddress, - unsigned short wReason, - PCMD_STATUS pStatus -); - -bool -bMgrPrepareBeaconToSend( - void *hDeviceContext, - PSMgmtObject pMgmt -); - -bool -bAdd_PMKID_Candidate( - void *hDeviceContext, - unsigned char *pbyBSSID, - PSRSNCapObject psRSNCapObj -); - -void -vFlush_PMKID_Candidate( - void *hDeviceContext -); - #endif // __WMGR_H__ -- cgit v1.2.3-59-g8ed1b From 8d0126b1f06a8921a6fe669870de1c5644a276f4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:29 +0000 Subject: staging: vt6655: dead code remove wcmd.c header will be removed later. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/bssdb.c | 7 - drivers/staging/vt6655/wcmd.c | 958 ---------------------------------------- drivers/staging/vt6655/wcmd.h | 32 -- 4 files changed, 998 deletions(-) delete mode 100644 drivers/staging/vt6655/wcmd.c diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index fa154ef10edc..271ca9df43a9 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -9,7 +9,6 @@ vt6655_stage-y += device_main.o \ baseband.o \ wctl.o \ 80211mgr.o \ - wcmd.o \ bssdb.o \ rxtx.o \ dpc.o \ diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 2b508ff5f492..abe38e1f34eb 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -1092,7 +1092,6 @@ BSSvSecondCallBack( if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) && (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) { pDevice->byBBVGANew = pDevice->abyBBVGA[0]; - bScheduleCommand((void *)pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL); } if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) { @@ -1151,8 +1150,6 @@ BSSvSecondCallBack( pr_debug("Roaming ...\n"); BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); pMgmt->eScanType = WMAC_SCAN_ACTIVE; - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID); pDevice->uAutoReConnectTime = 0; } } @@ -1166,8 +1163,6 @@ BSSvSecondCallBack( } else { pr_info("Adhoc re-scanning ...\n"); pMgmt->eScanType = WMAC_SCAN_ACTIVE; - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); pDevice->uAutoReConnectTime = 0; } } @@ -1430,8 +1425,6 @@ void s_vCheckSensitivity( } if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { pDevice->uBBVGADiffCount++; - if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) - bScheduleCommand((void *)pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL); } else { pDevice->uBBVGADiffCount = 0; } diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c deleted file mode 100644 index 3c980806a515..000000000000 --- a/drivers/staging/vt6655/wcmd.c +++ /dev/null @@ -1,958 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wcmd.c - * - * Purpose: Handles the management command interface functions - * - * Author: Lyndon Chen - * - * Date: May 8, 2003 - * - * Functions: - * s_vProbeChannel - Active scan channel - * s_MgrMakeProbeRequest - Make ProbeRequest packet - * CommandTimer - Timer function to handle command - * s_bCommandComplete - Command Complete function - * bScheduleCommand - Push Command and wait Command Scheduler to do - * vCommandTimer- Command call back functions - * vCommandTimerWait- Call back timer - * bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue - * - * Revision History: - * - */ - -#include "ttype.h" -#include "tmacro.h" -#include "device.h" -#include "mac.h" -#include "card.h" -#include "80211hdr.h" -#include "wcmd.h" -#include "wmgr.h" -#include "power.h" -#include "wctl.h" -#include "baseband.h" -#include "rxtx.h" -#include "rf.h" -#include "iowpa.h" -#include "channel.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -static -void -s_vProbeChannel( - struct vnt_private *pDevice -); - -static -PSTxMgmtPacket -s_MgrMakeProbeRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned char *pScanBSSID, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates -); - -static -bool -s_bCommandComplete( - struct vnt_private *pDevice -); - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/* - * Description: - * Stop AdHoc beacon during scan process - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * Out: - * none - * - * Return Value: none - * - */ -static -void -vAdHocBeaconStop(struct vnt_private *pDevice) -{ - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - bool bStop; - - /* - * temporarily stop Beacon packet for AdHoc Server - * if all of the following conditions are met: - * (1) STA is in AdHoc mode - * (2) VT3253 is programmed as automatic Beacon Transmitting - * (3) One of the following conditions is met - * (3.1) AdHoc channel is in B/G band and the - * current scan channel is in A band - * or - * (3.2) AdHoc channel is in A mode - */ - bStop = false; - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && - (pMgmt->eCurrState >= WMAC_STATE_STARTED)) { - if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) && - (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) { - bStop = true; - } - if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G) - bStop = true; - - } - - if (bStop) - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); -} /* vAdHocBeaconStop */ - -/* - * Description: - * Restart AdHoc beacon after scan process complete - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * Out: - * none - * - * Return Value: none - * - */ -static -void -vAdHocBeaconRestart(struct vnt_private *pDevice) -{ - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - /* - * Restart Beacon packet for AdHoc Server - * if all of the following coditions are met: - * (1) STA is in AdHoc mode - * (2) VT3253 is programmed as automatic Beacon Transmitting - */ - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && - (pMgmt->eCurrState >= WMAC_STATE_STARTED)) { - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); - } -} - -/*+ - * - * Routine Description: - * Prepare and send probe request management frames. - * - * - * Return Value: - * none. - * - -*/ - -static -void -s_vProbeChannel( - struct vnt_private *pDevice -) -{ - //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M - unsigned char abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; - unsigned char abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; - //6M, 9M, 12M, 48M - unsigned char abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; - unsigned char abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - unsigned char *pbyRate; - PSTxMgmtPacket pTxPacket; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int ii; - - if (pDevice->eCurrentPHYType == PHY_TYPE_11A) - pbyRate = &abyCurrSuppRatesA[0]; - else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) - pbyRate = &abyCurrSuppRatesB[0]; - else - pbyRate = &abyCurrSuppRatesG[0]; - - // build an assocreq frame and send it - pTxPacket = s_MgrMakeProbeRequest - ( - pDevice, - pMgmt, - pMgmt->abyScanBSSID, - (PWLAN_IE_SSID)pMgmt->abyScanSSID, - (PWLAN_IE_SUPP_RATES)pbyRate, - (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG - ); - - if (pTxPacket != NULL) { - for (ii = 0; ii < 2; ii++) { - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) - pr_debug("Probe request sending fail..\n"); - else - pr_debug("Probe request is sending..\n"); - } - } -} - -/*+ - * - * Routine Description: - * Constructs an probe request frame - * - * - * Return Value: - * A ptr to Tx frame or NULL on allocation failure - * - -*/ - -static PSTxMgmtPacket -s_MgrMakeProbeRequest( - struct vnt_private *pDevice, - PSMgmtObject pMgmt, - unsigned char *pScanBSSID, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pCurrRates, - PWLAN_IE_SUPP_RATES pCurrExtSuppRates - -) -{ - PSTxMgmtPacket pTxPacket = NULL; - - pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - - return pTxPacket; -} - -void -vCommandTimerWait( - void *hDeviceContext, - unsigned int MSecond -) -{ - struct vnt_private *pDevice = hDeviceContext; - - init_timer(&pDevice->sTimerCommand); - pDevice->sTimerCommand.data = (unsigned long) pDevice; - pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; - // RUN_AT :1 msec ~= (HZ/1024) - pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10); - add_timer(&pDevice->sTimerCommand); -} - -void -vCommandTimer( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - PWLAN_IE_SSID pItemSSID; - PWLAN_IE_SSID pItemSSIDCurr; - unsigned int ii; - unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - struct sk_buff *skb; - - if (pDevice->dwDiagRefCount != 0) - return; - if (!pDevice->bCmdRunning) - return; - - spin_lock_irq(&pDevice->lock); - - switch (pDevice->eCommandState) { - case WLAN_CMD_SCAN_START: - - pDevice->byReAssocCount = 0; - if (pDevice->bRadioOff) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } - - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - s_bCommandComplete(pDevice); - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_AP); - spin_unlock_irq(&pDevice->lock); - return; - } - - pr_debug("eCommandState= WLAN_CMD_SCAN_START\n"); - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID; - // wait all Data TD complete - if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) { - spin_unlock_irq(&pDevice->lock); - vCommandTimerWait((void *)pDevice, 10); - return; - } - - if (pMgmt->uScanChannel == 0) { - pMgmt->uScanChannel = pDevice->byMinChannel; - // Set Baseband to be more sensitive. - - } - if (pMgmt->uScanChannel > pDevice->byMaxChannel) { - pMgmt->eScanState = WMAC_NO_SCANNING; - - // Set Baseband's sensitivity back. - // Set channel back - set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel); - pr_debug("Scanning, set back to channel: [%d]\n", - pMgmt->uCurrChannel); - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_ADHOC); - else - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_STATION); - - vAdHocBeaconRestart(pDevice); - s_bCommandComplete(pDevice); - - } else { -//2008-8-4 by chester - if (!is_channel_valid(pMgmt->uScanChannel)) { - pr_debug("Invalid channel pMgmt->uScanChannel = %d\n", - pMgmt->uScanChannel); - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } - if (pMgmt->uScanChannel == pDevice->byMinChannel) { - pMgmt->abyScanBSSID[0] = 0xFF; - pMgmt->abyScanBSSID[1] = 0xFF; - pMgmt->abyScanBSSID[2] = 0xFF; - pMgmt->abyScanBSSID[3] = 0xFF; - pMgmt->abyScanBSSID[4] = 0xFF; - pMgmt->abyScanBSSID[5] = 0xFF; - pItemSSID->byElementID = WLAN_EID_SSID; - pMgmt->eScanState = WMAC_IS_SCANNING; - - } - - vAdHocBeaconStop(pDevice); - - if (set_channel(pMgmt->pAdapter, pMgmt->uScanChannel)) - pr_debug("SCAN Channel: %d\n", - pMgmt->uScanChannel); - else - pr_debug("SET SCAN Channel Fail: %d\n", - pMgmt->uScanChannel); - - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_UNSPECIFIED); - pMgmt->uScanChannel++; -//2008-8-4 by chester - if (!is_channel_valid(pMgmt->uScanChannel) && - pMgmt->uScanChannel <= pDevice->byMaxChannel) { - pMgmt->uScanChannel = pDevice->byMaxChannel + 1; - pMgmt->eCommandState = WLAN_CMD_SCAN_END; - - } - - if (!pMgmt->b11hEnable || - (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) { - s_vProbeChannel(pDevice); - spin_unlock_irq(&pDevice->lock); - vCommandTimerWait((void *)pDevice, WCMD_ACTIVE_SCAN_TIME); - return; - } else { - spin_unlock_irq(&pDevice->lock); - vCommandTimerWait((void *)pDevice, WCMD_PASSIVE_SCAN_TIME); - return; - } - - } - - break; - - case WLAN_CMD_SCAN_END: - - // Set Baseband's sensitivity back. - // Set channel back - set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel); - pr_debug("Scanning, set back to channel: [%d]\n", - pMgmt->uCurrChannel); - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_ADHOC); - else - CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, NL80211_IFTYPE_STATION); - - pMgmt->eScanState = WMAC_NO_SCANNING; - vAdHocBeaconRestart(pDevice); -//2008-0409-07, by Einsn Liu -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - if (pMgmt->eScanType == WMAC_SCAN_PASSIVE) { - //send scan event to wpa_Supplicant - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(wrqu)); - wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL); - } -#endif - 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; - } else { - pr_debug("Send Disassociation Packet..\n"); - // reason = 8 : disassoc because sta has left - pDevice->bLinkPass = false; - // unlock command busy - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - pItemSSID->len = 0; - memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN); - pMgmt->eCurrState = WMAC_STATE_IDLE; - pMgmt->sNodeDBTable[0].bActive = false; - } - netif_stop_queue(pDevice->dev); - pDevice->eCommandState = WLAN_DISASSOCIATE_WAIT; - // wait all Control TD complete - if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) { - vCommandTimerWait((void *)pDevice, 10); - spin_unlock_irq(&pDevice->lock); - return; - } - pr_debug(" CARDbRadioPowerOff\n"); - //2008-09-02 by chester - s_bCommandComplete(pDevice); - break; - - case WLAN_DISASSOCIATE_WAIT: - // wait all Control TD complete - if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) { - vCommandTimerWait((void *)pDevice, 10); - spin_unlock_irq(&pDevice->lock); - return; - } -//2008-09-02 by chester - s_bCommandComplete(pDevice); - break; - - case WLAN_CMD_SSID_START: - pDevice->byReAssocCount = 0; - if (pDevice->bRadioOff) { - s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); - return; - } - pr_debug("chester-abyDesireSSID=%s\n", ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID); - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; - pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - pr_debug(" cmd: desire ssid = %s\n", pItemSSID->abySSID); - pr_debug(" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID); - - if (pMgmt->eCurrState == WMAC_STATE_ASSOC) { - pr_debug(" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n"); - pr_debug(" pItemSSID->len =%d\n", pItemSSID->len); - pr_debug(" pItemSSIDCurr->len = %d\n", - pItemSSIDCurr->len); - pr_debug(" desire ssid = %s\n", pItemSSID->abySSID); - pr_debug(" curr ssid = %s\n", pItemSSIDCurr->abySSID); - } - - 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; - } - } - - netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = false; - } - // set initial state - pMgmt->eCurrState = WMAC_STATE_IDLE; - pMgmt->eCurrMode = WMAC_MODE_STANDBY; - PSvDisablePowerSaving((void *)pDevice); - BSSvClearNodeDBTable(pDevice, 0); - - // if Infra mode - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) { - // Call mgr to begin the deauthentication - // reason = (3) because sta has left ESS - - // Call mgr to begin the authentication - } - // if Adhoc mode - else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { - if (netif_queue_stopped(pDevice->dev)) - netif_wake_queue(pDevice->dev); - - pDevice->bLinkPass = true; - - pMgmt->sNodeDBTable[0].bActive = true; - pMgmt->sNodeDBTable[0].uInActiveCount = 0; - bClearBSSID_SCAN(pDevice); - } else { - // start own IBSS - - BSSvAddMulticastNode(pDevice); - } - } - // if SSID not found - else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) { - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA || - pMgmt->eConfigMode == WMAC_CONFIG_AUTO) { - // start own IBSS - - BSSvAddMulticastNode(pDevice); - if (netif_queue_stopped(pDevice->dev)) - netif_wake_queue(pDevice->dev); - - pDevice->bLinkPass = true; - } else { - pr_debug("Disconnect SSID none\n"); -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - { - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - pr_debug("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } -#endif - - } - } - s_bCommandComplete(pDevice); - break; - - case WLAN_AUTHENTICATE_WAIT: - pr_debug("eCommandState == WLAN_AUTHENTICATE_WAIT\n"); - if (pMgmt->eCurrState == WMAC_STATE_AUTH) { - // Call mgr to begin the association - pDevice->byLinkWaitCount = 0; - pr_debug("eCurrState == WMAC_STATE_AUTH\n"); - } - - else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) { - pr_debug("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n"); - } else if (pDevice->byLinkWaitCount <= 4) { //mike add:wait another 2 sec if authenticated_frame delay! - pDevice->byLinkWaitCount++; - pr_debug("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); - spin_unlock_irq(&pDevice->lock); - vCommandTimerWait((void *)pDevice, AUTHENTICATE_TIMEOUT/2); - return; - } - pDevice->byLinkWaitCount = 0; - s_bCommandComplete(pDevice); - break; - - case WLAN_ASSOCIATE_WAIT: - if (pMgmt->eCurrState == WMAC_STATE_ASSOC) { - pr_debug("eCurrState == WMAC_STATE_ASSOC\n"); - if (pDevice->ePSMode != WMAC_POWER_CAM) - PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval); - - if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) - KeybRemoveAllKey(&(pDevice->sKey), pDevice->abyBSSID, pDevice->PortOffset); - - pDevice->bLinkPass = true; - pDevice->byLinkWaitCount = 0; - pDevice->byReAssocCount = 0; - bClearBSSID_SCAN(pDevice); - if (pDevice->byFOETuning) { - BBvSetFOE(pDevice->PortOffset); - } - if (netif_queue_stopped(pDevice->dev)) - netif_wake_queue(pDevice->dev); - - if (pDevice->IsTxDataTrigger) { //TxDataTimer is not triggered at the first time - del_timer(&pDevice->sTimerTxData); - init_timer(&pDevice->sTimerTxData); - pDevice->sTimerTxData.data = (unsigned long) pDevice; - pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; - pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback - pDevice->fTxDataInSleep = false; - pDevice->nTxDataTimeCout = 0; - } - - pDevice->IsTxDataTrigger = true; - add_timer(&pDevice->sTimerTxData); - - } else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) { - netdev_err(pDevice->dev, - "WLAN_ASSOCIATE_WAIT:Association Fail???\n"); - } else if (pDevice->byLinkWaitCount <= 4) { //mike add:wait another 2 sec if associated_frame delay! - pDevice->byLinkWaitCount++; - pr_debug("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); - spin_unlock_irq(&pDevice->lock); - vCommandTimerWait((void *)pDevice, ASSOCIATE_TIMEOUT/2); - return; - } - pDevice->byLinkWaitCount = 0; - - s_bCommandComplete(pDevice); - break; - - case WLAN_CMD_AP_MODE_START: - pr_debug("eCommandState == WLAN_CMD_AP_MODE_START\n"); - - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - del_timer(&pMgmt->sTimerSecondCallback); - pMgmt->eCurrState = WMAC_STATE_IDLE; - pMgmt->eCurrMode = WMAC_MODE_STANDBY; - pDevice->bLinkPass = false; - if (pDevice->bEnableHostWEP) - BSSvClearNodeDBTable(pDevice, 1); - else - BSSvClearNodeDBTable(pDevice, 0); - pDevice->uAssocCount = 0; - pMgmt->eCurrState = WMAC_STATE_IDLE; - pDevice->bFixRate = false; - - // alway turn off unicast bit - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST); - pDevice->byRxMode &= ~RCR_UNICAST; - pr_debug("wcmd: rx_mode = %x\n", pDevice->byRxMode); - BSSvAddMulticastNode(pDevice); - if (netif_queue_stopped(pDevice->dev)) - netif_wake_queue(pDevice->dev); - - pDevice->bLinkPass = true; - add_timer(&pMgmt->sTimerSecondCallback); - } - s_bCommandComplete(pDevice); - break; - - case WLAN_CMD_TX_PSPACKET_START: - // DTIM Multicast tx - if (pMgmt->sNodeDBTable[0].bRxPSPoll) { - while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) { - if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) { - pMgmt->abyPSTxMap[0] &= ~byMask[0]; - pDevice->bMoreData = false; - } else { - pDevice->bMoreData = true; - } - - pMgmt->sNodeDBTable[0].wEnQueueCnt--; - } - } - - // PS nodes tx - for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { - if (pMgmt->sNodeDBTable[ii].bActive && - pMgmt->sNodeDBTable[ii].bRxPSPoll) { - pr_debug("Index=%d Enqueu Cnt= %d\n", - ii, - pMgmt->sNodeDBTable[ii].wEnQueueCnt); - while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) { - if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) { - // clear tx map - pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &= - ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7]; - pDevice->bMoreData = false; - } else { - pDevice->bMoreData = true; - } - - pMgmt->sNodeDBTable[ii].wEnQueueCnt--; - // check if sta ps enabled, and wait next pspoll. - // if sta ps disable, then send all pending buffers. - if (pMgmt->sNodeDBTable[ii].bPSEnable) - break; - } - if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) { - // clear tx map - pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &= - ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7]; - pr_debug("Index=%d PS queue clear\n", - ii); - } - pMgmt->sNodeDBTable[ii].bRxPSPoll = false; - } - } - - s_bCommandComplete(pDevice); - break; - - case WLAN_CMD_RADIO_START: - pr_debug("eCommandState == WLAN_CMD_RADIO_START\n"); - if (pDevice->bRadioCmd) - CARDbRadioPowerOn(pDevice); - else - CARDbRadioPowerOff(pDevice); - - s_bCommandComplete(pDevice); - break; - - case WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE: - // wait all TD complete - if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) { - vCommandTimerWait((void *)pDevice, 10); - spin_unlock_irq(&pDevice->lock); - return; - } - if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) { - vCommandTimerWait((void *)pDevice, 10); - spin_unlock_irq(&pDevice->lock); - return; - } - pDevice->byBBVGACurrent = pDevice->byBBVGANew; - BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); - pr_debug("SetVGAGainOffset %02X\n", pDevice->byBBVGACurrent); - s_bCommandComplete(pDevice); - break; - - default: - s_bCommandComplete(pDevice); - break; - - } //switch - spin_unlock_irq(&pDevice->lock); -} - -static -bool -s_bCommandComplete( - struct vnt_private *pDevice -) -{ - PWLAN_IE_SSID pSSID; - bool bRadioCmd = false; - bool bForceSCAN = true; - PSMgmtObject pMgmt = pDevice->pMgmt; - - pDevice->eCommandState = WLAN_CMD_IDLE; - if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) { - //Command Queue Empty - pDevice->bCmdRunning = false; - return true; - } else { - pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd; - pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID; - bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd; - bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN; - ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE); - pDevice->cbFreeCmdQueue++; - pDevice->bCmdRunning = true; - switch (pDevice->eCommand) { - case WLAN_CMD_BSSID_SCAN: - pr_debug("eCommandState= WLAN_CMD_BSSID_SCAN\n"); - pDevice->eCommandState = WLAN_CMD_SCAN_START; - pMgmt->uScanChannel = 0; - if (pSSID->len != 0) - memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - else - memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - - break; - case WLAN_CMD_SSID: - pDevice->eCommandState = WLAN_CMD_SSID_START; - if (pSSID->len > WLAN_SSID_MAXLEN) - pSSID->len = WLAN_SSID_MAXLEN; - if (pSSID->len != 0) - memcpy(pDevice->pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - pr_debug("eCommandState= WLAN_CMD_SSID_START\n"); - break; - case WLAN_CMD_DISASSOCIATE: - pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START; - break; - case WLAN_CMD_RX_PSPOLL: - pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START; - break; - case WLAN_CMD_RUN_AP: - pDevice->eCommandState = WLAN_CMD_AP_MODE_START; - break; - case WLAN_CMD_RADIO: - pDevice->eCommandState = WLAN_CMD_RADIO_START; - pDevice->bRadioCmd = bRadioCmd; - break; - case WLAN_CMD_CHANGE_BBSENSITIVITY: - pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE; - break; - - default: - break; - - } - - vCommandTimerWait((void *)pDevice, 0); - } - - return true; -} - -bool bScheduleCommand( - void *hDeviceContext, - CMD_CODE eCommand, - unsigned char *pbyItem0 -) -{ - struct vnt_private *pDevice = hDeviceContext; - - if (pDevice->cbFreeCmdQueue == 0) - return false; - - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand; - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true; - memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - - if (pbyItem0 != NULL) { - switch (eCommand) { - case WLAN_CMD_BSSID_SCAN: - memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, - pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false; - break; - - case WLAN_CMD_SSID: - memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, - pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - break; - - case WLAN_CMD_DISASSOCIATE: - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0); - break; - - case WLAN_CMD_RX_PSPOLL: - break; - - case WLAN_CMD_RADIO: - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0); - break; - - case WLAN_CMD_CHANGE_BBSENSITIVITY: - pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE; - break; - - default: - break; - } - } - - ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE); - pDevice->cbFreeCmdQueue--; - - if (!pDevice->bCmdRunning) - s_bCommandComplete(pDevice); - - return true; -} - -/* - * Description: - * Clear BSSID_SCAN cmd in CMD Queue - * - * Parameters: - * In: - * hDeviceContext - Pointer to the adapter - * eCommand - Command - * Out: - * none - * - * Return Value: true if success; otherwise false - * - */ -bool bClearBSSID_SCAN( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx; - unsigned int ii; - - if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) { - for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii++) { - if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN) - pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE; - ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE); - if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx) - break; - } - } - return true; -} - -//mike add:reset command timer -void -vResetCommandTimer( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - - //delete timer - del_timer(&pDevice->sTimerCommand); - //init timer - init_timer(&pDevice->sTimerCommand); - pDevice->sTimerCommand.data = (unsigned long) pDevice; - pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; - pDevice->sTimerCommand.expires = RUN_AT(HZ); - pDevice->cbFreeCmdQueue = CMD_Q_SIZE; - pDevice->uCmdDequeueIdx = 0; - pDevice->uCmdEnqueueIdx = 0; - pDevice->eCommandState = WLAN_CMD_IDLE; - pDevice->bCmdRunning = false; - pDevice->bCmdClear = false; -} - -void -BSSvSecondTxData( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - pDevice->nTxDataTimeCout++; - - if (pDevice->nTxDataTimeCout < 4) //don't tx data if timer less than 40s - { - pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback - add_timer(&pDevice->sTimerTxData); - return; - } - - spin_lock_irq(&pDevice->lock); - - /* open && sharekey linking */ - if ((pDevice->bLinkPass && (pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || - pDevice->fWPA_Authened) { /* wpa linking */ - pDevice->fTxDataInSleep = true; - pDevice->fTxDataInSleep = false; - } - - spin_unlock_irq(&pDevice->lock); - - pDevice->sTimerTxData.expires = RUN_AT(10*HZ); /* 10s callback */ - add_timer(&pDevice->sTimerTxData); -} diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h index 6ef04de69f37..ae7ddeaeb014 100644 --- a/drivers/staging/vt6655/wcmd.h +++ b/drivers/staging/vt6655/wcmd.h @@ -88,36 +88,4 @@ typedef enum tagCMD_STATE { WLAN_CMD_IDLE } CMD_STATE, *PCMD_STATE; -void -vResetCommandTimer( - void *hDeviceContext -); - -void -vCommandTimer( - void *hDeviceContext -); - -bool bClearBSSID_SCAN( - void *hDeviceContext -); - -bool -bScheduleCommand( - void *hDeviceContext, - CMD_CODE eCommand, - unsigned char *pbyItem0 -); - -void -vCommandTimerWait( - void *hDeviceContext, - unsigned int MSecond -); - -void -BSSvSecondTxData( - void *hDeviceContext -); - #endif //__WCMD_H__ -- cgit v1.2.3-59-g8ed1b From d829163fa9736846baef47837f2b0cfa1a3a9202 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:30 +0000 Subject: staging: vt6655: rxtx remove dead functions Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/IEEE11h.c | 2 - drivers/staging/vt6655/rxtx.c | 1185 -------------------------------------- drivers/staging/vt6655/rxtx.h | 34 -- drivers/staging/vt6655/wroute.c | 12 +- 4 files changed, 1 insertion(+), 1232 deletions(-) diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c index 180a27cc74d7..65eb4823a7f5 100644 --- a/drivers/staging/vt6655/IEEE11h.c +++ b/drivers/staging/vt6655/IEEE11h.c @@ -135,7 +135,5 @@ bool IEEE11hbMSRRepTx(void *pMgmtHandle) pTxPacket->cbMPDULen = uLength; pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN; - if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) - return false; return true; } diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index aa7e454cd9d3..5c460ad7665a 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -104,19 +104,6 @@ static const unsigned short wFB_Opt1[2][5] = { #define DATADUR_A_F1 13 /*--------------------- Static Functions --------------------------*/ - -static -void -s_vFillTxKey( - struct vnt_private *pDevice, - unsigned char *pbyBuf, - unsigned char *pbyIVHead, - PSKeyItem pTransmitKey, - unsigned char *pbyHdrBuf, - unsigned short wPayloadLen, - unsigned char *pMICHDR -); - static void s_vFillRTSHead( @@ -174,160 +161,6 @@ s_uFillDataHead( /*--------------------- Export Variables --------------------------*/ -static -void -s_vFillTxKey( - struct vnt_private *pDevice, - unsigned char *pbyBuf, - unsigned char *pbyIVHead, - PSKeyItem pTransmitKey, - unsigned char *pbyHdrBuf, - unsigned short wPayloadLen, - unsigned char *pMICHDR -) -{ - struct vnt_mic_hdr *mic_hdr = (struct vnt_mic_hdr *)pMICHDR; - unsigned long *pdwIV = (unsigned long *)pbyIVHead; - unsigned long *pdwExtIV = (unsigned long *)((unsigned char *)pbyIVHead+4); - PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; - unsigned long dwRevIVCounter; - unsigned char byKeyIndex = 0; - - //Fill TXKEY - if (pTransmitKey == NULL) - return; - - dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); - *pdwIV = pDevice->dwIVCounter; - byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; - - if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { - if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { - memcpy(pDevice->abyPRNG, (unsigned char *)&(dwRevIVCounter), 3); - memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); - } else { - memcpy(pbyBuf, (unsigned char *)&(dwRevIVCounter), 3); - memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); - if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { - memcpy(pbyBuf+8, (unsigned char *)&(dwRevIVCounter), 3); - memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); - } - memcpy(pDevice->abyPRNG, pbyBuf, 16); - } - // Append IV after Mac Header - *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111 - *pdwIV |= (unsigned long)byKeyIndex << 30; - *pdwIV = cpu_to_le32(*pdwIV); - pDevice->dwIVCounter++; - if (pDevice->dwIVCounter > WEP_IV_MASK) - pDevice->dwIVCounter = 0; - - } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { - pTransmitKey->wTSC15_0++; - if (pTransmitKey->wTSC15_0 == 0) - pTransmitKey->dwTSC47_16++; - - TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, - pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); - memcpy(pbyBuf, pDevice->abyPRNG, 16); - // Make IV - memcpy(pdwIV, pDevice->abyPRNG, 3); - - *(pbyIVHead+3) = (unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV - // Append IV&ExtIV after Mac Header - *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); - pr_debug("vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV); - - } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { - pTransmitKey->wTSC15_0++; - if (pTransmitKey->wTSC15_0 == 0) - pTransmitKey->dwTSC47_16++; - - memcpy(pbyBuf, pTransmitKey->abyKey, 16); - - // Make IV - *pdwIV = 0; - *(pbyIVHead+3) = (unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV - *pdwIV |= cpu_to_le16((unsigned short)(pTransmitKey->wTSC15_0)); - //Append IV&ExtIV after Mac Header - *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); - - /* MICHDR0 */ - mic_hdr->id = 0x59; - mic_hdr->tx_priority = 0; - ether_addr_copy(mic_hdr->mic_addr2, pMACHeader->abyAddr2); - - /* ccmp pn big endian order */ - mic_hdr->ccmp_pn[0] = (u8)(pTransmitKey->dwTSC47_16 >> 24); - mic_hdr->ccmp_pn[1] = (u8)(pTransmitKey->dwTSC47_16 >> 16); - mic_hdr->ccmp_pn[2] = (u8)(pTransmitKey->dwTSC47_16 >> 8); - mic_hdr->ccmp_pn[3] = (u8)pTransmitKey->dwTSC47_16; - mic_hdr->ccmp_pn[4] = (u8)(pTransmitKey->wTSC15_0 >> 8); - mic_hdr->ccmp_pn[5] = (u8)pTransmitKey->wTSC15_0; - - /* MICHDR1 */ - mic_hdr->payload_len = cpu_to_be16(wPayloadLen); - - if (pDevice->bLongHeader) - mic_hdr->hlen = cpu_to_be16(28); - else - mic_hdr->hlen = cpu_to_be16(22); - - ether_addr_copy(mic_hdr->addr1, pMACHeader->abyAddr1); - ether_addr_copy(mic_hdr->addr2, pMACHeader->abyAddr2); - - /* MICHDR2 */ - ether_addr_copy(mic_hdr->addr3, pMACHeader->abyAddr3); - mic_hdr->frame_control = - cpu_to_le16(pMACHeader->wFrameCtl & 0xc78f); - mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->wSeqCtl & 0xf); - - if (pDevice->bLongHeader) - ether_addr_copy(mic_hdr->addr4, pMACHeader->abyAddr4); - } -} - -static -void -s_vSWencryption( - struct vnt_private *pDevice, - PSKeyItem pTransmitKey, - unsigned char *pbyPayloadHead, - unsigned short wPayloadSize -) -{ - unsigned int cbICVlen = 4; - unsigned long dwICV = 0xFFFFFFFFL; - unsigned long *pdwICV; - - if (pTransmitKey == NULL) - return; - - if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { - //======================================================================= - // Append ICV after payload - dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) - pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize); - // finally, we must invert dwCRC to get the correct answer - *pdwICV = cpu_to_le32(~dwICV); - // RC4 encryption - rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength + 3); - rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); - //======================================================================= - } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { - //======================================================================= - //Append ICV after payload - dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) - pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize); - // finally, we must invert dwCRC to get the correct answer - *pdwICV = cpu_to_le32(~dwICV); - // RC4 encryption - rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); - rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); - //======================================================================= - } -} - static __le16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate) { return cpu_to_le16(wTimeStampOff[priv->byPreambleType % 2] @@ -1395,1024 +1228,6 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, return cbHeaderLength; } -void -vGenerateFIFOHeader(struct vnt_private *pDevice, unsigned char byPktType, - unsigned char *pbyTxBufferAddr, bool bNeedEncrypt, - unsigned int cbPayloadSize, unsigned int uDMAIdx, - PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, unsigned char *pPacket, - PSKeyItem pTransmitKey, unsigned int uNodeIndex, unsigned int *puMACfragNum, - unsigned int *pcbHeaderSize) -{ - unsigned int wTxBufSize; // FFinfo size - bool bNeedACK; - bool bIsAdhoc; - unsigned short cbMacHdLen; - PSTxBufHead pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; - - wTxBufSize = sizeof(STxBufHead); - - memset(pTxBufHead, 0, wTxBufSize); - //Set FIFOCTL_NEEDACK - - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) { - bNeedACK = false; - pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); - } else { - bNeedACK = true; - pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; - } - bIsAdhoc = true; - } else { - // MSDUs in Infra mode always need ACK - bNeedACK = true; - pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; - bIsAdhoc = false; - } - - pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us); - - //Set FIFOCTL_LHEAD - if (pDevice->bLongHeader) - pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD; - - //Set FIFOCTL_GENINT - - pTxBufHead->wFIFOCtl |= FIFOCTL_GENINT; - - //Set FIFOCTL_ISDMA0 - if (TYPE_TXDMA0 == uDMAIdx) - pTxBufHead->wFIFOCtl |= FIFOCTL_ISDMA0; - - //Set FRAGCTL_MACHDCNT - if (pDevice->bLongHeader) - cbMacHdLen = WLAN_HDR_ADDR3_LEN + 6; - else - cbMacHdLen = WLAN_HDR_ADDR3_LEN; - - pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10)); - - //Set packet type - if (byPktType == PK_TYPE_11A) //0000 0000 0000 0000 - ; - else if (byPktType == PK_TYPE_11B) //0000 0001 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - else if (byPktType == PK_TYPE_11GB) //0000 0010 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; - else if (byPktType == PK_TYPE_11GA) //0000 0011 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; - - //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - - //Set Auto Fallback Ctl - if (pDevice->wCurrentRate >= RATE_18M) { - if (pDevice->byAutoFBCtrl == AUTO_FB_0) - pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0; - else if (pDevice->byAutoFBCtrl == AUTO_FB_1) - pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1; - } - - //Set FRAGCTL_WEPTYP - pDevice->bAES = false; - - //Set FRAGCTL_WEPTYP - if (pDevice->byLocalID > REV_ID_VT3253_A1) { - if ((bNeedEncrypt) && (pTransmitKey != NULL)) { //WEP enabled - if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { - pTxBufHead->wFragCtl |= FRAGCTL_TKIP; - } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104 - if (pTransmitKey->uKeyLength != WLAN_WEP232_KEYLEN) - pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; - } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP - pTxBufHead->wFragCtl |= FRAGCTL_AES; - } - } - } - - RFbSetPower(pDevice, pDevice->wCurrentRate, pDevice->byCurrentCh); - - pTxBufHead->byTxPower = pDevice->byCurPwr; - - *pcbHeaderSize = s_cbFillTxBufHead(pDevice, byPktType, pbyTxBufferAddr, cbPayloadSize, - uDMAIdx, pHeadTD, psEthHeader, pPacket, bNeedEncrypt, - pTransmitKey, uNodeIndex, puMACfragNum); -} - -/*+ - * - * Description: - * Translate 802.3 to 802.11 header - * - * Parameters: - * In: - * pDevice - Pointer to adapter - * dwTxBufferAddr - Transmit Buffer - * pPacket - Packet from upper layer - * cbPacketSize - Transmit Data Length - * Out: - * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header - * pcbAppendPayload - size of append payload for 802.1H translation - * - * Return Value: none - * - -*/ - -void -vGenerateMACHeader( - struct vnt_private *pDevice, - unsigned char *pbyBufferAddr, - __le16 wDuration, - PSEthernetHeader psEthHeader, - bool bNeedEncrypt, - unsigned short wFragType, - unsigned int uDMAIdx, - unsigned int uFragIdx -) -{ - PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; - - memset(pMACHeader, 0, (sizeof(S802_11Header))); - - if (uDMAIdx == TYPE_ATIMDMA) - pMACHeader->wFrameCtl = TYPE_802_11_ATIM; - else - pMACHeader->wFrameCtl = TYPE_802_11_DATA; - - if (pDevice->op_mode == NL80211_IFTYPE_AP) { - ether_addr_copy(&(pMACHeader->abyAddr1[0]), - &(psEthHeader->abyDstAddr[0])); - ether_addr_copy(&(pMACHeader->abyAddr2[0]), - &(pDevice->abyBSSID[0])); - ether_addr_copy(&(pMACHeader->abyAddr3[0]), - &(psEthHeader->abySrcAddr[0])); - pMACHeader->wFrameCtl |= FC_FROMDS; - } else { - if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { - ether_addr_copy(&(pMACHeader->abyAddr1[0]), - &(psEthHeader->abyDstAddr[0])); - ether_addr_copy(&(pMACHeader->abyAddr2[0]), - &(psEthHeader->abySrcAddr[0])); - ether_addr_copy(&(pMACHeader->abyAddr3[0]), - &(pDevice->abyBSSID[0])); - } else { - ether_addr_copy(&(pMACHeader->abyAddr3[0]), - &(psEthHeader->abyDstAddr[0])); - ether_addr_copy(&(pMACHeader->abyAddr2[0]), - &(psEthHeader->abySrcAddr[0])); - ether_addr_copy(&(pMACHeader->abyAddr1[0]), - &(pDevice->abyBSSID[0])); - pMACHeader->wFrameCtl |= FC_TODS; - } - } - - if (bNeedEncrypt) - pMACHeader->wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_ISWEP(1)); - - pMACHeader->wDurationID = le16_to_cpu(wDuration); - - if (pDevice->bLongHeader) { - PWLAN_80211HDR_A4 pMACA4Header = (PWLAN_80211HDR_A4) pbyBufferAddr; - - pMACHeader->wFrameCtl |= (FC_TODS | FC_FROMDS); - memcpy(pMACA4Header->abyAddr4, pDevice->abyBSSID, WLAN_ADDR_LEN); - } - pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); - - //Set FragNumber in Sequence Control - pMACHeader->wSeqCtl |= cpu_to_le16((unsigned short)uFragIdx); - - if ((wFragType == FRAGCTL_ENDFRAG) || (wFragType == FRAGCTL_NONFRAG)) { - pDevice->wSeqCounter++; - if (pDevice->wSeqCounter > 0x0fff) - pDevice->wSeqCounter = 0; - } - - if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) //StartFrag or MidFrag - pMACHeader->wFrameCtl |= FC_MOREFRAG; -} - -CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket) -{ - PSTxDesc pFrstTD; - unsigned char byPktType; - unsigned char *pbyTxBufferAddr; - void *pvRTS; - struct vnt_cts *pCTS; - void *pvTxDataHd; - unsigned int uDuration; - unsigned int cbReqCount; - PS802_11Header pMACHeader; - unsigned int cbHeaderSize; - unsigned int cbFrameBodySize; - bool bNeedACK; - bool bIsPSPOLL = false; - PSTxBufHead pTxBufHead; - unsigned int cbFrameSize; - unsigned int cbIVlen = 0; - unsigned int cbICVlen = 0; - unsigned int cbMIClen = 0; - unsigned int cbFCSlen = 4; - unsigned int uPadding = 0; - unsigned short wTxBufSize; - unsigned int cbMacHdLen; - SEthernetHeader sEthHeader; - void *pvRrvTime; - void *pMICHDR; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned short wCurrentRate = RATE_1M; - - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) - return CMD_STATUS_RESOURCES; - - pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; - pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; - cbFrameBodySize = pPacket->cbPayloadLen; - pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; - wTxBufSize = sizeof(STxBufHead); - memset(pTxBufHead, 0, wTxBufSize); - - if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_1M; - byPktType = PK_TYPE_11B; - } - - // SetPower will cause error power TX state for OFDM Date packet in TX buffer. - // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. - // And cmd timer will wait data pkt TX finish before scanning so it's OK - // to set power here. - if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - else - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - - pTxBufHead->byTxPower = pDevice->byCurPwr; - //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++ - if (pDevice->byFOETuning) { - if ((pPacket->p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) { - wCurrentRate = RATE_24M; - byPktType = PK_TYPE_11GA; - } - } - - //Set packet type - if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 - pTxBufHead->wFIFOCtl = 0; - } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; - } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; - } - - pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); - - if (is_multicast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0]))) - bNeedACK = false; - else { - bNeedACK = true; - pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; - } - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || - (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { - pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; - } - - pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); - - if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { - bIsPSPOLL = true; - cbMacHdLen = WLAN_HDR_ADDR2_LEN; - } else { - cbMacHdLen = WLAN_HDR_ADDR3_LEN; - } - - //Set FRAGCTL_MACHDCNT - pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10)); - - // Notes: - // Although spec says MMPDU can be fragmented; In most cases, - // no one will send a MMPDU under fragmentation. With RTS may occur. - pDevice->bAES = false; //Set FRAGCTL_WEPTYP - - if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { - if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { - cbIVlen = 4; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_TKIP; - //We need to get seed here for filling TxKey entry. - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC - pTxBufHead->wFragCtl |= FRAGCTL_AES; - pDevice->bAES = true; - } - //MAC Header should be padding 0 to DW alignment. - uPadding = 4 - (cbMacHdLen%4); - uPadding %= 4; - } - - cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen; - - //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - - //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() - - //Set RrvTime/RTS/CTS Buffer - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet - pvRrvTime = (void *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = NULL; - pvRTS = NULL; - pCTS = (struct vnt_cts *)(pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts)); - pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts)); - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + - sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); - } else { // 802.11a/b packet - pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = NULL; - pvRTS = NULL; - pCTS = NULL; - pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab)); - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + - sizeof(struct vnt_tx_datahead_ab); - } - - memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); - - ether_addr_copy(&(sEthHeader.abyDstAddr[0]), - &(pPacket->p80211Header->sA3.abyAddr1[0])); - ether_addr_copy(&(sEthHeader.abySrcAddr[0]), - &(pPacket->p80211Header->sA3.abyAddr2[0])); - //========================= - // No Fragmentation - //========================= - pTxBufHead->wFragCtl |= (unsigned short)FRAGCTL_NONFRAG; - - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate); - - //Fill DataHead - uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, - 0, 0, 1, AUTO_FB_NONE, wCurrentRate, false); - - pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); - - cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize; - - if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { - unsigned char *pbyIVHead; - unsigned char *pbyPayloadHead; - unsigned char *pbyBSSID; - PSKeyItem pTransmitKey = NULL; - - pbyIVHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); - pbyPayloadHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); - - //Fill TXKEY - //Kyle: Need fix: TKIP and AES did't encrypt Mnt Packet. - //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL); - - //Fill IV(ExtIV,RSNHDR) - //s_vFillPrePayload(pDevice, pbyIVHead, NULL); - //--------------------------- - // S/W or H/W Encryption - //--------------------------- - do { - 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) { - // get group key - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { - pr_debug("Get GTK\n"); - break; - } - } else { - pr_debug("Get PTK\n"); - break; - } - } - // get group key - pbyBSSID = pDevice->abyBroadcastAddr; - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { - pTransmitKey = NULL; - pr_debug("KEY is NULL. OP Mode[%d]\n", - pDevice->op_mode); - } else { - pr_debug("Get GTK\n"); - } - } while (false); - //Fill TXKEY - s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, - (unsigned char *)pMACHeader, (unsigned short)cbFrameBodySize, NULL); - - memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen); - memcpy(pbyPayloadHead, ((unsigned char *)(pPacket->p80211Header) + cbMacHdLen), - cbFrameBodySize); - } else { - // Copy the Packet into a tx Buffer - memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); - } - - pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); - pDevice->wSeqCounter++; - if (pDevice->wSeqCounter > 0x0fff) - pDevice->wSeqCounter = 0; - - if (bIsPSPOLL) { - // The MAC will automatically replace the Duration-field of MAC header by Duration-field - // of FIFO control header. - // This will cause AID-field of PS-POLL packet to be incorrect (Because PS-POLL's AID field is - // in the same place of other packet's Duration-field). - // And it will cause Cisco-AP to issue Disassociation-packet - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_a = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); - ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); - } else { - ((struct vnt_tx_datahead_ab *)pvTxDataHd)->duration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); - } - } - - // first TD is the only TD - //Set TSR1 & ReqCount in TxDescHead - pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU); - pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma; - pFrstTD->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma); - pFrstTD->pTDInfo->byFlags = 0; - - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { - // Disable PS - MACbPSWakeup(pDevice->PortOffset); - } - pDevice->bPWBitOn = false; - - wmb(); - pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC; - wmb(); - - pDevice->iTDUsed[TYPE_TXDMA0]++; - - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) - pr_debug(" available td0 <= 1\n"); - - pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next; - - pDevice->nTxDataTimeCout = 0; //2008-8-21 chester for send null packet - - // Poll Transmit the adapter - MACvTransmit0(pDevice->PortOffset); - - return CMD_STATUS_PENDING; -} - -CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket) -{ - unsigned char byPktType; - unsigned char *pbyBuffer = (unsigned char *)pDevice->tx_beacon_bufs; - unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; - unsigned int cbHeaderSize = 0; - struct vnt_tx_short_buf_head *short_head = - (struct vnt_tx_short_buf_head *)pbyBuffer; - PS802_11Header pMACHeader; - unsigned short wCurrentRate; - - memset(short_head, 0, sizeof(*short_head)); - - if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_2M; - byPktType = PK_TYPE_11B; - } - - //Set Preamble type always long - pDevice->byPreambleType = PREAMBLE_LONG; - - /* Set FIFOCTL_GENINT */ - short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT); - - /* Set packet type & Get Duration */ - if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 - short_head->duration = - cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, - cbFrameSize, byPktType, wCurrentRate, false, - 0, 0, 1, AUTO_FB_NONE)); - } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 - short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B); - - short_head->duration = - cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, - cbFrameSize, byPktType, wCurrentRate, false, - 0, 0, 1, AUTO_FB_NONE)); - } - - vnt_get_phy_field(pDevice, cbFrameSize, - wCurrentRate, byPktType, &short_head->ab); - - /* Get TimeStampOff */ - short_head->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); - cbHeaderSize = sizeof(struct vnt_tx_short_buf_head); - - //Generate Beacon Header - pMACHeader = (PS802_11Header)(pbyBuffer + cbHeaderSize); - memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); - - pMACHeader->wDurationID = 0; - pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); - pDevice->wSeqCounter++; - if (pDevice->wSeqCounter > 0x0fff) - pDevice->wSeqCounter = 0; - - // Set Beacon buffer length - pDevice->wBCNBufLen = pPacket->cbMPDULen + cbHeaderSize; - - MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, (pDevice->tx_beacon_dma)); - - MACvSetCurrBCNLength(pDevice->PortOffset, pDevice->wBCNBufLen); - // Set auto Transmit on - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); - // Poll Transmit the adapter - MACvTransmitBCN(pDevice->PortOffset); - - return CMD_STATUS_PENDING; -} - -unsigned int -cbGetFragCount( - struct vnt_private *pDevice, - PSKeyItem pTransmitKey, - unsigned int cbFrameBodySize, - PSEthernetHeader psEthHeader -) -{ - unsigned int cbMACHdLen; - unsigned int cbFrameSize; - unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS - unsigned int cbFragPayloadSize; - unsigned int cbLastFragPayloadSize; - unsigned int cbIVlen = 0; - unsigned int cbICVlen = 0; - unsigned int cbMIClen = 0; - unsigned int cbFCSlen = 4; - unsigned int uMACfragNum = 1; - bool bNeedACK; - - if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || - (pDevice->op_mode == NL80211_IFTYPE_AP)) { - if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) - bNeedACK = false; - else - bNeedACK = true; - } else { - // MSDUs in Infra mode always need ACK - bNeedACK = true; - } - - if (pDevice->bLongHeader) - cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; - else - cbMACHdLen = WLAN_HDR_ADDR3_LEN; - - if (pDevice->bEncryptionEnable == true) { - if (pTransmitKey == NULL) { - if ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) || - (pDevice->pMgmt->eAuthenMode < WMAC_AUTH_WPA)) { - cbIVlen = 4; - cbICVlen = 4; - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC - } - } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { - cbIVlen = 4; - cbICVlen = 4; - } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC - } - } - - cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; - - if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == true)) { - // Fragmentation - cbFragmentSize = pDevice->wFragmentationThreshold; - cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen; - uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize); - cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize; - if (cbLastFragPayloadSize == 0) - cbLastFragPayloadSize = cbFragPayloadSize; - else - uMACfragNum++; - } - return uMACfragNum; -} - -void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb, - unsigned char *pbMPDU, unsigned int cbMPDULen) -{ - PSTxDesc pFrstTD; - unsigned char byPktType; - unsigned char *pbyTxBufferAddr; - void *pvRTS; - void *pvCTS; - void *pvTxDataHd; - unsigned int uDuration; - unsigned int cbReqCount; - PS802_11Header pMACHeader; - unsigned int cbHeaderSize; - unsigned int cbFrameBodySize; - bool bNeedACK; - bool bIsPSPOLL = false; - PSTxBufHead pTxBufHead; - unsigned int cbFrameSize; - unsigned int cbIVlen = 0; - unsigned int cbICVlen = 0; - unsigned int cbMIClen = 0; - unsigned int cbFCSlen = 4; - unsigned int uPadding = 0; - unsigned int cbMICHDR = 0; - unsigned int uLength = 0; - u32 dwMICKey0, dwMICKey1; - u32 dwMIC_Priority; - u32 *pdwMIC_L; - u32 *pdwMIC_R; - unsigned short wTxBufSize; - unsigned int cbMacHdLen; - SEthernetHeader sEthHeader; - void *pvRrvTime; - void *pMICHDR; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned short wCurrentRate = RATE_1M; - PUWLAN_80211HDR p80211Header; - unsigned int uNodeIndex = 0; - bool bNodeExist = false; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - unsigned char *pbyIVHead; - unsigned char *pbyPayloadHead; - unsigned char *pbyMacHdr; - - unsigned int cbExtSuppRate = 0; - - pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; - - if (cbMPDULen <= WLAN_HDR_ADDR3_LEN) - cbFrameBodySize = 0; - else - cbFrameBodySize = cbMPDULen - WLAN_HDR_ADDR3_LEN; - - p80211Header = (PUWLAN_80211HDR)pbMPDU; - - pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; - pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; - pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; - wTxBufSize = sizeof(STxBufHead); - memset(pTxBufHead, 0, wTxBufSize); - - if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_1M; - byPktType = PK_TYPE_11B; - } - - // SetPower will cause error power TX state for OFDM Date packet in TX buffer. - // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. - // And cmd timer will wait data pkt TX to finish before scanning so it's OK - // to set power here. - if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - else - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - - pTxBufHead->byTxPower = pDevice->byCurPwr; - - //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++ - if (pDevice->byFOETuning) { - if ((p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) { - wCurrentRate = RATE_24M; - byPktType = PK_TYPE_11GA; - } - } - - pr_debug("vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x\n", - p80211Header->sA3.wFrameCtl); - - //Set packet type - if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 - pTxBufHead->wFIFOCtl = 0; - } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; - } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; - } - - pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); - - if (is_multicast_ether_addr(&(p80211Header->sA3.abyAddr1[0]))) { - bNeedACK = false; - if (pDevice->bEnableHostWEP) { - uNodeIndex = 0; - bNodeExist = true; - } - } else { - if (pDevice->bEnableHostWEP) { - if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (unsigned char *)(p80211Header->sA3.abyAddr1), &uNodeIndex)) - bNodeExist = true; - } - bNeedACK = true; - pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; - } - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || - (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { - pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; - } - - pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); - - if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { - bIsPSPOLL = true; - cbMacHdLen = WLAN_HDR_ADDR2_LEN; - } else { - cbMacHdLen = WLAN_HDR_ADDR3_LEN; - } - - // hostapd deamon ext support rate patch - if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) - cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; - - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) - cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - - if (cbExtSuppRate > 0) - cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; - } - - //Set FRAGCTL_MACHDCNT - pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)cbMacHdLen << 10); - - // Notes: - // Although spec says MMPDU can be fragmented; In most cases, - // no one will send a MMPDU under fragmentation. With RTS may occur. - pDevice->bAES = false; //Set FRAGCTL_WEPTYP - - if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { - if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { - cbIVlen = 4; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_TKIP; - //We need to get seed here for filling TxKey entry. - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC - cbMICHDR = sizeof(struct vnt_mic_hdr); - pTxBufHead->wFragCtl |= FRAGCTL_AES; - pDevice->bAES = true; - } - //MAC Header should be padding 0 to DW alignment. - uPadding = 4 - (cbMacHdLen%4); - uPadding %= 4; - } - - cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; - - //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - - //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() - - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet - - pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts)); - pvRTS = NULL; - pvCTS = (struct vnt_cts *)(pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts) + cbMICHDR); - pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts)); - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + - cbMICHDR + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); - - } else {//802.11a/b packet - - pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + - wTxBufSize + sizeof(struct vnt_rrv_time_ab)); - pvRTS = NULL; - pvCTS = NULL; - pvTxDataHd = (void *)(pbyTxBufferAddr + - wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + - cbMICHDR + sizeof(struct vnt_tx_datahead_ab); - - } - - memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); - ether_addr_copy(&(sEthHeader.abyDstAddr[0]), - &(p80211Header->sA3.abyAddr1[0])); - ether_addr_copy(&(sEthHeader.abySrcAddr[0]), - &(p80211Header->sA3.abyAddr2[0])); - //========================= - // No Fragmentation - //========================= - pTxBufHead->wFragCtl |= (unsigned short)FRAGCTL_NONFRAG; - - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate); - - //Fill DataHead - uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, - 0, 0, 1, AUTO_FB_NONE, wCurrentRate, false); - - pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); - - cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; - - pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize); - pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); - pbyIVHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding); - - // Copy the Packet into a tx Buffer - memcpy(pbyMacHdr, pbMPDU, cbMacHdLen); - - // version set to 0, patch for hostapd deamon - pMACHeader->wFrameCtl &= cpu_to_le16(0xfffc); - memcpy(pbyPayloadHead, (pbMPDU + cbMacHdLen), cbFrameBodySize); - - // replace support rate, patch for hostapd deamon(only support 11M) - if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - if (cbExtSuppRate != 0) { - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) - memcpy((pbyPayloadHead + cbFrameBodySize), - pMgmt->abyCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN -); - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) - memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN, - pMgmt->abyCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN -); - } - } - - // Set wep - if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { - if (pDevice->bEnableHostWEP) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength -); - } - - if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); - - // DO Software Michael - MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((unsigned char *)&(sEthHeader.abyDstAddr[0]), 12); - dwMIC_Priority = 0; - MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); - pr_debug("DMA0_tx_8021:MIC KEY: %X, %X\n", - dwMICKey0, dwMICKey1); - - uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; - - MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); - - pdwMIC_L = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize); - pdwMIC_R = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); - - MIC_vGetMIC(pdwMIC_L, pdwMIC_R); - MIC_vUnInit(); - - if (pDevice->bTxMICFail == true) { - *pdwMIC_L = 0; - *pdwMIC_R = 0; - pDevice->bTxMICFail = false; - } - - pr_debug("uLength: %d, %d\n", uLength, cbFrameBodySize); - pr_debug("cbReqCount:%d, %d, %d, %d\n", - cbReqCount, cbHeaderSize, uPadding, cbIVlen); - pr_debug("MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R); - - } - - s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (unsigned short)cbFrameBodySize, (unsigned char *)pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) - s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (unsigned short)(cbFrameBodySize + cbMIClen)); - } - - pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); - pDevice->wSeqCounter++; - if (pDevice->wSeqCounter > 0x0fff) - pDevice->wSeqCounter = 0; - - if (bIsPSPOLL) { - // The MAC will automatically replace the Duration-field of MAC header by Duration-field - // of FIFO control header. - // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is - // in the same place of other packet's Duration-field). - // And it will cause Cisco-AP to issue Disassociation-packet - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_a = cpu_to_le16(p80211Header->sA2.wDurationID); - ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_b = cpu_to_le16(p80211Header->sA2.wDurationID); - } else { - ((struct vnt_tx_datahead_ab *)pvTxDataHd)->duration = cpu_to_le16(p80211Header->sA2.wDurationID); - } - } - - // first TD is the only TD - //Set TSR1 & ReqCount in TxDescHead - pFrstTD->pTDInfo->skb = skb; - pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU); - pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma; - pFrstTD->m_td1TD1.wReqCount = cpu_to_le16(cbReqCount); - pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma); - pFrstTD->pTDInfo->byFlags = 0; - pFrstTD->pTDInfo->byFlags |= TD_FLAGS_PRIV_SKB; - - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { - // Disable PS - MACbPSWakeup(pDevice->PortOffset); - } - pDevice->bPWBitOn = false; - - wmb(); - pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC; - wmb(); - - pDevice->iTDUsed[TYPE_TXDMA0]++; - - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) - pr_debug(" available td0 <= 1\n"); - - pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next; - - // Poll Transmit the adapter - MACvTransmit0(pDevice->PortOffset); -} - static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer, struct ieee80211_key_conf *tx_key, struct sk_buff *skb, u16 payload_len, diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index 145713dc4110..7b0566ce42a7 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -189,40 +189,6 @@ struct vnt_tx_short_buf_head { __le16 time_stamp_off; } __packed; -void -vGenerateMACHeader( - struct vnt_private *, - unsigned char *pbyBufferAddr, - unsigned short wDuration, - PSEthernetHeader psEthHeader, - bool bNeedEncrypt, - unsigned short wFragType, - unsigned int uDMAIdx, - unsigned int uFragIdx -); - -unsigned int -cbGetFragCount( - struct vnt_private *, - PSKeyItem pTransmitKey, - unsigned int cbFrameBodySize, - PSEthernetHeader psEthHeader -); - -void -vGenerateFIFOHeader(struct vnt_private *, unsigned char byPktTyp, - unsigned char *pbyTxBufferAddr, bool bNeedEncrypt, - unsigned int cbPayloadSize, unsigned int uDMAIdx, - PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, - unsigned char *pPacket, PSKeyItem pTransmitKey, - unsigned int uNodeIndex, unsigned int *puMACfragNum, - unsigned int *pcbHeaderSize); - -void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb, - unsigned char *pbMPDU, unsigned int cbMPDULen); -CMD_STATUS csMgmt_xmit(struct vnt_private *, PSTxMgmtPacket pPacket); -CMD_STATUS csBeacon_xmit(struct vnt_private *, PSTxMgmtPacket pPacket); - int vnt_generate_fifo_header(struct vnt_private *, u32, PSTxDesc head_td, struct sk_buff *); int vnt_beacon_make(struct vnt_private *, struct ieee80211_vif *); diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c index 6606a1c239ee..430e9441bc9e 100644 --- a/drivers/staging/vt6655/wroute.c +++ b/drivers/staging/vt6655/wroute.c @@ -66,12 +66,11 @@ bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, PSMgmtObject pMgmt = pDevice->pMgmt; PSTxDesc pHeadTD, pLastTD; unsigned int cbFrameBodySize; - unsigned int uMACfragNum; + unsigned int uMACfragNum = 0; unsigned char byPktType; bool bNeedEncryption = false; SKeyItem STempKey; PSKeyItem pTransmitKey = NULL; - unsigned int cbHeaderSize; unsigned int ii; unsigned char *pbyBSSID; @@ -120,9 +119,6 @@ bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, } } - uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, - cbFrameBodySize, &pDevice->sTxEthHeader); - if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA)) return false; @@ -152,12 +148,6 @@ bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, if (pDevice->wCurrentRate <= RATE_11M) byPktType = PK_TYPE_11B; - vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, - bNeedEncryption, cbFrameBodySize, TYPE_AC0DMA, - pHeadTD, &pDevice->sTxEthHeader, pbySkbData, - pTransmitKey, uNodeIndex, &uMACfragNum, - &cbHeaderSize); - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { /* Disable PS */ MACbPSWakeup(pDevice->PortOffset); -- cgit v1.2.3-59-g8ed1b From 1a48e8c412b7524bd140cd5220ce1abed8c32004 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:31 +0000 Subject: staging: vt6655: s_cbFillTxBufHead remove unused parameters Remove the following parameters PSEthernetHeader psEthHeader PSKeyItem pTransmitKey bool bNeedEncrypt Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 5c460ad7665a..c47042c07aad 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -138,9 +138,8 @@ static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, - PSEthernetHeader psEthHeader, unsigned char *pPacket, - bool bNeedEncrypt, PSKeyItem pTransmitKey, - unsigned int uNodeIndex, unsigned int *puMACfragNum); + unsigned char *pPacket, unsigned int uNodeIndex, + unsigned int *puMACfragNum); static __le16 @@ -1041,9 +1040,8 @@ static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, - PSEthernetHeader psEthHeader, unsigned char *pPacket, - bool bNeedEncrypt, PSKeyItem pTransmitKey, - unsigned int is_pspoll, unsigned int *puMACfragNum) + unsigned char *pPacket, unsigned int is_pspoll, + unsigned int *puMACfragNum) { PDEVICE_TD_INFO td_info = pHeadTD->pTDInfo; struct sk_buff *skb = td_info->skb; @@ -1413,8 +1411,8 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG); s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, skb->len, - dma_idx, head_td, NULL, (u8 *)skb->data, - false, NULL, is_pspoll, &frag); + dma_idx, head_td, (u8 *)skb->data, + is_pspoll, &frag); if (info->control.hw_key) { tx_key = info->control.hw_key; -- cgit v1.2.3-59-g8ed1b From 7d48710aecf6acb8457f8e7d117beaa4c1554587 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:32 +0000 Subject: staging: vt6655: dead code remove bssdb.c header will be removed later Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/bssdb.c | 1504 -------------------------------------- drivers/staging/vt6655/bssdb.h | 115 --- drivers/staging/vt6655/vntwifi.c | 16 - 4 files changed, 1636 deletions(-) delete mode 100644 drivers/staging/vt6655/bssdb.c diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 271ca9df43a9..2c0b7932b297 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -9,7 +9,6 @@ vt6655_stage-y += device_main.o \ baseband.o \ wctl.o \ 80211mgr.o \ - bssdb.o \ rxtx.o \ dpc.o \ power.o \ diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c deleted file mode 100644 index abe38e1f34eb..000000000000 --- a/drivers/staging/vt6655/bssdb.c +++ /dev/null @@ -1,1504 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: bssdb.c - * - * Purpose: Handles the Basic Service Set & Node Database functions - * - * Functions: - * BSSpSearchBSSList - Search known BSS list for Desire SSID or BSSID - * BSSvClearBSSList - Clear BSS List - * BSSbInsertToBSSList - Insert a BSS set into known BSS list - * BSSbUpdateToBSSList - Update BSS set in known BSS list - * BSSDBbIsSTAInNodeDB - Search Node DB table to find the index of matched DstAddr - * BSSvCreateOneNode - Allocate an Node for Node DB - * BSSvUpdateAPNode - Update AP Node content in Index 0 of KnownNodeDB - * BSSvSecondCallBack - One second timer callback function to update Node DB info & AP link status - * BSSvUpdateNodeTxCounter - Update Tx attemps, Tx failure counter in Node DB for auto-fall back rate control - * - * Revision History: - * - * Author: Lyndon Chen - * - * Date: July 17, 2002 - * - */ - -#include "ttype.h" -#include "tmacro.h" -#include "tether.h" -#include "device.h" -#include "80211hdr.h" -#include "bssdb.h" -#include "wmgr.h" -#include "datarate.h" -#include "desc.h" -#include "wcmd.h" -#include "wpa.h" -#include "baseband.h" -#include "rf.h" -#include "card.h" -#include "channel.h" -#include "mac.h" -#include "wpa2.h" -#include "iowpa.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ -static const unsigned short awHWRetry0[5][5] = { - {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M}, - {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M}, - {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M}, - {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M}, - {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M} -}; -static const unsigned short awHWRetry1[5][5] = { - {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M}, - {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M}, - {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M}, - {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M}, - {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M} -}; - -/*--------------------- Static Functions --------------------------*/ - -void s_vCheckSensitivity( - void *hDeviceContext -); - -#ifdef Calcu_LinkQual -void s_uCalculateLinkQual( - void *hDeviceContext -); -#endif - -void s_vCheckPreEDThreshold( - void *hDeviceContext -); -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/*+ - * - * Routine Description: - * Search known BSS list for Desire SSID or BSSID. - * - * Return Value: - * PTR to KnownBSS or NULL - * - -*/ - -PKnownBSS -BSSpSearchBSSList( - void *hDeviceContext, - unsigned char *pbyDesireBSSID, - unsigned char *pbyDesireSSID, - CARD_PHY_TYPE ePhyType -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned char *pbyBSSID = NULL; - PWLAN_IE_SSID pSSID = NULL; - PKnownBSS pCurrBSS = NULL; - PKnownBSS pSelect = NULL; - unsigned char ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - unsigned int ii = 0; - - if (pbyDesireBSSID != NULL) { - pr_debug("BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID); - if ((!is_broadcast_ether_addr(pbyDesireBSSID)) && - (memcmp(pbyDesireBSSID, ZeroBSSID, 6) != 0)) - pbyBSSID = pbyDesireBSSID; - } - if (pbyDesireSSID != NULL) { - if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0) - pSSID = (PWLAN_IE_SSID) pbyDesireSSID; - } - - if (pbyBSSID != NULL) { - /* match BSSID first */ - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pCurrBSS = &(pMgmt->sBSSList[ii]); - if (!pDevice->bLinkPass) - pCurrBSS->bSelected = false; - if ((pCurrBSS->bActive) && - (!pCurrBSS->bSelected)) { - if (ether_addr_equal(pCurrBSS->abyBSSID, - pbyBSSID)) { - if (pSSID != NULL) { - /* compare ssid */ - if (!memcmp(pSSID->abySSID, - ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID, - pSSID->len)) { - if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) || - ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || - ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) -) { - pCurrBSS->bSelected = true; - return pCurrBSS; - } - } - } else { - if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) || - ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || - ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) -) { - pCurrBSS->bSelected = true; - return pCurrBSS; - } - } - } - } - } - } else { - /* ignore BSSID */ - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pCurrBSS = &(pMgmt->sBSSList[ii]); - /* 2007-0721-01by MikeLiu */ - pCurrBSS->bSelected = false; - if (pCurrBSS->bActive) { - if (pSSID != NULL) { - /* matched SSID */ - if (!!memcmp(pSSID->abySSID, - ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID, - pSSID->len) || - (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) { - /* SSID not match skip this BSS */ - continue; - } - } - if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) || - ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) -) { - /* Type not match skip this BSS */ - pr_debug("BSS type mismatch.... Config[%d] BSS[0x%04x]\n", - pMgmt->eConfigMode, - pCurrBSS->wCapInfo); - continue; - } - - if (ePhyType != PHY_TYPE_AUTO) { - if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) || - ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) { - /* PhyType not match skip this BSS */ - pr_debug("Physical type mismatch.... ePhyType[%d] BSS[%d]\n", - ePhyType, - pCurrBSS->eNetworkTypeInUse); - continue; - } - } - - if (pSelect == NULL) { - pSelect = pCurrBSS; - } else { - /* compare RSSI, select signal strong one */ - if (pCurrBSS->uRSSI < pSelect->uRSSI) - pSelect = pCurrBSS; - } - } - } - if (pSelect != NULL) { - pSelect->bSelected = true; - return pSelect; - } - } - return NULL; -} - -/*+ - * - * Routine Description: - * Clear BSS List - * - * Return Value: - * None. - * - -*/ - -void -BSSvClearBSSList( - void *hDeviceContext, - bool bKeepCurrBSSID -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int ii; - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - if (bKeepCurrBSSID) { - if (pMgmt->sBSSList[ii].bActive && - ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, - pMgmt->abyCurrBSSID)) { - continue; - } - } - - if ((pMgmt->sBSSList[ii].bActive) && (pMgmt->sBSSList[ii].uClearCount < BSS_CLEAR_COUNT)) { - pMgmt->sBSSList[ii].uClearCount++; - continue; - } - - pMgmt->sBSSList[ii].bActive = false; - memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS)); - } - BSSvClearAnyBSSJoinRecord(pDevice); -} - -/*+ - * - * Routine Description: - * search BSS list by BSSID & SSID if matched - * - * Return Value: - * true if found. - * - -*/ -PKnownBSS -BSSpAddrIsInBSSList( - void *hDeviceContext, - unsigned char *abyBSSID, - PWLAN_IE_SSID pSSID -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - PKnownBSS pBSSList = NULL; - unsigned int ii; - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSSList = &(pMgmt->sBSSList[ii]); - if (pBSSList->bActive) { - if (ether_addr_equal(pBSSList->abyBSSID, abyBSSID)) { - if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len) { - if (memcmp(pSSID->abySSID, - ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID, - pSSID->len) == 0) - return pBSSList; - } - } - } - } - - return NULL; -}; - -/*+ - * - * Routine Description: - * Insert a BSS set into known BSS list - * - * Return Value: - * true if success. - * - -*/ - -bool -BSSbInsertToBSSList( - void *hDeviceContext, - unsigned char *abyBSSIDAddr, - __le64 qwTimestamp, - unsigned short wBeaconInterval, - unsigned short wCapInfo, - unsigned char byCurrChannel, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - unsigned int uIELength, - unsigned char *pbyIEs, - void *pRxPacketContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; - PKnownBSS pBSSList = NULL; - unsigned int ii; - bool bParsingQuiet = false; - PWLAN_IE_QUIET pQuiet = NULL; - - pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]); - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]); - if (!pBSSList->bActive) - break; - } - - if (ii == MAX_BSS_NUM) { - pr_debug("Get free KnowBSS node failed\n"); - return false; - } - /* save the BSS info */ - pBSSList->bActive = true; - memcpy(pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN); - pBSSList->qwBSSTimestamp = le64_to_cpu(qwTimestamp); - pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); - pBSSList->wCapInfo = cpu_to_le16(wCapInfo); - pBSSList->uClearCount = 0; - - if (pSSID->len > WLAN_SSID_MAXLEN) - pSSID->len = WLAN_SSID_MAXLEN; - memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); - - pBSSList->uChannel = byCurrChannel; - - if (pSuppRates->len > WLAN_RATES_MAXLEN) - pSuppRates->len = WLAN_RATES_MAXLEN; - memcpy(pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN); - - if (pExtSuppRates != NULL) { - if (pExtSuppRates->len > WLAN_RATES_MAXLEN) - pExtSuppRates->len = WLAN_RATES_MAXLEN; - memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN); - pr_debug("BSSbInsertToBSSList: pExtSuppRates->len = %d\n", - pExtSuppRates->len); - - } else { - memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - } - pBSSList->sERP.byERP = psERP->byERP; - pBSSList->sERP.bERPExist = psERP->bERPExist; - - /* check if BSS is 802.11a/b/g */ - if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { - pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; - } else { - if (pBSSList->sERP.bERPExist) - pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; - else - pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; - } - - pBSSList->byRxRate = pRxPacket->byRxRate; - pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF; - pBSSList->uRSSI = pRxPacket->uRSSI; - pBSSList->bySQ = pRxPacket->bySQ; - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && - (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - /* assoc with BSS */ - if (pBSSList == pMgmt->pCurrBSS) - bParsingQuiet = true; - } - - WPA_ClearRSN(pBSSList); - - if (pRSNWPA != NULL) { - unsigned int uLen = pRSNWPA->len + 2; - - if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSNWPA - pbyIEs))) { - pBSSList->wWPALen = uLen; - memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); - WPA_ParseRSN(pBSSList, pRSNWPA); - } - } - - WPA2_ClearRSN(pBSSList); - - if (pRSN != NULL) { - unsigned int uLen = pRSN->len + 2; - - if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSN - pbyIEs))) { - pBSSList->wRSNLen = uLen; - memcpy(pBSSList->byRSNIE, pRSN, uLen); - WPA2vParseRSN(pBSSList, pRSN); - } - } - - if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || pBSSList->bWPA2Valid) { - PSKeyItem pTransmitKey = NULL; - bool bIs802_1x = false; - - for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii++) { - if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) { - bIs802_1x = true; - break; - } - } - if (bIs802_1x && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) && - (!memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) { - - if (pDevice->bLinkPass && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - if (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) || - KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey)) { - pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList; - pDevice->gsPMKIDCandidate.Version = 1; - - } - - } - } - } - - if (pDevice->bUpdateBBVGA) { - /* monitor if RSSI is too strong */ - pBSSList->byRSSIStatCnt = 0; - RFvRSSITodBm(pDevice, (unsigned char)(pRxPacket->uRSSI), &pBSSList->ldBmMAX); - pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; - for (ii = 1; ii < RSSI_STAT_COUNT; ii++) - pBSSList->ldBmAverage[ii] = 0; - } - - if ((pIE_Country != NULL) && pMgmt->b11hEnable) { - set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse, - pIE_Country); - } - - if (bParsingQuiet && (pIE_Quiet != NULL)) { - if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) && - (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) { - /* valid EID */ - if (pQuiet == NULL) { - pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; - CARDbSetQuiet(pMgmt->pAdapter, - true, - pQuiet->byQuietCount, - pQuiet->byQuietPeriod, - *((unsigned short *)pQuiet->abyQuietDuration), - *((unsigned short *)pQuiet->abyQuietOffset) -); - } else { - pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; - CARDbSetQuiet(pMgmt->pAdapter, - false, - pQuiet->byQuietCount, - pQuiet->byQuietPeriod, - *((unsigned short *)pQuiet->abyQuietDuration), - *((unsigned short *)pQuiet->abyQuietOffset) - ); - } - } - } - - if (bParsingQuiet && (pQuiet != NULL)) - CARDbStartQuiet(pMgmt->pAdapter); - - pBSSList->uIELength = uIELength; - if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) - pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; - memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); - - return true; -} - -/*+ - * - * Routine Description: - * Update BSS set in known BSS list - * - * Return Value: - * true if success. - * - -*/ -/* TODO: input structure modify */ - -bool -BSSbUpdateToBSSList( - void *hDeviceContext, - __le64 qwTimestamp, - unsigned short wBeaconInterval, - unsigned short wCapInfo, - unsigned char byCurrChannel, - bool bChannelHit, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - PKnownBSS pBSSList, - unsigned int uIELength, - unsigned char *pbyIEs, - void *pRxPacketContext -) -{ - int ii; - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; - long ldBm; - bool bParsingQuiet = false; - PWLAN_IE_QUIET pQuiet = NULL; - - if (pBSSList == NULL) - return false; - - pBSSList->qwBSSTimestamp = le64_to_cpu(qwTimestamp); - pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); - pBSSList->wCapInfo = cpu_to_le16(wCapInfo); - pBSSList->uClearCount = 0; - pBSSList->uChannel = byCurrChannel; - - if (pSSID->len > WLAN_SSID_MAXLEN) - pSSID->len = WLAN_SSID_MAXLEN; - - if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0)) - memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); - memcpy(pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN); - - if (pExtSuppRates != NULL) - memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN); - else - memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - pBSSList->sERP.byERP = psERP->byERP; - pBSSList->sERP.bERPExist = psERP->bERPExist; - - /* check if BSS is 802.11a/b/g */ - if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { - pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; - } else { - if (pBSSList->sERP.bERPExist) - pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; - else - pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; - } - - pBSSList->byRxRate = pRxPacket->byRxRate; - pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF; - if (bChannelHit) - pBSSList->uRSSI = pRxPacket->uRSSI; - pBSSList->bySQ = pRxPacket->bySQ; - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && - (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { - /* assoc with BSS */ - if (pBSSList == pMgmt->pCurrBSS) - bParsingQuiet = true; - } - - WPA_ClearRSN(pBSSList); /* mike update */ - - if (pRSNWPA != NULL) { - unsigned int uLen = pRSNWPA->len + 2; - - if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSNWPA - pbyIEs))) { - pBSSList->wWPALen = uLen; - memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); - WPA_ParseRSN(pBSSList, pRSNWPA); - } - } - - WPA2_ClearRSN(pBSSList); /* mike update */ - - if (pRSN != NULL) { - unsigned int uLen = pRSN->len + 2; - - if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSN - pbyIEs))) { - pBSSList->wRSNLen = uLen; - memcpy(pBSSList->byRSNIE, pRSN, uLen); - WPA2vParseRSN(pBSSList, pRSN); - } - } - - if (pRxPacket->uRSSI != 0) { - RFvRSSITodBm(pDevice, (unsigned char)(pRxPacket->uRSSI), &ldBm); - /* monitor if RSSI is too strong */ - pBSSList->byRSSIStatCnt++; - pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT; - pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm; - for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { - if (pBSSList->ldBmAverage[ii] != 0) - pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm); - } - } - - if ((pIE_Country != NULL) && pMgmt->b11hEnable) { - set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse, - pIE_Country); - } - - if (bParsingQuiet && (pIE_Quiet != NULL)) { - if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) && - (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) { - /* valid EID */ - if (pQuiet == NULL) { - pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; - CARDbSetQuiet(pMgmt->pAdapter, - true, - pQuiet->byQuietCount, - pQuiet->byQuietPeriod, - *((unsigned short *)pQuiet->abyQuietDuration), - *((unsigned short *)pQuiet->abyQuietOffset) -); - } else { - pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; - CARDbSetQuiet(pMgmt->pAdapter, - false, - pQuiet->byQuietCount, - pQuiet->byQuietPeriod, - *((unsigned short *)pQuiet->abyQuietDuration), - *((unsigned short *)pQuiet->abyQuietOffset) - ); - } - } - } - - if (bParsingQuiet && (pQuiet != NULL)) - CARDbStartQuiet(pMgmt->pAdapter); - - pBSSList->uIELength = uIELength; - if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) - pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; - memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); - - return true; -} - -/*+ - * - * Routine Description: - * Search Node DB table to find the index of matched DstAddr - * - * Return Value: - * None - * - -*/ - -bool -BSSDBbIsSTAInNodeDB(void *pMgmtObject, unsigned char *abyDstAddr, - unsigned int *puNodeIndex) -{ - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - unsigned int ii; - - /* Index = 0 reserved for AP Node */ - for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { - if (pMgmt->sNodeDBTable[ii].bActive) { - if (ether_addr_equal(abyDstAddr, - pMgmt->sNodeDBTable[ii].abyMACAddr)) { - *puNodeIndex = ii; - return true; - } - } - } - - return false; -}; - -/*+ - * - * Routine Description: - * Find an empty node and allocat it; if there is no empty node, - * then use the most inactive one. - * - * Return Value: - * None - * - -*/ -void -BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int ii; - unsigned int BigestCount = 0; - unsigned int SelectIndex; - struct sk_buff *skb; - /* - * Index = 0 reserved for AP Node (In STA mode) - * Index = 0 reserved for Broadcast/MultiCast (In AP mode) - */ - SelectIndex = 1; - for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { - if (pMgmt->sNodeDBTable[ii].bActive) { - if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) { - BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount; - SelectIndex = ii; - } - } else { - break; - } - } - - /* if not found replace uInActiveCount is largest one */ - if (ii == (MAX_NODE_NUM + 1)) { - *puNodeIndex = SelectIndex; - pr_info("Replace inactive node = %d\n", SelectIndex); - /* clear ps buffer */ - if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) { - while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL) - dev_kfree_skb(skb); - } - } else { - *puNodeIndex = ii; - } - - memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB)); - pMgmt->sNodeDBTable[*puNodeIndex].bActive = true; - pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND; - /* for AP mode PS queue */ - skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue); - pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0; - pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0; - pr_debug("Create node index = %d\n", ii); - return; -}; - -/*+ - * - * Routine Description: - * Remove Node by NodeIndex - * - * - * Return Value: - * None - * - -*/ -void -BSSvRemoveOneNode( - void *hDeviceContext, - unsigned int uNodeIndex -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - struct sk_buff *skb; - - while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL) - dev_kfree_skb(skb); - /* clear context */ - memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB)); - /* clear tx bit map */ - pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7]; - - return; -}; -/*+ - * - * Routine Description: - * Update AP Node content in Index 0 of KnownNodeDB - * - * - * Return Value: - * None - * - -*/ - -void -BSSvUpdateAPNode( - void *hDeviceContext, - unsigned short *pwCapInfo, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uRateLen = WLAN_RATES_MAXLEN; - - memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); - - pMgmt->sNodeDBTable[0].bActive = true; - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) - uRateLen = WLAN_RATES_MAXLEN_11B; - pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - uRateLen); - pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - uRateLen); - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - true, - &(pMgmt->sNodeDBTable[0].wMaxBasicRate), - &(pMgmt->sNodeDBTable[0].wMaxSuppRate), - &(pMgmt->sNodeDBTable[0].wSuppRate), - &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) -); - memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate; - pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo); - pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND; - netdev_dbg(pDevice->dev, "BSSvUpdateAPNode:MaxSuppRate is %d\n", - pMgmt->sNodeDBTable[0].wMaxSuppRate); - /* auto rate fallback function initiation */ - pr_debug("pMgmt->sNodeDBTable[0].wTxDataRate = %d\n", - pMgmt->sNodeDBTable[0].wTxDataRate); -}; - -/*+ - * - * Routine Description: - * Add Multicast Node content in Index 0 of KnownNodeDB - * - * - * Return Value: - * None - * - -*/ - -void -BSSvAddMulticastNode( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - - if (!pDevice->bEnableHostWEP) - memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); - memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[0].bActive = true; - pMgmt->sNodeDBTable[0].bPSEnable = false; - skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue); - RATEvParseMaxRate((void *)pDevice, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, - (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, - true, - &(pMgmt->sNodeDBTable[0].wMaxBasicRate), - &(pMgmt->sNodeDBTable[0].wMaxSuppRate), - &(pMgmt->sNodeDBTable[0].wSuppRate), - &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), - &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) -); - pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate; - netdev_dbg(pDevice->dev, - "BSSvAddMultiCastNode:pMgmt->sNodeDBTable[0].wTxDataRate is %d\n", - pMgmt->sNodeDBTable[0].wTxDataRate); - pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND; -}; - -/*+ - * - * Routine Description: - * - * - * Second call back function to update Node DB info & AP link status - * - * - * Return Value: - * none. - * - -*/ -void -BSSvSecondCallBack( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int ii; - PWLAN_IE_SSID pItemSSID, pCurrSSID; - unsigned int uSleepySTACnt = 0; - unsigned int uNonShortSlotSTACnt = 0; - unsigned int uLongPreambleSTACnt = 0; - viawget_wpa_header *wpahdr; /* DavidWang */ - - spin_lock_irq(&pDevice->lock); - - pDevice->uAssocCount = 0; - - pDevice->byERPFlag &= - ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1)); - - if (pDevice->wUseProtectCntDown > 0) { - pDevice->wUseProtectCntDown--; - } else { - /* disable protect mode */ - pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1)); - } - - if (pDevice->eCommandState == WLAN_ASSOCIATE_WAIT) { - pDevice->byReAssocCount++; - /* 10 sec timeout */ - if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) { - netdev_info(pDevice->dev, "Re-association timeout!!!\n"); - pDevice->byReAssocCount = 0; -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - { - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } -#endif - } else if (pDevice->bLinkPass) - pDevice->byReAssocCount = 0; - } - -#ifdef Calcu_LinkQual - s_uCalculateLinkQual((void *)pDevice); -#endif - - for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { - if (pMgmt->sNodeDBTable[ii].bActive) { - /* increase in-activity counter */ - pMgmt->sNodeDBTable[ii].uInActiveCount++; - - if (ii > 0) { - if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) { - BSSvRemoveOneNode(pDevice, ii); - pr_debug("Inactive timeout [%d] sec, STA index = [%d] remove\n", - MAX_INACTIVE_COUNT, ii); - continue; - } - - if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) { - pDevice->uAssocCount++; - - /* check if Non ERP exist */ - if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) { - if (!pMgmt->sNodeDBTable[ii].bShortPreamble) { - pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1); - uLongPreambleSTACnt++; - } - if (!pMgmt->sNodeDBTable[ii].bERPExist) { - pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1); - pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); - } - if (!pMgmt->sNodeDBTable[ii].bShortSlotTime) - uNonShortSlotSTACnt++; - } - } - - /* check if any STA in PS mode */ - if (pMgmt->sNodeDBTable[ii].bPSEnable) - uSleepySTACnt++; - - } - - /* rate fallback check */ - if (!pDevice->bFixRate) { - if (ii > 0) { - /* ii = 0 for multicast node (AP & Adhoc) */ - RATEvTxRateFallBack((void *)pDevice, &(pMgmt->sNodeDBTable[ii])); - } else { - /* ii = 0 reserved for unicast AP node (Infra STA) */ - if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) - netdev_dbg(pDevice->dev, - "SecondCallback:Before:TxDataRate is %d\n", - pMgmt->sNodeDBTable[0].wTxDataRate); - RATEvTxRateFallBack((void *)pDevice, &(pMgmt->sNodeDBTable[ii])); - netdev_dbg(pDevice->dev, - "SecondCallback:After:TxDataRate is %d\n", - pMgmt->sNodeDBTable[0].wTxDataRate); - - } - - } - - /* check if pending PS queue */ - if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) { - pr_debug("Index= %d, Queue = %d pending\n", - ii, - pMgmt->sNodeDBTable[ii].wEnQueueCnt); - if ((ii > 0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) { - BSSvRemoveOneNode(pDevice, ii); - pr_info("Pending many queues PS STA Index = %d remove\n", - ii); - continue; - } - } - } - - } - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->eCurrentPHYType == PHY_TYPE_11G)) { - /* on/off protect mode */ - if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) { - if (!pDevice->bProtectMode) { - MACvEnableProtectMD(pDevice->PortOffset); - pDevice->bProtectMode = true; - } - } else { - if (pDevice->bProtectMode) { - MACvDisableProtectMD(pDevice->PortOffset); - pDevice->bProtectMode = false; - } - } - /* on/off short slot time */ - - if (uNonShortSlotSTACnt > 0) { - if (pDevice->bShortSlotTime) { - pDevice->bShortSlotTime = false; - BBvSetShortSlotTime(pDevice); - vUpdateIFS((void *)pDevice); - } - } else { - if (!pDevice->bShortSlotTime) { - pDevice->bShortSlotTime = true; - BBvSetShortSlotTime(pDevice); - vUpdateIFS((void *)pDevice); - } - } - - /* on/off barker long preamble mode */ - - if (uLongPreambleSTACnt > 0) { - if (!pDevice->bBarkerPreambleMd) { - MACvEnableBarkerPreambleMd(pDevice->PortOffset); - pDevice->bBarkerPreambleMd = true; - } - } else { - if (pDevice->bBarkerPreambleMd) { - MACvDisableBarkerPreambleMd(pDevice->PortOffset); - pDevice->bBarkerPreambleMd = false; - } - } - - } - - /* check if any STA in PS mode, enable DTIM multicast deliver */ - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (uSleepySTACnt > 0) - pMgmt->sNodeDBTable[0].bPSEnable = true; - else - pMgmt->sNodeDBTable[0].bPSEnable = false; - } - - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; - pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - - if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) || - (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) { - /* assoc with BSS */ - if (pMgmt->sNodeDBTable[0].bActive) { - if (pDevice->bUpdateBBVGA) - s_vCheckPreEDThreshold((void *)pDevice); - - if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) && - (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) { - pDevice->byBBVGANew = pDevice->abyBBVGA[0]; - } - - if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) { - pMgmt->sNodeDBTable[0].bActive = false; - pMgmt->eCurrMode = WMAC_MODE_STANDBY; - pMgmt->eCurrState = WMAC_STATE_IDLE; - netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = false; - pDevice->bRoaming = true; - pr_info("Lost AP beacon [%d] sec, disconnected !\n", - pMgmt->sNodeDBTable[0].uInActiveCount); - if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) { - wpahdr = (viawget_wpa_header *)pDevice->skb->data; - wpahdr->type = VIAWGET_DISASSOC_MSG; - wpahdr->resp_ie_len = 0; - wpahdr->req_ie_len = 0; - skb_put(pDevice->skb, sizeof(viawget_wpa_header)); - pDevice->skb->dev = pDevice->wpadev; - skb_reset_mac_header(pDevice->skb); - pDevice->skb->pkt_type = PACKET_HOST; - pDevice->skb->protocol = htons(ETH_P_802_2); - memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); - netif_rx(pDevice->skb); - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - } -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - { - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); - wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); - } -#endif - } - } else if (pItemSSID->len != 0) { - if (pDevice->uAutoReConnectTime < 10) { - pDevice->uAutoReConnectTime++; -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - /* - * network manager support need not do - * Roaming scan??? - */ - if (pDevice->bWPASuppWextEnabled) - pDevice->uAutoReConnectTime = 0; -#endif - } else { - /* - * mike use old encryption status - * for wpa reauthentication - */ - if (pDevice->bWPADEVUp) - pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus; - - pr_debug("Roaming ...\n"); - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); - pMgmt->eScanType = WMAC_SCAN_ACTIVE; - pDevice->uAutoReConnectTime = 0; - } - } - } - - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { - /* if adhoc started which essid is NULL string, rescanning */ - if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) { - if (pDevice->uAutoReConnectTime < 10) { - pDevice->uAutoReConnectTime++; - } else { - pr_info("Adhoc re-scanning ...\n"); - pMgmt->eScanType = WMAC_SCAN_ACTIVE; - pDevice->uAutoReConnectTime = 0; - } - } - if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { - if (pDevice->bUpdateBBVGA) - s_vCheckPreEDThreshold((void *)pDevice); - if (pMgmt->sNodeDBTable[0].uInActiveCount >= ADHOC_LOST_BEACON_COUNT) { - pr_info("Lost other STA beacon [%d] sec, started !\n", - pMgmt->sNodeDBTable[0].uInActiveCount); - pMgmt->sNodeDBTable[0].uInActiveCount = 0; - pMgmt->eCurrState = WMAC_STATE_STARTED; - netif_stop_queue(pDevice->dev); - pDevice->bLinkPass = false; - } - } - } - - spin_unlock_irq(&pDevice->lock); - - pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ); - add_timer(&pMgmt->sTimerSecondCallback); -} - -/*+ - * - * Routine Description: - * - * - * Update Tx attemps, Tx failure counter in Node DB - * - * - * Return Value: - * none. - * - -*/ - -void -BSSvUpdateNodeTxCounter( - void *hDeviceContext, - unsigned char byTsr0, - unsigned char byTsr1, - unsigned char *pbyBuffer, - unsigned int uFIFOHeaderSize -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uNodeIndex = 0; - unsigned char byTxRetry = (byTsr0 & TSR0_NCR); - PSTxBufHead pTxBufHead; - PS802_11Header pMACHeader; - unsigned short wRate; - unsigned short wFallBackRate = RATE_1M; - unsigned char byFallBack; - unsigned int ii; - - pTxBufHead = (PSTxBufHead) pbyBuffer; - if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_0) - byFallBack = AUTO_FB_0; - else if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_1) - byFallBack = AUTO_FB_1; - else - byFallBack = AUTO_FB_NONE; - wRate = pTxBufHead->wReserved; - - /* Only Unicast using support rates */ - if (pTxBufHead->wFIFOCtl & FIFOCTL_NEEDACK) { - pr_debug("wRate %04X, byTsr0 %02X, byTsr1 %02X\n", - wRate, byTsr0, byTsr1); - if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { - pMgmt->sNodeDBTable[0].uTxAttempts += 1; - if ((byTsr1 & TSR1_TERR) == 0) { - /* transmit success, TxAttempts at least plus one */ - pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++; - if ((byFallBack == AUTO_FB_NONE) || - (wRate < RATE_18M)) { - wFallBackRate = wRate; - } else if (byFallBack == AUTO_FB_0) { - if (byTxRetry < 5) - wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry]; - else - wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; - } else if (byFallBack == AUTO_FB_1) { - if (byTxRetry < 5) - wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry]; - else - wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; - } - pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++; - } else { - pMgmt->sNodeDBTable[0].uTxFailures++; - } - pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry; - if (byTxRetry != 0) { - pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE] += byTxRetry; - if ((byFallBack == AUTO_FB_NONE) || - (wRate < RATE_18M)) { - pMgmt->sNodeDBTable[0].uTxFail[wRate] += byTxRetry; - } else if (byFallBack == AUTO_FB_0) { - for (ii = 0; ii < byTxRetry; ii++) { - if (ii < 5) - wFallBackRate = awHWRetry0[wRate-RATE_18M][ii]; - else - wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; - pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; - } - } else if (byFallBack == AUTO_FB_1) { - for (ii = 0; ii < byTxRetry; ii++) { - if (ii < 5) - wFallBackRate = awHWRetry1[wRate-RATE_18M][ii]; - else - wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; - pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; - } - } - } - } - - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || - (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { - pMACHeader = (PS802_11Header)(pbyBuffer + uFIFOHeaderSize); - - if (BSSDBbIsSTAInNodeDB((void *)pMgmt, &(pMACHeader->abyAddr1[0]), &uNodeIndex)) { - pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1; - if ((byTsr1 & TSR1_TERR) == 0) { - /* transmit success, TxAttempts at least plus one */ - pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++; - if ((byFallBack == AUTO_FB_NONE) || - (wRate < RATE_18M)) { - wFallBackRate = wRate; - } else if (byFallBack == AUTO_FB_0) { - if (byTxRetry < 5) - wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry]; - else - wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; - } else if (byFallBack == AUTO_FB_1) { - if (byTxRetry < 5) - wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry]; - else - wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; - } - pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++; - } else { - pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++; - } - pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry; - if (byTxRetry != 0) { - pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE] += byTxRetry; - if ((byFallBack == AUTO_FB_NONE) || - (wRate < RATE_18M)) { - pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate] += byTxRetry; - } else if (byFallBack == AUTO_FB_0) { - for (ii = 0; ii < byTxRetry; ii++) { - if (ii < 5) - wFallBackRate = awHWRetry0[wRate - RATE_18M][ii]; - else - wFallBackRate = awHWRetry0[wRate - RATE_18M][4]; - pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; - } - } else if (byFallBack == AUTO_FB_1) { - for (ii = 0; ii < byTxRetry; ii++) { - if (ii < 5) - wFallBackRate = awHWRetry1[wRate-RATE_18M][ii]; - else - wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; - pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; - } - } - } - } - } - } -} - -/*+ - * - * Routine Description: - * Clear Nodes & skb in DB Table - * - * - * Parameters: - * In: - * hDeviceContext - The adapter context. - * uStartIndex - starting index - * Out: - * none - * - * Return Value: - * None. - * - -*/ - -void -BSSvClearNodeDBTable( - void *hDeviceContext, - unsigned int uStartIndex -) - -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - struct sk_buff *skb; - unsigned int ii; - - for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) { - if (pMgmt->sNodeDBTable[ii].bActive) { - /* check if sTxPSQueue has been initial */ - if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) { - while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) { - pr_debug("PS skb != NULL %d\n", ii); - dev_kfree_skb(skb); - } - } - memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB)); - } - } - - return; -}; - -void s_vCheckSensitivity( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PKnownBSS pBSSList = NULL; - PSMgmtObject pMgmt = pDevice->pMgmt; - int ii; - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) && (pDevice->byRFType == RF_RFMD2959) && - (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { - return; - } - - if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || - ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { - pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); - if (pBSSList != NULL) { - /* Update BB Reg if RSSI is too strong */ - long LocalldBmAverage = 0; - long uNumofdBm = 0; - - for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { - if (pBSSList->ldBmAverage[ii] != 0) { - uNumofdBm++; - LocalldBmAverage += pBSSList->ldBmAverage[ii]; - } - } - if (uNumofdBm > 0) { - LocalldBmAverage = LocalldBmAverage/uNumofdBm; - for (ii = 0; ii < BB_VGA_LEVEL; ii++) { - pr_debug("LocalldBmAverage:%ld, %ld %02x\n", - LocalldBmAverage, - pDevice->ldBmThreshold[ii], - pDevice->abyBBVGA[ii]); - if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) { - pDevice->byBBVGANew = pDevice->abyBBVGA[ii]; - break; - } - } - if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { - pDevice->uBBVGADiffCount++; - } else { - pDevice->uBBVGADiffCount = 0; - } - } - } - } -} - -void -BSSvClearAnyBSSJoinRecord( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int ii; - - for (ii = 0; ii < MAX_BSS_NUM; ii++) - pMgmt->sBSSList[ii].bSelected = false; -} - -#ifdef Calcu_LinkQual -void s_uCalculateLinkQual( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - unsigned long TxOkRatio, TxCnt; - unsigned long RxOkRatio, RxCnt; - unsigned long RssiRatio; - long ldBm; - - TxCnt = pDevice->scStatistic.TxNoRetryOkCount + - pDevice->scStatistic.TxRetryOkCount + - pDevice->scStatistic.TxFailCount; - RxCnt = pDevice->scStatistic.RxFcsErrCnt + - pDevice->scStatistic.RxOkCnt; - TxOkRatio = (TxCnt < 6) ? 4000 : ((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt); - RxOkRatio = (RxCnt < 6) ? 2000 : ((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt); - /* decide link quality */ - if (!pDevice->bLinkPass) { - pDevice->scStatistic.LinkQuality = 0; - pDevice->scStatistic.SignalStren = 0; - } else { - RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm); - if (-ldBm < 50) - RssiRatio = 4000; - else if (-ldBm > 90) - RssiRatio = 0; - else - RssiRatio = (40-(-ldBm-50))*4000/40; - pDevice->scStatistic.SignalStren = RssiRatio/40; - pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100; - } - pDevice->scStatistic.RxFcsErrCnt = 0; - pDevice->scStatistic.RxOkCnt = 0; - pDevice->scStatistic.TxFailCount = 0; - pDevice->scStatistic.TxNoRetryOkCount = 0; - pDevice->scStatistic.TxRetryOkCount = 0; -} -#endif - -void s_vCheckPreEDThreshold( - void *hDeviceContext -) -{ - struct vnt_private *pDevice = hDeviceContext; - PKnownBSS pBSSList = NULL; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - - if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || - ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { - pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); - if (pBSSList != NULL) - pDevice->byBBPreEDRSSI = (unsigned char) (~(pBSSList->ldBmAverRange) + 1); - } -} diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index 8a37a11809bb..511b7f907953 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -207,119 +207,4 @@ typedef struct tagKnownNodeDB { unsigned int uTimeCount; } KnownNodeDB, *PKnownNodeDB; -PKnownBSS -BSSpSearchBSSList( - void *hDeviceContext, - unsigned char *pbyDesireBSSID, - unsigned char *pbyDesireSSID, - CARD_PHY_TYPE ePhyType -); - -PKnownBSS -BSSpAddrIsInBSSList( - void *hDeviceContext, - unsigned char *abyBSSID, - PWLAN_IE_SSID pSSID -); - -void -BSSvClearBSSList( - void *hDeviceContext, - bool bKeepCurrBSSID -); - -bool -BSSbInsertToBSSList( - void *hDeviceContext, - unsigned char *abyBSSIDAddr, - __le64 qwTimestamp, - unsigned short wBeaconInterval, - unsigned short wCapInfo, - unsigned char byCurrChannel, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - unsigned int uIELength, - unsigned char *pbyIEs, - void *pRxPacketContext -); - -bool -BSSbUpdateToBSSList( - void *hDeviceContext, - __le64 qwTimestamp, - unsigned short wBeaconInterval, - unsigned short wCapInfo, - unsigned char byCurrChannel, - bool bChannelHit, - PWLAN_IE_SSID pSSID, - PWLAN_IE_SUPP_RATES pSuppRates, - PWLAN_IE_SUPP_RATES pExtSuppRates, - PERPObject psERP, - PWLAN_IE_RSN pRSN, - PWLAN_IE_RSN_EXT pRSNWPA, - PWLAN_IE_COUNTRY pIE_Country, - PWLAN_IE_QUIET pIE_Quiet, - PKnownBSS pBSSList, - unsigned int uIELength, - unsigned char *pbyIEs, - void *pRxPacketContext -); - -bool -BSSDBbIsSTAInNodeDB(void *hDeviceContext, unsigned char *abyDstAddr, - unsigned int *puNodeIndex); - -void -BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex); - -void -BSSvUpdateAPNode( - void *hDeviceContext, - unsigned short *pwCapInfo, - PWLAN_IE_SUPP_RATES pItemRates, - PWLAN_IE_SUPP_RATES pExtSuppRates -); - -void -BSSvSecondCallBack( - void *hDeviceContext -); - -void -BSSvUpdateNodeTxCounter( - void *hDeviceContext, - unsigned char byTsr0, - unsigned char byTsr1, - unsigned char *pbyBuffer, - unsigned int uFIFOHeaderSize -); - -void -BSSvRemoveOneNode( - void *hDeviceContext, - unsigned int uNodeIndex -); - -void -BSSvAddMulticastNode( - void *hDeviceContext -); - -void -BSSvClearNodeDBTable( - void *hDeviceContext, - unsigned int uStartIndex -); - -void -BSSvClearAnyBSSJoinRecord( - void *hDeviceContext -); - #endif /*__BSSDB_H__ */ diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 9cc3a67399ed..85374decaefa 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -488,8 +488,6 @@ VNTWIFIvUpdateNodeTxCounter( if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { - if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false) - return; } pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++; @@ -516,7 +514,6 @@ VNTWIFIvGetTxRate( ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - unsigned int uNodeIndex = 0; unsigned short wTxDataRate = RATE_1M; unsigned char byACKRate = RATE_1M; unsigned char byCCKBasicRate = RATE_1M; @@ -527,19 +524,6 @@ VNTWIFIvGetTxRate( if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { /* Adhoc Tx rate decided from node DB */ - if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) { - wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate); - pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates); - pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates); - } else { - if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) - wTxDataRate = RATE_2M; - else - wTxDataRate = RATE_24M; - - pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates; - pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates; - } } else { /* Infrastructure: rate decided from AP Node, index = 0 */ wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate); -- cgit v1.2.3-59-g8ed1b From f3de0df9b01a45d0d95bb1e43750d895ef8d79db Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:33 +0000 Subject: staging: vt6655: dead code datarate.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/datarate.c | 410 ----------------------------------- drivers/staging/vt6655/datarate.h | 78 ------- drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/vntwifi.c | 14 -- 5 files changed, 504 deletions(-) delete mode 100644 drivers/staging/vt6655/datarate.c delete mode 100644 drivers/staging/vt6655/datarate.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 2c0b7932b297..3c993a86f745 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -12,7 +12,6 @@ vt6655_stage-y += device_main.o \ rxtx.o \ dpc.o \ power.o \ - datarate.o \ srom.o \ mib.o \ rc4.o \ diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c deleted file mode 100644 index 52907a4fae9d..000000000000 --- a/drivers/staging/vt6655/datarate.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: datarate.c - * - * Purpose: Handles the auto fallback & data rates functions - * - * Author: Lyndon Chen - * - * Date: July 17, 2002 - * - * Functions: - * RATEvParseMaxRate - Parsing the highest basic & support rate in rate field of frame - * RATEvTxRateFallBack - Rate fallback Algorithm Implementaion - * RATEuSetIE- Set rate IE field. - * - * Revision History: - * - */ - -#include "ttype.h" -#include "tmacro.h" -#include "mac.h" -#include "80211mgr.h" -#include "bssdb.h" -#include "datarate.h" -#include "card.h" -#include "baseband.h" -#include "srom.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -extern unsigned short TxRate_iwconfig; /* 2008-5-8 by chester */ -/*--------------------- Static Variables --------------------------*/ -static const unsigned char acbyIERate[MAX_RATE] = { -0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C -}; - -#define AUTORATE_TXOK_CNT 0x0400 -#define AUTORATE_TXFAIL_CNT 0x0064 -#define AUTORATE_TIMEOUT 10 - -/*--------------------- Static Functions --------------------------*/ - -void s_vResetCounter( - PKnownNodeDB psNodeDBTable -); - -void -s_vResetCounter( - PKnownNodeDB psNodeDBTable -) -{ - unsigned char ii; - - /* clear statistic counter for auto_rate */ - for (ii = 0; ii <= MAX_RATE; ii++) { - psNodeDBTable->uTxOk[ii] = 0; - psNodeDBTable->uTxFail[ii] = 0; - } -} - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/*+ - * - * Description: - * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE - * - * Parameters: - * In: - * unsigned char - Rate value in SuppRates IE or ExtSuppRates IE - * Out: - * none - * - * Return Value: RateIdx - * - -*/ -unsigned char -DATARATEbyGetRateIdx( - unsigned char byRate -) -{ - unsigned char ii; - - /* Erase basicRate flag. */ - byRate = byRate & 0x7F;/* 0111 1111 */ - - for (ii = 0; ii < MAX_RATE; ii++) { - if (acbyIERate[ii] == byRate) - return ii; - } - return 0; -} - -/*+ - * - * Routine Description: - * Rate fallback Algorithm Implementation - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * psNodeDBTable - Pointer to Node Data Base - * Out: - * none - * - * Return Value: none - * - -*/ -#define AUTORATE_TXCNT_THRESHOLD 20 -#define AUTORATE_INC_THRESHOLD 30 - -/*+ - * - * Description: - * Get RateIdx from the value in SuppRates IE or ExtSuppRates IE - * - * Parameters: - * In: - * unsigned char - Rate value in SuppRates IE or ExtSuppRates IE - * Out: - * none - * - * Return Value: RateIdx - * - -*/ -unsigned short -wGetRateIdx( - unsigned char byRate -) -{ - unsigned short ii; - - /* Erase basicRate flag. */ - byRate = byRate & 0x7F;/* 0111 1111 */ - - for (ii = 0; ii < MAX_RATE; ii++) { - if (acbyIERate[ii] == byRate) - return ii; - } - - return 0; -} - -/*+ - * - * Description: - * Parsing the highest basic & support rate in rate field of frame. - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * pItemRates - Pointer to Rate field defined in 802.11 spec. - * pItemExtRates - Pointer to Extended Rate field defined in 802.11 spec. - * Out: - * pwMaxBasicRate - Maximum Basic Rate - * pwMaxSuppRate - Maximum Supported Rate - * pbyTopCCKRate - Maximum Basic Rate in CCK mode - * pbyTopOFDMRate - Maximum Basic Rate in OFDM mode - * - * Return Value: none - * - -*/ -void -RATEvParseMaxRate( - void *pDeviceHandler, - PWLAN_IE_SUPP_RATES pItemRates, - PWLAN_IE_SUPP_RATES pItemExtRates, - bool bUpdateBasicRate, - unsigned short *pwMaxBasicRate, - unsigned short *pwMaxSuppRate, - unsigned short *pwSuppRate, - unsigned char *pbyTopCCKRate, - unsigned char *pbyTopOFDMRate -) -{ - struct vnt_private *pDevice = pDeviceHandler; - unsigned int ii; - unsigned char byHighSuppRate = 0; - unsigned char byRate = 0; - unsigned short wOldBasicRate = pDevice->wBasicRate; - unsigned int uRateLen; - - if (pItemRates == NULL) - return; - - *pwSuppRate = 0; - uRateLen = pItemRates->len; - - pr_debug("ParseMaxRate Len: %d\n", uRateLen); - if (pDevice->eCurrentPHYType != PHY_TYPE_11B) { - if (uRateLen > WLAN_RATES_MAXLEN) - uRateLen = WLAN_RATES_MAXLEN; - } else { - if (uRateLen > WLAN_RATES_MAXLEN_11B) - uRateLen = WLAN_RATES_MAXLEN_11B; - } - - for (ii = 0; ii < uRateLen; ii++) { - byRate = (unsigned char)(pItemRates->abyRates[ii]); - if (WLAN_MGMT_IS_BASICRATE(byRate) && bUpdateBasicRate) { - /* Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate */ - CARDbAddBasicRate((void *)pDevice, wGetRateIdx(byRate)); - pr_debug("ParseMaxRate AddBasicRate: %d\n", - wGetRateIdx(byRate)); - } - byRate = (unsigned char)(pItemRates->abyRates[ii]&0x7F); - if (byHighSuppRate == 0) - byHighSuppRate = byRate; - if (byRate > byHighSuppRate) - byHighSuppRate = byRate; - *pwSuppRate |= (1<byElementID == WLAN_EID_EXTSUPP_RATES) && - (pDevice->eCurrentPHYType != PHY_TYPE_11B)) { - unsigned int uExtRateLen = pItemExtRates->len; - - if (uExtRateLen > WLAN_RATES_MAXLEN) - uExtRateLen = WLAN_RATES_MAXLEN; - - for (ii = 0; ii < uExtRateLen; ii++) { - byRate = (unsigned char)(pItemExtRates->abyRates[ii]); - /* select highest basic rate */ - if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) { - /* Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate */ - CARDbAddBasicRate((void *)pDevice, wGetRateIdx(byRate)); - pr_debug("ParseMaxRate AddBasicRate: %d\n", - wGetRateIdx(byRate)); - } - byRate = (unsigned char)(pItemExtRates->abyRates[ii]&0x7F); - if (byHighSuppRate == 0) - byHighSuppRate = byRate; - if (byRate > byHighSuppRate) - byHighSuppRate = byRate; - *pwSuppRate |= (1<byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) - pDevice->byPacketType = PK_TYPE_11GA; - - *pbyTopCCKRate = pDevice->byTopCCKBasicRate; - *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate; - *pwMaxSuppRate = wGetRateIdx(byHighSuppRate); - if ((pDevice->byPacketType == PK_TYPE_11B) || (pDevice->byPacketType == PK_TYPE_11GB)) - *pwMaxBasicRate = pDevice->byTopCCKBasicRate; - else - *pwMaxBasicRate = pDevice->byTopOFDMBasicRate; - if (wOldBasicRate != pDevice->wBasicRate) - CARDvSetRSPINF((void *)pDevice, pDevice->eCurrentPHYType); - - pr_debug("Exit ParseMaxRate\n"); -} - -/*+ - * - * Routine Description: - * Rate fallback Algorithm Implementaion - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * psNodeDBTable - Pointer to Node Data Base - * Out: - * none - * - * Return Value: none - * - -*/ -#define AUTORATE_TXCNT_THRESHOLD 20 -#define AUTORATE_INC_THRESHOLD 30 - -void -RATEvTxRateFallBack( - void *pDeviceHandler, - PKnownNodeDB psNodeDBTable -) -{ - struct vnt_private *pDevice = pDeviceHandler; - unsigned short wIdxDownRate = 0; - unsigned int ii; - bool bAutoRate[MAX_RATE] = {true, true, true, true, false, false, true, true, true, true, true, true}; - unsigned long dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540}; - unsigned long dwThroughput = 0; - unsigned short wIdxUpRate = 0; - unsigned long dwTxDiff = 0; - - if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) - /* Don't do Fallback when scanning Channel */ - return; - - psNodeDBTable->uTimeCount++; - - if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE]) - dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE]; - - if ((psNodeDBTable->uTxOk[MAX_RATE] < AUTORATE_TXOK_CNT) && - (dwTxDiff < AUTORATE_TXFAIL_CNT) && - (psNodeDBTable->uTimeCount < AUTORATE_TIMEOUT)) { - return; - } - - if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) - psNodeDBTable->uTimeCount = 0; - - for (ii = 0; ii < MAX_RATE; ii++) { - if (psNodeDBTable->wSuppRate & (0x0001<wTxDataRate; ii++) { - if ((psNodeDBTable->uTxOk[ii] != 0) || - (psNodeDBTable->uTxFail[ii] != 0)) { - dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii]; - if (ii < RATE_11M) - psNodeDBTable->uTxFail[ii] *= 4; - - dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]); - } - } - dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate]; - - wIdxDownRate = psNodeDBTable->wTxDataRate; - for (ii = psNodeDBTable->wTxDataRate; ii > 0;) { - ii--; - if ((dwThroughputTbl[ii] > dwThroughput) && bAutoRate[ii]) { - dwThroughput = dwThroughputTbl[ii]; - wIdxDownRate = (unsigned short) ii; - } - } - psNodeDBTable->wTxDataRate = wIdxDownRate; - if (psNodeDBTable->uTxOk[MAX_RATE]) { - if (psNodeDBTable->uTxOk[MAX_RATE] > - (psNodeDBTable->uTxFail[MAX_RATE] * 4)) { - psNodeDBTable->wTxDataRate = wIdxUpRate; - } - } else { - /* adhoc, if uTxOk =0 & uTxFail = 0 */ - if (psNodeDBTable->uTxFail[MAX_RATE] == 0) - psNodeDBTable->wTxDataRate = wIdxUpRate; - } - - /* 2008-5-8 by chester */ - TxRate_iwconfig = psNodeDBTable->wTxDataRate; - s_vResetCounter(psNodeDBTable); -} - -/*+ - * - * Description: - * This routine is used to assemble available Rate IE. - * - * Parameters: - * In: - * pDevice - * Out: - * - * Return Value: None - * - -*/ -unsigned char -RATEuSetIE( - PWLAN_IE_SUPP_RATES pSrcRates, - PWLAN_IE_SUPP_RATES pDstRates, - unsigned int uRateLen -) -{ - unsigned int ii, uu, uRateCnt = 0; - - if ((pSrcRates == NULL) || (pDstRates == NULL)) - return 0; - - if (pSrcRates->len == 0) - return 0; - - for (ii = 0; ii < uRateLen; ii++) { - for (uu = 0; uu < pSrcRates->len; uu++) { - if ((pSrcRates->abyRates[uu] & 0x7F) == acbyIERate[ii]) { - pDstRates->abyRates[uRateCnt++] = pSrcRates->abyRates[uu]; - break; - } - } - } - return (unsigned char)uRateCnt; -} diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h deleted file mode 100644 index d55b07455cc2..000000000000 --- a/drivers/staging/vt6655/datarate.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: datarate.h - * - * Purpose: Handles the auto fallback & data rates functions - * - * Author: Lyndon Chen - * - * Date: July 16, 2002 - * - */ -#ifndef __DATARATE_H__ -#define __DATARATE_H__ - -#define FALLBACK_PKT_COLLECT_TR_H 50 -#define FALLBACK_PKT_COLLECT_TR_L 10 -#define FALLBACK_POLL_SECOND 5 -#define FALLBACK_RECOVER_SECOND 30 -#define FALLBACK_THRESHOLD 15 -#define UPGRADE_THRESHOLD 5 -#define UPGRADE_CNT_THRD 3 -#define RETRY_TIMES_THRD_H 2 -#define RETRY_TIMES_THRD_L 1 - -void -RATEvParseMaxRate( - void *pDeviceHandler, - PWLAN_IE_SUPP_RATES pItemRates, - PWLAN_IE_SUPP_RATES pItemExtRates, - bool bUpdateBasicRate, - unsigned short *pwMaxBasicRate, - unsigned short *pwMaxSuppRate, - unsigned short *pwSuppRate, - unsigned char *pbyTopCCKRate, - unsigned char *pbyTopOFDMRate -); - -void -RATEvTxRateFallBack( - void *pDeviceHandler, - PKnownNodeDB psNodeDBTable -); - -unsigned char -RATEuSetIE( - PWLAN_IE_SUPP_RATES pSrcRates, - PWLAN_IE_SUPP_RATES pDstRates, - unsigned int uRateLen -); - -unsigned short -wGetRateIdx( - unsigned char byRate -); - -unsigned char -DATARATEbyGetRateIdx( - unsigned char byRate -); - -#endif /* __DATARATE_H__ */ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 991a276f1ecf..848c258119a6 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -69,7 +69,6 @@ #include "wroute.h" #include "bssdb.h" #include "dpc.h" -#include "datarate.h" #include "rf.h" #include "iowpa.h" #include diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 85374decaefa..27e055e89f7e 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -36,7 +36,6 @@ #include "country.h" #include "device.h" #include "wmgr.h" -#include "datarate.h" /*--------------------- Static Definitions -------------------------*/ @@ -210,7 +209,6 @@ VNTWIFIbyGetMaxSupportRate( if (pSupportRateIEs) { for (ii = 0; ii < pSupportRateIEs->len; ii++) { - bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]); if (bySupportRate > byMaxSupportRate) byMaxSupportRate = bySupportRate; @@ -218,7 +216,6 @@ VNTWIFIbyGetMaxSupportRate( } if (pExtSupportRateIEs) { for (ii = 0; ii < pExtSupportRateIEs->len; ii++) { - bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]); if (bySupportRate > byMaxSupportRate) byMaxSupportRate = bySupportRate; @@ -252,7 +249,6 @@ VNTWIFIbyGetACKTxRate( ) { unsigned char byMaxAckRate; - unsigned char byBasicRate; unsigned int ii; if (byRxDataRate <= RATE_11M) { @@ -264,22 +260,12 @@ VNTWIFIbyGetACKTxRate( if (pSupportRateIEs) { for (ii = 0; ii < pSupportRateIEs->len; ii++) { if (pSupportRateIEs->abyRates[ii] & 0x80) { - byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]); - if ((byBasicRate <= byRxDataRate) && - (byBasicRate > byMaxAckRate)) { - byMaxAckRate = byBasicRate; - } } } } if (pExtSupportRateIEs) { for (ii = 0; ii < pExtSupportRateIEs->len; ii++) { if (pExtSupportRateIEs->abyRates[ii] & 0x80) { - byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]); - if ((byBasicRate <= byRxDataRate) && - (byBasicRate > byMaxAckRate)) { - byMaxAckRate = byBasicRate; - } } } } -- cgit v1.2.3-59-g8ed1b From 86b5afa757cddcf26b7ee6a2f21b70e313776faa Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:34 +0000 Subject: staging: vt6655: dead code remove IEEE11.h.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/IEEE11h.c | 139 --------------------------------------- drivers/staging/vt6655/IEEE11h.h | 42 ------------ drivers/staging/vt6655/Makefile | 3 +- drivers/staging/vt6655/vntwifi.c | 3 - 4 files changed, 1 insertion(+), 186 deletions(-) delete mode 100644 drivers/staging/vt6655/IEEE11h.c delete mode 100644 drivers/staging/vt6655/IEEE11h.h diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c deleted file mode 100644 index 65eb4823a7f5..000000000000 --- a/drivers/staging/vt6655/IEEE11h.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: IEEE11h.c - * - * Purpose: - * - * Functions: - * - * Revision History: - * - * Author: Yiching Chen - * - * Date: Mar. 31, 2005 - * - */ - -#include "ttype.h" -#include "tmacro.h" -#include "tether.h" -#include "IEEE11h.h" -#include "device.h" -#include "wmgr.h" -#include "rxtx.h" -#include "channel.h" - -/*--------------------- Static Definitions -------------------------*/ - -#pragma pack(1) - -typedef struct _WLAN_FRAME_ACTION { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char abyVars[1]; -} WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION; - -typedef struct _WLAN_FRAME_MSRREQ { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_MEASURE_REQ sMSRReqEIDs[1]; -} WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ; - -typedef struct _WLAN_FRAME_MSRREP { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_MEASURE_REP sMSRRepEIDs[1]; -} WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP; - -typedef struct _WLAN_FRAME_TPCREQ { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_TPC_REQ sTPCReqEIDs; -} WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ; - -typedef struct _WLAN_FRAME_TPCREP { - WLAN_80211HDR_A3 Header; - unsigned char byCategory; - unsigned char byAction; - unsigned char byDialogToken; - WLAN_IE_TPC_REP sTPCRepEIDs; -} WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP; - -#pragma pack() - -/* action field reference ieee 802.11h Table 20e */ -#define ACTION_MSRREQ 0 -#define ACTION_MSRREP 1 -#define ACTION_TPCREQ 2 -#define ACTION_TPCREP 3 -#define ACTION_CHSW 4 - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -bool IEEE11hbMSRRepTx(void *pMgmtHandle) -{ - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; - PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP) - (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket)); - size_t uLength = 0; - PSTxMgmtPacket pTxPacket = NULL; - - pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep; - memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + - sizeof(STxMgmtPacket)); - - pMSRRep->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | - WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) -); - - memcpy(pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ) - (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN); - memcpy(pMSRRep->Header.abyAddr2, - CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN); - memcpy(pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - - pMSRRep->byCategory = 0; - pMSRRep->byAction = 1; - pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ) - (pMgmt->abyCurrentMSRReq))->byDialogToken; - - uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP, - sMSRRepEIDs); - - pTxPacket->cbMPDULen = uLength; - pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN; - return true; -} diff --git a/drivers/staging/vt6655/IEEE11h.h b/drivers/staging/vt6655/IEEE11h.h deleted file mode 100644 index b3e318d7278f..000000000000 --- a/drivers/staging/vt6655/IEEE11h.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: IEEE11h.h - * - * Purpose: Defines the macros, types, and functions for dealing - * with IEEE 802.11h. - * - * Author: Yiching Chen - * - * Date: Mar. 31, 2005 - * - */ - -#ifndef __IEEE11h_H__ -#define __IEEE11h_H__ - -#include "ttype.h" -#include "80211hdr.h" -#include "80211mgr.h" - -bool IEEE11hbMSRRepTx( - void *pMgmtHandle -); - -#endif /* __IEEE11h_H__ */ diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 3c993a86f745..141c0c11ee22 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -25,7 +25,6 @@ vt6655_stage-y += device_main.o \ rf.o \ wpa2.o \ aes_ccmp.o \ - vntwifi.o \ - IEEE11h.o + vntwifi.o obj-$(CONFIG_VT6655) += vt6655_stage.o diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 27e055e89f7e..a5eccf7cec8b 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -32,7 +32,6 @@ */ #include "vntwifi.h" -#include "IEEE11h.h" #include "country.h" #include "device.h" #include "wmgr.h" @@ -648,8 +647,6 @@ VNTWIFIbMeasureReport( pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len); pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID; } - if (bEndOfReport) - IEEE11hbMSRRepTx(pMgmt); return true; } -- cgit v1.2.3-59-g8ed1b From dd1c689cec2dbfcb3910a002b39282efe10c29fe Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:35 +0000 Subject: staging: vt6655: card.c/h remove dead functions Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 724 ------------------------------------------ drivers/staging/vt6655/card.h | 75 ----- 2 files changed, 799 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 72896c1b842d..bff77c88a792 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -34,8 +34,6 @@ * CARDvUpdateNextTBTT - Sync. NIC Beacon time * CARDbRadioPowerOff - Turn Off NIC Radio Power * CARDbRadioPowerOn - Turn On NIC Radio Power - * CARDbSetWEPMode - Set NIC Wep mode - * CARDbSetTxPower - Set NIC tx power * * Revision History: * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. @@ -50,12 +48,7 @@ #include "mac.h" #include "desc.h" #include "rf.h" -#include "vntwifi.h" #include "power.h" -#include "key.h" -#include "rc4.h" -#include "country.h" -#include "channel.h" /*--------------------- Static Definitions -------------------------*/ @@ -200,43 +193,6 @@ s_vCalculateOFDMRParameter( /*--------------------- Export Functions --------------------------*/ -/* - * Description: Get Card short preamble option value - * - * Parameters: - * In: - * pDevice - The adapter to be set - * Out: - * none - * - * Return Value: true if short preamble; otherwise false - */ -bool CARDbIsShortPreamble(struct vnt_private *pDevice) -{ - - if (pDevice->byPreambleType == 0) - return false; - - return true; -} - -/* - * Description: Get Card short slot time option value - * - * Parameters: - * In: - * pDevice - The adapter to be set - * Out: - * none - * - * Return Value: true if short slot time; otherwise false - */ -bool CARDbIsShorSlotTime(struct vnt_private *pDevice) -{ - - return pDevice->bShortSlotTime; -} - /* * Description: Update IFS * @@ -454,218 +410,6 @@ bool CARDbSetBeaconPeriod(struct vnt_private *pDevice, return true; } -/* - * Description: Card Stop Hardware Tx - * - * Parameters: - * In: - * pDeviceHandler - The adapter to be set - * ePktType - Packet type to stop - * Out: - * none - * - * Return Value: true if all data packet complete; otherwise false. - */ -bool CARDbStopTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) -{ - - if (ePktType == PKT_TYPE_802_11_ALL) { - pDevice->bStopBeacon = true; - pDevice->bStopTx0Pkt = true; - pDevice->bStopDataPkt = true; - } else if (ePktType == PKT_TYPE_802_11_BCN) { - pDevice->bStopBeacon = true; - } else if (ePktType == PKT_TYPE_802_11_MNG) { - pDevice->bStopTx0Pkt = true; - } else if (ePktType == PKT_TYPE_802_11_DATA) { - pDevice->bStopDataPkt = true; - } - - if (pDevice->bStopBeacon == true) { - if (pDevice->bIsBeaconBufReadySet == true) { - if (pDevice->cbBeaconBufReadySetCnt < WAIT_BEACON_TX_DOWN_TMO) { - pDevice->cbBeaconBufReadySetCnt++; - return false; - } - } - pDevice->bIsBeaconBufReadySet = false; - pDevice->cbBeaconBufReadySetCnt = 0; - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); - } - /* wait all TD0 complete */ - if (pDevice->bStopTx0Pkt == true) { - if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) - return false; - } - /* wait all Data TD complete */ - if (pDevice->bStopDataPkt == true) { - if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) - return false; - } - - return true; -} - -/* - * Description: Card Start Hardware Tx - * - * Parameters: - * In: - * pDeviceHandler - The adapter to be set - * ePktType - Packet type to start - * Out: - * none - * - * Return Value: true if success; false if failed. - */ -bool CARDbStartTxPacket(struct vnt_private *pDevice, CARD_PKT_TYPE ePktType) -{ - - if (ePktType == PKT_TYPE_802_11_ALL) { - pDevice->bStopBeacon = false; - pDevice->bStopTx0Pkt = false; - pDevice->bStopDataPkt = false; - } else if (ePktType == PKT_TYPE_802_11_BCN) { - pDevice->bStopBeacon = false; - } else if (ePktType == PKT_TYPE_802_11_MNG) { - pDevice->bStopTx0Pkt = false; - } else if (ePktType == PKT_TYPE_802_11_DATA) { - pDevice->bStopDataPkt = false; - } - - if ((pDevice->bStopBeacon == false) && - (pDevice->bBeaconBufReady == true) && - (pDevice->op_mode == NL80211_IFTYPE_ADHOC)) { - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); - } - - return true; -} - -/* - * Description: Card Set BSSID value - * - * Parameters: - * In: - * pDeviceHandler - The adapter to be set - * pbyBSSID - pointer to BSSID field - * bAdhoc - flag to indicate IBSS - * Out: - * none - * - * Return Value: true if success; false if failed. - */ -bool CARDbSetBSSID(struct vnt_private *pDevice, - unsigned char *pbyBSSID, enum nl80211_iftype op_mode) -{ - - MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID); - memcpy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN); - if (op_mode == NL80211_IFTYPE_ADHOC) - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); - else - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); - - if (op_mode == NL80211_IFTYPE_AP) - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); - else - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); - - if (op_mode == NL80211_IFTYPE_UNSPECIFIED) { - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); - pDevice->bBSSIDFilter = false; - pDevice->byRxMode &= ~RCR_BSSID; - pr_debug("wcmd: rx_mode = %x\n", pDevice->byRxMode); - } else { - if (is_zero_ether_addr(pDevice->abyBSSID) == false) { - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); - pDevice->bBSSIDFilter = true; - pDevice->byRxMode |= RCR_BSSID; - } - pr_debug("wmgr: rx_mode = %x\n", pDevice->byRxMode); - } - /* Adopt BSS state in Adapter Device Object */ - pDevice->op_mode = op_mode; - return true; -} - -/* - * Description: Card indicate status - * - * Parameters: - * In: - * pDeviceHandler - The adapter to be set - * eStatus - Status - * Out: - * none - * - * Return Value: true if success; false if failed. - */ - -/* - * Description: Save Assoc info. contain in assoc. response frame - * - * Parameters: - * In: - * pDevice - The adapter to be set - * wCapabilityInfo - Capability information - * wStatus - Status code - * wAID - Assoc. ID - * uLen - Length of IEs - * pbyIEs - pointer to IEs - * Out: - * none - * - * Return Value: true if succeed; otherwise false - */ -bool CARDbSetTxDataRate( - struct vnt_private *pDevice, - unsigned short wDataRate -) -{ - - pDevice->wCurrentRate = wDataRate; - return true; -} - -/* - * Routine Description: - * Consider to power down when no more packets to tx or rx. - * - * Parameters: - * In: - * pDevice - The adapter to be set - * Out: - * none - * - * Return Value: true if power down success; otherwise false - */ -bool -CARDbPowerDown( - struct vnt_private *pDevice -) -{ - unsigned int uIdx; - - /* check if already in Doze mode */ - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) - return true; - - /* Froce PSEN on */ - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN); - - /* check if all TD are empty */ - - for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) { - if (pDevice->iTDUsed[uIdx] != 0) - return false; - } - - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE); - pr_debug("Go to Doze ZZZZZZZZZZZZZZZ\n"); - return true; -} - /* * Description: Turn off Radio power * @@ -761,474 +505,6 @@ bool CARDbRadioPowerOn(struct vnt_private *pDevice) return bResult; } -bool CARDbRemoveKey(struct vnt_private *pDevice, unsigned char *pbyBSSID) -{ - - KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset); - return true; -} - -/* - * Description: - * Add BSSID in PMKID Candidate list. - * - * Parameters: - * In: - * hDeviceContext - device structure point - * pbyBSSID - BSSID address for adding - * wRSNCap - BSS's RSN capability - * Out: - * none - * - * Return Value: none. - */ -bool -CARDbAdd_PMKID_Candidate( - struct vnt_private *pDevice, - unsigned char *pbyBSSID, - bool bRSNCapExist, - unsigned short wRSNCap -) -{ - struct pmkid_candidate *pCandidateList; - unsigned int ii = 0; - - pr_debug("bAdd_PMKID_Candidate START: (%d)\n", - (int)pDevice->gsPMKIDCandidate.NumCandidates); - - if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) { - pr_debug("vFlush_PMKID_Candidate: 3\n"); - memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); - } - - for (ii = 0; ii < 6; ii++) - pr_debug("%02X ", *(pbyBSSID + ii)); - - pr_debug("\n"); - - /* Update Old Candidate */ - for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { - pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; - if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { - if (bRSNCapExist && (wRSNCap & BIT0)) - pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - else - pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - - return true; - } - } - - /* New Candidate */ - pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; - if (bRSNCapExist && (wRSNCap & BIT0)) - pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - else - pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - - ether_addr_copy(pCandidateList->BSSID, pbyBSSID); - pDevice->gsPMKIDCandidate.NumCandidates++; - pr_debug("NumCandidates:%d\n", - (int)pDevice->gsPMKIDCandidate.NumCandidates); - return true; -} - -void * -CARDpGetCurrentAddress( - struct vnt_private *pDevice -) -{ - - return pDevice->abyCurrentNetAddr; -} - -/* - * Description: - * Start Spectrum Measure defined in 802.11h - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -bool -CARDbStartMeasure( - struct vnt_private *pDevice, - void *pvMeasureEIDs, - unsigned int uNumOfMeasureEIDs -) -{ - PWLAN_IE_MEASURE_REQ pEID = (PWLAN_IE_MEASURE_REQ) pvMeasureEIDs; - u64 qwCurrTSF; - u64 qwStartTSF; - bool bExpired = true; - unsigned short wDuration = 0; - - if ((pEID == NULL) || - (uNumOfMeasureEIDs == 0)) { - return true; - } - CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF); - if (pDevice->bMeasureInProgress == true) { - pDevice->bMeasureInProgress = false; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR); - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4); - /* clear measure control */ - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); - MACvSelectPage0(pDevice->PortOffset); - set_channel(pDevice, pDevice->byOrgChannel); - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); - MACvSelectPage0(pDevice->PortOffset); - } - pDevice->uNumOfMeasureEIDs = uNumOfMeasureEIDs; - - do { - pDevice->pCurrMeasureEID = pEID; - pEID++; - pDevice->uNumOfMeasureEIDs--; - - if (pDevice->byLocalID > REV_ID_VT3253_B1) { - qwStartTSF = *((u64 *)(pDevice->pCurrMeasureEID->sReq.abyStartTime)); - wDuration = *((unsigned short *)(pDevice->pCurrMeasureEID->sReq.abyDuration)); - wDuration += 1; /* 1 TU for channel switching */ - - if (qwStartTSF == 0) { - /* start immediately by setting start TSF == current TSF + 2 TU */ - qwStartTSF = qwCurrTSF + 2048; - - bExpired = false; - break; - } else { - /* start at setting start TSF - 1TU(for channel switching) */ - qwStartTSF -= 1024; - } - - if (qwCurrTSF < qwStartTSF) { - bExpired = false; - break; - } - VNTWIFIbMeasureReport(pDevice->pMgmt, - false, - pDevice->pCurrMeasureEID, - MEASURE_MODE_LATE, - pDevice->byBasicMap, - pDevice->byCCAFraction, - pDevice->abyRPIs - ); - } else { - /* hardware do not support measure */ - VNTWIFIbMeasureReport(pDevice->pMgmt, - false, - pDevice->pCurrMeasureEID, - MEASURE_MODE_INCAPABLE, - pDevice->byBasicMap, - pDevice->byCCAFraction, - pDevice->abyRPIs - ); - } - } while (pDevice->uNumOfMeasureEIDs != 0); - - if (!bExpired) { - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART, (u32)qwStartTSF); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART + 4, (u32)(qwStartTSF >> 32)); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_MSRDURATION, wDuration); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); - MACvSelectPage0(pDevice->PortOffset); - } else { - /* all measure start time expired we should complete action */ - VNTWIFIbMeasureReport(pDevice->pMgmt, - true, - NULL, - 0, - pDevice->byBasicMap, - pDevice->byCCAFraction, - pDevice->abyRPIs - ); - } - return true; -} - -/* - * Description: - * Do Channel Switch defined in 802.11h - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -bool -CARDbChannelSwitch( - struct vnt_private *pDevice, - unsigned char byMode, - unsigned char byNewChannel, - unsigned char byCount -) -{ - bool bResult = true; - - if (byCount == 0) { - bResult = set_channel(pDevice, byNewChannel); - VNTWIFIbChannelSwitch(pDevice->pMgmt, byNewChannel); - MACvSelectPage1(pDevice->PortOffset); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); - MACvSelectPage0(pDevice->PortOffset); - return bResult; - } - pDevice->byChannelSwitchCount = byCount; - pDevice->byNewChannel = byNewChannel; - pDevice->bChannelSwitch = true; - if (byMode == 1) - bResult = CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL); - - return bResult; -} - -/* - * Description: - * Handle Quiet EID defined in 802.11h - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -bool -CARDbSetQuiet( - struct vnt_private *pDevice, - bool bResetQuiet, - unsigned char byQuietCount, - unsigned char byQuietPeriod, - unsigned short wQuietDuration, - unsigned short wQuietOffset -) -{ - unsigned int ii = 0; - - if (bResetQuiet) { - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); - for (ii = 0; ii < MAX_QUIET_COUNT; ii++) - pDevice->sQuiet[ii].bEnable = false; - - pDevice->uQuietEnqueue = 0; - pDevice->bEnableFirstQuiet = false; - pDevice->bQuietEnable = false; - pDevice->byQuietStartCount = byQuietCount; - } - if (pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable == false) { - pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable = true; - pDevice->sQuiet[pDevice->uQuietEnqueue].byPeriod = byQuietPeriod; - pDevice->sQuiet[pDevice->uQuietEnqueue].wDuration = wQuietDuration; - pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime = (unsigned long) byQuietCount; - pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime *= pDevice->wBeaconInterval; - pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset; - pDevice->uQuietEnqueue++; - pDevice->uQuietEnqueue %= MAX_QUIET_COUNT; - if (pDevice->byQuietStartCount < byQuietCount) - pDevice->byQuietStartCount = byQuietCount; - } - return true; -} - -/* - * Description: - * Do Quiet, It will be called by either ISR(after start) - * or VNTWIFI(before start) so we do not need a SPINLOCK - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -bool -CARDbStartQuiet( - struct vnt_private *pDevice -) -{ - unsigned int ii = 0; - unsigned long dwStartTime = 0xFFFFFFFF; - unsigned int uCurrentQuietIndex = 0; - unsigned long dwNextTime = 0; - unsigned long dwGap = 0; - unsigned long dwDuration = 0; - - for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { - if ((pDevice->sQuiet[ii].bEnable == true) && - (dwStartTime > pDevice->sQuiet[ii].dwStartTime)) { - dwStartTime = pDevice->sQuiet[ii].dwStartTime; - uCurrentQuietIndex = ii; - } - } - if (dwStartTime == 0xFFFFFFFF) { - /* no more quiet */ - pDevice->bQuietEnable = false; - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); - } else { - if (pDevice->bQuietEnable == false) { - /* first quiet */ - pDevice->byQuietStartCount--; - dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; - dwNextTime %= pDevice->wBeaconInterval; - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETINIT, (unsigned short) dwNextTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) pDevice->sQuiet[uCurrentQuietIndex].wDuration); - if (pDevice->byQuietStartCount == 0) { - pDevice->bEnableFirstQuiet = false; - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); - } else { - pDevice->bEnableFirstQuiet = true; - } - MACvSelectPage0(pDevice->PortOffset); - } else { - if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) { - /* overlap with previous Quiet */ - dwGap = pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; - if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) { - /* - * return false to indicate next quiet - * expired, should call this function - * again - */ - return false; - } - dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap; - dwGap = 0; - } else { - dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime; - dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration; - } - /* set GAP and Next duration */ - MACvSelectPage1(pDevice->PortOffset); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (unsigned short) dwGap); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) dwDuration); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_QUIETRPT); - MACvSelectPage0(pDevice->PortOffset); - } - pDevice->bQuietEnable = true; - pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; - pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration; - if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) { - /* not period disable current quiet element */ - pDevice->sQuiet[uCurrentQuietIndex].bEnable = false; - } else { - /* set next period start time */ - dwNextTime = (unsigned long) pDevice->sQuiet[uCurrentQuietIndex].byPeriod; - dwNextTime *= pDevice->wBeaconInterval; - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime; - } - if (pDevice->dwCurrentQuietEndTime > 0x80010000) { - /* decreament all time to avoid wrap around */ - for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { - if (pDevice->sQuiet[ii].bEnable == true) - pDevice->sQuiet[ii].dwStartTime -= 0x80000000; - - } - pDevice->dwCurrentQuietEndTime -= 0x80000000; - } - } - return true; -} - -/* - * Description: - * Set Local Power Constraint - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -void -CARDvSetPowerConstraint( - struct vnt_private *pDevice, - unsigned char byChannel, - char byPower -) -{ - - if (byChannel > CB_MAX_CHANNEL_24G) { - if (pDevice->bCountryInfo5G == true) - pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower; - - } else { - if (pDevice->bCountryInfo24G == true) - pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower; - - } -} - -/* - * Description: - * Set Local Power Constraint - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -void -CARDvGetPowerCapability( - struct vnt_private *pDevice, - unsigned char *pbyMinPower, - unsigned char *pbyMaxPower -) -{ - unsigned char byDec = 0; - - *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh]; - byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh]; - if (pDevice->byRFType == RF_UW2452) { - byDec *= 3; - byDec >>= 1; - } else { - byDec <<= 1; - } - *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec; -} - -/* - * Description: - * Get Current Tx Power - * - * Parameters: - * In: - * hDeviceContext - device structure point - * Out: - * none - * - * Return Value: none. - */ -char -CARDbyGetTransmitPower( - struct vnt_private *pDevice -) -{ - - return pDevice->byCurPwrdBm; -} - void CARDvSafeResetTx( struct vnt_private *pDevice diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index cb95a0de5bf6..fa1e692ca8a0 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -86,91 +86,16 @@ void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeac bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF); u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval); u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2); -bool CARDbSetTxPower(struct vnt_private *, unsigned long ulTxPower); unsigned char CARDbyGetPktType(struct vnt_private *); void CARDvSafeResetTx(struct vnt_private *); void CARDvSafeResetRx(struct vnt_private *); bool CARDbRadioPowerOff(struct vnt_private *); bool CARDbRadioPowerOn(struct vnt_private *); -bool CARDbIsShortPreamble(struct vnt_private *); -bool CARDbIsShorSlotTime(struct vnt_private *); bool CARDbSetPhyParameter(struct vnt_private *, CARD_PHY_TYPE ePHYType, unsigned short wCapInfo, unsigned char byERPField, void *pvSupportRateIEs, void *pvExtSupportRateIEs); bool CARDbUpdateTSF(struct vnt_private *, unsigned char byRxRate, u64 qwBSSTimestamp, u64 qwLocalTSF); -bool CARDbStopTxPacket(struct vnt_private *, CARD_PKT_TYPE ePktType); -bool CARDbStartTxPacket(struct vnt_private *, CARD_PKT_TYPE ePktType); bool CARDbSetBeaconPeriod(struct vnt_private *, unsigned short wBeaconInterval); -bool CARDbSetBSSID(struct vnt_private *, - unsigned char *pbyBSSID, enum nl80211_iftype); - -bool CARDbPowerDown(struct vnt_private *); - -bool CARDbSetTxDataRate(struct vnt_private *, unsigned short wDataRate); - -bool CARDbRemoveKey(struct vnt_private *, unsigned char *pbyBSSID); - -bool -CARDbAdd_PMKID_Candidate( - struct vnt_private *, - unsigned char *pbyBSSID, - bool bRSNCapExist, - unsigned short wRSNCap -); - -void * -CARDpGetCurrentAddress( - struct vnt_private * -); - -bool -CARDbStartMeasure( - struct vnt_private *, - void *pvMeasureEIDs, - unsigned int uNumOfMeasureEIDs -); - -bool -CARDbChannelSwitch( - struct vnt_private *, - unsigned char byMode, - unsigned char byNewChannel, - unsigned char byCount -); - -bool -CARDbSetQuiet( - struct vnt_private *, - bool bResetQuiet, - unsigned char byQuietCount, - unsigned char byQuietPeriod, - unsigned short wQuietDuration, - unsigned short wQuietOffset -); - -bool -CARDbStartQuiet( - struct vnt_private * -); - -void -CARDvSetPowerConstraint( - struct vnt_private *, - unsigned char byChannel, - char byPower -); - -void -CARDvGetPowerCapability( - struct vnt_private *, - unsigned char *pbyMinPower, - unsigned char *pbyMaxPower -); - -char -CARDbyGetTransmitPower( - struct vnt_private * -); #endif /* __CARD_H__ */ -- cgit v1.2.3-59-g8ed1b From c49802bfb6f3aadc64360994e6500bd2e2f080b6 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:36 +0000 Subject: staging: vt6655: deadcode remove wroute.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/rxtx.c | 1 - drivers/staging/vt6655/wroute.c | 177 ----------------------------------- drivers/staging/vt6655/wroute.h | 45 --------- 5 files changed, 225 deletions(-) delete mode 100644 drivers/staging/vt6655/wroute.c delete mode 100644 drivers/staging/vt6655/wroute.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 141c0c11ee22..e5ea1ea9beab 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -21,7 +21,6 @@ vt6655_stage-y += device_main.o \ key.o \ tkip.o \ michael.o \ - wroute.o \ rf.o \ wpa2.o \ aes_ccmp.o \ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 848c258119a6..18dad0cb69a0 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -66,7 +66,6 @@ #include "iocmd.h" #include "tcrc.h" #include "rxtx.h" -#include "wroute.h" #include "bssdb.h" #include "dpc.h" #include "rf.h" diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index c47042c07aad..6ae859404553 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -59,7 +59,6 @@ #include "tkip.h" #include "tcrc.h" #include "wctl.h" -#include "wroute.h" #include "rf.h" /*--------------------- Static Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c deleted file mode 100644 index 430e9441bc9e..000000000000 --- a/drivers/staging/vt6655/wroute.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wroute.c - * - * Purpose: handle WMAC frame relay & filtering - * - * Author: Lyndon Chen - * - * Date: May 20, 2003 - * - * Functions: - * ROUTEbRelay - Relay packet - * - * Revision History: - * - */ - -#include "mac.h" -#include "tcrc.h" -#include "rxtx.h" -#include "wroute.h" -#include "card.h" -#include "baseband.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/* - * Description: - * Relay packet. Return true if packet is copy to DMA1 - * - * Parameters: - * In: - * pDevice - - * pbySkbData - rx packet skb data - * Out: - * true, false - * - * Return Value: true if packet duplicate; otherwise false - * - */ -bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, - unsigned int uDataLen, unsigned int uNodeIndex) -{ - PSMgmtObject pMgmt = pDevice->pMgmt; - PSTxDesc pHeadTD, pLastTD; - unsigned int cbFrameBodySize; - unsigned int uMACfragNum = 0; - unsigned char byPktType; - bool bNeedEncryption = false; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - unsigned int ii; - unsigned char *pbyBSSID; - - if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 0) { - pr_debug("Relay can't allocate TD1..\n"); - return false; - } - - pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA]; - - pHeadTD->m_td1TD1.byTCR = (TCR_EDP | TCR_STP); - - memcpy(pDevice->sTxEthHeader.abyDstAddr, pbySkbData, ETH_HLEN); - - cbFrameBodySize = uDataLen - ETH_HLEN; - - if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) - cbFrameBodySize += 8; - - if (pDevice->bEncryptionEnable == true) { - bNeedEncryption = true; - - /* get group key */ - pbyBSSID = pDevice->abyBroadcastAddr; - if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, - GROUP_KEY, &pTransmitKey) == false) { - pTransmitKey = NULL; - pr_debug("KEY is NULL. [%d]\n", - pDevice->pMgmt->eCurrMode); - } else { - pr_debug("Get GTK\n"); - } - } - - if (pDevice->bEnableHostWEP) { - if (uNodeIndex < MAX_NODE_NUM + 1) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength); - } - } - - if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA)) - return false; - - byPktType = pDevice->byPacketType; - - if (pDevice->bFixRate) { - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) - pDevice->wCurrentRate = RATE_11M; - else - pDevice->wCurrentRate = pDevice->uConnectionRate; - } else { - if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) && - (pDevice->uConnectionRate <= RATE_6M)) { - pDevice->wCurrentRate = RATE_6M; - } else { - if (pDevice->uConnectionRate >= RATE_54M) - pDevice->wCurrentRate = RATE_54M; - else - pDevice->wCurrentRate = pDevice->uConnectionRate; - } - } - } else { - pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; - } - - if (pDevice->wCurrentRate <= RATE_11M) - byPktType = PK_TYPE_11B; - - if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { - /* Disable PS */ - MACbPSWakeup(pDevice->PortOffset); - } - - pDevice->bPWBitOn = false; - - pLastTD = pHeadTD; - for (ii = 0; ii < uMACfragNum; ii++) { - /* Poll Transmit the adapter */ - wmb(); - pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC; - wmb(); - if (ii == (uMACfragNum - 1)) - pLastTD = pHeadTD; - pHeadTD = pHeadTD->next; - } - - pLastTD->pTDInfo->skb = NULL; - pLastTD->pTDInfo->byFlags = 0; - - pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD; - - MACvTransmitAC0(pDevice->PortOffset); - - return true; -} diff --git a/drivers/staging/vt6655/wroute.h b/drivers/staging/vt6655/wroute.h deleted file mode 100644 index e59eec955cac..000000000000 --- a/drivers/staging/vt6655/wroute.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wroute.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: May 21, 2003 - * - */ - -#ifndef __WROUTE_H__ -#define __WROUTE_H__ - -#include "device.h" - -/*--------------------- Export Definitions -------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData, - unsigned int uDataLen, unsigned int uNodeIndex); - -#endif /* __WROUTE_H__ */ -- cgit v1.2.3-59-g8ed1b From 6bedc35b75e99ef66b42b40e23c3eaf3f76cf6d2 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:37 +0000 Subject: staging: vt6655: dead code remove wpa/wpa2 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211mgr.c | 13 -- drivers/staging/vt6655/Makefile | 2 - drivers/staging/vt6655/vntwifi.c | 7 - drivers/staging/vt6655/vntwifi.h | 1 - drivers/staging/vt6655/wmgr.h | 2 - drivers/staging/vt6655/wpa.c | 300 ------------------------------- drivers/staging/vt6655/wpa.h | 83 --------- drivers/staging/vt6655/wpa2.c | 359 -------------------------------------- drivers/staging/vt6655/wpa2.h | 77 -------- 9 files changed, 844 deletions(-) delete mode 100644 drivers/staging/vt6655/wpa.c delete mode 100644 drivers/staging/vt6655/wpa.h delete mode 100644 drivers/staging/vt6655/wpa2.c delete mode 100644 drivers/staging/vt6655/wpa2.h diff --git a/drivers/staging/vt6655/80211mgr.c b/drivers/staging/vt6655/80211mgr.c index 7d2c6472ec9a..22ded38e6a2e 100644 --- a/drivers/staging/vt6655/80211mgr.c +++ b/drivers/staging/vt6655/80211mgr.c @@ -57,7 +57,6 @@ #include "80211mgr.h" #include "80211hdr.h" #include "device.h" -#include "wpa.h" /*--------------------- Static Definitions -------------------------*/ @@ -171,9 +170,6 @@ vMgrDecodeBeacon( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) - pFrame->pRSNWPA = - (PWLAN_IE_RSN_EXT)pItem; } break; @@ -389,9 +385,6 @@ vMgrDecodeAssocRequest( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) - pFrame->pRSNWPA = - (PWLAN_IE_RSN_EXT)pItem; } break; case WLAN_EID_EXTSUPP_RATES: @@ -574,9 +567,6 @@ vMgrDecodeReassocRequest( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) - pFrame->pRSNWPA = - (PWLAN_IE_RSN_EXT)pItem; } break; @@ -767,9 +757,6 @@ vMgrDecodeProbeResponse( break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) - pFrame->pRSNWPA = - (PWLAN_IE_RSN_EXT)pItem; } break; case WLAN_EID_ERP: diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index e5ea1ea9beab..7286e328a2a4 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -17,12 +17,10 @@ vt6655_stage-y += device_main.o \ rc4.o \ tether.o \ tcrc.o \ - wpa.o \ key.o \ tkip.o \ michael.o \ rf.o \ - wpa2.o \ aes_ccmp.o \ vntwifi.o diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index a5eccf7cec8b..54c65fca332d 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -557,13 +557,6 @@ VNTWIFIbSetPMKIDCache( void *pPMKIDInfo ) { - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - - if (ulCount > MAX_PMKID_CACHE) - return false; - - pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount; - memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo))); return true; } diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index 880b8ab109be..9db734f00419 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -33,7 +33,6 @@ #include "ttype.h" #include "80211mgr.h" #include "card.h" -#include "wpa2.h" /*--------------------- Export Definitions -------------------------*/ #define RATE_1M 0 diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 4b7196bd1607..7df62bb6eafd 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -39,7 +39,6 @@ #include "80211hdr.h" #include "wcmd.h" #include "bssdb.h" -#include "wpa2.h" #include "vntwifi.h" #include "card.h" @@ -291,7 +290,6 @@ typedef struct tagSMgmtObject { KnownNodeDB sNodeDBTable[MAX_NODE_NUM + 1]; // WPA2 PMKID Cache - SPMKIDCache gsPMKIDCache; bool bRoaming; // rate fall back vars diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c deleted file mode 100644 index 5d4eca8512af..000000000000 --- a/drivers/staging/vt6655/wpa.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wpa.c - * - * Purpose: Handles the Basic Service Set & Node Database functions - * - * Functions: - * WPA_ParseRSN - Parse RSN IE. - * - * Revision History: - * - * Author: Kyle Hsu - * - * Date: July 14, 2003 - * - */ - -#include "ttype.h" -#include "tmacro.h" -#include "tether.h" -#include "device.h" -#include "80211hdr.h" -#include "bssdb.h" -#include "wmgr.h" -#include "wpa.h" -#include "80211mgr.h" - -/*--------------------- Static Variables --------------------------*/ -static const unsigned char abyOUI00[4] = { 0x00, 0x50, 0xf2, 0x00 }; -static const unsigned char abyOUI01[4] = { 0x00, 0x50, 0xf2, 0x01 }; -static const unsigned char abyOUI02[4] = { 0x00, 0x50, 0xf2, 0x02 }; -static const unsigned char abyOUI03[4] = { 0x00, 0x50, 0xf2, 0x03 }; -static const unsigned char abyOUI04[4] = { 0x00, 0x50, 0xf2, 0x04 }; -static const unsigned char abyOUI05[4] = { 0x00, 0x50, 0xf2, 0x05 }; - -/*+ - * - * Description: - * Clear RSN information in BSSList. - * - * Parameters: - * In: - * pBSSList - BSS list. - * Out: - * none - * - * Return Value: none. - * - -*/ - -void -WPA_ClearRSN( - PKnownBSS pBSSList -) -{ - int ii; - - pBSSList->byGKType = WPA_TKIP; - for (ii = 0; ii < 4; ii++) - pBSSList->abyPKType[ii] = WPA_TKIP; - pBSSList->wPKCount = 0; - for (ii = 0; ii < 4; ii++) - pBSSList->abyAuthType[ii] = WPA_AUTH_IEEE802_1X; - pBSSList->wAuthCount = 0; - pBSSList->byDefaultK_as_PK = 0; - pBSSList->byReplayIdx = 0; - pBSSList->sRSNCapObj.bRSNCapExist = false; - pBSSList->sRSNCapObj.wRSNCap = 0; - pBSSList->bWPAValid = false; -} - -/*+ - * - * Description: - * Parse RSN IE. - * - * Parameters: - * In: - * pBSSList - BSS list. - * pRSN - Pointer to the RSN IE. - * Out: - * none - * - * Return Value: none. - * - -*/ -void -WPA_ParseRSN( - PKnownBSS pBSSList, - PWLAN_IE_RSN_EXT pRSN -) -{ - PWLAN_IE_RSN_AUTH pIE_RSN_Auth = NULL; - int i, j, m, n = 0; - unsigned char *pbyCaps; - - WPA_ClearRSN(pBSSList); - - pr_debug("WPA_ParseRSN: [%d]\n", pRSN->len); - - // information element header makes sense - if ((pRSN->len >= 6) // oui1(4)+ver(2) - && (pRSN->byElementID == WLAN_EID_RSN_WPA) && !memcmp(pRSN->abyOUI, abyOUI01, 4) - && (pRSN->wVersion == 1)) { - pr_debug("Legal RSN\n"); - // update each variable if pRSN is long enough to contain the variable - if (pRSN->len >= 10) { - //OUI1(4)+ver(2)+GKSuite(4) - if (!memcmp(pRSN->abyMulticast, abyOUI01, 4)) - pBSSList->byGKType = WPA_WEP40; - else if (!memcmp(pRSN->abyMulticast, abyOUI02, 4)) - pBSSList->byGKType = WPA_TKIP; - else if (!memcmp(pRSN->abyMulticast, abyOUI03, 4)) - pBSSList->byGKType = WPA_AESWRAP; - else if (!memcmp(pRSN->abyMulticast, abyOUI04, 4)) - pBSSList->byGKType = WPA_AESCCMP; - else if (!memcmp(pRSN->abyMulticast, abyOUI05, 4)) - pBSSList->byGKType = WPA_WEP104; - else - // any vendor checks here - pBSSList->byGKType = WPA_NONE; - - pr_debug("byGKType: %x\n", pBSSList->byGKType); - } - - if (pRSN->len >= 12) { - //oui1(4)+ver(2)+GKS(4)+PKSCnt(2) - j = 0; - pr_debug("wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n", - pRSN->wPKCount, sizeof(pBSSList->abyPKType)); - for (i = 0; (i < pRSN->wPKCount) && (j < ARRAY_SIZE(pBSSList->abyPKType)); i++) { - if (pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i) - if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4)) - pBSSList->abyPKType[j++] = WPA_NONE; - else if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI02, 4)) - pBSSList->abyPKType[j++] = WPA_TKIP; - else if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI03, 4)) - pBSSList->abyPKType[j++] = WPA_AESWRAP; - else if (!memcmp(pRSN->PKSList[i].abyOUI, abyOUI04, 4)) - pBSSList->abyPKType[j++] = WPA_AESCCMP; - else - // any vendor checks here - ; - } else - break; - } - pBSSList->wPKCount = (unsigned short)j; - pr_debug("wPKCount: %d\n", pBSSList->wPKCount); - } - - m = pRSN->wPKCount; - pr_debug("m: %d\n", m); - pr_debug("14+m*4: %d\n", 14+m*4); - - if (pRSN->len >= 14+m*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2) - // overlay IE_RSN_Auth structure into correct place - pIE_RSN_Auth = (PWLAN_IE_RSN_AUTH) pRSN->PKSList[m].abyOUI; - j = 0; - pr_debug("wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n", - pIE_RSN_Auth->wAuthCount, - sizeof(pBSSList->abyAuthType)); - for (i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < ARRAY_SIZE(pBSSList->abyAuthType)); i++) { - if (pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i) - if (!memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4)) - pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X; - else if (!memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI02, 4)) - pBSSList->abyAuthType[j++] = WPA_AUTH_PSK; - else - // any vendor checks here - ; - } else - break; - - } - if (j > 0) - pBSSList->wAuthCount = (unsigned short)j; - pr_debug("wAuthCount: %d\n", pBSSList->wAuthCount); - } - - if (pIE_RSN_Auth != NULL) { - n = pIE_RSN_Auth->wAuthCount; - - pr_debug("n: %d\n", n); - pr_debug("14+4+(m+n)*4: %d\n", 14+4+(m+n)*4); - - if (pRSN->len+2 >= 14+4+(m+n)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*n)+Cap(2) - pbyCaps = (unsigned char *)pIE_RSN_Auth->AuthKSList[n].abyOUI; - pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG; - pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS); - pBSSList->sRSNCapObj.bRSNCapExist = true; - pBSSList->sRSNCapObj.wRSNCap = *(unsigned short *)pbyCaps; - } - } - pBSSList->bWPAValid = true; - } -} - -/*+ - * - * Description: - * Search RSN information in BSSList. - * - * Parameters: - * In: - * byCmd - Search type - * byEncrypt- Encrypt Type - * pBSSList - BSS list - * Out: - * none - * - * Return Value: none. - * - -*/ -bool -WPA_SearchRSN( - unsigned char byCmd, - unsigned char byEncrypt, - PKnownBSS pBSSList -) -{ - int ii; - unsigned char byPKType = WPA_NONE; - - if (!pBSSList->bWPAValid) - return false; - - switch (byCmd) { - case 0: - - if (byEncrypt != pBSSList->byGKType) - return false; - - if (pBSSList->wPKCount > 0) { - for (ii = 0; ii < pBSSList->wPKCount; ii++) { - if (pBSSList->abyPKType[ii] == WPA_AESCCMP) - byPKType = WPA_AESCCMP; - else if ((pBSSList->abyPKType[ii] == WPA_TKIP) && (byPKType != WPA_AESCCMP)) - byPKType = WPA_TKIP; - else if ((pBSSList->abyPKType[ii] == WPA_WEP40) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP)) - byPKType = WPA_WEP40; - else if ((pBSSList->abyPKType[ii] == WPA_WEP104) && (byPKType != WPA_AESCCMP) && (byPKType != WPA_TKIP)) - byPKType = WPA_WEP104; - } - if (byEncrypt != byPKType) - return false; - } - return true; - - default: - break; - } - return false; -} - -/*+ - * - * Description: - * Check if RSN IE makes sense. - * - * Parameters: - * In: - * pRSN - Pointer to the RSN IE. - * Out: - * none - * - * Return Value: none. - * - -*/ -bool -WPAb_Is_RSN( - PWLAN_IE_RSN_EXT pRSN -) -{ - if (pRSN == NULL) - return false; - - if ((pRSN->len >= 6) && // oui1(4)+ver(2) - (pRSN->byElementID == WLAN_EID_RSN_WPA) && !memcmp(pRSN->abyOUI, abyOUI01, 4) && - (pRSN->wVersion == 1)) { - return true; - } else - return false; -} diff --git a/drivers/staging/vt6655/wpa.h b/drivers/staging/vt6655/wpa.h deleted file mode 100644 index d012cb97043f..000000000000 --- a/drivers/staging/vt6655/wpa.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wpa.h - * - * Purpose: Defines the macros, types, and functions for dealing - * with WPA informations. - * - * Author: Kyle Hsu - * - * Date: Jul 14, 2003 - * - */ - -#ifndef __WPA_H__ -#define __WPA_H__ - -#include "ttype.h" -#include "80211hdr.h" - -/*--------------------- Export Definitions -------------------------*/ - -#define WPA_NONE 0 -#define WPA_WEP40 1 -#define WPA_TKIP 2 -#define WPA_AESWRAP 3 -#define WPA_AESCCMP 4 -#define WPA_WEP104 5 -#define WPA_AUTH_IEEE802_1X 1 -#define WPA_AUTH_PSK 2 - -#define WPA_GROUPFLAG 0x02 -#define WPA_REPLAYBITSSHIFT 2 -#define WPA_REPLAYBITS 0x03 - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Types ------------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -void -WPA_ClearRSN( - PKnownBSS pBSSList -); - -void -WPA_ParseRSN( - PKnownBSS pBSSList, - PWLAN_IE_RSN_EXT pRSN -); - -bool -WPA_SearchRSN( - unsigned char byCmd, - unsigned char byEncrypt, - PKnownBSS pBSSList -); - -bool -WPAb_Is_RSN( - PWLAN_IE_RSN_EXT pRSN -); - -#endif /* __WPA_H__ */ diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c deleted file mode 100644 index bb335ef51172..000000000000 --- a/drivers/staging/vt6655/wpa2.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wpa2.c - * - * Purpose: Handles the Basic Service Set & Node Database functions - * - * Functions: - * - * Revision History: - * - * Author: Yiching Chen - * - * Date: Oct. 4, 2004 - * - */ - -#include "wpa2.h" -#include "device.h" -#include "wmgr.h" - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -static const unsigned char abyOUIGK[4] = { 0x00, 0x0F, 0xAC, 0x00 }; -static const unsigned char abyOUIWEP40[4] = { 0x00, 0x0F, 0xAC, 0x01 }; -static const unsigned char abyOUIWEP104[4] = { 0x00, 0x0F, 0xAC, 0x05 }; -static const unsigned char abyOUITKIP[4] = { 0x00, 0x0F, 0xAC, 0x02 }; -static const unsigned char abyOUICCMP[4] = { 0x00, 0x0F, 0xAC, 0x04 }; - -static const unsigned char abyOUI8021X[4] = { 0x00, 0x0F, 0xAC, 0x01 }; -static const unsigned char abyOUIPSK[4] = { 0x00, 0x0F, 0xAC, 0x02 }; - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/*+ - * - * Description: - * Clear RSN information in BSSList. - * - * Parameters: - * In: - * pBSSNode - BSS list. - * Out: - * none - * - * Return Value: none. - * - -*/ -void -WPA2_ClearRSN( - PKnownBSS pBSSNode -) -{ - int ii; - - pBSSNode->bWPA2Valid = false; - - pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP; - for (ii = 0; ii < 4; ii++) - pBSSNode->abyCSSPK[ii] = WLAN_11i_CSS_CCMP; - pBSSNode->wCSSPKCount = 1; - for (ii = 0; ii < 4; ii++) - pBSSNode->abyAKMSSAuthType[ii] = WLAN_11i_AKMSS_802_1X; - pBSSNode->wAKMSSAuthCount = 1; - pBSSNode->sRSNCapObj.bRSNCapExist = false; - pBSSNode->sRSNCapObj.wRSNCap = 0; -} - -/*+ - * - * Description: - * Parse RSN IE. - * - * Parameters: - * In: - * pBSSNode - BSS list. - * pRSN - Pointer to the RSN IE. - * Out: - * none - * - * Return Value: none. - * - -*/ -void -WPA2vParseRSN( - PKnownBSS pBSSNode, - PWLAN_IE_RSN pRSN -) -{ - int i, j; - unsigned short m = 0, n = 0; - unsigned char *pbyOUI; - bool bUseGK = false; - - pr_debug("WPA2_ParseRSN: [%d]\n", pRSN->len); - - WPA2_ClearRSN(pBSSNode); - - if (pRSN->len == 2) { // ver(2) - if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1)) - pBSSNode->bWPA2Valid = true; - - return; - } - - if (pRSN->len < 6) { // ver(2) + GK(4) - // invalid CSS, P802.11i/D10.0, p31 - return; - } - - // information element header makes sense - if ((pRSN->byElementID == WLAN_EID_RSN) && - (pRSN->wVersion == 1)) { - pr_debug("Legal 802.11i RSN\n"); - - pbyOUI = &(pRSN->abyRSN[0]); - if (!memcmp(pbyOUI, abyOUIWEP40, 4)) - pBSSNode->byCSSGK = WLAN_11i_CSS_WEP40; - else if (!memcmp(pbyOUI, abyOUITKIP, 4)) - pBSSNode->byCSSGK = WLAN_11i_CSS_TKIP; - else if (!memcmp(pbyOUI, abyOUICCMP, 4)) - pBSSNode->byCSSGK = WLAN_11i_CSS_CCMP; - else if (!memcmp(pbyOUI, abyOUIWEP104, 4)) - pBSSNode->byCSSGK = WLAN_11i_CSS_WEP104; - else if (!memcmp(pbyOUI, abyOUIGK, 4)) { - // invalid CSS, P802.11i/D10.0, p32 - return; - } else - // any vendor checks here - pBSSNode->byCSSGK = WLAN_11i_CSS_UNKNOWN; - - pr_debug("802.11i CSS: %X\n", pBSSNode->byCSSGK); - - if (pRSN->len == 6) { - pBSSNode->bWPA2Valid = true; - return; - } - - if (pRSN->len >= 8) { // ver(2) + GK(4) + PK count(2) - pBSSNode->wCSSPKCount = *((unsigned short *)&(pRSN->abyRSN[4])); - j = 0; - pbyOUI = &(pRSN->abyRSN[6]); - - for (i = 0; (i < pBSSNode->wCSSPKCount) && (j < sizeof(pBSSNode->abyCSSPK)/sizeof(unsigned char)); i++) { - if (pRSN->len >= 8+i*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i) - if (!memcmp(pbyOUI, abyOUIGK, 4)) { - pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_USE_GROUP; - bUseGK = true; - } else if (!memcmp(pbyOUI, abyOUIWEP40, 4)) { - // Invalid CSS, continue to parsing - } else if (!memcmp(pbyOUI, abyOUITKIP, 4)) { - if (pBSSNode->byCSSGK != WLAN_11i_CSS_CCMP) - pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_TKIP; - else - ; // Invalid CSS, continue to parsing - } else if (!memcmp(pbyOUI, abyOUICCMP, 4)) { - pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_CCMP; - } else if (!memcmp(pbyOUI, abyOUIWEP104, 4)) { - // Invalid CSS, continue to parsing - } else { - // any vendor checks here - pBSSNode->abyCSSPK[j++] = WLAN_11i_CSS_UNKNOWN; - } - pbyOUI += 4; - pr_debug("abyCSSPK[%d]: %X\n", - j-1, pBSSNode->abyCSSPK[j-1]); - } else - break; - } //for - - if (bUseGK) { - if (j != 1) { - // invalid CSS, This should be only PK CSS. - return; - } - if (pBSSNode->byCSSGK == WLAN_11i_CSS_CCMP) { - // invalid CSS, If CCMP is enable , PK can't be CSSGK. - return; - } - } - if ((pBSSNode->wCSSPKCount != 0) && (j == 0)) { - // invalid CSS, No valid PK. - return; - } - pBSSNode->wCSSPKCount = (unsigned short)j; - pr_debug("wCSSPKCount: %d\n", pBSSNode->wCSSPKCount); - } - - m = *((unsigned short *)&(pRSN->abyRSN[4])); - - if (pRSN->len >= 10+m*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2) - pBSSNode->wAKMSSAuthCount = *((unsigned short *)&(pRSN->abyRSN[6+4*m])); - j = 0; - pbyOUI = &(pRSN->abyRSN[8+4*m]); - for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(unsigned char)); i++) { - if (pRSN->len >= 10+(m+i)*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSS(2)+AKS(4*i) - if (!memcmp(pbyOUI, abyOUI8021X, 4)) - pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_802_1X; - else if (!memcmp(pbyOUI, abyOUIPSK, 4)) - pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_PSK; - else - // any vendor checks here - pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_UNKNOWN; - pr_debug("abyAKMSSAuthType[%d]: %X\n", - j-1, - pBSSNode->abyAKMSSAuthType[j-1]); - } else - break; - } - pBSSNode->wAKMSSAuthCount = (unsigned short)j; - pr_debug("wAKMSSAuthCount: %d\n", - pBSSNode->wAKMSSAuthCount); - - n = *((unsigned short *)&(pRSN->abyRSN[6+4*m])); - if (pRSN->len >= 12 + 4 * m + 4 * n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2) - pBSSNode->sRSNCapObj.bRSNCapExist = true; - pBSSNode->sRSNCapObj.wRSNCap = *((unsigned short *)&(pRSN->abyRSN[8+4*m+4*n])); - } - } - //ignore PMKID lists bcs only (Re)Assocrequest has this field - pBSSNode->bWPA2Valid = true; - } -} - -/*+ - * - * Description: - * Set WPA IEs - * - * Parameters: - * In: - * pMgmtHandle - Pointer to management object - * Out: - * pRSNIEs - Pointer to the RSN IE to set. - * - * Return Value: length of IEs. - * - -*/ -unsigned int -WPA2uSetIEs( - void *pMgmtHandle, - PWLAN_IE_RSN pRSNIEs -) -{ - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; - unsigned char *pbyBuffer = NULL; - unsigned int ii = 0; - unsigned short *pwPMKID = NULL; - - if (pRSNIEs == NULL) - return 0; - - if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && - (pMgmt->pCurrBSS != NULL)) { - /* WPA2 IE */ - pbyBuffer = (unsigned char *)pRSNIEs; - pRSNIEs->byElementID = WLAN_EID_RSN; - pRSNIEs->len = 6; //Version(2)+GK(4) - pRSNIEs->wVersion = 1; - //Group Key Cipher Suite - pRSNIEs->abyRSN[0] = 0x00; - pRSNIEs->abyRSN[1] = 0x0F; - pRSNIEs->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) - pRSNIEs->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - else if (pMgmt->byCSSGK == KEY_CTL_TKIP) - pRSNIEs->abyRSN[3] = WLAN_11i_CSS_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - pRSNIEs->abyRSN[3] = WLAN_11i_CSS_CCMP; - else - pRSNIEs->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - - // Pairwise Key Cipher Suite - pRSNIEs->abyRSN[4] = 1; - pRSNIEs->abyRSN[5] = 0; - pRSNIEs->abyRSN[6] = 0x00; - pRSNIEs->abyRSN[7] = 0x0F; - pRSNIEs->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_TKIP; - else if (pMgmt->byCSSPK == KEY_CTL_CCMP) - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_CCMP; - else if (pMgmt->byCSSPK == KEY_CTL_NONE) - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - else - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - - pRSNIEs->len += 6; - - // Auth Key Management Suite - pRSNIEs->abyRSN[10] = 1; - pRSNIEs->abyRSN[11] = 0; - pRSNIEs->abyRSN[12] = 0x00; - pRSNIEs->abyRSN[13] = 0x0F; - pRSNIEs->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) - pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_PSK; - else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) - pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - else - pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - - pRSNIEs->len += 6; - - // RSN Capabilities - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { - memcpy(&pRSNIEs->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); - } else { - pRSNIEs->abyRSN[16] = 0; - pRSNIEs->abyRSN[17] = 0; - } - pRSNIEs->len += 2; - - if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) && - pMgmt->bRoaming && - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { - // RSN PMKID - pwPMKID = (unsigned short *)(&pRSNIEs->abyRSN[18]); // Point to PMKID count - *pwPMKID = 0; // Initialize PMKID count - pbyBuffer = &pRSNIEs->abyRSN[20]; // Point to PMKID list - for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) { - if (!memcmp(&pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], pMgmt->abyCurrBSSID, ETH_ALEN)) { - (*pwPMKID)++; - memcpy(pbyBuffer, pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, 16); - pbyBuffer += 16; - } - } - if (*pwPMKID != 0) - pRSNIEs->len += (2 + (*pwPMKID)*16); - else - pbyBuffer = &pRSNIEs->abyRSN[18]; - } - return pRSNIEs->len + WLAN_IEHDR_LEN; - } - return 0; -} diff --git a/drivers/staging/vt6655/wpa2.h b/drivers/staging/vt6655/wpa2.h deleted file mode 100644 index 2d0bd2e515f3..000000000000 --- a/drivers/staging/vt6655/wpa2.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wpa2.h - * - * Purpose: Defines the macros, types, and functions for dealing - * with WPA2 informations. - * - * Author: Yiching Chen - * - * Date: Oct. 4, 2004 - * - */ - -#ifndef __WPA2_H__ -#define __WPA2_H__ - -#include "ttype.h" -#include "80211mgr.h" -#include "80211hdr.h" -#include "bssdb.h" - -/*--------------------- Export Definitions -------------------------*/ -#define MAX_PMKID_CACHE 16 - -typedef struct tagsPMKIDInfo { - unsigned char abyBSSID[6]; - unsigned char abyPMKID[16]; -} PMKIDInfo, *PPMKIDInfo; - -typedef struct tagSPMKIDCache { - unsigned long BSSIDInfoCount; - PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE]; -} SPMKIDCache, *PSPMKIDCache; - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Types ------------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -void -WPA2_ClearRSN( - PKnownBSS pBSSNode -); - -void -WPA2vParseRSN( - PKnownBSS pBSSNode, - PWLAN_IE_RSN pRSN -); - -unsigned int -WPA2uSetIEs( - void *pMgmtHandle, - PWLAN_IE_RSN pRSNIEs -); - -#endif // __WPA2_H__ -- cgit v1.2.3-59-g8ed1b From 7c23c2d25df818805e6754cd196076a52d84af39 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:38 +0000 Subject: staging: vt6655: deadcode remove aes_ccmp/rc4/tkip Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 3 - drivers/staging/vt6655/aes_ccmp.c | 374 -------------------------------------- drivers/staging/vt6655/aes_ccmp.h | 37 ---- drivers/staging/vt6655/device.h | 2 - drivers/staging/vt6655/rc4.c | 88 --------- drivers/staging/vt6655/rc4.h | 47 ----- drivers/staging/vt6655/rxtx.c | 1 - drivers/staging/vt6655/tkip.c | 268 --------------------------- drivers/staging/vt6655/tkip.h | 57 ------ 9 files changed, 877 deletions(-) delete mode 100644 drivers/staging/vt6655/aes_ccmp.c delete mode 100644 drivers/staging/vt6655/aes_ccmp.h delete mode 100644 drivers/staging/vt6655/rc4.c delete mode 100644 drivers/staging/vt6655/rc4.h delete mode 100644 drivers/staging/vt6655/tkip.c delete mode 100644 drivers/staging/vt6655/tkip.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 7286e328a2a4..f49f12bc8b17 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -14,14 +14,11 @@ vt6655_stage-y += device_main.o \ power.o \ srom.o \ mib.o \ - rc4.o \ tether.o \ tcrc.o \ key.o \ - tkip.o \ michael.o \ rf.o \ - aes_ccmp.o \ vntwifi.o obj-$(CONFIG_VT6655) += vt6655_stage.o diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c deleted file mode 100644 index 1dfcfcb3c69c..000000000000 --- a/drivers/staging/vt6655/aes_ccmp.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: aes_ccmp.c - * - * Purpose: AES_CCMP decryption - * - * Author: Warren Hsu - * - * Date: Feb 15, 2005 - * - * Functions: - * AESbGenCCMP - Parsing RX-packet - * - * - * Revision History: - * - */ - -#include "device.h" -#include "80211hdr.h" -#include "aes_ccmp.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/* - * SBOX Table - */ - -static unsigned char sbox_table[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -}; - -static unsigned char dot2_table[256] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, - 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, - 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, - 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, - 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, - 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, - 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, - 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, - 0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05, - 0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25, - 0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45, - 0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65, - 0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85, - 0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5, - 0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5, - 0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5 -}; - -static unsigned char dot3_table[256] = { - 0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11, - 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, - 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71, - 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41, - 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, - 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1, - 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1, - 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81, - 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a, - 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba, - 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, - 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, - 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a, - 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, - 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, - 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a -}; - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -static void xor_128(unsigned char *a, unsigned char *b, unsigned char *out) -{ - unsigned long *dwPtrA = (unsigned long *)a; - unsigned long *dwPtrB = (unsigned long *)b; - unsigned long *dwPtrOut = (unsigned long *)out; - - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); -} - -static void xor_32(unsigned char *a, unsigned char *b, unsigned char *out) -{ - unsigned long *dwPtrA = (unsigned long *)a; - unsigned long *dwPtrB = (unsigned long *)b; - unsigned long *dwPtrOut = (unsigned long *)out; - - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); -} - -static void AddRoundKey(unsigned char *key, int round) -{ - unsigned char sbox_key[4]; - unsigned char rcon_table[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36}; - - sbox_key[0] = sbox_table[key[13]]; - sbox_key[1] = sbox_table[key[14]]; - sbox_key[2] = sbox_table[key[15]]; - sbox_key[3] = sbox_table[key[12]]; - - key[0] = key[0] ^ rcon_table[round]; - xor_32(&key[0], sbox_key, &key[0]); - - xor_32(&key[4], &key[0], &key[4]); - xor_32(&key[8], &key[4], &key[8]); - xor_32(&key[12], &key[8], &key[12]); -} - -static void SubBytes(unsigned char *in, unsigned char *out) -{ - int i; - - for (i = 0; i < 16; i++) - out[i] = sbox_table[in[i]]; -} - -static void ShiftRows(unsigned char *in, unsigned char *out) -{ - out[0] = in[0]; - out[1] = in[5]; - out[2] = in[10]; - out[3] = in[15]; - out[4] = in[4]; - out[5] = in[9]; - out[6] = in[14]; - out[7] = in[3]; - out[8] = in[8]; - out[9] = in[13]; - out[10] = in[2]; - out[11] = in[7]; - out[12] = in[12]; - out[13] = in[1]; - out[14] = in[6]; - out[15] = in[11]; -} - -static void MixColumns(unsigned char *in, unsigned char *out) -{ - out[0] = dot2_table[in[0]] ^ dot3_table[in[1]] ^ in[2] ^ in[3]; - out[1] = in[0] ^ dot2_table[in[1]] ^ dot3_table[in[2]] ^ in[3]; - out[2] = in[0] ^ in[1] ^ dot2_table[in[2]] ^ dot3_table[in[3]]; - out[3] = dot3_table[in[0]] ^ in[1] ^ in[2] ^ dot2_table[in[3]]; -} - -static void AESv128(unsigned char *key, unsigned char *data, unsigned char *ciphertext) -{ - int i; - int round; - unsigned char TmpdataA[16]; - unsigned char TmpdataB[16]; - unsigned char abyRoundKey[16]; - - for (i = 0; i < 16; i++) - abyRoundKey[i] = key[i]; - - for (round = 0; round < 11; round++) { - if (round == 0) { - xor_128(abyRoundKey, data, ciphertext); - AddRoundKey(abyRoundKey, round); - } else if (round == 10) { - SubBytes(ciphertext, TmpdataA); - ShiftRows(TmpdataA, TmpdataB); - xor_128(TmpdataB, abyRoundKey, ciphertext); - } else /* round 1 ~ 9 */{ - SubBytes(ciphertext, TmpdataA); - ShiftRows(TmpdataA, TmpdataB); - MixColumns(&TmpdataB[0], &TmpdataA[0]); - MixColumns(&TmpdataB[4], &TmpdataA[4]); - MixColumns(&TmpdataB[8], &TmpdataA[8]); - MixColumns(&TmpdataB[12], &TmpdataA[12]); - xor_128(TmpdataA, abyRoundKey, ciphertext); - AddRoundKey(abyRoundKey, round); - } - } -} - -/* - * Description: AES decryption - * - * Parameters: - * In: - * pbyRxKey - The key used to decrypt - * pbyFrame - Starting address of packet header - * wFrameSize - Total packet size including CRC - * Out: - * none - * - * Return Value: MIC compare result - * - */ -bool AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, unsigned short wFrameSize) -{ - unsigned char abyNonce[13]; - unsigned char MIC_IV[16]; - unsigned char MIC_HDR1[16]; - unsigned char MIC_HDR2[16]; - unsigned char abyMIC[16]; - unsigned char abyCTRPLD[16]; - unsigned char abyTmp[16]; - unsigned char abyPlainText[16]; - unsigned char abyLastCipher[16]; - - PS802_11Header pMACHeader = (PS802_11Header) pbyFrame; - unsigned char *pbyIV; - unsigned char *pbyPayload; - unsigned short wHLen = 22; - unsigned short wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN;/* 8 is IV, 8 is MIC, 4 is CRC */ - bool bA4 = false; - unsigned char byTmp; - unsigned short wCnt; - int ii, jj, kk; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if (WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && - WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame)) { - bA4 = true; - pbyIV += 6; /* 6 is 802.11 address4 */ - wHLen += 6; - wPayloadSize -= 6; - } - pbyPayload = pbyIV + 8; /* IV-length */ - - abyNonce[0] = 0x00; /* now is 0, if Qos here will be priority */ - memcpy(&(abyNonce[1]), pMACHeader->abyAddr2, ETH_ALEN); - abyNonce[7] = pbyIV[7]; - abyNonce[8] = pbyIV[6]; - abyNonce[9] = pbyIV[5]; - abyNonce[10] = pbyIV[4]; - abyNonce[11] = pbyIV[1]; - abyNonce[12] = pbyIV[0]; - - /* MIC_IV */ - MIC_IV[0] = 0x59; - memcpy(&(MIC_IV[1]), &(abyNonce[0]), 13); - MIC_IV[14] = (unsigned char)(wPayloadSize >> 8); - MIC_IV[15] = (unsigned char)(wPayloadSize & 0xff); - - /* MIC_HDR1 */ - MIC_HDR1[0] = (unsigned char)(wHLen >> 8); - MIC_HDR1[1] = (unsigned char)(wHLen & 0xff); - byTmp = (unsigned char)(pMACHeader->wFrameCtl & 0xff); - MIC_HDR1[2] = byTmp & 0x8f; - byTmp = (unsigned char)(pMACHeader->wFrameCtl >> 8); - byTmp &= 0x87; - MIC_HDR1[3] = byTmp | 0x40; - memcpy(&(MIC_HDR1[4]), pMACHeader->abyAddr1, ETH_ALEN); - memcpy(&(MIC_HDR1[10]), pMACHeader->abyAddr2, ETH_ALEN); - - /* MIC_HDR2 */ - memcpy(&(MIC_HDR2[0]), pMACHeader->abyAddr3, ETH_ALEN); - byTmp = (unsigned char)(pMACHeader->wSeqCtl & 0xff); - MIC_HDR2[6] = byTmp & 0x0f; - MIC_HDR2[7] = 0; - if (bA4) { - memcpy(&(MIC_HDR2[8]), pMACHeader->abyAddr4, ETH_ALEN); - } else { - MIC_HDR2[8] = 0x00; - MIC_HDR2[9] = 0x00; - MIC_HDR2[10] = 0x00; - MIC_HDR2[11] = 0x00; - MIC_HDR2[12] = 0x00; - MIC_HDR2[13] = 0x00; - } - MIC_HDR2[14] = 0x00; - MIC_HDR2[15] = 0x00; - - /* CCMP */ - AESv128(pbyRxKey, MIC_IV, abyMIC); - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = MIC_HDR1[kk] ^ abyMIC[kk]; - AESv128(pbyRxKey, abyTmp, abyMIC); - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = MIC_HDR2[kk] ^ abyMIC[kk]; - AESv128(pbyRxKey, abyTmp, abyMIC); - - wCnt = 1; - abyCTRPLD[0] = 0x01; - memcpy(&(abyCTRPLD[1]), &(abyNonce[0]), 13); - - for (jj = wPayloadSize; jj > 16; jj = jj - 16) { - abyCTRPLD[14] = (unsigned char)(wCnt >> 8); - abyCTRPLD[15] = (unsigned char)(wCnt & 0xff); - - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - - for (kk = 0; kk < 16; kk++) - abyPlainText[kk] = abyTmp[kk] ^ pbyPayload[kk]; - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk]; - AESv128(pbyRxKey, abyTmp, abyMIC); - - memcpy(pbyPayload, abyPlainText, 16); - wCnt++; - pbyPayload += 16; - } /* for wPayloadSize */ - - /* last payload */ - memcpy(&(abyLastCipher[0]), pbyPayload, jj); - for (ii = jj; ii < 16; ii++) - abyLastCipher[ii] = 0x00; - - abyCTRPLD[14] = (unsigned char)(wCnt >> 8); - abyCTRPLD[15] = (unsigned char)(wCnt & 0xff); - - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - for (kk = 0; kk < 16; kk++) - abyPlainText[kk] = abyTmp[kk] ^ abyLastCipher[kk]; - memcpy(pbyPayload, abyPlainText, jj); - pbyPayload += jj; - - /* for MIC calculation */ - for (ii = jj; ii < 16; ii++) - abyPlainText[ii] = 0x00; - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk]; - AESv128(pbyRxKey, abyTmp, abyMIC); - - /* =>above is the calculate MIC */ - /* -------------------------------------------- */ - - wCnt = 0; - abyCTRPLD[14] = (unsigned char)(wCnt >> 8); - abyCTRPLD[15] = (unsigned char)(wCnt & 0xff); - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - for (kk = 0; kk < 8; kk++) - abyTmp[kk] = abyTmp[kk] ^ pbyPayload[kk]; - /* =>above is the dec-MIC from packet */ - /* -------------------------------------------- */ - - return !memcmp(abyMIC, abyTmp, 8); -} diff --git a/drivers/staging/vt6655/aes_ccmp.h b/drivers/staging/vt6655/aes_ccmp.h deleted file mode 100644 index fe0c506205d5..000000000000 --- a/drivers/staging/vt6655/aes_ccmp.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: aes_ccmp.h - * - * Purpose: AES_CCMP Decryption - * - * Author: Warren Hsu - * - * Date: Feb 15, 2005 - * - */ - -#ifndef __AES_H__ -#define __AES_H__ - -#include "ttype.h" - -bool AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, unsigned short wFrameSize); - -#endif /* __AES_H__ */ diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 6729d237a6ae..4bea23799233 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -74,7 +74,6 @@ #include "wcmd.h" #include "mib.h" #include "srom.h" -#include "rc4.h" #include "desc.h" #include "key.h" #include "mac.h" @@ -546,7 +545,6 @@ struct vnt_private { u64 qwPacketNumber; /* For CCMP and TKIP as TSC(6 bytes) */ unsigned int uCurrentWEPMode; - RC4Ext SBox; unsigned char abyPRNG[WLAN_WEPMAX_KEYLEN+3]; unsigned char byKeyIndex; unsigned int uKeyLength; diff --git a/drivers/staging/vt6655/rc4.c b/drivers/staging/vt6655/rc4.c deleted file mode 100644 index b7819bc702de..000000000000 --- a/drivers/staging/vt6655/rc4.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: rc4.c - * - * Purpose: - * - * Functions: - * - * Revision History: - * - * Author: Kyle Hsu - * - * Date: Sep 4, 2002 - * - */ - -#include "rc4.h" - -void rc4_init(PRC4Ext pRC4, unsigned char *pbyKey, unsigned int cbKey_len) -{ - unsigned int ust1, ust2; - unsigned int keyindex; - unsigned int stateindex; - unsigned char *pbyst; - unsigned int idx; - - pbyst = pRC4->abystate; - pRC4->ux = 0; - pRC4->uy = 0; - for (idx = 0; idx < 256; idx++) - pbyst[idx] = (unsigned char)idx; - keyindex = 0; - stateindex = 0; - for (idx = 0; idx < 256; idx++) { - ust1 = pbyst[idx]; - stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff; - ust2 = pbyst[stateindex]; - pbyst[stateindex] = (unsigned char)ust1; - pbyst[idx] = (unsigned char)ust2; - if (++keyindex >= cbKey_len) - keyindex = 0; - } -} - -unsigned int rc4_byte(PRC4Ext pRC4) -{ - unsigned int ux; - unsigned int uy; - unsigned int ustx, usty; - unsigned char *pbyst; - - pbyst = pRC4->abystate; - ux = (pRC4->ux + 1) & 0xff; - ustx = pbyst[ux]; - uy = (ustx + pRC4->uy) & 0xff; - usty = pbyst[uy]; - pRC4->ux = ux; - pRC4->uy = uy; - pbyst[uy] = (unsigned char)ustx; - pbyst[ux] = (unsigned char)usty; - - return pbyst[(ustx + usty) & 0xff]; -} - -void rc4_encrypt(PRC4Ext pRC4, unsigned char *pbyDest, - unsigned char *pbySrc, unsigned int cbData_len) -{ - unsigned int ii; - - for (ii = 0; ii < cbData_len; ii++) - pbyDest[ii] = (unsigned char)(pbySrc[ii] ^ rc4_byte(pRC4)); -} diff --git a/drivers/staging/vt6655/rc4.h b/drivers/staging/vt6655/rc4.h deleted file mode 100644 index 74b2eed9bce3..000000000000 --- a/drivers/staging/vt6655/rc4.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * File: rc4.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Purpose: - * - * Functions: - * - * Revision History: - * - * Author: Kyle Hsu - * - * Date: Sep 4, 2002 - * - */ - -#ifndef __RC4_H__ -#define __RC4_H__ - -#include "ttype.h" - -/*--------------------- Export Definitions -------------------------*/ -/*--------------------- Export Types ------------------------------*/ -typedef struct { - unsigned int ux; - unsigned int uy; - unsigned char abystate[256]; -} RC4Ext, *PRC4Ext; - -void rc4_init(PRC4Ext pRC4, unsigned char *pbyKey, unsigned int cbKey_len); -unsigned int rc4_byte(PRC4Ext pRC4); -void rc4_encrypt(PRC4Ext pRC4, unsigned char *pbyDest, unsigned char *pbySrc, unsigned int cbData_len); - -#endif //__RC4_H__ diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 6ae859404553..5ece2db9a2d4 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -56,7 +56,6 @@ #include "mac.h" #include "baseband.h" #include "michael.h" -#include "tkip.h" #include "tcrc.h" #include "wctl.h" #include "rf.h" diff --git a/drivers/staging/vt6655/tkip.c b/drivers/staging/vt6655/tkip.c deleted file mode 100644 index f758d021c60e..000000000000 --- a/drivers/staging/vt6655/tkip.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tkip.c - * - * Purpose: Implement functions for 802.11i TKIP - * - * Author: Jerry Chen - * - * Date: Mar. 11, 2003 - * - * Functions: - * TKIPvMixKey - Get TKIP RC4 Key from TK,TA, and TSC - * - * Revision History: - * - */ - -#include "tmacro.h" -#include "tkip.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/* The Sbox is reduced to 2 16-bit wide tables, each with 256 entries. */ -/* The 2nd table is the same as the 1st but with the upper and lower */ -/* bytes swapped. To allow an endian tolerant implementation, the byte */ -/* halves have been expressed independently here. */ -static const unsigned char TKIP_Sbox_Lower[256] = { - 0xA5, 0x84, 0x99, 0x8D, 0x0D, 0xBD, 0xB1, 0x54, - 0x50, 0x03, 0xA9, 0x7D, 0x19, 0x62, 0xE6, 0x9A, - 0x45, 0x9D, 0x40, 0x87, 0x15, 0xEB, 0xC9, 0x0B, - 0xEC, 0x67, 0xFD, 0xEA, 0xBF, 0xF7, 0x96, 0x5B, - 0xC2, 0x1C, 0xAE, 0x6A, 0x5A, 0x41, 0x02, 0x4F, - 0x5C, 0xF4, 0x34, 0x08, 0x93, 0x73, 0x53, 0x3F, - 0x0C, 0x52, 0x65, 0x5E, 0x28, 0xA1, 0x0F, 0xB5, - 0x09, 0x36, 0x9B, 0x3D, 0x26, 0x69, 0xCD, 0x9F, - 0x1B, 0x9E, 0x74, 0x2E, 0x2D, 0xB2, 0xEE, 0xFB, - 0xF6, 0x4D, 0x61, 0xCE, 0x7B, 0x3E, 0x71, 0x97, - 0xF5, 0x68, 0x00, 0x2C, 0x60, 0x1F, 0xC8, 0xED, - 0xBE, 0x46, 0xD9, 0x4B, 0xDE, 0xD4, 0xE8, 0x4A, - 0x6B, 0x2A, 0xE5, 0x16, 0xC5, 0xD7, 0x55, 0x94, - 0xCF, 0x10, 0x06, 0x81, 0xF0, 0x44, 0xBA, 0xE3, - 0xF3, 0xFE, 0xC0, 0x8A, 0xAD, 0xBC, 0x48, 0x04, - 0xDF, 0xC1, 0x75, 0x63, 0x30, 0x1A, 0x0E, 0x6D, - 0x4C, 0x14, 0x35, 0x2F, 0xE1, 0xA2, 0xCC, 0x39, - 0x57, 0xF2, 0x82, 0x47, 0xAC, 0xE7, 0x2B, 0x95, - 0xA0, 0x98, 0xD1, 0x7F, 0x66, 0x7E, 0xAB, 0x83, - 0xCA, 0x29, 0xD3, 0x3C, 0x79, 0xE2, 0x1D, 0x76, - 0x3B, 0x56, 0x4E, 0x1E, 0xDB, 0x0A, 0x6C, 0xE4, - 0x5D, 0x6E, 0xEF, 0xA6, 0xA8, 0xA4, 0x37, 0x8B, - 0x32, 0x43, 0x59, 0xB7, 0x8C, 0x64, 0xD2, 0xE0, - 0xB4, 0xFA, 0x07, 0x25, 0xAF, 0x8E, 0xE9, 0x18, - 0xD5, 0x88, 0x6F, 0x72, 0x24, 0xF1, 0xC7, 0x51, - 0x23, 0x7C, 0x9C, 0x21, 0xDD, 0xDC, 0x86, 0x85, - 0x90, 0x42, 0xC4, 0xAA, 0xD8, 0x05, 0x01, 0x12, - 0xA3, 0x5F, 0xF9, 0xD0, 0x91, 0x58, 0x27, 0xB9, - 0x38, 0x13, 0xB3, 0x33, 0xBB, 0x70, 0x89, 0xA7, - 0xB6, 0x22, 0x92, 0x20, 0x49, 0xFF, 0x78, 0x7A, - 0x8F, 0xF8, 0x80, 0x17, 0xDA, 0x31, 0xC6, 0xB8, - 0xC3, 0xB0, 0x77, 0x11, 0xCB, 0xFC, 0xD6, 0x3A -}; - -static const unsigned char TKIP_Sbox_Upper[256] = { - 0xC6, 0xF8, 0xEE, 0xF6, 0xFF, 0xD6, 0xDE, 0x91, - 0x60, 0x02, 0xCE, 0x56, 0xE7, 0xB5, 0x4D, 0xEC, - 0x8F, 0x1F, 0x89, 0xFA, 0xEF, 0xB2, 0x8E, 0xFB, - 0x41, 0xB3, 0x5F, 0x45, 0x23, 0x53, 0xE4, 0x9B, - 0x75, 0xE1, 0x3D, 0x4C, 0x6C, 0x7E, 0xF5, 0x83, - 0x68, 0x51, 0xD1, 0xF9, 0xE2, 0xAB, 0x62, 0x2A, - 0x08, 0x95, 0x46, 0x9D, 0x30, 0x37, 0x0A, 0x2F, - 0x0E, 0x24, 0x1B, 0xDF, 0xCD, 0x4E, 0x7F, 0xEA, - 0x12, 0x1D, 0x58, 0x34, 0x36, 0xDC, 0xB4, 0x5B, - 0xA4, 0x76, 0xB7, 0x7D, 0x52, 0xDD, 0x5E, 0x13, - 0xA6, 0xB9, 0x00, 0xC1, 0x40, 0xE3, 0x79, 0xB6, - 0xD4, 0x8D, 0x67, 0x72, 0x94, 0x98, 0xB0, 0x85, - 0xBB, 0xC5, 0x4F, 0xED, 0x86, 0x9A, 0x66, 0x11, - 0x8A, 0xE9, 0x04, 0xFE, 0xA0, 0x78, 0x25, 0x4B, - 0xA2, 0x5D, 0x80, 0x05, 0x3F, 0x21, 0x70, 0xF1, - 0x63, 0x77, 0xAF, 0x42, 0x20, 0xE5, 0xFD, 0xBF, - 0x81, 0x18, 0x26, 0xC3, 0xBE, 0x35, 0x88, 0x2E, - 0x93, 0x55, 0xFC, 0x7A, 0xC8, 0xBA, 0x32, 0xE6, - 0xC0, 0x19, 0x9E, 0xA3, 0x44, 0x54, 0x3B, 0x0B, - 0x8C, 0xC7, 0x6B, 0x28, 0xA7, 0xBC, 0x16, 0xAD, - 0xDB, 0x64, 0x74, 0x14, 0x92, 0x0C, 0x48, 0xB8, - 0x9F, 0xBD, 0x43, 0xC4, 0x39, 0x31, 0xD3, 0xF2, - 0xD5, 0x8B, 0x6E, 0xDA, 0x01, 0xB1, 0x9C, 0x49, - 0xD8, 0xAC, 0xF3, 0xCF, 0xCA, 0xF4, 0x47, 0x10, - 0x6F, 0xF0, 0x4A, 0x5C, 0x38, 0x57, 0x73, 0x97, - 0xCB, 0xA1, 0xE8, 0x3E, 0x96, 0x61, 0x0D, 0x0F, - 0xE0, 0x7C, 0x71, 0xCC, 0x90, 0x06, 0xF7, 0x1C, - 0xC2, 0x6A, 0xAE, 0x69, 0x17, 0x99, 0x3A, 0x27, - 0xD9, 0xEB, 0x2B, 0x22, 0xD2, 0xA9, 0x07, 0x33, - 0x2D, 0x3C, 0x15, 0xC9, 0x87, 0xAA, 0x50, 0xA5, - 0x03, 0x59, 0x09, 0x1A, 0x65, 0xD7, 0x84, 0xD0, - 0x82, 0x29, 0x5A, 0x1E, 0x7B, 0xA8, 0x6D, 0x2C -}; - -//STKIPKeyManagement sTKIPKeyTable[MAX_TKIP_KEY]; - -/*--------------------- Static Functions --------------------------*/ -unsigned int tkip_sbox(unsigned int index); -unsigned int rotr1(unsigned int a); - -/*--------------------- Export Variables --------------------------*/ - -/************************************************************/ -/* tkip_sbox() */ -/* Returns a 16 bit value from a 64K entry table. The Table */ -/* is synthesized from two 256 entry byte wide tables. */ -/************************************************************/ -unsigned int tkip_sbox(unsigned int index) -{ - unsigned int index_low; - unsigned int index_high; - unsigned int left, right; - - index_low = (index % 256); - index_high = ((index >> 8) % 256); - - left = TKIP_Sbox_Lower[index_low] + (TKIP_Sbox_Upper[index_low] * 256); - right = TKIP_Sbox_Upper[index_high] + (TKIP_Sbox_Lower[index_high] * 256); - - return left ^ right; -}; - -unsigned int rotr1(unsigned int a) -{ - unsigned int b; - - if ((a & 0x01) == 0x01) - b = (a >> 1) | 0x8000; - else - b = (a >> 1) & 0x7fff; - - b = b % 65536; - return b; -} - -/* - * Description: Calculate RC4Key fom TK, TA, and TSC - * - * Parameters: - * In: - * pbyTKey - TKey - * pbyTA - TA - * dwTSC - TSC - * Out: - * pbyRC4Key - RC4Key - * - * Return Value: none - * - */ -void TKIPvMixKey( - unsigned char *pbyTKey, - unsigned char *pbyTA, - unsigned short wTSC15_0, - unsigned long dwTSC47_16, - unsigned char *pbyRC4Key -) -{ - unsigned int p1k[5]; - unsigned int tsc0, tsc1, tsc2; - unsigned int ppk0, ppk1, ppk2, ppk3, ppk4, ppk5; - unsigned long int pnl, pnh; - - int i, j; - - pnl = wTSC15_0; - pnh = dwTSC47_16; - - tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */ - tsc1 = (unsigned int)(pnh % 65536); - tsc2 = (unsigned int)(pnl % 65536); /* lsb */ - - /* Phase 1, step 1 */ - p1k[0] = tsc1; - p1k[1] = tsc0; - p1k[2] = (unsigned int)(pbyTA[0] + (pbyTA[1]*256)); - p1k[3] = (unsigned int)(pbyTA[2] + (pbyTA[3]*256)); - p1k[4] = (unsigned int)(pbyTA[4] + (pbyTA[5]*256)); - - /* Phase 1, step 2 */ - for (i = 0; i < 8; i++) { - j = 2 * (i & 1); - p1k[0] = (p1k[0] + tkip_sbox((p1k[4] ^ ((256*pbyTKey[1+j]) + pbyTKey[j])) % 65536)) % 65536; - p1k[1] = (p1k[1] + tkip_sbox((p1k[0] ^ ((256*pbyTKey[5+j]) + pbyTKey[4+j])) % 65536)) % 65536; - p1k[2] = (p1k[2] + tkip_sbox((p1k[1] ^ ((256*pbyTKey[9+j]) + pbyTKey[8+j])) % 65536)) % 65536; - p1k[3] = (p1k[3] + tkip_sbox((p1k[2] ^ ((256*pbyTKey[13+j]) + pbyTKey[12+j])) % 65536)) % 65536; - p1k[4] = (p1k[4] + tkip_sbox((p1k[3] ^ (((256*pbyTKey[1+j]) + pbyTKey[j]))) % 65536)) % 65536; - p1k[4] = (p1k[4] + i) % 65536; - } - /* Phase 2, Step 1 */ - ppk0 = p1k[0]; - ppk1 = p1k[1]; - ppk2 = p1k[2]; - ppk3 = p1k[3]; - ppk4 = p1k[4]; - ppk5 = (p1k[4] + tsc2) % 65536; - - /* Phase2, Step 2 */ - ppk0 = ppk0 + tkip_sbox((ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) % 65536); - ppk1 = ppk1 + tkip_sbox((ppk0 ^ ((256*pbyTKey[3]) + pbyTKey[2])) % 65536); - ppk2 = ppk2 + tkip_sbox((ppk1 ^ ((256*pbyTKey[5]) + pbyTKey[4])) % 65536); - ppk3 = ppk3 + tkip_sbox((ppk2 ^ ((256*pbyTKey[7]) + pbyTKey[6])) % 65536); - ppk4 = ppk4 + tkip_sbox((ppk3 ^ ((256*pbyTKey[9]) + pbyTKey[8])) % 65536); - ppk5 = ppk5 + tkip_sbox((ppk4 ^ ((256*pbyTKey[11]) + pbyTKey[10])) % 65536); - - ppk0 = ppk0 + rotr1(ppk5 ^ ((256*pbyTKey[13]) + pbyTKey[12])); - ppk1 = ppk1 + rotr1(ppk0 ^ ((256*pbyTKey[15]) + pbyTKey[14])); - ppk2 = ppk2 + rotr1(ppk1); - ppk3 = ppk3 + rotr1(ppk2); - ppk4 = ppk4 + rotr1(ppk3); - ppk5 = ppk5 + rotr1(ppk4); - - /* Phase 2, Step 3 */ - pbyRC4Key[0] = (tsc2 >> 8) % 256; - pbyRC4Key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f; - pbyRC4Key[2] = tsc2 % 256; - pbyRC4Key[3] = ((ppk5 ^ ((256*pbyTKey[1]) + pbyTKey[0])) >> 1) % 256; - - pbyRC4Key[4] = ppk0 % 256; - pbyRC4Key[5] = (ppk0 >> 8) % 256; - - pbyRC4Key[6] = ppk1 % 256; - pbyRC4Key[7] = (ppk1 >> 8) % 256; - - pbyRC4Key[8] = ppk2 % 256; - pbyRC4Key[9] = (ppk2 >> 8) % 256; - - pbyRC4Key[10] = ppk3 % 256; - pbyRC4Key[11] = (ppk3 >> 8) % 256; - - pbyRC4Key[12] = ppk4 % 256; - pbyRC4Key[13] = (ppk4 >> 8) % 256; - - pbyRC4Key[14] = ppk5 % 256; - pbyRC4Key[15] = (ppk5 >> 8) % 256; -} diff --git a/drivers/staging/vt6655/tkip.h b/drivers/staging/vt6655/tkip.h deleted file mode 100644 index 3b6357ac6dee..000000000000 --- a/drivers/staging/vt6655/tkip.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tkip.h - * - * Purpose: Implement functions for 802.11i TKIP - * - * Author: Jerry Chen - * - * Date: Mar. 11, 2003 - * - */ - -#ifndef __TKIP_H__ -#define __TKIP_H__ - -#include "ttype.h" -#include "tether.h" - -/*--------------------- Export Definitions -------------------------*/ -#define TKIP_KEY_LEN 16 - -/*--------------------- Export Types ------------------------------*/ - -/*--------------------- Export Macros ------------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -void TKIPvMixKey( - unsigned char *pbyTKey, - unsigned char *pbyTA, - unsigned short wTSC15_0, - unsigned long dwTSC47_16, - unsigned char *pbyRC4Key -); - -#endif // __TKIP_H__ -- cgit v1.2.3-59-g8ed1b From e813580c36dc52c61a30dd2f71498fa1033df111 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:39 +0000 Subject: staging: vt6655: dead code remove michael.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/michael.c | 148 --------------------------------------- drivers/staging/vt6655/michael.h | 52 -------------- drivers/staging/vt6655/rxtx.c | 1 - 4 files changed, 202 deletions(-) delete mode 100644 drivers/staging/vt6655/michael.c delete mode 100644 drivers/staging/vt6655/michael.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index f49f12bc8b17..5449cedefdba 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -17,7 +17,6 @@ vt6655_stage-y += device_main.o \ tether.o \ tcrc.o \ key.o \ - michael.o \ rf.o \ vntwifi.o diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c deleted file mode 100644 index edee48777aac..000000000000 --- a/drivers/staging/vt6655/michael.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: michael.cpp - * - * Purpose: The implementation of LIST data structure. - * - * Author: Kyle Hsu - * - * Date: Sep 4, 2002 - * - * Functions: - * s_dwGetUINT32 - Convert from unsigned char [] to unsigned long in a portable way - * s_vPutUINT32 - Convert from unsigned long to unsigned char [] in a portable way - * s_vClear - Reset the state to the empty message. - * s_vSetKey - Set the key. - * MIC_vInit - Set the key. - * s_vAppendByte - Append the byte to our word-sized buffer. - * MIC_vAppend - call s_vAppendByte. - * MIC_vGetMIC - Append the minimum padding and call s_vAppendByte. - * - * Revision History: - * - */ - -#include "tmacro.h" -#include "michael.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -static void s_vClear(void); // Clear the internal message, -// resets the object to the state just after construction. -static void s_vSetKey(u32 dwK0, u32 dwK1); -static void s_vAppendByte(unsigned char b); // Add a single byte to the internal message - -/*--------------------- Export Variables --------------------------*/ -static u32 L, R; /* Current state */ - -static u32 K0, K1; /* Key */ -static u32 M; /* Message accumulator (single word) */ -static unsigned int nBytesInM; // # bytes in M - -/*--------------------- Export Functions --------------------------*/ - -static void s_vClear(void) -{ - // Reset the state to the empty message. - L = K0; - R = K1; - nBytesInM = 0; - M = 0; -} - -static void s_vSetKey(u32 dwK0, u32 dwK1) -{ - // Set the key - K0 = dwK0; - K1 = dwK1; - // and reset the message - s_vClear(); -} - -static void s_vAppendByte(unsigned char b) -{ - // Append the byte to our word-sized buffer - M |= b << (8*nBytesInM); - nBytesInM++; - // Process the word if it is full. - if (nBytesInM >= 4) { - L ^= M; - R ^= ROL32(L, 17); - L += R; - R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); - L += R; - R ^= ROL32(L, 3); - L += R; - R ^= ROR32(L, 2); - L += R; - // Clear the buffer - M = 0; - nBytesInM = 0; - } -} - -void MIC_vInit(u32 dwK0, u32 dwK1) -{ - // Set the key - s_vSetKey(dwK0, dwK1); -} - -void MIC_vUnInit(void) -{ - // Wipe the key material - K0 = 0; - K1 = 0; - - // And the other fields as well. - //Note that this sets (L,R) to (K0,K1) which is just fine. - s_vClear(); -} - -void MIC_vAppend(unsigned char *src, unsigned int nBytes) -{ - // This is simple - while (nBytes > 0) { - s_vAppendByte(*src++); - nBytes--; - } -} - -void MIC_vGetMIC(u32 *pdwL, u32 *pdwR) -{ - // Append the minimum padding - s_vAppendByte(0x5a); - s_vAppendByte(0); - s_vAppendByte(0); - s_vAppendByte(0); - s_vAppendByte(0); - // and then zeroes until the length is a multiple of 4 - while (nBytesInM != 0) - s_vAppendByte(0); - - // The s_vAppendByte function has already computed the result. - *pdwL = L; - *pdwR = R; - // Reset to the empty message. - s_vClear(); -} diff --git a/drivers/staging/vt6655/michael.h b/drivers/staging/vt6655/michael.h deleted file mode 100644 index 86cb140e3087..000000000000 --- a/drivers/staging/vt6655/michael.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: Michael.h - * - * Purpose: Reference implementation for Michael - * written by Niels Ferguson - * - * Author: Kyle Hsu - * - * Date: Jan 2, 2003 - * - */ - -#ifndef __MICHAEL_H__ -#define __MICHAEL_H__ - -#include - -void MIC_vInit(u32 dwK0, u32 dwK1); - -void MIC_vUnInit(void); - -/* Append bytes to the message to be MICed */ -void MIC_vAppend(unsigned char *src, unsigned int nBytes); - -/* Get the MIC result. Destination should accept 8 bytes of result. */ -/* This also resets the message to empty. */ -void MIC_vGetMIC(u32 *pdwL, u32 *pdwR); - -/* Rotation functions on 32 bit values */ -#define ROL32(A, n) \ - (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1))) -#define ROR32(A, n) ROL32((A), 32-(n)) - -#endif /*__MICHAEL_H__ */ diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 5ece2db9a2d4..4770b9cf622b 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -55,7 +55,6 @@ #include "bssdb.h" #include "mac.h" #include "baseband.h" -#include "michael.h" #include "tcrc.h" #include "wctl.h" #include "rf.h" -- cgit v1.2.3-59-g8ed1b From 610cc9d98b4335c7211207bd6c5c2254fcf43688 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:40 +0000 Subject: staging: vt6655: dead code remove vntwifi.c functions Header will be removed later Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 3 +- drivers/staging/vt6655/vntwifi.c | 658 --------------------------------------- drivers/staging/vt6655/vntwifi.h | 168 ---------- 3 files changed, 1 insertion(+), 828 deletions(-) delete mode 100644 drivers/staging/vt6655/vntwifi.c diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 5449cedefdba..d571e6f46ade 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -17,7 +17,6 @@ vt6655_stage-y += device_main.o \ tether.o \ tcrc.o \ key.o \ - rf.o \ - vntwifi.o + rf.o obj-$(CONFIG_VT6655) += vt6655_stage.o diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c deleted file mode 100644 index 54c65fca332d..000000000000 --- a/drivers/staging/vt6655/vntwifi.c +++ /dev/null @@ -1,658 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: vntwifi.c - * - * Purpose: export functions for vntwifi lib - * - * Functions: - * - * Revision History: - * - * Author: Yiching Chen - * - * Date: feb. 2, 2005 - * - */ - -#include "vntwifi.h" -#include "country.h" -#include "device.h" -#include "wmgr.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/*+ - * - * Description: - * Set Operation Mode - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * eOPMode - Operation Mode - * Out: - * none - * - * Return Value: none - * - -*/ -void -VNTWIFIvSetOPMode( - void *pMgmtHandle, - WMAC_CONFIG_MODE eOPMode -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - pMgmt->eConfigMode = eOPMode; -} - -/*+ - * - * Description: - * Set Operation Mode - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * wBeaconPeriod - Beacon Period - * wATIMWindow - ATIM window - * uChannel - channel number - * Out: - * none - * - * Return Value: none - * - -*/ -void -VNTWIFIvSetIBSSParameter( - void *pMgmtHandle, - unsigned short wBeaconPeriod, - unsigned short wATIMWindow, - unsigned int uChannel -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - pMgmt->wIBSSBeaconPeriod = wBeaconPeriod; - pMgmt->wIBSSATIMWindow = wATIMWindow; - pMgmt->uIBSSChannel = uChannel; -} - -/*+ - * - * Description: - * Get current SSID - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * Out: - * none - * - * Return Value: current SSID pointer. - * - -*/ -PWLAN_IE_SSID -VNTWIFIpGetCurrentSSID( - void *pMgmtHandle -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - return (PWLAN_IE_SSID) pMgmt->abyCurrSSID; -} - -/*+ - * - * Description: - * Get current link channel - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * Out: - * none - * - * Return Value: current Channel. - * - -*/ -unsigned int -VNTWIFIpGetCurrentChannel( - void *pMgmtHandle -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - if (pMgmtHandle != NULL) - return pMgmt->uCurrChannel; - - return 0; -} - -/*+ - * - * Description: - * Get current Assoc ID - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * Out: - * none - * - * Return Value: current Assoc ID - * - -*/ -unsigned short -VNTWIFIwGetAssocID( - void *pMgmtHandle -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - return pMgmt->wCurrAID; -} - -/*+ - * - * Description: - * This routine return max support rate of IES - * - * Parameters: - * In: - * pSupportRateIEs - * pExtSupportRateIEs - * - * Out: - * - * Return Value: max support rate - * - -*/ -unsigned char -VNTWIFIbyGetMaxSupportRate( - PWLAN_IE_SUPP_RATES pSupportRateIEs, - PWLAN_IE_SUPP_RATES pExtSupportRateIEs -) -{ - unsigned char byMaxSupportRate = RATE_1M; - unsigned char bySupportRate = RATE_1M; - unsigned int ii = 0; - - if (pSupportRateIEs) { - for (ii = 0; ii < pSupportRateIEs->len; ii++) { - if (bySupportRate > byMaxSupportRate) - byMaxSupportRate = bySupportRate; - - } - } - if (pExtSupportRateIEs) { - for (ii = 0; ii < pExtSupportRateIEs->len; ii++) { - if (bySupportRate > byMaxSupportRate) - byMaxSupportRate = bySupportRate; - - } - } - - return byMaxSupportRate; -} - -/*+ - * - * Description: - * This routine return data rate of ACK packtet - * - * Parameters: - * In: - * byRxDataRate - * pSupportRateIEs - * pExtSupportRateIEs - * - * Out: - * - * Return Value: max support rate - * - -*/ -unsigned char -VNTWIFIbyGetACKTxRate( - unsigned char byRxDataRate, - PWLAN_IE_SUPP_RATES pSupportRateIEs, - PWLAN_IE_SUPP_RATES pExtSupportRateIEs -) -{ - unsigned char byMaxAckRate; - unsigned int ii; - - if (byRxDataRate <= RATE_11M) { - byMaxAckRate = RATE_1M; - } else { - /* 24M is mandatory for 802.11a and 802.11g */ - byMaxAckRate = RATE_24M; - } - if (pSupportRateIEs) { - for (ii = 0; ii < pSupportRateIEs->len; ii++) { - if (pSupportRateIEs->abyRates[ii] & 0x80) { - } - } - } - if (pExtSupportRateIEs) { - for (ii = 0; ii < pExtSupportRateIEs->len; ii++) { - if (pExtSupportRateIEs->abyRates[ii] & 0x80) { - } - } - } - - return byMaxAckRate; -} - -/*+ - * - * Description: - * Set Authentication Mode - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * eAuthMode - Authentication mode - * Out: - * none - * - * Return Value: none - * - -*/ -void -VNTWIFIvSetAuthenticationMode( - void *pMgmtHandle, - WMAC_AUTHENTICATION_MODE eAuthMode -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - pMgmt->eAuthenMode = eAuthMode; - if ((eAuthMode == WMAC_AUTH_SHAREKEY) || - (eAuthMode == WMAC_AUTH_AUTO)) { - pMgmt->bShareKeyAlgorithm = true; - } else { - pMgmt->bShareKeyAlgorithm = false; - } -} - -/*+ - * - * Description: - * Set Encryption Mode - * - * Parameters: - * In: - * pMgmtHandle - pointer to management object - * eAuthMode - Authentication mode - * Out: - * none - * - * Return Value: none - * - -*/ -void -VNTWIFIvSetEncryptionMode( - void *pMgmtHandle, - WMAC_ENCRYPTION_MODE eEncryptionMode -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - pMgmt->eEncryptionMode = eEncryptionMode; - if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) || - (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) || - (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled)) { - pMgmt->bPrivacyInvoked = true; - } else { - pMgmt->bPrivacyInvoked = false; - } -} - -bool -VNTWIFIbConfigPhyMode( - void *pMgmtHandle, - CARD_PHY_TYPE ePhyType -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - if ((ePhyType != PHY_TYPE_AUTO) && - (ePhyType != pMgmt->eCurrentPHYMode)) { - if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL) == true) - pMgmt->eCurrentPHYMode = ePhyType; - else - return false; - } - pMgmt->eConfigPHYMode = ePhyType; - return true; -} - -void -VNTWIFIbGetConfigPhyMode( - void *pMgmtHandle, - void *pePhyType -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - if ((pMgmt != NULL) && (pePhyType != NULL)) - *(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode; -} - -/*+ - * - * Description: - * Clear BSS List Database except current assoc BSS - * - * Parameters: - * In: - * pMgmtHandle - Management Object structure - * bLinkPass - Current Link status - * Out: - * - * Return Value: None. - * - -*/ - -/*+ - * - * Description: - * Query BSS List in management database - * - * Parameters: - * In: - * pMgmtHandle - Management Object structure - * Out: - * puBSSCount - BSS count - * pvFirstBSS - pointer to first BSS - * - * Return Value: None. - * - -*/ - -void -VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirstBSS) -{ - unsigned int ii = 0; - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - PKnownBSS pBSS = NULL; - unsigned int uCount = 0; - - *pvFirstBSS = NULL; - - for (ii = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - - if (*pvFirstBSS == NULL) - *pvFirstBSS = &(pMgmt->sBSSList[ii]); - - uCount++; - } - *puBSSCount = uCount; -} - -void -VNTWIFIvGetNextBSS( - void *pMgmtHandle, - void *pvCurrentBSS, - void **pvNextBSS -) -{ - PKnownBSS pBSS = (PKnownBSS) pvCurrentBSS; - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - *pvNextBSS = NULL; - - while (*pvNextBSS == NULL) { - pBSS++; - if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) - return; - - if (pBSS->bActive == true) { - *pvNextBSS = pBSS; - return; - } - } -} - -/*+ - * - * Description: - * Update Tx attemps, Tx failure counter in Node DB - * - * In: - * Out: - * none - * - * Return Value: none - * - -*/ -void -VNTWIFIvUpdateNodeTxCounter( - void *pMgmtHandle, - unsigned char *pbyDestAddress, - bool bTxOk, - unsigned short wRate, - unsigned char *pbyTxFailCount -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - unsigned int uNodeIndex = 0; - unsigned int ii; - - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || - (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { - } - - pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++; - if (bTxOk) { - /* transmit success, TxAttempts at least plus one */ - pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++; - pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++; - } else { - pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++; - } - pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE]; - for (ii = 0; ii < MAX_RATE; ii++) - pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii]; -} - -void -VNTWIFIvGetTxRate( - void *pMgmtHandle, - unsigned char *pbyDestAddress, - unsigned short *pwTxDataRate, - unsigned char *pbyACKRate, - unsigned char *pbyCCKBasicRate, - unsigned char *pbyOFDMBasicRate -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - unsigned short wTxDataRate = RATE_1M; - unsigned char byACKRate = RATE_1M; - unsigned char byCCKBasicRate = RATE_1M; - unsigned char byOFDMBasicRate = RATE_24M; - PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL; - PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL; - - if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || - (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { - /* Adhoc Tx rate decided from node DB */ - } else { /* Infrastructure: rate decided from AP Node, index = 0 */ - - wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate); - - pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates; - pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates; - } - byACKRate = VNTWIFIbyGetACKTxRate((unsigned char) wTxDataRate, - pSupportRateIEs, - pExtSupportRateIEs -); - if (byACKRate > (unsigned char) wTxDataRate) - byACKRate = (unsigned char) wTxDataRate; - - byCCKBasicRate = VNTWIFIbyGetACKTxRate(RATE_11M, - pSupportRateIEs, - pExtSupportRateIEs -); - byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M, - pSupportRateIEs, - pExtSupportRateIEs -); - *pwTxDataRate = wTxDataRate; - *pbyACKRate = byACKRate; - *pbyCCKBasicRate = byCCKBasicRate; - *pbyOFDMBasicRate = byOFDMBasicRate; -} - -unsigned char -VNTWIFIbyGetKeyCypher( - void *pMgmtHandle, - bool bGroupKey -) -{ - PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - - if (bGroupKey) - return pMgmt->byCSSGK; - return pMgmt->byCSSPK; -} - -bool -VNTWIFIbSetPMKIDCache( - void *pMgmtObject, - unsigned long ulCount, - void *pPMKIDInfo -) -{ - return true; -} - -unsigned short -VNTWIFIwGetMaxSupportRate( - void *pMgmtObject -) -{ - unsigned short wRate = RATE_54M; - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - - for (wRate = RATE_54M; wRate > RATE_1M; wRate--) { - if (pMgmt->sNodeDBTable[0].wSuppRate & (1<eCurrentPHYMode == PHY_TYPE_11A) - return RATE_6M; - return RATE_1M; -} - -void -VNTWIFIvSet11h( - void *pMgmtObject, - bool b11hEnable -) -{ - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - - pMgmt->b11hEnable = b11hEnable; -} - -bool -VNTWIFIbMeasureReport( - void *pMgmtObject, - bool bEndOfReport, - void *pvMeasureEID, - unsigned char byReportMode, - unsigned char byBasicMap, - unsigned char byCCAFraction, - unsigned char *pbyRPIs -) -{ - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - unsigned char *pbyCurrentEID = (unsigned char *)(pMgmt->pCurrMeasureEIDRep); - - if ((pvMeasureEID != NULL) && - (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3)) -) { - pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP; - pMgmt->pCurrMeasureEIDRep->len = 3; - pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ)pvMeasureEID)->byToken; - pMgmt->pCurrMeasureEIDRep->byMode = byReportMode; - pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType; - switch (pMgmt->pCurrMeasureEIDRep->byType) { - case MEASURE_TYPE_BASIC: - pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC); - memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sBasic), - &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq), - sizeof(MEASEURE_REQ)); - pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap; - break; - case MEASURE_TYPE_CCA: - pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA); - memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sCCA), - &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq), - sizeof(MEASEURE_REQ)); - pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction; - break; - case MEASURE_TYPE_RPI: - pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI); - memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sRPI), - &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq), - sizeof(MEASEURE_REQ)); - memcpy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8); - break; - default: - break; - } - pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len); - pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len); - pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID; - } - - return true; -} - -bool -VNTWIFIbChannelSwitch( - void *pMgmtObject, - unsigned char byNewChannel -) -{ - PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - - pMgmt->uCurrChannel = byNewChannel; - pMgmt->bSwitchChannel = false; - return true; -} diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index 9db734f00419..ad180e077e3f 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -100,173 +100,5 @@ typedef enum tagWMAC_POWER_MODE { WMAC_POWER_MAX } WMAC_POWER_MODE, *PWMAC_POWER_MODE; -#define VNTWIFIbIsShortSlotTime(wCapInfo) \ - WLAN_GET_CAP_INFO_SHORTSLOTTIME(wCapInfo) \ - -#define VNTWIFIbIsProtectMode(byERP) \ - ((byERP & WLAN_EID_ERP_USE_PROTECTION) != 0) \ - -#define VNTWIFIbIsBarkerMode(byERP) \ - ((byERP & WLAN_EID_ERP_BARKER_MODE) != 0) \ - -#define VNTWIFIbIsShortPreamble(wCapInfo) \ - WLAN_GET_CAP_INFO_SHORTPREAMBLE(wCapInfo) \ - -#define VNTWIFIbIsEncryption(wCapInfo) \ - WLAN_GET_CAP_INFO_PRIVACY(wCapInfo) \ - -#define VNTWIFIbIsESS(wCapInfo) \ - WLAN_GET_CAP_INFO_ESS(wCapInfo) \ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Types ------------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -void -VNTWIFIvSetIBSSParameter( - void *pMgmtHandle, - unsigned short wBeaconPeriod, - unsigned short wATIMWindow, - unsigned int uChannel -); - -void -VNTWIFIvSetOPMode( - void *pMgmtHandle, - WMAC_CONFIG_MODE eOPMode -); - -PWLAN_IE_SSID -VNTWIFIpGetCurrentSSID( - void *pMgmtHandle -); - -unsigned int -VNTWIFIpGetCurrentChannel( - void *pMgmtHandle -); - -unsigned short -VNTWIFIwGetAssocID( - void *pMgmtHandle -); - -unsigned char -VNTWIFIbyGetMaxSupportRate( - PWLAN_IE_SUPP_RATES pSupportRateIEs, - PWLAN_IE_SUPP_RATES pExtSupportRateIEs -); - -unsigned char -VNTWIFIbyGetACKTxRate( - unsigned char byRxDataRate, - PWLAN_IE_SUPP_RATES pSupportRateIEs, - PWLAN_IE_SUPP_RATES pExtSupportRateIEs -); - -void -VNTWIFIvSetAuthenticationMode( - void *pMgmtHandle, - WMAC_AUTHENTICATION_MODE eAuthMode -); - -void -VNTWIFIvSetEncryptionMode( - void *pMgmtHandle, - WMAC_ENCRYPTION_MODE eEncryptionMode -); - -bool -VNTWIFIbConfigPhyMode( - void *pMgmtHandle, - CARD_PHY_TYPE ePhyType -); - -void -VNTWIFIbGetConfigPhyMode( - void *pMgmtHandle, - void *pePhyType -); - -void -VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, - void **pvFirstBSS); - -void -VNTWIFIvGetNextBSS( - void *pMgmtHandle, - void *pvCurrentBSS, - void **pvNextBSS -); - -void -VNTWIFIvUpdateNodeTxCounter( - void *pMgmtHandle, - unsigned char *pbyDestAddress, - bool bTxOk, - unsigned short wRate, - unsigned char *pbyTxFailCount -); - -void -VNTWIFIvGetTxRate( - void *pMgmtHandle, - unsigned char *pbyDestAddress, - unsigned short *pwTxDataRate, - unsigned char *pbyACKRate, - unsigned char *pbyCCKBasicRate, - unsigned char *pbyOFDMBasicRate -); - -unsigned char -VNTWIFIbyGetKeyCypher( - void *pMgmtHandle, - bool bGroupKey -); - -bool -VNTWIFIbSetPMKIDCache( - void *pMgmtObject, - unsigned long ulCount, - void *pPMKIDInfo -); - -bool -VNTWIFIbCommandRunning( - void *pMgmtObject -); - -unsigned short -VNTWIFIwGetMaxSupportRate( - void *pMgmtObject -); - -// for 802.11h -void -VNTWIFIvSet11h( - void *pMgmtObject, - bool b11hEnable -); - -bool -VNTWIFIbMeasureReport( - void *pMgmtObject, - bool bEndOfReport, - void *pvMeasureEID, - unsigned char byReportMode, - unsigned char byBasicMap, - unsigned char byCCAFraction, - unsigned char *pbyRPIs -); - -bool -VNTWIFIbChannelSwitch( - void *pMgmtObject, - unsigned char byNewChannel -); #endif //__VNTWIFI_H__ -- cgit v1.2.3-59-g8ed1b From 77bb9975d445422c5b1acc5f5ca1355db87a843a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:41 +0000 Subject: staging: vt6655: key.c remove dead functions Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 1 - drivers/staging/vt6655/key.c | 760 ---------------------------------------- drivers/staging/vt6655/key.h | 120 ------- 3 files changed, 881 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 4bea23799233..a5e5a00743c6 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -539,7 +539,6 @@ struct vnt_private { bool bTransmitKey; NDIS_802_11_WEP_STATUS eOldEncryptionStatus; - SKeyManagement sKey; unsigned long dwIVCounter; u64 qwPacketNumber; /* For CCMP and TKIP as TSC(6 bytes) */ diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index b2fa8125e29d..f2b3fea90533 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -25,772 +25,12 @@ * * Date: May 29, 2003 * - * Functions: - * KeyvInitTable - Init Key management table - * KeybGetKey - Get Key from table - * KeybSetKey - Set Key to table - * KeybRemoveKey - Remove Key from table - * KeybGetTransmitKey - Get Transmit Key from table - * - * Revision History: - * */ #include "tmacro.h" #include "key.h" #include "mac.h" -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ -static void -s_vCheckKeyTableValid(PSKeyManagement pTable, void __iomem *dwIoBase) -{ - int i; - - for (i = 0; i < MAX_KEY_TABLE; i++) { - if (pTable->KeyTable[i].bInUse && - !pTable->KeyTable[i].PairwiseKey.bKeyValid && - !pTable->KeyTable[i].GroupKey[0].bKeyValid && - !pTable->KeyTable[i].GroupKey[1].bKeyValid && - !pTable->KeyTable[i].GroupKey[2].bKeyValid && - !pTable->KeyTable[i].GroupKey[3].bKeyValid) { - pTable->KeyTable[i].bInUse = false; - pTable->KeyTable[i].wKeyCtl = 0; - pTable->KeyTable[i].bSoftWEP = false; - MACvDisableKeyEntry(dwIoBase, i); - } - } -} - -/*--------------------- Export Functions --------------------------*/ - -/* - * Description: Init Key management table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * Out: - * none - * - * Return Value: none - * - */ -void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase) -{ - int i; - int jj; - - for (i = 0; i < MAX_KEY_TABLE; i++) { - pTable->KeyTable[i].bInUse = false; - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - pTable->KeyTable[i].PairwiseKey.pvKeyTable = (void *)&pTable->KeyTable[i]; - for (jj = 0; jj < MAX_GROUP_KEY; jj++) { - pTable->KeyTable[i].GroupKey[jj].bKeyValid = false; - pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (void *)&pTable->KeyTable[i]; - } - pTable->KeyTable[i].wKeyCtl = 0; - pTable->KeyTable[i].dwGTKeyIndex = 0; - pTable->KeyTable[i].bSoftWEP = false; - MACvDisableKeyEntry(dwIoBase, i); - } -} - -/* - * Description: Get Key from table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * pbyBSSID - BSSID of Key - * dwKeyIndex - Key Index (0xFFFFFFFF means pairwise key) - * Out: - * pKey - Key return - * - * Return Value: true if found otherwise false - * - */ -bool KeybGetKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - PSKeyItem *pKey -) -{ - int i; - - pr_debug("KeybGetKey()\n"); - - *pKey = NULL; - for (i = 0; i < MAX_KEY_TABLE; i++) { - if (pTable->KeyTable[i].bInUse && - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - if (dwKeyIndex == 0xFFFFFFFF) { - if (pTable->KeyTable[i].PairwiseKey.bKeyValid) { - *pKey = &(pTable->KeyTable[i].PairwiseKey); - return true; - } else { - return false; - } - } else if (dwKeyIndex < MAX_GROUP_KEY) { - if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid) { - *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); - return true; - } else { - return false; - } - } else { - return false; - } - } - } - return false; -} - -/* - * Description: Set Key to table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * pbyBSSID - BSSID of Key - * dwKeyIndex - Key index (reference to NDIS DDK) - * uKeyLength - Key length - * KeyRSC - Key RSC - * pbyKey - Pointer to key - * Out: - * none - * - * Return Value: true if success otherwise false - * - */ -bool KeybSetKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - u64 *pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - void __iomem *dwIoBase, - unsigned char byLocalID -) -{ - int i, j; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; - - pr_debug("Enter KeybSetKey: %lX\n", dwKeyIndex); - - j = (MAX_KEY_TABLE-1); - for (i = 0; i < (MAX_KEY_TABLE - 1); i++) { - if (!pTable->KeyTable[i].bInUse && (j == (MAX_KEY_TABLE-1))) { - // found empty table - j = i; - } - if (pTable->KeyTable[i].bInUse && - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - // found table already exist - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - // Pairwise key - pKey = &(pTable->KeyTable[i].PairwiseKey); - pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed - pTable->KeyTable[i].wKeyCtl |= byKeyDecMode; - uKeyIdx = 4; // use HW key entry 4 for pairwise key - } else { - // Group key - if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return false; - pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; - pr_debug("Group transmit key(R)[%lX]: %d\n", - pTable->KeyTable[i].dwGTKeyIndex, i); - } - pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed - pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address - uKeyIdx = (dwKeyIndex & 0x000000FF); - } - pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - pKey->KeyRSC = 0; - } else { - pKey->KeyRSC = *pKeyRSC; - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - pr_debug("KeybSetKey(R):\n"); - pr_debug("pKey->bKeyValid: %d\n ", pKey->bKeyValid); - pr_debug("pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) - pr_debug("%02x ", pKey->abyKey[ii]); - - pr_debug("\n"); - - pr_debug("pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); - pr_debug("pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); - pr_debug("pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex); - - return true; - } - } - if (j < (MAX_KEY_TABLE-1)) { - ether_addr_copy(pTable->KeyTable[j].abyBSSID, pbyBSSID); - pTable->KeyTable[j].bInUse = true; - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - // Pairwise key - pKey = &(pTable->KeyTable[j].PairwiseKey); - pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed - pTable->KeyTable[j].wKeyCtl |= byKeyDecMode; - uKeyIdx = 4; // use HW key entry 4 for pairwise key - } else { - // Group key - if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return false; - pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex; - pr_debug("Group transmit key(N)[%lX]: %d\n", - pTable->KeyTable[j].dwGTKeyIndex, j); - } - pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed - pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address - uKeyIdx = (dwKeyIndex & 0x000000FF); - } - pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - pKey->KeyRSC = 0; - } else { - pKey->KeyRSC = *pKeyRSC; - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - pr_debug("KeybSetKey(N):\n"); - pr_debug("pKey->bKeyValid: %d\n ", pKey->bKeyValid); - pr_debug("pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); - pr_debug("pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) - pr_debug("%02x ", pKey->abyKey[ii]); - - pr_debug("\n"); - - pr_debug("pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); - pr_debug("pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); - pr_debug("pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex); - - return true; - } - return false; -} - -/* - * Description: Remove Key from table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * pbyBSSID - BSSID of Key - * dwKeyIndex - Key Index (reference to NDIS DDK) - * Out: - * none - * - * Return Value: true if success otherwise false - * - */ -bool KeybRemoveKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - void __iomem *dwIoBase -) -{ - int i; - - if (is_broadcast_ether_addr(pbyBSSID)) { - // delete all keys - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - for (i = 0; i < MAX_KEY_TABLE; i++) - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - for (i = 0; i < MAX_KEY_TABLE; i++) { - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { - // remove Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = 0; - } - } - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } - return false; - } - - for (i = 0; i < MAX_KEY_TABLE; i++) { - if (pTable->KeyTable[i].bInUse && - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { - // remove Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = 0; - } - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } - return false; - } - } - return false; -} - -/* - * Description: Remove Key from table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * pbyBSSID - BSSID of Key - * Out: - * none - * - * Return Value: true if success otherwise false - * - */ -bool KeybRemoveAllKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - void __iomem *dwIoBase -) -{ - int i, u; - - for (i = 0; i < MAX_KEY_TABLE; i++) { - if (pTable->KeyTable[i].bInUse && - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - for (u = 0; u < MAX_GROUP_KEY; u++) - pTable->KeyTable[i].GroupKey[u].bKeyValid = false; - - pTable->KeyTable[i].dwGTKeyIndex = 0; - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } - } - return false; -} - -/* - * Description: Remove WEP Key from table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * Out: - * none - * - * Return Value: true if success otherwise false - * - */ -void KeyvRemoveWEPKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - void __iomem *dwIoBase -) -{ - if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse) { - if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) { - pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) { - // remove Group transmit key - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0; - } - } - } - s_vCheckKeyTableValid(pTable, dwIoBase); - } -} - -void KeyvRemoveAllWEPKey( - PSKeyManagement pTable, - void __iomem *dwIoBase -) -{ - int i; - - for (i = 0; i < MAX_GROUP_KEY; i++) - KeyvRemoveWEPKey(pTable, i, dwIoBase); -} - -/* - * Description: Get Transmit Key from table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * pbyBSSID - BSSID of Key - * Out: - * pKey - Key return - * - * Return Value: true if found otherwise false - * - */ -bool KeybGetTransmitKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyType, - PSKeyItem *pKey -) -{ - int i, ii; - - *pKey = NULL; - for (i = 0; i < MAX_KEY_TABLE; i++) { - if (pTable->KeyTable[i].bInUse && - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - if (dwKeyType == PAIRWISE_KEY) { - if (pTable->KeyTable[i].PairwiseKey.bKeyValid) { - *pKey = &(pTable->KeyTable[i].PairwiseKey); - - pr_debug("KeybGetTransmitKey:"); - pr_debug("PAIRWISE_KEY: KeyTable.abyBSSID: "); - for (ii = 0; ii < 6; ii++) - pr_debug("%x ", - pTable->KeyTable[i].abyBSSID[ii]); - - pr_debug("\n"); - - return true; - } else { - pr_debug("PairwiseKey.bKeyValid == false\n"); - return false; - } - } // End of Type == PAIRWISE - else { - if (pTable->KeyTable[i].dwGTKeyIndex == 0) { - pr_debug("ERROR: dwGTKeyIndex == 0 !!!\n"); - return false; - } - if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid) { - *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]); - - pr_debug("KeybGetTransmitKey:"); - pr_debug("GROUP_KEY: KeyTable.abyBSSID\n"); - for (ii = 0; ii < 6; ii++) - pr_debug("%x ", - pTable->KeyTable[i].abyBSSID[ii]); - - pr_debug("\n"); - pr_debug("dwGTKeyIndex: %lX\n", - pTable->KeyTable[i].dwGTKeyIndex); - - return true; - } else { - pr_debug("GroupKey.bKeyValid == false\n"); - return false; - } - } // End of Type = GROUP - } // BSSID match - } - pr_debug("ERROR: NO Match BSSID !!! "); - for (ii = 0; ii < 6; ii++) - pr_debug("%02x ", *(pbyBSSID+ii)); - - pr_debug("\n"); - return false; -} - -/* - * Description: Check Pairewise Key - * - * Parameters: - * In: - * pTable - Pointer to Key table - * Out: - * none - * - * Return Value: true if found otherwise false - * - */ -bool KeybCheckPairewiseKey( - PSKeyManagement pTable, - PSKeyItem *pKey -) -{ - int i; - - *pKey = NULL; - for (i = 0; i < MAX_KEY_TABLE; i++) { - if (pTable->KeyTable[i].bInUse && - pTable->KeyTable[i].PairwiseKey.bKeyValid) { - *pKey = &(pTable->KeyTable[i].PairwiseKey); - return true; - } - } - return false; -} - -/* - * Description: Set Key to table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * dwKeyIndex - Key index (reference to NDIS DDK) - * uKeyLength - Key length - * KeyRSC - Key RSC - * pbyKey - Pointer to key - * Out: - * none - * - * Return Value: true if success otherwise false - * - */ -bool KeybSetDefaultKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - u64 *pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - void __iomem *dwIoBase, - unsigned char byLocalID -) -{ - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; - - pr_debug("Enter KeybSetDefaultKey: %1x, %d\n", - (int)dwKeyIndex, (int)uKeyLength); - - if ((dwKeyIndex & PAIRWISE_KEY) != 0) // Pairwise key - return false; - else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return false; - - if (uKeyLength > MAX_KEY_LEN) - return false; - - pTable->KeyTable[MAX_KEY_TABLE - 1].bInUse = true; - for (ii = 0; ii < ETH_ALEN; ii++) - pTable->KeyTable[MAX_KEY_TABLE - 1].abyBSSID[ii] = 0xFF; - - // Group key - pKey = &(pTable->KeyTable[MAX_KEY_TABLE - 1].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex; - pr_debug("Group transmit key(R)[%lX]: %d\n", - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, - MAX_KEY_TABLE-1); - - } - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode); - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address - uKeyIdx = (dwKeyIndex & 0x000000FF); - - if ((uKeyLength == WLAN_WEP232_KEYLEN) && - (byKeyDecMode == KEY_CTL_WEP)) { - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match - pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true; - } else { - if (!pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP) - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match - } - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (u32 *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - pKey->KeyRSC = 0; - } else { - pKey->KeyRSC = *pKeyRSC; - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - pr_debug("KeybSetKey(R):\n"); - pr_debug("pKey->bKeyValid: %d\n", pKey->bKeyValid); - pr_debug("pKey->uKeyLength: %d\n", (int)pKey->uKeyLength); - pr_debug("pKey->abyKey:\n"); - for (ii = 0; ii < pKey->uKeyLength; ii++) - pr_debug("%x", pKey->abyKey[ii]); - - pr_debug("\n"); - - pr_debug("pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16); - pr_debug("pKey->wTSC15_0: %x\n", pKey->wTSC15_0); - pr_debug("pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex); - - return true; -} - -/* - * Description: Set Key to table - * - * Parameters: - * In: - * pTable - Pointer to Key table - * dwKeyIndex - Key index (reference to NDIS DDK) - * uKeyLength - Key length - * KeyRSC - Key RSC - * pbyKey - Pointer to key - * Out: - * none - * - * Return Value: true if success otherwise false - * - */ -bool KeybSetAllGroupKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - u64 *pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - void __iomem *dwIoBase, - unsigned char byLocalID -) -{ - int i; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; - - pr_debug("Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex); - - if ((dwKeyIndex & PAIRWISE_KEY) != 0) // Pairwise key - return false; - else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return false; - - for (i = 0; i < MAX_KEY_TABLE - 1; i++) { - if (pTable->KeyTable[i].bInUse) { - // found table already exist - // Group key - pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; - pr_debug("Group transmit key(R)[%lX]: %d\n", - pTable->KeyTable[i].dwGTKeyIndex, i); - - } - pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed - pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address - uKeyIdx = (dwKeyIndex & 0x000000FF); - - pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (u32 *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - pKey->KeyRSC = 0; - } else { - pKey->KeyRSC = *pKeyRSC; - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - pr_debug("KeybSetKey(R):\n"); - pr_debug("pKey->bKeyValid: %d\n ", pKey->bKeyValid); - pr_debug("pKey->uKeyLength: %d\n ", - (int)pKey->uKeyLength); - pr_debug("pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) - pr_debug("%02x ", pKey->abyKey[ii]); - - pr_debug("\n"); - - } // (pTable->KeyTable[i].bInUse == true) - } - return true; -} - int vnt_key_init_table(struct vnt_private *priv) { u32 i; diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index d70ffd6fe728..56d1b05aad79 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -63,126 +63,6 @@ #define VNT_KEY_ONFLY 0x8000 #define VNT_KEY_ONFLY_ALL 0x4000 -typedef struct tagSKeyItem { - bool bKeyValid; - unsigned long uKeyLength; - unsigned char abyKey[MAX_KEY_LEN]; - u64 KeyRSC; - unsigned long dwTSC47_16; - unsigned short wTSC15_0; - unsigned char byCipherSuite; - unsigned char byReserved0; - unsigned long dwKeyIndex; - void *pvKeyTable; -} SKeyItem, *PSKeyItem; //64 - -typedef struct tagSKeyTable { - unsigned char abyBSSID[ETH_ALEN]; //6 - unsigned char byReserved0[2]; //8 - SKeyItem PairwiseKey; - SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 - unsigned long dwGTKeyIndex; // GroupTransmitKey Index - bool bInUse; - //2006-1116-01, by NomadZhao - bool bSoftWEP; - unsigned short wKeyCtl; // for address of wKeyCtl at align 4 - - unsigned char byReserved1[6]; -} SKeyTable, *PSKeyTable; //348 - -typedef struct tagSKeyManagement { - SKeyTable KeyTable[MAX_KEY_TABLE]; -} SKeyManagement, *PSKeyManagement; - -/*--------------------- Export Types ------------------------------*/ - -/*--------------------- Export Macros ------------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase); - -bool KeybGetKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - PSKeyItem *pKey -); - -bool KeybSetKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - u64 *pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - void __iomem *dwIoBase, - unsigned char byLocalID -); - -bool KeybSetDefaultKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - u64 *pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - void __iomem *dwIoBase, - unsigned char byLocalID -); - -bool KeybRemoveKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - void __iomem *dwIoBase -); - -bool KeybGetTransmitKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyType, - PSKeyItem *pKey -); - -bool KeybCheckPairewiseKey( - PSKeyManagement pTable, - PSKeyItem *pKey -); - -bool KeybRemoveAllKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - void __iomem *dwIoBase -); - -void KeyvRemoveWEPKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - void __iomem *dwIoBase -); - -void KeyvRemoveAllWEPKey( - PSKeyManagement pTable, - void __iomem *dwIoBase -); - -bool KeybSetAllGroupKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - u64 *pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - void __iomem *dwIoBase, - unsigned char byLocalID -); - struct vnt_private; int vnt_key_init_table(struct vnt_private *); -- cgit v1.2.3-59-g8ed1b From 1243317b4670db31b12a9ed6364b0ffd0692c4d1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:42 +0000 Subject: staging: vt6655: mib remove unused functions and structure members Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mib.c | 423 ------------------------------------------- drivers/staging/vt6655/mib.h | 259 -------------------------- 2 files changed, 682 deletions(-) diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index 111c01877086..d2f351d19ff8 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -25,24 +25,15 @@ * Date: May 21, 1996 * * Functions: - * STAvClearAllCounter - Clear All MIB Counter * STAvUpdateIstStatCounter - Update ISR statistic counter - * STAvUpdateRDStatCounter - Update Rx statistic counter - * STAvUpdateRDStatCounterEx - Update Rx statistic counter and copy rcv data - * STAvUpdateTDStatCounter - Update Tx statistic counter - * STAvUpdateTDStatCounterEx - Update Tx statistic counter and copy tx data * STAvUpdate802_11Counter - Update 802.11 mib counter * * Revision History: * */ -#include "upc.h" #include "mac.h" -#include "tether.h" #include "mib.h" -#include "wctl.h" -#include "baseband.h" /*--------------------- Static Classes ----------------------------*/ @@ -54,24 +45,6 @@ /*--------------------- Export Functions --------------------------*/ -/* - * Description: Clear All Statistic Counter - * - * Parameters: - * In: - * pStatistic - Pointer to Statistic Counter Data Structure - * Out: - * none - * - * Return Value: none - * - */ -void STAvClearAllCounter(PSStatCounter pStatistic) -{ - // set memory to zero - memset(pStatistic, 0, sizeof(SStatCounter)); -} - /* * Description: Update Isr Statistic Counter * @@ -138,373 +111,6 @@ void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr) pStatistic->ISRStat.dwIsrSTIMER1Int++; } -/* - * Description: Update Rx Statistic Counter - * - * Parameters: - * In: - * pStatistic - Pointer to Statistic Counter Data Structure - * byRSR - Rx Status - * byNewRSR - Rx Status - * pbyBuffer - Rx Buffer - * cbFrameLength - Rx Length - * Out: - * none - * - * Return Value: none - * - */ -void STAvUpdateRDStatCounter(PSStatCounter pStatistic, - unsigned char byRSR, unsigned char byNewRSR, unsigned char byRxRate, - unsigned char *pbyBuffer, unsigned int cbFrameLength) -{ - //need change - PS802_11Header pHeader = (PS802_11Header)pbyBuffer; - - if (byRSR & RSR_ADDROK) - pStatistic->dwRsrADDROk++; - if (byRSR & RSR_CRCOK) { - pStatistic->dwRsrCRCOk++; - - pStatistic->ullRsrOK++; - - if (cbFrameLength >= ETH_ALEN) { - // update counters in case of successful transmit - if (byRSR & RSR_ADDRBROAD) { - pStatistic->ullRxBroadcastFrames++; - pStatistic->ullRxBroadcastBytes += (unsigned long long) cbFrameLength; - } else if (byRSR & RSR_ADDRMULTI) { - pStatistic->ullRxMulticastFrames++; - pStatistic->ullRxMulticastBytes += (unsigned long long) cbFrameLength; - } else { - pStatistic->ullRxDirectedFrames++; - pStatistic->ullRxDirectedBytes += (unsigned long long) cbFrameLength; - } - } - } - - if (byRxRate == 22) { - pStatistic->CustomStat.ullRsr11M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr11MCRCOk++; - - pr_debug("11M: ALL[%d], OK[%d]:[%02x]\n", - (int)pStatistic->CustomStat.ullRsr11M, - (int)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR); - } else if (byRxRate == 11) { - pStatistic->CustomStat.ullRsr5M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr5MCRCOk++; - - pr_debug(" 5M: ALL[%d], OK[%d]:[%02x]\n", - (int)pStatistic->CustomStat.ullRsr5M, - (int)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR); - } else if (byRxRate == 4) { - pStatistic->CustomStat.ullRsr2M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr2MCRCOk++; - - pr_debug(" 2M: ALL[%d], OK[%d]:[%02x]\n", - (int)pStatistic->CustomStat.ullRsr2M, - (int)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR); - } else if (byRxRate == 2) { - pStatistic->CustomStat.ullRsr1M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr1MCRCOk++; - - pr_debug(" 1M: ALL[%d], OK[%d]:[%02x]\n", - (int)pStatistic->CustomStat.ullRsr1M, - (int)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR); - } else if (byRxRate == 12) { - pStatistic->CustomStat.ullRsr6M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr6MCRCOk++; - - pr_debug(" 6M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr6M, - (int)pStatistic->CustomStat.ullRsr6MCRCOk); - } else if (byRxRate == 18) { - pStatistic->CustomStat.ullRsr9M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr9MCRCOk++; - - pr_debug(" 9M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr9M, - (int)pStatistic->CustomStat.ullRsr9MCRCOk); - } else if (byRxRate == 24) { - pStatistic->CustomStat.ullRsr12M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr12MCRCOk++; - - pr_debug("12M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr12M, - (int)pStatistic->CustomStat.ullRsr12MCRCOk); - } else if (byRxRate == 36) { - pStatistic->CustomStat.ullRsr18M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr18MCRCOk++; - - pr_debug("18M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr18M, - (int)pStatistic->CustomStat.ullRsr18MCRCOk); - } else if (byRxRate == 48) { - pStatistic->CustomStat.ullRsr24M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr24MCRCOk++; - - pr_debug("24M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr24M, - (int)pStatistic->CustomStat.ullRsr24MCRCOk); - } else if (byRxRate == 72) { - pStatistic->CustomStat.ullRsr36M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr36MCRCOk++; - - pr_debug("36M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr36M, - (int)pStatistic->CustomStat.ullRsr36MCRCOk); - } else if (byRxRate == 96) { - pStatistic->CustomStat.ullRsr48M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr48MCRCOk++; - - pr_debug("48M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr48M, - (int)pStatistic->CustomStat.ullRsr48MCRCOk); - } else if (byRxRate == 108) { - pStatistic->CustomStat.ullRsr54M++; - if (byRSR & RSR_CRCOK) - pStatistic->CustomStat.ullRsr54MCRCOk++; - - pr_debug("54M: ALL[%d], OK[%d]\n", - (int)pStatistic->CustomStat.ullRsr54M, - (int)pStatistic->CustomStat.ullRsr54MCRCOk); - } else { - pr_debug("Unknown: Total[%d], CRCOK[%d]\n", - (int)pStatistic->dwRsrRxPacket+1, - (int)pStatistic->dwRsrCRCOk); - } - - if (byRSR & RSR_BSSIDOK) - pStatistic->dwRsrBSSIDOk++; - - if (byRSR & RSR_BCNSSIDOK) - pStatistic->dwRsrBCNSSIDOk++; - if (byRSR & RSR_IVLDLEN) //invalid len (> 2312 byte) - pStatistic->dwRsrLENErr++; - if (byRSR & RSR_IVLDTYP) //invalid packet type - pStatistic->dwRsrTYPErr++; - if (byRSR & (RSR_IVLDTYP | RSR_IVLDLEN)) - pStatistic->dwRsrErr++; - - if (byNewRSR & NEWRSR_DECRYPTOK) - pStatistic->dwNewRsrDECRYPTOK++; - if (byNewRSR & NEWRSR_CFPIND) - pStatistic->dwNewRsrCFP++; - if (byNewRSR & NEWRSR_HWUTSF) - pStatistic->dwNewRsrUTSF++; - if (byNewRSR & NEWRSR_BCNHITAID) - pStatistic->dwNewRsrHITAID++; - if (byNewRSR & NEWRSR_BCNHITAID0) - pStatistic->dwNewRsrHITAID0++; - - // increase rx packet count - pStatistic->dwRsrRxPacket++; - pStatistic->dwRsrRxOctet += cbFrameLength; - - if (IS_TYPE_DATA(pbyBuffer)) - pStatistic->dwRsrRxData++; - else if (IS_TYPE_MGMT(pbyBuffer)) - pStatistic->dwRsrRxManage++; - else if (IS_TYPE_CONTROL(pbyBuffer)) - pStatistic->dwRsrRxControl++; - - if (byRSR & RSR_ADDRBROAD) - pStatistic->dwRsrBroadcast++; - else if (byRSR & RSR_ADDRMULTI) - pStatistic->dwRsrMulticast++; - else - pStatistic->dwRsrDirected++; - - if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl)) - pStatistic->dwRsrRxFragment++; - - if (cbFrameLength < ETH_ZLEN + 4) - pStatistic->dwRsrRunt++; - else if (cbFrameLength == ETH_ZLEN + 4) - pStatistic->dwRsrRxFrmLen64++; - else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) - pStatistic->dwRsrRxFrmLen65_127++; - else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) - pStatistic->dwRsrRxFrmLen128_255++; - else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) - pStatistic->dwRsrRxFrmLen256_511++; - else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) - pStatistic->dwRsrRxFrmLen512_1023++; - else if ((1024 <= cbFrameLength) && (cbFrameLength <= ETH_FRAME_LEN + 4)) - pStatistic->dwRsrRxFrmLen1024_1518++; - else if (cbFrameLength > ETH_FRAME_LEN + 4) - pStatistic->dwRsrLong++; -} - -/* - * Description: Update Rx Statistic Counter and copy Rx buffer - * - * Parameters: - * In: - * pStatistic - Pointer to Statistic Counter Data Structure - * byRSR - Rx Status - * byNewRSR - Rx Status - * pbyBuffer - Rx Buffer - * cbFrameLength - Rx Length - * Out: - * none - * - * Return Value: none - * - */ - -void -STAvUpdateRDStatCounterEx( - PSStatCounter pStatistic, - unsigned char byRSR, - unsigned char byNewRSR, - unsigned char byRxRate, - unsigned char *pbyBuffer, - unsigned int cbFrameLength -) -{ - STAvUpdateRDStatCounter( - pStatistic, - byRSR, - byNewRSR, - byRxRate, - pbyBuffer, - cbFrameLength -); - - // rx length - pStatistic->dwCntRxFrmLength = cbFrameLength; - // rx pattern, we just see 10 bytes for sample - memcpy(pStatistic->abyCntRxPattern, (unsigned char *)pbyBuffer, 10); -} - -/* - * Description: Update Tx Statistic Counter - * - * Parameters: - * In: - * pStatistic - Pointer to Statistic Counter Data Structure - * byTSR0 - Tx Status - * byTSR1 - Tx Status - * pbyBuffer - Tx Buffer - * cbFrameLength - Tx Length - * uIdx - Index of Tx DMA - * Out: - * none - * - * Return Value: none - * - */ -void -STAvUpdateTDStatCounter( - PSStatCounter pStatistic, - unsigned char byTSR0, - unsigned char byTSR1, - unsigned char *pbyBuffer, - unsigned int cbFrameLength, - unsigned int uIdx -) -{ - PWLAN_80211HDR_A4 pHeader; - unsigned char *pbyDestAddr; - unsigned char byTSR0_NCR = byTSR0 & TSR0_NCR; - - pHeader = (PWLAN_80211HDR_A4) pbyBuffer; - if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) - pbyDestAddr = &(pHeader->abyAddr1[0]); - else - pbyDestAddr = &(pHeader->abyAddr3[0]); - - // increase tx packet count - pStatistic->dwTsrTxPacket[uIdx]++; - pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength; - - if (byTSR0_NCR != 0) { - pStatistic->dwTsrRetry[uIdx]++; - pStatistic->dwTsrTotalRetry[uIdx] += byTSR0_NCR; - - if (byTSR0_NCR == 1) - pStatistic->dwTsrOnceRetry[uIdx]++; - else - pStatistic->dwTsrMoreThanOnceRetry[uIdx]++; - } - - if ((byTSR1&(TSR1_TERR|TSR1_RETRYTMO|TSR1_TMO|ACK_DATA)) == 0) { - pStatistic->ullTsrOK[uIdx]++; - pStatistic->CustomStat.ullTsrAllOK = - (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]); - // update counters in case that successful transmit - if (is_broadcast_ether_addr(pbyDestAddr)) { - pStatistic->ullTxBroadcastFrames[uIdx]++; - pStatistic->ullTxBroadcastBytes[uIdx] += (unsigned long long) cbFrameLength; - } else if (is_multicast_ether_addr(pbyDestAddr)) { - pStatistic->ullTxMulticastFrames[uIdx]++; - pStatistic->ullTxMulticastBytes[uIdx] += (unsigned long long) cbFrameLength; - } else { - pStatistic->ullTxDirectedFrames[uIdx]++; - pStatistic->ullTxDirectedBytes[uIdx] += (unsigned long long) cbFrameLength; - } - } else { - if (byTSR1 & TSR1_TERR) - pStatistic->dwTsrErr[uIdx]++; - if (byTSR1 & TSR1_RETRYTMO) - pStatistic->dwTsrRetryTimeout[uIdx]++; - if (byTSR1 & TSR1_TMO) - pStatistic->dwTsrTransmitTimeout[uIdx]++; - if (byTSR1 & ACK_DATA) - pStatistic->dwTsrACKData[uIdx]++; - } - - if (is_broadcast_ether_addr(pbyDestAddr)) - pStatistic->dwTsrBroadcast[uIdx]++; - else if (is_multicast_ether_addr(pbyDestAddr)) - pStatistic->dwTsrMulticast[uIdx]++; - else - pStatistic->dwTsrDirected[uIdx]++; -} - -/* - * Description: Update Tx Statistic Counter and copy Tx buffer - * - * Parameters: - * In: - * pStatistic - Pointer to Statistic Counter Data Structure - * pbyBuffer - Tx Buffer - * cbFrameLength - Tx Length - * Out: - * none - * - * Return Value: none - * - */ -void -STAvUpdateTDStatCounterEx( - PSStatCounter pStatistic, - unsigned char *pbyBuffer, - unsigned long cbFrameLength -) -{ - unsigned int uPktLength; - - uPktLength = (unsigned int)cbFrameLength; - - // tx length - pStatistic->dwCntTxBufLength = uPktLength; - // tx pattern, we just see 16 bytes for sample - memcpy(pStatistic->abyCntTxPattern, pbyBuffer, 16); -} - /* * Description: Update 802.11 mib counter * @@ -526,37 +132,8 @@ STAvUpdate802_11Counter( unsigned long dwCounter ) { - p802_11Counter->MulticastTransmittedFrameCount = (unsigned long long) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] + - pStatistic->dwTsrBroadcast[TYPE_TXDMA0] + - pStatistic->dwTsrMulticast[TYPE_AC0DMA] + - pStatistic->dwTsrMulticast[TYPE_TXDMA0]); - p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]); - p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]); - p802_11Counter->MultipleRetryCount = (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] + - pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]); p802_11Counter->RTSSuccessCount += (unsigned long long) (dwCounter & 0x000000ff); p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8); p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16); p802_11Counter->FCSErrorCount += (unsigned long long) ((dwCounter & 0xff000000) >> 24); - p802_11Counter->MulticastReceivedFrameCount = (unsigned long long) (pStatistic->dwRsrBroadcast + - pStatistic->dwRsrMulticast); -} - -/* - * Description: Clear 802.11 mib counter - * - * Parameters: - * In: - * p802_11Counter - Pointer to 802.11 mib counter - * Out: - * none - * - * Return Value: none - * - */ -void -STAvClear802_11Counter(PSDot11Counters p802_11Counter) -{ - // set memory to zero - memset(p802_11Counter, 0, sizeof(SDot11Counters)); } diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 732bddaf5b91..fdb40f20d3e5 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -38,136 +38,16 @@ // typedef struct tagSDot11Counters { - unsigned long Length; - unsigned long long TransmittedFragmentCount; - unsigned long long MulticastTransmittedFrameCount; - unsigned long long FailedCount; - unsigned long long RetryCount; - unsigned long long MultipleRetryCount; unsigned long long RTSSuccessCount; unsigned long long RTSFailureCount; unsigned long long ACKFailureCount; - unsigned long long FrameDuplicateCount; - unsigned long long ReceivedFragmentCount; - unsigned long long MulticastReceivedFrameCount; unsigned long long FCSErrorCount; - unsigned long long TKIPLocalMICFailures; - unsigned long long TKIPRemoteMICFailures; - unsigned long long TKIPICVErrors; - unsigned long long TKIPCounterMeasuresInvoked; - unsigned long long TKIPReplays; - unsigned long long CCMPFormatErrors; - unsigned long long CCMPReplays; - unsigned long long CCMPDecryptErrors; - unsigned long long FourWayHandshakeFailures; } SDot11Counters, *PSDot11Counters; -// -// MIB2 counter -// -typedef struct tagSMib2Counter { - long ifIndex; - char ifDescr[256]; - long ifType; - long ifMtu; - unsigned long ifSpeed; - unsigned char ifPhysAddress[ETH_ALEN]; - long ifAdminStatus; - long ifOperStatus; - unsigned long ifLastChange; - unsigned long ifInOctets; - unsigned long ifInUcastPkts; - unsigned long ifInNUcastPkts; - unsigned long ifInDiscards; - unsigned long ifInErrors; - unsigned long ifInUnknownProtos; - unsigned long ifOutOctets; - unsigned long ifOutUcastPkts; - unsigned long ifOutNUcastPkts; - unsigned long ifOutDiscards; - unsigned long ifOutErrors; - unsigned long ifOutQLen; - unsigned long ifSpecific; -} SMib2Counter, *PSMib2Counter; - -// Value in the ifType entry -#define WIRELESSLANIEEE80211b 6 - -// Value in the ifAdminStatus/ifOperStatus entry -#define UP 1 -#define DOWN 2 -#define TESTING 3 - -// -// RMON counter -// -typedef struct tagSRmonCounter { - long etherStatsIndex; - unsigned long etherStatsDataSource; - unsigned long etherStatsDropEvents; - unsigned long etherStatsOctets; - unsigned long etherStatsPkts; - unsigned long etherStatsBroadcastPkts; - unsigned long etherStatsMulticastPkts; - unsigned long etherStatsCRCAlignErrors; - unsigned long etherStatsUndersizePkts; - unsigned long etherStatsOversizePkts; - unsigned long etherStatsFragments; - unsigned long etherStatsJabbers; - unsigned long etherStatsCollisions; - unsigned long etherStatsPkt64Octets; - unsigned long etherStatsPkt65to127Octets; - unsigned long etherStatsPkt128to255Octets; - unsigned long etherStatsPkt256to511Octets; - unsigned long etherStatsPkt512to1023Octets; - unsigned long etherStatsPkt1024to1518Octets; - unsigned long etherStatsOwners; - unsigned long etherStatsStatus; -} SRmonCounter, *PSRmonCounter; - -// -// Custom counter -// -typedef struct tagSCustomCounters { - unsigned long Length; - - unsigned long long ullTsrAllOK; - - unsigned long long ullRsr11M; - unsigned long long ullRsr5M; - unsigned long long ullRsr2M; - unsigned long long ullRsr1M; - - unsigned long long ullRsr11MCRCOk; - unsigned long long ullRsr5MCRCOk; - unsigned long long ullRsr2MCRCOk; - unsigned long long ullRsr1MCRCOk; - - unsigned long long ullRsr54M; - unsigned long long ullRsr48M; - unsigned long long ullRsr36M; - unsigned long long ullRsr24M; - unsigned long long ullRsr18M; - unsigned long long ullRsr12M; - unsigned long long ullRsr9M; - unsigned long long ullRsr6M; - - unsigned long long ullRsr54MCRCOk; - unsigned long long ullRsr48MCRCOk; - unsigned long long ullRsr36MCRCOk; - unsigned long long ullRsr24MCRCOk; - unsigned long long ullRsr18MCRCOk; - unsigned long long ullRsr12MCRCOk; - unsigned long long ullRsr9MCRCOk; - unsigned long long ullRsr6MCRCOk; -} SCustomCounters, *PSCustomCounters; - // // Custom counter // typedef struct tagSISRCounters { - unsigned long Length; - unsigned long dwIsrTx0OK; unsigned long dwIsrAC0TxOK; unsigned long dwIsrBeaconTxOK; @@ -183,161 +63,22 @@ typedef struct tagSISRCounters { unsigned long dwIsrUnknown; unsigned long dwIsrRx1OK; - unsigned long dwIsrATIMTxOK; - unsigned long dwIsrSYNCTxOK; - unsigned long dwIsrCFPEnd; - unsigned long dwIsrATIMEnd; - unsigned long dwIsrSYNCFlushOK; unsigned long dwIsrSTIMER1Int; } SISRCounters, *PSISRCounters; -// Value in the etherStatsStatus entry -#define VALID 1 -#define CREATE_REQUEST 2 -#define UNDER_CREATION 3 -#define INVALID 4 - // // statistic counter // typedef struct tagSStatCounter { - // RSR status count - // - unsigned long dwRsrFrmAlgnErr; - unsigned long dwRsrErr; - unsigned long dwRsrCRCErr; - unsigned long dwRsrCRCOk; - unsigned long dwRsrBSSIDOk; - unsigned long dwRsrADDROk; - unsigned long dwRsrBCNSSIDOk; - unsigned long dwRsrLENErr; - unsigned long dwRsrTYPErr; - - unsigned long dwNewRsrDECRYPTOK; - unsigned long dwNewRsrCFP; - unsigned long dwNewRsrUTSF; - unsigned long dwNewRsrHITAID; - unsigned long dwNewRsrHITAID0; - - unsigned long dwRsrLong; - unsigned long dwRsrRunt; - - unsigned long dwRsrRxControl; - unsigned long dwRsrRxData; - unsigned long dwRsrRxManage; - - unsigned long dwRsrRxPacket; - unsigned long dwRsrRxOctet; - unsigned long dwRsrBroadcast; - unsigned long dwRsrMulticast; - unsigned long dwRsrDirected; - // 64-bit OID - unsigned long long ullRsrOK; - - // for some optional OIDs (64 bits) and DMI support - unsigned long long ullRxBroadcastBytes; - unsigned long long ullRxMulticastBytes; - unsigned long long ullRxDirectedBytes; - unsigned long long ullRxBroadcastFrames; - unsigned long long ullRxMulticastFrames; - unsigned long long ullRxDirectedFrames; - - unsigned long dwRsrRxFragment; - unsigned long dwRsrRxFrmLen64; - unsigned long dwRsrRxFrmLen65_127; - unsigned long dwRsrRxFrmLen128_255; - unsigned long dwRsrRxFrmLen256_511; - unsigned long dwRsrRxFrmLen512_1023; - unsigned long dwRsrRxFrmLen1024_1518; - - // TSR status count - // - unsigned long dwTsrTotalRetry[TYPE_MAXTD]; // total collision retry count - unsigned long dwTsrOnceRetry[TYPE_MAXTD]; // this packet only occur one collision - unsigned long dwTsrMoreThanOnceRetry[TYPE_MAXTD]; // this packet occur more than one collision - unsigned long dwTsrRetry[TYPE_MAXTD]; // this packet has ever occur collision, - // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0) - unsigned long dwTsrACKData[TYPE_MAXTD]; - unsigned long dwTsrErr[TYPE_MAXTD]; - unsigned long dwAllTsrOK[TYPE_MAXTD]; - unsigned long dwTsrRetryTimeout[TYPE_MAXTD]; - unsigned long dwTsrTransmitTimeout[TYPE_MAXTD]; - - unsigned long dwTsrTxPacket[TYPE_MAXTD]; - unsigned long dwTsrTxOctet[TYPE_MAXTD]; - unsigned long dwTsrBroadcast[TYPE_MAXTD]; - unsigned long dwTsrMulticast[TYPE_MAXTD]; - unsigned long dwTsrDirected[TYPE_MAXTD]; - - // RD/TD count - unsigned long dwCntRxFrmLength; - unsigned long dwCntTxBufLength; - - unsigned char abyCntRxPattern[16]; - unsigned char abyCntTxPattern[16]; - - // Software check.... - unsigned long dwCntRxDataErr; // rx buffer data software compare CRC err count - unsigned long dwCntDecryptErr; // rx buffer data software compare CRC err count - unsigned long dwCntRxICVErr; // rx buffer data software compare CRC err count - unsigned int idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD - - // 64-bit OID - unsigned long long ullTsrOK[TYPE_MAXTD]; - - // for some optional OIDs (64 bits) and DMI support - unsigned long long ullTxBroadcastFrames[TYPE_MAXTD]; - unsigned long long ullTxMulticastFrames[TYPE_MAXTD]; - unsigned long long ullTxDirectedFrames[TYPE_MAXTD]; - unsigned long long ullTxBroadcastBytes[TYPE_MAXTD]; - unsigned long long ullTxMulticastBytes[TYPE_MAXTD]; - unsigned long long ullTxDirectedBytes[TYPE_MAXTD]; - SISRCounters ISRStat; - - SCustomCounters CustomStat; - -#ifdef Calcu_LinkQual - //Tx count: - unsigned long TxNoRetryOkCount; - unsigned long TxRetryOkCount; - unsigned long TxFailCount; - //Rx count: - unsigned long RxOkCnt; - unsigned long RxFcsErrCnt; - //statistic - unsigned long SignalStren; - unsigned long LinkQuality; -#endif } SStatCounter, *PSStatCounter; -void STAvClearAllCounter(PSStatCounter pStatistic); - void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr); -void STAvUpdateRDStatCounter(PSStatCounter pStatistic, - unsigned char byRSR, unsigned char byNewRSR, unsigned char byRxRate, - unsigned char *pbyBuffer, unsigned int cbFrameLength); - -void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic, - unsigned char byRSR, unsigned char byNewRsr, unsigned char byRxRate, - unsigned char *pbyBuffer, unsigned int cbFrameLength); - -void STAvUpdateTDStatCounter(PSStatCounter pStatistic, unsigned char byTSR0, unsigned char byTSR1, - unsigned char *pbyBuffer, unsigned int cbFrameLength, unsigned int uIdx); - -void STAvUpdateTDStatCounterEx( - PSStatCounter pStatistic, - unsigned char *pbyBuffer, - unsigned long cbFrameLength -); - void STAvUpdate802_11Counter( PSDot11Counters p802_11Counter, PSStatCounter pStatistic, unsigned long dwCounter ); -void STAvClear802_11Counter(PSDot11Counters p802_11Counter); - #endif // __MIB_H__ -- cgit v1.2.3-59-g8ed1b From 029c7d225aa431fa09af97e855e3d12d5aed8a6c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:43 +0000 Subject: staging: vt6655L remove tether.c functions remove ETHbyGetHashIndexByCrc32 ETHbIsBufferCrc32Ok tether.h header will be removed later Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/tether.c | 105 ---------------------------------------- drivers/staging/vt6655/tether.h | 4 -- 3 files changed, 110 deletions(-) delete mode 100644 drivers/staging/vt6655/tether.c diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index d571e6f46ade..1a5876deba8e 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -14,7 +14,6 @@ vt6655_stage-y += device_main.o \ power.o \ srom.o \ mib.o \ - tether.o \ tcrc.o \ key.o \ rf.o diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c deleted file mode 100644 index 1e7d3e2115a9..000000000000 --- a/drivers/staging/vt6655/tether.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tether.c - * - * Purpose: - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - * Functions: - * ETHbyGetHashIndexByCrc32 - Calculate multicast hash value by CRC32 - * ETHbIsBufferCrc32Ok - Check CRC value of the buffer if Ok or not - * - * Revision History: - * - */ - -#include "device.h" -#include "tmacro.h" -#include "tcrc.h" -#include "tether.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/* - * Description: Calculate multicast hash value by CRC32 - * - * Parameters: - * In: - * pbyMultiAddr - Multicast Address - * Out: - * none - * - * Return Value: Hash value - * - */ -unsigned char ETHbyGetHashIndexByCrc32(unsigned char *pbyMultiAddr) -{ - int ii; - unsigned char byTmpHash; - unsigned char byHash = 0; - - // get the least 6-bits from CRC generator - byTmpHash = (unsigned char)(CRCdwCrc32(pbyMultiAddr, ETH_ALEN, - 0xFFFFFFFFL) & 0x3F); - // reverse most bit to least bit - for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) { - byHash <<= 1; - if (byTmpHash & 0x01) - byHash |= 1; - byTmpHash >>= 1; - } - - // adjust 6-bits to the right most - return byHash >> 2; -} - -/* - * Description: Check CRC value of the buffer if Ok or not - * - * Parameters: - * In: - * pbyBuffer - pointer of buffer (normally is rx buffer) - * cbFrameLength - length of buffer, including CRC portion - * Out: - * none - * - * Return Value: true if ok; false if error. - * - */ -bool ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength) -{ - unsigned long dwCRC; - - dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); - if (cpu_to_le32(*((unsigned long *)(pbyBuffer + cbFrameLength - 4))) != dwCRC) - return false; - - return true; -} diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 94cc8830d8cc..850554c3e762 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -185,8 +185,4 @@ S802_11Header, *PS802_11Header; /*--------------------- Export Functions --------------------------*/ -unsigned char ETHbyGetHashIndexByCrc32(unsigned char *pbyMultiAddr); -//unsigned char ETHbyGetHashIndexByCrc(unsigned char *pbyMultiAddr); -bool ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength); - #endif // __TETHER_H__ -- cgit v1.2.3-59-g8ed1b From 5e6fc9d7e4f9573a3b110fff8eb3e82553e0c0b0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:44 +0000 Subject: staging: vt6655: dead code remove tcrc.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/rxtx.c | 1 - drivers/staging/vt6655/tcrc.c | 191 ----------------------------------- drivers/staging/vt6655/tcrc.h | 50 --------- 5 files changed, 244 deletions(-) delete mode 100644 drivers/staging/vt6655/tcrc.c delete mode 100644 drivers/staging/vt6655/tcrc.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 1a5876deba8e..390c23ef9f44 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -14,7 +14,6 @@ vt6655_stage-y += device_main.o \ power.o \ srom.o \ mib.o \ - tcrc.o \ key.o \ rf.o diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 18dad0cb69a0..2c2f42fe10af 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -64,7 +64,6 @@ #include "power.h" #include "wcmd.h" #include "iocmd.h" -#include "tcrc.h" #include "rxtx.h" #include "bssdb.h" #include "dpc.h" diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 4770b9cf622b..b8ff8c60a84a 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -55,7 +55,6 @@ #include "bssdb.h" #include "mac.h" #include "baseband.h" -#include "tcrc.h" #include "wctl.h" #include "rf.h" diff --git a/drivers/staging/vt6655/tcrc.c b/drivers/staging/vt6655/tcrc.c deleted file mode 100644 index ddc5efd040f9..000000000000 --- a/drivers/staging/vt6655/tcrc.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tcrc.c - * - * Purpose: Implement functions to calculate CRC - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - * Functions: - * CRCdwCrc32 - - * CRCdwGetCrc32 - - * CRCdwGetCrc32Ex - - * - * Revision History: - * - */ - -#include "tcrc.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/* 32-bit CRC table */ -static const unsigned long s_adwCrc32Table[256] = { - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL -}; - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*+ - * - * Description: - * Generate a CRC-32 from the data stream - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * dwCrcSeed - Seed for CRC32 - * Out: - * none - * - * Return Value: CRC-32 - * - -*/ -unsigned long CRCdwCrc32(unsigned char *pbyData, unsigned int cbByte, unsigned long dwCrcSeed) -{ - unsigned long dwCrc; - - dwCrc = dwCrcSeed; - while (cbByte--) { - dwCrc = s_adwCrc32Table[(unsigned char)((dwCrc ^ (*pbyData)) & 0xFF)] ^ (dwCrc >> 8); - pbyData++; - } - - return dwCrc; -} - -/*+ - * - * Description: - * To test CRC generator, input 8 bytes packet - * -- 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00 - * the generated CRC should be - * -- 0xff 0xff 0xff 0xff - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * Out: - * none - * - * Return Value: CRC-32 - * - -*/ -unsigned long CRCdwGetCrc32(unsigned char *pbyData, unsigned int cbByte) -{ - return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL); -} - -/*+ - * - * Description: - * - * NOTE.... Because CRCdwGetCrc32Ex() is an iteration function, - * this means we will use the output of CRCdwGetCrc32Ex() - * to be a new argument to do next CRCdwGetCrc32Ex() calculation. - * Thus, the final result must be inverted to be the - * correct answer. - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * Out: - * none - * - * Return Value: CRC-32 - * - -*/ -unsigned long CRCdwGetCrc32Ex(unsigned char *pbyData, unsigned int cbByte, unsigned long dwPreCRC) -{ - return CRCdwCrc32(pbyData, cbByte, dwPreCRC); -} diff --git a/drivers/staging/vt6655/tcrc.h b/drivers/staging/vt6655/tcrc.h deleted file mode 100644 index 82b5ddafae55..000000000000 --- a/drivers/staging/vt6655/tcrc.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tcrc.h - * - * Purpose: Implement functions to calculate CRC - * - * Author: Tevin Chen - * - * Date: Jan. 28, 1997 - * - */ - -#ifndef __TCRC_H__ -#define __TCRC_H__ - -#include "ttype.h" - -/*--------------------- Export Definitions -------------------------*/ - -/*--------------------- Export Types ------------------------------*/ - -/*--------------------- Export Macros ------------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -unsigned long CRCdwCrc32(unsigned char *pbyData, unsigned int cbByte, unsigned long dwCrcSeed); -unsigned long CRCdwGetCrc32(unsigned char *pbyData, unsigned int cbByte); -unsigned long CRCdwGetCrc32Ex(unsigned char *pbyData, unsigned int cbByte, unsigned long dwPreCRC); - -#endif // __TCRC_H__ -- cgit v1.2.3-59-g8ed1b From 7910356c7f7645a638ee3ba4b425ecc8c825760e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:45 +0000 Subject: staging: vt6655: dead code remove 80211mgr.c and functions 80211mgr.h header will be removed later Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211mgr.c | 1006 ------------------------------------- drivers/staging/vt6655/80211mgr.h | 110 ---- drivers/staging/vt6655/Makefile | 1 - 3 files changed, 1117 deletions(-) delete mode 100644 drivers/staging/vt6655/80211mgr.c diff --git a/drivers/staging/vt6655/80211mgr.c b/drivers/staging/vt6655/80211mgr.c deleted file mode 100644 index 22ded38e6a2e..000000000000 --- a/drivers/staging/vt6655/80211mgr.c +++ /dev/null @@ -1,1006 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: 80211mgr.c - * - * Purpose: Handles the 802.11 management support functions - * - * Author: Lyndon Chen - * - * Date: May 8, 2002 - * - * Functions: - * vMgrEncodeBeacon - Encode the Beacon frame - * vMgrDecodeBeacon - Decode the Beacon frame - * vMgrEncodeIBSSATIM - Encode the IBSS ATIM frame - * vMgrDecodeIBSSATIM - Decode the IBSS ATIM frame - * vMgrEncodeDisassociation - Encode the Disassociation frame - * vMgrDecodeDisassociation - Decode the Disassociation frame - * vMgrEncodeAssocRequest - Encode the Association request frame - * vMgrDecodeAssocRequest - Decode the Association request frame - * vMgrEncodeAssocResponse - Encode the Association response frame - * vMgrDecodeAssocResponse - Decode the Association response frame - * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame - * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame - * vMgrEncodeProbeRequest - Encode the Probe request frame - * vMgrDecodeProbeRequest - Decode the Probe request frame - * vMgrEncodeProbeResponse - Encode the Probe response frame - * vMgrDecodeProbeResponse - Decode the Probe response frame - * vMgrEncodeAuthen - Encode the Authentication frame - * vMgrDecodeAuthen - Decode the Authentication frame - * vMgrEncodeDeauthen - Encode the DeAuthentication frame - * vMgrDecodeDeauthen - Decode the DeAuthentication frame - * vMgrEncodeReassocResponse - Encode the Reassociation response frame - * vMgrDecodeReassocResponse - Decode the Reassociation response frame - * - * Revision History: - * - */ - -#include "tmacro.h" -#include "tether.h" -#include "80211mgr.h" -#include "80211hdr.h" -#include "device.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -/*+ - * - * Routine Description: - * Encode Beacon frame body offset - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeBeacon( - PWLAN_FR_BEACON pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pqwTimestamp = (__le64 *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_BEACON_OFF_TS); - pFrame->pwBeaconInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_BEACON_OFF_BCN_INT); - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_BEACON_OFF_CAPINFO); - - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID; -} - -/*+ - * - * Routine Description: - * Decode Beacon frame body offset - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeBeacon( - PWLAN_FR_BEACON pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pqwTimestamp = (__le64 *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_BEACON_OFF_TS); - pFrame->pwBeaconInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_BEACON_OFF_BCN_INT); - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_BEACON_OFF_CAPINFO); - - /* Information elements */ - pItem = (PWLAN_IE)((unsigned char *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) + - WLAN_BEACON_OFF_SSID); - while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; - case WLAN_EID_FH_PARMS: - /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */ - break; - case WLAN_EID_DS_PARMS: - if (pFrame->pDSParms == NULL) - pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; - break; - case WLAN_EID_CF_PARMS: - if (pFrame->pCFParms == NULL) - pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; - break; - case WLAN_EID_IBSS_PARMS: - if (pFrame->pIBSSParms == NULL) - pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; - break; - case WLAN_EID_TIM: - if (pFrame->pTIM == NULL) - pFrame->pTIM = (PWLAN_IE_TIM)pItem; - break; - - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - } - break; - - case WLAN_EID_ERP: - if (pFrame->pERP == NULL) - pFrame->pERP = (PWLAN_IE_ERP)pItem; - break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - case WLAN_EID_COUNTRY: /* 7 */ - if (pFrame->pIE_Country == NULL) - pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; - break; - - case WLAN_EID_PWR_CONSTRAINT: /* 32 */ - if (pFrame->pIE_PowerConstraint == NULL) - pFrame->pIE_PowerConstraint = - (PWLAN_IE_PW_CONST)pItem; - break; - - case WLAN_EID_CH_SWITCH: /* 37 */ - if (pFrame->pIE_CHSW == NULL) - pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; - break; - - case WLAN_EID_QUIET: /* 40 */ - if (pFrame->pIE_Quiet == NULL) - pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; - break; - - case WLAN_EID_IBSS_DFS: - if (pFrame->pIE_IBSSDFS == NULL) - pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; - break; - - default: - pr_debug("Unrecognized EID=%dd in beacon decode\n", - pItem->byElementID); - break; - - } - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - } -} - -/*+ - * - * Routine Description: - * Encode IBSS ATIM - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeIBSSATIM( - PWLAN_FR_IBSSATIM pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - pFrame->len = WLAN_HDR_ADDR3_LEN; -} - -/*+ - * - * Routine Description: - * Decode IBSS ATIM - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeIBSSATIM( - PWLAN_FR_IBSSATIM pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; -} - -/*+ - * - * Routine Description: - * Encode Disassociation - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeDisassociation( - PWLAN_FR_DISASSOC pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwReason = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_DISASSOC_OFF_REASON); - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + - sizeof(*(pFrame->pwReason)); -} - -/*+ - * - * Routine Description: - * Decode Disassociation - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeDisassociation( - PWLAN_FR_DISASSOC pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwReason = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_DISASSOC_OFF_REASON); -} - -/*+ - * - * Routine Description: - * Encode Association Request - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeAssocRequest( - PWLAN_FR_ASSOCREQ pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCREQ_OFF_LISTEN_INT); - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + - sizeof(*(pFrame->pwListenInterval)); -} - -/*+ - * - * Routine Description: (AP) - * Decode Association Request - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeAssocRequest( - PWLAN_FR_ASSOCREQ pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCREQ_OFF_LISTEN_INT); - - /* Information elements */ - pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_ASSOCREQ_OFF_SSID); - - while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - } - break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - default: - pr_debug("Unrecognized EID=%dd in assocreq decode\n", - pItem->byElementID); - break; - } - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - } -} - -/*+ - * - * Routine Description: (AP) - * Encode Association Response - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeAssocResponse( - PWLAN_FR_ASSOCRESP pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_STATUS); - pFrame->pwAid = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_AID); - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID + - sizeof(*(pFrame->pwAid)); -} - -/*+ - * - * Routine Description: - * Decode Association Response - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeAssocResponse( - PWLAN_FR_ASSOCRESP pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_STATUS); - pFrame->pwAid = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_AID); - - /* Information elements */ - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_ASSOCRESP_OFF_SUPP_RATES); - - pItem = (PWLAN_IE)(pFrame->pSuppRates); - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - - if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && - (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - pr_debug("pFrame->pExtSuppRates=[%p]\n", pItem); - } else { - pFrame->pExtSuppRates = NULL; - } -} - -/*+ - * - * Routine Description: - * Encode Reassociation Request - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeReassocRequest( - PWLAN_FR_REASSOCREQ pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCREQ_OFF_LISTEN_INT); - pFrame->pAddrCurrAP = (PIEEE_ADDR) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCREQ_OFF_CURR_AP); - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + - sizeof(*(pFrame->pAddrCurrAP)); -} - -/*+ - * - * Routine Description: (AP) - * Decode Reassociation Request - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeReassocRequest( - PWLAN_FR_REASSOCREQ pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCREQ_OFF_LISTEN_INT); - pFrame->pAddrCurrAP = (PIEEE_ADDR) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCREQ_OFF_CURR_AP); - - /* Information elements */ - pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_REASSOCREQ_OFF_SSID); - - while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - } - break; - - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - default: - pr_debug("Unrecognized EID=%dd in reassocreq decode\n", - pItem->byElementID); - break; - } - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - } -} - -/*+ - * - * Routine Description: - * Encode Probe Request - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeProbeRequest( - PWLAN_FR_PROBEREQ pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - pFrame->len = WLAN_HDR_ADDR3_LEN; -} - -/*+ - * - * Routine Description: - * Decode Probe Request - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeProbeRequest( - PWLAN_FR_PROBEREQ pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Information elements */ - pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))); - - while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - default: - pr_debug("Bad EID=%dd in probereq\n", - pItem->byElementID); - break; - } - - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - } -} - -/*+ - * - * Routine Description: - * Encode Probe Response - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeProbeResponse( - PWLAN_FR_PROBERESP pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pqwTimestamp = (__le64 *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_PROBERESP_OFF_TS); - pFrame->pwBeaconInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_PROBERESP_OFF_BCN_INT); - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_PROBERESP_OFF_CAP_INFO); - - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO + - sizeof(*(pFrame->pwCapInfo)); -} - -/*+ - * - * Routine Description: - * Decode Probe Response - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeProbeResponse( - PWLAN_FR_PROBERESP pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pqwTimestamp = (__le64 *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_PROBERESP_OFF_TS); - pFrame->pwBeaconInterval = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_PROBERESP_OFF_BCN_INT); - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_PROBERESP_OFF_CAP_INFO); - - /* Information elements */ - pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_PROBERESP_OFF_SSID); - - while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - case WLAN_EID_FH_PARMS: - break; - case WLAN_EID_DS_PARMS: - if (pFrame->pDSParms == NULL) - pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; - break; - case WLAN_EID_CF_PARMS: - if (pFrame->pCFParms == NULL) - pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; - break; - case WLAN_EID_IBSS_PARMS: - if (pFrame->pIBSSParms == NULL) - pFrame->pIBSSParms = - (PWLAN_IE_IBSS_PARMS)pItem; - break; - - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - } - break; - case WLAN_EID_ERP: - if (pFrame->pERP == NULL) - pFrame->pERP = (PWLAN_IE_ERP)pItem; - break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = - (PWLAN_IE_SUPP_RATES)pItem; - break; - - case WLAN_EID_COUNTRY: /* 7 */ - if (pFrame->pIE_Country == NULL) - pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; - break; - - case WLAN_EID_PWR_CONSTRAINT: /* 32 */ - if (pFrame->pIE_PowerConstraint == NULL) - pFrame->pIE_PowerConstraint = - (PWLAN_IE_PW_CONST)pItem; - break; - - case WLAN_EID_CH_SWITCH: /* 37 */ - if (pFrame->pIE_CHSW == NULL) - pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; - break; - - case WLAN_EID_QUIET: /* 40 */ - if (pFrame->pIE_Quiet == NULL) - pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; - break; - - case WLAN_EID_IBSS_DFS: - if (pFrame->pIE_IBSSDFS == NULL) - pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; - break; - - default: - pr_debug("Bad EID=%dd in proberesp\n", - pItem->byElementID); - break; - } - - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - } -} - -/*+ - * - * Routine Description: - * Encode Authentication frame - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeAuthen( - PWLAN_FR_AUTHEN pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwAuthAlgorithm = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_AUTHEN_OFF_AUTH_ALG); - pFrame->pwAuthSequence = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_AUTHEN_OFF_AUTH_SEQ); - pFrame->pwStatus = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_AUTHEN_OFF_STATUS); - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + - sizeof(*(pFrame->pwStatus)); -} - -/*+ - * - * Routine Description: - * Decode Authentication - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeAuthen( - PWLAN_FR_AUTHEN pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwAuthAlgorithm = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_AUTHEN_OFF_AUTH_ALG); - pFrame->pwAuthSequence = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_AUTHEN_OFF_AUTH_SEQ); - pFrame->pwStatus = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_AUTHEN_OFF_STATUS); - - /* Information elements */ - pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) - + WLAN_AUTHEN_OFF_CHALLENGE); - - if (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) && - pItem->byElementID == WLAN_EID_CHALLENGE) - pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem; -} - -/*+ - * - * Routine Description: - * Encode Authentication - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeDeauthen( - PWLAN_FR_DEAUTHEN pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwReason = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_DEAUTHEN_OFF_REASON); - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + - sizeof(*(pFrame->pwReason)); -} - -/*+ - * - * Routine Description: - * Decode Deauthentication - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeDeauthen( - PWLAN_FR_DEAUTHEN pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwReason = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_DEAUTHEN_OFF_REASON); -} - -/*+ - * - * Routine Description: (AP) - * Encode Reassociation Response - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrEncodeReassocResponse( - PWLAN_FR_REASSOCRESP pFrame -) -{ - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_STATUS); - pFrame->pwAid = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_AID); - - pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + - sizeof(*(pFrame->pwAid)); -} - -/*+ - * - * Routine Description: - * Decode Reassociation Response - * - * - * Return Value: - * None. - * - -*/ - -void -vMgrDecodeReassocResponse( - PWLAN_FR_REASSOCRESP pFrame -) -{ - PWLAN_IE pItem; - - pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - - /* Fixed Fields */ - pFrame->pwCapInfo = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_STATUS); - pFrame->pwAid = (unsigned short *) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_AID); - - /* Information elements */ - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES) - (WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + - WLAN_REASSOCRESP_OFF_SUPP_RATES); - - pItem = (PWLAN_IE)(pFrame->pSuppRates); - pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - - if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && - (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - } -} diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h index d462a8af087b..94cff3b87cb1 100644 --- a/drivers/staging/vt6655/80211mgr.h +++ b/drivers/staging/vt6655/80211mgr.h @@ -612,114 +612,4 @@ typedef struct tagWLAN_FR_DEAUTHEN { unsigned short *pwReason; } WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN; -void -vMgrEncodeBeacon( - PWLAN_FR_BEACON pFrame -); - -void -vMgrDecodeBeacon( - PWLAN_FR_BEACON pFrame -); - -void -vMgrEncodeIBSSATIM( - PWLAN_FR_IBSSATIM pFrame -); - -void -vMgrDecodeIBSSATIM( - PWLAN_FR_IBSSATIM pFrame -); - -void -vMgrEncodeDisassociation( - PWLAN_FR_DISASSOC pFrame -); - -void -vMgrDecodeDisassociation( - PWLAN_FR_DISASSOC pFrame -); - -void -vMgrEncodeAssocRequest( - PWLAN_FR_ASSOCREQ pFrame -); - -void -vMgrDecodeAssocRequest( - PWLAN_FR_ASSOCREQ pFrame -); - -void -vMgrEncodeAssocResponse( - PWLAN_FR_ASSOCRESP pFrame -); - -void -vMgrDecodeAssocResponse( - PWLAN_FR_ASSOCRESP pFrame -); - -void -vMgrEncodeReassocRequest( - PWLAN_FR_REASSOCREQ pFrame -); - -void -vMgrDecodeReassocRequest( - PWLAN_FR_REASSOCREQ pFrame -); - -void -vMgrEncodeProbeRequest( - PWLAN_FR_PROBEREQ pFrame -); - -void -vMgrDecodeProbeRequest( - PWLAN_FR_PROBEREQ pFrame -); - -void -vMgrEncodeProbeResponse( - PWLAN_FR_PROBERESP pFrame -); - -void -vMgrDecodeProbeResponse( - PWLAN_FR_PROBERESP pFrame -); - -void -vMgrEncodeAuthen( - PWLAN_FR_AUTHEN pFrame -); - -void -vMgrDecodeAuthen( - PWLAN_FR_AUTHEN pFrame -); - -void -vMgrEncodeDeauthen( - PWLAN_FR_DEAUTHEN pFrame -); - -void -vMgrDecodeDeauthen( - PWLAN_FR_DEAUTHEN pFrame -); - -void -vMgrEncodeReassocResponse( - PWLAN_FR_REASSOCRESP pFrame -); - -void -vMgrDecodeReassocResponse( - PWLAN_FR_REASSOCRESP pFrame -); - #endif/* __80211MGR_H__ */ diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 390c23ef9f44..5f3c0192d0c2 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -8,7 +8,6 @@ vt6655_stage-y += device_main.o \ mac.o \ baseband.o \ wctl.o \ - 80211mgr.o \ rxtx.o \ dpc.o \ power.o \ -- cgit v1.2.3-59-g8ed1b From b4ba0cb10f5db831f0e7b9bb090411d53e1a9579 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:46 +0000 Subject: staging: vt6655: dead code remove wctl.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Makefile | 1 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/rxtx.c | 1 - drivers/staging/vt6655/wctl.c | 233 ----------------------------------- drivers/staging/vt6655/wctl.h | 105 ---------------- 5 files changed, 341 deletions(-) delete mode 100644 drivers/staging/vt6655/wctl.c delete mode 100644 drivers/staging/vt6655/wctl.h diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile index 5f3c0192d0c2..115b951bf0d9 100644 --- a/drivers/staging/vt6655/Makefile +++ b/drivers/staging/vt6655/Makefile @@ -7,7 +7,6 @@ vt6655_stage-y += device_main.o \ channel.o \ mac.o \ baseband.o \ - wctl.o \ rxtx.o \ dpc.o \ power.o \ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 2c2f42fe10af..1111d1eda359 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -60,7 +60,6 @@ #include "mac.h" #include "tether.h" #include "wmgr.h" -#include "wctl.h" #include "power.h" #include "wcmd.h" #include "iocmd.h" diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index b8ff8c60a84a..00ae6de05628 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -55,7 +55,6 @@ #include "bssdb.h" #include "mac.h" #include "baseband.h" -#include "wctl.h" #include "rf.h" /*--------------------- Static Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c deleted file mode 100644 index 5a54d98d985a..000000000000 --- a/drivers/staging/vt6655/wctl.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wctl.c - * - * Purpose: handle WMAC duplicate filter & defragment - * - * Author: Jerry Chen - * - * Date: Jun. 27, 2002 - * - * Functions: - * WCTLbIsDuplicate - Test if duplicate packet - * WCTLuSearchDFCB - Search DeFragment Control Database - * WCTLuInsertDFCB - Insert DeFragment Control Database - * WCTLbHandleFragment - Handle received fragment packet - * - * Revision History: - * - */ - -#include "wctl.h" -#include "device.h" -#include "card.h" - -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/* - * Description: - * Scan Rx cache. Return true if packet is duplicate, else - * inserts in receive cache and returns false. - * - * Parameters: - * In: - * pCache - Receive packets history - * pMACHeader - 802.11 MAC Header of received packet - * Out: - * none - * - * Return Value: true if packet duplicate; otherwise false - * - */ - -bool WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader) -{ - unsigned int uIndex; - unsigned int ii; - PSCacheEntry pCacheEntry; - - if (IS_FC_RETRY(pMACHeader)) { - uIndex = pCache->uInPtr; - for (ii = 0; ii < DUPLICATE_RX_CACHE_LENGTH; ii++) { - pCacheEntry = &(pCache->asCacheEntry[uIndex]); - if ((pCacheEntry->wFmSequence == pMACHeader->wSeqCtl) && - ether_addr_equal(pCacheEntry->abyAddr2, - pMACHeader->abyAddr2)) { - /* Duplicate match */ - return true; - } - ADD_ONE_WITH_WRAP_AROUND(uIndex, DUPLICATE_RX_CACHE_LENGTH); - } - } - /* Not fount in cache - insert */ - pCacheEntry = &pCache->asCacheEntry[pCache->uInPtr]; - pCacheEntry->wFmSequence = pMACHeader->wSeqCtl; - memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), ETH_ALEN); - ADD_ONE_WITH_WRAP_AROUND(pCache->uInPtr, DUPLICATE_RX_CACHE_LENGTH); - return false; -} - -/* - * Description: - * Found if sequence number of received fragment packet in Defragment Database - * - * Parameters: - * In: - * pDevice - Pointer to adapter - * pMACHeader - 802.11 MAC Header of received packet - * Out: - * none - * - * Return Value: index number in Defragment Database - * - */ -unsigned int WCTLuSearchDFCB(struct vnt_private *pDevice, - PS802_11Header pMACHeader) -{ - unsigned int ii; - - for (ii = 0; ii < pDevice->cbDFCB; ii++) { - if (pDevice->sRxDFCB[ii].bInUse && - ether_addr_equal(pDevice->sRxDFCB[ii].abyAddr2, - pMACHeader->abyAddr2)) { - return ii; - } - } - return pDevice->cbDFCB; -} - -/* - * Description: - * Insert received fragment packet in Defragment Database - * - * Parameters: - * In: - * pDevice - Pointer to adapter - * pMACHeader - 802.11 MAC Header of received packet - * Out: - * none - * - * Return Value: index number in Defragment Database - * - */ -unsigned int WCTLuInsertDFCB(struct vnt_private *pDevice, PS802_11Header pMACHeader) -{ - unsigned int ii; - - if (pDevice->cbFreeDFCB == 0) - return pDevice->cbDFCB; - for (ii = 0; ii < pDevice->cbDFCB; ii++) { - if (!pDevice->sRxDFCB[ii].bInUse) { - pDevice->cbFreeDFCB--; - pDevice->sRxDFCB[ii].uLifetime = pDevice->dwMaxReceiveLifetime; - pDevice->sRxDFCB[ii].bInUse = true; - pDevice->sRxDFCB[ii].wSequence = (pMACHeader->wSeqCtl >> 4); - pDevice->sRxDFCB[ii].wFragNum = (pMACHeader->wSeqCtl & 0x000F); - memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]), ETH_ALEN); - return ii; - } - } - return pDevice->cbDFCB; -} - -/* - * Description: - * Handle received fragment packet - * - * Parameters: - * In: - * pDevice - Pointer to adapter - * pMACHeader - 802.11 MAC Header of received packet - * cbFrameLength - Frame length - * bWEP - is WEP packet - * Out: - * none - * - * Return Value: true if it is valid fragment packet and we have resource to defragment; otherwise false - * - */ -bool WCTLbHandleFragment(struct vnt_private *pDevice, PS802_11Header pMACHeader, - unsigned int cbFrameLength, bool bWEP, bool bExtIV) -{ - unsigned int uHeaderSize; - - if (bWEP) { - uHeaderSize = 28; - if (bExtIV) - // ExtIV - uHeaderSize += 4; - } else { - uHeaderSize = 24; - } - - if (IS_FIRST_FRAGMENT_PKT(pMACHeader)) { - pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader); - if (pDevice->uCurrentDFCBIdx < pDevice->cbDFCB) { - // duplicate, we must flush previous DCB - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].uLifetime = pDevice->dwMaxReceiveLifetime; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence = (pMACHeader->wSeqCtl >> 4); - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum = (pMACHeader->wSeqCtl & 0x000F); - } else { - pDevice->uCurrentDFCBIdx = WCTLuInsertDFCB(pDevice, pMACHeader); - if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB) - return false; - } - // reserve 4 byte to match MAC RX Buffer - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (unsigned char *)(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4); - memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, pMACHeader, cbFrameLength); - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength = cbFrameLength; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++; - return false; - } else { - pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader); - if (pDevice->uCurrentDFCBIdx != pDevice->cbDFCB) { - if ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wSequence == (pMACHeader->wSeqCtl >> 4)) && - (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum == (pMACHeader->wSeqCtl & 0x000F)) && - ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength + cbFrameLength - uHeaderSize) < 2346)) { - memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, ((unsigned char *)(pMACHeader) + uHeaderSize), (cbFrameLength - uHeaderSize)); - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength += (cbFrameLength - uHeaderSize); - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += (cbFrameLength - uHeaderSize); - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++; - } else { - // seq error or frag # error flush DFCB - pDevice->cbFreeDFCB++; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false; - return false; - } - } else { - return false; - } - if (IS_LAST_FRAGMENT_PKT(pMACHeader)) { - //enq defragcontrolblock - pDevice->cbFreeDFCB++; - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false; - return true; - } - return false; - } -} diff --git a/drivers/staging/vt6655/wctl.h b/drivers/staging/vt6655/wctl.h deleted file mode 100644 index f0995d86f71f..000000000000 --- a/drivers/staging/vt6655/wctl.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wctl.h - * - * Purpose: - * - * Author: Jerry Chen - * - * Date: Jun. 27, 2002 - * - */ - -#ifndef __WCTL_H__ -#define __WCTL_H__ - -#include "ttype.h" -#include "tether.h" -#include "device.h" - -/*--------------------- Export Definitions -------------------------*/ - -#define IS_TYPE_DATA(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_DATA) - -#define IS_TYPE_MGMT(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_MGMT) - -#define IS_TYPE_CONTROL(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_CTL) - -#define IS_FC_MOREDATA(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREDATA) == FC_MOREDATA) - -#define IS_FC_POWERMGT(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_POWERMGT) == FC_POWERMGT) - -#define IS_FC_RETRY(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_RETRY) == FC_RETRY) - -#define IS_FC_WEP(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_WEP) == FC_WEP) - -#ifdef __BIG_ENDIAN - -#define IS_FRAGMENT_PKT(pMACHeader) \ - (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \ - ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) != 0)) - -#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) == 0) - -#else - -#define IS_FRAGMENT_PKT(pMACHeader) \ - (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \ - ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) != 0)) - -#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) == 0) - -#endif//#ifdef __BIG_ENDIAN - -#define IS_LAST_FRAGMENT_PKT(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) == 0) - -#define IS_CTL_PSPOLL(pMACHeader) \ - ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) - -#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) \ -do { \ - if ((uVar) >= ((uModulo) - 1)) \ - (uVar) = 0; \ - else \ - (uVar)++; \ -} while (0) - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -bool WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader); -bool WCTLbHandleFragment(struct vnt_private *, PS802_11Header pMACHeader, - unsigned int cbFrameLength, bool bWEP, bool bExtIV); -unsigned int WCTLuSearchDFCB(struct vnt_private *, PS802_11Header pMACHeader); -unsigned int WCTLuInsertDFCB(struct vnt_private *, PS802_11Header pMACHeader); - -#endif // __WCTL_H__ -- cgit v1.2.3-59-g8ed1b From d40c444668657b3467283ec6888276788ed88155 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:47 +0000 Subject: staging: vt6655: channel.c remove dead functions Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 113 --------------------------------------- drivers/staging/vt6655/channel.h | 13 ----- 2 files changed, 126 deletions(-) diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index a7b39d4c18c5..41146eb113ef 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -166,66 +166,6 @@ void vnt_init_bands(struct vnt_private *priv) } } -/** - * is_channel_valid() - Is Country Channel Valid - * @ChanneIndex: defined as VT3253 MAC channel: - * 1 = 2.4G channel 1 - * 2 = 2.4G channel 2 - * ... - * 14 = 2.4G channel 14 - * 15 = 4.9G channel 183 - * 16 = 4.9G channel 184 - * ..... - * Output: true if the specified 5GHz band is allowed to be used, - * false otherwise. - * 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22) - * - * 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64, - * 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56) - */ - -bool is_channel_valid(unsigned int ChannelIndex) -{ - bool bValid; - - bValid = false; - /* If Channel Index is invalid, return invalid */ - if ((ChannelIndex > CB_MAX_CHANNEL) || - (ChannelIndex == 0)) { - bValid = false; - goto exit; - } -exit: - return bValid; -} - -/** - * channel_get_list() - Get Available Channel List for a given country - * @CountryCode: The country code defined in country.h - * - * Output: - * pbyChannelTable: (QWORD *) correspondent bit mask - * of available channels - * 0x0000000000000001 means channel 1 is supported - * 0x0000000000000003 means channel 1,2 are supported - * 0x000000000000000F means channel 1,2,..15 are supported - */ - -bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable) -{ - return true; -} - -unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType) -{ - return 0; -} - -unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex) -{ - return 0; -} - /** * set_channel() - Set NIC media channel * @@ -277,56 +217,3 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) return bResult; } - -/** - * set_country_info() - Set Channel Info of Country - * - * Return Value: none. - * - */ - -void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE) -{ -} - -/** - * - * set_support_channels() - Set Support Channels IE defined in 802.11h - * - * @hDeviceContext: device structure point - * - * Return Value: none. - * - */ - -unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) -{ - unsigned char byLen = 0; - return byLen; -} - -void set_country_IE(void *pDeviceHandler, void *pIE) -{ -} - -bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, - unsigned char *pbyChannelNumber, unsigned char *pbyMap) -{ - return 0; -} - -void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, - unsigned char byMap) -{ -} - -void clear_channel_map_info(void *pDeviceHandler) -{ - -} - -unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType) -{ - unsigned char byOptionChannel = 0; - return byOptionChannel; -} diff --git a/drivers/staging/vt6655/channel.h b/drivers/staging/vt6655/channel.h index 78ab642738ed..ee00f4e3d52f 100644 --- a/drivers/staging/vt6655/channel.h +++ b/drivers/staging/vt6655/channel.h @@ -28,19 +28,6 @@ void vnt_init_bands(struct vnt_private *); -bool is_channel_valid(unsigned int CountryCode); -unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelNumber, CARD_PHY_TYPE ePhyType); -bool channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable); -unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex); bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel); -void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE); -unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs); -void set_country_IE(void *pDeviceHandler, void *pIE); -bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, - unsigned char *pbyChannelNumber, unsigned char *pbyMap); -void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex, - unsigned char byMap); -void clear_channel_map_info(void *pDeviceHandler); -unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType); #endif /* _CHANNEL_H_ */ -- cgit v1.2.3-59-g8ed1b From b0437f281ddc82b7ba421de304ec531dc5daea0c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:48 +0000 Subject: staging: vt6655: move all RATE_* macros to device.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 15 +++++++++++++++ drivers/staging/vt6655/vntwifi.h | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index a5e5a00743c6..b96d8328b466 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -80,6 +80,21 @@ /*--------------------- Export Definitions -------------------------*/ +#define RATE_1M 0 +#define RATE_2M 1 +#define RATE_5M 2 +#define RATE_11M 3 +#define RATE_6M 4 +#define RATE_9M 5 +#define RATE_12M 6 +#define RATE_18M 7 +#define RATE_24M 8 +#define RATE_36M 9 +#define RATE_48M 10 +#define RATE_54M 11 +#define RATE_AUTO 12 +#define MAX_RATE 12 + #define MAC_MAX_CONTEXT_REG (256+128) #define MAX_MULTICAST_ADDRESS_NUM 32 diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index ad180e077e3f..2ba7713d04a7 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -35,20 +35,6 @@ #include "card.h" /*--------------------- Export Definitions -------------------------*/ -#define RATE_1M 0 -#define RATE_2M 1 -#define RATE_5M 2 -#define RATE_11M 3 -#define RATE_6M 4 -#define RATE_9M 5 -#define RATE_12M 6 -#define RATE_18M 7 -#define RATE_24M 8 -#define RATE_36M 9 -#define RATE_48M 10 -#define RATE_54M 11 -#define RATE_AUTO 12 -#define MAX_RATE 12 // key CipherSuite #define KEY_CTL_WEP 0x00 -- cgit v1.2.3-59-g8ed1b From 8ec94797eb3aba4346fbc1c1f3181e8b6f9f21f9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:49 +0000 Subject: staging: vt6655: dead code remove vntwifi.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 1 - drivers/staging/vt6655/device_main.c | 2 - drivers/staging/vt6655/vntwifi.h | 90 ------------------------------------ drivers/staging/vt6655/wmgr.h | 5 -- 4 files changed, 98 deletions(-) delete mode 100644 drivers/staging/vt6655/vntwifi.h diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index b96d8328b466..5e48608a8744 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -507,7 +507,6 @@ struct vnt_private { bool bEnablePSMode; unsigned short wListenInterval; bool bPWBitOn; - WMAC_POWER_MODE ePSMode; /* GPIO Radio Control */ unsigned char byRadioCtl; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 1111d1eda359..d8fd44c88206 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -344,7 +344,6 @@ device_set_options(struct vnt_private *pDevice) pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME; pDevice->byShortPreamble = (pDevice->sOpts.flags & DEVICE_FLAGS_PREAMBLE_TYPE) ? 1 : 0; pDevice->byOpMode = (pDevice->sOpts.flags & DEVICE_FLAGS_OP_MODE) ? 1 : 0; - pDevice->ePSMode = (pDevice->sOpts.flags & DEVICE_FLAGS_PS_MODE) ? 1 : 0; pDevice->b11hEnable = (pDevice->sOpts.flags & DEVICE_FLAGS_80211h_MODE) ? 1 : 0; pDevice->bDiversityRegCtlON = (pDevice->sOpts.flags & DEVICE_FLAGS_DiversityANT) ? 1 : 0; pDevice->uConnectionRate = pDevice->sOpts.data_rate; @@ -359,7 +358,6 @@ device_set_options(struct vnt_private *pDevice) pr_debug(" uChannel= %d\n", (int)pDevice->uChannel); pr_debug(" byOpMode= %d\n", (int)pDevice->byOpMode); - pr_debug(" ePSMode= %d\n", (int)pDevice->ePSMode); pr_debug(" wRTSThreshold= %d\n", (int)pDevice->wRTSThreshold); pr_debug(" byShortRetryLimit= %d\n", (int)pDevice->byShortRetryLimit); pr_debug(" byLongRetryLimit= %d\n", (int)pDevice->byLongRetryLimit); diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h deleted file mode 100644 index 2ba7713d04a7..000000000000 --- a/drivers/staging/vt6655/vntwifi.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: vntwifi.h - * - * Purpose: export VNT Host WiFi library function - * - * Author: Yiching Chen - * - * Date: Jan 7, 2004 - * - */ - -#ifndef __VNTWIFI_H__ -#define __VNTWIFI_H__ - -#include "ttype.h" -#include "80211mgr.h" -#include "card.h" - -/*--------------------- Export Definitions -------------------------*/ - -// key CipherSuite -#define KEY_CTL_WEP 0x00 -#define KEY_CTL_NONE 0x01 -#define KEY_CTL_TKIP 0x02 -#define KEY_CTL_CCMP 0x03 -#define KEY_CTL_INVALID 0xFF - -#define CHANNEL_MAX_24G 14 - -#define MAX_BSS_NUM 42 - -// Pre-configured Authenticaiton Mode (from XP) -typedef enum tagWMAC_AUTHENTICATION_MODE { - WMAC_AUTH_OPEN, - WMAC_AUTH_SHAREKEY, - WMAC_AUTH_AUTO, - WMAC_AUTH_WPA, - WMAC_AUTH_WPAPSK, - WMAC_AUTH_WPANONE, - WMAC_AUTH_WPA2, - WMAC_AUTH_WPA2PSK, - WMAC_AUTH_MAX // Not a real mode, defined as upper bound -} WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE; - -typedef enum tagWMAC_ENCRYPTION_MODE { - WMAC_ENCRYPTION_WEPEnabled, - WMAC_ENCRYPTION_WEPDisabled, - WMAC_ENCRYPTION_WEPKeyAbsent, - WMAC_ENCRYPTION_WEPNotSupported, - WMAC_ENCRYPTION_TKIPEnabled, - WMAC_ENCRYPTION_TKIPKeyAbsent, - WMAC_ENCRYPTION_AESEnabled, - WMAC_ENCRYPTION_AESKeyAbsent -} WMAC_ENCRYPTION_MODE, *PWMAC_ENCRYPTION_MODE; - -// Pre-configured Mode (from XP) - -typedef enum tagWMAC_CONFIG_MODE { - WMAC_CONFIG_ESS_STA = 0, - WMAC_CONFIG_IBSS_STA, - WMAC_CONFIG_AUTO, - WMAC_CONFIG_AP -} WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE; - -typedef enum tagWMAC_POWER_MODE { - WMAC_POWER_CAM, - WMAC_POWER_FAST, - WMAC_POWER_MAX -} WMAC_POWER_MODE, *PWMAC_POWER_MODE; - - -#endif //__VNTWIFI_H__ diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 7df62bb6eafd..ecbb8d4b3154 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -39,7 +39,6 @@ #include "80211hdr.h" #include "wcmd.h" #include "bssdb.h" -#include "vntwifi.h" #include "card.h" /*--------------------- Export Definitions -------------------------*/ @@ -189,7 +188,6 @@ typedef struct tagSMgmtObject { unsigned char abyMACAddr[WLAN_ADDR_LEN]; // Configuration Mode - WMAC_CONFIG_MODE eConfigMode; // MAC pre-configed mode CARD_PHY_TYPE eCurrentPHYMode; CARD_PHY_TYPE eConfigPHYMode; @@ -245,8 +243,6 @@ typedef struct tagSMgmtObject { unsigned char abyScanBSSID[WLAN_BSSID_LEN]; // Privacy - WMAC_AUTHENTICATION_MODE eAuthenMode; - WMAC_ENCRYPTION_MODE eEncryptionMode; bool bShareKeyAlgorithm; unsigned char abyChallenge[WLAN_CHALLENGE_LEN]; bool bPrivacyInvoked; @@ -258,7 +254,6 @@ typedef struct tagSMgmtObject { unsigned char byDTIMPeriod; // Power saving state vars - WMAC_POWER_MODE ePSMode; unsigned short wListenInterval; unsigned short wCountToWakeUp; bool bInTIMWake; -- cgit v1.2.3-59-g8ed1b From ab2eb50af8ce07b2f81ccd30bd08ae67c5b614b0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:50 +0000 Subject: staging: vt6655: wmgr.h remove management structures Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 5 -- drivers/staging/vt6655/wmgr.h | 194 ---------------------------------------- 2 files changed, 199 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 5e48608a8744..d2779a30a23b 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -426,11 +426,6 @@ struct vnt_private { /* 802.11 counter */ SDot11Counters s802_11Counter; - /* 802.11 management */ - PSMgmtObject pMgmt; - SMgmtObject sMgmtObj; - - /* 802.11 MAC specific */ unsigned int uCurrRSSI; unsigned char byCurrSQ; diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index ecbb8d4b3154..1deedd8fbe77 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -112,199 +112,5 @@ typedef struct tagSAssocInfo { unsigned long RequestIELength; unsigned char abyReqIEs[WLAN_BEACON_FR_MAXLEN]; } SAssocInfo, *PSAssocInfo; -//--- - -typedef enum tagWMAC_SCAN_TYPE { - WMAC_SCAN_ACTIVE, - WMAC_SCAN_PASSIVE, - WMAC_SCAN_HYBRID -} WMAC_SCAN_TYPE, *PWMAC_SCAN_TYPE; - -typedef enum tagWMAC_SCAN_STATE { - WMAC_NO_SCANNING, - WMAC_IS_SCANNING, - WMAC_IS_PROBEPENDING -} WMAC_SCAN_STATE, *PWMAC_SCAN_STATE; - -// Notes: -// Basic Service Set state explained as following: -// WMAC_STATE_IDLE : no BSS is selected (Adhoc or Infra) -// WMAC_STATE_STARTED : no BSS is selected, start own IBSS (Adhoc only) -// WMAC_STATE_JOINTED : BSS is selected and synchronized (Adhoc or Infra) -// WMAC_STATE_AUTHPENDING : Authentication pending (Infra) -// WMAC_STATE_AUTH : Authenticated (Infra) -// WMAC_STATE_ASSOCPENDING : Association pending (Infra) -// WMAC_STATE_ASSOC : Associated (Infra) - -typedef enum tagWMAC_BSS_STATE { - WMAC_STATE_IDLE, - WMAC_STATE_STARTED, - WMAC_STATE_JOINTED, - WMAC_STATE_AUTHPENDING, - WMAC_STATE_AUTH, - WMAC_STATE_ASSOCPENDING, - WMAC_STATE_ASSOC -} WMAC_BSS_STATE, *PWMAC_BSS_STATE; - -// WMAC selected running mode -typedef enum tagWMAC_CURRENT_MODE { - WMAC_MODE_STANDBY, - WMAC_MODE_ESS_STA, - WMAC_MODE_IBSS_STA, - WMAC_MODE_ESS_AP -} WMAC_CURRENT_MODE, *PWMAC_CURRENT_MODE; - -/* - typedef enum tagWMAC_POWER_MODE { - WMAC_POWER_CAM, - WMAC_POWER_FAST, - WMAC_POWER_MAX - - } WMAC_POWER_MODE, *PWMAC_POWER_MODE; -*/ - -// Tx Management Packet descriptor -typedef struct tagSTxMgmtPacket { - PUWLAN_80211HDR p80211Header; - unsigned int cbMPDULen; - unsigned int cbPayloadLen; -} STxMgmtPacket, *PSTxMgmtPacket; - -// Rx Management Packet descriptor -typedef struct tagSRxMgmtPacket { - PUWLAN_80211HDR p80211Header; - u64 qwLocalTSF; - unsigned int cbMPDULen; - unsigned int cbPayloadLen; - unsigned int uRSSI; - unsigned char bySQ; - unsigned char byRxRate; - unsigned char byRxChannel; -} SRxMgmtPacket, *PSRxMgmtPacket; - -typedef struct tagSMgmtObject { - void *pAdapter; - // MAC address - unsigned char abyMACAddr[WLAN_ADDR_LEN]; - - // Configuration Mode - CARD_PHY_TYPE eCurrentPHYMode; - CARD_PHY_TYPE eConfigPHYMode; - - // Operation state variables - WMAC_CURRENT_MODE eCurrMode; // MAC current connection mode - WMAC_BSS_STATE eCurrState; // MAC current BSS state - - PKnownBSS pCurrBSS; - unsigned char byCSSGK; - unsigned char byCSSPK; - - // Current state vars - unsigned int uCurrChannel; - unsigned char abyCurrBSSID[WLAN_BSSID_LEN]; - unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned char abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - unsigned short wCurrCapInfo; - unsigned short wCurrAID; - unsigned short wCurrATIMWindow; - unsigned short wCurrBeaconPeriod; - bool bIsDS; - unsigned char byERPContext; - - CMD_STATE eCommandState; - unsigned int uScanChannel; - - // Desire joining BSS vars - unsigned char abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - unsigned char abyDesireBSSID[WLAN_BSSID_LEN]; - - // Adhoc or AP configuration vars - unsigned short wIBSSBeaconPeriod; - unsigned short wIBSSATIMWindow; - unsigned int uIBSSChannel; - unsigned char abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned char byAPBBType; - unsigned char abyWPAIE[MAX_WPA_IE_LEN]; - unsigned short wWPAIELen; - - unsigned int uAssocCount; - bool bMoreData; - - // Scan state vars - WMAC_SCAN_STATE eScanState; - WMAC_SCAN_TYPE eScanType; - unsigned int uScanStartCh; - unsigned int uScanEndCh; - unsigned short wScanSteps; - unsigned int uScanBSSType; - // Desire scanning vars - unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - unsigned char abyScanBSSID[WLAN_BSSID_LEN]; - - // Privacy - bool bShareKeyAlgorithm; - unsigned char abyChallenge[WLAN_CHALLENGE_LEN]; - bool bPrivacyInvoked; - - // Received beacon state vars - bool bInTIM; - bool bMulticastTIM; - unsigned char byDTIMCount; - unsigned char byDTIMPeriod; - - // Power saving state vars - unsigned short wListenInterval; - unsigned short wCountToWakeUp; - bool bInTIMWake; - unsigned char *pbyPSPacketPool; - unsigned char byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN]; - bool bRxBeaconInTBTTWake; - unsigned char abyPSTxMap[MAX_NODE_NUM + 1]; - - // management command related - unsigned int uCmdBusy; - unsigned int uCmdHostAPBusy; - - // management packet pool - unsigned char *pbyMgmtPacketPool; - unsigned char byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; - - // One second callback timer - struct timer_list sTimerSecondCallback; - - // Temporarily Rx Mgmt Packet Descriptor - SRxMgmtPacket sRxPacket; - - // link list of known bss's (scan results) - KnownBSS sBSSList[MAX_BSS_NUM]; - - // table list of known node - // sNodeDBList[0] is reserved for AP under Infra mode - // sNodeDBList[0] is reserved for Multicast under adhoc/AP mode - KnownNodeDB sNodeDBTable[MAX_NODE_NUM + 1]; - - // WPA2 PMKID Cache - bool bRoaming; - - // rate fall back vars - - // associate info - SAssocInfo sAssocInfo; - - // for 802.11h - bool b11hEnable; - bool bSwitchChannel; - unsigned char byNewChannel; - PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep; - unsigned int uLengthOfRepEIDs; - unsigned char abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; - unsigned char abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; - unsigned char abyIECountry[WLAN_A3FR_MAXLEN]; - unsigned char abyIBSSDFSOwner[6]; - unsigned char byIBSSDFSRecovery; - - struct sk_buff skb; -} SMgmtObject, *PSMgmtObject; #endif // __WMGR_H__ -- cgit v1.2.3-59-g8ed1b From 38ad4a00eb716da05859288e5ee1cee629ea02b2 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:51 +0000 Subject: staging: vt6655: dead code remove ndis and pmkid strutures. struct pmkid_candidate typedef struct _BSSID_INFO typedef struct tagSPMKID typedef struct tagSPMKIDCandidateEvent NDIS_802_11_MAC_ADDRESS typedef struct _NDIS_802_11_AI_REQFI typedef struct _NDIS_802_11_AI_RESFI typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION typedef struct tagSAssocInfo Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 26 -------------------------- drivers/staging/vt6655/wmgr.h | 35 ----------------------------------- 2 files changed, 61 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index d2779a30a23b..0725d783d322 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -216,29 +216,6 @@ typedef enum _NDIS_802_11_STATUS_TYPE { Ndis802_11StatusTypeMax /* defined as an upper bound */ } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE; -/* Added new types for PMKID Candidate lists. */ -struct pmkid_candidate { - NDIS_802_11_MAC_ADDRESS BSSID; - unsigned long Flags; -}; - -typedef struct _BSSID_INFO { - NDIS_802_11_MAC_ADDRESS BSSID; - NDIS_802_11_PMKID_VALUE PMKID; -} BSSID_INFO, *PBSSID_INFO; - -typedef struct tagSPMKID { - unsigned long Length; - unsigned long BSSIDInfoCount; - BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID]; -} SPMKID, *PSPMKID; - -typedef struct tagSPMKIDCandidateEvent { - NDIS_802_11_STATUS_TYPE StatusType; - unsigned long Version; /* Version of the structure */ - unsigned long NumCandidates; /* No. of pmkid candidates */ - struct pmkid_candidate CandidateList[MAX_PMKIDLIST]; -} SPMKIDCandidateEvent, *PSPMKIDCandidateEvent; /* 802.11h related */ #define MAX_QUIET_COUNT 8 @@ -667,9 +644,6 @@ struct vnt_private { unsigned char abySNAP_RFC1042[ETH_ALEN]; unsigned char abySNAP_Bridgetunnel[ETH_ALEN]; unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */ - /* Pre-Authentication & PMK cache */ - SPMKID gsPMKID; - SPMKIDCandidateEvent gsPMKIDCandidate; /* for 802.11h */ bool b11hEnable; diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 1deedd8fbe77..cc8662e52718 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -78,39 +78,4 @@ #define timer_expire(timer, next_tick) mod_timer(&timer, RUN_AT(next_tick)) typedef void (*TimerFunction)(unsigned long); -//+++ NDIS related - -typedef unsigned char NDIS_802_11_MAC_ADDRESS[6]; -typedef struct _NDIS_802_11_AI_REQFI { - unsigned short Capabilities; - unsigned short ListenInterval; - NDIS_802_11_MAC_ADDRESS CurrentAPAddress; -} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI; - -typedef struct _NDIS_802_11_AI_RESFI { - unsigned short Capabilities; - unsigned short StatusCode; - unsigned short AssociationId; -} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI; - -typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION { - unsigned long Length; - unsigned short AvailableRequestFixedIEs; - NDIS_802_11_AI_REQFI RequestFixedIEs; - unsigned long RequestIELength; - unsigned long OffsetRequestIEs; - unsigned short AvailableResponseFixedIEs; - NDIS_802_11_AI_RESFI ResponseFixedIEs; - unsigned long ResponseIELength; - unsigned long OffsetResponseIEs; -} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION; - -typedef struct tagSAssocInfo { - NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo; - unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN]; - // store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION - unsigned long RequestIELength; - unsigned char abyReqIEs[WLAN_BEACON_FR_MAXLEN]; -} SAssocInfo, *PSAssocInfo; - #endif // __WMGR_H__ -- cgit v1.2.3-59-g8ed1b From 37cc22b1c4a542181db7b827136bcf63118d1346 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:52 +0000 Subject: staging: vt6655: dead remove wcmd.h and typedefs CMD_STATE CMD_CODE CMD_ITEM Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 5 -- drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/power.c | 1 - drivers/staging/vt6655/rxtx.h | 1 - drivers/staging/vt6655/wcmd.h | 91 ------------------------------------ drivers/staging/vt6655/wmgr.h | 1 - 6 files changed, 100 deletions(-) delete mode 100644 drivers/staging/vt6655/wcmd.h diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 0725d783d322..f73239fdc665 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -71,7 +71,6 @@ #include "80211hdr.h" #include "tether.h" #include "wmgr.h" -#include "wcmd.h" #include "mib.h" #include "srom.h" #include "desc.h" @@ -498,9 +497,6 @@ struct vnt_private { unsigned char byCurrentCh; unsigned int uScanTime; - CMD_STATE eCommandState; - - CMD_CODE eCommand; bool bBeaconTx; bool bStopBeacon; @@ -510,7 +506,6 @@ struct vnt_private { /* 802.11 counter */ - CMD_ITEM eCmdQueue[CMD_Q_SIZE]; unsigned int uCmdDequeueIdx; unsigned int uCmdEnqueueIdx; unsigned int cbFreeCmdQueue; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index d8fd44c88206..80bbe1dda05b 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -61,7 +61,6 @@ #include "tether.h" #include "wmgr.h" #include "power.h" -#include "wcmd.h" #include "iocmd.h" #include "rxtx.h" #include "bssdb.h" diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 040484e204e3..6f83650db5a3 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -42,7 +42,6 @@ #include "device.h" #include "wmgr.h" #include "power.h" -#include "wcmd.h" #include "card.h" /*--------------------- Static Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index 7b0566ce42a7..50d77a0f88ea 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -31,7 +31,6 @@ #include "ttype.h" #include "device.h" -#include "wcmd.h" /*--------------------- Export Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h deleted file mode 100644 index ae7ddeaeb014..000000000000 --- a/drivers/staging/vt6655/wcmd.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: wcmd.h - * - * Purpose: Handles the management command interface functions - * - * Author: Lyndon Chen - * - * Date: May 8, 2002 - * - */ - -#ifndef __WCMD_H__ -#define __WCMD_H__ - -#include "ttype.h" -#include "80211hdr.h" -#include "80211mgr.h" - -#define AUTHENTICATE_TIMEOUT 1000 -#define ASSOCIATE_TIMEOUT 1000 - -typedef enum tagCMD_CODE { - WLAN_CMD_BSSID_SCAN, - WLAN_CMD_SSID, - WLAN_CMD_DISASSOCIATE, - WLAN_CMD_DEAUTH, - WLAN_CMD_RX_PSPOLL, - WLAN_CMD_RADIO, - WLAN_CMD_CHANGE_BBSENSITIVITY, - WLAN_CMD_SETPOWER, - WLAN_CMD_TBTT_WAKEUP, - WLAN_CMD_BECON_SEND, - WLAN_CMD_CHANGE_ANTENNA, - WLAN_CMD_REMOVE_ALLKEY, - WLAN_CMD_MAC_DISPOWERSAVING, - WLAN_CMD_11H_CHSW, - WLAN_CMD_RUN_AP -} CMD_CODE, *PCMD_CODE; - -#define CMD_Q_SIZE 32 - -typedef enum tagCMD_STATUS { - CMD_STATUS_SUCCESS = 0, - CMD_STATUS_FAILURE, - CMD_STATUS_RESOURCES, - CMD_STATUS_TIMEOUT, - CMD_STATUS_PENDING -} CMD_STATUS, *PCMD_STATUS; - -typedef struct tagCMD_ITEM { - CMD_CODE eCmd; - unsigned char abyCmdDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - bool bNeedRadioOFF; - unsigned short wDeAuthenReason; - bool bRadioCmd; - bool bForceSCAN; -} CMD_ITEM, *PCMD_ITEM; - -typedef enum tagCMD_STATE { - WLAN_CMD_SCAN_START, - WLAN_CMD_SCAN_END, - WLAN_CMD_DISASSOCIATE_START, - WLAN_CMD_SSID_START, - WLAN_AUTHENTICATE_WAIT, - WLAN_ASSOCIATE_WAIT, - WLAN_DISASSOCIATE_WAIT, - WLAN_CMD_TX_PSPACKET_START, - WLAN_CMD_AP_MODE_START, - WLAN_CMD_RADIO_START, - WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE, - WLAN_CMD_IDLE -} CMD_STATE, *PCMD_STATE; - -#endif //__WCMD_H__ diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index cc8662e52718..0e6a6f039aa1 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -37,7 +37,6 @@ #include "ttype.h" #include "80211mgr.h" #include "80211hdr.h" -#include "wcmd.h" #include "bssdb.h" #include "card.h" -- cgit v1.2.3-59-g8ed1b From d853ce22915ce8ac33695cea2f02ea38a9d38bc7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:53 +0000 Subject: staging: vt6655: dead code remove bssdb.h header Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/bssdb.h | 210 ----------------------------------- drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/rxtx.c | 1 - drivers/staging/vt6655/wmgr.h | 1 - 4 files changed, 213 deletions(-) delete mode 100644 drivers/staging/vt6655/bssdb.h diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h deleted file mode 100644 index 511b7f907953..000000000000 --- a/drivers/staging/vt6655/bssdb.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: bssdb.h - * - * Purpose: Handles the Basic Service Set & Node Database functions - * - * Author: Lyndon Chen - * - * Date: July 16, 2002 - * - */ - -#ifndef __BSSDB_H__ -#define __BSSDB_H__ - -#include -#include "80211hdr.h" -#include "80211mgr.h" -#include "card.h" - -#define MAX_NODE_NUM 64 -#define MAX_BSS_NUM 42 -#define LOST_BEACON_COUNT 10 /* 10 sec, XP defined */ -#define MAX_PS_TX_BUF 32 /* sta max power saving tx buf */ -#define ADHOC_LOST_BEACON_COUNT 30 /* 30 sec, beacon lost for adhoc only */ -#define MAX_INACTIVE_COUNT 300 /* 300 sec, inactive STA node refresh */ - -#define USE_PROTECT_PERIOD 10 /*10 sec, Use protect mode check period*/ -#define ERP_RECOVER_COUNT 30 /* 30 sec, ERP support callback check */ -#define BSS_CLEAR_COUNT 1 - -#define RSSI_STAT_COUNT 10 -#define MAX_CHECK_RSSI_COUNT 8 - -/* STA dwflags */ -#define WLAN_STA_AUTH BIT0 -#define WLAN_STA_ASSOC BIT1 -#define WLAN_STA_PS BIT2 -#define WLAN_STA_TIM BIT3 -/* permanent; do not remove entry on expiration */ -#define WLAN_STA_PERM BIT4 -/* - * If 802.1X is used, this flag is controlling whether STA is authorized - * to send and receive non-IEEE 802.1X frames - */ -#define WLAN_STA_AUTHORIZED BIT5 - -#define MAX_RATE 12 - -#define MAX_WPA_IE_LEN 64 - -/* IEEE 802.11 Structures and definitions */ - -typedef enum _NDIS_802_11_NETWORK_TYPE { - Ndis802_11FH, - Ndis802_11DS, - Ndis802_11OFDM5, - Ndis802_11OFDM24, - Ndis802_11NetworkTypeMax /* defined as an upper bound */ -} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE; - -typedef struct tagSERPObject { - bool bERPExist; - unsigned char byERP; -} ERPObject, *PERPObject; - -typedef struct tagSRSNCapObject { - bool bRSNCapExist; - unsigned short wRSNCap; -} SRSNCapObject, *PSRSNCapObject; - -/* BSS info(AP) */ -#pragma pack(1) -typedef struct tagKnownBSS { - bool bActive; - unsigned char abyBSSID[WLAN_BSSID_LEN]; - unsigned int uChannel; - unsigned char abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned char abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - unsigned int uRSSI; - unsigned char bySQ; - unsigned short wBeaconInterval; - unsigned short wCapInfo; - unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - unsigned char byRxRate; - - unsigned char byRSSIStatCnt; - long ldBmMAX; - long ldBmAverage[RSSI_STAT_COUNT]; - long ldBmAverRange; - bool bSelected; - - bool bWPAValid; - unsigned char byGKType; - unsigned char abyPKType[4]; - unsigned short wPKCount; - unsigned char abyAuthType[4]; - unsigned short wAuthCount; - unsigned char byDefaultK_as_PK; - unsigned char byReplayIdx; - - bool bWPA2Valid; - unsigned char byCSSGK; - unsigned short wCSSPKCount; - unsigned char abyCSSPK[4]; - unsigned short wAKMSSAuthCount; - unsigned char abyAKMSSAuthType[4]; - - unsigned char byWPAIE[MAX_WPA_IE_LEN]; - unsigned char byRSNIE[MAX_WPA_IE_LEN]; - unsigned short wWPALen; - unsigned short wRSNLen; - - unsigned int uClearCount; - unsigned int uIELength; - u64 qwBSSTimestamp; - u64 qwLocalTSF; - - CARD_PHY_TYPE eNetworkTypeInUse; - - ERPObject sERP; - SRSNCapObject sRSNCapObj; - unsigned char abyIEs[1024]; -} __attribute__ ((__packed__)) -KnownBSS , *PKnownBSS; - -#pragma pack() - -typedef enum tagNODE_STATE { - NODE_FREE, - NODE_AGED, - NODE_KNOWN, - NODE_AUTH, - NODE_ASSOC -} NODE_STATE, *PNODE_STATE; - -/* STA node info */ -typedef struct tagKnownNodeDB { - bool bActive; - unsigned char abyMACAddr[WLAN_ADDR_LEN]; - unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; - unsigned char abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; - unsigned short wTxDataRate; - bool bShortPreamble; - bool bERPExist; - bool bShortSlotTime; - unsigned int uInActiveCount; - unsigned short wMaxBasicRate; /* Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp. */ - unsigned short wMaxSuppRate; /* Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon. */ - unsigned short wSuppRate; - unsigned char byTopOFDMBasicRate; /* Records the highest basic rate in OFDM mode */ - unsigned char byTopCCKBasicRate; /* Records the highest basic rate in CCK mode */ - - /* For AP mode */ - struct sk_buff_head sTxPSQueue; - unsigned short wCapInfo; - unsigned short wListenInterval; - unsigned short wAID; - NODE_STATE eNodeState; - bool bPSEnable; - bool bRxPSPoll; - unsigned char byAuthSequence; - unsigned long ulLastRxJiffer; - unsigned char bySuppRate; - unsigned long dwFlags; - unsigned short wEnQueueCnt; - - bool bOnFly; - unsigned long long KeyRSC; - unsigned char byKeyIndex; - unsigned long dwKeyIndex; - unsigned char byCipherSuite; - unsigned long dwTSC47_16; - unsigned short wTSC15_0; - unsigned int uWepKeyLength; - unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN]; - /* Auto rate fallback vars */ - bool bIsInFallback; - unsigned int uAverageRSSI; - unsigned int uRateRecoveryTimeout; - unsigned int uRatePollTimeout; - unsigned int uTxFailures; - unsigned int uTxAttempts; - - unsigned int uTxRetry; - unsigned int uFailureRatio; - unsigned int uRetryRatio; - unsigned int uTxOk[MAX_RATE+1]; - unsigned int uTxFail[MAX_RATE+1]; - unsigned int uTimeCount; -} KnownNodeDB, *PKnownNodeDB; - -#endif /*__BSSDB_H__ */ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 80bbe1dda05b..dfaec046ef51 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -63,7 +63,6 @@ #include "power.h" #include "iocmd.h" #include "rxtx.h" -#include "bssdb.h" #include "dpc.h" #include "rf.h" #include "iowpa.h" diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 00ae6de05628..246a250cbb95 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -52,7 +52,6 @@ #include "rxtx.h" #include "tether.h" #include "card.h" -#include "bssdb.h" #include "mac.h" #include "baseband.h" #include "rf.h" diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 0e6a6f039aa1..9e983f6da41d 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -37,7 +37,6 @@ #include "ttype.h" #include "80211mgr.h" #include "80211hdr.h" -#include "bssdb.h" #include "card.h" /*--------------------- Export Definitions -------------------------*/ -- cgit v1.2.3-59-g8ed1b From d54435d3fb278e90f65f6033adbee89b23113229 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:54 +0000 Subject: staging: vt6655: dead code remove tether.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 1 - drivers/staging/vt6655/baseband.h | 1 - drivers/staging/vt6655/desc.h | 1 - drivers/staging/vt6655/device.h | 3 - drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/key.h | 1 - drivers/staging/vt6655/mac.c | 1 - drivers/staging/vt6655/mib.h | 1 - drivers/staging/vt6655/rxtx.c | 1 - drivers/staging/vt6655/srom.c | 1 - drivers/staging/vt6655/tether.h | 188 ----------------------------------- 11 files changed, 200 deletions(-) delete mode 100644 drivers/staging/vt6655/tether.h diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index c7ad927084d7..ed7850558c96 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -50,7 +50,6 @@ */ #include "tmacro.h" -#include "tether.h" #include "mac.h" #include "baseband.h" #include "srom.h" diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 31f2255519cf..2d7a3e236fd6 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -31,7 +31,6 @@ #define __BASEBAND_H__ #include "ttype.h" -#include "tether.h" #include "device.h" /* diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index b59405bca606..32dd1cab7dcf 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -35,7 +35,6 @@ #include #include "linux/ieee80211.h" #include "ttype.h" -#include "tether.h" #define B_OWNED_BY_CHIP 1 #define B_OWNED_BY_HOST 0 diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index f73239fdc665..4d9d60bc756a 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -69,7 +69,6 @@ #include "device_cfg.h" #include "ttype.h" #include "80211hdr.h" -#include "tether.h" #include "wmgr.h" #include "mib.h" #include "srom.h" @@ -633,8 +632,6 @@ struct vnt_private { unsigned long uNumSQ3[MAX_RATE]; unsigned short wAntDiversityMaxRate; - SEthernetHeader sTxEthHeader; - SEthernetHeader sRxEthHeader; unsigned char abyBroadcastAddr[ETH_ALEN]; unsigned char abySNAP_RFC1042[ETH_ALEN]; unsigned char abySNAP_Bridgetunnel[ETH_ALEN]; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index dfaec046ef51..2327369ba790 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -58,7 +58,6 @@ #include "channel.h" #include "baseband.h" #include "mac.h" -#include "tether.h" #include "wmgr.h" #include "power.h" #include "iocmd.h" diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 56d1b05aad79..53b46062765d 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -33,7 +33,6 @@ #include #include "ttype.h" -#include "tether.h" #include "80211mgr.h" /*--------------------- Export Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index a347f3963934..955dbfebe170 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -69,7 +69,6 @@ */ #include "tmacro.h" -#include "tether.h" #include "mac.h" unsigned short TxRate_iwconfig;//2008-5-8 by chester diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index fdb40f20d3e5..a2e6106b4570 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -30,7 +30,6 @@ #define __MIB_H__ #include "ttype.h" -#include "tether.h" #include "desc.h" // diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 246a250cbb95..f4da7e76f658 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -50,7 +50,6 @@ #include "device.h" #include "rxtx.h" -#include "tether.h" #include "card.h" #include "mac.h" #include "baseband.h" diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index 5396e5832c22..1ac60fb4490f 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -44,7 +44,6 @@ #include "upc.h" #include "tmacro.h" -#include "tether.h" #include "mac.h" #include "srom.h" diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h deleted file mode 100644 index 850554c3e762..000000000000 --- a/drivers/staging/vt6655/tether.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: tether.h - * - * Purpose: - * - * Author: Tevin Chen - * - * Date: Jan. 28, 1997 - * - */ - -#ifndef __TETHER_H__ -#define __TETHER_H__ - -#include -#include "ttype.h" - -/*--------------------- Export Definitions -------------------------*/ -// -// constants -// -#define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1) -// Ethernet address string length - -#define MAX_LOOKAHEAD_SIZE ETH_FRAME_LEN - -#define U_MULTI_ADDR_LEN 8 // multicast address length - -#ifdef __BIG_ENDIAN - -#define TYPE_PKT_IP 0x0800 // -#define TYPE_PKT_ARP 0x0806 // -#define TYPE_PKT_RARP 0x8035 // -#define TYPE_PKT_IPX 0x8137 // -#define TYPE_PKT_802_1x 0x888e -#define TYPE_PKT_PreAuth 0x88C7 - -#define TYPE_PKT_PING_M_REQ 0x8011 // master reguest -#define TYPE_PKT_PING_S_GNT 0x8022 // slave grant -#define TYPE_PKT_PING_M 0x8077 // pingpong master packet -#define TYPE_PKT_PING_S 0x8088 // pingpong slave packet -#define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request -#define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant -#define TYPE_MGMT_PROBE_RSP 0x5000 -#define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt -#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt -// -// wFrameCtl field in the S802_11Header -// -// NOTE.... -// in network byte order, high byte is going first -#define FC_TODS 0x0001 -#define FC_FROMDS 0x0002 -#define FC_MOREFRAG 0x0004 -#define FC_RETRY 0x0008 -#define FC_POWERMGT 0x0010 -#define FC_MOREDATA 0x0020 -#define FC_WEP 0x0040 -#define TYPE_802_11_ATIM 0x9000 - -#define TYPE_802_11_DATA 0x0800 -#define TYPE_802_11_CTL 0x0400 -#define TYPE_802_11_MGMT 0x0000 -#define TYPE_802_11_MASK 0x0C00 -#define TYPE_SUBTYPE_MASK 0xFC00 -#define TYPE_802_11_NODATA 0x4000 -#define TYPE_DATE_NULL 0x4800 - -#define TYPE_CTL_PSPOLL 0xa400 -#define TYPE_CTL_RTS 0xb400 -#define TYPE_CTL_CTS 0xc400 -#define TYPE_CTL_ACK 0xd400 - -#else //if LITTLE_ENDIAN -// -// wType field in the SEthernetHeader -// -// NOTE.... -// in network byte order, high byte is going first -#define TYPE_PKT_IP 0x0008 // -#define TYPE_PKT_ARP 0x0608 // -#define TYPE_PKT_RARP 0x3580 // -#define TYPE_PKT_IPX 0x3781 // - -#define TYPE_PKT_802_1x 0x8e88 -#define TYPE_PKT_PreAuth 0xC788 - -#define TYPE_PKT_PING_M_REQ 0x1180 // master reguest -#define TYPE_PKT_PING_S_GNT 0x2280 // slave grant -#define TYPE_PKT_PING_M 0x7780 // pingpong master packet -#define TYPE_PKT_PING_S 0x8880 // pingpong slave packet -#define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request -#define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant -#define TYPE_MGMT_PROBE_RSP 0x0050 -#define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt -#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt -// -// wFrameCtl field in the S802_11Header -// -// NOTE.... -// in network byte order, high byte is going first -#define FC_TODS 0x0100 -#define FC_FROMDS 0x0200 -#define FC_MOREFRAG 0x0400 -#define FC_RETRY 0x0800 -#define FC_POWERMGT 0x1000 -#define FC_MOREDATA 0x2000 -#define FC_WEP 0x4000 -#define TYPE_802_11_ATIM 0x0090 - -#define TYPE_802_11_DATA 0x0008 -#define TYPE_802_11_CTL 0x0004 -#define TYPE_802_11_MGMT 0x0000 -#define TYPE_802_11_MASK 0x000C -#define TYPE_SUBTYPE_MASK 0x00FC -#define TYPE_802_11_NODATA 0x0040 -#define TYPE_DATE_NULL 0x0048 - -#define TYPE_CTL_PSPOLL 0x00a4 -#define TYPE_CTL_RTS 0x00b4 -#define TYPE_CTL_CTS 0x00c4 -#define TYPE_CTL_ACK 0x00d4 - -#endif //#ifdef __BIG_ENDIAN - -#define WEP_IV_MASK 0x00FFFFFF - -/*--------------------- Export Types ------------------------------*/ -// -// Ethernet packet -// -typedef struct tagSEthernetHeader { - unsigned char abyDstAddr[ETH_ALEN]; - unsigned char abySrcAddr[ETH_ALEN]; - unsigned short wType; -} __attribute__ ((__packed__)) -SEthernetHeader, *PSEthernetHeader; - -// -// 802_3 packet -// -typedef struct tagS802_3Header { - unsigned char abyDstAddr[ETH_ALEN]; - unsigned char abySrcAddr[ETH_ALEN]; - unsigned short wLen; -} __attribute__ ((__packed__)) -S802_3Header, *PS802_3Header; - -// -// 802_11 packet -// -typedef struct tagS802_11Header { - unsigned short wFrameCtl; - unsigned short wDurationID; - unsigned char abyAddr1[ETH_ALEN]; - unsigned char abyAddr2[ETH_ALEN]; - unsigned char abyAddr3[ETH_ALEN]; - unsigned short wSeqCtl; - unsigned char abyAddr4[ETH_ALEN]; -} __attribute__ ((__packed__)) -S802_11Header, *PS802_11Header; - -/*--------------------- Export Macros ------------------------------*/ - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - -#endif // __TETHER_H__ -- cgit v1.2.3-59-g8ed1b From 8224e771ca32895bc244f5f61f978d20ecbb8af6 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:55 +0000 Subject: staging: vt6655: dead code remove 80211mgr.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211mgr.h | 615 -------------------------------------- drivers/staging/vt6655/device.h | 1 - drivers/staging/vt6655/key.h | 1 - drivers/staging/vt6655/wmgr.h | 1 - 4 files changed, 618 deletions(-) delete mode 100644 drivers/staging/vt6655/80211mgr.h diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h deleted file mode 100644 index 94cff3b87cb1..000000000000 --- a/drivers/staging/vt6655/80211mgr.h +++ /dev/null @@ -1,615 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: 80211mgr.h - * - * Purpose: 802.11 management frames pre-defines. - * - * - * Author: Lyndon Chen - * - * Date: May 8, 2002 - * - */ - -#ifndef __80211MGR_H__ -#define __80211MGR_H__ - -#include -#include "linux/ieee80211.h" - -#include "ttype.h" -#include "80211hdr.h" - -#define WLAN_MIN_ARRAY 1 - -/* Information Element ID value */ -#define WLAN_EID_FH_PARMS 2 -#define WLAN_EID_DS_PARMS 3 -#define WLAN_EID_CF_PARMS 4 -#define WLAN_EID_IBSS_PARMS 6 -#define WLAN_EID_TPC_REQ 34 -#define WLAN_EID_TPC_REP 35 -#define WLAN_EID_SUPP_CH 36 -#define WLAN_EID_CH_SWITCH 37 -#define WLAN_EID_MEASURE_REQ 38 -#define WLAN_EID_MEASURE_REP 39 -#define WLAN_EID_QUIET 40 -#define WLAN_EID_IBSS_DFS 41 -#define WLAN_EID_ERP 42 -/* reference 802.11i 7.3.2 table 20 */ -#define WLAN_EID_EXTSUPP_RATES 50 -/* reference WiFi WPA spec. */ -#define WLAN_EID_RSN_WPA 221 - -#define WLAN_EID_ERP_NONERP_PRESENT 0x01 -#define WLAN_EID_ERP_USE_PROTECTION 0x02 -#define WLAN_EID_ERP_BARKER_MODE 0x04 - -/* Reason Codes */ -#define WLAN_MGMT_REASON_RSVD 0 -#define WLAN_MGMT_REASON_UNSPEC 1 -#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2 -#define WLAN_MGMT_REASON_DEAUTH_LEAVING 3 -#define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4 -#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5 -#define WLAN_MGMT_REASON_CLASS2_NONAUTH 6 -#define WLAN_MGMT_REASON_CLASS3_NONASSOC 7 -#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8 -#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9 -#define WLAN_MGMT_REASON_DISASSOC_PWR_CAP_UNACCEPT 10 -#define WLAN_MGMT_REASON_DISASSOC_SUPP_CH_UNACCEPT 11 -#define WLAN_MGMT_REASON_INVALID_IE 13 -#define WLAN_MGMT_REASON_MIC_FAILURE 14 -#define WLAN_MGMT_REASON_4WAY_HANDSHAKE_TIMEOUT 15 -#define WLAN_MGMT_REASON_GRPKEY_UPDATE_TIMEOUT 16 -#define WLAN_MGMT_REASON_4WAY_INFO_DIFFERENT 17 -#define WLAN_MGMT_REASON_MULTCAST_CIPHER_INVALID 18 -#define WLAN_MGMT_REASON_UNCAST_CIPHER_INVALID 19 -#define WLAN_MGMT_REASON_AKMP_INVALID 20 -#define WLAN_MGMT_REASON_RSNE_UNSUPPORTED 21 -#define WLAN_MGMT_REASON_RSNE_CAP_INVALID 22 -#define WLAN_MGMT_REASON_80211X_AUTH_FAILED 23 - -/* Status Codes */ -#define WLAN_MGMT_STATUS_SUCCESS 0 -#define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1 -#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10 -#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11 -#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12 -#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13 -#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14 -#define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15 -#define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16 -#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17 -#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18 -#define WLAN_MGMT_STATUS_ASSOC_DENIED_SHORTPREAMBLE 19 -#define WLAN_MGMT_STATUS_ASSOC_DENIED_PBCC 20 -#define WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY 21 - -/* reference 802.11h 7.3.1.9 */ -#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SPECTRUM_MNG 22 -#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_PWR_CAP 23 -#define WLAN_MGMT_STATUS_ASSOC_REJECT_BCS_SUPP_CH 24 -/* reference 802.11g 7.3.1.9 */ -#define WLAN_MGMT_STATUS_SHORTSLOTTIME_UNSUPPORTED 25 -#define WLAN_MGMT_STATUS_DSSSOFDM_UNSUPPORTED 26 -/* reference 802.11i 3.7.1.9 table 19 */ -#define WLAN_MGMT_STATUS_INVALID_IE 40 -#define WLAN_MGMT_STATUS_GROUP_CIPHER_INVALID 41 -#define WLAN_MGMT_STATUS_PAIRWISE_CIPHER_INVALID 42 -#define WLAN_MGMT_STATUS_AKMP_INVALID 43 -#define WLAN_MGMT_STATUS_UNSUPPORT_RSN_IE_VER 44 -#define WLAN_MGMT_STATUS_INVALID_RSN_IE_CAP 45 -#define WLAN_MGMT_STATUS_CIPHER_REJECT 46 - -/* Auth Algorithm */ -#define WLAN_AUTH_ALG_OPENSYSTEM 0 -#define WLAN_AUTH_ALG_SHAREDKEY 1 - -/* Management Frame Field Offsets */ -/* Note: Not all fields are listed because of variable lengths. */ -/* Note: These offsets are from the start of the frame data */ - -#define WLAN_BEACON_OFF_TS 0 -#define WLAN_BEACON_OFF_BCN_INT 8 -#define WLAN_BEACON_OFF_CAPINFO 10 -#define WLAN_BEACON_OFF_SSID 12 - -#define WLAN_DISASSOC_OFF_REASON 0 - -#define WLAN_ASSOCREQ_OFF_CAP_INFO 0 -#define WLAN_ASSOCREQ_OFF_LISTEN_INT 2 -#define WLAN_ASSOCREQ_OFF_SSID 4 - -#define WLAN_ASSOCRESP_OFF_CAP_INFO 0 -#define WLAN_ASSOCRESP_OFF_STATUS 2 -#define WLAN_ASSOCRESP_OFF_AID 4 -#define WLAN_ASSOCRESP_OFF_SUPP_RATES 6 - -#define WLAN_REASSOCREQ_OFF_CAP_INFO 0 -#define WLAN_REASSOCREQ_OFF_LISTEN_INT 2 -#define WLAN_REASSOCREQ_OFF_CURR_AP 4 -#define WLAN_REASSOCREQ_OFF_SSID 10 - -#define WLAN_REASSOCRESP_OFF_CAP_INFO 0 -#define WLAN_REASSOCRESP_OFF_STATUS 2 -#define WLAN_REASSOCRESP_OFF_AID 4 -#define WLAN_REASSOCRESP_OFF_SUPP_RATES 6 - -#define WLAN_PROBEREQ_OFF_SSID 0 - -#define WLAN_PROBERESP_OFF_TS 0 -#define WLAN_PROBERESP_OFF_BCN_INT 8 -#define WLAN_PROBERESP_OFF_CAP_INFO 10 -#define WLAN_PROBERESP_OFF_SSID 12 - -#define WLAN_AUTHEN_OFF_AUTH_ALG 0 -#define WLAN_AUTHEN_OFF_AUTH_SEQ 2 -#define WLAN_AUTHEN_OFF_STATUS 4 -#define WLAN_AUTHEN_OFF_CHALLENGE 6 - -#define WLAN_DEAUTHEN_OFF_REASON 0 - -/* Cipher Suite Selectors defined in 802.11i */ -#define WLAN_11i_CSS_USE_GROUP 0 -#define WLAN_11i_CSS_WEP40 1 -#define WLAN_11i_CSS_TKIP 2 -#define WLAN_11i_CSS_CCMP 4 -#define WLAN_11i_CSS_WEP104 5 -#define WLAN_11i_CSS_UNKNOWN 255 - -/* Authentication and Key Management Suite Selectors defined in 802.11i */ -#define WLAN_11i_AKMSS_802_1X 1 -#define WLAN_11i_AKMSS_PSK 2 -#define WLAN_11i_AKMSS_UNKNOWN 255 - -/* Measurement type definitions reference ieee 802.11h Table 20b */ -#define MEASURE_TYPE_BASIC 0 -#define MEASURE_TYPE_CCA 1 -#define MEASURE_TYPE_RPI 2 - -/* Measurement request mode definitions reference ieee 802.11h Figure 46h */ -#define MEASURE_MODE_ENABLE 0x02 -#define MEASURE_MODE_REQ 0x04 -#define MEASURE_MODE_REP 0x08 - -/* Measurement report mode definitions reference ieee 802.11h Figure 46m */ -#define MEASURE_MODE_LATE 0x01 -#define MEASURE_MODE_INCAPABLE 0x02 -#define MEASURE_MODE_REFUSED 0x04 - -/* Information Element Types */ - -#pragma pack(1) -typedef struct tagWLAN_IE { - unsigned char byElementID; - unsigned char len; -} __attribute__ ((__packed__)) -WLAN_IE, *PWLAN_IE; - -/* Service Set Identity (SSID) */ -#pragma pack(1) -typedef struct tagWLAN_IE_SSID { - unsigned char byElementID; - unsigned char len; - unsigned char abySSID[1]; -} __attribute__ ((__packed__)) -WLAN_IE_SSID, *PWLAN_IE_SSID; - -/* Supported Rates */ -#pragma pack(1) -typedef struct tagWLAN_IE_SUPP_RATES { - unsigned char byElementID; - unsigned char len; - unsigned char abyRates[1]; -} __attribute__ ((__packed__)) -WLAN_IE_SUPP_RATES, *PWLAN_IE_SUPP_RATES; - -/* FH Parameter Set */ -#pragma pack(1) -typedef struct _WLAN_IE_FH_PARMS { - unsigned char byElementID; - unsigned char len; - unsigned short wDwellTime; - unsigned char byHopSet; - unsigned char byHopPattern; - unsigned char byHopIndex; -} WLAN_IE_FH_PARMS, *PWLAN_IE_FH_PARMS; - -/* DS Parameter Set */ -#pragma pack(1) -typedef struct tagWLAN_IE_DS_PARMS { - unsigned char byElementID; - unsigned char len; - unsigned char byCurrChannel; -} __attribute__ ((__packed__)) -WLAN_IE_DS_PARMS, *PWLAN_IE_DS_PARMS; - -/* CF Parameter Set */ -#pragma pack(1) -typedef struct tagWLAN_IE_CF_PARMS { - unsigned char byElementID; - unsigned char len; - unsigned char byCFPCount; - unsigned char byCFPPeriod; - unsigned short wCFPMaxDuration; - unsigned short wCFPDurRemaining; -} __attribute__ ((__packed__)) -WLAN_IE_CF_PARMS, *PWLAN_IE_CF_PARMS; - -/* TIM */ -#pragma pack(1) -typedef struct tagWLAN_IE_TIM { - unsigned char byElementID; - unsigned char len; - unsigned char byDTIMCount; - unsigned char byDTIMPeriod; - unsigned char byBitMapCtl; - unsigned char byVirtBitMap[1]; -} __attribute__ ((__packed__)) -WLAN_IE_TIM, *PWLAN_IE_TIM; - -/* IBSS Parameter Set */ -#pragma pack(1) -typedef struct tagWLAN_IE_IBSS_PARMS { - unsigned char byElementID; - unsigned char len; - unsigned short wATIMWindow; -} __attribute__ ((__packed__)) -WLAN_IE_IBSS_PARMS, *PWLAN_IE_IBSS_PARMS; - -/* Challenge Text */ -#pragma pack(1) -typedef struct tagWLAN_IE_CHALLENGE { - unsigned char byElementID; - unsigned char len; - unsigned char abyChallenge[1]; -} __attribute__ ((__packed__)) -WLAN_IE_CHALLENGE, *PWLAN_IE_CHALLENGE; - -#pragma pack(1) -typedef struct tagWLAN_IE_RSN_EXT { - unsigned char byElementID; - unsigned char len; - unsigned char abyOUI[4]; - unsigned short wVersion; - unsigned char abyMulticast[4]; - unsigned short wPKCount; - struct { - unsigned char abyOUI[4]; - } PKSList[1]; /* the rest is variable so need to */ - /* overlay ieauth structure */ -} WLAN_IE_RSN_EXT, *PWLAN_IE_RSN_EXT; - -#pragma pack(1) -typedef struct tagWLAN_IE_RSN_AUTH { - unsigned short wAuthCount; - struct { - unsigned char abyOUI[4]; - } AuthKSList[1]; -} WLAN_IE_RSN_AUTH, *PWLAN_IE_RSN_AUTH; - -/* RSN Identity */ -#pragma pack(1) -typedef struct tagWLAN_IE_RSN { - unsigned char byElementID; - unsigned char len; - unsigned short wVersion; - unsigned char abyRSN[WLAN_MIN_ARRAY]; -} WLAN_IE_RSN, *PWLAN_IE_RSN; - -/* ERP */ -#pragma pack(1) -typedef struct tagWLAN_IE_ERP { - unsigned char byElementID; - unsigned char len; - unsigned char byContext; -} __attribute__ ((__packed__)) -WLAN_IE_ERP, *PWLAN_IE_ERP; - -#pragma pack(1) -typedef struct _MEASEURE_REQ { - unsigned char byChannel; - unsigned char abyStartTime[8]; - unsigned char abyDuration[2]; -} MEASEURE_REQ, *PMEASEURE_REQ, - MEASEURE_REQ_BASIC, *PMEASEURE_REQ_BASIC, - MEASEURE_REQ_CCA, *PMEASEURE_REQ_CCA, - MEASEURE_REQ_RPI, *PMEASEURE_REQ_RPI; - -typedef struct _MEASEURE_REP_BASIC { - unsigned char byChannel; - unsigned char abyStartTime[8]; - unsigned char abyDuration[2]; - unsigned char byMap; -} MEASEURE_REP_BASIC, *PMEASEURE_REP_BASIC; - -typedef struct _MEASEURE_REP_CCA { - unsigned char byChannel; - unsigned char abyStartTime[8]; - unsigned char abyDuration[2]; - unsigned char byCCABusyFraction; -} MEASEURE_REP_CCA, *PMEASEURE_REP_CCA; - -typedef struct _MEASEURE_REP_RPI { - unsigned char byChannel; - unsigned char abyStartTime[8]; - unsigned char abyDuration[2]; - unsigned char abyRPIdensity[8]; -} MEASEURE_REP_RPI, *PMEASEURE_REP_RPI; - -typedef union _MEASEURE_REP { - MEASEURE_REP_BASIC sBasic; - MEASEURE_REP_CCA sCCA; - MEASEURE_REP_RPI sRPI; -} MEASEURE_REP, *PMEASEURE_REP; - -typedef struct _WLAN_IE_MEASURE_REQ { - unsigned char byElementID; - unsigned char len; - unsigned char byToken; - unsigned char byMode; - unsigned char byType; - MEASEURE_REQ sReq; -} WLAN_IE_MEASURE_REQ, *PWLAN_IE_MEASURE_REQ; - -typedef struct _WLAN_IE_MEASURE_REP { - unsigned char byElementID; - unsigned char len; - unsigned char byToken; - unsigned char byMode; - unsigned char byType; - MEASEURE_REP sRep; -} WLAN_IE_MEASURE_REP, *PWLAN_IE_MEASURE_REP; - -typedef struct _WLAN_IE_CH_SW { - unsigned char byElementID; - unsigned char len; - unsigned char byMode; - unsigned char byChannel; - unsigned char byCount; -} WLAN_IE_CH_SW, *PWLAN_IE_CH_SW; - -typedef struct _WLAN_IE_QUIET { - unsigned char byElementID; - unsigned char len; - unsigned char byQuietCount; - unsigned char byQuietPeriod; - unsigned char abyQuietDuration[2]; - unsigned char abyQuietOffset[2]; -} WLAN_IE_QUIET, *PWLAN_IE_QUIET; - -typedef struct _WLAN_IE_COUNTRY { - unsigned char byElementID; - unsigned char len; - unsigned char abyCountryString[3]; - unsigned char abyCountryInfo[3]; -} WLAN_IE_COUNTRY, *PWLAN_IE_COUNTRY; - -typedef struct _WLAN_IE_PW_CONST { - unsigned char byElementID; - unsigned char len; - unsigned char byPower; -} WLAN_IE_PW_CONST, *PWLAN_IE_PW_CONST; - -typedef struct _WLAN_IE_PW_CAP { - unsigned char byElementID; - unsigned char len; - unsigned char byMinPower; - unsigned char byMaxPower; -} WLAN_IE_PW_CAP, *PWLAN_IE_PW_CAP; - -typedef struct _WLAN_IE_SUPP_CH { - unsigned char byElementID; - unsigned char len; - unsigned char abyChannelTuple[2]; -} WLAN_IE_SUPP_CH, *PWLAN_IE_SUPP_CH; - -typedef struct _WLAN_IE_TPC_REQ { - unsigned char byElementID; - unsigned char len; -} WLAN_IE_TPC_REQ, *PWLAN_IE_TPC_REQ; - -typedef struct _WLAN_IE_TPC_REP { - unsigned char byElementID; - unsigned char len; - unsigned char byTxPower; - unsigned char byLinkMargin; -} WLAN_IE_TPC_REP, *PWLAN_IE_TPC_REP; - -typedef struct _WLAN_IE_IBSS_DFS { - unsigned char byElementID; - unsigned char len; - unsigned char abyDFSOwner[6]; - unsigned char byDFSRecovery; - unsigned char abyChannelMap[2]; -} WLAN_IE_IBSS_DFS, *PWLAN_IE_IBSS_DFS; - -#pragma pack() - -/* Frame Types */ -/* prototype structure, all mgmt frame types will start with these members */ -typedef struct tagWLAN_FR_MGMT { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; -} WLAN_FR_MGMT, *PWLAN_FR_MGMT; - -/* Beacon frame */ -typedef struct tagWLAN_FR_BEACON { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - __le64 *pqwTimestamp; - unsigned short *pwBeaconInterval; - unsigned short *pwCapInfo; - PWLAN_IE_SSID pSSID; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_DS_PARMS pDSParms; - PWLAN_IE_CF_PARMS pCFParms; - PWLAN_IE_TIM pTIM; - PWLAN_IE_IBSS_PARMS pIBSSParms; - PWLAN_IE_RSN pRSN; - PWLAN_IE_RSN_EXT pRSNWPA; - PWLAN_IE_ERP pERP; - PWLAN_IE_SUPP_RATES pExtSuppRates; - PWLAN_IE_COUNTRY pIE_Country; - PWLAN_IE_PW_CONST pIE_PowerConstraint; - PWLAN_IE_CH_SW pIE_CHSW; - PWLAN_IE_IBSS_DFS pIE_IBSSDFS; - PWLAN_IE_QUIET pIE_Quiet; -} WLAN_FR_BEACON, *PWLAN_FR_BEACON; - -/* IBSS ATIM frame */ -typedef struct tagWLAN_FR_IBSSATIM { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; -} WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM; - -/* Disassociation */ -typedef struct tagWLAN_FR_DISASSOC { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwReason; -} WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC; - -/* Association Request */ -typedef struct tagWLAN_FR_ASSOCREQ { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwCapInfo; - unsigned short *pwListenInterval; - PWLAN_IE_SSID pSSID; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_RSN pRSN; - PWLAN_IE_RSN_EXT pRSNWPA; - PWLAN_IE_SUPP_RATES pExtSuppRates; - PWLAN_IE_PW_CAP pCurrPowerCap; - PWLAN_IE_SUPP_CH pCurrSuppCh; -} WLAN_FR_ASSOCREQ, *PWLAN_FR_ASSOCREQ; - -/* Association Response */ -typedef struct tagWLAN_FR_ASSOCRESP { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwCapInfo; - unsigned short *pwStatus; - unsigned short *pwAid; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_SUPP_RATES pExtSuppRates; -} WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP; - -/* Reassociation Request */ -typedef struct tagWLAN_FR_REASSOCREQ { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwCapInfo; - unsigned short *pwListenInterval; - PIEEE_ADDR pAddrCurrAP; - PWLAN_IE_SSID pSSID; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_RSN pRSN; - PWLAN_IE_RSN_EXT pRSNWPA; - PWLAN_IE_SUPP_RATES pExtSuppRates; -} WLAN_FR_REASSOCREQ, *PWLAN_FR_REASSOCREQ; - -/* Reassociation Response */ -typedef struct tagWLAN_FR_REASSOCRESP { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwCapInfo; - unsigned short *pwStatus; - unsigned short *pwAid; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_SUPP_RATES pExtSuppRates; -} WLAN_FR_REASSOCRESP, *PWLAN_FR_REASSOCRESP; - -/* Probe Request */ -typedef struct tagWLAN_FR_PROBEREQ { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - PWLAN_IE_SSID pSSID; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_SUPP_RATES pExtSuppRates; -} WLAN_FR_PROBEREQ, *PWLAN_FR_PROBEREQ; - -/* Probe Response */ -typedef struct tagWLAN_FR_PROBERESP { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - __le64 *pqwTimestamp; - unsigned short *pwBeaconInterval; - unsigned short *pwCapInfo; - PWLAN_IE_SSID pSSID; - PWLAN_IE_SUPP_RATES pSuppRates; - PWLAN_IE_DS_PARMS pDSParms; - PWLAN_IE_CF_PARMS pCFParms; - PWLAN_IE_IBSS_PARMS pIBSSParms; - PWLAN_IE_RSN pRSN; - PWLAN_IE_RSN_EXT pRSNWPA; - PWLAN_IE_ERP pERP; - PWLAN_IE_SUPP_RATES pExtSuppRates; - PWLAN_IE_COUNTRY pIE_Country; - PWLAN_IE_PW_CONST pIE_PowerConstraint; - PWLAN_IE_CH_SW pIE_CHSW; - PWLAN_IE_IBSS_DFS pIE_IBSSDFS; - PWLAN_IE_QUIET pIE_Quiet; -} WLAN_FR_PROBERESP, *PWLAN_FR_PROBERESP; - -/* Authentication */ -typedef struct tagWLAN_FR_AUTHEN { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwAuthAlgorithm; - unsigned short *pwAuthSequence; - unsigned short *pwStatus; - PWLAN_IE_CHALLENGE pChallenge; -} WLAN_FR_AUTHEN, *PWLAN_FR_AUTHEN; - -/* Deauthenication */ -typedef struct tagWLAN_FR_DEAUTHEN { - unsigned int uType; - unsigned int len; - unsigned char *pBuf; - PUWLAN_80211HDR pHdr; - unsigned short *pwReason; -} WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN; - -#endif/* __80211MGR_H__ */ diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 4d9d60bc756a..1816f3c2a502 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -642,7 +642,6 @@ struct vnt_private { unsigned char abyCountryCode[3]; /* for 802.11h DFS */ unsigned int uNumOfMeasureEIDs; - PWLAN_IE_MEASURE_REQ pCurrMeasureEID; bool bMeasureInProgress; unsigned char byOrgChannel; unsigned char byOrgRCR; diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 53b46062765d..5615f397f6e7 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -33,7 +33,6 @@ #include #include "ttype.h" -#include "80211mgr.h" /*--------------------- Export Definitions -------------------------*/ #define MAX_GROUP_KEY 4 diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 9e983f6da41d..44976e0200bb 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -35,7 +35,6 @@ #define __WMGR_H__ #include "ttype.h" -#include "80211mgr.h" #include "80211hdr.h" #include "card.h" -- cgit v1.2.3-59-g8ed1b From 47a2a3cb758f6b44b0a6ce2a379f44b18666c125 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:56 +0000 Subject: staging: vt6655: dead code remove iowpa.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/iowpa.h | 130 ----------------------------------- 2 files changed, 131 deletions(-) delete mode 100644 drivers/staging/vt6655/iowpa.h diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 2327369ba790..d5ab7c4b6891 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -64,7 +64,6 @@ #include "rxtx.h" #include "dpc.h" #include "rf.h" -#include "iowpa.h" #include #include #include diff --git a/drivers/staging/vt6655/iowpa.h b/drivers/staging/vt6655/iowpa.h deleted file mode 100644 index 7f79eaeecc9e..000000000000 --- a/drivers/staging/vt6655/iowpa.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: iowpa.h - * - * Purpose: Handles wpa supplicant ioctl interface - * - * Author: Lyndon Chen - * - * Date: May 8, 2002 - * - */ - -#ifndef __IOWPA_H__ -#define __IOWPA_H__ - -#define WPA_IE_LEN 64 - -/* WPA related */ - -enum { - VIAWGET_SET_WPA = 1, - VIAWGET_SET_KEY = 2, - VIAWGET_SET_SCAN = 3, - VIAWGET_GET_SCAN = 4, - VIAWGET_GET_SSID = 5, - VIAWGET_GET_BSSID = 6, - VIAWGET_SET_DROP_UNENCRYPT = 7, - VIAWGET_SET_DEAUTHENTICATE = 8, - VIAWGET_SET_ASSOCIATE = 9, - VIAWGET_SET_DISASSOCIATE = 10 -}; - -enum { - VIAWGET_ASSOC_MSG = 1, - VIAWGET_DISASSOC_MSG = 2, - VIAWGET_PTK_MIC_MSG = 3, - VIAWGET_GTK_MIC_MSG = 4, - VIAWGET_CCKM_ROAM_MSG = 5, - VIAWGET_DEVICECLOSE_MSG = 6 -}; - -#pragma pack(1) -typedef struct viawget_wpa_header { - u8 type; - u16 req_ie_len; - u16 resp_ie_len; -} viawget_wpa_header; - -struct viawget_wpa_param { - u32 cmd; - u8 addr[6]; - union { - struct { - u8 len; - u8 data[0]; - } generic_elem; - - struct { - u8 bssid[6]; - u8 ssid[32]; - u8 ssid_len; - u8 __user *wpa_ie; - u16 wpa_ie_len; - int pairwise_suite; - int group_suite; - int key_mgmt_suite; - int auth_alg; - int mode; - - } wpa_associate; - - struct { - int alg_name; - u16 key_index; - u16 set_tx; - u8 *seq; - u16 seq_len; - u8 *key; - u16 key_len; - } wpa_key; - - struct { - u8 ssid_len; - u8 ssid[32]; - } scan_req; - - struct { - u16 scan_count; - u8 __user *buf; - } scan_results; - - } u; -}; - -#pragma pack(1) -struct viawget_scan_result { - u8 bssid[6]; - u8 ssid[32]; - u16 ssid_len; - u8 wpa_ie[WPA_IE_LEN]; - u16 wpa_ie_len; - u8 rsn_ie[WPA_IE_LEN]; - u16 rsn_ie_len; - int freq; /* MHz */ - int caps; /* e.g. privacy */ - int qual; /* signal quality */ - int noise; - int level; - int maxrate; -}; - -#pragma pack() - -#endif /* __IOWPA_H__ */ -- cgit v1.2.3-59-g8ed1b From 651a39cad5f3009e8aa80e3132ac34a9474ebf74 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:57 +0000 Subject: staging: vt6655: dead code remove iocmd.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/iocmd.h | 386 ----------------------------------- 2 files changed, 387 deletions(-) delete mode 100644 drivers/staging/vt6655/iocmd.h diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index d5ab7c4b6891..7892f861521e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -60,7 +60,6 @@ #include "mac.h" #include "wmgr.h" #include "power.h" -#include "iocmd.h" #include "rxtx.h" #include "dpc.h" #include "rf.h" diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h deleted file mode 100644 index 804c903404a1..000000000000 --- a/drivers/staging/vt6655/iocmd.h +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: iocmd.h - * - * Purpose: Handles the viawget ioctl private interface functions - * - * Author: Lyndon Chen - * - * Date: May 8, 2002 - * - */ - -#ifndef __IOCMD_H__ -#define __IOCMD_H__ - -#include "ttype.h" - -/* ioctl Command code */ -#define MAGIC_CODE 0x3142 -#define IOCTL_CMD_TEST (SIOCDEVPRIVATE + 0) -#define IOCTL_CMD_SET (SIOCDEVPRIVATE + 1) -#define IOCTL_CMD_HOSTAPD (SIOCDEVPRIVATE + 2) -#define IOCTL_CMD_WPA (SIOCDEVPRIVATE + 3) - -typedef enum tagWMAC_CMD { - WLAN_CMD_BSS_SCAN, - WLAN_CMD_BSS_JOIN, - WLAN_CMD_DISASSOC, - WLAN_CMD_SET_WEP, - WLAN_CMD_GET_LINK, - WLAN_CMD_GET_LISTLEN, - WLAN_CMD_GET_LIST, - WLAN_CMD_GET_MIB, - WLAN_CMD_GET_STAT, - WLAN_CMD_STOP_MAC, - WLAN_CMD_START_MAC, - WLAN_CMD_AP_START, - WLAN_CMD_SET_HOSTAPD, - WLAN_CMD_SET_HOSTAPD_STA, - WLAN_CMD_SET_802_1X, - WLAN_CMD_SET_HOST_WEP, - WLAN_CMD_SET_WPA, - WLAN_CMD_GET_NODE_CNT, - WLAN_CMD_ZONETYPE_SET, - WLAN_CMD_GET_NODE_LIST -} WMAC_CMD, *PWMAC_CMD; - -typedef enum tagWZONETYPE { - ZoneType_USA = 0, - ZoneType_Japan = 1, - ZoneType_Europe = 2 -} WZONETYPE; - -#define ADHOC 0 -#define INFRA 1 -#define BOTH 2 -#define AP 3 - -#define ADHOC_STARTED 1 -#define ADHOC_JOINTED 2 - -#define PHY80211a 0 -#define PHY80211b 1 -#define PHY80211g 2 - -#define SSID_ID 0 -#define SSID_MAXLEN 32 -#define BSSID_LEN 6 -#define WEP_NKEYS 4 -#define WEP_KEYMAXLEN 29 -#define WEP_40BIT_LEN 5 -#define WEP_104BIT_LEN 13 -#define WEP_232BIT_LEN 16 - -/* Ioctl interface structure, Command structure */ -#pragma pack(1) -typedef struct tagSCmdRequest { - u8 name[16]; - void __user *data; - u16 wResult; - u16 wCmdCode; -} SCmdRequest, *PSCmdRequest; - -/* Scan */ -typedef struct tagSCmdScan { - u8 ssid[SSID_MAXLEN + 2]; -} SCmdScan, *PSCmdScan; - -/* BSS Join */ -typedef struct tagSCmdBSSJoin { - u16 wBSSType; - u16 wBBPType; - u8 ssid[SSID_MAXLEN + 2]; - u32 uChannel; - bool bPSEnable; - bool bShareKeyAuth; -} SCmdBSSJoin, *PSCmdBSSJoin; - -/* Zonetype Setting */ -typedef struct tagSCmdZoneTypeSet { - bool bWrite; - WZONETYPE ZoneType; -} SCmdZoneTypeSet, *PSCmdZoneTypeSet; - -#ifdef WPA_SM_Transtatus -typedef struct tagSWPAResult { - char ifname[100]; - u8 proto; - u8 key_mgmt; - u8 eap_type; - bool authenticated; -} SWPAResult, *PSWPAResult; -#endif - -typedef struct tagSCmdStartAP { - u16 wBSSType; - u16 wBBPType; - u8 ssid[SSID_MAXLEN + 2]; - u32 uChannel; - u32 uBeaconInt; - bool bShareKeyAuth; - u8 byBasicRate; -} SCmdStartAP, *PSCmdStartAP; - -typedef struct tagSCmdSetWEP { - bool bEnableWep; - u8 byKeyIndex; - u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; - bool bWepKeyAvailable[WEP_NKEYS]; - u32 auWepKeyLength[WEP_NKEYS]; -} SCmdSetWEP, *PSCmdSetWEP; - -typedef struct tagSBSSIDItem { - u32 uChannel; - u8 abyBSSID[BSSID_LEN]; - u8 abySSID[SSID_MAXLEN + 1]; - u8 byNetType; - u16 wBeaconInterval; - u16 wCapInfo; /* for address of byNetType at align 4 */ - - bool bWEPOn; - u32 uRSSI; -} SBSSIDItem; - -typedef struct tagSBSSIDList { - u32 uItem; - SBSSIDItem sBSSIDList[0]; -} SBSSIDList, *PSBSSIDList; - -typedef struct tagSCmdLinkStatus { - bool bLink; - u16 wBSSType; - u8 byState; - u8 abyBSSID[BSSID_LEN]; - u8 abySSID[SSID_MAXLEN + 2]; - u32 uChannel; - u32 uLinkRate; -} SCmdLinkStatus, *PSCmdLinkStatus; - -/* 802.11 counter */ -typedef struct tagSDot11MIBCount { - u32 TransmittedFragmentCount; - u32 MulticastTransmittedFrameCount; - u32 FailedCount; - u32 RetryCount; - u32 MultipleRetryCount; - u32 RTSSuccessCount; - u32 RTSFailureCount; - u32 ACKFailureCount; - u32 FrameDuplicateCount; - u32 ReceivedFragmentCount; - u32 MulticastReceivedFrameCount; - u32 FCSErrorCount; -} SDot11MIBCount, *PSDot11MIBCount; - -/* statistic counter */ -typedef struct tagSStatMIBCount { - /* ISR status count */ - u32 dwIsrTx0OK; - u32 dwIsrTx1OK; - u32 dwIsrBeaconTxOK; - u32 dwIsrRxOK; - u32 dwIsrTBTTInt; - u32 dwIsrSTIMERInt; - u32 dwIsrUnrecoverableError; - u32 dwIsrSoftInterrupt; - u32 dwIsrRxNoBuf; - - u32 dwIsrUnknown; - - /* RSR status count */ - u32 dwRsrFrmAlgnErr; - u32 dwRsrErr; - u32 dwRsrCRCErr; - u32 dwRsrCRCOk; - u32 dwRsrBSSIDOk; - u32 dwRsrADDROk; - u32 dwRsrICVOk; - u32 dwNewRsrShortPreamble; - u32 dwRsrLong; - u32 dwRsrRunt; - - u32 dwRsrRxControl; - u32 dwRsrRxData; - u32 dwRsrRxManage; - - u32 dwRsrRxPacket; - u32 dwRsrRxOctet; - u32 dwRsrBroadcast; - u32 dwRsrMulticast; - u32 dwRsrDirected; - /* 64-bit OID */ - u32 ullRsrOK; - - /* for some optional OIDs (64 bits) and DMI support */ - u32 ullRxBroadcastBytes; - u32 ullRxMulticastBytes; - u32 ullRxDirectedBytes; - u32 ullRxBroadcastFrames; - u32 ullRxMulticastFrames; - u32 ullRxDirectedFrames; - - u32 dwRsrRxFragment; - u32 dwRsrRxFrmLen64; - u32 dwRsrRxFrmLen65_127; - u32 dwRsrRxFrmLen128_255; - u32 dwRsrRxFrmLen256_511; - u32 dwRsrRxFrmLen512_1023; - u32 dwRsrRxFrmLen1024_1518; - - /* TSR0,1 status count */ - u32 dwTsrTotalRetry[2]; /* total collision retry count */ - u32 dwTsrOnceRetry[2]; /* this packet only occur one collision */ - u32 dwTsrMoreThanOnceRetry[2]; /* this packet occur more than one collision */ - u32 dwTsrRetry[2]; /* this packet has ever occur collision */ - /* that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0) */ - u32 dwTsrACKData[2]; - u32 dwTsrErr[2]; - u32 dwAllTsrOK[2]; - u32 dwTsrRetryTimeout[2]; - u32 dwTsrTransmitTimeout[2]; - - u32 dwTsrTxPacket[2]; - u32 dwTsrTxOctet[2]; - u32 dwTsrBroadcast[2]; - u32 dwTsrMulticast[2]; - u32 dwTsrDirected[2]; - - /* RD/TD count */ - u32 dwCntRxFrmLength; - u32 dwCntTxBufLength; - - u8 abyCntRxPattern[16]; - u8 abyCntTxPattern[16]; - - /* Software check */ - u32 dwCntRxDataErr; /* rx buffer data software compare CRC err count */ - u32 dwCntDecryptErr; /* rx buffer data software compare CRC err count */ - u32 dwCntRxICVErr; /* rx buffer data software compare CRC err count */ - u32 idxRxErrorDesc; /* index for rx data error RD */ - - /* 64-bit OID */ - u32 ullTsrOK[2]; - - /* for some optional OIDs (64 bits) and DMI support */ - u32 ullTxBroadcastFrames[2]; - u32 ullTxMulticastFrames[2]; - u32 ullTxDirectedFrames[2]; - u32 ullTxBroadcastBytes[2]; - u32 ullTxMulticastBytes[2]; - u32 ullTxDirectedBytes[2]; -} SStatMIBCount, *PSStatMIBCount; - -typedef struct tagSNodeItem { - /* STA info */ - u16 wAID; - u8 abyMACAddr[6]; - u16 wTxDataRate; - u16 wInActiveCount; - u16 wEnQueueCnt; - u16 wFlags; - bool bPWBitOn; - u8 byKeyIndex; - u16 wWepKeyLength; - u8 abyWepKey[WEP_KEYMAXLEN]; - /* Auto rate fallback vars */ - bool bIsInFallback; - u32 uTxFailures; - u32 uTxAttempts; - u16 wFailureRatio; -} SNodeItem; - -typedef struct tagSNodeList { - u32 uItem; - SNodeItem sNodeList[0]; -} SNodeList, *PSNodeList; - -typedef struct tagSCmdValue { - u32 dwValue; -} SCmdValue, *PSCmdValue; - -/* hostapd & viawget ioctl related */ -enum { - VIAWGET_HOSTAPD_FLUSH = 1, - VIAWGET_HOSTAPD_ADD_STA = 2, - VIAWGET_HOSTAPD_REMOVE_STA = 3, - VIAWGET_HOSTAPD_GET_INFO_STA = 4, - VIAWGET_HOSTAPD_SET_ENCRYPTION = 5, - VIAWGET_HOSTAPD_GET_ENCRYPTION = 6, - VIAWGET_HOSTAPD_SET_FLAGS_STA = 7, - VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8, - VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9, - VIAWGET_HOSTAPD_MLME = 10, - VIAWGET_HOSTAPD_SCAN_REQ = 11, - VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12, -}; - -#define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ - ((int)(&((struct viawget_hostapd_param *)0)->u.generic_elem.data)) - -/*Maximum length for algorithm names (-1 for nul termination) used in ioctl()*/ - -struct viawget_hostapd_param { - u32 cmd; - u8 sta_addr[6]; - union { - struct { - u16 aid; - u16 capability; - u8 tx_supp_rates; - } add_sta; - struct { - u32 inactive_sec; - } get_info_sta; - struct { - u8 alg; - u32 flags; - u32 err; - u8 idx; - u8 seq[8]; - u16 key_len; - u8 key[0]; - } crypt; - struct { - u32 flags_and; - u32 flags_or; - } set_flags_sta; - struct { - u16 rid; - u16 len; - u8 data[0]; - } rid; - struct { - u8 len; - u8 data[0]; - } generic_elem; - struct { - u16 cmd; - u16 reason_code; - } mlme; - struct { - u8 ssid_len; - u8 ssid[32]; - } scan_req; - } u; -}; - -#pragma pack() - -#endif /* __IOCMD_H__ */ -- cgit v1.2.3-59-g8ed1b From 4cf8e50303c92333e1d2be838624f004e7371513 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:58 +0000 Subject: staging: vt6655: dead code remove country.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 1 - drivers/staging/vt6655/country.h | 161 --------------------------------------- 2 files changed, 162 deletions(-) delete mode 100644 drivers/staging/vt6655/country.h diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 41146eb113ef..6bd5f161894d 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -21,7 +21,6 @@ */ #include "baseband.h" -#include "country.h" #include "channel.h" #include "device.h" #include "rf.h" diff --git a/drivers/staging/vt6655/country.h b/drivers/staging/vt6655/country.h deleted file mode 100644 index 2365fb13b033..000000000000 --- a/drivers/staging/vt6655/country.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: country.h - * - * Purpose: Country Code information - * - * Author: Lucas Lin - * - * Date: Dec 23, 2004 - * - */ - -#ifndef __COUNTRY_H__ -#define __COUNTRY_H__ - -#include "ttype.h" - -/************************************************************************ - * The definition here should be complied with the INF country order - * Please check with VNWL.inf/VNWL64.inf/VNWL*.inf - ************************************************************************/ -typedef enum _COUNTRY_CODE { - CCODE_FCC = 0, - CCODE_TELEC, - CCODE_ETSI, - CCODE_RESV3, - CCODE_RESV4, - CCODE_RESV5, - CCODE_RESV6, - CCODE_RESV7, - CCODE_RESV8, - CCODE_RESV9, - CCODE_RESVa, - CCODE_RESVb, - CCODE_RESVc, - CCODE_RESVd, - CCODE_RESVe, - CCODE_ALLBAND, - CCODE_ALBANIA, - CCODE_ALGERIA, - CCODE_ARGENTINA, - CCODE_ARMENIA, - CCODE_AUSTRALIA, - CCODE_AUSTRIA, - CCODE_AZERBAIJAN, - CCODE_BAHRAIN, - CCODE_BELARUS, - CCODE_BELGIUM, - CCODE_BELIZE, - CCODE_BOLIVIA, - CCODE_BRAZIL, - CCODE_BRUNEI_DARUSSALAM, - CCODE_BULGARIA, - CCODE_CANADA, - CCODE_CHILE, - CCODE_CHINA, - CCODE_COLOMBIA, - CCODE_COSTA_RICA, - CCODE_CROATIA, - CCODE_CYPRUS, - CCODE_CZECH, - CCODE_DENMARK, - CCODE_DOMINICAN_REPUBLIC, - CCODE_ECUADOR, - CCODE_EGYPT, - CCODE_EL_SALVADOR, - CCODE_ESTONIA, - CCODE_FINLAND, - CCODE_FRANCE, - CCODE_GERMANY, - CCODE_GREECE, - CCODE_GEORGIA, - CCODE_GUATEMALA, - CCODE_HONDURAS, - CCODE_HONG_KONG, - CCODE_HUNGARY, - CCODE_ICELAND, - CCODE_INDIA, - CCODE_INDONESIA, - CCODE_IRAN, - CCODE_IRELAND, - CCODE_ITALY, - CCODE_ISRAEL, - CCODE_JAPAN, - CCODE_JORDAN, - CCODE_KAZAKHSTAN, - CCODE_KUWAIT, - CCODE_LATVIA, - CCODE_LEBANON, - CCODE_LEICHTENSTEIN, - CCODE_LITHUANIA, - CCODE_LUXEMBURG, - CCODE_MACAU, - CCODE_MACEDONIA, - CCODE_MALTA, - CCODE_MALAYSIA, - CCODE_MEXICO, - CCODE_MONACO, - CCODE_MOROCCO, - CCODE_NETHERLANDS, - CCODE_NEW_ZEALAND, - CCODE_NORTH_KOREA, - CCODE_NORWAY, - CCODE_OMAN, - CCODE_PAKISTAN, - CCODE_PANAMA, - CCODE_PERU, - CCODE_PHILIPPINES, - CCODE_POLAND, - CCODE_PORTUGAL, - CCODE_PUERTO_RICO, - CCODE_QATAR, - CCODE_ROMANIA, - CCODE_RUSSIA, - CCODE_SAUDI_ARABIA, - CCODE_SINGAPORE, - CCODE_SLOVAKIA, - CCODE_SLOVENIA, - CCODE_SOUTH_AFRICA, - CCODE_SOUTH_KOREA, - CCODE_SPAIN, - CCODE_SWEDEN, - CCODE_SWITZERLAND, - CCODE_SYRIA, - CCODE_TAIWAN, - CCODE_THAILAND, - CCODE_TRINIDAD_TOBAGO, - CCODE_TUNISIA, - CCODE_TURKEY, - CCODE_UK, - CCODE_UKRAINE, - CCODE_UNITED_ARAB_EMIRATES, - CCODE_UNITED_STATES, - CCODE_URUGUAY, - CCODE_UZBEKISTAN, - CCODE_VENEZUELA, - CCODE_VIETNAM, - CCODE_YEMEN, - CCODE_ZIMBABWE, - CCODE_JAPAN_W52_W53, - CCODE_MAX -} COUNTRY_CODE; - -#endif /* __COUNTRY_H__ */ -- cgit v1.2.3-59-g8ed1b From 146761058f63d8530d150bef00c1d3daaa53dbba Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:55:59 +0000 Subject: staging: vt6655: struct vnt_private remove dead members Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 153 +--------------------------------------- 1 file changed, 1 insertion(+), 152 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 1816f3c2a502..bc33b2d8de4e 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -317,8 +317,6 @@ struct vnt_private { u16 current_aid; int mc_list_count; u8 mac_hw; -/* netdev */ - struct net_device *dev; /* dma addr, rx/tx pool */ dma_addr_t pool_dma; @@ -378,10 +376,6 @@ struct vnt_private { u8 rx_rate; int multicast_limit; - pid_t MLMEThr_pid; - struct completion notify; - struct semaphore mlme_semaphore; - u32 rx_bytes; /* Version control */ @@ -392,7 +386,7 @@ struct vnt_private { unsigned char byZoneType; bool bZoneRegExist; unsigned char byOriginalZonetype; - unsigned char abyMacContext[MAC_MAX_CONTEXT_REG]; + unsigned char abyCurrentNetAddr[ETH_ALEN]; bool bLinkPass; /* link status: OK or fail */ @@ -453,14 +447,6 @@ struct vnt_private { unsigned char byOpMode; bool bBSSIDFilter; unsigned short wMaxTransmitMSDULifetime; - unsigned char abyBSSID[ETH_ALEN]; - unsigned char abyDesireBSSID[ETH_ALEN]; - unsigned short wACKDuration; /* update while speed change */ - unsigned short wRTSTransmitLen; /* update while speed change */ - unsigned char byRTSServiceField; /* update while speed change */ - unsigned char byRTSSignalField; /* update while speed change */ - - unsigned long dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ bool bEncryptionEnable; bool bLongHeader; @@ -469,9 +455,6 @@ struct vnt_private { bool bNonERPPresent; bool bBarkerPreambleMd; - unsigned char byERPFlag; - unsigned short wUseProtectCntDown; - bool bRadioControlOff; bool bRadioOff; bool bEnablePSMode; @@ -494,61 +477,11 @@ struct vnt_private { unsigned int cbBeaconBufReadySetCnt; bool bFixRate; unsigned char byCurrentCh; - unsigned int uScanTime; - - bool bBeaconTx; - - bool bStopBeacon; - bool bStopDataPkt; - bool bStopTx0Pkt; - unsigned int uAutoReConnectTime; - - /* 802.11 counter */ - - unsigned int uCmdDequeueIdx; - unsigned int uCmdEnqueueIdx; - unsigned int cbFreeCmdQueue; - bool bCmdRunning; - bool bCmdClear; - - bool bRoaming; - unsigned char abyIPAddr[4]; - - unsigned long ulTxPower; - NDIS_802_11_WEP_STATUS eEncryptionStatus; - bool bTransmitKey; - NDIS_802_11_WEP_STATUS eOldEncryptionStatus; - - unsigned long dwIVCounter; - - u64 qwPacketNumber; /* For CCMP and TKIP as TSC(6 bytes) */ - unsigned int uCurrentWEPMode; - - unsigned char abyPRNG[WLAN_WEPMAX_KEYLEN+3]; - unsigned char byKeyIndex; - unsigned int uKeyLength; - unsigned char abyKey[WLAN_WEP232_KEYLEN]; bool bAES; - unsigned char byCntMeasure; - - /* for AP mode */ - unsigned int uAssocCount; - bool bMoreData; - - /* QoS */ - bool bGrpAckPolicy; - - /* for OID_802_11_ASSOCIATION_INFORMATION */ - bool bAssocInfoSet; unsigned char byAutoFBCtrl; - bool bTxMICFail; - bool bRxMICFail; - - unsigned int uRATEIdx; - /* For Update BaseBand VGA Gain Offset */ bool bUpdateBBVGA; unsigned int uBBVGADiffCount; @@ -560,22 +493,11 @@ struct vnt_private { unsigned char byBBPreEDRSSI; unsigned char byBBPreEDIndex; - bool bRadioCmd; unsigned long dwDiagRefCount; /* For FOE Tuning */ unsigned char byFOETuning; - /* For Auto Power Tunning */ - unsigned char byAutoPwrTunning; - short sPSetPointCCK; - short sPSetPointOFDMG; - short sPSetPointOFDMA; - long lPFormulaOffset; - short sPThreshold; - char cAdjustStep; - char cMinTxAGC; - /* For RF Power table */ unsigned char byCCKPwr; unsigned char byOFDMPwrG; @@ -594,21 +516,6 @@ struct vnt_private { unsigned char byBBCR88; unsigned char byBBCR09; - /* command timer */ - struct timer_list sTimerCommand; - struct timer_list sTimerTxData; - unsigned long nTxDataTimeCout; - bool fTxDataInSleep; - bool IsTxDataTrigger; - -#ifdef WPA_SM_Transtatus - bool fWPA_Authened; /* is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */ -#endif - unsigned char byReAssocCount; - unsigned char byLinkWaitCount; - - unsigned char abyNodeName[17]; - bool bDiversityRegCtlON; bool bDiversityEnable; unsigned long ulDiversityNValue; @@ -639,72 +546,14 @@ struct vnt_private { /* for 802.11h */ bool b11hEnable; - unsigned char abyCountryCode[3]; - /* for 802.11h DFS */ - unsigned int uNumOfMeasureEIDs; - bool bMeasureInProgress; - unsigned char byOrgChannel; - unsigned char byOrgRCR; - unsigned long dwOrgMAR0; - unsigned long dwOrgMAR4; - unsigned char byBasicMap; - unsigned char byCCAFraction; - unsigned char abyRPIs[8]; - unsigned long dwRPIs[8]; - bool bChannelSwitch; - unsigned char byNewChannel; - unsigned char byChannelSwitchCount; - bool bQuietEnable; - bool bEnableFirstQuiet; - unsigned char byQuietStartCount; - unsigned int uQuietEnqueue; - unsigned long dwCurrentQuietEndTime; - SQuietControl sQuiet[MAX_QUIET_COUNT]; - /* for 802.11h TPC */ - bool bCountryInfo5G; - bool bCountryInfo24G; unsigned short wBeaconInterval; - /* WPA supplicant deamon */ - struct net_device *wpadev; - bool bWPADEVUp; - struct sk_buff *skb; -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - unsigned int bwextcount; - bool bWPASuppWextEnabled; -#endif - -#ifdef HOSTAP - /* user space daemon: hostapd, is used for HOSTAP */ - bool bEnableHostapd; - bool bEnable8021x; - bool bEnableHostWEP; - struct net_device *apdev; - int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); -#endif unsigned int uChannel; - bool bMACSuspend; struct iw_statistics wstats; /* wireless stats */ - bool bCommit; }; -static inline bool device_get_ip(struct vnt_private *pInfo) -{ - struct in_device *in_dev = (struct in_device *)pInfo->dev->ip_ptr; - struct in_ifaddr *ifa; - - if (in_dev != NULL) { - ifa = (struct in_ifaddr *)in_dev->ifa_list; - if (ifa != NULL) { - memcpy(pInfo->abyIPAddr, &ifa->ifa_address, 4); - return true; - } - } - return false; -} - static inline PDEVICE_RD_INFO alloc_rd_info(void) { return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC); -- cgit v1.2.3-59-g8ed1b From 9c644a05c67d276e0cf2b7985b312cd64bbab92d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:00 +0000 Subject: staging: vt6655: device.h remove dead strutures and macros Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 76 ----------------------------------------- 1 file changed, 76 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index bc33b2d8de4e..79c4ae02832c 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -147,16 +147,6 @@ #define NUM 64 -#define PRIVATE_Message 0 - -/*--------------------- Export Types ------------------------------*/ - -#define PRINT_K(p, args...) \ -do { \ - if (PRIVATE_Message) \ - printk(p, ##args); \ -} while (0) - /* 0:11A 1:11B 2:11G */ typedef enum _VIA_BB_TYPE { @@ -174,57 +164,6 @@ typedef enum _VIA_PKT_TYPE PK_TYPE_11GA } VIA_PKT_TYPE, *PVIA_PKT_TYPE; -typedef enum __device_msg_level { - MSG_LEVEL_ERR = 0, /* Errors that will cause abnormal operation. */ - MSG_LEVEL_NOTICE = 1, /* Some errors need users to be notified. */ - MSG_LEVEL_INFO = 2, /* Normal message. */ - MSG_LEVEL_VERBOSE = 3, /* Will report all trival errors. */ - MSG_LEVEL_DEBUG = 4 /* Only for debug purpose. */ -} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL; - -/* NDIS related */ -#define MAX_BSSIDINFO_4_PMKID 16 -#define MAX_PMKIDLIST 5 -/* Flags for PMKID Candidate list structure */ -#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01 - -/* PMKID Structures */ -typedef unsigned char NDIS_802_11_PMKID_VALUE[16]; - -typedef enum _NDIS_802_11_WEP_STATUS { - Ndis802_11WEPEnabled, - Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled, - Ndis802_11WEPDisabled, - Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled, - Ndis802_11WEPKeyAbsent, - Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent, - Ndis802_11WEPNotSupported, - Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported, - Ndis802_11Encryption2Enabled, - Ndis802_11Encryption2KeyAbsent, - Ndis802_11Encryption3Enabled, - Ndis802_11Encryption3KeyAbsent -} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS, - NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS; - -typedef enum _NDIS_802_11_STATUS_TYPE { - Ndis802_11StatusType_Authentication, - Ndis802_11StatusType_MediaStreamMode, - Ndis802_11StatusType_PMKID_CandidateList, - Ndis802_11StatusTypeMax /* defined as an upper bound */ -} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE; - - -/* 802.11h related */ -#define MAX_QUIET_COUNT 8 - -typedef struct tagSQuietControl { - bool bEnable; - unsigned long dwStartTime; - unsigned char byPeriod; - unsigned short wDuration; -} SQuietControl, *PSQuietControl; - typedef struct __chip_info_tbl { CHIP_TYPE chip_id; char *name; @@ -238,20 +177,6 @@ typedef enum { OWNED_BY_NIC = 1 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE; -/* The receive duplicate detection cache entry */ -typedef struct tagSCacheEntry { - unsigned short wFmSequence; - unsigned char abyAddr2[ETH_ALEN]; -} SCacheEntry, *PSCacheEntry; - -typedef struct tagSCache { -/* The receive cache is updated circularly. The next entry to be written is - * indexed by the "InPtr". - */ - unsigned int uInPtr; /* Place to use next */ - SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH]; -} SCache, *PSCache; - #define CB_MAX_RX_FRAG 64 /* DeFragment Control Block, used for collecting fragments prior to reassembly */ typedef struct tagSDeFragControlBlock { @@ -361,7 +286,6 @@ struct vnt_private { volatile PSRxDesc aRD0Ring; volatile PSRxDesc aRD1Ring; volatile PSRxDesc pCurrRD[TYPE_MAXRD]; - SCache sDupRxCache; SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; unsigned int cbDFCB; -- cgit v1.2.3-59-g8ed1b From dd46cf735d3c95c6f5996716e55934ed40ad4d01 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:01 +0000 Subject: staging: vt6655: dead code remove 80211hdr.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211hdr.h | 318 -------------------------------------- drivers/staging/vt6655/device.h | 1 - drivers/staging/vt6655/wmgr.h | 1 - 3 files changed, 320 deletions(-) delete mode 100644 drivers/staging/vt6655/80211hdr.h diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h deleted file mode 100644 index 36e14ec50564..000000000000 --- a/drivers/staging/vt6655/80211hdr.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: 80211hdr.h - * - * Purpose: 802.11 MAC headers related pre-defines and macros. - * - * - * Author: Lyndon Chen - * - * Date: Apr 8, 2002 - * - */ - -#ifndef __80211HDR_H__ -#define __80211HDR_H__ - -#include "ttype.h" - -/* bit type */ -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 - -/* 802.11 frame related, defined as 802.11 spec */ -#define WLAN_ADDR_LEN 6 -#define WLAN_CRC_LEN 4 -#define WLAN_CRC32_LEN 4 -#define WLAN_FCS_LEN 4 -#define WLAN_BSSID_LEN 6 -#define WLAN_BSS_TS_LEN 8 -#define WLAN_HDR_ADDR2_LEN 16 -#define WLAN_HDR_ADDR3_LEN 24 -#define WLAN_HDR_ADDR4_LEN 30 -#define WLAN_IEHDR_LEN 2 -#define WLAN_SSID_MAXLEN 32 -#define WLAN_RATES_MAXLEN 16 -#define WLAN_RATES_MAXLEN_11B 4 -#define WLAN_RSN_MAXLEN 32 -#define WLAN_DATA_MAXLEN 2312 -#define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + \ - WLAN_CRC_LEN) - -#define WLAN_BEACON_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0) -#define WLAN_NULLDATA_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0) -#define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2) -#define WLAN_ASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_ASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_REASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_REASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_PROBEREQ_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_PROBERESP_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_AUTHEN_FR_MAXLEN WLAN_A3FR_MAXLEN -#define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2) - -#define WLAN_WEP_NKEYS 4 -#define WLAN_WEP40_KEYLEN 5 -#define WLAN_WEP104_KEYLEN 13 -#define WLAN_WEP232_KEYLEN 29 -#define WLAN_WEPMAX_KEYLEN 32 -#define WLAN_CHALLENGE_IE_MAXLEN 255 -#define WLAN_CHALLENGE_IE_LEN 130 -#define WLAN_CHALLENGE_LEN 128 -#define WLAN_WEP_IV_LEN 4 -#define WLAN_WEP_ICV_LEN 4 -#define WLAN_FRAGS_MAX 16 - -/* Frame Type */ -#define WLAN_TYPE_MGR 0x00 -#define WLAN_TYPE_CTL 0x01 -#define WLAN_TYPE_DATA 0x02 - -#define WLAN_FTYPE_MGMT 0x00 -#define WLAN_FTYPE_CTL 0x01 -#define WLAN_FTYPE_DATA 0x02 - -/* Frame Subtypes */ -#define WLAN_FSTYPE_ASSOCREQ 0x00 -#define WLAN_FSTYPE_ASSOCRESP 0x01 -#define WLAN_FSTYPE_REASSOCREQ 0x02 -#define WLAN_FSTYPE_REASSOCRESP 0x03 -#define WLAN_FSTYPE_PROBEREQ 0x04 -#define WLAN_FSTYPE_PROBERESP 0x05 -#define WLAN_FSTYPE_BEACON 0x08 -#define WLAN_FSTYPE_ATIM 0x09 -#define WLAN_FSTYPE_DISASSOC 0x0a -#define WLAN_FSTYPE_AUTHEN 0x0b -#define WLAN_FSTYPE_DEAUTHEN 0x0c -#define WLAN_FSTYPE_ACTION 0x0d - -/* Control */ -#define WLAN_FSTYPE_PSPOLL 0x0a -#define WLAN_FSTYPE_RTS 0x0b -#define WLAN_FSTYPE_CTS 0x0c -#define WLAN_FSTYPE_ACK 0x0d -#define WLAN_FSTYPE_CFEND 0x0e -#define WLAN_FSTYPE_CFENDCFACK 0x0f - -/* Data */ -#define WLAN_FSTYPE_DATAONLY 0x00 -#define WLAN_FSTYPE_DATA_CFACK 0x01 -#define WLAN_FSTYPE_DATA_CFPOLL 0x02 -#define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03 -#define WLAN_FSTYPE_NULL 0x04 -#define WLAN_FSTYPE_CFACK 0x05 -#define WLAN_FSTYPE_CFPOLL 0x06 -#define WLAN_FSTYPE_CFACK_CFPOLL 0x07 - -#ifdef __BIG_ENDIAN - -/* GET & SET Frame Control bit */ -#define WLAN_GET_FC_PRVER(n) (((unsigned short)(n) >> 8) & (BIT0 | BIT1)) -#define WLAN_GET_FC_FTYPE(n) ((((unsigned short)(n) >> 8) & (BIT2 | BIT3)) >> 2) -#define WLAN_GET_FC_FSTYPE(n) ((((unsigned short)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4) -#define WLAN_GET_FC_TODS(n) ((((unsigned short)(n) << 8) & (BIT8)) >> 8) -#define WLAN_GET_FC_FROMDS(n) ((((unsigned short)(n) << 8) & (BIT9)) >> 9) -#define WLAN_GET_FC_MOREFRAG(n) ((((unsigned short)(n) << 8) & (BIT10)) >> 10) -#define WLAN_GET_FC_RETRY(n) ((((unsigned short)(n) << 8) & (BIT11)) >> 11) -#define WLAN_GET_FC_PWRMGT(n) ((((unsigned short)(n) << 8) & (BIT12)) >> 12) -#define WLAN_GET_FC_MOREDATA(n) ((((unsigned short)(n) << 8) & (BIT13)) >> 13) -#define WLAN_GET_FC_ISWEP(n) ((((unsigned short)(n) << 8) & (BIT14)) >> 14) -#define WLAN_GET_FC_ORDER(n) ((((unsigned short)(n) << 8) & (BIT15)) >> 15) - -/* Sequence Field bit */ -#define WLAN_GET_SEQ_FRGNUM(n) (((unsigned short)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3)) -#define WLAN_GET_SEQ_SEQNUM(n) ((((unsigned short)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) - -/* Capability Field bit */ -#define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0) -#define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1) -#define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2) -#define WLAN_GET_CAP_INFO_CFPOLLREQ(n) ((((n) >> 8) & BIT3) >> 3) -#define WLAN_GET_CAP_INFO_PRIVACY(n) ((((n) >> 8) & BIT4) >> 4) -#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5) -#define WLAN_GET_CAP_INFO_PBCC(n) ((((n) >> 8) & BIT6) >> 6) -#define WLAN_GET_CAP_INFO_AGILITY(n) ((((n) >> 8) & BIT7) >> 7) -#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) ((((n)) & BIT8) >> 10) -#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n)) & BIT10) >> 10) -#define WLAN_GET_CAP_INFO_DSSSOFDM(n) ((((n)) & BIT13) >> 13) -#define WLAN_GET_CAP_INFO_GRPACK(n) ((((n)) & BIT14) >> 14) - -#else - -/* GET & SET Frame Control bit */ -#define WLAN_GET_FC_PRVER(n) (((unsigned short)(n)) & (BIT0 | BIT1)) -#define WLAN_GET_FC_FTYPE(n) ((((unsigned short)(n)) & (BIT2 | BIT3)) >> 2) -#define WLAN_GET_FC_FSTYPE(n) ((((unsigned short)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4) -#define WLAN_GET_FC_TODS(n) ((((unsigned short)(n)) & (BIT8)) >> 8) -#define WLAN_GET_FC_FROMDS(n) ((((unsigned short)(n)) & (BIT9)) >> 9) -#define WLAN_GET_FC_MOREFRAG(n) ((((unsigned short)(n)) & (BIT10)) >> 10) -#define WLAN_GET_FC_RETRY(n) ((((unsigned short)(n)) & (BIT11)) >> 11) -#define WLAN_GET_FC_PWRMGT(n) ((((unsigned short)(n)) & (BIT12)) >> 12) -#define WLAN_GET_FC_MOREDATA(n) ((((unsigned short)(n)) & (BIT13)) >> 13) -#define WLAN_GET_FC_ISWEP(n) ((((unsigned short)(n)) & (BIT14)) >> 14) -#define WLAN_GET_FC_ORDER(n) ((((unsigned short)(n)) & (BIT15)) >> 15) - -/* Sequence Field bit */ -#define WLAN_GET_SEQ_FRGNUM(n) (((unsigned short)(n)) & (BIT0|BIT1|BIT2|BIT3)) -#define WLAN_GET_SEQ_SEQNUM(n) ((((unsigned short)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) - -/* Capability Field bit */ -#define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0) -#define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1) -#define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2) -#define WLAN_GET_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3) -#define WLAN_GET_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4) -#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5) -#define WLAN_GET_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6) -#define WLAN_GET_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7) -#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) (((n) & BIT8) >> 10) -#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10) -#define WLAN_GET_CAP_INFO_DSSSOFDM(n) (((n) & BIT13) >> 13) -#define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14) - -#endif /*#ifdef __BIG_ENDIAN */ - -#define WLAN_SET_CAP_INFO_ESS(n) (n) -#define WLAN_SET_CAP_INFO_IBSS(n) ((n) << 1) -#define WLAN_SET_CAP_INFO_CFPOLLABLE(n) ((n) << 2) -#define WLAN_SET_CAP_INFO_CFPOLLREQ(n) ((n) << 3) -#define WLAN_SET_CAP_INFO_PRIVACY(n) ((n) << 4) -#define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5) -#define WLAN_SET_CAP_INFO_SPECTRUMMNG(n) ((n) << 8) -#define WLAN_SET_CAP_INFO_PBCC(n) ((n) << 6) -#define WLAN_SET_CAP_INFO_AGILITY(n) ((n) << 7) -#define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10) -#define WLAN_SET_CAP_INFO_DSSSOFDM(n) ((n) << 13) -#define WLAN_SET_CAP_INFO_GRPACK(n) ((n) << 14) - -#define WLAN_SET_FC_PRVER(n) ((unsigned short)(n)) -#define WLAN_SET_FC_FTYPE(n) (((unsigned short)(n)) << 2) -#define WLAN_SET_FC_FSTYPE(n) (((unsigned short)(n)) << 4) -#define WLAN_SET_FC_TODS(n) (((unsigned short)(n)) << 8) -#define WLAN_SET_FC_FROMDS(n) (((unsigned short)(n)) << 9) -#define WLAN_SET_FC_MOREFRAG(n) (((unsigned short)(n)) << 10) -#define WLAN_SET_FC_RETRY(n) (((unsigned short)(n)) << 11) -#define WLAN_SET_FC_PWRMGT(n) (((unsigned short)(n)) << 12) -#define WLAN_SET_FC_MOREDATA(n) (((unsigned short)(n)) << 13) -#define WLAN_SET_FC_ISWEP(n) (((unsigned short)(n)) << 14) -#define WLAN_SET_FC_ORDER(n) (((unsigned short)(n)) << 15) - -#define WLAN_SET_SEQ_FRGNUM(n) ((unsigned short)(n)) -#define WLAN_SET_SEQ_SEQNUM(n) (((unsigned short)(n)) << 4) - -/* ERP Field bit */ - -#define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0) -#define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1) -#define WLAN_GET_ERP_BARKER_MODE(n) (((n) & BIT2) >> 2) - -#define WLAN_SET_ERP_NONERP_PRESENT(n) (n) -#define WLAN_SET_ERP_USE_PROTECTION(n) ((n) << 1) -#define WLAN_SET_ERP_BARKER_MODE(n) ((n) << 2) - -/* Support & Basic Rates field */ -#define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7) -#define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7) - -/* TIM field */ -#define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0) -#define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1) - -/* 3-Addr & 4-Addr */ -#define WLAN_HDR_A3_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR3_LEN) -#define WLAN_HDR_A4_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR4_LEN) - -/* IEEE ADDR */ -#define IEEE_ADDR_UNIVERSAL 0x02 -#define IEEE_ADDR_GROUP 0x01 - -typedef struct { - unsigned char abyAddr[6]; -} IEEE_ADDR, *PIEEE_ADDR; - -/* 802.11 Header Format */ - -typedef struct tagWLAN_80211HDR_A2 { - unsigned short wFrameCtl; - unsigned short wDurationID; - unsigned char abyAddr1[WLAN_ADDR_LEN]; - unsigned char abyAddr2[WLAN_ADDR_LEN]; -} __attribute__ ((__packed__)) -WLAN_80211HDR_A2, *PWLAN_80211HDR_A2; - -typedef struct tagWLAN_80211HDR_A3 { - unsigned short wFrameCtl; - unsigned short wDurationID; - unsigned char abyAddr1[WLAN_ADDR_LEN]; - unsigned char abyAddr2[WLAN_ADDR_LEN]; - unsigned char abyAddr3[WLAN_ADDR_LEN]; - unsigned short wSeqCtl; -} __attribute__ ((__packed__)) -WLAN_80211HDR_A3, *PWLAN_80211HDR_A3; - -typedef struct tagWLAN_80211HDR_A4 { - unsigned short wFrameCtl; - unsigned short wDurationID; - unsigned char abyAddr1[WLAN_ADDR_LEN]; - unsigned char abyAddr2[WLAN_ADDR_LEN]; - unsigned char abyAddr3[WLAN_ADDR_LEN]; - unsigned short wSeqCtl; - unsigned char abyAddr4[WLAN_ADDR_LEN]; -} __attribute__ ((__packed__)) -WLAN_80211HDR_A4, *PWLAN_80211HDR_A4; - -typedef union tagUWLAN_80211HDR { - WLAN_80211HDR_A2 sA2; - WLAN_80211HDR_A3 sA3; - WLAN_80211HDR_A4 sA4; -} UWLAN_80211HDR, *PUWLAN_80211HDR; - -#endif /* __80211HDR_H__ */ diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 79c4ae02832c..e0c40690a3eb 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -68,7 +68,6 @@ #include "device_cfg.h" #include "ttype.h" -#include "80211hdr.h" #include "wmgr.h" #include "mib.h" #include "srom.h" diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 44976e0200bb..8f9748bf569d 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -35,7 +35,6 @@ #define __WMGR_H__ #include "ttype.h" -#include "80211hdr.h" #include "card.h" /*--------------------- Export Definitions -------------------------*/ -- cgit v1.2.3-59-g8ed1b From e11cdc39f381e541fbdc2eccf2c4fce910a4f2bb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:02 +0000 Subject: staging: vt6655: remove typedef void *TimerFunction Covert functions TimerSQ3CallBack and TimerState1CallBack to the correct type for struct timer_list.function to remove the cast altogether. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 8 ++++---- drivers/staging/vt6655/baseband.h | 4 ++-- drivers/staging/vt6655/device_main.c | 6 +++--- drivers/staging/vt6655/wmgr.h | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index ed7850558c96..b04dfd945d41 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2781,10 +2781,10 @@ void BBvAntennaDiversity(struct vnt_private *pDevice, void TimerSQ3CallBack( - void *hDeviceContext + unsigned long data ) { - struct vnt_private *pDevice = hDeviceContext; + struct vnt_private *pDevice = (struct vnt_private *)data; unsigned long flags; pr_debug("TimerSQ3CallBack...\n"); @@ -2827,10 +2827,10 @@ TimerSQ3CallBack( void TimerState1CallBack( - void *hDeviceContext + unsigned long data ) { - struct vnt_private *pDevice = hDeviceContext; + struct vnt_private *pDevice = (struct vnt_private *)data; unsigned long flags; pr_debug("TimerState1CallBack...\n"); diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 2d7a3e236fd6..772ea0df84e2 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -103,12 +103,12 @@ void BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID); void TimerSQ3CallBack( - void *hDeviceContext + unsigned long ); void TimerState1CallBack( - void *hDeviceContext + unsigned long ); void BBvAntennaDiversity(struct vnt_private *pDevice, diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 7892f861521e..5c91c2ff1491 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -625,17 +625,17 @@ static void device_init_diversity_timer(struct vnt_private *pDevice) { init_timer(&pDevice->TimerSQ3Tmax1); pDevice->TimerSQ3Tmax1.data = (unsigned long) pDevice; - pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack; + pDevice->TimerSQ3Tmax1.function = TimerSQ3CallBack; pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ); init_timer(&pDevice->TimerSQ3Tmax2); pDevice->TimerSQ3Tmax2.data = (unsigned long) pDevice; - pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack; + pDevice->TimerSQ3Tmax2.function = TimerSQ3CallBack; pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ); init_timer(&pDevice->TimerSQ3Tmax3); pDevice->TimerSQ3Tmax3.data = (unsigned long) pDevice; - pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerState1CallBack; + pDevice->TimerSQ3Tmax3.function = TimerState1CallBack; pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ); } diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 8f9748bf569d..74f1f16b915e 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -72,6 +72,5 @@ /*--------------------- Export Types ------------------------------*/ #define timer_expire(timer, next_tick) mod_timer(&timer, RUN_AT(next_tick)) -typedef void (*TimerFunction)(unsigned long); #endif // __WMGR_H__ -- cgit v1.2.3-59-g8ed1b From 1903e6dd0552d15a39664d71e4ebb9f0769969cc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:03 +0000 Subject: staging: vt6655: Move LIFETIME RES 64us macros to rxtx.h Used only by vnt_generate_fifo_header move these macros. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.h | 4 ++++ drivers/staging/vt6655/wmgr.h | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index 50d77a0f88ea..cf0dfa6f0a07 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -32,6 +32,10 @@ #include "ttype.h" #include "device.h" +#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 /* 64us */ +#define DEFAULT_MGN_LIFETIME_RES_64us 125 /* 64us */ + + /*--------------------- Export Definitions -------------------------*/ /*--------------------- Export Variables --------------------------*/ diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 74f1f16b915e..daf996cc9f27 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -51,10 +51,8 @@ #define WCMD_PASSIVE_SCAN_TIME 100 //(ms) #define DEFAULT_MSDU_LIFETIME 512 // ms -#define DEFAULT_MSDU_LIFETIME_RES_64us 8000 // 64us #define DEFAULT_MGN_LIFETIME 8 // ms -#define DEFAULT_MGN_LIFETIME_RES_64us 125 // 64us #define MAKE_BEACON_RESERVED 10 //(us) -- cgit v1.2.3-59-g8ed1b From c3fb46429be7d1dcbb0f3fc0c7a73cfb2b18c6cb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:04 +0000 Subject: staging: vt6655: move MAKE_BEACON_RESERVED to device.h Used only in function device_intr in device_main.c move macro. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 ++ drivers/staging/vt6655/wmgr.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index e0c40690a3eb..45181a8b8a86 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -137,6 +137,8 @@ #define RUN_AT(x) (jiffies+(x)) #endif +#define MAKE_BEACON_RESERVED 10 /* (us) */ + /* DMA related */ #define RESERV_AC0DMA 4 diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index daf996cc9f27..ea23c7902646 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -54,8 +54,6 @@ #define DEFAULT_MGN_LIFETIME 8 // ms -#define MAKE_BEACON_RESERVED 10 //(us) - #define TIM_MULTICAST_MASK 0x01 #define TIM_BITMAPOFFSET_MASK 0xFE #define DEFAULT_DTIM_PERIOD 1 -- cgit v1.2.3-59-g8ed1b From 33785983ca3364bafc1c1ec805560ff83c9fdb0c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:05 +0000 Subject: staging: vt6655: dead code remove wmgr.h on removal needs to be replaced by card.h in device.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 +- drivers/staging/vt6655/device_main.c | 1 - drivers/staging/vt6655/power.c | 1 - drivers/staging/vt6655/wmgr.h | 72 ------------------------------------ 4 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 drivers/staging/vt6655/wmgr.h diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 45181a8b8a86..d0855bd3937f 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -68,7 +68,7 @@ #include "device_cfg.h" #include "ttype.h" -#include "wmgr.h" +#include "card.h" #include "mib.h" #include "srom.h" #include "desc.h" diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 5c91c2ff1491..f0b336bb393d 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -58,7 +58,6 @@ #include "channel.h" #include "baseband.h" #include "mac.h" -#include "wmgr.h" #include "power.h" #include "rxtx.h" #include "dpc.h" diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 6f83650db5a3..a8aedee18b6b 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -40,7 +40,6 @@ #include "ttype.h" #include "mac.h" #include "device.h" -#include "wmgr.h" #include "power.h" #include "card.h" diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h deleted file mode 100644 index ea23c7902646..000000000000 --- a/drivers/staging/vt6655/wmgr.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: wmgr.h - * - * Purpose: - * - * Author: lyndon chen - * - * Date: Jan 2, 2003 - * - * Functions: - * - * Revision History: - * - */ - -#ifndef __WMGR_H__ -#define __WMGR_H__ - -#include "ttype.h" -#include "card.h" - -/*--------------------- Export Definitions -------------------------*/ - -// Scan time -#define PROBE_DELAY 100 // (us) -#define SWITCH_CHANNEL_DELAY 200 // (us) -#define WLAN_SCAN_MINITIME 25 // (ms) -#define WLAN_SCAN_MAXTIME 100 // (ms) -#define TRIVIAL_SYNC_DIFFERENCE 0 // (us) -#define DEFAULT_IBSS_BI 100 // (ms) - -#define WCMD_ACTIVE_SCAN_TIME 50 //(ms) -#define WCMD_PASSIVE_SCAN_TIME 100 //(ms) - -#define DEFAULT_MSDU_LIFETIME 512 // ms - -#define DEFAULT_MGN_LIFETIME 8 // ms - -#define TIM_MULTICAST_MASK 0x01 -#define TIM_BITMAPOFFSET_MASK 0xFE -#define DEFAULT_DTIM_PERIOD 1 - -#define AP_LONG_RETRY_LIMIT 4 - -#define DEFAULT_IBSS_CHANNEL 6 //2.4G - -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Types ------------------------------*/ -#define timer_expire(timer, next_tick) mod_timer(&timer, RUN_AT(next_tick)) - -#endif // __WMGR_H__ -- cgit v1.2.3-59-g8ed1b From 0fbdd5ca6f83ca4c60f797b9900c3eb61386ae3a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 29 Oct 2014 17:56:06 +0000 Subject: staging: vt6655: dead code remove header type.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.h | 1 - drivers/staging/vt6655/card.h | 1 - drivers/staging/vt6655/channel.h | 1 - drivers/staging/vt6655/desc.h | 1 - drivers/staging/vt6655/device.h | 1 - drivers/staging/vt6655/device_cfg.h | 2 -- drivers/staging/vt6655/key.h | 2 -- drivers/staging/vt6655/mac.h | 1 - drivers/staging/vt6655/mib.h | 1 - drivers/staging/vt6655/power.c | 1 - drivers/staging/vt6655/rf.h | 1 - drivers/staging/vt6655/rxtx.h | 1 - drivers/staging/vt6655/srom.h | 2 -- drivers/staging/vt6655/tmacro.h | 2 -- drivers/staging/vt6655/ttype.h | 42 ------------------------------------- drivers/staging/vt6655/upc.h | 1 - 16 files changed, 61 deletions(-) delete mode 100644 drivers/staging/vt6655/ttype.h diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 772ea0df84e2..bfdd422c490f 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -30,7 +30,6 @@ #ifndef __BASEBAND_H__ #define __BASEBAND_H__ -#include "ttype.h" #include "device.h" /* diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index fa1e692ca8a0..f12afefd7fd8 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -29,7 +29,6 @@ #ifndef __CARD_H__ #define __CARD_H__ -#include "ttype.h" #include #include diff --git a/drivers/staging/vt6655/channel.h b/drivers/staging/vt6655/channel.h index ee00f4e3d52f..4f4264e23462 100644 --- a/drivers/staging/vt6655/channel.h +++ b/drivers/staging/vt6655/channel.h @@ -23,7 +23,6 @@ #ifndef _CHANNEL_H_ #define _CHANNEL_H_ -#include "ttype.h" #include "card.h" void vnt_init_bands(struct vnt_private *); diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index 32dd1cab7dcf..758eeb2afd51 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -34,7 +34,6 @@ #include #include #include "linux/ieee80211.h" -#include "ttype.h" #define B_OWNED_BY_CHIP 1 #define B_OWNED_BY_HOST 0 diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index d0855bd3937f..93d2ccb9ba67 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -67,7 +67,6 @@ /* device specific */ #include "device_cfg.h" -#include "ttype.h" #include "card.h" #include "mib.h" #include "srom.h" diff --git a/drivers/staging/vt6655/device_cfg.h b/drivers/staging/vt6655/device_cfg.h index 7221824e4f23..a4a8a8489e0b 100644 --- a/drivers/staging/vt6655/device_cfg.h +++ b/drivers/staging/vt6655/device_cfg.h @@ -29,8 +29,6 @@ #include -#include "ttype.h" - typedef struct _version { unsigned char major; diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 5615f397f6e7..c01d4afb6ab8 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -32,8 +32,6 @@ #include -#include "ttype.h" - /*--------------------- Export Definitions -------------------------*/ #define MAX_GROUP_KEY 4 #define MAX_KEY_TABLE 11 diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 0bf93759b6af..5391277a1a19 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -34,7 +34,6 @@ #ifndef __MAC_H__ #define __MAC_H__ -#include "ttype.h" #include "tmacro.h" #include "upc.h" diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index a2e6106b4570..5cb59b8a1c7c 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -29,7 +29,6 @@ #ifndef __MIB_H__ #define __MIB_H__ -#include "ttype.h" #include "desc.h" // diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index a8aedee18b6b..e826f07e91c0 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -37,7 +37,6 @@ * */ -#include "ttype.h" #include "mac.h" #include "device.h" #include "power.h" diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index be4ef88b7666..e8a7372e5483 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -30,7 +30,6 @@ #ifndef __RF_H__ #define __RF_H__ -#include "ttype.h" #include "device.h" /*--------------------- Export Definitions -------------------------*/ diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index cf0dfa6f0a07..b9bd1639b13e 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -29,7 +29,6 @@ #ifndef __RXTX_H__ #define __RXTX_H__ -#include "ttype.h" #include "device.h" #define DEFAULT_MSDU_LIFETIME_RES_64us 8000 /* 64us */ diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index 3128e535bbd8..9f309c401770 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -30,8 +30,6 @@ #ifndef __SROM_H__ #define __SROM_H__ -#include "ttype.h" - /*--------------------- Export Definitions -------------------------*/ #define EEP_MAX_CONTEXT_SIZE 256 diff --git a/drivers/staging/vt6655/tmacro.h b/drivers/staging/vt6655/tmacro.h index 59c6e72f993a..607b78f7a6a0 100644 --- a/drivers/staging/vt6655/tmacro.h +++ b/drivers/staging/vt6655/tmacro.h @@ -29,8 +29,6 @@ #ifndef __TMACRO_H__ #define __TMACRO_H__ -#include "ttype.h" - /****** Common helper macros ***********************************************/ #if !defined(LOBYTE) diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h deleted file mode 100644 index 747ef62ec9be..000000000000 --- a/drivers/staging/vt6655/ttype.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: ttype.h - * - * Purpose: define basic common types and macros - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - */ - -#ifndef __TTYPE_H__ -#define __TTYPE_H__ - -/******* Common definitions and typedefs ***********************************/ - -#ifndef WPA_SM_Transtatus -#define WPA_SM_Transtatus -#endif - -#ifndef Calcu_LinkQual -#define Calcu_LinkQual -#endif - -#endif // __TTYPE_H__ diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h index c5c889cade25..c53703a772f5 100644 --- a/drivers/staging/vt6655/upc.h +++ b/drivers/staging/vt6655/upc.h @@ -30,7 +30,6 @@ #define __UPC_H__ #include "device.h" -#include "ttype.h" /*--------------------- Export Definitions -------------------------*/ -- cgit v1.2.3-59-g8ed1b From 92be2d4d3ca4a086d295ddd5339587e675d46c0c Mon Sep 17 00:00:00 2001 From: Brian Vandre Date: Wed, 29 Oct 2014 07:02:23 -0500 Subject: Staging: xgifb: fix space before comma This fixes the checkpatch.pl error: ERROR: space prohibited before that ',' Signed-off-by: Brian Vandre Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index be7778b59118..709d49e7f3c9 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -2012,7 +2012,7 @@ static int xgifb_probe(struct pci_dev *pdev, XGIfb_get_fix(&fb_info->fix, -1, fb_info); fb_info->pseudo_palette = xgifb_info->pseudo_palette; - fb_alloc_cmap(&fb_info->cmap, 256 , 0); + fb_alloc_cmap(&fb_info->cmap, 256, 0); #ifdef CONFIG_MTRR xgifb_info->mtrr = mtrr_add(xgifb_info->video_base, -- cgit v1.2.3-59-g8ed1b From c65a5a562e3b55297767a4022543867e01a66080 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Wed, 29 Oct 2014 19:30:41 +0530 Subject: Staging: rtl8192e: Revert one previous commit This patch reverts commit 450246465a76 ("Staging: rtl8192e: Fix incorrect type in assignment in rtl819x_BAProc.c") as it is changing code and introducing bug to skip the endian conversion. Here, tmp variable is used to hold the endian-corrected values and network-data requires fixed endianness. Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 6da57847a533..946c1dc25de5 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -115,14 +115,14 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, if (ACT_ADDBARSP == type) { RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); - tmp = StatusCode; + tmp = cpu_to_le16(StatusCode); memcpy(tag, (u8 *)&tmp, 2); tag += 2; } - tmp = pBA->BaParamSet.shortData; + tmp = cpu_to_le16(pBA->BaParamSet.shortData); memcpy(tag, (u8 *)&tmp, 2); tag += 2; - tmp = pBA->BaTimeoutValue; + tmp = cpu_to_le16(pBA->BaTimeoutValue); memcpy(tag, (u8 *)&tmp, 2); tag += 2; @@ -178,10 +178,10 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, *tag++ = ACT_CAT_BA; *tag++ = ACT_DELBA; - tmp = DelbaParamSet.shortData; + tmp = cpu_to_le16(DelbaParamSet.shortData); memcpy(tag, (u8 *)&tmp, 2); tag += 2; - tmp = ReasonCode; + tmp = cpu_to_le16(ReasonCode); memcpy(tag, (u8 *)&tmp, 2); tag += 2; -- cgit v1.2.3-59-g8ed1b From b32af401fc9d79b920eb6cf2a5747c8baa6fde5f Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Wed, 29 Oct 2014 19:30:51 +0530 Subject: Staging: rtl8192e: Change variable type from u16 to __le16 This patch changes declaration of variable tmp from u16 to __le16 in order to remove following sparse warning at number of places: warning: incorrect type in assignment (different base types) expected unsigned short [unsigned] [usertype] tmp got restricted __le16 [usertype] Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 946c1dc25de5..2866c1237ae5 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -79,7 +79,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, struct sk_buff *skb = NULL; struct rtllib_hdr_3addr *BAReq = NULL; u8 *tag = NULL; - u16 tmp = 0; + __le16 tmp = 0; u16 len = ieee->tx_headroom + 9; RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" @@ -143,7 +143,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, struct sk_buff *skb = NULL; struct rtllib_hdr_3addr *Delba = NULL; u8 *tag = NULL; - u16 tmp = 0; + __le16 tmp = 0; u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) -- cgit v1.2.3-59-g8ed1b From a58af1e1ce10b1a92221823aa8ab0de881d9a129 Mon Sep 17 00:00:00 2001 From: anuvazhayil Date: Thu, 30 Oct 2014 00:03:48 +0530 Subject: Staging: rtl8723au: rtw_cmd: Replace foo*bar to foo *bar Fixed the checkpatch.pl ERROR: "foo*bar" should be "foo *bar" Signed-off-by: anuvazhayil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index f80e81cd14e6..44eae8e6bd9d 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -601,7 +601,7 @@ exit: return res; } -int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms, +int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms, bool enqueue) { struct cmd_obj *cmdobj = NULL; @@ -789,7 +789,7 @@ exit: return res; } -int rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr) +int rtw_addbareq_cmd23a(struct rtw_adapter *padapter, u8 tid, u8 *addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_obj *ph2c; @@ -825,7 +825,7 @@ exit: return res; } -int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter*padapter) +int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter *padapter) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; @@ -862,7 +862,7 @@ exit: * This is only ever called from on_action_spct23a_ch_switch () which isn't * called from anywhere itself */ -int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, +int rtw_set_ch_cmd23a(struct rtw_adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue) { struct cmd_obj *pcmdobj; @@ -1100,7 +1100,7 @@ exit: return res; } -int rtw_ps_cmd23a(struct rtw_adapter*padapter) +int rtw_ps_cmd23a(struct rtw_adapter *padapter) { struct cmd_obj *ppscmd; struct drvextra_cmd_parm *pdrvextra_cmd_parm; @@ -1170,7 +1170,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) } } -int rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter) +int rtw_chk_hi_queue_cmd23a(struct rtw_adapter *padapter) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; -- cgit v1.2.3-59-g8ed1b From 0d20dac3775ea61443dd52a8cf9c55e60b48e3a3 Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Wed, 29 Oct 2014 21:29:56 +0200 Subject: staging: rtl8188eu: core: Removed unnecessary parenthesis. This patch removes unnecessarry parenthesis in rtw_security.c by using this coccinelle script: @r1@ expression e1,e2; @@ if - ((e1 == e2)) + (e1 == e2) {...} Signed-off-by: Gulsah Kose Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index f9096a512da5..1baa98e636e1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -1219,7 +1219,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if ((pattrib->encrypt == _AES_)) { + if (pattrib->encrypt == _AES_) { if (pattrib->psta) stainfo = pattrib->psta; else @@ -1460,7 +1460,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) u32 res = _SUCCESS; pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* 4 start to encrypt each fragment */ - if ((prxattrib->encrypt == _AES_)) { + if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); -- cgit v1.2.3-59-g8ed1b From 2d37545751f27e38aa6beb71564adc35cc2d79ea Mon Sep 17 00:00:00 2001 From: Mikael Svantesson Date: Wed, 29 Oct 2014 17:55:34 +0100 Subject: staging: skein: skein_api.c: removed space before ',' Signed-off-by: Mikael Svantesson Acked-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/skein/skein_api.c b/drivers/staging/skein/skein_api.c index 6e700eefc00c..5bfce076f7c8 100644 --- a/drivers/staging/skein/skein_api.c +++ b/drivers/staging/skein/skein_api.c @@ -31,7 +31,7 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) { skein_assert_ret(ctx && size, SKEIN_FAIL); - memset(ctx , 0, sizeof(struct skein_ctx)); + memset(ctx, 0, sizeof(struct skein_ctx)); ctx->skein_size = size; return SKEIN_SUCCESS; -- cgit v1.2.3-59-g8ed1b From 8d94b6d22403cf4aebfbd246bb781501366db005 Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Wed, 29 Oct 2014 23:41:49 +0400 Subject: staging:lustre:lnet:selftest: fix sparse warnings Fix sparse warnings: symbol X was not declared. Should it be static? Some functions used only in files where they are declared. They can be static. Signed-off-by: Anton Saraev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/conctl.c | 34 ++++++++-------- drivers/staging/lustre/lnet/selftest/conrpc.c | 20 +++++----- drivers/staging/lustre/lnet/selftest/framework.c | 50 ++++++++++++------------ drivers/staging/lustre/lnet/selftest/module.c | 4 +- drivers/staging/lustre/lnet/selftest/rpc.c | 34 ++++++++-------- drivers/staging/lustre/lnet/selftest/timer.c | 8 ++-- 6 files changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index ae7b0fcd818d..5bc615309e72 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -45,7 +45,7 @@ #include "../../include/linux/lnet/lnetst.h" #include "console.h" -int +static int lst_session_new_ioctl(lstio_session_new_args_t *args) { char *name; @@ -82,7 +82,7 @@ lst_session_new_ioctl(lstio_session_new_args_t *args) return rc; } -int +static int lst_session_end_ioctl(lstio_session_end_args_t *args) { if (args->lstio_ses_key != console_session.ses_key) @@ -91,7 +91,7 @@ lst_session_end_ioctl(lstio_session_end_args_t *args) return lstcon_session_end(); } -int +static int lst_session_info_ioctl(lstio_session_info_args_t *args) { /* no checking of key */ @@ -113,7 +113,7 @@ lst_session_info_ioctl(lstio_session_info_args_t *args) args->lstio_ses_nmlen); } -int +static int lst_debug_ioctl(lstio_debug_args_t *args) { char *name = NULL; @@ -194,7 +194,7 @@ out: return rc; } -int +static int lst_group_add_ioctl(lstio_group_add_args_t *args) { char *name; @@ -228,7 +228,7 @@ lst_group_add_ioctl(lstio_group_add_args_t *args) return rc; } -int +static int lst_group_del_ioctl(lstio_group_del_args_t *args) { int rc; @@ -262,7 +262,7 @@ lst_group_del_ioctl(lstio_group_del_args_t *args) return rc; } -int +static int lst_group_update_ioctl(lstio_group_update_args_t *args) { int rc; @@ -320,7 +320,7 @@ lst_group_update_ioctl(lstio_group_update_args_t *args) return rc; } -int +static int lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) { unsigned feats; @@ -365,7 +365,7 @@ lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) return rc; } -int +static int lst_group_list_ioctl(lstio_group_list_args_t *args) { if (args->lstio_grp_key != console_session.ses_key) @@ -382,7 +382,7 @@ lst_group_list_ioctl(lstio_group_list_args_t *args) args->lstio_grp_namep); } -int +static int lst_group_info_ioctl(lstio_group_info_args_t *args) { char *name; @@ -446,7 +446,7 @@ lst_group_info_ioctl(lstio_group_info_args_t *args) return 0; } -int +static int lst_batch_add_ioctl(lstio_batch_add_args_t *args) { int rc; @@ -480,7 +480,7 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args) return rc; } -int +static int lst_batch_run_ioctl(lstio_batch_run_args_t *args) { int rc; @@ -515,7 +515,7 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args) return rc; } -int +static int lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) { int rc; @@ -551,7 +551,7 @@ lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) return rc; } -int +static int lst_batch_query_ioctl(lstio_batch_query_args_t *args) { char *name; @@ -593,7 +593,7 @@ lst_batch_query_ioctl(lstio_batch_query_args_t *args) return rc; } -int +static int lst_batch_list_ioctl(lstio_batch_list_args_t *args) { if (args->lstio_bat_key != console_session.ses_key) @@ -610,7 +610,7 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args) args->lstio_bat_namep); } -int +static int lst_batch_info_ioctl(lstio_batch_info_args_t *args) { char *name; @@ -675,7 +675,7 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args) return rc; } -int +static int lst_stat_query_ioctl(lstio_stat_args_t *args) { int rc; diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index a3a60d6e9081..9999b0dc03e4 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -88,7 +88,7 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc) spin_unlock(&rpc->crpc_lock); } -int +static int lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats, int bulk_npg, int bulk_len, int embedded, lstcon_rpc_t *crpc) { @@ -113,7 +113,7 @@ lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats, return 0; } -int +static int lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats, int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp) { @@ -182,7 +182,7 @@ lstcon_rpc_put(lstcon_rpc_t *crpc) atomic_dec(&console_session.ses_rpc_counter); } -void +static void lstcon_rpc_post(lstcon_rpc_t *crpc) { lstcon_rpc_trans_t *trans = crpc->crp_trans; @@ -383,7 +383,7 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout) return rc; } -int +static int lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp) { lstcon_node_t *nd = crpc->crp_node; @@ -718,7 +718,7 @@ lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov) return &pid[idx % SFW_ID_PER_PAGE]; } -int +static int lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, int dist, int span, int nkiov, lnet_kiov_t *kiov) { @@ -772,7 +772,7 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, return 0; } -int +static int lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req) { test_ping_req_t *prq = &req->tsr_u.ping; @@ -783,7 +783,7 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req) return 0; } -int +static int lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req) { test_bulk_req_t *brq = &req->tsr_u.bulk_v0; @@ -795,7 +795,7 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req) return 0; } -int +static int lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req) { test_bulk_req_v1_t *brq = &req->tsr_u.bulk_v1; @@ -915,7 +915,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats, return rc; } -int +static int lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans, lstcon_node_t *nd, srpc_msg_t *reply) { @@ -1162,7 +1162,7 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist, return rc; } -void +static void lstcon_rpc_pinger(void *arg) { stt_timer_t *ptimer = (stt_timer_t *)arg; diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index df04ab7de835..82cc94b9cef2 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -156,7 +156,7 @@ sfw_register_test (srpc_service_t *service, sfw_test_client_ops_t *cliops) return 0; } -void +static void sfw_add_session_timer (void) { sfw_session_t *sn = sfw_data.fw_session; @@ -176,7 +176,7 @@ sfw_add_session_timer (void) return; } -int +static int sfw_del_session_timer (void) { sfw_session_t *sn = sfw_data.fw_session; @@ -238,7 +238,7 @@ sfw_deactivate_session (void) } -void +static void sfw_session_expired (void *data) { sfw_session_t *sn = data; @@ -284,7 +284,7 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid, } /* completion handler for incoming framework RPCs */ -void +static void sfw_server_rpc_done(struct srpc_server_rpc *rpc) { struct srpc_service *sv = rpc->srpc_scd->scd_svc; @@ -302,7 +302,7 @@ sfw_server_rpc_done(struct srpc_server_rpc *rpc) return; } -void +static void sfw_client_rpc_fini (srpc_client_rpc_t *rpc) { LASSERT (rpc->crpc_bulk.bk_niov == 0); @@ -325,7 +325,7 @@ sfw_client_rpc_fini (srpc_client_rpc_t *rpc) spin_unlock(&sfw_data.fw_lock); } -sfw_batch_t * +static sfw_batch_t * sfw_find_batch (lst_bid_t bid) { sfw_session_t *sn = sfw_data.fw_session; @@ -341,7 +341,7 @@ sfw_find_batch (lst_bid_t bid) return NULL; } -sfw_batch_t * +static sfw_batch_t * sfw_bid2batch (lst_bid_t bid) { sfw_session_t *sn = sfw_data.fw_session; @@ -367,7 +367,7 @@ sfw_bid2batch (lst_bid_t bid) return bat; } -int +static int sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -479,7 +479,7 @@ sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply) return 0; } -int +static int sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -511,7 +511,7 @@ sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply) return 0; } -int +static int sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -532,7 +532,7 @@ sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply) return 0; } -void +static void sfw_test_rpc_fini (srpc_client_rpc_t *rpc) { sfw_test_unit_t *tsu = rpc->crpc_priv; @@ -554,7 +554,7 @@ sfw_test_buffers(sfw_test_instance_t *tsi) return max(SFW_TEST_WI_MIN, nbuf + SFW_TEST_WI_EXTRA); } -int +static int sfw_load_test(struct sfw_test_instance *tsi) { struct sfw_test_case *tsc; @@ -591,7 +591,7 @@ sfw_load_test(struct sfw_test_instance *tsi) return 0; } -void +static void sfw_unload_test(struct sfw_test_instance *tsi) { struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service); @@ -609,7 +609,7 @@ sfw_unload_test(struct sfw_test_instance *tsi) return; } -void +static void sfw_destroy_test_instance (sfw_test_instance_t *tsi) { srpc_client_rpc_t *rpc; @@ -643,7 +643,7 @@ clean: return; } -void +static void sfw_destroy_batch (sfw_batch_t *tsb) { sfw_test_instance_t *tsi; @@ -682,7 +682,7 @@ sfw_destroy_session (sfw_session_t *sn) return; } -void +static void sfw_unpack_addtest_req(srpc_msg_t *msg) { srpc_test_reqst_t *req = &msg->msg_body.tes_reqst; @@ -727,7 +727,7 @@ sfw_unpack_addtest_req(srpc_msg_t *msg) return; } -int +static int sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) { srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg; @@ -865,7 +865,7 @@ sfw_test_unit_done (sfw_test_unit_t *tsu) return; } -void +static void sfw_test_rpc_done (srpc_client_rpc_t *rpc) { sfw_test_unit_t *tsu = rpc->crpc_priv; @@ -944,7 +944,7 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer, return 0; } -int +static int sfw_run_test (swi_workitem_t *wi) { sfw_test_unit_t *tsu = wi->swi_workitem.wi_data; @@ -994,7 +994,7 @@ test_done: return 1; } -int +static int sfw_run_batch (sfw_batch_t *tsb) { swi_workitem_t *wi; @@ -1072,7 +1072,7 @@ sfw_stop_batch (sfw_batch_t *tsb, int force) return 0; } -int +static int sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply) { sfw_test_instance_t *tsi; @@ -1117,7 +1117,7 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len, return 0; } -int +static int sfw_add_test (srpc_server_rpc_t *rpc) { sfw_session_t *sn = sfw_data.fw_session; @@ -1187,7 +1187,7 @@ sfw_add_test (srpc_server_rpc_t *rpc) return 0; } -int +static int sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -1228,7 +1228,7 @@ sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply) return 0; } -int +static int sfw_handle_server_rpc(struct srpc_server_rpc *rpc) { struct srpc_service *sv = rpc->srpc_scd->scd_svc; @@ -1334,7 +1334,7 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc) return rc; } -int +static int sfw_bulk_ready(struct srpc_server_rpc *rpc, int status) { struct srpc_service *sv = rpc->srpc_scd->scd_svc; diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 6dd4309dc5ea..b2dd891f3734 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -55,7 +55,7 @@ static int lst_init_step = LST_INIT_NONE; struct cfs_wi_sched *lst_sched_serial; struct cfs_wi_sched **lst_sched_test; -void +static void lnet_selftest_fini(void) { int i; @@ -101,7 +101,7 @@ lnet_selftest_structure_assertion(void) CLASSERT(sizeof(srpc_stat_reqst_t) == 28); } -int +static int lnet_selftest_init(void) { int nscheds; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index a9f29d8833a9..c9a1a45923ed 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -87,7 +87,7 @@ void srpc_set_counters (const srpc_counters_t *cnt) spin_unlock(&srpc_data.rpc_glock); } -int +static int srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob) { nob = min(nob, (int)PAGE_CACHE_SIZE); @@ -170,7 +170,7 @@ srpc_next_id (void) return id; } -void +static void srpc_init_server_rpc(struct srpc_server_rpc *rpc, struct srpc_service_cd *scd, struct srpc_buffer *buffer) @@ -351,7 +351,7 @@ srpc_remove_service (srpc_service_t *sv) return 0; } -int +static int srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf, int len, int options, lnet_process_id_t peer, lnet_handle_md_t *mdh, srpc_event_t *ev) @@ -391,7 +391,7 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf, return 0; } -int +static int srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, int options, lnet_process_id_t peer, lnet_nid_t self, lnet_handle_md_t *mdh, srpc_event_t *ev) @@ -443,7 +443,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, return 0; } -int +static int srpc_post_active_rqtbuf(lnet_process_id_t peer, int service, void *buf, int len, lnet_handle_md_t *mdh, srpc_event_t *ev) { @@ -452,7 +452,7 @@ srpc_post_active_rqtbuf(lnet_process_id_t peer, int service, void *buf, LNET_NID_ANY, mdh, ev); } -int +static int srpc_post_passive_rqtbuf(int service, int local, void *buf, int len, lnet_handle_md_t *mdh, srpc_event_t *ev) { @@ -466,7 +466,7 @@ srpc_post_passive_rqtbuf(int service, int local, void *buf, int len, LNET_MD_OP_PUT, any, mdh, ev); } -int +static int srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf) { struct srpc_service *sv = scd->scd_svc; @@ -697,7 +697,7 @@ srpc_finish_service(struct srpc_service *sv) } /* called with sv->sv_lock held */ -void +static void srpc_service_recycle_buffer(struct srpc_service_cd *scd, srpc_buffer_t *buf) { if (!scd->scd_svc->sv_shuttingdown && scd->scd_buf_adjust >= 0) { @@ -787,7 +787,7 @@ srpc_shutdown_service(srpc_service_t *sv) } } -int +static int srpc_send_request (srpc_client_rpc_t *rpc) { srpc_event_t *ev = &rpc->crpc_reqstev; @@ -807,7 +807,7 @@ srpc_send_request (srpc_client_rpc_t *rpc) return rc; } -int +static int srpc_prepare_reply (srpc_client_rpc_t *rpc) { srpc_event_t *ev = &rpc->crpc_replyev; @@ -831,7 +831,7 @@ srpc_prepare_reply (srpc_client_rpc_t *rpc) return rc; } -int +static int srpc_prepare_bulk (srpc_client_rpc_t *rpc) { srpc_bulk_t *bk = &rpc->crpc_bulk; @@ -863,7 +863,7 @@ srpc_prepare_bulk (srpc_client_rpc_t *rpc) return rc; } -int +static int srpc_do_bulk (srpc_server_rpc_t *rpc) { srpc_event_t *ev = &rpc->srpc_ev; @@ -891,7 +891,7 @@ srpc_do_bulk (srpc_server_rpc_t *rpc) } /* only called from srpc_handle_rpc */ -void +static void srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status) { struct srpc_service_cd *scd = rpc->srpc_scd; @@ -1066,7 +1066,7 @@ srpc_handle_rpc(swi_workitem_t *wi) return 0; } -void +static void srpc_client_rpc_expired (void *data) { srpc_client_rpc_t *rpc = data; @@ -1108,7 +1108,7 @@ srpc_add_client_rpc_timer (srpc_client_rpc_t *rpc) * * Upon exit the RPC expiry timer is not queued and the handler is not * running on any CPU. */ -void +static void srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc) { /* timer not planted or already exploded */ @@ -1129,7 +1129,7 @@ srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc) } } -void +static void srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status) { swi_workitem_t *wi = &rpc->crpc_wi; @@ -1393,7 +1393,7 @@ srpc_send_reply(struct srpc_server_rpc *rpc) } /* when in kernel always called with LNET_LOCK() held, and in thread context */ -void +static void srpc_lnet_ev_handler(lnet_event_t *ev) { struct srpc_service_cd *scd; diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index 91d4caa4edb0..f8352c2a7d37 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -121,7 +121,7 @@ stt_del_timer(stt_timer_t *timer) } /* called with stt_data.stt_lock held */ -int +static int stt_expire_list(struct list_head *slot, unsigned long now) { int expired = 0; @@ -145,7 +145,7 @@ stt_expire_list(struct list_head *slot, unsigned long now) return expired; } -int +static int stt_check_timers(unsigned long *last) { int expired = 0; @@ -168,7 +168,7 @@ stt_check_timers(unsigned long *last) } -int +static int stt_timer_main(void *arg) { cfs_block_allsigs(); @@ -187,7 +187,7 @@ stt_timer_main(void *arg) return 0; } -int +static int stt_start_timer_thread(void) { struct task_struct *task; -- cgit v1.2.3-59-g8ed1b From 553d8ae8056d13f1562a9c91714ccb2f9fb94339 Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Wed, 29 Oct 2014 23:41:50 +0400 Subject: staging:lustre:lnet:selftest: remove unused function Function lnet_selftest_structure_assertion is never used and can be removed. Signed-off-by: Anton Saraev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/module.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index b2dd891f3734..92520c2e08fd 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -90,17 +90,6 @@ lnet_selftest_fini(void) return; } -void -lnet_selftest_structure_assertion(void) -{ - CLASSERT(sizeof(srpc_msg_t) == 160); - CLASSERT(sizeof(srpc_test_reqst_t) == 70); - CLASSERT(offsetof(srpc_msg_t, msg_body.tes_reqst.tsr_concur) == 72); - CLASSERT(offsetof(srpc_msg_t, msg_body.tes_reqst.tsr_ndest) == 78); - CLASSERT(sizeof(srpc_stat_reply_t) == 136); - CLASSERT(sizeof(srpc_stat_reqst_t) == 28); -} - static int lnet_selftest_init(void) { -- cgit v1.2.3-59-g8ed1b From 6c3773defb993275e749c9f876b826af5f7605f3 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Wed, 29 Oct 2014 23:32:30 +0100 Subject: staging: panel: Use designated initializers Fix "warning: missing initializer [-Wmissing-field-initializers]" by using designated struct initializers. Signed-off-by: Mariusz Gorski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 6d1a32097d3c..98556ce8af6a 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1375,9 +1375,9 @@ static const struct file_operations lcd_fops = { }; static struct miscdevice lcd_dev = { - LCD_MINOR, - "lcd", - &lcd_fops + .minor = LCD_MINOR, + .name = "lcd", + .fops = &lcd_fops, }; /* public function usable from the kernel for any purpose */ @@ -1652,9 +1652,9 @@ static const struct file_operations keypad_fops = { }; static struct miscdevice keypad_dev = { - KEYPAD_MINOR, - "keypad", - &keypad_fops + .minor = KEYPAD_MINOR, + .name = "keypad", + .fops = &keypad_fops, }; static void keypad_send_key(const char *string, int max_len) -- cgit v1.2.3-59-g8ed1b From 33de8f24a70238984700229cac9095d111e6da91 Mon Sep 17 00:00:00 2001 From: Behan Webster Date: Wed, 29 Oct 2014 15:38:42 -0700 Subject: staging, rts5208, LLVMLinux: Change extern inline to static inline With compilers which follow the C99 standard (like modern versions of gcc and clang), "extern inline" does the opposite thing from older versions of gcc (emits code for an externally linkable version of the inline function). "static inline" does the intended behavior in both gcc and clang. Signed-off-by: Behan Webster Suggested-by: Arnd Bergmann Cc: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_transport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/rtsx_transport.h b/drivers/staging/rts5208/rtsx_transport.h index b4b112372776..899bc2079dbe 100644 --- a/drivers/staging/rts5208/rtsx_transport.h +++ b/drivers/staging/rts5208/rtsx_transport.h @@ -46,7 +46,7 @@ void rtsx_add_cmd(struct rtsx_chip *chip, void rtsx_send_cmd_no_wait(struct rtsx_chip *chip); int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout); -extern inline u8 *rtsx_get_cmd_data(struct rtsx_chip *chip) +static inline u8 *rtsx_get_cmd_data(struct rtsx_chip *chip) { #ifdef CMD_USING_SG return (u8 *)(chip->host_sg_tbl_ptr); -- cgit v1.2.3-59-g8ed1b From 6d91857d4826b382b3fd4fad95f52713be646f96 Mon Sep 17 00:00:00 2001 From: Behan Webster Date: Wed, 29 Oct 2014 15:42:20 -0700 Subject: staging, rtl8192e, LLVMLinux: Change extern inline to static inline With compilers which follow the C99 standard (like modern versions of gcc and clang), "extern inline" does the opposite thing from older versions of gcc (emits code for an externally linkable version of the inline function). "static inline" does the intended behavior in all cases instead. Signed-off-by: Behan Webster Suggested-by: Arnd Bergmann Cc: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 4 ++-- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2d82f8993ea1..33995ac49584 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2944,12 +2944,12 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern const long rtllib_wlan_frequencies[]; -extern inline void rtllib_increment_scans(struct rtllib_device *ieee) +static inline void rtllib_increment_scans(struct rtllib_device *ieee) { ieee->scans++; } -extern inline int rtllib_get_scans(struct rtllib_device *ieee) +static inline int rtllib_get_scans(struct rtllib_device *ieee) { return ieee->scans; } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index abb6729ae279..067a45ab97dd 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -343,7 +343,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, } } -inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) +static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) { unsigned int len, rate_len; u8 *tag; -- cgit v1.2.3-59-g8ed1b From 62ec95f86d2850b7ce6d73fb236a6fcf48411aea Mon Sep 17 00:00:00 2001 From: Behan Webster Date: Wed, 29 Oct 2014 15:42:21 -0700 Subject: staging, rtl8192e, LLVMLinux: Remove unused inline prototype rtllib_probe_req is defined as "static inline" in rtllib_softmac.c however it is declared differently as "extern inline" in rtllib_softmac.h. Since it isn't used outside of the scope of rtllib_softmac, it makes sense to remove the incorrect declaration. Signed-off-by: Behan Webster Suggested-by: Arnd Bergmann Cc: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 33995ac49584..132278265396 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2762,7 +2762,6 @@ extern void rtllib_stop_scan(struct rtllib_device *ieee); extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan); extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); -extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee); extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); -- cgit v1.2.3-59-g8ed1b From d82f0029e03d8512ac523ac2e4caa5cecb989570 Mon Sep 17 00:00:00 2001 From: Behan Webster Date: Wed, 29 Oct 2014 15:42:22 -0700 Subject: staging, rtl8192e, LLVMLinux: Remove unused prototype MgntQuery_MgntFrameTxRate is only used within rtllib_softmac.c, so it really should be static instead of extern. Since it is currently extern a warning is generated because a different function of the same name is defined staticlly in ieee80211_softmac.c Removing the incorrect extern declaration and defining the rtllib_softmac version of this routine static fixes the warning. Signed-off-by: Behan Webster Suggested-by: Arnd Bergmann Cc: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 132278265396..cef2dc27103f 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -2762,7 +2762,6 @@ extern void rtllib_stop_scan(struct rtllib_device *ieee); extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan); extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); -extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 067a45ab97dd..089a058ad2ed 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -193,7 +193,7 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) return QueryRate; } -u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) +static u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 rate; -- cgit v1.2.3-59-g8ed1b From 16fc54ee26912d3f2450bc4832b19c943dbdff17 Mon Sep 17 00:00:00 2001 From: Behan Webster Date: Wed, 29 Oct 2014 15:42:23 -0700 Subject: staging, rtl8192e, LLVMLinux: Make static local in inline function const rtllib_association_req is a (large) inline function which defines 2 constant static arrays which aren't labelled as const. As a result clang complains with: non-constant static local variable in inline function may be different in different files [-Wstatic-local-in-inline] static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; ^ The solution is making them "static const". However doing so requires dropping const when being used with struct octet_string. However the value is used in a const fashion thereafter, so no harm done. Signed-off-by: Behan Webster Suggested-by: Arnd Bergmann Cc: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 089a058ad2ed..e970db474470 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1311,7 +1311,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, } if (beacon->bCkipSupported) { - static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; + static const u8 AironetIeOui[] = {0x00, 0x01, 0x66}; u8 CcxAironetBuf[30]; struct octet_string osCcxAironetIE; @@ -1331,10 +1331,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, } if (beacon->bCcxRmEnable) { - static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; + static const u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, + 0x00}; struct octet_string osCcxRmCap; - osCcxRmCap.Octet = CcxRmCapBuf; + osCcxRmCap.Octet = (u8 *) CcxRmCapBuf; osCcxRmCap.Length = sizeof(CcxRmCapBuf); tag = skb_put(skb, ccxrm_ie_len); *tag++ = MFIE_TYPE_GENERIC; -- cgit v1.2.3-59-g8ed1b From 9d9921e93078075b9142b7e8d68a038416967d4c Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Wed, 29 Oct 2014 06:06:57 +0200 Subject: staging: rtl8188eu: core: Removed unnecessary return keyword. This patch fixes WARNING: void function return statements are not generally useful checkpatch.pl warning in rtw_efuse.c by using this coccinelle script @r@ identifier i; @@ void i(...) { ... -return; } Signed-off-by: Gulsah Kose Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index e037c43c2837..bc897da8c103 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -322,7 +322,6 @@ void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _si iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); iol_mode_enable(Adapter, 0); } - return; } /* Do not support BT */ -- cgit v1.2.3-59-g8ed1b From 04947c5be5ca3824586f94352293549b899b2d89 Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Thu, 30 Oct 2014 02:28:03 +0200 Subject: staging: rtl8188eu: os_dep: Removed unnecessary return. This patch fixes WARNING: void function return statements are not generally useful checkpatch.pl warning in usb_intf.c by using this coccinelle script @r@ identifier i; @@ void i(...) { ... -return; } Signed-off-by: Gulsah Kose Reviewed-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 407a318b09db..65a257f1bd10 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -556,8 +556,6 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); DBG_88E("-r871xu_dev_remove, done\n"); - - return; } static struct usb_driver rtl8188e_usb_drv = { -- cgit v1.2.3-59-g8ed1b From 3fd511d98660cba235dfadf1f296a3246fbaea58 Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Thu, 30 Oct 2014 03:03:46 +0200 Subject: staging: rtl8188eu: os_dep: Used min_t instead of min This patch fixes this checkpatch.pl warning: WARNING: min() should probably be min_t(int, req->essid_len, IW_ESSID_MAX_SIZE) by using this coccinelle script: @r@ identifier i; expression e1, e2; type t1, t2; @@ t1 i = - min((t2)e1, e2); + min_t(t2, e1, e2); Signed-off-by: Gulsah Kose Reviewed-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 70b729f26613..08ba7d3e6c69 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1134,7 +1134,8 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, struct iw_scan_req *req = (struct iw_scan_req *)extra; if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { - int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); + int len = min_t(int, req->essid_len, + IW_ESSID_MAX_SIZE); memcpy(ssid[0].Ssid, req->essid, len); ssid[0].SsidLength = len; -- cgit v1.2.3-59-g8ed1b From 12c492cf462704fcfc8c86046d539c16d57dfbe3 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:01:38 +0530 Subject: staging: cptm1217: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cptm1217/clearpad_tm1217.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/cptm1217/clearpad_tm1217.c b/drivers/staging/cptm1217/clearpad_tm1217.c index edf9ff2ea25b..7f265ce0dd13 100644 --- a/drivers/staging/cptm1217/clearpad_tm1217.c +++ b/drivers/staging/cptm1217/clearpad_tm1217.c @@ -278,7 +278,7 @@ static void cp_tm1217_get_data(struct cp_tm1217_device *ts) static irqreturn_t cp_tm1217_sample_thread(int irq, void *handle) { - struct cp_tm1217_device *ts = (struct cp_tm1217_device *) handle; + struct cp_tm1217_device *ts = handle; u8 req[2]; int retval; -- cgit v1.2.3-59-g8ed1b From d591f5d0e548cb79a942be5fd86fbc714b530a39 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:01:52 +0530 Subject: staging: dgap: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index dfdf20969987..105c3b8f4024 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1167,7 +1167,7 @@ schedule_poller: */ static irqreturn_t dgap_intr(int irq, void *voidbrd) { - struct board_t *brd = (struct board_t *) voidbrd; + struct board_t *brd = voidbrd; if (!brd) return IRQ_NONE; -- cgit v1.2.3-59-g8ed1b From fc33bd2921c27241f0b695bb265fa020c51d352b Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:02:04 +0530 Subject: staging: dgnc: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 2 +- drivers/staging/dgnc/dgnc_neo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index 360fe258946d..bedc5221b6fc 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -792,7 +792,7 @@ static void cls_tasklet(unsigned long data) */ static irqreturn_t cls_intr(int irq, void *voidbrd) { - struct dgnc_board *brd = (struct dgnc_board *) voidbrd; + struct dgnc_board *brd = voidbrd; uint i = 0; unsigned char poll_reg; unsigned long flags; diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index cc6136418071..c9a8a9825cfb 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -944,7 +944,7 @@ static void neo_tasklet(unsigned long data) */ static irqreturn_t neo_intr(int irq, void *voidbrd) { - struct dgnc_board *brd = (struct dgnc_board *) voidbrd; + struct dgnc_board *brd = voidbrd; struct channel_t *ch; int port = 0; int type = 0; -- cgit v1.2.3-59-g8ed1b From edb3cc10e03874067c7e86107462a89b54bfdfc9 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:02:15 +0530 Subject: staging: gdm72xx: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_wimax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 5b7747f6b847..9cab54bfa6f4 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -115,7 +115,7 @@ static void gdm_wimax_event_rcv(struct net_device *dev, u16 type, void *msg, { struct nic *nic = netdev_priv(dev); - u8 *buf = (u8 *)msg; + u8 *buf = msg; u16 hci_cmd = (buf[0]<<8) | buf[1]; u16 hci_len = (buf[2]<<8) | buf[3]; -- cgit v1.2.3-59-g8ed1b From 31f8f066f5bc8dc5ce1efbbdfddec401ed790a2b Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:02:25 +0530 Subject: staging: iio: adc: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7606_spi.c | 2 +- drivers/staging/iio/adc/lpc32xx_adc.c | 2 +- drivers/staging/iio/adc/spear_adc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c index 6a8ecd73a1a7..7303983e64a7 100644 --- a/drivers/staging/iio/adc/ad7606_spi.c +++ b/drivers/staging/iio/adc/ad7606_spi.c @@ -23,7 +23,7 @@ static int ad7606_spi_read_block(struct device *dev, int i, ret; unsigned short *data = buf; - ret = spi_read(spi, (u8 *)buf, count * 2); + ret = spi_read(spi, buf, count * 2); if (ret < 0) { dev_err(&spi->dev, "SPI read error\n"); return ret; diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c index a876ce755351..84a53a9430ef 100644 --- a/drivers/staging/iio/adc/lpc32xx_adc.c +++ b/drivers/staging/iio/adc/lpc32xx_adc.c @@ -116,7 +116,7 @@ static const struct iio_chan_spec lpc32xx_adc_iio_channels[] = { static irqreturn_t lpc32xx_adc_isr(int irq, void *dev_id) { - struct lpc32xx_adc_info *info = (struct lpc32xx_adc_info *) dev_id; + struct lpc32xx_adc_info *info = dev_id; /* Read value and clear irq */ info->value = __raw_readl(LPC32XX_ADC_VALUE(info->adc_base)) & diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 67a364c2e794..de37b35ea154 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -226,7 +226,7 @@ static const struct iio_chan_spec spear_adc_iio_channels[] = { static irqreturn_t spear_adc_isr(int irq, void *dev_id) { - struct spear_adc_state *st = (struct spear_adc_state *)dev_id; + struct spear_adc_state *st = dev_id; /* Read value to clear IRQ */ st->value = spear_adc_get_average(st); -- cgit v1.2.3-59-g8ed1b From ad1d2a4fc8676588f6fe9882235056f1c6d13b50 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:02:36 +0530 Subject: staging: media: davinci_vpfe: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 4 ++-- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 6d4893b44c1f..413acbb9e948 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -421,7 +421,7 @@ static int ipipeif_get_config(struct v4l2_subdev *sd, void __user *arg) { struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); - struct ipipeif_params *config = (struct ipipeif_params *)arg; + struct ipipeif_params *config = arg; struct device *dev = ipipeif->subdev.v4l2_dev->dev; if (!arg) { @@ -462,7 +462,7 @@ ipipeif_get_config(struct v4l2_subdev *sd, void __user *arg) static long ipipeif_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) { - struct ipipeif_params *config = (struct ipipeif_params *)arg; + struct ipipeif_params *config = arg; int ret = -ENOIOCTLCMD; switch (cmd) { diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 415502651033..36fc15ad190c 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -149,7 +149,7 @@ configure_resizer_out_params(struct vpfe_resizer_device *resizer, int index, param->rsz_en[index] = DISABLE; return; } - output = (struct vpfe_rsz_output_spec *)output_spec; + output = output_spec; param->rsz_en[index] = ENABLE; if (partial) { param->rsz_rsc_param[index].h_flip = output->h_flip; @@ -1218,12 +1218,12 @@ static long resizer_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) switch (cmd) { case VIDIOC_VPFE_RSZ_S_CONFIG: - user_config = (struct vpfe_rsz_config *)arg; + user_config = arg; ret = resizer_set_configuration(resizer, user_config); break; case VIDIOC_VPFE_RSZ_G_CONFIG: - user_config = (struct vpfe_rsz_config *)arg; + user_config = arg; if (!user_config->config) { dev_err(dev, "error in VIDIOC_VPFE_RSZ_G_CONFIG\n"); return -EINVAL; -- cgit v1.2.3-59-g8ed1b From d82e62deb51b50b10736c71f06fa6ac26be3b5a3 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:02:48 +0530 Subject: staging: media: lirc: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_igorplugusb.c | 2 +- drivers/staging/media/lirc/lirc_imon.c | 4 ++-- drivers/staging/media/lirc/lirc_sasem.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_igorplugusb.c b/drivers/staging/media/lirc/lirc_igorplugusb.c index 431d1e86ebf9..fd5d3d26b15d 100644 --- a/drivers/staging/media/lirc/lirc_igorplugusb.c +++ b/drivers/staging/media/lirc/lirc_igorplugusb.c @@ -282,7 +282,7 @@ static void send_fragment(struct igorplug *ir, struct lirc_buffer *buf, static int igorplugusb_remote_poll(void *data, struct lirc_buffer *buf) { int ret; - struct igorplug *ir = (struct igorplug *)data; + struct igorplug *ir = data; if (!ir || !ir->usbdev) /* Has the device been removed? */ return -ENODEV; diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index e3b1fa9fd2f4..f98418cd2305 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -495,7 +495,7 @@ static int ir_open(void *data) /* prevent races with disconnect */ mutex_lock(&driver_lock); - context = (struct imon_context *)data; + context = data; /* initial IR protocol decode variables */ context->rx.count = 0; @@ -516,7 +516,7 @@ static void ir_close(void *data) { struct imon_context *context; - context = (struct imon_context *)data; + context = data; if (!context) { pr_err("%s: no context for device\n", __func__); return; diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index 05969fb451ca..123ddf68b587 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -488,7 +488,7 @@ static int ir_open(void *data) /* prevent races with disconnect */ mutex_lock(&disconnect_lock); - context = (struct sasem_context *) data; + context = data; mutex_lock(&context->ctx_lock); @@ -530,7 +530,7 @@ static void ir_close(void *data) { struct sasem_context *context; - context = (struct sasem_context *)data; + context = data; if (!context) { pr_err("%s: no context for device\n", __func__); return; -- cgit v1.2.3-59-g8ed1b From b3d43a39104de1ed4278e85e16bd017c7ed73d91 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:02:57 +0530 Subject: staging: ozwpan: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 8 ++++---- drivers/staging/ozwpan/ozusbsvc1.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 3d03e9255831..27217d75f155 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -730,7 +730,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) { /* Cleanup the current configuration and report reset to the core. */ - struct oz_port *port = (struct oz_port *)hport; + struct oz_port *port = hport; struct oz_hcd *ozhcd = port->ozhcd; oz_dbg(ON, "PD Reset\n"); @@ -749,7 +749,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, int length, int offset, int total_size) { - struct oz_port *port = (struct oz_port *)hport; + struct oz_port *port = hport; struct urb *urb; int err = 0; @@ -889,7 +889,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, int data_len) { - struct oz_port *port = (struct oz_port *)hport; + struct oz_port *port = hport; struct urb *urb; struct usb_ctrlrequest *setup; struct usb_hcd *hcd = port->ozhcd->hcd; @@ -1036,7 +1036,7 @@ static inline int oz_usb_get_frame_number(void) int oz_hcd_heartbeat(void *hport) { int rc = 0; - struct oz_port *port = (struct oz_port *)hport; + struct oz_port *port = hport; struct oz_hcd *ozhcd = port->ozhcd; struct oz_urb_link *urbl, *n; LIST_HEAD(xfr_list); diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index be7ee01c50ab..d434d8c6fff6 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -56,7 +56,7 @@ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei, int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, u8 index, __le16 windex, int offset, int len) { - struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_usb_ctx *usb_ctx = hpd; struct oz_pd *pd = usb_ctx->pd; struct oz_elt *elt; struct oz_get_desc_req *body; @@ -92,7 +92,7 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, */ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) { - struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_usb_ctx *usb_ctx = hpd; struct oz_pd *pd = usb_ctx->pd; struct oz_elt *elt; struct oz_elt_buf *eb = &pd->elt_buff; @@ -115,7 +115,7 @@ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) */ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) { - struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_usb_ctx *usb_ctx = hpd; struct oz_pd *pd = usb_ctx->pd; struct oz_elt *elt; struct oz_elt_buf *eb = &pd->elt_buff; @@ -140,7 +140,7 @@ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, u8 recipient, u8 index, __le16 feature) { - struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_usb_ctx *usb_ctx = hpd; struct oz_pd *pd = usb_ctx->pd; struct oz_elt *elt; struct oz_elt_buf *eb = &pd->elt_buff; @@ -166,7 +166,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, u8 request, __le16 value, __le16 index, const u8 *data, int data_len) { - struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_usb_ctx *usb_ctx = hpd; struct oz_pd *pd = usb_ctx->pd; struct oz_elt *elt; struct oz_elt_buf *eb = &pd->elt_buff; @@ -244,7 +244,7 @@ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, */ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) { - struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_usb_ctx *usb_ctx = hpd; struct oz_pd *pd = usb_ctx->pd; struct oz_elt_buf *eb; int i; -- cgit v1.2.3-59-g8ed1b From 60c8991148d8ad7cdbfd210a42db721eccd58d26 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:03:08 +0530 Subject: staging: rtl8188eu: core: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- drivers/staging/rtl8188eu/core/rtw_debug.c | 14 +++++++------- drivers/staging/rtl8188eu/core/rtw_efuse.c | 16 ++++++++-------- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 350d2e73b419..7731cdb72b22 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -167,7 +167,7 @@ int rtw_cmd_thread(void *context) struct cmd_obj *pcmd; u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf); void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd); - struct adapter *padapter = (struct adapter *)context; + struct adapter *padapter = context; struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); allow_signal(SIGTERM); diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c index 1f72f7d8097e..bc3fe10ff247 100644 --- a/drivers/staging/rtl8188eu/core/rtw_debug.c +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -45,7 +45,7 @@ int proc_get_write_reg(char *page, char **start, int proc_set_write_reg(struct file *file, const char __user *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); char tmp[32]; u32 addr, val, len; @@ -577,7 +577,7 @@ int proc_get_rx_signal(char *page, char **start, int proc_set_rx_signal(struct file *file, const char __user *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); char tmp[32]; u32 is_signal_dbg; @@ -627,7 +627,7 @@ int proc_get_ht_enable(char *page, char **start, int proc_set_ht_enable(struct file *file, const char __user *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -669,7 +669,7 @@ int proc_get_cbw40_enable(char *page, char **start, int proc_set_cbw40_enable(struct file *file, const char __user *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -710,7 +710,7 @@ int proc_get_ampdu_enable(char *page, char **start, int proc_set_ampdu_enable(struct file *file, const char __user *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -771,7 +771,7 @@ int proc_get_rx_stbc(char *page, char **start, int proc_set_rx_stbc(struct file *file, const char __user *buffer, unsigned long count, void *data) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -800,7 +800,7 @@ 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) { - struct net_device *dev = (struct net_device *)data; + struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); char tmp[32]; u32 enable = 0; diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index bc897da8c103..31986670b7f0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -331,56 +331,56 @@ void EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, v case TYPE_EFUSE_MAX_SECTION: { u8 *pMax_section; - pMax_section = (u8 *)pOut; + pMax_section = pOut; *pMax_section = EFUSE_MAX_SECTION_88E; } break; case TYPE_EFUSE_REAL_CONTENT_LEN: { u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; + pu2Tmp = pOut; *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; } break; case TYPE_EFUSE_CONTENT_LEN_BANK: { u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; + pu2Tmp = pOut; *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; } break; case TYPE_AVAILABLE_EFUSE_BYTES_BANK: { u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; + pu2Tmp = pOut; *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); } break; case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: { u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; + pu2Tmp = pOut; *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); } break; case TYPE_EFUSE_MAP_LEN: { u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; + pu2Tmp = pOut; *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; } break; case TYPE_EFUSE_PROTECT_BYTES_BANK: { u8 *pu1Tmp; - pu1Tmp = (u8 *)pOut; + pu1Tmp = pOut; *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); } break; default: { u8 *pu1Tmp; - pu1Tmp = (u8 *)pOut; + pu1Tmp = pOut; *pu1Tmp = 0; } break; diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 384be22052e5..2aa62517e4a2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -28,7 +28,7 @@ /* */ void BlinkTimerCallback(void *data) { - struct LED_871x *pLed = (struct LED_871x *)data; + struct LED_871x *pLed = data; struct adapter *padapter = pLed->padapter; if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index b4e8504b34ed..dec26a89c356 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1362,7 +1362,7 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) */ void _rtw_join_timeout_handler (void *function_context) { - struct adapter *adapter = (struct adapter *)function_context; + struct adapter *adapter = function_context; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int do_join_r; @@ -1404,7 +1404,7 @@ void _rtw_join_timeout_handler (void *function_context) */ void rtw_scan_timeout_handler (void *function_context) { - struct adapter *adapter = (struct adapter *)function_context; + struct adapter *adapter = function_context; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 5ba5099ec20d..8bb490820557 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -4835,7 +4835,7 @@ void linked_status_chk(struct adapter *padapter) void survey_timer_hdl(void *function_context) { - struct adapter *padapter = (struct adapter *)function_context; + struct adapter *padapter = function_context; struct cmd_obj *ph2c; struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -4912,7 +4912,7 @@ void link_timer_hdl(void *function_context) void addba_timer_hdl(void *function_context) { - struct sta_info *psta = (struct sta_info *)function_context; + struct sta_info *psta = function_context; struct ht_priv *phtpriv; if (!psta) diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 27ed83cca193..768dbeee94c4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -284,7 +284,7 @@ exit: static void pwr_state_check_handler(void *FunctionContext) { - struct adapter *padapter = (struct adapter *)FunctionContext; + struct adapter *padapter = FunctionContext; rtw_ps_cmd(padapter); } diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 4d56dbad2a7d..53a054c189e4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -1949,7 +1949,7 @@ _err_exit: void rtw_reordering_ctrl_timeout_handler(void *pcontext) { - struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext; + struct recv_reorder_ctrl *preorder_ctrl = pcontext; struct adapter *padapter = preorder_ctrl->padapter; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; -- cgit v1.2.3-59-g8ed1b From 08a3d85a016467c68b224e1a4d9e844a397d92e2 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:03:19 +0530 Subject: staging: rtl8188eu: hal: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index d6fe5e6aa4f4..68db5c99696f 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -181,7 +181,7 @@ static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable switch (eVariable) { case HAL_ODM_STA_INFO: { - struct sta_info *psta = (struct sta_info *)pValue1; + struct sta_info *psta = pValue1; if (bSet) { DBG_88E("### Set STA_(%d) info\n", psta->mac_id); ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c index 7a4f754d86df..a6ba53b488e3 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c @@ -25,7 +25,7 @@ void dump_txrpt_ccx_88e(void *buf) { - struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + struct txrpt_ccx_88e *txrpt_ccx = buf; DBG_88E("%s:\n" "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n" -- cgit v1.2.3-59-g8ed1b From 037a449ac71fc5c70d2b0af28ce6792065daae55 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:03:31 +0530 Subject: staging: rtl8188eu: os_dep: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index ba1e178fb510..7da85f9c127b 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -843,7 +843,7 @@ void usb_write_port_cancel(struct adapter *padapter) void rtl8188eu_recv_tasklet(void *priv) { struct sk_buff *pskb; - struct adapter *adapt = (struct adapter *)priv; + struct adapter *adapt = priv; struct recv_priv *precvpriv = &adapt->recvpriv; while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { @@ -862,7 +862,7 @@ void rtl8188eu_recv_tasklet(void *priv) void rtl8188eu_xmit_tasklet(void *priv) { int ret = false; - struct adapter *adapt = (struct adapter *)priv; + struct adapter *adapt = priv; struct xmit_priv *pxmitpriv = &adapt->xmitpriv; if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) -- cgit v1.2.3-59-g8ed1b From ad6128a3a16627e6bfd3f34db371365f0d341c6f Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:03:55 +0530 Subject: staging: rtl8723au: core: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 799b9cf63263..81960e788f89 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -176,7 +176,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, switch (type) { case TYPE_EFUSE_MAX_SECTION: - pMax_section = (u8 *) pOut; + pMax_section = pOut; if (efuseType == EFUSE_WIFI) *pMax_section = EFUSE_MAX_SECTION_8723A; @@ -185,7 +185,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; case TYPE_EFUSE_REAL_CONTENT_LEN: - pu2Tmp = (u16 *) pOut; + pu2Tmp = pOut; if (efuseType == EFUSE_WIFI) *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; @@ -194,7 +194,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; case TYPE_AVAILABLE_EFUSE_BYTES_BANK: - pu2Tmp = (u16 *) pOut; + pu2Tmp = pOut; if (efuseType == EFUSE_WIFI) *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - @@ -205,7 +205,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: - pu2Tmp = (u16 *) pOut; + pu2Tmp = pOut; if (efuseType == EFUSE_WIFI) *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - @@ -216,7 +216,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; case TYPE_EFUSE_MAP_LEN: - pu2Tmp = (u16 *) pOut; + pu2Tmp = pOut; if (efuseType == EFUSE_WIFI) *pu2Tmp = EFUSE_MAP_LEN_8723A; @@ -225,7 +225,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; case TYPE_EFUSE_PROTECT_BYTES_BANK: - pu1Tmp = (u8 *) pOut; + pu1Tmp = pOut; if (efuseType == EFUSE_WIFI) *pu1Tmp = EFUSE_OOB_PROTECT_BYTES; @@ -234,7 +234,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; case TYPE_EFUSE_CONTENT_LEN_BANK: - pu2Tmp = (u16 *) pOut; + pu2Tmp = pOut; if (efuseType == EFUSE_WIFI) *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; @@ -243,7 +243,7 @@ EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, break; default: - pu1Tmp = (u8 *) pOut; + pu1Tmp = pOut; *pu1Tmp = 0; break; } -- cgit v1.2.3-59-g8ed1b From aa54b60d63abf51227336de9c1ec13bdbabfee88 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:04:05 +0530 Subject: staging: rts5208: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 2d2527c3aea2..c74f1b8108f6 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -418,7 +418,7 @@ static void rtsx_shutdown(struct pci_dev *pci) static int rtsx_control_thread(void *__dev) { - struct rtsx_dev *dev = (struct rtsx_dev *)__dev; + struct rtsx_dev *dev = __dev; struct rtsx_chip *chip = dev->chip; struct Scsi_Host *host = rtsx_to_host(dev); @@ -527,7 +527,7 @@ SkipForAbort: static int rtsx_polling_thread(void *__dev) { - struct rtsx_dev *dev = (struct rtsx_dev *)__dev; + struct rtsx_dev *dev = __dev; struct rtsx_chip *chip = dev->chip; struct sd_info *sd_card = &(chip->sd_card); struct xd_info *xd_card = &(chip->xd_card); -- cgit v1.2.3-59-g8ed1b From e3b6db3294b079b5bc986cceb465feddf3623906 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:04:15 +0530 Subject: staging: ft1000: ft1000-pcmcia: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 9de308906054..5a9d20bc4204 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -2002,7 +2002,7 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) static irqreturn_t ft1000_interrupt(int irq, void *dev_id) { - struct net_device *dev = (struct net_device *)dev_id; + struct net_device *dev = dev_id; struct ft1000_info *info = netdev_priv(dev); u16 tempword; u16 inttype; -- cgit v1.2.3-59-g8ed1b From 099e1f8f777f4f329181415fc405a3a2093a3e15 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:04:24 +0530 Subject: staging: ft1000: ft1000-usb: Remove useless cast on void pointer void pointers do not need to be cast to other pointer types. The semantic patch used to find this: @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 7fb5c3f00632..fe882bd69e38 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -653,7 +653,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, state = STATE_START_DWNLD; - file_hdr = (struct dsp_file_hdr *)pFileStart; + file_hdr = pFileStart; ft1000_write_register(ft1000dev, 0x800, FT1000_REG_MAG_WATERMARK); -- cgit v1.2.3-59-g8ed1b From f811be139e9bcf014049d7aa93225a4dbea33c53 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 17:04:36 +0530 Subject: staging: rtl8188eu: Remove double test Removed the duplicate test on memcmp(pIE->data, BROADCOM_OUI2, 3). The semantic that find this problem is // @@ expression E; @@ ( * E || ... || E | * E && ... && E ) // Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 33ccbbbd8ed6..c495977c209e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1394,7 +1394,6 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) DBG_88E("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || - (!memcmp(pIE->data, BROADCOM_OUI2, 3)) || (!memcmp(pIE->data, BROADCOM_OUI2, 3))) { DBG_88E("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; -- cgit v1.2.3-59-g8ed1b From d8d34a817bc0041ba2f0ee09e40c18c7161e2c2d Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 18:23:11 +0530 Subject: staging: dgap: Remove useless cast on NULL Cast on NULL to a pointer type is not required. This patch removes NULL casted to some pointer type. The sematic patch used is: @r@ type T; @@ - (T *)NULL + NULL Build tested it. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 105c3b8f4024..ed356f1bdece 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -7028,7 +7028,7 @@ static char *dgap_sindex(char *string, char *group) char *ptr; if (!string || !group) - return (char *) NULL; + return NULL; if (*group == '^') { group++; @@ -7049,7 +7049,7 @@ static char *dgap_sindex(char *string, char *group) } } - return (char *) NULL; + return NULL; } /* -- cgit v1.2.3-59-g8ed1b From 7499b702f0873b670cbd769c9bfeb437e9fa4c55 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 18:25:00 +0530 Subject: staging: rt18188eu: Remove useless cast on NULL Cast on NULL to a pointer type is not required. This patch removes NULL casted to some pointer type. The sematic patch used is: @r@ type T; @@ - (T *)NULL + NULL Build tested it. Signed-off-by: Tapasweni Pathak Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 8bb490820557..a00ebcddc881 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -945,7 +945,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame } pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (pstat == (struct sta_info *)NULL) { + if (pstat == NULL) { status = _RSON_CLS2_; goto asoc_class2_error; } -- cgit v1.2.3-59-g8ed1b From 7ede7af3fd5f92966d328586f7f42b378fa17d83 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Thu, 30 Oct 2014 17:12:53 +0200 Subject: staging: media: lirc: lirc_zilog.c: remove unnecessary 'out of memory' message This patch fixes the following the following checkpatch.pl warning: Possible unnecessary 'out of memory' message The warning was issued for the file lirc_zilog.c after changing two custom printk messages to dev_err. The dev_err calls were simply removed. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_zilog.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index 11a7cb128d9e..52f8e91a6383 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c @@ -771,7 +771,6 @@ static int fw_load(struct IR_tx *tx) /* Parse the file */ tx_data = vmalloc(sizeof(*tx_data)); if (tx_data == NULL) { - dev_err(tx->ir->l.dev, "out of memory\n"); release_firmware(fw_entry); ret = -ENOMEM; goto out; @@ -781,7 +780,6 @@ static int fw_load(struct IR_tx *tx) /* Copy the data so hotplug doesn't get confused and timeout */ tx_data->datap = vmalloc(fw_entry->size); if (tx_data->datap == NULL) { - dev_err(tx->ir->l.dev, "out of memory\n"); release_firmware(fw_entry); vfree(tx_data); ret = -ENOMEM; -- cgit v1.2.3-59-g8ed1b From a055b3cbb72d2487938d3452c79e2a338088fbc1 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 21:08:09 +0530 Subject: staging: rtl8188eu: core: Remove null check before kfree kfree on NULL pointer is a no-op. This patch uses the following semantic patch to find such an instance where NULL check is present before kfree. // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // smpl> Build tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 7731cdb72b22..dd24138d13b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -433,8 +433,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; if (psecnetwork == NULL) { - if (pcmd != NULL) - kfree(pcmd); + kfree(pcmd); res = _FAIL; -- cgit v1.2.3-59-g8ed1b From 3cfab18ce55282a85e2c7e5db15c5daf065efdb4 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 21:11:57 +0530 Subject: staging: rtl8188eu: core: Improve cleanup code The code is restructured such that kfree(efuseTbl) is not called if the allocation of efuseTbl and such that kfree(eFuseWord) is not called if the allocation of eFuseWord has failed. To accomplish this a new label eFuseWord_failed has been added. Suggested by: Julia Lawall Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 31986670b7f0..c47b1573c6e8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -106,13 +106,13 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); if (efuseTbl == NULL) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); - goto exit; + return; } eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); if (eFuseWord == NULL) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); - goto exit; + goto eFuseWord_failed; } /* 0. Refresh efuse init map as all oxFF. */ @@ -210,10 +210,10 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) /* */ exit: - kfree(efuseTbl); + kfree(eFuseWord); - if (eFuseWord) - kfree(eFuseWord); +eFuseWord_failed: + kfree(efuseTbl); } static void efuse_read_phymap_from_txpktbuf( -- cgit v1.2.3-59-g8ed1b From 3f3efca9c57fd5c12ac8d9e151db5bbbaec2d716 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Thu, 30 Oct 2014 22:03:36 +0530 Subject: staging: emxx_udc: use USB API functions rather than constants This patch introduces the use of the functions usb_endpoint_type and usb_endpoint_num. The Coccinelle semantic patch that makes these changes is as follows: @@ struct usb_endpoint_descriptor *epd; @@ - (epd->bEndpointAddress & \(USB_ENDPOINT_NUMBER_MASK\|0x0f\)) + usb_endpoint_num(epd) @@ struct usb_endpoint_descriptor *epd; @@ - (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\)) + usb_endpoint_type(epd) Build Tested it. Signed-off-by: Tapasweni Pathak Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 77e4aee74fa1..0261d0b22ba7 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2622,7 +2622,7 @@ static int nbu2ss_ep_enable( return -EINVAL; } - ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; + ep_type = usb_endpoint_type(desc); if ((ep_type == USB_ENDPOINT_XFER_CONTROL) || (ep_type == USB_ENDPOINT_XFER_ISOC)) { @@ -2644,7 +2644,7 @@ static int nbu2ss_ep_enable( spin_lock_irqsave(&udc->lock, flags); ep->desc = desc; - ep->epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + ep->epnum = usb_endpoint_num(desc); ep->direct = desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK; ep->ep_type = ep_type; ep->wedged = 0; -- cgit v1.2.3-59-g8ed1b From 35438c0011c3a3ba120ad78ea99bf38f009dc736 Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Fri, 31 Oct 2014 01:32:38 +0530 Subject: Staging: ft1000: ft1000_hw.c: Removed some checkpatch errors and warnings. ERROR: space prohibited after that '&' (ctx:WxW) ERROR: "foo * bar" should be "foo *bar" ERROR: space prohibited after that open parenthesis '(' ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 5a9d20bc4204..25b06d350f14 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -997,8 +997,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev) } else { tempword = FT1000_DPRAM_MAG_RX_BASE; - } - if ( ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword) ) { + } + if (ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword)) { /* Get the message type which is total_len + PSEUDO header + msgtype + message body */ pdrvmsg = (struct drv_msg *) & cmdbuffer[0]; @@ -1224,7 +1224,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) for (i=1; i<7; i++) { ppseudo_hdr->checksum ^= *pmsg++; } - pmsg = (u16 *) & tempbuffer[16]; + pmsg = (u16 *) &tempbuffer[16]; *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG); *pmsg++ = htons(0x000e); *pmsg++ = htons(info->DSP_TIME[0]); @@ -1756,7 +1756,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) SUCCESS -------------------------------------------------------------------------*/ -static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len) +static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) { struct ft1000_info *info = netdev_priv(dev); struct ft1000_pcmcia *pcmcia = info->priv; -- cgit v1.2.3-59-g8ed1b From ab784e5075698ed3b767d5e264a50aab39add209 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 29 Oct 2014 17:35:11 +0000 Subject: staging: comedi: das16: deschedule timer routine on detach The "das16" driver optionally uses a kernel timer and a DMA channel to support asynchronous data acquisition, but currently never calls `del_timer_sync()`. There is some possibility the timer routine could still be scheduled to run when the comedi "detach" handler is run to clean up the device and cause a certain amount of havoc. Avoid that by calling `del_time_sync()` in the comedi "detach" handler `das16_detach()` if the timer was initialized by the "attach" handler `das16_attach()`. Use the timer's `data` member to tell whether it was initialized or not. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index aa9e3e10d59d..4556af109eae 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1228,6 +1228,8 @@ static void das16_detach(struct comedi_device *dev) int i; if (devpriv) { + if (devpriv->timer.data) + del_timer_sync(&devpriv->timer); if (dev->iobase) das16_reset(dev); -- cgit v1.2.3-59-g8ed1b From 0a43f75ef57fcf20b9637fa49889e6721ceb5ea7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 29 Oct 2014 17:35:12 +0000 Subject: staging: comedi: das16: use spin-lock when setting timer "das16" sets a timer running in `das16_cmd_exec()` and sets `devpriv->timer_running` to indicate that it is running. The timer expiration routine `das16_timer_interrupt()` checks `devpriv->timer_running` to check whether it needs to reschedule the timer, but this is not synchronized with `das16_cmd_exec()`. Since `das16_cancel()` acquires the `dev->spinlock` spin-lock when clearing `devpriv->timer_running` and removing the timer from the queue, use the same spin-lock in `das16_cmd_exec()` and `das16_timer_interrupt()` around the setting and checking of `devpriv->timer_running`. Since `das16_interrupt()` (called from `das16_timer_interrupt()`) checks whether DMA is enabled in the device while holding `dev->spinlock`, and DMA is enabled by `das16_cmd_exec()` around the time it schedules the timer, enable the DMA in the device while holding the spin-lock. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 4556af109eae..8e512b241653 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -595,11 +595,14 @@ static void das16_timer_interrupt(unsigned long arg) { struct comedi_device *dev = (struct comedi_device *)arg; struct das16_private_struct *devpriv = dev->private; + unsigned long flags; das16_interrupt(dev); + spin_lock_irqsave(&dev->spinlock, flags); if (devpriv->timer_running) mod_timer(&devpriv->timer, jiffies + timer_period()); + spin_unlock_irqrestore(&dev->spinlock, flags); } static int das16_ai_check_chanlist(struct comedi_device *dev, @@ -816,7 +819,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) enable_dma(devpriv->dma_chan); release_dma_lock(flags); - /* set up interrupt */ + /* set up timer */ + spin_lock_irqsave(&dev->spinlock, flags); devpriv->timer_running = 1; devpriv->timer.expires = jiffies + timer_period(); add_timer(&devpriv->timer); @@ -825,6 +829,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->can_burst) outb(0, dev->iobase + DAS1600_CONV_REG); + spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } -- cgit v1.2.3-59-g8ed1b From 8369e382bd98ee5586928bed41992f8bd73d4cec Mon Sep 17 00:00:00 2001 From: Eric Rost Date: Wed, 29 Oct 2014 19:12:08 -0500 Subject: staging: skein: Removes skein_debug include Removes skein_debug.h include since skein_debug.h is nonexistent. Removes unneeded debug empty macro defines and their uses. Signed-off-by: Eric Rost Reviewed-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_base.c | 18 ------------- drivers/staging/skein/skein_base.h | 17 ------------- drivers/staging/skein/skein_block.c | 51 +------------------------------------ 3 files changed, 1 insertion(+), 85 deletions(-) diff --git a/drivers/staging/skein/skein_base.c b/drivers/staging/skein/skein_base.c index ebc436a1098f..7e700a6b5788 100644 --- a/drivers/staging/skein/skein_base.c +++ b/drivers/staging/skein/skein_base.c @@ -124,8 +124,6 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ cfg.w[2] = skein_swap64(tree_info); - skein_show_key(256, &ctx->h, key, key_bytes); - /* compute the initial chaining values from config block */ skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); @@ -232,8 +230,6 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) /* "output" the ctr mode bytes */ skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->x, x, sizeof(x)); } @@ -353,8 +349,6 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ cfg.w[2] = skein_swap64(tree_info); - skein_show_key(512, &ctx->h, key, key_bytes); - /* compute the initial chaining values from config block */ skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); @@ -461,8 +455,6 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) /* "output" the ctr mode bytes */ skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, n); - skein_show_final(512, &ctx->h, n, - hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->x, x, sizeof(x)); } @@ -577,8 +569,6 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ cfg.w[2] = skein_swap64(tree_info); - skein_show_key(1024, &ctx->h, key, key_bytes); - /* compute the initial chaining values from config block */ skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); @@ -685,8 +675,6 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) /* "output" the ctr mode bytes */ skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, n); - skein_show_final(1024, &ctx->h, n, - hash_val+i*SKEIN_1024_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->x, x, sizeof(x)); } @@ -794,8 +782,6 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) /* "output" the ctr mode bytes */ skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->x, x, sizeof(x)); } @@ -833,8 +819,6 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) /* "output" the ctr mode bytes */ skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->x, x, sizeof(x)); } @@ -872,8 +856,6 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) /* "output" the ctr mode bytes */ skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, n); - skein_show_final(256, &ctx->h, n, - hash_val+i*SKEIN_1024_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->x, x, sizeof(x)); } diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h index 0111fa426b32..993b951172f6 100644 --- a/drivers/staging/skein/skein_base.h +++ b/drivers/staging/skein/skein_base.h @@ -15,10 +15,6 @@ ** ** The "default" note explains what happens when the switch is not defined. ** -** SKEIN_DEBUG -- make callouts from inside Skein code -** to examine/display intermediate values. -** [default: no callouts (no overhead)] -** ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein ** code. If not defined, most error checking ** is disabled (for performance). Otherwise, @@ -279,19 +275,6 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \ } -/***************************************************************** -** "Internal" Skein definitions for debugging and error checking -******************************************************************/ -#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ -#include "skein_debug.h" -#else /* default is no callouts */ -#define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) -#define skein_show_round(bits, ctx, r, x) -#define skein_show_r_ptr(bits, ctx, r, x_ptr) -#define skein_show_final(bits, ctx, cnt, out_ptr) -#define skein_show_key(bits, ctx, key, key_bytes) -#endif - /* ignore all asserts, for performance */ #define skein_assert_ret(x, ret_code) #define skein_assert(x) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 36b0b400acf3..66261ab25c88 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -70,7 +70,6 @@ do { \ #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \ do { \ ROUND256(p0, p1, p2, p3, ROT, r_num); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) #define I256(R) \ @@ -80,14 +79,12 @@ do { \ X1 += ks[((R) + 2) % 5] + ts[((R) + 1) % 3]; \ X2 += ks[((R) + 3) % 5] + ts[((R) + 2) % 3]; \ X3 += ks[((R) + 4) % 5] + (R) + 1; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R256(p0, p1, p2, p3, ROT, r_num) \ do { \ ROUND256(p0, p1, p2, p3, ROT, r_num); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) #define I256(R) \ @@ -100,7 +97,6 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 4] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #endif #define R256_8_ROUNDS(R) \ @@ -160,8 +156,7 @@ do { \ #if SKEIN_UNROLL_512 == 0 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ do { \ - ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ } while (0) #define I512(R) \ @@ -175,14 +170,12 @@ do { \ X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ X7 += ks[((R) + 8) % 9] + (R) + 1; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ do { \ ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) #define I512(R) \ @@ -199,7 +192,6 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 8] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #endif /* end of looped code definitions */ #define R512_8_ROUNDS(R) /* do 8 full rounds */ \ @@ -274,7 +266,6 @@ do { \ do { \ ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rn); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ } while (0) #define I1024(R) \ @@ -296,7 +287,6 @@ do { \ X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ X15 += ks[((R) + 16) % 17] + (R) + 1; \ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ @@ -304,7 +294,6 @@ do { \ do { \ ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rn); \ - skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ } while (0) #define I1024(R) \ @@ -329,7 +318,6 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 16] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - skein_show_r_ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #endif @@ -413,7 +401,6 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); /* do the first full key injection */ X0 = w[0] + ks[0]; @@ -421,10 +408,6 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, X2 = w[2] + ks[2] + ts[1]; X3 = w[3] + ks[3]; - /* show starting state values */ - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - x_ptr); - blk_ptr += SKEIN_256_BLOCK_BYTES; /* run the rounds */ @@ -481,8 +464,6 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, ctx->x[2] = X2 ^ w[2]; ctx->x[3] = X3 ^ w[3]; - skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); - ts[1] &= ~SKEIN_T1_FLAG_FIRST; } while (--blk_cnt); ctx->h.tweak[0] = ts[0]; @@ -558,7 +539,6 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); /* do the first full key injection */ X0 = w[0] + ks[0]; @@ -572,8 +552,6 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, blk_ptr += SKEIN_512_BLOCK_BYTES; - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - X_ptr); /* run the rounds */ for (r = 1; r < (SKEIN_UNROLL_512 ? 2 * RCNT : 2); @@ -634,7 +612,6 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, ctx->x[5] = X5 ^ w[5]; ctx->x[6] = X6 ^ w[6]; ctx->x[7] = X7 ^ w[7]; - skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } while (--blk_cnt); @@ -674,26 +651,6 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, u64 X00, X01, X02, X03, X04, X05, X06, X07, X08, X09, X10, X11, X12, X13, X14, X15; u64 w[WCNT]; /* local copy of input block */ -#ifdef SKEIN_DEBUG - const u64 *X_ptr[16]; /* use for debugging (help cc put Xn in regs) */ - - X_ptr[0] = &X00; - X_ptr[1] = &X01; - X_ptr[2] = &X02; - X_ptr[3] = &X03; - X_ptr[4] = &X04; - X_ptr[5] = &X05; - X_ptr[6] = &X06; - X_ptr[7] = &X07; - X_ptr[8] = &X08; - X_ptr[9] = &X09; - X_ptr[10] = &X10; - X_ptr[11] = &X11; - X_ptr[12] = &X12; - X_ptr[13] = &X13; - X_ptr[14] = &X14; - X_ptr[15] = &X15; -#endif skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.tweak[0]; @@ -732,7 +689,6 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); /* do the first full key injection */ X00 = w[0] + ks[0]; @@ -752,9 +708,6 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, X14 = w[14] + ks[14] + ts[1]; X15 = w[15] + ks[15]; - skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - X_ptr); - for (r = 1; r < (SKEIN_UNROLL_1024 ? 2 * RCNT : 2); r += (SKEIN_UNROLL_1024 ? 2 * SKEIN_UNROLL_1024 : 1)) { @@ -821,8 +774,6 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, ctx->x[14] = X14 ^ w[14]; ctx->x[15] = X15 ^ w[15]; - skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); - ts[1] &= ~SKEIN_T1_FLAG_FIRST; blk_ptr += SKEIN_1024_BLOCK_BYTES; } while (--blk_cnt); -- cgit v1.2.3-59-g8ed1b From a6a39a7fcff597c4384a21922332ee513f33ccbf Mon Sep 17 00:00:00 2001 From: Eunbong Song Date: Thu, 30 Oct 2014 01:09:00 +0000 Subject: staging: octeon-ethernet: disable load balance for receiving packet when CONFIG_RPS is enabled. It's better disable load balance for receiving packet when CONFIG_RPS is enabled. If not, octeon-ethernet driver select CPU and then the rps select again CPU. It can be ipi interrupts overhead and packet reordering could be possible. Signed-off-by: Eunbong Song Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index b2b6c3cd2bed..44e372f09683 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -286,6 +286,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) did_work_request = 1; } +#ifndef CONFIG_RPS if (rx_count == 0) { /* * First time through, see if there is enough @@ -300,6 +301,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) if (backlog > budget * cores_in_use && napi != NULL) cvm_oct_enable_one_cpu(); } +#endif rx_count++; skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1; -- cgit v1.2.3-59-g8ed1b From 425ebd0aa35dcfc5fe2449ef3e1194e422f6f9b4 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:45 -0400 Subject: staging: unisys: virtpci: Add a blank line after the definition of driver_private Insert a blank line between the definition of the driver_private structure and the next statement. Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 52ec69f06b92..1f72103c7b9b 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -50,6 +50,7 @@ struct driver_private { struct module_kobject *mkobj; struct device_driver *driver; }; + #define to_driver(obj) container_of(obj, struct driver_private, kobj) /* bus_id went away in 2.6.30 - the size was 20 bytes, so we'll define -- cgit v1.2.3-59-g8ed1b From 65cfadc33ede24a62e793f75f23acffd1d2bbf9c Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:46 -0400 Subject: staging: unisys: virtpci: Remove extraneous blank lines Removed unnecessary blank lines from virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 1f72103c7b9b..7b00cef79110 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -177,7 +177,6 @@ int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem *chanptr) int count = 120; while (count > 0) { - if (SPAR_CHANNEL_SERVER_READY(&chanptr->channel_header)) return 1; UIS_THREAD_WAIT_SEC(1); @@ -348,7 +347,6 @@ static int add_vhba(struct add_virt_guestpart *addparams) POSTCODE_SEVERITY_INFO); } return i; - } /* for CHANSOCK macaddr is AUTO-GENERATED; for normal channels, @@ -1566,7 +1564,6 @@ static void __exit virtpci_mod_exit(void) bus_unregister(&virtpci_bus_type); debugfs_remove_recursive(virtpci_debugfs_dir); LOGINF("Leaving\n"); - } module_init(virtpci_mod_init); -- cgit v1.2.3-59-g8ed1b From 15c769671739919226bb8aa2b7e23c5df7603086 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:47 -0400 Subject: staging: unisys: virtpci: Remove space between cast and variable Remove the whitespace between a cast and a variable in virtpci.c. Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 7b00cef79110..560639a715ca 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -200,7 +200,7 @@ static int write_vbus_chpInfo(struct spar_vbus_channel_protocol *chan, LOGERR("vbus channel not used, because chp_info_offset == 0"); return -1; } - memcpy(((u8 *) (chan)) + off, info, sizeof(*info)); + memcpy(((u8 *)(chan)) + off, info, sizeof(*info)); return 0; } @@ -219,7 +219,7 @@ static int write_vbus_busInfo(struct spar_vbus_channel_protocol *chan, LOGERR("vbus channel not used, because bus_info_offset == 0"); return -1; } - memcpy(((u8 *) (chan)) + off, info, sizeof(*info)); + memcpy(((u8 *)(chan)) + off, info, sizeof(*info)); return 0; } @@ -244,7 +244,7 @@ write_vbus_devInfo(struct spar_vbus_channel_protocol *chan, LOGERR("vbus channel not used, because dev_info_offset == 0"); return -1; } - memcpy(((u8 *) (chan)) + off, info, sizeof(*info)); + memcpy(((u8 *)(chan)) + off, info, sizeof(*info)); return 0; } @@ -325,7 +325,7 @@ static int add_vhba(struct add_virt_guestpart *addparams) POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (!WAIT_FOR_IO_CHANNEL - ((struct spar_io_channel_protocol __iomem *) addparams->chanptr)) { + ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) { LOGERR("Timed out. Channel not ready\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; @@ -355,16 +355,16 @@ static int add_vhba(struct add_virt_guestpart *addparams) #define GET_NETADAPINFO_FROM_CHANPTR(chanptr) { \ memcpy_fromio(net.mac_addr, \ ((struct spar_io_channel_protocol __iomem *) \ - chanptr)->vnic.macaddr, \ + chanptr)->vnic.macaddr, \ MAX_MACADDR_LEN); \ net.num_rcv_bufs = \ readl(&((struct spar_io_channel_protocol __iomem *)\ - chanptr)->vnic.num_rcv_bufs); \ + chanptr)->vnic.num_rcv_bufs); \ net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \ - chanptr)->vnic.mtu); \ + chanptr)->vnic.mtu); \ memcpy_fromio(&net.zone_uuid, \ &((struct spar_io_channel_protocol __iomem *)\ - chanptr)->vnic.zone_uuid, \ + chanptr)->vnic.zone_uuid, \ sizeof(uuid_le)); \ } @@ -381,7 +381,7 @@ add_vnic(struct add_virt_guestpart *addparams) POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (!WAIT_FOR_IO_CHANNEL - ((struct spar_io_channel_protocol __iomem *) addparams->chanptr)) { + ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) { LOGERR("Timed out, channel not ready\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; @@ -431,7 +431,7 @@ delete_vbus_device(struct device *vbus, void *data) int checkforroot = (data != NULL); struct device *pDev = &virtpci_rootbus_device; - if ((checkforroot) && match_busid(vbus, (void *) BUS_ID(pDev))) { + if ((checkforroot) && match_busid(vbus, (void *)BUS_ID(pDev))) { /* skip it - don't delete root bus */ LOGINF("skipping root bus\n"); return 0; /* pretend no error */ @@ -606,7 +606,7 @@ static void delete_all(void) /* now delete each vbus */ if (bus_for_each_dev - (&virtpci_bus_type, NULL, (void *) 1, delete_vbus_device)) + (&virtpci_bus_type, NULL, (void *)1, delete_vbus_device)) LOGERR("delete of all vbus failed\n"); } @@ -1447,7 +1447,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, printparam.buf = vbuf; printparam.len = &len; if (bus_for_each_dev(&virtpci_bus_type, NULL, - (void *) &printparam, print_vbus)) + (void *)&printparam, print_vbus)) LOGERR("Failed to find bus\n"); str_pos += scnprintf(vbuf + str_pos, len - str_pos, @@ -1532,7 +1532,7 @@ static int __init virtpci_mod_init(void) } DBGINF("device_register successful ret:%x\n", ret); - if (!uisctrl_register_req_handler(2, (void *) &virtpci_ctrlchan_func, + if (!uisctrl_register_req_handler(2, (void *)&virtpci_ctrlchan_func, &Chipset_DriverInfo)) { LOGERR("uisctrl_register_req_handler ****FAILED.\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); @@ -1542,7 +1542,7 @@ static int __init virtpci_mod_init(void) } LOGINF("successfully registered virtpci_ctrlchan_func (0x%p) as callback.\n", - (void *) &virtpci_ctrlchan_func); + (void *)&virtpci_ctrlchan_func); /* create debugfs directory and info file inside. */ virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL); debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir, -- cgit v1.2.3-59-g8ed1b From 732bf98833d8a3f13a658e24513ca5661a4be62f Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:48 -0400 Subject: staging: unisys: virtpci: Allocate memory using the size of the variable Change two instances of using the sizeof a structure to the size of a specific variable when allocating memory in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 560639a715ca..3cfa7671ec06 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -256,7 +256,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams) int ret; struct device *vbus; - vbus = kzalloc(sizeof(struct device), GFP_ATOMIC); + vbus = kzalloc(sizeof(*vbus), GFP_ATOMIC); POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (!vbus) @@ -922,7 +922,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, } /* add a Virtual Device */ - virtpcidev = kzalloc(sizeof(struct virtpci_dev), GFP_ATOMIC); + virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC); if (virtpcidev == NULL) { LOGERR("can't add device - malloc FALLED\n"); POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); -- cgit v1.2.3-59-g8ed1b From 65b96899ce7f12711656f0b3203554fd99e074a0 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:49 -0400 Subject: staging: unisys: virtpci: Place logical continuation at the end of a line Move the && logical continuation from the start of the second line of an if statement to the end of the first line. Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 3cfa7671ec06..baf12e54b6d9 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -696,8 +696,8 @@ virtpci_match_device(const struct pci_device_id *ids, DBGINF("ids->vendor:%x dev->vendor:%x ids->device:%x dev->device:%x\n", ids->vendor, dev->vendor, ids->device, dev->device); - if ((ids->vendor == dev->vendor) - && (ids->device == dev->device)) + if ((ids->vendor == dev->vendor) && + (ids->device == dev->device)) return ids; ids++; -- cgit v1.2.3-59-g8ed1b From 5e7590ee82a211948da94392cbc580811dbc85b8 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:50 -0400 Subject: staging: unisys: virtpci: Add braces to if/else statements Update if/else blocks with braces on both the if and the else blocks in virtpci.c. Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index baf12e54b6d9..07d1966e8b35 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -847,8 +847,9 @@ static int virtpci_device_probe(struct device *dev) virtpcidev->mydriver = virtpcidrv; POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC, POSTCODE_SEVERITY_INFO); - } else + } else { put_device(dev); + } } POSTCODE_LINUX_2(VPCI_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return error; /* -ENODEV for probe failure */ @@ -992,9 +993,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype, } /* add it at the head */ - if (!VpcidevListHead) + if (!VpcidevListHead) { VpcidevListHead = virtpcidev; - else { + } else { /* insert virtpcidev at the head of our linked list of * vpcidevs */ -- cgit v1.2.3-59-g8ed1b From fe3600f33814a05389b18bc368410913c8bd395d Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:51 -0400 Subject: staging: unisys: virtpci: Use a single blank line to separate code blocks Remove one blank line of two between function variable declaration and implementation in virt_pci_mod_init(). Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 07d1966e8b35..f13daab98e56 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -1502,7 +1502,6 @@ static int __init virtpci_mod_init(void) { int ret; - if (!unisys_spar_platform) return -ENODEV; -- cgit v1.2.3-59-g8ed1b From 197ac858ae982eac0d59e1d3e7e87bc1e2b2908a Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:52 -0400 Subject: staging: unisys: virtpci: Fix alignment issues Use the appropriate whitespace alignment for multiline statements in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index f13daab98e56..928f0fde11bd 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -110,7 +110,7 @@ static int virtpci_device_probe(struct device *dev); static int virtpci_device_remove(struct device *dev); static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); + size_t len, loff_t *offset); static const struct file_operations debugfs_info_fops = { .read = info_debugfs_read, @@ -392,9 +392,9 @@ add_vnic(struct add_virt_guestpart *addparams) GET_BUS_DEV(addparams->bus_no); LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n", - net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], - net.mac_addr[4], net.mac_addr[5], net.num_rcv_bufs, net.mtu, - addparams->chanptr, &net.zone_uuid); + net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], + net.mac_addr[3], net.mac_addr[4], net.mac_addr[5], + net.num_rcv_bufs, net.mtu, addparams->chanptr, &net.zone_uuid); i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net); if (i) { LOGINF("Added vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -624,7 +624,7 @@ static int delete_all_virt(enum virtpci_dev_type devtype, if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) { LOGERR("**** FAILED to delete all devices; devtype:%d not vhba:%d or vnic:%d\n", - devtype, VIRTHBA_TYPE, VIRTNIC_TYPE); + devtype, VIRTHBA_TYPE, VIRTNIC_TYPE); return 0; } @@ -694,7 +694,7 @@ virtpci_match_device(const struct pci_device_id *ids, { while (ids->vendor || ids->subvendor || ids->class_mask) { DBGINF("ids->vendor:%x dev->vendor:%x ids->device:%x dev->device:%x\n", - ids->vendor, dev->vendor, ids->device, dev->device); + ids->vendor, dev->vendor, ids->device, dev->device); if ((ids->vendor == dev->vendor) && (ids->device == dev->device)) @@ -793,9 +793,9 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, break; } bus_device_info_init(&devInfo, stype, - virtpcidrv->name, - virtpcidrv->version, - virtpcidrv->vertag); + virtpcidrv->name, + virtpcidrv->version, + virtpcidrv->vertag); write_vbus_devInfo(pChan, &devInfo, devNo); /* Re-write bus+chipset info, because it is possible that this @@ -916,7 +916,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) { LOGERR("**** FAILED to add device; devtype:%d not vhba:%d or vnic:%d\n", - devtype, VIRTHBA_TYPE, VIRTNIC_TYPE); + devtype, VIRTHBA_TYPE, VIRTNIC_TYPE); POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, devtype, POSTCODE_SEVERITY_ERR); return 0; @@ -1427,7 +1427,7 @@ static int print_vbus(struct device *vbus, void *data) } static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) + size_t len, loff_t *offset) { ssize_t bytes_read = 0; int str_pos = 0; @@ -1519,7 +1519,7 @@ static int __init virtpci_mod_init(void) } DBGINF("bus_register successful\n"); bus_device_info_init(&Bus_DriverInfo, "clientbus", "virtpci", - VERSION, NULL); + VERSION, NULL); /* create a root bus used to parent all the virtpci buses. */ ret = device_register(&virtpci_rootbus_device); @@ -1542,11 +1542,11 @@ static int __init virtpci_mod_init(void) } LOGINF("successfully registered virtpci_ctrlchan_func (0x%p) as callback.\n", - (void *)&virtpci_ctrlchan_func); + (void *)&virtpci_ctrlchan_func); /* create debugfs directory and info file inside. */ virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL); debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir, - NULL, &debugfs_info_fops); + NULL, &debugfs_info_fops); LOGINF("Leaving\n"); POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); return 0; -- cgit v1.2.3-59-g8ed1b From 60444139a0ae5c4c4a4f4a7494a8ec0a1785979a Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 30 Oct 2014 16:18:53 -0400 Subject: staging: unisys: virtpci: Adjust lines to contain a maximum of 80 characters Update delete_all_virt function definition to two lines so each line is less than 80 characters long. Move comments on virtpci_device_add function parameters to a header block to contain each line to 80 characters. Signed-off-by: Bryan Thompson Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 928f0fde11bd..b6c313000899 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -897,10 +897,13 @@ static void virtpci_bus_release(struct device *dev) /* Adapter functions */ /*****************************************************/ +/* scsi is expected to be NULL for VNIC add + * net is expected to be NULL for VHBA add + */ static int virtpci_device_add(struct device *parentbus, int devtype, struct add_virt_guestpart *addparams, - struct scsi_adap_info *scsi, /* NULL for VNIC add */ - struct net_adap_info *net /* NULL for VHBA add */) + struct scsi_adap_info *scsi, + struct net_adap_info *net) { struct virtpci_dev *virtpcidev = NULL; struct virtpci_dev *tmpvpcidev = NULL, *prev; -- cgit v1.2.3-59-g8ed1b From 9056be30542bfff51190bdda67088f319cf4c9f5 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Thu, 30 Oct 2014 14:35:01 -0700 Subject: Staging: lustre: lnet: lnet: Better cookie gen api-ni.c uses do_gettimeofday to get a 'cookie' or timestamp. This patch replaces it with ktime_get_ns for the following reasons: 1. ktime_get_ns returns a __u64 which is safer than 'struct timeval' which will overflow on 32-bit systems in year 2038 and beyond. 2. Improved resolution: nsecs instead of usecs. 3. Reduced compute: ktime_get_ns is faster than the multiply/add combination used in this function Signed-off-by: Tina Ruchandani Suggested-by: Arnd Bergmann Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 60bc2ae4fdf1..5e6e4e22ed31 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -37,6 +37,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" #include +#include #define D_LNI D_CONSOLE @@ -417,17 +418,9 @@ static __u64 lnet_create_interface_cookie(void) { /* NB the interface cookie in wire handles guards against delayed - * replies and ACKs appearing valid after reboot. Initialisation time, - * even if it's only implemented to millisecond resolution is probably - * easily good enough. */ - struct timeval tv; - __u64 cookie; - - do_gettimeofday(&tv); - cookie = tv.tv_sec; - cookie *= 1000000; - cookie += tv.tv_usec; - return cookie; + * replies and ACKs appearing valid after reboot. + */ + return ktime_get_ns(); } static char * -- cgit v1.2.3-59-g8ed1b From 37951dabd899587afc31ddd508b9cdddc9c24524 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:20 -0400 Subject: staging: unisys: get rid of VISORCHIPSET_STATE typedef Remove the typedef for VISORCHIPSET_STATE and replace it with enum visorchipset_state. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index feae36885376..ef62f3a54184 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -31,14 +31,14 @@ /** Describes the state from the perspective of which controlvm messages have * been received for a bus or device. */ -typedef struct { +struct visorchipset_state { u32 created:1; u32 attached:1; u32 configured:1; u32 running:1; /* Add new fields above. */ /* Remaining bits in this 32-bit word are unused. */ -} VISORCHIPSET_STATE; +}; typedef enum { /** address is guest physical, but outside of the physical memory @@ -80,7 +80,7 @@ typedef struct { u32 busNo; u32 devNo; uuid_le devInstGuid; - VISORCHIPSET_STATE state; + struct visorchipset_state state; VISORCHIPSET_CHANNEL_INFO chanInfo; u32 Reserved1; /* control_vm_id */ u64 Reserved2; @@ -125,7 +125,7 @@ static inline void delbusdevices(struct list_head *list, u32 busNo) typedef struct { struct list_head entry; u32 busNo; - VISORCHIPSET_STATE state; + struct visorchipset_state state; VISORCHIPSET_CHANNEL_INFO chanInfo; uuid_le partitionGuid; u64 partitionHandle; @@ -162,7 +162,7 @@ findbus(struct list_head *list, u32 busNo) */ typedef struct { u32 switchNo; - VISORCHIPSET_STATE state; + struct visorchipset_state state; uuid_le switchTypeGuid; u8 *authService1; u8 *authService2; @@ -182,7 +182,7 @@ typedef struct { typedef struct { u32 switchNo; u32 externalPortNo; - VISORCHIPSET_STATE state; + struct visorchipset_state state; uuid_le networkZoneGuid; int pdPort; u8 *ip; @@ -205,7 +205,7 @@ typedef struct { typedef struct { u32 switchNo; u32 internalPortNo; - VISORCHIPSET_STATE state; + struct visorchipset_state state; u32 busNo; /* valid only when state.attached == 1 */ u32 devNo; /* valid only when state.attached == 1 */ u64 Reserved1; -- cgit v1.2.3-59-g8ed1b From 6fb23e18944adaec20bd38caf5703271875cede5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:21 -0400 Subject: staging: unisys: refactor VISORCHIPSET_ADDRESSTYPE Get rid of VISORCHIPSET_ADDRESSTYPE and replace it with enum visorchipset_addresstype. Fix CamelCase names: ADDRTYPE_localPhysical => ADDRTYPE_LOCALPHYSICAL ADDRTYPE_localTest => ADDRTYPE_LOCALTEST Update all references to changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 10 +++++----- drivers/staging/unisys/visorchipset/visorchipset_main.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index ef62f3a54184..6ca6580583b5 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -40,18 +40,18 @@ struct visorchipset_state { /* Remaining bits in this 32-bit word are unused. */ }; -typedef enum { +enum visorchipset_addresstype { /** address is guest physical, but outside of the physical memory * region that is controlled by the running OS (this is the normal * address type for Supervisor channels) */ - ADDRTYPE_localPhysical, + ADDRTYPE_LOCALPHYSICAL, /** address is guest physical, and withIN the confines of the * physical memory controlled by the running OS. */ - ADDRTYPE_localTest, -} VISORCHIPSET_ADDRESSTYPE; + ADDRTYPE_LOCALTEST, +}; typedef enum { CRASH_dev, @@ -61,7 +61,7 @@ typedef enum { /** Attributes for a particular Supervisor channel. */ typedef struct { - VISORCHIPSET_ADDRESSTYPE addrType; + enum visorchipset_addresstype addrType; HOSTADDRESS channelAddr; struct irq_info intr; u64 nChannelBytes; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 392e046be359..70a54899fca6 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1130,9 +1130,9 @@ bus_create(struct controlvm_message *inmsg) POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pBusInfo->chanInfo.addrType = ADDRTYPE_localTest; + pBusInfo->chanInfo.addrType = ADDRTYPE_LOCALTEST; else - pBusInfo->chanInfo.addrType = ADDRTYPE_localPhysical; + pBusInfo->chanInfo.addrType = ADDRTYPE_LOCALPHYSICAL; pBusInfo->flags.server = inmsg->hdr.flags.server; pBusInfo->chanInfo.channelAddr = cmd->create_bus.channel_addr; @@ -1280,9 +1280,9 @@ my_device_create(struct controlvm_message *inmsg) POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pDevInfo->chanInfo.addrType = ADDRTYPE_localTest; + pDevInfo->chanInfo.addrType = ADDRTYPE_LOCALTEST; else - pDevInfo->chanInfo.addrType = ADDRTYPE_localPhysical; + pDevInfo->chanInfo.addrType = ADDRTYPE_LOCALPHYSICAL; pDevInfo->chanInfo.channelAddr = cmd->create_device.channel_addr; pDevInfo->chanInfo.nChannelBytes = cmd->create_device.channel_bytes; pDevInfo->chanInfo.channelTypeGuid = cmd->create_device.data_type_uuid; -- cgit v1.2.3-59-g8ed1b From 2c683cde06c1d57a9ecbacc484540e259e7255fa Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:22 -0400 Subject: staging: unisys: refactor CRASH_OBJ_TYPE Remove the typedef from the enumeration and replace references to it with enum crash_obj_type. Fix CamelCase names: CRASH_dev => CRASH_DEV CRASH_bus => CRASH_BUS Update all references to changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 10 +++++----- drivers/staging/unisys/visorchipset/visorchipset_main.c | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 6ca6580583b5..75f20f068225 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -53,10 +53,10 @@ enum visorchipset_addresstype { ADDRTYPE_LOCALTEST, }; -typedef enum { - CRASH_dev, - CRASH_bus, -} CRASH_OBJ_TYPE; +enum crash_obj_type { + CRASH_DEV, + CRASH_BUS, +}; /** Attributes for a particular Supervisor channel. */ @@ -288,7 +288,7 @@ int visorchipset_chipset_notready(void); void visorchipset_controlvm_respond_reportEvent(struct controlvm_message *msg, void *payload); void visorchipset_save_message(struct controlvm_message *msg, - CRASH_OBJ_TYPE type); + enum crash_obj_type type); void *visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block, char *fn, int ln); void visorchipset_cache_free(struct kmem_cache *pool, void *p, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 70a54899fca6..229c75881c5a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -760,7 +760,8 @@ static void controlvm_respond_physdev_changestate( } void -visorchipset_save_message(struct controlvm_message *msg, CRASH_OBJ_TYPE type) +visorchipset_save_message(struct controlvm_message *msg, + enum crash_obj_type type) { u32 localSavedCrashMsgOffset; u16 localSavedCrashMsgCount; @@ -796,7 +797,7 @@ visorchipset_save_message(struct controlvm_message *msg, CRASH_OBJ_TYPE type) return; } - if (type == CRASH_bus) { + if (type == CRASH_BUS) { if (visorchannel_write(ControlVm_channel, localSavedCrashMsgOffset, msg, -- cgit v1.2.3-59-g8ed1b From 9b1caee7170b9078f39c2f4c7a33334ad40cd47b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:23 -0400 Subject: staging: unisys: refactor VISORCHIPSET_CHANNEL_INFO Remove the typedef from this type and use struct visorchipset_channel_info instead. Fix CamelCase member names: addrType => addr_type channelAddr => channel_addr nChannelBytes => n_channel_bytes channelTypeGuid => channel_type_uuid channelInstGuid => channel_inst_uuid Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 18 +++++----- .../unisys/visorchipset/visorchipset_main.c | 38 ++++++++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 75f20f068225..c8a936684cfb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -60,15 +60,15 @@ enum crash_obj_type { /** Attributes for a particular Supervisor channel. */ -typedef struct { - enum visorchipset_addresstype addrType; - HOSTADDRESS channelAddr; +struct visorchipset_channel_info { + enum visorchipset_addresstype addr_type; + HOSTADDRESS channel_addr; struct irq_info intr; - u64 nChannelBytes; - uuid_le channelTypeGuid; - uuid_le channelInstGuid; + u64 n_channel_bytes; + uuid_le channel_type_uuid; + uuid_le channel_inst_uuid; -} VISORCHIPSET_CHANNEL_INFO; +}; /** Attributes for a particular Supervisor device. * Any visorchipset client can query these attributes using @@ -81,7 +81,7 @@ typedef struct { u32 devNo; uuid_le devInstGuid; struct visorchipset_state state; - VISORCHIPSET_CHANNEL_INFO chanInfo; + struct visorchipset_channel_info chanInfo; u32 Reserved1; /* control_vm_id */ u64 Reserved2; u32 switchNo; /* when devState.attached==1 */ @@ -126,7 +126,7 @@ typedef struct { struct list_head entry; u32 busNo; struct visorchipset_state state; - VISORCHIPSET_CHANNEL_INFO chanInfo; + struct visorchipset_channel_info chanInfo; uuid_le partitionGuid; u64 partitionHandle; u8 *name; /* UTF8 */ diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 229c75881c5a..00a3445c3ce2 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1131,15 +1131,16 @@ bus_create(struct controlvm_message *inmsg) POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pBusInfo->chanInfo.addrType = ADDRTYPE_LOCALTEST; + pBusInfo->chanInfo.addr_type = ADDRTYPE_LOCALTEST; else - pBusInfo->chanInfo.addrType = ADDRTYPE_LOCALPHYSICAL; + pBusInfo->chanInfo.addr_type = ADDRTYPE_LOCALPHYSICAL; pBusInfo->flags.server = inmsg->hdr.flags.server; - pBusInfo->chanInfo.channelAddr = cmd->create_bus.channel_addr; - pBusInfo->chanInfo.nChannelBytes = cmd->create_bus.channel_bytes; - pBusInfo->chanInfo.channelTypeGuid = cmd->create_bus.bus_data_type_uuid; - pBusInfo->chanInfo.channelInstGuid = cmd->create_bus.bus_inst_uuid; + pBusInfo->chanInfo.channel_addr = cmd->create_bus.channel_addr; + pBusInfo->chanInfo.n_channel_bytes = cmd->create_bus.channel_bytes; + pBusInfo->chanInfo.channel_type_uuid = + cmd->create_bus.bus_data_type_uuid; + pBusInfo->chanInfo.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; list_add(&pBusInfo->entry, &BusInfoList); @@ -1281,19 +1282,20 @@ my_device_create(struct controlvm_message *inmsg) POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pDevInfo->chanInfo.addrType = ADDRTYPE_LOCALTEST; + pDevInfo->chanInfo.addr_type = ADDRTYPE_LOCALTEST; else - pDevInfo->chanInfo.addrType = ADDRTYPE_LOCALPHYSICAL; - pDevInfo->chanInfo.channelAddr = cmd->create_device.channel_addr; - pDevInfo->chanInfo.nChannelBytes = cmd->create_device.channel_bytes; - pDevInfo->chanInfo.channelTypeGuid = cmd->create_device.data_type_uuid; + pDevInfo->chanInfo.addr_type = ADDRTYPE_LOCALPHYSICAL; + pDevInfo->chanInfo.channel_addr = cmd->create_device.channel_addr; + pDevInfo->chanInfo.n_channel_bytes = cmd->create_device.channel_bytes; + pDevInfo->chanInfo.channel_type_uuid = + cmd->create_device.data_type_uuid; pDevInfo->chanInfo.intr = cmd->create_device.intr; list_add(&pDevInfo->entry, &DevInfoList); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); Away: /* get the bus and devNo for DiagPool channel */ - if (is_diagpool_channel(pDevInfo->chanInfo.channelTypeGuid)) { + if (is_diagpool_channel(pDevInfo->chanInfo.channel_type_uuid)) { g_diagpoolBusNo = busNo; g_diagpoolDevNo = devNo; LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", @@ -1302,7 +1304,7 @@ Away: device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); + FOR_VISORBUS(pDevInfo->chanInfo.channel_type_uuid)); } static void @@ -1336,7 +1338,8 @@ Away: device_epilog(busNo, devNo, state, CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); + FOR_VISORBUS( + pDevInfo->chanInfo.channel_type_uuid)); } static void @@ -1366,7 +1369,8 @@ Away: device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); + FOR_VISORBUS( + pDevInfo->chanInfo.channel_type_uuid)); } /* When provided with the physical address of the controlvm channel @@ -1932,7 +1936,7 @@ static HOSTADDRESS controlvm_get_channel_address(void) static void controlvm_periodic_work(struct work_struct *work) { - VISORCHIPSET_CHANNEL_INFO chanInfo; + struct visorchipset_channel_info chanInfo; struct controlvm_message inmsg; BOOL gotACommand = FALSE; BOOL handle_command_failed = FALSE; @@ -1947,7 +1951,7 @@ controlvm_periodic_work(struct work_struct *work) if (visorchipset_clientregwait && !clientregistered) goto Away; - memset(&chanInfo, 0, sizeof(VISORCHIPSET_CHANNEL_INFO)); + memset(&chanInfo, 0, sizeof(struct visorchipset_channel_info)); Poll_Count++; if (Poll_Count >= 250) -- cgit v1.2.3-59-g8ed1b From 246e0cd0985e3cf5ec316cd62dbb8bc9b3a93582 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:24 -0400 Subject: staging: unisys: refactor VISORCHIPSET_DEVICE_INFO Remove the typedef and use struct visorchipset_device_info instead. Fix CamelCase names: busNo => bus_no devNo => dev_no devInstGuid => dev_inst_guid chanInfo => chan_info Reserved1 => reserved1 Reserved2 => reserved2 switchNo => switch_no internalPortNo => internal_port_no pendingMsgHdr => pending_msg_hdr Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 34 +++++----- .../unisys/visorchipset/visorchipset_main.c | 78 +++++++++++----------- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index c8a936684cfb..a792cf263adb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -75,30 +75,30 @@ struct visorchipset_channel_info { * visorchipset_get_client_device_info() or * visorchipset_get_server_device_info(). */ -typedef struct { +struct visorchipset_device_info { struct list_head entry; - u32 busNo; - u32 devNo; - uuid_le devInstGuid; + u32 bus_no; + u32 dev_no; + uuid_le dev_inst_uuid; struct visorchipset_state state; - struct visorchipset_channel_info chanInfo; - u32 Reserved1; /* control_vm_id */ - u64 Reserved2; - u32 switchNo; /* when devState.attached==1 */ - u32 internalPortNo; /* when devState.attached==1 */ - struct controlvm_message_header pendingMsgHdr; /* CONTROLVM_MESSAGE */ + struct visorchipset_channel_info chan_info; + u32 reserved1; /* control_vm_id */ + u64 reserved2; + u32 switch_no; /* when devState.attached==1 */ + u32 internal_port_no; /* when devState.attached==1 */ + struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */ /** For private use by the bus driver */ void *bus_driver_context; -} VISORCHIPSET_DEVICE_INFO; +}; -static inline VISORCHIPSET_DEVICE_INFO * +static inline struct visorchipset_device_info * finddevice(struct list_head *list, u32 busNo, u32 devNo) { - VISORCHIPSET_DEVICE_INFO *p; + struct visorchipset_device_info *p; list_for_each_entry(p, list, entry) { - if (p->busNo == busNo && p->devNo == devNo) + if (p->bus_no == busNo && p->dev_no == devNo) return p; } return NULL; @@ -106,10 +106,10 @@ finddevice(struct list_head *list, u32 busNo, u32 devNo) static inline void delbusdevices(struct list_head *list, u32 busNo) { - VISORCHIPSET_DEVICE_INFO *p, *tmp; + struct visorchipset_device_info *p, *tmp; list_for_each_entry_safe(p, tmp, list, entry) { - if (p->busNo == busNo) { + if (p->bus_no == busNo) { list_del(&p->entry); kfree(p); } @@ -274,7 +274,7 @@ void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response); BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo); BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, - VISORCHIPSET_DEVICE_INFO *devInfo); + struct visorchipset_device_info *devInfo); BOOL visorchipset_get_switch_info(ulong switchNo, VISORCHIPSET_SWITCH_INFO *switchInfo); BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 00a3445c3ce2..ba74bf5dcc01 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -561,10 +561,11 @@ busInfo_clear(void *v) static void devInfo_clear(void *v) { - VISORCHIPSET_DEVICE_INFO *p = (VISORCHIPSET_DEVICE_INFO *) (v); + struct visorchipset_device_info *p = + (struct visorchipset_device_info *)(v); p->state.created = 0; - memset(p, 0, sizeof(VISORCHIPSET_DEVICE_INFO)); + memset(p, 0, sizeof(struct visorchipset_device_info)); } static u8 @@ -638,7 +639,7 @@ static void cleanup_controlvm_structures(void) { VISORCHIPSET_BUS_INFO *bi, *tmp_bi; - VISORCHIPSET_DEVICE_INFO *di, *tmp_di; + struct visorchipset_device_info *di, *tmp_di; list_for_each_entry_safe(bi, tmp_bi, &BusInfoList, entry) { busInfo_clear(bi); @@ -865,7 +866,7 @@ device_changestate_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, int response, struct spar_segment_state responseState) { - VISORCHIPSET_DEVICE_INFO *p = NULL; + struct visorchipset_device_info *p = NULL; struct controlvm_message outmsg; p = finddevice(&DevInfoList, busNo, devNo); @@ -873,16 +874,16 @@ device_changestate_responder(enum controlvm_id cmdId, LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); return; } - if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { + if (p->pending_msg_hdr.id == CONTROLVM_INVALID) { LOGERR("device_responder no pending msg"); return; /* no controlvm response needed */ } - if (p->pendingMsgHdr.id != cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); + if (p->pending_msg_hdr.id != cmdId) { + LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id); return; } - controlvm_init_response(&outmsg, &p->pendingMsgHdr, response); + controlvm_init_response(&outmsg, &p->pending_msg_hdr, response); outmsg.cmd.device_change_state.bus_no = busNo; outmsg.cmd.device_change_state.dev_no = devNo; @@ -894,14 +895,14 @@ device_changestate_responder(enum controlvm_id cmdId, return; } - p->pendingMsgHdr.id = CONTROLVM_INVALID; + p->pending_msg_hdr.id = CONTROLVM_INVALID; } static void device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, int response) { - VISORCHIPSET_DEVICE_INFO *p = NULL; + struct visorchipset_device_info *p = NULL; BOOL need_clear = FALSE; p = finddevice(&DevInfoList, busNo, devNo); @@ -916,16 +917,16 @@ device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo, need_clear = TRUE; } - if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { + if (p->pending_msg_hdr.id == CONTROLVM_INVALID) { LOGERR("device_responder no pending msg"); return; /* no controlvm response needed */ } - if (p->pendingMsgHdr.id != (u32) cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); + if (p->pending_msg_hdr.id != (u32) cmdId) { + LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id); return; } - controlvm_respond(&p->pendingMsgHdr, response); - p->pendingMsgHdr.id = CONTROLVM_INVALID; + controlvm_respond(&p->pending_msg_hdr, response); + p->pending_msg_hdr.id = CONTROLVM_INVALID; if (need_clear) devInfo_clear(p); } @@ -1005,7 +1006,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL; BOOL notified = FALSE; - VISORCHIPSET_DEVICE_INFO *pDevInfo = + struct visorchipset_device_info *pDevInfo = finddevice(&DevInfoList, busNo, devNo); char *envp[] = { "SPARSP_DIAGPOOL_PAUSED_STATE = 1", @@ -1021,10 +1022,10 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, else notifiers = &BusDev_Client_Notifiers; if (needResponse) { - memcpy(&pDevInfo->pendingMsgHdr, msgHdr, + memcpy(&pDevInfo->pending_msg_hdr, msgHdr, sizeof(struct controlvm_message_header)); } else - pDevInfo->pendingMsgHdr.id = CONTROLVM_INVALID; + pDevInfo->pending_msg_hdr.id = CONTROLVM_INVALID; down(&NotifierLock); if (response >= 0) { @@ -1234,7 +1235,7 @@ my_device_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->create_device.bus_no; ulong devNo = cmd->create_device.dev_no; - VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; + struct visorchipset_device_info *pDevInfo = NULL; VISORCHIPSET_BUS_INFO *pBusInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; @@ -1264,7 +1265,7 @@ my_device_create(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; goto Away; } - pDevInfo = kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL); + pDevInfo = kzalloc(sizeof(struct visorchipset_device_info), GFP_KERNEL); if (pDevInfo == NULL) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed", busNo, devNo); @@ -1275,27 +1276,27 @@ my_device_create(struct controlvm_message *inmsg) } INIT_LIST_HEAD(&pDevInfo->entry); - pDevInfo->busNo = busNo; - pDevInfo->devNo = devNo; - pDevInfo->devInstGuid = cmd->create_device.dev_inst_uuid; + pDevInfo->bus_no = busNo; + pDevInfo->dev_no = devNo; + pDevInfo->dev_inst_uuid = cmd->create_device.dev_inst_uuid; POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pDevInfo->chanInfo.addr_type = ADDRTYPE_LOCALTEST; + pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST; else - pDevInfo->chanInfo.addr_type = ADDRTYPE_LOCALPHYSICAL; - pDevInfo->chanInfo.channel_addr = cmd->create_device.channel_addr; - pDevInfo->chanInfo.n_channel_bytes = cmd->create_device.channel_bytes; - pDevInfo->chanInfo.channel_type_uuid = + pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; + pDevInfo->chan_info.channel_addr = cmd->create_device.channel_addr; + pDevInfo->chan_info.n_channel_bytes = cmd->create_device.channel_bytes; + pDevInfo->chan_info.channel_type_uuid = cmd->create_device.data_type_uuid; - pDevInfo->chanInfo.intr = cmd->create_device.intr; + pDevInfo->chan_info.intr = cmd->create_device.intr; list_add(&pDevInfo->entry, &DevInfoList); POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, POSTCODE_SEVERITY_INFO); Away: /* get the bus and devNo for DiagPool channel */ - if (is_diagpool_channel(pDevInfo->chanInfo.channel_type_uuid)) { + if (is_diagpool_channel(pDevInfo->chan_info.channel_type_uuid)) { g_diagpoolBusNo = busNo; g_diagpoolDevNo = devNo; LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", @@ -1304,7 +1305,7 @@ Away: device_epilog(busNo, devNo, segment_state_running, CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, - FOR_VISORBUS(pDevInfo->chanInfo.channel_type_uuid)); + FOR_VISORBUS(pDevInfo->chan_info.channel_type_uuid)); } static void @@ -1314,7 +1315,7 @@ my_device_changestate(struct controlvm_message *inmsg) ulong busNo = cmd->device_change_state.bus_no; ulong devNo = cmd->device_change_state.dev_no; struct spar_segment_state state = cmd->device_change_state.state; - VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; + struct visorchipset_device_info *pDevInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; pDevInfo = finddevice(&DevInfoList, busNo, devNo); @@ -1339,7 +1340,7 @@ Away: &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS( - pDevInfo->chanInfo.channel_type_uuid)); + pDevInfo->chan_info.channel_type_uuid)); } static void @@ -1348,7 +1349,7 @@ my_device_destroy(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->destroy_device.bus_no; ulong devNo = cmd->destroy_device.dev_no; - VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; + struct visorchipset_device_info *pDevInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; pDevInfo = finddevice(&DevInfoList, busNo, devNo); @@ -1370,7 +1371,7 @@ Away: CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, inmsg->hdr.flags.response_expected == 1, FOR_VISORBUS( - pDevInfo->chanInfo.channel_type_uuid)); + pDevInfo->chan_info.channel_type_uuid)); } /* When provided with the physical address of the controlvm channel @@ -2228,7 +2229,7 @@ EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, - VISORCHIPSET_DEVICE_INFO *devInfo) + struct visorchipset_device_info *devInfo) { void *p = finddevice(&DevInfoList, busNo, devNo); @@ -2236,7 +2237,7 @@ visorchipset_get_device_info(ulong busNo, ulong devNo, LOGERR("(%lu,%lu) failed", busNo, devNo); return FALSE; } - memcpy(devInfo, p, sizeof(VISORCHIPSET_DEVICE_INFO)); + memcpy(devInfo, p, sizeof(struct visorchipset_device_info)); return TRUE; } EXPORT_SYMBOL_GPL(visorchipset_get_device_info); @@ -2244,7 +2245,8 @@ EXPORT_SYMBOL_GPL(visorchipset_get_device_info); BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context) { - VISORCHIPSET_DEVICE_INFO *p = finddevice(&DevInfoList, busNo, devNo); + struct visorchipset_device_info *p = + finddevice(&DevInfoList, busNo, devNo); if (!p) { LOGERR("(%lu,%lu) failed", busNo, devNo); -- cgit v1.2.3-59-g8ed1b From 0a96ec728e71d5c170b2dcb3949e10ccab86cf0d Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:25 -0400 Subject: staging: unisys: fix CamelCase parameters in finddevice() Fix CamelCase names in finddevice(): busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index a792cf263adb..d2bb9f02b2ec 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -92,13 +92,13 @@ struct visorchipset_device_info { }; -static inline struct visorchipset_device_info * -finddevice(struct list_head *list, u32 busNo, u32 devNo) +static inline struct visorchipset_device_info *finddevice( + struct list_head *list, u32 bus_no, u32 dev_no) { struct visorchipset_device_info *p; list_for_each_entry(p, list, entry) { - if (p->bus_no == busNo && p->dev_no == devNo) + if (p->bus_no == bus_no && p->dev_no == dev_no) return p; } return NULL; -- cgit v1.2.3-59-g8ed1b From 8f67b5bc068b0ab8da6512d4ddb2f4806653bf6f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:26 -0400 Subject: staging: unisys: fix CamelCase parameters in delbusdevices() Fix the CamelCase parameter in delbusdevices() in visorchipset.h: busNo => bus_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index d2bb9f02b2ec..c36c08f9eb7d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -104,12 +104,12 @@ static inline struct visorchipset_device_info *finddevice( return NULL; } -static inline void delbusdevices(struct list_head *list, u32 busNo) +static inline void delbusdevices(struct list_head *list, u32 bus_no) { struct visorchipset_device_info *p, *tmp; list_for_each_entry_safe(p, tmp, list, entry) { - if (p->bus_no == busNo) { + if (p->bus_no == bus_no) { list_del(&p->entry); kfree(p); } -- cgit v1.2.3-59-g8ed1b From 33192fa1d173b91ba98c29cb8ab414c76ae3ff0b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:27 -0400 Subject: staging: unisys: refactor VISORCHIPSET_BUS_INFO Remove the typedef and use the name struct visorchipset_bus_info instead. Fix CamelCase member names in the structure: busNo => bus_no chanInfo => chan_info partitionGuid => partition_uuid partitionHandle => partition_handle Reserved1 => reserved1 Reserved2 => reserved2 procObject => proc_object Update references to changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 31 +++++----- .../unisys/visorchipset/visorchipset_main.c | 72 +++++++++++----------- 2 files changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index c36c08f9eb7d..b93174d73671 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -122,37 +122,37 @@ static inline void delbusdevices(struct list_head *list, u32 bus_no) * Any visorchipset client can query these attributes using * visorchipset_get_client_bus_info() or visorchipset_get_bus_info(). */ -typedef struct { +struct visorchipset_bus_info { struct list_head entry; - u32 busNo; + u32 bus_no; struct visorchipset_state state; - struct visorchipset_channel_info chanInfo; - uuid_le partitionGuid; - u64 partitionHandle; + struct visorchipset_channel_info chan_info; + uuid_le partition_uuid; + u64 partition_handle; u8 *name; /* UTF8 */ u8 *description; /* UTF8 */ - u64 Reserved1; - u32 Reserved2; - MYPROCOBJECT *procObject; + u64 reserved1; + u32 reserved2; + MYPROCOBJECT *proc_object; struct { u32 server:1; /* Add new fields above. */ /* Remaining bits in this 32-bit word are unused. */ } flags; - struct controlvm_message_header pendingMsgHdr; /* CONTROLVM MsgHdr */ + struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */ /** For private use by the bus driver */ void *bus_driver_context; - u64 devNo; + u64 dev_no; -} VISORCHIPSET_BUS_INFO; +}; -static inline VISORCHIPSET_BUS_INFO * +static inline struct visorchipset_bus_info * findbus(struct list_head *list, u32 busNo) { - VISORCHIPSET_BUS_INFO *p; + struct visorchipset_bus_info *p; list_for_each_entry(p, list, entry) { - if (p->busNo == busNo) + if (p->bus_no == busNo) return p; } return NULL; @@ -272,7 +272,8 @@ typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response); -BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo); +BOOL visorchipset_get_bus_info(ulong busNo, + struct visorchipset_bus_info *busInfo); BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, struct visorchipset_device_info *devInfo); BOOL visorchipset_get_switch_info(ulong switchNo, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index ba74bf5dcc01..5f3d6cd52dc3 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -542,11 +542,11 @@ testUnicode(void) static void busInfo_clear(void *v) { - VISORCHIPSET_BUS_INFO *p = (VISORCHIPSET_BUS_INFO *) (v); + struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v); - if (p->procObject) { - visor_proc_DestroyObject(p->procObject); - p->procObject = NULL; + if (p->proc_object) { + visor_proc_DestroyObject(p->proc_object); + p->proc_object = NULL; } kfree(p->name); p->name = NULL; @@ -555,7 +555,7 @@ busInfo_clear(void *v) p->description = NULL; p->state.created = 0; - memset(p, 0, sizeof(VISORCHIPSET_BUS_INFO)); + memset(p, 0, sizeof(struct visorchipset_bus_info)); } static void @@ -638,7 +638,7 @@ EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client); static void cleanup_controlvm_structures(void) { - VISORCHIPSET_BUS_INFO *bi, *tmp_bi; + struct visorchipset_bus_info *bi, *tmp_bi; struct visorchipset_device_info *di, *tmp_di; list_for_each_entry_safe(bi, tmp_bi, &BusInfoList, entry) { @@ -825,7 +825,7 @@ EXPORT_SYMBOL_GPL(visorchipset_save_message); static void bus_responder(enum controlvm_id cmdId, ulong busNo, int response) { - VISORCHIPSET_BUS_INFO *p = NULL; + struct visorchipset_bus_info *p = NULL; BOOL need_clear = FALSE; p = findbus(&BusInfoList, busNo); @@ -845,16 +845,16 @@ bus_responder(enum controlvm_id cmdId, ulong busNo, int response) need_clear = TRUE; } - if (p->pendingMsgHdr.id == CONTROLVM_INVALID) { + if (p->pending_msg_hdr.id == CONTROLVM_INVALID) { LOGERR("bus_responder no pending msg"); return; /* no controlvm response needed */ } - if (p->pendingMsgHdr.id != (u32) cmdId) { - LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.id); + if (p->pending_msg_hdr.id != (u32) cmdId) { + LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id); return; } - controlvm_respond(&p->pendingMsgHdr, response); - p->pendingMsgHdr.id = CONTROLVM_INVALID; + controlvm_respond(&p->pending_msg_hdr, response); + p->pending_msg_hdr.id = CONTROLVM_INVALID; if (need_clear) { busInfo_clear(p); delbusdevices(&DevInfoList, busNo); @@ -938,17 +938,17 @@ bus_epilog(u32 busNo, { BOOL notified = FALSE; - VISORCHIPSET_BUS_INFO *pBusInfo = findbus(&BusInfoList, busNo); + struct visorchipset_bus_info *pBusInfo = findbus(&BusInfoList, busNo); if (!pBusInfo) { LOGERR("HUH? bad busNo=%d", busNo); return; } if (needResponse) { - memcpy(&pBusInfo->pendingMsgHdr, msgHdr, + memcpy(&pBusInfo->pending_msg_hdr, msgHdr, sizeof(struct controlvm_message_header)); } else - pBusInfo->pendingMsgHdr.id = CONTROLVM_INVALID; + pBusInfo->pending_msg_hdr.id = CONTROLVM_INVALID; down(&NotifierLock); if (response == CONTROLVM_RESP_SUCCESS) { @@ -1103,7 +1103,7 @@ bus_create(struct controlvm_message *inmsg) struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->create_bus.bus_no; int rc = CONTROLVM_RESP_SUCCESS; - VISORCHIPSET_BUS_INFO *pBusInfo = NULL; + struct visorchipset_bus_info *pBusInfo = NULL; pBusInfo = findbus(&BusInfoList, busNo); @@ -1115,7 +1115,7 @@ bus_create(struct controlvm_message *inmsg) rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; goto Away; } - pBusInfo = kzalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL); + pBusInfo = kzalloc(sizeof(struct visorchipset_bus_info), GFP_KERNEL); if (pBusInfo == NULL) { LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed", busNo); @@ -1126,22 +1126,22 @@ bus_create(struct controlvm_message *inmsg) } INIT_LIST_HEAD(&pBusInfo->entry); - pBusInfo->busNo = busNo; - pBusInfo->devNo = cmd->create_bus.dev_count; + pBusInfo->bus_no = busNo; + pBusInfo->dev_no = cmd->create_bus.dev_count; POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); if (inmsg->hdr.flags.test_message == 1) - pBusInfo->chanInfo.addr_type = ADDRTYPE_LOCALTEST; + pBusInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST; else - pBusInfo->chanInfo.addr_type = ADDRTYPE_LOCALPHYSICAL; + pBusInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL; pBusInfo->flags.server = inmsg->hdr.flags.server; - pBusInfo->chanInfo.channel_addr = cmd->create_bus.channel_addr; - pBusInfo->chanInfo.n_channel_bytes = cmd->create_bus.channel_bytes; - pBusInfo->chanInfo.channel_type_uuid = + pBusInfo->chan_info.channel_addr = cmd->create_bus.channel_addr; + pBusInfo->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes; + pBusInfo->chan_info.channel_type_uuid = cmd->create_bus.bus_data_type_uuid; - pBusInfo->chanInfo.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; + pBusInfo->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid; list_add(&pBusInfo->entry, &BusInfoList); @@ -1157,7 +1157,7 @@ bus_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->destroy_bus.bus_no; - VISORCHIPSET_BUS_INFO *pBusInfo; + struct visorchipset_bus_info *pBusInfo; int rc = CONTROLVM_RESP_SUCCESS; pBusInfo = findbus(&BusInfoList, busNo); @@ -1183,7 +1183,7 @@ bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx) { struct controlvm_message_packet *cmd = &inmsg->cmd; ulong busNo = cmd->configure_bus.bus_no; - VISORCHIPSET_BUS_INFO *pBusInfo = NULL; + struct visorchipset_bus_info *pBusInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; char s[99]; @@ -1208,21 +1208,21 @@ bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx) goto Away; } /* TBD - add this check to other commands also... */ - if (pBusInfo->pendingMsgHdr.id != CONTROLVM_INVALID) { + if (pBusInfo->pending_msg_hdr.id != CONTROLVM_INVALID) { LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding", - busNo, (uint) pBusInfo->pendingMsgHdr.id); + busNo, (uint) pBusInfo->pending_msg_hdr.id); POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; goto Away; } - pBusInfo->partitionHandle = cmd->configure_bus.guest_handle; - pBusInfo->partitionGuid = parser_id_get(parser_ctx); + pBusInfo->partition_handle = cmd->configure_bus.guest_handle; + pBusInfo->partition_uuid = parser_id_get(parser_ctx); parser_param_start(parser_ctx, PARSERSTRING_NAME); pBusInfo->name = parser_string_get(parser_ctx); - visorchannel_uuid_id(&pBusInfo->partitionGuid, s); + visorchannel_uuid_id(&pBusInfo->partition_uuid, s); POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); Away: bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, @@ -1236,7 +1236,7 @@ my_device_create(struct controlvm_message *inmsg) ulong busNo = cmd->create_device.bus_no; ulong devNo = cmd->create_device.dev_no; struct visorchipset_device_info *pDevInfo = NULL; - VISORCHIPSET_BUS_INFO *pBusInfo = NULL; + struct visorchipset_bus_info *pBusInfo = NULL; int rc = CONTROLVM_RESP_SUCCESS; pDevInfo = finddevice(&DevInfoList, busNo, devNo); @@ -2200,7 +2200,7 @@ device_resume_response(ulong busNo, ulong devNo, int response) } BOOL -visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo) +visorchipset_get_bus_info(ulong busNo, struct visorchipset_bus_info *busInfo) { void *p = findbus(&BusInfoList, busNo); @@ -2208,7 +2208,7 @@ visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo) LOGERR("(%lu) failed", busNo); return FALSE; } - memcpy(busInfo, p, sizeof(VISORCHIPSET_BUS_INFO)); + memcpy(busInfo, p, sizeof(struct visorchipset_bus_info)); return TRUE; } EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); @@ -2216,7 +2216,7 @@ EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); BOOL visorchipset_set_bus_context(ulong busNo, void *context) { - VISORCHIPSET_BUS_INFO *p = findbus(&BusInfoList, busNo); + struct visorchipset_bus_info *p = findbus(&BusInfoList, busNo); if (!p) { LOGERR("(%lu) failed", busNo); -- cgit v1.2.3-59-g8ed1b From b4d55e39a34bf93d307965b8d340a80170cea535 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:28 -0400 Subject: staging: unisys: fix CamelCase in findbus() Fix the CamelCase parameter name in findbus() in visorchipset.h. busNo => bus_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index b93174d73671..a578d0a0714b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -147,12 +147,12 @@ struct visorchipset_bus_info { }; static inline struct visorchipset_bus_info * -findbus(struct list_head *list, u32 busNo) +findbus(struct list_head *list, u32 bus_no) { struct visorchipset_bus_info *p; list_for_each_entry(p, list, entry) { - if (p->bus_no == busNo) + if (p->bus_no == bus_no) return p; } return NULL; -- cgit v1.2.3-59-g8ed1b From e2320e653e99d70bd58e61344f2d472d5dac3126 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:29 -0400 Subject: staging: unisys: refactor VISORCHIPSET_SWITCH_INFO Remove the typedef and use struct visorchipset_switch_info instead. Fix all CamelCase member names: switchNo => switch_no switchTypeGuid => switch_type_uuid authService1 => authservice1 authService2 => authservice2 authService3 => authservice3 securityContext => security_context Reserved => reserved Reserved2 => reserved2 pendingMsgHdr => pending_msg_hdr Signed-off-by: Benjamin Romer --- drivers/staging/unisys/visorchipset/visorchipset.h | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index a578d0a0714b..762bc1380085 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -160,21 +160,20 @@ findbus(struct list_head *list, u32 bus_no) /** Attributes for a particular Supervisor switch. */ -typedef struct { - u32 switchNo; +struct visorchipset_switch_info { + u32 switch_no; struct visorchipset_state state; - uuid_le switchTypeGuid; - u8 *authService1; - u8 *authService2; - u8 *authService3; - u8 *securityContext; - u64 Reserved; - u32 Reserved2; /* control_vm_id */ + uuid_le switch_type_uuid; + u8 *authservice1; + u8 *authservice2; + u8 *authservice3; + u8 *security_context; + u64 reserved; + u32 reserved2; /* control_vm_id */ struct device dev; BOOL dev_exists; - struct controlvm_message_header pendingMsgHdr; - -} VISORCHIPSET_SWITCH_INFO; + struct controlvm_message_header pending_msg_hdr; +}; /** Attributes for a particular Supervisor external port, which is connected * to a specific switch. @@ -277,7 +276,7 @@ BOOL visorchipset_get_bus_info(ulong busNo, BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, struct visorchipset_device_info *devInfo); BOOL visorchipset_get_switch_info(ulong switchNo, - VISORCHIPSET_SWITCH_INFO *switchInfo); + struct visorchipset_switch_info *switchInfo); BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo, VISORCHIPSET_EXTERNALPORT_INFO *externalPortInfo); -- cgit v1.2.3-59-g8ed1b From 53414833fe7979153cd238a8829e0fea01eb1e7b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:30 -0400 Subject: staging: unisys: refactor VISORCHIPSET_EXTERNALPORT_INFO Remove the typedef and just use struct visorchipset_externalport_info instead. Fix all CamelCase names: switchNo => switch_no externalPortNo => external_port_no networkZoneGuid => network_zone_uuid pdPort => pd_port ipNetmask => ip_netmask ipBroadcast => ip_broadcast ipNetwork => ip_network ipGateway => ip_gateway ipDNS => ip_dns Reserved1 => reserved1 Reserved2 => reserved2 pendingMsgHdr => pending_msg_hdr Signed-off-by: Benjamin Romer --- drivers/staging/unisys/visorchipset/visorchipset.h | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 762bc1380085..e20eb10e4250 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -178,25 +178,24 @@ struct visorchipset_switch_info { /** Attributes for a particular Supervisor external port, which is connected * to a specific switch. */ -typedef struct { - u32 switchNo; - u32 externalPortNo; +struct visorchipset_externalport_info { + u32 switch_no; + u32 external_port_no; struct visorchipset_state state; - uuid_le networkZoneGuid; - int pdPort; + uuid_le network_zone_uuid; + int pd_port; u8 *ip; - u8 *ipNetmask; - u8 *ipBroadcast; - u8 *ipNetwork; - u8 *ipGateway; - u8 *ipDNS; - u64 Reserved1; - u32 Reserved2; /* control_vm_id */ + u8 *ip_netmask; + u8 *ip_broadcast; + u8 *ip_network; + u8 *ip_gateway; + u8 *ip_dns; + u64 reserved1; + u32 reserved2; /* control_vm_id */ struct device dev; BOOL dev_exists; - struct controlvm_message_header pendingMsgHdr; - -} VISORCHIPSET_EXTERNALPORT_INFO; + struct controlvm_message_header pending_msg_hdr; +}; /** Attributes for a particular Supervisor internal port, which is how a * device connects to a particular switch. @@ -278,7 +277,7 @@ BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, BOOL visorchipset_get_switch_info(ulong switchNo, struct visorchipset_switch_info *switchInfo); BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo, - VISORCHIPSET_EXTERNALPORT_INFO + struct visorchipset_externalport_info *externalPortInfo); BOOL visorchipset_set_bus_context(ulong busNo, void *context); BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context); -- cgit v1.2.3-59-g8ed1b From 2924bbc97f63bd166f6f97c0bf71656eabab5a87 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:31 -0400 Subject: staging: unisys: refactor VISORCHIPSET_INTERNALPORT_INFO Get rid of the typedef and use struct visorchipset_internalport_info and fix CamelCase member names: switchNo => switch_no internalPortNo => internal_port_no busNo => bus_no devNo => dev_no Reserved1 => reserved1 Reserved2 => reserved2 pendingMsgHdr => pending_msg_hdr procObject => proc_object Signed-off-by: Benjamin Romer --- drivers/staging/unisys/visorchipset/visorchipset.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index e20eb10e4250..7d3b2c1db045 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -200,18 +200,18 @@ struct visorchipset_externalport_info { /** Attributes for a particular Supervisor internal port, which is how a * device connects to a particular switch. */ -typedef struct { - u32 switchNo; - u32 internalPortNo; +struct visorchipset_internalport_info { + u32 switch_no; + u32 internal_port_no; struct visorchipset_state state; - u32 busNo; /* valid only when state.attached == 1 */ - u32 devNo; /* valid only when state.attached == 1 */ - u64 Reserved1; - u32 Reserved2; /* CONTROLVM_ID */ - struct controlvm_message_header pendingMsgHdr; - MYPROCOBJECT *procObject; - -} VISORCHIPSET_INTERNALPORT_INFO; + u32 bus_no; /* valid only when state.attached == 1 */ + u32 dev_no; /* valid only when state.attached == 1 */ + u64 reserved1; + u32 reserved2; /* CONTROLVM_ID */ + struct controlvm_message_header pending_msg_hdr; + MYPROCOBJECT *proc_object; + +}; /* These functions will be called from within visorchipset when certain * events happen. (The implementation of these functions is outside of -- cgit v1.2.3-59-g8ed1b From fe90d8926c93601b739f7cdd39fcf445c8687709 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:32 -0400 Subject: staging: unisys: refactor VISORCHIPSET_BUSDEV_NOTIFIERS Get rid of the typedef and just use struct visorchipset_busdev_notifiers instead. Fix CamelCase names in parameters for the function pointers: busNo => bus_no devNo => dev_no typeGuid => type_uuid minSize => min_size maxSize => max_size Update references. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 34 ++++++++++++---------- .../unisys/visorchipset/visorchipset_main.c | 20 +++++++------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 7d3b2c1db045..da14ef73f850 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -217,16 +217,16 @@ struct visorchipset_internalport_info { * events happen. (The implementation of these functions is outside of * visorchipset.) */ -typedef struct { - void (*bus_create)(ulong busNo); - void (*bus_destroy)(ulong busNo); - void (*device_create)(ulong busNo, ulong devNo); - void (*device_destroy)(ulong busNo, ulong devNo); - void (*device_pause)(ulong busNo, ulong devNo); - void (*device_resume)(ulong busNo, ulong devNo); - int (*get_channel_info)(uuid_le typeGuid, ulong *minSize, - ulong *maxSize); -} VISORCHIPSET_BUSDEV_NOTIFIERS; +struct visorchipset_busdev_notifiers { + void (*bus_create)(ulong bus_no); + void (*bus_destroy)(ulong bus_no); + void (*device_create)(ulong bus_no, ulong dev_no); + void (*device_destroy)(ulong bus_no, ulong dev_no); + void (*device_pause)(ulong bus_no, ulong dev_no); + void (*device_resume)(ulong bus_no, ulong dev_no); + int (*get_channel_info)(uuid_le type_uuid, ulong *min_size, + ulong *max_size); +}; /* These functions live inside visorchipset, and will be called to indicate * responses to specific events (by code outside of visorchipset). @@ -250,9 +250,10 @@ typedef struct { * responses. */ void -visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, - struct ultra_vbus_deviceinfo *driverInfo); +visorchipset_register_busdev_client( + struct visorchipset_busdev_notifiers *notifiers, + VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct ultra_vbus_deviceinfo *driverInfo); /** Register functions (in the bus driver) to get called by visorchipset * whenever a bus or device appears for which this service partition is @@ -261,9 +262,10 @@ visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, * responses. */ void -visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, - struct ultra_vbus_deviceinfo *driverInfo); +visorchipset_register_busdev_server( + struct visorchipset_busdev_notifiers *notifiers, + VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct ultra_vbus_deviceinfo *driverInfo); typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, int status); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 5f3d6cd52dc3..ee0c88af11f0 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -230,8 +230,8 @@ static void parahotplug_process_list(void); /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / * CONTROLVM_REPORTEVENT. */ -static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Server_Notifiers; -static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Client_Notifiers; +static struct visorchipset_busdev_notifiers BusDev_Server_Notifiers; +static struct visorchipset_busdev_notifiers BusDev_Client_Notifiers; static void bus_create_response(ulong busNo, int response); static void bus_destroy_response(ulong busNo, int response); @@ -589,9 +589,10 @@ clear_chipset_events(void) } void -visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, - struct ultra_vbus_deviceinfo *driverInfo) +visorchipset_register_busdev_server( + struct visorchipset_busdev_notifiers *notifiers, + VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct ultra_vbus_deviceinfo *driverInfo) { down(&NotifierLock); if (notifiers == NULL) { @@ -613,9 +614,10 @@ visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); void -visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, - struct ultra_vbus_deviceinfo *driverInfo) +visorchipset_register_busdev_client( + struct visorchipset_busdev_notifiers *notifiers, + VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct ultra_vbus_deviceinfo *driverInfo) { down(&NotifierLock); if (notifiers == NULL) { @@ -1003,7 +1005,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, struct controlvm_message_header *msgHdr, int response, BOOL needResponse, BOOL for_visorbus) { - VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL; + struct visorchipset_busdev_notifiers *notifiers = NULL; BOOL notified = FALSE; struct visorchipset_device_info *pDevInfo = -- cgit v1.2.3-59-g8ed1b From 929aa8ae2f14ecf3cdae4c3124ebe119f83d0224 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:33 -0400 Subject: staging: unisys: refactor VISORCHIPSET_BUSDEV_RESPONDERS Get rid of the typedef and just use struct visorchipset_busdev_responders instead. Fix CamelCase parameter names in the function pointer definitions for the structure: busNo => bus_no devNo => dev_no Update references to changed names. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 20 ++++++++++---------- .../staging/unisys/visorchipset/visorchipset_main.c | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index da14ef73f850..f4c6ff1d9c39 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -234,14 +234,14 @@ struct visorchipset_busdev_notifiers { * 0 = it worked * -1 = it failed */ -typedef struct { - void (*bus_create)(ulong busNo, int response); - void (*bus_destroy)(ulong busNo, int response); - void (*device_create)(ulong busNo, ulong devNo, int response); - void (*device_destroy)(ulong busNo, ulong devNo, int response); - void (*device_pause)(ulong busNo, ulong devNo, int response); - void (*device_resume)(ulong busNo, ulong devNo, int response); -} VISORCHIPSET_BUSDEV_RESPONDERS; +struct visorchipset_busdev_responders { + void (*bus_create)(ulong bus_no, int response); + void (*bus_destroy)(ulong bus_no, int response); + void (*device_create)(ulong bus_no, ulong dev_no, int response); + void (*device_destroy)(ulong bus_no, ulong dev_no, int response); + void (*device_pause)(ulong bus_no, ulong dev_no, int response); + void (*device_resume)(ulong bus_no, ulong dev_no, int response); +}; /** Register functions (in the bus driver) to get called by visorchipset * whenever a bus or device appears for which this service partition is @@ -252,7 +252,7 @@ typedef struct { void visorchipset_register_busdev_client( struct visorchipset_busdev_notifiers *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driverInfo); /** Register functions (in the bus driver) to get called by visorchipset @@ -264,7 +264,7 @@ visorchipset_register_busdev_client( void visorchipset_register_busdev_server( struct visorchipset_busdev_notifiers *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driverInfo); typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index ee0c88af11f0..12746e0a4e86 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -239,7 +239,7 @@ static void device_create_response(ulong busNo, ulong devNo, int response); static void device_destroy_response(ulong busNo, ulong devNo, int response); static void device_resume_response(ulong busNo, ulong devNo, int response); -static VISORCHIPSET_BUSDEV_RESPONDERS BusDev_Responders = { +static struct visorchipset_busdev_responders BusDev_Responders = { .bus_create = bus_create_response, .bus_destroy = bus_destroy_response, .device_create = device_create_response, @@ -591,7 +591,7 @@ clear_chipset_events(void) void visorchipset_register_busdev_server( struct visorchipset_busdev_notifiers *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driverInfo) { down(&NotifierLock); @@ -616,7 +616,7 @@ EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); void visorchipset_register_busdev_client( struct visorchipset_busdev_notifiers *notifiers, - VISORCHIPSET_BUSDEV_RESPONDERS *responders, + struct visorchipset_busdev_responders *responders, struct ultra_vbus_deviceinfo *driverInfo) { down(&NotifierLock); @@ -991,7 +991,7 @@ bus_epilog(u32 busNo, } if (notified) /* The callback function just called above is responsible - * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS + * for calling the appropriate visorchipset_busdev_responders * function, which will call bus_responder() */ ; @@ -1090,7 +1090,7 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd, } if (notified) /* The callback function just called above is responsible - * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS + * for calling the appropriate visorchipset_busdev_responders * function, which will call device_responder() */ ; -- cgit v1.2.3-59-g8ed1b From 43fce019e90fbe4283ac26b3e9f8445ae7533c1e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:34 -0400 Subject: staging: unisys: fix CamelCase name in visorchipset_register_busdev_client() Fix CamelCase parameter: driverInfo => driver_info Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index f4c6ff1d9c39..e8687ad9dda5 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -253,7 +253,7 @@ void visorchipset_register_busdev_client( struct visorchipset_busdev_notifiers *notifiers, struct visorchipset_busdev_responders *responders, - struct ultra_vbus_deviceinfo *driverInfo); + struct ultra_vbus_deviceinfo *driver_info); /** Register functions (in the bus driver) to get called by visorchipset * whenever a bus or device appears for which this service partition is diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 12746e0a4e86..0dfd8f4b78bb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -617,7 +617,7 @@ void visorchipset_register_busdev_client( struct visorchipset_busdev_notifiers *notifiers, struct visorchipset_busdev_responders *responders, - struct ultra_vbus_deviceinfo *driverInfo) + struct ultra_vbus_deviceinfo *driver_info) { down(&NotifierLock); if (notifiers == NULL) { @@ -630,9 +630,9 @@ visorchipset_register_busdev_client( } if (responders) *responders = BusDev_Responders; - if (driverInfo) - bus_device_info_init(driverInfo, "chipset(bolts)", "visorchipset", - VERSION, NULL); + if (driver_info) + bus_device_info_init(driver_info, "chipset(bolts)", + "visorchipset", VERSION, NULL); up(&NotifierLock); } EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client); -- cgit v1.2.3-59-g8ed1b From 1e7a59c1464eb0bb2bc6940ba963845fa246fa61 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:35 -0400 Subject: staging: unisys: fix CamelCase name in visorchipset_register_busdev_server() Fix CamelCase name: driverInfo => driver_info Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index e8687ad9dda5..4bafcf2ecd1d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -265,7 +265,7 @@ void visorchipset_register_busdev_server( struct visorchipset_busdev_notifiers *notifiers, struct visorchipset_busdev_responders *responders, - struct ultra_vbus_deviceinfo *driverInfo); + struct ultra_vbus_deviceinfo *driver_info); typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, int status); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 0dfd8f4b78bb..95545b9e2d50 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -592,7 +592,7 @@ void visorchipset_register_busdev_server( struct visorchipset_busdev_notifiers *notifiers, struct visorchipset_busdev_responders *responders, - struct ultra_vbus_deviceinfo *driverInfo) + struct ultra_vbus_deviceinfo *driver_info) { down(&NotifierLock); if (notifiers == NULL) { @@ -605,8 +605,8 @@ visorchipset_register_busdev_server( } if (responders) *responders = BusDev_Responders; - if (driverInfo) - bus_device_info_init(driverInfo, "chipset", "visorchipset", + if (driver_info) + bus_device_info_init(driver_info, "chipset", "visorchipset", VERSION, NULL); up(&NotifierLock); -- cgit v1.2.3-59-g8ed1b From 8420f417e52682bb828dc7d7fd19b7c58b89d658 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:36 -0400 Subject: staging: unisys: fix CamelCase in visorchipset_device_pause_response() Fix CamelCase parameters: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 3 ++- drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 4bafcf2ecd1d..8ed92f0d73c5 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -270,7 +270,8 @@ visorchipset_register_busdev_server( typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, int status); -void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response); +void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, + int response); BOOL visorchipset_get_bus_info(ulong busNo, struct visorchipset_bus_info *busInfo); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 95545b9e2d50..8c6e73024bbe 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2184,11 +2184,11 @@ device_destroy_response(ulong busNo, ulong devNo, int response) } void -visorchipset_device_pause_response(ulong busNo, ulong devNo, int response) +visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response) { device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, - busNo, devNo, response, + bus_no, dev_no, response, segment_state_standby); } EXPORT_SYMBOL_GPL(visorchipset_device_pause_response); -- cgit v1.2.3-59-g8ed1b From 77db7127c7e63a642525114d80ca350ce1eabf39 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:37 -0400 Subject: staging: unisys: fix CamelCase in visorchipset_get_bus_info Fix CamelCase names: busNo => bus_no busInfo => bus_info Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 4 ++-- drivers/staging/unisys/visorchipset/visorchipset_main.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 8ed92f0d73c5..6f42712dfcd1 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -273,8 +273,8 @@ typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response); -BOOL visorchipset_get_bus_info(ulong busNo, - struct visorchipset_bus_info *busInfo); +BOOL visorchipset_get_bus_info(ulong bus_no, + struct visorchipset_bus_info *bus_info); BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, struct visorchipset_device_info *devInfo); BOOL visorchipset_get_switch_info(ulong switchNo, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 8c6e73024bbe..041dba0d9e06 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2202,15 +2202,15 @@ device_resume_response(ulong busNo, ulong devNo, int response) } BOOL -visorchipset_get_bus_info(ulong busNo, struct visorchipset_bus_info *busInfo) +visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info) { - void *p = findbus(&BusInfoList, busNo); + void *p = findbus(&BusInfoList, bus_no); if (!p) { - LOGERR("(%lu) failed", busNo); + LOGERR("(%lu) failed", bus_no); return FALSE; } - memcpy(busInfo, p, sizeof(struct visorchipset_bus_info)); + memcpy(bus_info, p, sizeof(struct visorchipset_bus_info)); return TRUE; } EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); -- cgit v1.2.3-59-g8ed1b From b486df191c629718bb64d6e2ae8d78b8a4de9276 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:38 -0400 Subject: staging: unisys: fix CamelCase in visorchipset_get_device_info() Fix CamelCase names: busNo => bus_no devNo => dev_no devInfo => dev_info Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 4 ++-- drivers/staging/unisys/visorchipset/visorchipset_main.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 6f42712dfcd1..7265e2ffc8a8 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -275,8 +275,8 @@ void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, BOOL visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info); -BOOL visorchipset_get_device_info(ulong busNo, ulong devNo, - struct visorchipset_device_info *devInfo); +BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, + struct visorchipset_device_info *dev_info); BOOL visorchipset_get_switch_info(ulong switchNo, struct visorchipset_switch_info *switchInfo); BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo, diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 041dba0d9e06..bebd0e4a3b94 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2230,16 +2230,16 @@ visorchipset_set_bus_context(ulong busNo, void *context) EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); BOOL -visorchipset_get_device_info(ulong busNo, ulong devNo, - struct visorchipset_device_info *devInfo) +visorchipset_get_device_info(ulong bus_no, ulong dev_no, + struct visorchipset_device_info *dev_info) { - void *p = finddevice(&DevInfoList, busNo, devNo); + void *p = finddevice(&DevInfoList, bus_no, dev_no); if (!p) { - LOGERR("(%lu,%lu) failed", busNo, devNo); + LOGERR("(%lu,%lu) failed", bus_no, dev_no); return FALSE; } - memcpy(devInfo, p, sizeof(struct visorchipset_device_info)); + memcpy(dev_info, p, sizeof(struct visorchipset_device_info)); return TRUE; } EXPORT_SYMBOL_GPL(visorchipset_get_device_info); -- cgit v1.2.3-59-g8ed1b From 5c01b454d828098421c9c93b42dc338037b47c10 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:39 -0400 Subject: staging: unisys: remove unused definitions from visorchipset.h Delete visorchipset_get_switch_info() and visorchipset_get_externalport_info() as these functions were declared but not defined, or used. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 7265e2ffc8a8..ac8f44db449c 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -277,11 +277,6 @@ BOOL visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info); BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, struct visorchipset_device_info *dev_info); -BOOL visorchipset_get_switch_info(ulong switchNo, - struct visorchipset_switch_info *switchInfo); -BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo, - struct visorchipset_externalport_info - *externalPortInfo); BOOL visorchipset_set_bus_context(ulong busNo, void *context); BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context); int visorchipset_chipset_ready(void); -- cgit v1.2.3-59-g8ed1b From 58dd8f2d79549b53f49b9198bbddb3de94b49760 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:40 -0400 Subject: staging: unisys: fix CamelCase in visorchipset_set_bus_context() Fix CamelCase parameter: busNo => bus_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index ac8f44db449c..9302036c6ecd 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -277,7 +277,7 @@ BOOL visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info); BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, struct visorchipset_device_info *dev_info); -BOOL visorchipset_set_bus_context(ulong busNo, void *context); +BOOL visorchipset_set_bus_context(ulong bus_no, void *context); BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context); int visorchipset_chipset_ready(void); int visorchipset_chipset_selftest(void); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index bebd0e4a3b94..873b9ea875fb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2216,12 +2216,12 @@ visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info) EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); BOOL -visorchipset_set_bus_context(ulong busNo, void *context) +visorchipset_set_bus_context(ulong bus_no, void *context) { - struct visorchipset_bus_info *p = findbus(&BusInfoList, busNo); + struct visorchipset_bus_info *p = findbus(&BusInfoList, bus_no); if (!p) { - LOGERR("(%lu) failed", busNo); + LOGERR("(%lu) failed", bus_no); return FALSE; } p->bus_driver_context = context; -- cgit v1.2.3-59-g8ed1b From cf0bd0b5794ba4832cd482d60edf0c32bb060745 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:41 -0400 Subject: staging: unisys: fix CamelCase in visorchipset_set_device_context() Fix CamelCase parameter names: busNo => bus_no devNo => dev_no Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 9302036c6ecd..5efc2d6dc57b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -278,7 +278,7 @@ BOOL visorchipset_get_bus_info(ulong bus_no, BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, struct visorchipset_device_info *dev_info); BOOL visorchipset_set_bus_context(ulong bus_no, void *context); -BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context); +BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context); int visorchipset_chipset_ready(void); int visorchipset_chipset_selftest(void); int visorchipset_chipset_notready(void); diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 873b9ea875fb..b5a0e460da07 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2245,13 +2245,13 @@ visorchipset_get_device_info(ulong bus_no, ulong dev_no, EXPORT_SYMBOL_GPL(visorchipset_get_device_info); BOOL -visorchipset_set_device_context(ulong busNo, ulong devNo, void *context) +visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context) { struct visorchipset_device_info *p = - finddevice(&DevInfoList, busNo, devNo); + finddevice(&DevInfoList, bus_no, dev_no); if (!p) { - LOGERR("(%lu,%lu) failed", busNo, devNo); + LOGERR("(%lu,%lu) failed", bus_no, dev_no); return FALSE; } p->bus_driver_context = context; -- cgit v1.2.3-59-g8ed1b From 60f4cf035e232e06f9f1895bb0b6cee4eaa41bfb Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:42 -0400 Subject: staging: unisys: remove visorchipset_controlvm_respond_reportEvent() No one is using this definition so remove it. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 5efc2d6dc57b..4963cbccdc2b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -282,8 +282,6 @@ BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context); int visorchipset_chipset_ready(void); int visorchipset_chipset_selftest(void); int visorchipset_chipset_notready(void); -void visorchipset_controlvm_respond_reportEvent(struct controlvm_message *msg, - void *payload); void visorchipset_save_message(struct controlvm_message *msg, enum crash_obj_type type); void *visorchipset_cache_alloc(struct kmem_cache *pool, -- cgit v1.2.3-59-g8ed1b From 10c295a1d20c493d06d910ff2a244bdbb1c223cc Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Fri, 31 Oct 2014 09:57:43 -0400 Subject: staging: unisys: remove unused macros from visorchipset.h Delete the macros and related preprocessor code for DBG_GETFILE_PAYLOAD(), DBG_GETFILE(), and DBG_PUTFILE(). Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 4963cbccdc2b..46dad63fa2c8 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -289,17 +289,4 @@ void *visorchipset_cache_alloc(struct kmem_cache *pool, void visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln); -#if defined(TRANSMITFILE_DEBUG) || defined(DEBUG) -#define DBG_GETFILE_PAYLOAD(msg, controlvm_header) \ - LOGINF(msg, \ - (ulong)controlvm_header.PayloadVmOffset, \ - (ulong)controlvm_header.PayloadMaxBytes) -#define DBG_GETFILE(fmt, ...) LOGINF(fmt, ##__VA_ARGS__) -#define DBG_PUTFILE(fmt, ...) LOGINF(fmt, ##__VA_ARGS__) -#else -#define DBG_GETFILE_PAYLOAD(msg, controlvm_header) -#define DBG_GETFILE(fmt, ...) -#define DBG_PUTFILE(fmt, ...) -#endif - #endif -- cgit v1.2.3-59-g8ed1b From 09b0e27621ad8eed4fd48a5fb2d177834b1cb142 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:00 -0500 Subject: staging: unisys: virtpci: Fix CamelCase Chipset_DriverInfo Rename Chipset_DriverInfo to chipset_driver_info in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index b6c313000899..6b4d94cae1fc 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -138,7 +138,7 @@ static struct device virtpci_rootbus_device = { }; /* filled in with info about parent chipset driver when we register with it */ -static struct ultra_vbus_deviceinfo Chipset_DriverInfo; +static struct ultra_vbus_deviceinfo chipset_driver_info; static const struct sysfs_ops virtpci_driver_sysfs_ops = { .show = virtpci_driver_attr_show, @@ -280,7 +280,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams) return 0; } write_vbus_chpInfo(vbus->platform_data /* chanptr */ , - &Chipset_DriverInfo); + &chipset_driver_info); write_vbus_busInfo(vbus->platform_data /* chanptr */ , &Bus_DriverInfo); LOGINF("Added vbus %d; device %s created successfully\n", addparams->bus_no, BUS_ID(vbus)); @@ -801,7 +801,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, /* Re-write bus+chipset info, because it is possible that this * was previously written by our good counterpart, visorbus. */ - write_vbus_chpInfo(pChan, &Chipset_DriverInfo); + write_vbus_chpInfo(pChan, &chipset_driver_info); write_vbus_busInfo(pChan, &Bus_DriverInfo); } @@ -1536,7 +1536,7 @@ static int __init virtpci_mod_init(void) DBGINF("device_register successful ret:%x\n", ret); if (!uisctrl_register_req_handler(2, (void *)&virtpci_ctrlchan_func, - &Chipset_DriverInfo)) { + &chipset_driver_info)) { LOGERR("uisctrl_register_req_handler ****FAILED.\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); device_unregister(&virtpci_rootbus_device); -- cgit v1.2.3-59-g8ed1b From 8a7281b21b6e78717a74ebac4ed0a1e3446973df Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:01 -0500 Subject: staging: unisys: virtpci: Fix CamelCase virtpci device list head Rename VpcidevListHead to vpcidev_list_head in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 6b4d94cae1fc..383be50f6a3d 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -149,7 +149,7 @@ static struct kobj_type virtpci_driver_kobj_type = { .sysfs_ops = &virtpci_driver_sysfs_ops, }; -static struct virtpci_dev *VpcidevListHead; +static struct virtpci_dev *vpcidev_list_head; static DEFINE_RWLOCK(VpcidevListLock); /* filled in with info about this driver, wrt it servicing client busses */ @@ -590,8 +590,8 @@ static void delete_all(void) /* delete the entire vhba/vnic list in one shot */ write_lock_irqsave(&VpcidevListLock, flags); - tmpvpcidev = VpcidevListHead; - VpcidevListHead = NULL; + tmpvpcidev = vpcidev_list_head; + vpcidev_list_head = NULL; write_unlock_irqrestore(&VpcidevListLock, flags); /* delete one vhba/vnic at a time */ @@ -967,7 +967,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, * duplicate wwnn/macaddr first */ write_lock_irqsave(&VpcidevListLock, flags); - for (tmpvpcidev = VpcidevListHead; tmpvpcidev; + for (tmpvpcidev = vpcidev_list_head; tmpvpcidev; tmpvpcidev = tmpvpcidev->next) { if (devtype == VIRTHBA_TYPE) { if ((tmpvpcidev->scsi.wwnn.wwnn1 == scsi->wwnn.wwnn1) && @@ -996,14 +996,14 @@ static int virtpci_device_add(struct device *parentbus, int devtype, } /* add it at the head */ - if (!VpcidevListHead) { - VpcidevListHead = virtpcidev; + if (!vpcidev_list_head) { + vpcidev_list_head = virtpcidev; } else { /* insert virtpcidev at the head of our linked list of * vpcidevs */ - virtpcidev->next = VpcidevListHead; - VpcidevListHead = virtpcidev; + virtpcidev->next = vpcidev_list_head; + vpcidev_list_head = virtpcidev; } write_unlock_irqrestore(&VpcidevListLock, flags); @@ -1041,14 +1041,14 @@ static int virtpci_device_add(struct device *parentbus, int devtype, CHANNELCLI_DETACHED, NULL); /* remove virtpcidev, the one we just added, from the list */ write_lock_irqsave(&VpcidevListLock, flags); - for (tmpvpcidev = VpcidevListHead, prev = NULL; + for (tmpvpcidev = vpcidev_list_head, prev = NULL; tmpvpcidev; prev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { if (tmpvpcidev == virtpcidev) { if (prev) prev->next = tmpvpcidev->next; else - VpcidevListHead = tmpvpcidev->next; + vpcidev_list_head = tmpvpcidev->next; break; } } @@ -1086,7 +1086,7 @@ static int virtpci_device_serverdown(struct device *parentbus, /* find the vhba or vnic in virtpci device list */ write_lock_irqsave(&VpcidevListLock, flags); - for (tmpvpcidev = VpcidevListHead, prevvpcidev = NULL; + for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; (tmpvpcidev && !found); prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { if (tmpvpcidev->devtype != devtype) @@ -1145,7 +1145,7 @@ static int virtpci_device_serverup(struct device *parentbus, /* find the vhba or vnic in virtpci device list */ write_lock_irqsave(&VpcidevListLock, flags); - for (tmpvpcidev = VpcidevListHead, prevvpcidev = NULL; + for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; (tmpvpcidev && !found); prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { if (tmpvpcidev->devtype != devtype) @@ -1224,7 +1224,7 @@ static int virtpci_device_del(struct device *parentbus, * encounter "schedule while atomic" */ write_lock_irqsave(&VpcidevListLock, flags); - for (tmpvpcidev = VpcidevListHead, prevvpcidev = NULL; tmpvpcidev;) { + for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; tmpvpcidev;) { if (tmpvpcidev->devtype != devtype) DEL_CONTINUE; @@ -1258,7 +1258,7 @@ static int virtpci_device_del(struct device *parentbus, /* not at head */ prevvpcidev->next = tmpvpcidev->next; else - VpcidevListHead = tmpvpcidev->next; + vpcidev_list_head = tmpvpcidev->next; /* add it to our deletelist */ tmpvpcidev->next = dellist; @@ -1273,7 +1273,7 @@ static int virtpci_device_del(struct device *parentbus, if (prevvpcidev) tmpvpcidev = prevvpcidev->next; else - tmpvpcidev = VpcidevListHead; + tmpvpcidev = vpcidev_list_head; } write_unlock_irqrestore(&VpcidevListLock, flags); @@ -1457,7 +1457,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n Virtual PCI devices\n"); read_lock_irqsave(&VpcidevListLock, flags); - tmpvpcidev = VpcidevListHead; + tmpvpcidev = vpcidev_list_head; while (tmpvpcidev) { if (tmpvpcidev->devtype == VIRTHBA_TYPE) { str_pos += scnprintf(vbuf + str_pos, len - str_pos, -- cgit v1.2.3-59-g8ed1b From 4ecd8281b2fa6fc49927a22e95ddb859d40a20b4 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:02 -0500 Subject: staging: unisys: virtpci: Fix CamelCase virtpci device list lock Rename VpcidevListLock to vpcidev_list_lock in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 383be50f6a3d..143bb0028981 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -150,7 +150,7 @@ static struct kobj_type virtpci_driver_kobj_type = { }; static struct virtpci_dev *vpcidev_list_head; -static DEFINE_RWLOCK(VpcidevListLock); +static DEFINE_RWLOCK(vpcidev_list_lock); /* filled in with info about this driver, wrt it servicing client busses */ static struct ultra_vbus_deviceinfo Bus_DriverInfo; @@ -589,10 +589,10 @@ static void delete_all(void) struct virtpci_dev *tmpvpcidev, *nextvpcidev; /* delete the entire vhba/vnic list in one shot */ - write_lock_irqsave(&VpcidevListLock, flags); + write_lock_irqsave(&vpcidev_list_lock, flags); tmpvpcidev = vpcidev_list_head; vpcidev_list_head = NULL; - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); /* delete one vhba/vnic at a time */ while (tmpvpcidev) { @@ -966,7 +966,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, /* add the vhba/vnic to virtpci device list - but check for * duplicate wwnn/macaddr first */ - write_lock_irqsave(&VpcidevListLock, flags); + write_lock_irqsave(&vpcidev_list_lock, flags); for (tmpvpcidev = vpcidev_list_head; tmpvpcidev; tmpvpcidev = tmpvpcidev->next) { if (devtype == VIRTHBA_TYPE) { @@ -988,7 +988,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, /* found a vhba/vnic already in the list with same * wwnn or macaddr - reject add */ - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); kfree(virtpcidev); LOGERR("**** FAILED vhba/vnic already exists in the list\n"); POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); @@ -1006,7 +1006,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, vpcidev_list_head = virtpcidev; } - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); /* Must transition channel to ATTACHED state BEFORE * registering the device, because polling of the channel @@ -1040,7 +1040,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, BUS_ID(pDev), CHANNELCLI_DETACHED, NULL); /* remove virtpcidev, the one we just added, from the list */ - write_lock_irqsave(&VpcidevListLock, flags); + write_lock_irqsave(&vpcidev_list_lock, flags); for (tmpvpcidev = vpcidev_list_head, prev = NULL; tmpvpcidev; prev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) { @@ -1052,7 +1052,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, break; } } - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); kfree(virtpcidev); return 0; } @@ -1084,7 +1084,7 @@ static int virtpci_device_serverdown(struct device *parentbus, } /* find the vhba or vnic in virtpci device list */ - write_lock_irqsave(&VpcidevListLock, flags); + write_lock_irqsave(&vpcidev_list_lock, flags); for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; (tmpvpcidev && !found); @@ -1114,7 +1114,7 @@ static int virtpci_device_serverdown(struct device *parentbus, vpcidriver = tmpvpcidev->mydriver; rc = vpcidriver->suspend(tmpvpcidev, 0); } - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); if (!found) { LOGERR("**** FAILED to find vhba/vnic in the list\n"); @@ -1143,7 +1143,7 @@ static int virtpci_device_serverup(struct device *parentbus, } /* find the vhba or vnic in virtpci device list */ - write_lock_irqsave(&VpcidevListLock, flags); + write_lock_irqsave(&vpcidev_list_lock, flags); for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; (tmpvpcidev && !found); @@ -1182,7 +1182,7 @@ static int virtpci_device_serverup(struct device *parentbus, rc = vpcidriver->resume(tmpvpcidev); } - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); if (!found) { LOGERR("**** FAILED to find vhba/vnic in the list\n"); @@ -1223,7 +1223,7 @@ static int virtpci_device_del(struct device *parentbus, * device_unregister after we release the lock; otherwise we * encounter "schedule while atomic" */ - write_lock_irqsave(&VpcidevListLock, flags); + write_lock_irqsave(&vpcidev_list_lock, flags); for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; tmpvpcidev;) { if (tmpvpcidev->devtype != devtype) DEL_CONTINUE; @@ -1275,7 +1275,7 @@ static int virtpci_device_del(struct device *parentbus, else tmpvpcidev = vpcidev_list_head; } - write_unlock_irqrestore(&VpcidevListLock, flags); + write_unlock_irqrestore(&vpcidev_list_lock, flags); if (!all && (count == 0)) { LOGERR("**** FAILED to find vhba/vnic in the list\n"); @@ -1456,7 +1456,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n Virtual PCI devices\n"); - read_lock_irqsave(&VpcidevListLock, flags); + read_lock_irqsave(&vpcidev_list_lock, flags); tmpvpcidev = vpcidev_list_head; while (tmpvpcidev) { if (tmpvpcidev->devtype == VIRTHBA_TYPE) { @@ -1489,7 +1489,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, tmpvpcidev->queueinfo.chan); tmpvpcidev = tmpvpcidev->next; } - read_unlock_irqrestore(&VpcidevListLock, flags); + read_unlock_irqrestore(&vpcidev_list_lock, flags); str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n"); bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos); -- cgit v1.2.3-59-g8ed1b From e322528dca1ead8f254a302a77af72ed20efcc55 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:03 -0500 Subject: staging: unisys: virtpci: Fix CamelCase vbus driver info variable Rename BusDriverInfo variable to bus_driver_info in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 143bb0028981..7d997fd432e3 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -153,7 +153,7 @@ static struct virtpci_dev *vpcidev_list_head; static DEFINE_RWLOCK(vpcidev_list_lock); /* filled in with info about this driver, wrt it servicing client busses */ -static struct ultra_vbus_deviceinfo Bus_DriverInfo; +static struct ultra_vbus_deviceinfo bus_driver_info; /*****************************************************/ /* debugfs entries */ @@ -281,7 +281,8 @@ static int add_vbus(struct add_vbus_guestpart *addparams) } write_vbus_chpInfo(vbus->platform_data /* chanptr */ , &chipset_driver_info); - write_vbus_busInfo(vbus->platform_data /* chanptr */ , &Bus_DriverInfo); + write_vbus_busInfo(vbus->platform_data /* chanptr */ , + &bus_driver_info); LOGINF("Added vbus %d; device %s created successfully\n", addparams->bus_no, BUS_ID(vbus)); POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -802,7 +803,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, * was previously written by our good counterpart, visorbus. */ write_vbus_chpInfo(pChan, &chipset_driver_info); - write_vbus_busInfo(pChan, &Bus_DriverInfo); + write_vbus_busInfo(pChan, &bus_driver_info); } /* This function is called to query the existence of a specific device @@ -1521,7 +1522,7 @@ static int __init virtpci_mod_init(void) return ret; } DBGINF("bus_register successful\n"); - bus_device_info_init(&Bus_DriverInfo, "clientbus", "virtpci", + bus_device_info_init(&bus_driver_info, "clientbus", "virtpci", VERSION, NULL); /* create a root bus used to parent all the virtpci buses. */ -- cgit v1.2.3-59-g8ed1b From 442ab1dfcf8e3d5613e7992649196f0205cc4ee9 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:04 -0500 Subject: staging: unisys: virtpci: Fix CamelCase write_vbus_chpInfo() Rename write_vbus_chpInfo() to write_vbus_chp_info() in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 7d997fd432e3..5e1a7ebdbb31 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -186,8 +186,8 @@ int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem *chanptr) } /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */ -static int write_vbus_chpInfo(struct spar_vbus_channel_protocol *chan, - struct ultra_vbus_deviceinfo *info) +static int write_vbus_chp_info(struct spar_vbus_channel_protocol *chan, + struct ultra_vbus_deviceinfo *info) { int off; @@ -279,8 +279,8 @@ static int add_vbus(struct add_vbus_guestpart *addparams) POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; } - write_vbus_chpInfo(vbus->platform_data /* chanptr */ , - &chipset_driver_info); + write_vbus_chp_info(vbus->platform_data /* chanptr */ , + &chipset_driver_info); write_vbus_busInfo(vbus->platform_data /* chanptr */ , &bus_driver_info); LOGINF("Added vbus %d; device %s created successfully\n", @@ -802,7 +802,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, /* Re-write bus+chipset info, because it is possible that this * was previously written by our good counterpart, visorbus. */ - write_vbus_chpInfo(pChan, &chipset_driver_info); + write_vbus_chp_info(pChan, &chipset_driver_info); write_vbus_busInfo(pChan, &bus_driver_info); } -- cgit v1.2.3-59-g8ed1b From b820d030b0eb2fab5a80f1c491540bf802d05ae6 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:05 -0500 Subject: staging: unisys: virtpci: Fix CamelCase write_vbus_busInfo() Rename write_vbus_busInfo() to write_vbus_bus_info() in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 5e1a7ebdbb31..c992b9fd4ad0 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -205,8 +205,8 @@ static int write_vbus_chp_info(struct spar_vbus_channel_protocol *chan, } /* Write the contents of to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */ -static int write_vbus_busInfo(struct spar_vbus_channel_protocol *chan, - struct ultra_vbus_deviceinfo *info) +static int write_vbus_bus_info(struct spar_vbus_channel_protocol *chan, + struct ultra_vbus_deviceinfo *info) { int off; @@ -281,8 +281,8 @@ static int add_vbus(struct add_vbus_guestpart *addparams) } write_vbus_chp_info(vbus->platform_data /* chanptr */ , &chipset_driver_info); - write_vbus_busInfo(vbus->platform_data /* chanptr */ , - &bus_driver_info); + write_vbus_bus_info(vbus->platform_data /* chanptr */ , + &bus_driver_info); LOGINF("Added vbus %d; device %s created successfully\n", addparams->bus_no, BUS_ID(vbus)); POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -803,7 +803,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, * was previously written by our good counterpart, visorbus. */ write_vbus_chp_info(pChan, &chipset_driver_info); - write_vbus_busInfo(pChan, &bus_driver_info); + write_vbus_bus_info(pChan, &bus_driver_info); } /* This function is called to query the existence of a specific device -- cgit v1.2.3-59-g8ed1b From 57fd91999195029d3ae0dc9af7ddfcf85207d379 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:06 -0500 Subject: staging: unisys: virtpci: Fix CamelCase write_vbus_devInfo() Rename write_vbus_devInfo() to write_vbus_dev_info() in virtpci.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index c992b9fd4ad0..a299b32a3b95 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -227,8 +227,8 @@ static int write_vbus_bus_info(struct spar_vbus_channel_protocol *chan, * ULTRA_VBUS_CHANNEL_PROTOCOL.DevInfo[]. */ static int -write_vbus_devInfo(struct spar_vbus_channel_protocol *chan, - struct ultra_vbus_deviceinfo *info, int devix) +write_vbus_dev_info(struct spar_vbus_channel_protocol *chan, + struct ultra_vbus_deviceinfo *info, int devix) { int off; @@ -797,7 +797,7 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, virtpcidrv->name, virtpcidrv->version, virtpcidrv->vertag); - write_vbus_devInfo(pChan, &devInfo, devNo); + write_vbus_dev_info(pChan, &devInfo, devNo); /* Re-write bus+chipset info, because it is possible that this * was previously written by our good counterpart, visorbus. -- cgit v1.2.3-59-g8ed1b From 865cde938ee6ab758fd47d1a36150aee20371b85 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:07 -0500 Subject: staging: unisys: virtpci: Fix CamelCase in delete_vbus_device() Rename pDev to dev in delete_vbus_device() Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index a299b32a3b95..b6e508f99136 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -430,9 +430,9 @@ static int delete_vbus_device(struct device *vbus, void *data) { int checkforroot = (data != NULL); - struct device *pDev = &virtpci_rootbus_device; + struct device *dev = &virtpci_rootbus_device; - if ((checkforroot) && match_busid(vbus, (void *)BUS_ID(pDev))) { + if ((checkforroot) && match_busid(vbus, (void *)BUS_ID(dev))) { /* skip it - don't delete root bus */ LOGINF("skipping root bus\n"); return 0; /* pretend no error */ -- cgit v1.2.3-59-g8ed1b From d13b23b8c933902c58559df6e4eb541135959e4a Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:08 -0500 Subject: staging: unisys: virtpci: Fix CamelCase name fix_vbus_devInfo() Rename fix_vbus_devInfo() to fix_vbus_dev_info(). Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index b6e508f99136..b4eaca2f4129 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -756,8 +756,8 @@ static int virtpci_device_resume(struct device *dev) * the appropriate slot within the vbus channel of the bus * instance. */ -static void fix_vbus_devInfo(struct device *dev, int devNo, int devType, - struct virtpci_driver *virtpcidrv) +static void fix_vbus_dev_info(struct device *dev, int devNo, int devType, + struct virtpci_driver *virtpcidrv) { struct device *vbus; void *pChan; @@ -843,8 +843,8 @@ static int virtpci_device_probe(struct device *dev) */ error = virtpcidrv->probe(virtpcidev, id); if (!error) { - fix_vbus_devInfo(dev, virtpcidev->device_no, - virtpcidev->device, virtpcidrv); + fix_vbus_dev_info(dev, virtpcidev->device_no, + virtpcidev->device, virtpcidrv); virtpcidev->mydriver = virtpcidrv; POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -1177,9 +1177,9 @@ static int virtpci_device_serverup(struct device *parentbus, * ever have a bus that contains NO devices, since we * would never even get here in that case. */ - fix_vbus_devInfo(&tmpvpcidev->generic_dev, - tmpvpcidev->device_no, - tmpvpcidev->device, vpcidriver); + fix_vbus_dev_info(&tmpvpcidev->generic_dev, + tmpvpcidev->device_no, + tmpvpcidev->device, vpcidriver); rc = vpcidriver->resume(tmpvpcidev); } -- cgit v1.2.3-59-g8ed1b From ceddd0b31949a59ff4faf2c154430833765ab9a8 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:09 -0500 Subject: staging: unisys: virtpci: Fix CamelCase parameters of fix_vbus_dev_info() Rename the following fix_vbus_dev_info() parameters devNo changed to dev_no devType changed to dev_type Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index b4eaca2f4129..80be2335c990 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -756,7 +756,7 @@ static int virtpci_device_resume(struct device *dev) * the appropriate slot within the vbus channel of the bus * instance. */ -static void fix_vbus_dev_info(struct device *dev, int devNo, int devType, +static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type, struct virtpci_driver *virtpcidrv) { struct device *vbus; @@ -782,7 +782,7 @@ static void fix_vbus_dev_info(struct device *dev, int devNo, int devType, LOGERR("%s dev bus has no channel", __func__); return; } - switch (devType) { + switch (dev_type) { case PCI_DEVICE_ID_VIRTHBA: stype = "vHBA"; break; @@ -797,7 +797,7 @@ static void fix_vbus_dev_info(struct device *dev, int devNo, int devType, virtpcidrv->name, virtpcidrv->version, virtpcidrv->vertag); - write_vbus_dev_info(pChan, &devInfo, devNo); + write_vbus_dev_info(pChan, &devInfo, dev_no); /* Re-write bus+chipset info, because it is possible that this * was previously written by our good counterpart, visorbus. -- cgit v1.2.3-59-g8ed1b From a87606c76f7e2a7ad8d5cdbc68417e5772fb8dc6 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:10 -0500 Subject: staging: unisys: virtpci: Fix CamelCase local variables in fix_vbus_dev_info() Rename the following local variables in fix_vbus_dev_info() Change pChan to chan Change devInfo to dev_info Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 80be2335c990..bfcc0271df79 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -760,8 +760,8 @@ static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type, struct virtpci_driver *virtpcidrv) { struct device *vbus; - void *pChan; - struct ultra_vbus_deviceinfo devInfo; + void *chan; + struct ultra_vbus_deviceinfo dev_info; const char *stype; if (!dev) { @@ -777,8 +777,8 @@ static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type, LOGERR("%s dev has no parent bus", __func__); return; } - pChan = vbus->platform_data; - if (!pChan) { + chan = vbus->platform_data; + if (!chan) { LOGERR("%s dev bus has no channel", __func__); return; } @@ -793,17 +793,17 @@ static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type, stype = "unknown"; break; } - bus_device_info_init(&devInfo, stype, + bus_device_info_init(&dev_info, stype, virtpcidrv->name, virtpcidrv->version, virtpcidrv->vertag); - write_vbus_dev_info(pChan, &devInfo, dev_no); + write_vbus_dev_info(chan, &dev_info, dev_no); /* Re-write bus+chipset info, because it is possible that this * was previously written by our good counterpart, visorbus. */ - write_vbus_chp_info(pChan, &chipset_driver_info); - write_vbus_bus_info(pChan, &bus_driver_info); + write_vbus_chp_info(chan, &chipset_driver_info); + write_vbus_bus_info(chan, &bus_driver_info); } /* This function is called to query the existence of a specific device -- cgit v1.2.3-59-g8ed1b From c159921f7eca8ca323316e7c0ad64d0e073b2ded Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Mon, 3 Nov 2014 14:21:11 -0500 Subject: staging: unisys: virtpci: Fix CamelCase local variables in virtpci_device_add() Rename the following local variables in virtpci_device_add() pIoChan changed to io_chan pDev changed to dev Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index bfcc0271df79..e212c7afb468 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -910,8 +910,8 @@ static int virtpci_device_add(struct device *parentbus, int devtype, struct virtpci_dev *tmpvpcidev = NULL, *prev; unsigned long flags; int ret; - struct spar_io_channel_protocol __iomem *pIoChan = NULL; - struct device *pDev; + struct spar_io_channel_protocol __iomem *io_chan = NULL; + struct device *dev; LOGINF("virtpci_device_add parentbus:%p chanptr:%p\n", parentbus, addparams->chanptr); @@ -951,7 +951,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype, virtpcidev->queueinfo.send_int_if_needed = NULL; /* Set up safe queue... */ - pIoChan = (struct spar_io_channel_protocol __iomem *) + io_chan = (struct spar_io_channel_protocol __iomem *) virtpcidev->queueinfo.chan; virtpcidev->intr = addparams->intr; @@ -1013,9 +1013,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype, * registering the device, because polling of the channel * queues can begin at any time after device_register(). */ - pDev = &virtpcidev->generic_dev; + dev = &virtpcidev->generic_dev; SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, - BUS_ID(pDev), + BUS_ID(dev), CHANNELCLI_ATTACHED, NULL); /* don't register until device has been added to @@ -1036,9 +1036,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype, */ if (ret) { LOGERR("device_register returned %d\n", ret); - pDev = &virtpcidev->generic_dev; + dev = &virtpcidev->generic_dev; SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr, - BUS_ID(pDev), + BUS_ID(dev), CHANNELCLI_DETACHED, NULL); /* remove virtpcidev, the one we just added, from the list */ write_lock_irqsave(&vpcidev_list_lock, flags); -- cgit v1.2.3-59-g8ed1b From 5519b5f5514ee8282044bf0d5a30481fb5c1b3bb Mon Sep 17 00:00:00 2001 From: Ken Depro Date: Mon, 3 Nov 2014 14:56:32 -0500 Subject: staging: unisys: Remove unneeded spaces from channel.c This patch removes some unneeded white space after casts within the channel.c file. The checkpatch script was run after these changes, and no further checks or warnings were seen. Signed-off-by: Ken Depro Signed-off-by: Ben Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index 2fc61a74ee54..74cc4d6b515f 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -51,7 +51,7 @@ unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue, struct signal_queue_header __iomem *pqhdr = (struct signal_queue_header __iomem *) - ((char __iomem *) ch + readq(&ch->ch_space_offset)) + ((char __iomem *)ch + readq(&ch->ch_space_offset)) + queue; /* capture current head and tail */ @@ -107,7 +107,7 @@ spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig) void __iomem *psource; unsigned int head, tail; struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *) ((char __iomem *) ch + + (struct signal_queue_header __iomem *)((char __iomem *)ch + readq(&ch->ch_space_offset)) + queue; /* capture current head and tail */ @@ -124,7 +124,7 @@ spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig) tail = (tail + 1) % readl(&pqhdr->max_slots); /* copy signal from tail location to the area pointed to by pSignal */ - psource = (char __iomem *) pqhdr + readq(&pqhdr->sig_base_offset) + + psource = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + (tail * readl(&pqhdr->signal_size)); memcpy_fromio(sig, psource, readl(&pqhdr->signal_size)); @@ -162,7 +162,7 @@ unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, void *psource; unsigned int head, tail, count = 0; struct signal_queue_header *pqhdr = - (struct signal_queue_header *) ((char *) ch + + (struct signal_queue_header *)((char *)ch + ch->ch_space_offset) + queue; /* capture current head and tail */ @@ -181,9 +181,9 @@ unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue, * to by pSignal */ psource = - (char *) pqhdr + pqhdr->sig_base_offset + + (char *)pqhdr + pqhdr->sig_base_offset + (tail * pqhdr->signal_size); - memcpy((char *) sig + (pqhdr->signal_size * count), + memcpy((char *)sig + (pqhdr->signal_size * count), psource, pqhdr->signal_size); mb(); /* channel synch */ @@ -211,7 +211,7 @@ unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch, u32 queue) { struct signal_queue_header __iomem *pqhdr = - (struct signal_queue_header __iomem *) ((char __iomem *) ch + + (struct signal_queue_header __iomem *)((char __iomem *)ch + readq(&ch->ch_space_offset)) + queue; return readl(&pqhdr->head) == readl(&pqhdr->tail); } -- cgit v1.2.3-59-g8ed1b From b7c12ca4df9dc69e4d8dd4468d3b5b780de1ae36 Mon Sep 17 00:00:00 2001 From: Dilek Uzulmez Date: Thu, 30 Oct 2014 23:20:46 +0200 Subject: staging: rtl8188eu: Remove unnecessary else after return This patch fixes checkpatch.pl warning in files of rtl8188eu WARNING: else is not generally useful after a break or return Signed-off-by: Dilek Uzulmez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index c47b1573c6e8..8816d116a8b8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -637,10 +637,9 @@ static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u8 efuse if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { return false; - } else { - efuse_addr++; - continue; } + efuse_addr++; + continue; } else if (pg_header != tmp_header) { /* offset PG fail */ struct pgpkt fixPkt; fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); @@ -707,14 +706,13 @@ static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u if (badworden == 0x0F) { /* write ok */ return true; - } else { - /* reorganize other pg packet */ - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data); - if (!PgWriteSuccess) - return false; - else - return true; } + /* reorganize other pg packet */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data); + if (!PgWriteSuccess) + return false; + else + return true; } static bool -- cgit v1.2.3-59-g8ed1b From 11dd2a979a5b81d69d6c877f94541987b19c54b5 Mon Sep 17 00:00:00 2001 From: Tina Ruchandani Date: Thu, 30 Oct 2014 17:45:22 -0700 Subject: Staging: lustre: lnet: Improve 'incarnation' stamp ksock_net_t uses a __u64 quantity as an 'incarnation' timestamp. This is also passed on in hello messages and used to detect if a reboot has occurred. This 'incarnation' is obtained using do_gettimeofday.It is only used in equality checks, so the absolute value does not matter. This patch replaces do_gettimeofday with ktime_get_ns for the following reasons: 1. ktime_get_ns returns a __u64 which is safer than 'struct timeval' which will overflow on 32-bit systems in year 2038 and beyond. 2. Reduced compute: ktime_get_ns is faster than the multiply/add combination used in this function Signed-off-by: Tina Ruchandani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 038854e8302f..8ac6410e2ae2 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -2348,16 +2348,11 @@ ksocknal_base_shutdown(void) static __u64 ksocknal_new_incarnation (void) { - struct timeval tv; /* The incarnation number is the time this module loaded and it - * identifies this particular instance of the socknal. Hopefully - * we won't be able to reboot more frequently than 1MHz for the - * foreseeable future :) */ - - do_gettimeofday(&tv); - - return (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; + * identifies this particular instance of the socknal. + */ + return ktime_get_ns(); } static int -- cgit v1.2.3-59-g8ed1b From 8c4f13649731576d5f82dfffff465041feae8d60 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Fri, 31 Oct 2014 07:56:29 +0530 Subject: Staging: lustre: Use put_unaligned_le64 This patch introduces the use of function put_unaligned_le64. This is done using Coccinelle and semantic patch used is as follows: @@ identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le64(y); <+... when != tmp - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le64(y,ptr); ...+> ? tmp = e @@ type T; identifier tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/debug.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c index d0f8f875ddd6..9c934e6d2ea1 100644 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ b/drivers/staging/lustre/lustre/obdclass/debug.c @@ -40,6 +40,7 @@ #define DEBUG_SUBSYSTEM D_OTHER +#include #include "../include/obd_support.h" #include "../include/lustre_debug.h" @@ -60,14 +61,11 @@ int block_debug_setup(void *addr, int len, __u64 off, __u64 id) { LASSERT(addr); - off = cpu_to_le64 (off); - id = cpu_to_le64 (id); - memcpy(addr, (char *)&off, LPDS); - memcpy(addr + LPDS, (char *)&id, LPDS); - + put_unaligned_le64(off, addr); + put_unaligned_le64(id, addr+LPDS); addr += len - LPDS - LPDS; - memcpy(addr, (char *)&off, LPDS); - memcpy(addr + LPDS, (char *)&id, LPDS); + put_unaligned_le64(off, addr); + put_unaligned_le64(id, addr+LPDS); return 0; } -- cgit v1.2.3-59-g8ed1b From f5333f8982c2fe95b04c8f1bce64fed691b47eec Mon Sep 17 00:00:00 2001 From: Roberta Dobrescu Date: Fri, 31 Oct 2014 00:01:20 +0200 Subject: staging: rtl8723au: Remove useless static functions This patch removes the static functions bthci_CmdSetEventFilter, bthci_CmdReadRSSI and bthci_CmdHostNumberOfCompletedPackets, since their body only consists of 'return HCI_STATUS_SUCCESS'. Signed-off-by: Roberta Dobrescu Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 25 ---------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 5de806e45c3b..d80ea4ee39e9 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -1759,16 +1759,6 @@ static enum hci_status bthci_CmdReadConnectionAcceptTimeout(struct rtw_adapter * return status; } -/* 7.3.3 */ -static enum hci_status -bthci_CmdSetEventFilter( - struct rtw_adapter *padapter, - struct packet_irp_hcicmd_data *pHciCmd - ) -{ - return HCI_STATUS_SUCCESS; -} - /* 7.3.14 */ static enum hci_status bthci_CmdWriteConnectionAcceptTimeout( @@ -2980,11 +2970,6 @@ bthci_CmdReadLinkQuality( return status; } -static enum hci_status bthci_CmdReadRSSI(struct rtw_adapter *padapter) -{ - return HCI_STATUS_SUCCESS; -} - static enum hci_status bthci_CmdCreateLogicalLink( struct rtw_adapter *padapter, @@ -4132,13 +4117,6 @@ bthci_CmdHostBufferSize(struct rtw_adapter *padapter, return status; } -static enum hci_status -bthci_CmdHostNumberOfCompletedPackets(struct rtw_adapter *padapter, - struct packet_irp_hcicmd_data *pHciCmd) -{ - return HCI_STATUS_SUCCESS; -} - static enum hci_status bthci_UnknownCMD(struct rtw_adapter *padapter, struct packet_irp_hcicmd_data *pHciCmd) { @@ -4212,7 +4190,6 @@ bthci_HandleOGFSetEventMaskCMD(struct rtw_adapter *padapter, break; case HCI_SET_EVENT_FILTER: RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_SET_EVENT_FILTER\n")); - status = bthci_CmdSetEventFilter(padapter, pHciCmd); break; case HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT: RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT\n")); @@ -4228,7 +4205,6 @@ bthci_HandleOGFSetEventMaskCMD(struct rtw_adapter *padapter, break; case HCI_HOST_NUMBER_OF_COMPLETED_PACKETS: RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_HOST_NUMBER_OF_COMPLETED_PACKETS\n")); - status = bthci_CmdHostNumberOfCompletedPackets(padapter, pHciCmd); break; case HCI_READ_LINK_SUPERVISION_TIMEOUT: RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_READ_LINK_SUPERVISION_TIMEOUT\n")); @@ -4316,7 +4292,6 @@ bthci_HandleOGFStatusParameters(struct rtw_adapter *padapter, break; case HCI_READ_RSSI: RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_READ_RSSI\n")); - status = bthci_CmdReadRSSI(padapter); break; case HCI_READ_LOCAL_AMP_INFO: RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_READ_LOCAL_AMP_INFO\n")); -- cgit v1.2.3-59-g8ed1b From 0f24cd7062cdb9e45cb05265fa1b9fc619c56084 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Fri, 31 Oct 2014 08:41:42 +0530 Subject: Staging: rtl8192e: Use put_unaligned_le16 This patch introduces the use of function put_unaligned_le16. This is done using Coccinelle and semantic patch used is as follows: @@ identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le16(y); <+... when != tmp - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le16(y,ptr); ...+> ? tmp = e @@ type T; identifier tmp; @@ - T tmp; ...when != tmp Here, to be compatible with the change header file is added too. Signed-off-by: Vaishali Thakkar Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 2866c1237ae5..66ea79198892 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -16,6 +16,7 @@ * Contact Information: * wlanfae ******************************************************************************/ +#include #include "rtllib.h" #include "rtl819x_BA.h" @@ -79,7 +80,6 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, struct sk_buff *skb = NULL; struct rtllib_hdr_3addr *BAReq = NULL; u8 *tag = NULL; - __le16 tmp = 0; u16 len = ieee->tx_headroom + 9; RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" @@ -115,15 +115,15 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, if (ACT_ADDBARSP == type) { RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); - tmp = cpu_to_le16(StatusCode); - memcpy(tag, (u8 *)&tmp, 2); + + put_unaligned_le16(StatusCode, tag); tag += 2; } - tmp = cpu_to_le16(pBA->BaParamSet.shortData); - memcpy(tag, (u8 *)&tmp, 2); + + put_unaligned_le16(pBA->BaParamSet.shortData, tag); tag += 2; - tmp = cpu_to_le16(pBA->BaTimeoutValue); - memcpy(tag, (u8 *)&tmp, 2); + + put_unaligned_le16(pBA->BaTimeoutValue, tag); tag += 2; if (ACT_ADDBAREQ == type) { @@ -143,7 +143,6 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, struct sk_buff *skb = NULL; struct rtllib_hdr_3addr *Delba = NULL; u8 *tag = NULL; - __le16 tmp = 0; u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) @@ -178,11 +177,11 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, *tag++ = ACT_CAT_BA; *tag++ = ACT_DELBA; - tmp = cpu_to_le16(DelbaParamSet.shortData); - memcpy(tag, (u8 *)&tmp, 2); + + put_unaligned_le16(DelbaParamSet.shortData, tag); tag += 2; - tmp = cpu_to_le16(ReasonCode); - memcpy(tag, (u8 *)&tmp, 2); + + put_unaligned_le16(ReasonCode, tag); tag += 2; RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); -- cgit v1.2.3-59-g8ed1b From 19e016c39967e23d127517b1d4baf00927870639 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Fri, 31 Oct 2014 16:36:18 +0530 Subject: Staging: rtl8192u: Use put_unaligned_le16 This patch introduces the use of function put_unaligned_le16. This is done using Coccinelle and semantic patch used is as follows: @@ identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le16(y); <+... when != tmp - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le16(y,ptr); ...+> ? tmp = e @@ type T; identifier tmp; @@ - T tmp; ...when != tmp Here, unnecessory comment after change is removed too. This patch also fixes sparse warnings in file ieeee80211_softmac.c. Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 9b874086766f..d1471877e19d 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -804,12 +804,11 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d *(tag++) = ieee->current_network.channel; if(atim_len){ - u16 val16; *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; - //*((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); - val16 = cpu_to_le16(ieee->current_network.atim_window); - memcpy((u8 *)tag, (u8 *)&val16, 2); + + put_unaligned_le16(ieee->current_network.atim_window, + (u8 *)tag); tag+=2; } -- cgit v1.2.3-59-g8ed1b From 86ca02dae72562bbd95b21dfc884a9a7d82ac387 Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Fri, 31 Oct 2014 17:27:54 +0530 Subject: Staging: rtl8188eu: rtw_pwrctrl: fixed checkpatch warning. WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 768dbeee94c4..044d849d10aa 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -577,7 +577,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal if (pwrpriv->ps_processing) { DBG_88E("%s wait ps_processing...\n", __func__); while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000) - msleep(10); + usleep_range(1000, 3000); if (pwrpriv->ps_processing) DBG_88E("%s wait ps_processing timeout\n", __func__); else -- cgit v1.2.3-59-g8ed1b From 1e39898b66b5f3eb515fa8c2cf9ebde6dff8310b Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Fri, 31 Oct 2014 17:39:54 +0530 Subject: Staging: rtl8188eu: rtw_pwrctrl: removed a checkpatch warning. WARNING: void function return statements are not generally useful Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 044d849d10aa..8ebef8456f3f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -279,7 +279,6 @@ void rtw_ps_processor(struct adapter *padapter) exit: rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); pwrpriv->ps_processing = false; - return; } static void pwr_state_check_handler(void *FunctionContext) -- cgit v1.2.3-59-g8ed1b From 2adc8c46b4266bed15c240b6d2721b84734e77ea Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Fri, 31 Oct 2014 17:54:12 +0530 Subject: Staging: rtl8188eu: rtw_pwrctrl: removed space before semicolon. WARNING: space prohibited before semicolon Signed-off-by: Surya Seetharaman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 8ebef8456f3f..df463a29b641 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -526,7 +526,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->LpsIdleCount = 0; if (padapter->registrypriv.mp_mode == 1) - pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE ; + pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; else pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; -- cgit v1.2.3-59-g8ed1b From 74d443bb2d7b9ca387de3c598962be0d4a46b33d Mon Sep 17 00:00:00 2001 From: Somya Anand Date: Fri, 31 Oct 2014 18:30:32 +0530 Subject: staging: android: logger: Add a TODO A comment about a pre-existing bug data structure definition is added. This bug was evidently introduced by Xiong Zhou in the patch bd471258f2e09 ("staging: android: logger: use kuid_t instead of uid_t") where the code was changed to hide a valid build warning instead of solving the bug that was identified by it. Signed-off-by: Somya Anand Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/TODO | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO index b15fb0d6b152..06954cdf3dba 100644 --- a/drivers/staging/android/TODO +++ b/drivers/staging/android/TODO @@ -5,6 +5,13 @@ TODO: - make sure things build as modules properly - add proper arch dependencies as needed - audit userspace interfaces to make sure they are sane + - kuid_t should never be exposed to user space as it is + kernel internal type. Data structure for this kuid_t is: + typedef struct { + uid_t val; + } kuid_t; + - This bug is introduced by Xiong Zhou in the patch bd471258f2e09 + - ("staging: android: logger: use kuid_t instead of uid_t") Please send patches to Greg Kroah-Hartman and Cc: Brian Swetland -- cgit v1.2.3-59-g8ed1b From 85ebbcca8ac2014d439fd90764e334924ca33ed3 Mon Sep 17 00:00:00 2001 From: Sarah Khan Date: Sat, 1 Nov 2014 04:32:45 +0530 Subject: staging: xgifb: Removed a definition which was not used in driver This patch removes a definition that was not used in driver xgifb Signed-off-by: Sarah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 481eb174fdf0..d9524a2e9ce4 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -7,7 +7,6 @@ #define SupportCRT2in301C 0x0100 /* for 301C */ #define SetCHTVOverScan 0x8000 -#define Panel_320x480 0x07 /*fstn*/ #define PanelResInfo 0x1F /* CR36 Panel Type/LCDResInfo */ #define Panel_1024x768x75 0x22 #define Panel_1280x1024x75 0x23 -- cgit v1.2.3-59-g8ed1b From 2b365fa9d9264faa7ebccf313899d096b228c65a Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Fri, 31 Oct 2014 23:39:14 +0530 Subject: Staging: rtl8188eu: Use put_unaligned_le32 This patch introduces the use of function put_unaligned_le32. This is done using Coccinelle and semantic patch used is as follows: @@ identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le32(y); <+... when != tmp - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le32(y,ptr); ...+> ? tmp = e @@ type T; identifier tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index 023a3d84ee8b..ce55d9d9f0f6 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -150,11 +150,9 @@ u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask) struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); if (haldata->fw_ractrl) { - __le32 lmask; memset(buf, 0, 3); - lmask = cpu_to_le32(mask); - memcpy(buf, &lmask, 3); + put_unaligned_le32(mask, buf); FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf); } else { -- cgit v1.2.3-59-g8ed1b From eb3a13230b78c3dc580b509e370862c632c90dae Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:10:50 -0700 Subject: staging: comedi: comedi_buf: make comedi_buf_write_samples() add samples that fit This function currently fails if the number of samples to add would overflow the async buffer. Modify it to add the samples that fit so at least some of the sample data is returned to the user. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 6dd87cb2a8af..b43424d611ad 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -484,12 +484,16 @@ unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, unsigned int max_samples; unsigned int nbytes; - /* make sure there is enought room in the buffer for all the samples */ + /* + * Make sure there is enough room in the buffer for all the samples. + * If not, clamp the nsamples to the number that will fit, flag the + * buffer overrun and add the samples that fit. + */ max_samples = comedi_buf_write_n_available(s) / bytes_per_sample(s); if (nsamples > max_samples) { dev_warn(s->device->class_dev, "buffer overrun\n"); s->async->events |= COMEDI_CB_OVERFLOW; - return 0; + nsamples = max_samples; } if (nsamples == 0) -- cgit v1.2.3-59-g8ed1b From e6245fc78b65a5492c7480d665cebb89082824f9 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 8 Oct 2014 17:19:12 +0200 Subject: imx-drm: ipuv3-plane: allow local alpha in ipu_plane_mode_set() For the overlay plane scanning out a framebuffer with an alpha component, enable the DP local alpha feature on the partial plane. Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipuv3-plane.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 944962b692bb..48cbeef73934 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -148,14 +148,22 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, ret); return ret; } - ipu_dp_set_global_alpha(ipu_plane->dp, 1, 0, 1); + ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true); break; case IPU_DP_FLOW_SYNC_FG: ipu_dp_setup_channel(ipu_plane->dp, ipu_drm_fourcc_to_colorspace(fb->pixel_format), IPUV3_COLORSPACE_UNKNOWN); ipu_dp_set_window_pos(ipu_plane->dp, crtc_x, crtc_y); - break; + /* Enable local alpha on partial plane */ + switch (fb->pixel_format) { + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_ABGR8888: + ipu_dp_set_global_alpha(ipu_plane->dp, false, 0, false); + break; + default: + break; + } } ret = ipu_dmfc_init_channel(ipu_plane->dmfc, crtc_w); -- cgit v1.2.3-59-g8ed1b From 7cd9bebee609c4a2e382ad5089f1c24e6098f493 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 8 Oct 2014 17:19:13 +0200 Subject: imx-drm: ipuv3-plane: move stride setting out of base setup Setting the stride can only be done on inactive channels, while the buffer base address can also be updated for running channels using the hardware double buffering feature. Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipuv3-plane.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 48cbeef73934..85f49e6fdee9 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -74,8 +74,6 @@ int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb, dev_dbg(ipu_plane->base.dev->dev, "phys = %pad, x = %d, y = %d", &cma_obj->paddr, x, y); - ipu_cpmem_set_stride(ipu_plane->ipu_ch, fb->pitches[0]); - eba = cma_obj->paddr + fb->offsets[0] + fb->pitches[0] * y + (fb->bits_per_pixel >> 3) * x; ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 0, eba); @@ -189,6 +187,7 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, return ret; } ipu_cpmem_set_high_priority(ipu_plane->ipu_ch); + ipu_cpmem_set_stride(ipu_plane->ipu_ch, fb->pitches[0]); ret = ipu_plane_set_base(ipu_plane, fb, src_x, src_y); if (ret < 0) -- cgit v1.2.3-59-g8ed1b From 356f952472f24b3677f191f534479d7d1be0183e Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 8 Oct 2014 17:19:14 +0200 Subject: imx-drm: ipuv3-plane: enable double buffering This allows to update the buffer base address while the DMA channel is running. It is needed to flip the frame buffer of an active plane. Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipuv3-plane.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 85f49e6fdee9..16134d9c4054 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -64,6 +64,7 @@ int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb, { struct drm_gem_cma_object *cma_obj; unsigned long eba; + int active; cma_obj = drm_fb_cma_get_gem_obj(fb, 0); if (!cma_obj) { @@ -76,8 +77,15 @@ int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb, eba = cma_obj->paddr + fb->offsets[0] + fb->pitches[0] * y + (fb->bits_per_pixel >> 3) * x; - ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 0, eba); - ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 1, eba); + + if (ipu_plane->enabled) { + active = ipu_idmac_get_current_buffer(ipu_plane->ipu_ch); + ipu_cpmem_set_buffer(ipu_plane->ipu_ch, !active, eba); + ipu_idmac_select_buffer(ipu_plane->ipu_ch, !active); + } else { + ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 0, eba); + ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 1, eba); + } /* cache offsets for subsequent pageflips */ ipu_plane->x = x; @@ -187,6 +195,7 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, return ret; } ipu_cpmem_set_high_priority(ipu_plane->ipu_ch); + ipu_idmac_set_double_buffer(ipu_plane->ipu_ch, 1); ipu_cpmem_set_stride(ipu_plane->ipu_ch, fb->pitches[0]); ret = ipu_plane_set_base(ipu_plane, fb, src_x, src_y); -- cgit v1.2.3-59-g8ed1b From 9a6660308c44a4fb8f7d6bcec6e4fb4c9afa4750 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 8 Oct 2014 17:19:15 +0200 Subject: imx-drm: ipuv3-plane: fix plane updates for active planes While the DMA channel is running, it is not allowed to change anything but the inactive (double) buffer base address, so resizing a plane or changing to a frame buffer with different pixel format is not possible. Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipuv3-plane.c | 15 +++++++++++++++ drivers/staging/imx-drm/ipuv3-plane.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 16134d9c4054..6987e16fe99b 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -143,6 +143,18 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, if (crtc_h < 2) return -EINVAL; + /* + * since we cannot touch active IDMAC channels, we do not support + * resizing the enabled plane or changing its format + */ + if (ipu_plane->enabled) { + if (src_w != ipu_plane->w || src_h != ipu_plane->h || + fb->pixel_format != ipu_plane->base.fb->pixel_format) + return -EINVAL; + + return ipu_plane_set_base(ipu_plane, fb, src_x, src_y); + } + switch (ipu_plane->dp_flow) { case IPU_DP_FLOW_SYNC_BG: ret = ipu_dp_setup_channel(ipu_plane->dp, @@ -202,6 +214,9 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, if (ret < 0) return ret; + ipu_plane->w = src_w; + ipu_plane->h = src_h; + return 0; } diff --git a/drivers/staging/imx-drm/ipuv3-plane.h b/drivers/staging/imx-drm/ipuv3-plane.h index c0aae5bcb5d4..af125fb40ef5 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.h +++ b/drivers/staging/imx-drm/ipuv3-plane.h @@ -26,6 +26,8 @@ struct ipu_plane { int x; int y; + int w; + int h; bool enabled; }; -- cgit v1.2.3-59-g8ed1b From 161f6d8ff31e232dbc915c5ea51cb72b4676219a Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 9 Oct 2014 15:21:17 +0200 Subject: imx-drm: currently only IPUv3 is supported, make it mandatory As long as only IPUv3 is supported in imx-drm, hide the separate DRM_IMX_IPUV3 option and make DRM_IMX depend on IMX_IPUV3_CORE. Reported-by: Michael Olbrich Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/Kconfig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig index 82fb758a29bc..ab31848e92cf 100644 --- a/drivers/staging/imx-drm/Kconfig +++ b/drivers/staging/imx-drm/Kconfig @@ -6,6 +6,7 @@ config DRM_IMX select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER depends on DRM && (ARCH_MXC || ARCH_MULTIPLATFORM) + depends on IMX_IPUV3_CORE help enable i.MX graphics support @@ -40,11 +41,11 @@ config DRM_IMX_LDB found on i.MX53 and i.MX6 processors. config DRM_IMX_IPUV3 - tristate "DRM Support for i.MX IPUv3" + tristate depends on DRM_IMX depends on IMX_IPUV3_CORE - help - Choose this if you have a i.MX5 or i.MX6 processor. + default y if DRM_IMX=y + default m if DRM_IMX=m config DRM_IMX_HDMI tristate "Freescale i.MX DRM HDMI" -- cgit v1.2.3-59-g8ed1b From ad92c8bfff579165739705235d0909ebc94de2cd Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 3 Nov 2014 15:54:47 +0100 Subject: imx-drm: parallel-display: Fix drm_panel support Call drm_panel_enable/disable in reaction to encoder_commit and encoder_disable callbacks. Signed-off-by: Philipp Zabel Signed-off-by: Markus Pargmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/parallel-display.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 015a454b87e1..ac89a18b8332 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -128,6 +128,10 @@ static void imx_pd_encoder_prepare(struct drm_encoder *encoder) static void imx_pd_encoder_commit(struct drm_encoder *encoder) { + struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + + drm_panel_prepare(imxpd->panel); + drm_panel_enable(imxpd->panel); } static void imx_pd_encoder_mode_set(struct drm_encoder *encoder, @@ -138,6 +142,10 @@ static void imx_pd_encoder_mode_set(struct drm_encoder *encoder, static void imx_pd_encoder_disable(struct drm_encoder *encoder) { + struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + + drm_panel_disable(imxpd->panel); + drm_panel_unprepare(imxpd->panel); } static struct drm_connector_funcs imx_pd_connector_funcs = { -- cgit v1.2.3-59-g8ed1b From f8e4df53c785a3c19650e57b5c514a4b50d82078 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 7 Oct 2014 21:42:19 -0300 Subject: imx-drm: imx-drm-core: Remove unneeded forward declaration There is no need to forward declare 'struct imx_drm_crtc' because the "imx-drm.h" header file already includes it. Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-drm-core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 3ca1acdae72b..8510937ff6fc 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -29,8 +29,6 @@ #define MAX_CRTC 4 -struct imx_drm_crtc; - struct imx_drm_component { struct device_node *of_node; struct list_head list; -- cgit v1.2.3-59-g8ed1b From d0915b2255bfbdd537fd6a52f9a0a7037ecbe2d5 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 31 Oct 2014 13:40:39 +0300 Subject: staging: r8188eu: get a string from the user correctly The original code had two bugs: 1) It didn't check if the string was zero length so it could oops when it tried to dereference the ZERO_SIZE_PTR. 2) It didn't enforce that the string was NUL terminated. It was also messy as pants. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/rtw_android.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index d9d55d12fd5f..b40317822aed 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -162,22 +162,12 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) ret = -EFAULT; goto exit; } - command = kmalloc(priv_cmd.total_len, GFP_KERNEL); - if (!command) { - DBG_88E("%s: failed to allocate memory\n", __func__); - ret = -ENOMEM; - goto exit; - } - if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) { - DBG_88E("%s: failed to access memory\n", __func__); - ret = -EFAULT; - goto exit; - } - if (copy_from_user(command, (char __user *)priv_cmd.buf, - priv_cmd.total_len)) { - ret = -EFAULT; - goto exit; - } + if (priv_cmd.total_len < 1) + return -EINVAL; + command = memdup_user(priv_cmd.buf, priv_cmd.total_len); + if (IS_ERR(command)) + return PTR_ERR(command); + command[priv_cmd.total_len - 1] = 0; DBG_88E("%s: Android private cmd \"%s\" on %s\n", __func__, command, ifr->ifr_name); cmd_num = rtw_android_cmdstr_to_num(command); -- cgit v1.2.3-59-g8ed1b From 85e1c554f4c80d1afec6069b4dad0a7bf6ce9b3d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 31 Oct 2014 13:41:05 +0300 Subject: staging: r8188eu: cleanups in rtw_android_set_block() 1) We can tighten up the code a little by returning directly and it makes the code more future proof and easier to read. 2) "free" is a better name than "exit". 3) sizeof(priv_cmd) is shorter and more clear than sizeof(struct android_wifi_priv_cmd). Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/rtw_android.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index b40317822aed..99ce077007f4 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -148,20 +148,15 @@ static int rtw_android_set_block(struct net_device *net, char *command, int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) { int ret = 0; - char *command = NULL; + char *command; int cmd_num; int bytes_written = 0; struct android_wifi_priv_cmd priv_cmd; - if (!ifr->ifr_data) { - ret = -EINVAL; - goto exit; - } - if (copy_from_user(&priv_cmd, ifr->ifr_data, - sizeof(struct android_wifi_priv_cmd))) { - ret = -EFAULT; - goto exit; - } + if (!ifr->ifr_data) + return -EINVAL; + if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(priv_cmd))) + return -EFAULT; if (priv_cmd.total_len < 1) return -EINVAL; command = memdup_user(priv_cmd.buf, priv_cmd.total_len); @@ -181,7 +176,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n", __func__, command, ifr->ifr_name); ret = 0; - goto exit; + goto free; } switch (cmd_num) { case ANDROID_WIFI_CMD_STOP: @@ -269,7 +264,7 @@ response: } else { ret = bytes_written; } -exit: +free: kfree(command); return ret; } -- cgit v1.2.3-59-g8ed1b From dafe271690457f3c44844c0da0942d282c73e58f Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Sat, 1 Nov 2014 11:52:11 +0100 Subject: staging: panel: Remove outdated TODO task Remove Lindent task from TODO file as it's obsolete. Signed-off-by: Mariusz Gorski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/panel/TODO b/drivers/staging/panel/TODO index a4be749bcdfc..2db3f994b632 100644 --- a/drivers/staging/panel/TODO +++ b/drivers/staging/panel/TODO @@ -1,6 +1,5 @@ TODO: - checkpatch.pl cleanups - - Lindent - review major/minor usages - review userspace api - see if all of this could be easier done in userspace instead. -- cgit v1.2.3-59-g8ed1b From bc47e7d97666ad32993abe0ea924ffa81a8356e7 Mon Sep 17 00:00:00 2001 From: Tristan Lelong Date: Fri, 31 Oct 2014 16:31:31 -0700 Subject: Staging: android: ion: fix typos in comments s/comming/coming/ in drivers/staging/android/ion/ion.c s/specfic/specific/ in drivers/staging/android/ion/ion.h s/peformance/performance/ in drivers/staging/android/ion/ion_priv.h Signed-off-by: Tristan Lelong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 2 +- drivers/staging/android/ion/ion.h | 2 +- drivers/staging/android/ion/ion_priv.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 290d4d22c102..8724ef89ce94 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -250,7 +250,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, our systems the only dma_address space is physical addresses. Additionally, we can't afford the overhead of invalidating every allocation via dma_map_sg. The implicit contract here is that - memory comming from the heaps is ready for dma, ie if it has a + memory coming from the heaps is ready for dma, ie if it has a cached mapping that mapping has been invalidated */ for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) sg_dma_address(sg) = sg_phys(sg); diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index d305bb7e9a74..443db8459a9e 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -76,7 +76,7 @@ struct ion_platform_data { * size * * Calls memblock reserve to set aside memory for heaps that are - * located at specific memory addresses or of specfic sizes not + * located at specific memory addresses or of specific sizes not * managed by the kernel */ void ion_reserve(struct ion_platform_data *data); diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index c8f01757abfa..18a5f93e13b7 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -345,7 +345,7 @@ void ion_carveout_free(struct ion_heap *heap, ion_phys_addr_t addr, * functions for creating and destroying a heap pool -- allows you * to keep a pool of pre allocated memory to use from your heap. Keeping * a pool of memory that is ready for dma, ie any cached mapping have been - * invalidated from the cache, provides a significant peformance benefit on + * invalidated from the cache, provides a significant performance benefit on * many systems */ /** @@ -362,7 +362,7 @@ void ion_carveout_free(struct ion_heap *heap, ion_phys_addr_t addr, * * Allows you to keep a pool of pre allocated pages to use from your heap. * Keeping a pool of pages that is ready for dma, ie any cached mapping have - * been invalidated from the cache, provides a significant peformance benefit + * been invalidated from the cache, provides a significant performance benefit * on many systems */ struct ion_page_pool { -- cgit v1.2.3-59-g8ed1b From 769971b2a45400a3c18632979dce30c6f9d3892a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 10 Oct 2014 21:41:30 +0200 Subject: stating: rtl8723au: Eliminate write-only struct xmit_priv->txirp_cnt Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 -- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 4c2f0a1201bf..a0f7e2787afe 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -180,8 +180,6 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, for (i = 0; i < 4; i ++) pxmitpriv->wmm_para_seq[i] = i; - pxmitpriv->txirp_cnt = 1; - sema_init(&pxmitpriv->tx_retevt, 0); pxmitpriv->ack_tx = false; diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index abe4316b9124..73e5f9cbfac0 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -312,7 +312,6 @@ struct xmit_priv { */ struct semaphore tx_retevt;/* all tx return event; */ - u8 txirp_cnt;/* */ struct tasklet_struct xmit_tasklet; -- cgit v1.2.3-59-g8ed1b From 0b2cf5c8402bb313c0054b2cd7df5ca50f250a1d Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 31 Oct 2014 10:20:37 +0900 Subject: staging: dgap: re-arrange functions for removing forward declarations Re-arrange the functions for removing forward declarations. Signed-off-by: Daeseok Youn Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 10805 +++++++++++++++++++++--------------------- 1 file changed, 5340 insertions(+), 5465 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ed356f1bdece..293dc3320b3a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -65,145 +65,6 @@ #include "dgap.h" -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Digi International, http://www.digi.com"); -MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); -MODULE_SUPPORTED_DEVICE("dgap"); - -static int dgap_start(void); -static void dgap_stop(void); -static void dgap_init_globals(void); -static struct board_t *dgap_found_board(struct pci_dev *pdev, int id, - int boardnum); -static void dgap_cleanup_board(struct board_t *brd); -static void dgap_poll_handler(ulong dummy); -static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); -static void dgap_remove_one(struct pci_dev *dev); -static int dgap_remap(struct board_t *brd); -static void dgap_unmap(struct board_t *brd); -static irqreturn_t dgap_intr(int irq, void *voidbrd); - -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 channel_t *ch, - struct digi_t __user *retinfo); -static int dgap_tty_digiseta(struct channel_t *ch, struct board_t *bd, - struct un_t *un, struct digi_t __user *new_info); -static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo); -static int dgap_tty_digisetedelay(struct channel_t *ch, struct board_t *bd, - struct un_t *un, 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 channel_t *ch, struct board_t *bd, - struct un_t *un, 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 channel_t *ch, struct board_t *bd, - struct un_t *un, int __user *new_info); -static int dgap_tty_digigetcustombaud(struct channel_t *ch, struct un_t *un, - 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 int dgap_tty_register(struct board_t *brd); -static void dgap_tty_unregister(struct board_t *brd); -static int dgap_tty_init(struct board_t *); -static void dgap_tty_free(struct board_t *); -static void dgap_cleanup_tty(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 - */ -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, u8 cmd, u8 byte1, - u8 byte2, uint ncmds); -static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds); -static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); -static int dgap_param(struct channel_t *ch, struct board_t *bd, u32 un_type); -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. - */ -static int dgap_gettok(char **in); -static char *dgap_getword(char **in); -static int dgap_checknode(struct cnode *p); - -/* - * Function prototypes from dgap_sysfs.h - */ -static void dgap_create_ports_sysfiles(struct board_t *bd); -static void dgap_remove_ports_sysfiles(struct board_t *bd); - -static int dgap_create_driver_sysfiles(struct pci_driver *); -static void dgap_remove_driver_sysfiles(struct pci_driver *); - -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 - */ -static int dgap_parsefile(char **in); -static struct cnode *dgap_find_config(int type, int bus, int slot); -static uint dgap_config_get_num_prts(struct board_t *bd); -static char *dgap_create_config_string(struct board_t *bd, char *string); -static uint dgap_config_get_useintr(struct board_t *bd); -static uint dgap_config_get_altpin(struct board_t *bd); - -static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len); -static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len); -#ifdef DIGI_CONCENTRATORS_SUPPORTED -static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len); -#endif -static int dgap_alloc_flipbuf(struct board_t *brd); -static void dgap_free_flipbuf(struct board_t *brd); -static int dgap_request_irq(struct board_t *brd); -static void dgap_free_irq(struct board_t *brd); - -static void dgap_get_vpd(struct board_t *brd); -static void dgap_do_reset_board(struct board_t *brd); -static int dgap_test_bios(struct board_t *brd); -static int dgap_test_fep(struct board_t *brd); -static int dgap_tty_register_ports(struct board_t *brd); -static int dgap_firmware_load(struct pci_dev *pdev, int card_type, - struct board_t *brd); -static void dgap_cleanup_nodes(void); - -static void dgap_cleanup_module(void); - -module_exit(dgap_cleanup_module); - /* * File operations permitted on Control/Management major. */ @@ -298,13 +159,6 @@ static struct board_id dgap_ids[] = { {0,} /* 0 terminated list. */ }; -static struct pci_driver dgap_driver = { - .name = "dgap", - .probe = dgap_init_one, - .id_table = dgap_pci_tbl, - .remove = dgap_remove_one, -}; - struct firmware_info { u8 *conf_name; /* dgap.conf */ u8 *bios_name; /* BIOS filename */ @@ -367,29 +221,6 @@ static struct ktermios dgap_default_termios = { .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 -}; - /* * Our needed internal static variables from dgap_parse.c */ @@ -457,3104 +288,2909 @@ static struct toklist dgap_tlist[] = { { 0, NULL } }; -/************************************************************************ - * - * Driver load/unload functions - * - ************************************************************************/ /* - * init_module() - * - * Module load. This is where it all starts. + * 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 int dgap_init_module(void) +static char *dgap_sindex(char *string, char *group) { - int rc; - - pr_info("%s, Digi International Part Number %s\n", DG_NAME, DG_PART); - - rc = dgap_start(); - if (rc) - return rc; - - rc = pci_register_driver(&dgap_driver); - if (rc) - goto err_stop; - - rc = dgap_create_driver_sysfiles(&dgap_driver); - if (rc) - goto err_unregister; - - dgap_driver_state = DRIVER_READY; + char *ptr; - return 0; + if (!string || !group) + return NULL; -err_unregister: - pci_unregister_driver(&dgap_driver); -err_stop: - dgap_stop(); + 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 rc; + return NULL; } -module_init(dgap_init_module); /* - * Start of driver. + * get a word from the input stream, also keep track of current line number. + * words are separated by whitespace. */ -static int dgap_start(void) +static char *dgap_getword(char **in) { - int rc; - unsigned long flags; - struct device *device; - - /* - * make sure that the globals are - * init'd before we do anything else - */ - dgap_init_globals(); - - dgap_numboards = 0; - - pr_info("For the tools package please visit http://www.digi.com\n"); + char *ret_ptr = *in; - /* - * Register our base character device into the kernel. - */ + char *ptr = dgap_sindex(*in, " \t\n"); - /* - * Register management/dpa devices - */ - rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap", &dgap_board_fops); - if (rc < 0) - return rc; + /* If no word found, return null */ + if (!ptr) + return NULL; - dgap_class = class_create(THIS_MODULE, "dgap_mgmt"); - if (IS_ERR(dgap_class)) { - rc = PTR_ERR(dgap_class); - goto failed_class; - } + /* Mark new location for our buffer */ + *ptr = '\0'; + *in = ptr + 1; - device = device_create(dgap_class, NULL, - MKDEV(DIGI_DGAP_MAJOR, 0), - NULL, "dgap_mgmt"); - if (IS_ERR(device)) { - rc = PTR_ERR(device); - goto failed_device; + /* Eat any extra spaces/tabs/newlines that might be present */ + while (*in && **in && ((**in == ' ') || + (**in == '\t') || + (**in == '\n'))) { + **in = '\0'; + *in = *in + 1; } - /* Start the poller */ - spin_lock_irqsave(&dgap_poll_lock, flags); - init_timer(&dgap_poll_timer); - dgap_poll_timer.function = dgap_poll_handler; - dgap_poll_timer.data = 0; - dgap_poll_time = jiffies + dgap_jiffies_from_ms(dgap_poll_tick); - dgap_poll_timer.expires = dgap_poll_time; - spin_unlock_irqrestore(&dgap_poll_lock, flags); - - add_timer(&dgap_poll_timer); - - return rc; - -failed_device: - class_destroy(dgap_class); -failed_class: - unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); - return rc; + return ret_ptr; } -static void dgap_stop(void) -{ - unsigned long lock_flags; - spin_lock_irqsave(&dgap_poll_lock, lock_flags); - dgap_poll_stop = 1; - spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); +/* + * Get a token from the input file; return 0 if end of file is reached + */ +static int dgap_gettok(char **in) +{ + char *w; + struct toklist *t; - del_timer_sync(&dgap_poll_timer); + if (strstr(dgap_cword, "board")) { + w = dgap_getword(in); + snprintf(dgap_cword, MAXCWORD, "%s", w); + for (t = dgap_brdtype; t->token != 0; t++) { + if (!strcmp(w, t->string)) + return t->token; + } + } else { + while ((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; + } + } + } - device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); - class_destroy(dgap_class); - unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); + return 0; } -static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +/* + * 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) { - int rc; - struct board_t *brd; - - if (dgap_numboards >= MAXBOARDS) - return -EPERM; + switch (p->type) { + case LNODE: + if (p->u.line.v_speed == 0) { + pr_err("line speed not specified"); + return 1; + } + return 0; - rc = pci_enable_device(pdev); - if (rc) - return -EIO; - - brd = dgap_found_board(pdev, ent->driver_data, dgap_numboards); - if (IS_ERR(brd)) - return PTR_ERR(brd); - - rc = dgap_firmware_load(pdev, ent->driver_data, brd); - if (rc) - goto cleanup_brd; - - rc = dgap_alloc_flipbuf(brd); - if (rc) - goto cleanup_brd; - - rc = dgap_tty_register(brd); - if (rc) - goto free_flipbuf; - - rc = dgap_request_irq(brd); - if (rc) - goto unregister_tty; + case CNODE: + if (p->u.conc.v_speed == 0) { + pr_err("concentrator line speed not specified"); + return 1; + } + if (p->u.conc.v_nport == 0) { + pr_err("number of ports on concentrator not specified"); + return 1; + } + if (p->u.conc.v_id == 0) { + pr_err("concentrator id letter not specified"); + return 1; + } + return 0; - /* - * Do tty device initialization. - */ - rc = dgap_tty_init(brd); - if (rc < 0) - goto free_irq; + case MNODE: + if (p->u.module.v_nport == 0) { + pr_err("number of ports on EBI module not specified"); + return 1; + } + if (p->u.module.v_id == 0) { + pr_err("EBI module id letter not specified"); + return 1; + } + return 0; + } + return 0; +} - rc = dgap_tty_register_ports(brd); - if (rc) - goto tty_free; +/* + * Given a board pointer, returns whether we should use interrupts or not. + */ +static uint dgap_config_get_useintr(struct board_t *bd) +{ + struct cnode *p; - brd->state = BOARD_READY; - brd->dpastatus = BD_RUNNING; + if (!bd) + return 0; - dgap_board[dgap_numboards++] = brd; + for (p = bd->bd_config; p; p = p->next) { + if (p->type == INTRNODE) { + /* + * check for pcxr types. + */ + return p->u.useintr; + } + } + /* If not found, then don't turn on interrupts. */ return 0; - -tty_free: - dgap_tty_free(brd); -free_irq: - dgap_free_irq(brd); -unregister_tty: - dgap_tty_unregister(brd); -free_flipbuf: - dgap_free_flipbuf(brd); -cleanup_brd: - dgap_cleanup_nodes(); - dgap_unmap(brd); - kfree(brd); - - return rc; -} - -static void dgap_remove_one(struct pci_dev *dev) -{ - /* Do Nothing */ } /* - * dgap_cleanup_module() - * - * Module unload. This is where it all ends. + * Given a board pointer, returns whether we turn on altpin or not. */ -static void dgap_cleanup_module(void) +static uint dgap_config_get_altpin(struct board_t *bd) { - unsigned int i; - ulong lock_flags; - - spin_lock_irqsave(&dgap_poll_lock, lock_flags); - dgap_poll_stop = 1; - spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); - - /* Turn off poller right away. */ - del_timer_sync(&dgap_poll_timer); - - dgap_remove_driver_sysfiles(&dgap_driver); + struct cnode *p; - device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); - class_destroy(dgap_class); - unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); + if (!bd) + return 0; - for (i = 0; i < dgap_numboards; ++i) { - dgap_remove_ports_sysfiles(dgap_board[i]); - dgap_cleanup_tty(dgap_board[i]); - dgap_cleanup_board(dgap_board[i]); + for (p = bd->bd_config; p; p = p->next) { + if (p->type == ANODE) { + /* + * check for pcxr types. + */ + return p->u.altpin; + } } - dgap_cleanup_nodes(); - - if (dgap_numboards) - pci_unregister_driver(&dgap_driver); + /* If not found, then don't turn on interrupts. */ + return 0; } /* - * dgap_cleanup_board() - * - * Free all the memory associated with a board + * Given a specific type of board, if found, detached link and + * returns the first occurrence in the list. */ -static void dgap_cleanup_board(struct board_t *brd) +static struct cnode *dgap_find_config(int type, int bus, int slot) { - unsigned int i; + struct cnode *p, *prev, *prev2, *found; - if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return; + p = &dgap_head; - dgap_free_irq(brd); + while (p->next) { + prev = p; + p = p->next; - tasklet_kill(&brd->helper_tasklet); + if (p->type != BNODE) + continue; - dgap_unmap(brd); + if (p->u.board.type != type) + continue; - /* Free all allocated channels structs */ - for (i = 0; i < MAXPORTS ; i++) - kfree(brd->channels[i]); + if (p->u.board.v_pcibus && + p->u.board.pcibus != bus) + continue; - kfree(brd->flipbuf); - kfree(brd->flipflagbuf); + if (p->u.board.v_pcislot && + p->u.board.pcislot != slot) + continue; - dgap_board[brd->boardnum] = NULL; + found = p; + /* + * Keep walking thru the list till we + * find the next board. + */ + while (p->next) { + prev2 = p; + p = p->next; - kfree(brd); + if (p->type != BNODE) + continue; + + /* + * Mark the end of our 1 board + * chain of configs. + */ + prev2->next = NULL; + + /* + * Link the "next" board to the + * previous board, effectively + * "unlinking" our board from + * the main config. + */ + prev->next = p; + + return found; + } + /* + * It must be the last board in the list. + */ + prev->next = NULL; + return found; + } + return NULL; } /* - * dgap_found_board() - * - * A board has been found, init it. + * 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) */ -static struct board_t *dgap_found_board(struct pci_dev *pdev, int id, - int boardnum) +static uint dgap_config_get_num_prts(struct board_t *bd) { - struct board_t *brd; - unsigned int pci_irq; - int i; - int ret; - - /* get the board structure and prep it */ - brd = kzalloc(sizeof(struct board_t), GFP_KERNEL); - if (!brd) - return ERR_PTR(-ENOMEM); - - /* store the info for the board we've found */ - brd->magic = DGAP_BOARD_MAGIC; - brd->boardnum = boardnum; - brd->vendor = dgap_pci_tbl[id].vendor; - brd->device = dgap_pci_tbl[id].device; - brd->pdev = pdev; - brd->pci_bus = pdev->bus->number; - brd->pci_slot = PCI_SLOT(pdev->devfn); - brd->name = dgap_ids[id].name; - brd->maxports = dgap_ids[id].maxports; - brd->type = dgap_ids[id].config_type; - brd->dpatype = dgap_ids[id].dpatype; - brd->dpastatus = BD_NOFEP; - init_waitqueue_head(&brd->state_wait); - - spin_lock_init(&brd->bd_lock); - - brd->inhibit_poller = FALSE; - brd->wait_for_bios = 0; - brd->wait_for_fep = 0; + int count = 0; + struct cnode *p; - for (i = 0; i < MAXPORTS; i++) - brd->channels[i] = NULL; + if (!bd) + return 0; - /* store which card & revision we have */ - pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor); - pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice); - pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev); + for (p = bd->bd_config; p; p = p->next) { - pci_irq = pdev->irq; - brd->irq = pci_irq; - - /* get the PCI Base Address Registers */ - - /* Xr Jupiter and EPC use BAR 2 */ - if (brd->device == PCI_DEV_XRJ_DID || brd->device == PCI_DEV_EPCJ_DID) { - brd->membase = pci_resource_start(pdev, 2); - brd->membase_end = pci_resource_end(pdev, 2); - } - /* Everyone else uses BAR 0 */ - else { - brd->membase = pci_resource_start(pdev, 0); - brd->membase_end = pci_resource_end(pdev, 0); - } - - if (!brd->membase) { - ret = -ENODEV; - goto free_brd; + 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; +} - if (brd->membase & 1) - brd->membase &= ~3; - else - brd->membase &= ~15; - - /* - * 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 - */ - brd->port = brd->membase + PCI_IO_OFFSET; - brd->port_end = brd->port + PCI_IO_SIZE; - - /* - * Special initialization for non-PLX boards - */ - if (brd->device != PCI_DEV_XRJ_DID && brd->device != PCI_DEV_EPCJ_DID) { - unsigned short cmd; - - pci_write_config_byte(pdev, 0x40, 0); - pci_write_config_byte(pdev, 0x46, 0); - - /* Limit burst length to 2 doubleword transactions */ - pci_write_config_byte(pdev, 0x42, 1); +static char *dgap_create_config_string(struct board_t *bd, char *string) +{ + char *ptr = string; + struct cnode *p; + struct cnode *q; + int speed; - /* - * Enable IO and mem if not already done. - * This was needed for support on Itanium. - */ - pci_read_config_word(pdev, PCI_COMMAND, &cmd); - cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); - pci_write_config_word(pdev, PCI_COMMAND, cmd); + if (!bd) { + *ptr = 0xff; + return string; } - /* init our poll helper tasklet */ - tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet, - (unsigned long) brd); - - ret = dgap_remap(brd); - if (ret) - goto free_brd; - - pr_info("dgap: board %d: %s (rev %d), irq %ld\n", - boardnum, brd->name, brd->rev, brd->irq); + for (p = bd->bd_config; p; p = p->next) { - return brd; + 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 && (q->type == MNODE)) { + *ptr = (p->u.conc.nport + 0x80); + ptr++; + p = q; + while (q->next && (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++; + } -free_brd: - kfree(brd); + *ptr = speed; + ptr++; + break; + } + } - return ERR_PTR(ret); + *ptr = 0xff; + return string; } - -static int dgap_request_irq(struct board_t *brd) +/* + * Parse a configuration file read into memory as a string. + */ +static int dgap_parsefile(char **in) { + struct cnode *p, *brd, *line, *conc; int rc; + char *s; + int linecnt = 0; - if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return -ENODEV; - - /* - * Set up our interrupt handler if we are set to do interrupts. - */ - if (dgap_config_get_useintr(brd) && brd->irq) { + p = &dgap_head; + brd = line = conc = NULL; - rc = request_irq(brd->irq, dgap_intr, IRQF_SHARED, "DGAP", brd); + /* perhaps we are adding to an existing list? */ + while (p->next) + p = p->next; - if (!rc) - brd->intr_used = 1; + /* file must start with a BEGIN */ + while ((rc = dgap_gettok(in)) != BEGIN) { + if (rc == 0) { + pr_err("unexpected EOF"); + return -1; + } } - return 0; -} -static void dgap_free_irq(struct board_t *brd) -{ - if (brd->intr_used && brd->irq) - free_irq(brd->irq, brd); -} + for (; ;) { + int board_type = 0; + int conc_type = 0; + int module_type = 0; -static int dgap_firmware_load(struct pci_dev *pdev, int card_type, - struct board_t *brd) -{ - const struct firmware *fw; - char *tmp_ptr; - int ret; - char *dgap_config_buf; + rc = dgap_gettok(in); + if (rc == 0) { + pr_err("unexpected EOF"); + return -1; + } - dgap_get_vpd(brd); - dgap_do_reset_board(brd); + switch (rc) { + case BEGIN: /* should only be 1 begin */ + pr_err("unexpected config_begin\n"); + return -1; - if (fw_info[card_type].conf_name) { - ret = request_firmware(&fw, fw_info[card_type].conf_name, - &pdev->dev); - if (ret) { - dev_err(&pdev->dev, "config file %s not found\n", - fw_info[card_type].conf_name); - return ret; - } + case END: + return 0; - dgap_config_buf = kzalloc(fw->size + 1, GFP_KERNEL); - if (!dgap_config_buf) { - release_firmware(fw); - return -ENOMEM; - } + case BOARD: /* board info */ + if (dgap_checknode(p)) + return -1; - memcpy(dgap_config_buf, fw->data, fw->size); - release_firmware(fw); + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* - * preserve dgap_config_buf - * as dgap_parsefile would - * otherwise alter it. - */ - tmp_ptr = dgap_config_buf; + p = p->next; - if (dgap_parsefile(&tmp_ptr) != 0) { - kfree(dgap_config_buf); - return -EINVAL; - } - kfree(dgap_config_buf); - } + p->type = BNODE; + p->u.board.status = kstrdup("No", GFP_KERNEL); + line = conc = NULL; + brd = p; + linecnt = -1; - /* - * 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); + board_type = dgap_gettok(in); + if (board_type == 0) { + pr_err("board !!type not specified"); + return -1; + } - /* - * 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); + p->u.board.type = board_type; - if (!brd->bd_config) { - dev_err(&pdev->dev, "No valid configuration found\n"); - return -EINVAL; - } + break; - if (fw_info[card_type].bios_name) { - ret = request_firmware(&fw, fw_info[card_type].bios_name, - &pdev->dev); - if (ret) { - dev_err(&pdev->dev, "bios file %s not found\n", - fw_info[card_type].bios_name); - return ret; - } - dgap_do_bios_load(brd, fw->data, fw->size); - release_firmware(fw); - - /* Wait for BIOS to test board... */ - ret = dgap_test_bios(brd); - if (ret) - return ret; - } - - if (fw_info[card_type].fep_name) { - ret = request_firmware(&fw, fw_info[card_type].fep_name, - &pdev->dev); - if (ret) { - dev_err(&pdev->dev, "dgap: fep file %s not found\n", - fw_info[card_type].fep_name); - return ret; - } - dgap_do_fep_load(brd, fw->data, fw->size); - release_firmware(fw); - - /* Wait for FEP to load on board... */ - ret = dgap_test_fep(brd); - if (ret) - return ret; - } - -#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) { - dev_err(&pdev->dev, "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 - - return 0; -} - -/* - * Remap PCI memory. - */ -static int dgap_remap(struct board_t *brd) -{ - if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return -EIO; - - if (!request_mem_region(brd->membase, 0x200000, "dgap")) - return -ENOMEM; - - if (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000, - "dgap")) { - release_mem_region(brd->membase, 0x200000); - return -ENOMEM; - } - - brd->re_map_membase = ioremap(brd->membase, 0x200000); - if (!brd->re_map_membase) { - release_mem_region(brd->membase, 0x200000); - release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); - return -ENOMEM; - } - - brd->re_map_port = ioremap((brd->membase + PCI_IO_OFFSET), 0x200000); - if (!brd->re_map_port) { - release_mem_region(brd->membase, 0x200000); - release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); - iounmap(brd->re_map_membase); - return -ENOMEM; - } - - return 0; -} - -static void dgap_unmap(struct board_t *brd) -{ - iounmap(brd->re_map_port); - iounmap(brd->re_map_membase); - release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); - release_mem_region(brd->membase, 0x200000); -} -/***************************************************************************** -* -* Function: -* -* dgap_poll_handler -* -* Author: -* -* Scott H Kilau -* -* Parameters: -* -* dummy -- ignored -* -* Return Values: -* -* none -* -* 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. -* -******************************************************************************/ - -static void dgap_poll_handler(ulong dummy) -{ - unsigned int i; - struct board_t *brd; - unsigned long lock_flags; - ulong new_time; - - dgap_poll_counter++; - - /* - * Do not start the board state machine until - * driver tells us its up and running, and has - * everything it needs. - */ - if (dgap_driver_state != DRIVER_READY) - goto schedule_poller; - - /* - * If we have just 1 board, or the system is not SMP, - * then use the typical old style poller. - * Otherwise, use our new tasklet based poller, which should - * speed things up for multiple boards. - */ - if ((dgap_numboards == 1) || (num_online_cpus() <= 1)) { - for (i = 0; i < dgap_numboards; i++) { - - brd = dgap_board[i]; - - if (brd->state == BOARD_FAILED) - continue; - if (!brd->intr_running) - /* Call the real board poller directly */ - dgap_poll_tasklet((unsigned long) brd); - } - } else { - /* - * Go thru each board, kicking off a - * tasklet for each if needed - */ - for (i = 0; i < dgap_numboards; i++) { - brd = dgap_board[i]; - - /* - * Attempt to grab the board lock. - * - * If we can't get it, no big deal, the next poll - * will get it. Basically, I just really don't want - * to spin in here, because I want to kick off my - * tasklets as fast as I can, and then get out the - * poller. - */ - if (!spin_trylock(&brd->bd_lock)) - continue; + case IO: /* i/o port */ + if (p->type != BNODE) { + pr_err("IO port only valid for boards"); + return -1; + } + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.board.portstr = kstrdup(s, GFP_KERNEL); + if (kstrtol(s, 0, &p->u.board.port)) { + pr_err("bad number for IO port"); + return -1; + } + p->u.board.v_port = 1; + break; - /* - * If board is in a failed state, don't bother - * scheduling a tasklet - */ - if (brd->state == BOARD_FAILED) { - spin_unlock(&brd->bd_lock); - continue; + case MEM: /* memory address */ + if (p->type != BNODE) { + pr_err("memory address only valid for boards"); + return -1; + } + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.board.addrstr = kstrdup(s, GFP_KERNEL); + if (kstrtoul(s, 0, &p->u.board.addr)) { + pr_err("bad number for memory address"); + return -1; } + p->u.board.v_addr = 1; + break; - /* Schedule a poll helper task */ - if (!brd->intr_running) - tasklet_schedule(&brd->helper_tasklet); + case PCIINFO: /* pci information */ + if (p->type != BNODE) { + pr_err("memory address only valid for boards"); + return -1; + } + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.board.pcibusstr = kstrdup(s, GFP_KERNEL); + if (kstrtoul(s, 0, &p->u.board.pcibus)) { + pr_err("bad number for pci bus"); + return -1; + } + p->u.board.v_pcibus = 1; + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.board.pcislotstr = kstrdup(s, GFP_KERNEL); + if (kstrtoul(s, 0, &p->u.board.pcislot)) { + pr_err("bad number for pci slot"); + return -1; + } + p->u.board.v_pcislot = 1; + break; - /* - * Can't do DGAP_UNLOCK here, as we don't have - * lock_flags because we did a trylock above. - */ - spin_unlock(&brd->bd_lock); - } - } - -schedule_poller: - - /* - * Schedule ourself back at the nominal wakeup interval. - */ - spin_lock_irqsave(&dgap_poll_lock, lock_flags); - dgap_poll_time += dgap_jiffies_from_ms(dgap_poll_tick); - - new_time = dgap_poll_time - jiffies; - - if ((ulong) new_time >= 2 * dgap_poll_tick) { - dgap_poll_time = - jiffies + dgap_jiffies_from_ms(dgap_poll_tick); - } - - dgap_poll_timer.function = dgap_poll_handler; - dgap_poll_timer.data = 0; - dgap_poll_timer.expires = dgap_poll_time; - spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); - - if (!dgap_poll_stop) - add_timer(&dgap_poll_timer); -} - -/* - * dgap_intr() - * - * Driver interrupt handler. - */ -static irqreturn_t dgap_intr(int irq, void *voidbrd) -{ - struct board_t *brd = voidbrd; - - if (!brd) - return IRQ_NONE; - - /* - * Check to make sure its for us. - */ - if (brd->magic != DGAP_BOARD_MAGIC) - return IRQ_NONE; - - brd->intr_count++; - - /* - * Schedule tasklet to run at a better time. - */ - tasklet_schedule(&brd->helper_tasklet); - return IRQ_HANDLED; -} - -/* - * dgap_init_globals() - * - * This is where we initialize the globals from the static insmod - * configuration variables. These are declared near the head of - * this file. - */ -static void dgap_init_globals(void) -{ - unsigned int i; - - for (i = 0; i < MAXBOARDS; i++) - dgap_board[i] = NULL; - - init_timer(&dgap_poll_timer); -} - -/************************************************************************ - * - * TTY Initialization/Cleanup Functions - * - ************************************************************************/ - -/* - * dgap_tty_register() - * - * Init the tty subsystem for this board. - */ -static int dgap_tty_register(struct board_t *brd) -{ - int rc; - - brd->serial_driver = tty_alloc_driver(MAXPORTS, 0); - if (IS_ERR(brd->serial_driver)) - return PTR_ERR(brd->serial_driver); - - snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgap_%d_", - brd->boardnum); - brd->serial_driver->name = brd->serial_name; - brd->serial_driver->name_base = 0; - brd->serial_driver->major = 0; - brd->serial_driver->minor_start = 0; - brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL; - brd->serial_driver->subtype = SERIAL_TYPE_NORMAL; - brd->serial_driver->init_termios = dgap_default_termios; - brd->serial_driver->driver_name = DRVSTR; - brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW | - TTY_DRIVER_DYNAMIC_DEV | - TTY_DRIVER_HARDWARE_BREAK); - - /* The kernel wants space to store pointers to tty_structs */ - brd->serial_driver->ttys = - kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->serial_driver->ttys) { - rc = -ENOMEM; - goto free_serial_drv; - } - - /* - * Entry points for driver. Called by the kernel from - * tty_io.c and n_tty.c. - */ - tty_set_operations(brd->serial_driver, &dgap_tty_ops); - - /* - * If we're doing transparent print, we have to do all of the above - * again, separately so we don't get the LD confused about what major - * we are when we get into the dgap_tty_open() routine. - */ - brd->print_driver = tty_alloc_driver(MAXPORTS, 0); - if (IS_ERR(brd->print_driver)) { - rc = PTR_ERR(brd->print_driver); - goto free_serial_drv; - } - - snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgap_%d_", - brd->boardnum); - brd->print_driver->name = brd->print_name; - brd->print_driver->name_base = 0; - brd->print_driver->major = 0; - brd->print_driver->minor_start = 0; - brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL; - brd->print_driver->subtype = SERIAL_TYPE_NORMAL; - brd->print_driver->init_termios = dgap_default_termios; - brd->print_driver->driver_name = DRVSTR; - brd->print_driver->flags = (TTY_DRIVER_REAL_RAW | - TTY_DRIVER_DYNAMIC_DEV | - TTY_DRIVER_HARDWARE_BREAK); - - /* The kernel wants space to store pointers to tty_structs */ - brd->print_driver->ttys = - kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->print_driver->ttys) { - rc = -ENOMEM; - goto free_print_drv; - } - - /* - * Entry points for driver. Called by the kernel from - * tty_io.c and n_tty.c. - */ - tty_set_operations(brd->print_driver, &dgap_tty_ops); - - /* Register tty devices */ - rc = tty_register_driver(brd->serial_driver); - if (rc < 0) - goto free_print_drv; - - /* Register Transparent Print devices */ - rc = tty_register_driver(brd->print_driver); - if (rc < 0) - goto unregister_serial_drv; - - dgap_boards_by_major[brd->serial_driver->major] = brd; - brd->dgap_serial_major = brd->serial_driver->major; - - dgap_boards_by_major[brd->print_driver->major] = brd; - brd->dgap_transparent_print_major = brd->print_driver->major; - - return 0; - -unregister_serial_drv: - tty_unregister_driver(brd->serial_driver); -free_print_drv: - put_tty_driver(brd->print_driver); -free_serial_drv: - put_tty_driver(brd->serial_driver); - - return rc; -} - -static void dgap_tty_unregister(struct board_t *brd) -{ - tty_unregister_driver(brd->print_driver); - tty_unregister_driver(brd->serial_driver); - put_tty_driver(brd->print_driver); - put_tty_driver(brd->serial_driver); -} - -/* - * dgap_tty_init() - * - * Init the tty subsystem. Called once per board after board has been - * downloaded and init'ed. - */ -static int dgap_tty_init(struct board_t *brd) -{ - int i; - int tlw; - uint true_count; - u8 __iomem *vaddr; - u8 modem; - struct channel_t *ch; - struct bs_t __iomem *bs; - struct cm_t __iomem *cm; - int ret; - - /* - * Initialize board structure elements. - */ - - vaddr = brd->re_map_membase; - true_count = readw((vaddr + NCHAN)); - - brd->nasync = dgap_config_get_num_prts(brd); - - if (!brd->nasync) - brd->nasync = brd->maxports; - - if (brd->nasync > brd->maxports) - brd->nasync = brd->maxports; - - if (true_count != brd->nasync) { - dev_warn(&brd->pdev->dev, - "%s configured for %d ports, has %d ports.\n", - brd->name, brd->nasync, true_count); - - if ((brd->type == PPCM) && - (true_count == 64 || true_count == 0)) { - dev_warn(&brd->pdev->dev, - "Please make SURE the EBI cable running from the card\n"); - dev_warn(&brd->pdev->dev, - "to each EM module is plugged into EBI IN!\n"); - } - - 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 -EIO; - } - } - - /* - * Allocate channel memory that might not have been allocated - * when the driver was first loaded. - */ - for (i = 0; i < brd->nasync; i++) { - brd->channels[i] = - kzalloc(sizeof(struct channel_t), GFP_KERNEL); - if (!brd->channels[i]) { - ret = -ENOMEM; - goto free_chan; - } - } - - ch = brd->channels[0]; - vaddr = brd->re_map_membase; - - bs = (struct bs_t __iomem *) ((ulong) vaddr + CHANBUF); - cm = (struct cm_t __iomem *) ((ulong) vaddr + CMDBUF); - - brd->bd_bs = bs; - - /* Set up channel variables */ - for (i = 0; i < brd->nasync; i++, ch = brd->channels[i], bs++) { - - spin_lock_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 + (ioread16(&(ch->ch_bs->tx_seg)) << 4); - ch->ch_raddr = vaddr + (ioread16(&(ch->ch_bs->rx_seg)) << 4); - ch->ch_tx_win = 0; - ch->ch_rx_win = 0; - ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1; - ch->ch_rsize = readw(&(ch->ch_bs->rx_max)) + 1; - ch->ch_tstart = 0; - ch->ch_rstart = 0; - - /* - * Set queue water marks, interrupt mask, - * and general tty parameters. - */ - tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) : - ch->ch_tsize / 2; - ch->ch_tlw = tlw; - - 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); - - /* 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)); - } - - return 0; - -free_chan: - while (--i >= 0) { - kfree(brd->channels[i]); - brd->channels[i] = NULL; - } - return ret; -} - -/* - * dgap_tty_free() - * - * Free the channles which are allocated in dgap_tty_init(). - */ -static void dgap_tty_free(struct board_t *brd) -{ - int i; - - for (i = 0; i < brd->nasync; i++) - kfree(brd->channels[i]); -} -/* - * dgap_cleanup_tty() - * - * Uninitialize the TTY portion of this driver. Free all memory and - * resources. - */ -static void dgap_cleanup_tty(struct board_t *brd) -{ - struct device *dev; - unsigned int i; - - dgap_boards_by_major[brd->serial_driver->major] = NULL; - brd->dgap_serial_major = 0; - for (i = 0; i < brd->nasync; i++) { - tty_port_destroy(&brd->serial_ports[i]); - dev = brd->channels[i]->ch_tun.un_sysfs; - dgap_remove_tty_sysfs(dev); - tty_unregister_device(brd->serial_driver, i); - } - tty_unregister_driver(brd->serial_driver); - put_tty_driver(brd->serial_driver); - kfree(brd->serial_ports); - - dgap_boards_by_major[brd->print_driver->major] = NULL; - brd->dgap_transparent_print_major = 0; - for (i = 0; i < brd->nasync; i++) { - tty_port_destroy(&brd->printer_ports[i]); - dev = brd->channels[i]->ch_pun.un_sysfs; - dgap_remove_tty_sysfs(dev); - tty_unregister_device(brd->print_driver, i); - } - tty_unregister_driver(brd->print_driver); - put_tty_driver(brd->print_driver); - kfree(brd->printer_ports); -} - -/*======================================================================= - * - * dgap_input - Process received data. - * - * ch - Pointer to channel structure. - * - *=======================================================================*/ - -static void dgap_input(struct channel_t *ch) -{ - struct board_t *bd; - struct bs_t __iomem *bs; - struct tty_struct *tp; - struct tty_ldisc *ld; - uint rmask; - uint head; - uint tail; - int data_len; - ulong lock_flags; - ulong lock_flags2; - int flip_len; - int len; - int n; - u8 *buf; - u8 tmpchar; - int s; - - 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; - - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + case METHOD: + if (p->type != BNODE) { + pr_err("install method only valid for boards"); + return -1; + } + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.board.method = kstrdup(s, GFP_KERNEL); + p->u.board.v_method = 1; + break; - /* - * Figure the number of characters in the buffer. - * Exit immediately if none. - */ + case STATUS: + if (p->type != BNODE) { + pr_err("config status only valid for boards"); + return -1; + } + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.board.status = kstrdup(s, GFP_KERNEL); + break; - rmask = ch->ch_rsize - 1; + case NPORTS: /* number of ports */ + if (p->type == BNODE) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.board.nport)) { + pr_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) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.conc.nport)) { + pr_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) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.module.nport)) { + pr_err("bad number for number of ports"); + return -1; + } + p->u.module.v_nport = 1; + } else { + pr_err("nports only valid for concentrators or modules"); + return -1; + } + break; - head = readw(&(bs->rx_head)); - head &= rmask; - tail = readw(&(bs->rx_tail)); - tail &= rmask; + case ID: /* letter ID used in tty name */ + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } - data_len = (head - tail) & rmask; + p->u.board.status = kstrdup(s, GFP_KERNEL); - if (data_len == 0) { - writeb(1, &(bs->idata)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return; - } + if (p->type == CNODE) { + p->u.conc.id = kstrdup(s, GFP_KERNEL); + p->u.conc.v_id = 1; + } else if (p->type == MNODE) { + p->u.module.id = kstrdup(s, GFP_KERNEL); + p->u.module.v_id = 1; + } else { + pr_err("id only valid for concentrators or modules"); + return -1; + } + break; - /* - * 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)) { + case STARTO: /* start offset of ID */ + if (p->type == BNODE) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.board.start)) { + pr_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) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.conc.start)) { + pr_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) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.module.start)) { + pr_err("bad number for start of tty count"); + return -1; + } + p->u.module.v_start = 1; + } else { + pr_err("start only valid for concentrators or modules"); + return -1; + } + break; - writew(head, &(bs->rx_tail)); - writeb(1, &(bs->idata)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return; - } + case TTYN: /* tty name prefix */ + if (dgap_checknode(p)) + return -1; - /* - * If we are throttled, simply don't read any data. - */ - if (ch->ch_flags & CH_RXBLOCK) { - writeb(1, &(bs->idata)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return; - } + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* - * Ignore oruns. - */ - tmpchar = readb(&(bs->orun)); - if (tmpchar) { - ch->ch_err_overrun++; - writeb(0, &(bs->orun)); - } + p = p->next; + p->type = TNODE; - /* Decide how much data we can send into the tty layer */ - flip_len = TTY_FLIPBUF_SIZE; + s = dgap_getword(in); + if (!s) { + pr_err("unexpeced end of file"); + return -1; + } + p->u.ttyname = kstrdup(s, GFP_KERNEL); + if (!p->u.ttyname) + return -1; - /* Chop down the length, if needed */ - len = min(data_len, flip_len); - len = min(len, (N_TTY_BUF_SIZE - 1)); + break; - ld = tty_ldisc_ref(tp); + case CU: /* cu name prefix */ + if (dgap_checknode(p)) + return -1; -#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 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* - * 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; - } - } + p = p->next; + p->type = CUNODE; - if (len <= 0) { - writeb(1, &(bs->idata)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if (ld) - tty_ldisc_deref(ld); - return; - } + s = dgap_getword(in); + if (!s) { + pr_err("unexpeced end of file"); + return -1; + } + p->u.cuname = kstrdup(s, GFP_KERNEL); + if (!p->u.cuname) + return -1; - buf = ch->ch_bd->flipbuf; - n = len; + break; - /* - * 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) { + case LINE: /* line information */ + if (dgap_checknode(p)) + return -1; + if (!brd) { + pr_err("must specify board before line info"); + return -1; + } + switch (brd->u.board.type) { + case PPCM: + pr_err("line not valid for PC/em"); + return -1; + } - s = ((head >= tail) ? head : ch->ch_rsize) - tail; - s = min(s, n); + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - if (s <= 0) + p = p->next; + p->type = LNODE; + conc = NULL; + line = p; + linecnt++; break; - memcpy_fromio(buf, ch->ch_raddr + tail, s); - - tail += s; - buf += s; + case CONC: /* concentrator information */ + if (dgap_checknode(p)) + return -1; + if (!line) { + pr_err("must specify line info before concentrator"); + return -1; + } - n -= s; - /* Flip queue if needed */ - tail &= rmask; - } + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - writew(tail, &(bs->rx_tail)); - writeb(1, &(bs->idata)); - ch->ch_rxcount += len; + p = p->next; + p->type = CNODE; + conc = p; - /* - * 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); + if (linecnt) + brd->u.board.conc2++; + else + brd->u.board.conc1++; - 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); - } + conc_type = dgap_gettok(in); + if (conc_type == 0 || conc_type != CX || + conc_type != EPC) { + pr_err("failed to set a type of concentratros"); + return -1; + } - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + p->u.conc.type = conc_type; - /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp->port); + break; - if (ld) - tty_ldisc_deref(ld); + case MOD: /* EBI module */ + if (dgap_checknode(p)) + return -1; + if (!brd) { + pr_err("must specify board info before EBI modules"); + return -1; + } + switch (brd->u.board.type) { + case PPCM: + linecnt = 0; + break; + default: + if (!conc) { + pr_err("must specify concentrator info before EBI module"); + return -1; + } + } -} + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; -/************************************************************************ - * Determines when CARRIER changes state and takes appropriate - * action. - ************************************************************************/ -static void dgap_carrier(struct channel_t *ch) -{ - struct board_t *bd; + p = p->next; + p->type = MNODE; - int virt_carrier = 0; - int phys_carrier = 0; + if (linecnt) + brd->u.board.module2++; + else + brd->u.board.module1++; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + module_type = dgap_gettok(in); + if (module_type == 0 || module_type != PORTS || + module_type != MODEM) { + pr_err("failed to set a type of module"); + return -1; + } - bd = ch->ch_bd; + p->u.module.type = module_type; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + break; - /* 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; - } + case CABLE: + if (p->type == LNODE) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.line.cable = kstrdup(s, GFP_KERNEL); + p->u.line.v_cable = 1; + } + break; - if (ch->ch_mistat & D_CD(ch)) - phys_carrier = 1; + case SPEED: /* sync line speed indication */ + if (p->type == LNODE) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.line.speed)) { + pr_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) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.conc.speed)) { + pr_err("bad number for line speed"); + return -1; + } + p->u.conc.v_speed = 1; + } else { + pr_err("speed valid only for lines or concentrators."); + return -1; + } + break; - if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) - virt_carrier = 1; + case CONNECT: + if (p->type == CNODE) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + p->u.conc.connect = kstrdup(s, GFP_KERNEL); + p->u.conc.v_connect = 1; + } + break; + case PRINT: /* transparent print name prefix */ + if (dgap_checknode(p)) + return -1; - if (ch->ch_c_cflag & CLOCAL) - virt_carrier = 1; + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* - * Test for a VIRTUAL carrier transition to HIGH. - */ - if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { + p = p->next; + p->type = PNODE; - /* - * When carrier rises, wake any threads waiting - * for carrier in the open routine. - */ + s = dgap_getword(in); + if (!s) { + pr_err("unexpeced end of file"); + return -1; + } + p->u.printname = kstrdup(s, GFP_KERNEL); + if (!p->u.printname) + return -1; - if (waitqueue_active(&(ch->ch_flags_wait))) - wake_up_interruptible(&ch->ch_flags_wait); - } + break; - /* - * Test for a PHYSICAL carrier transition to HIGH. - */ - if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { + case CMAJOR: /* major number */ + if (dgap_checknode(p)) + return -1; - /* - * When carrier rises, wake any threads waiting - * for carrier in the open routine. - */ + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - if (waitqueue_active(&(ch->ch_flags_wait))) - wake_up_interruptible(&ch->ch_flags_wait); - } + p = p->next; + p->type = JNODE; - /* - * 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)) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.majornumber)) { + pr_err("bad number for major number"); + return -1; + } + break; - /* - * 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); + case ALTPIN: /* altpin setting */ + if (dgap_checknode(p)) + return -1; - if (ch->ch_tun.un_open_count > 0) - tty_hangup(ch->ch_tun.un_tty); + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - if (ch->ch_pun.un_open_count > 0) - tty_hangup(ch->ch_pun.un_tty); - } + p = p->next; + p->type = ANODE; - /* - * 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; + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.altpin)) { + pr_err("bad number for altpin"); + return -1; + } + break; - if (phys_carrier == 1) - ch->ch_flags |= CH_CD; - else - ch->ch_flags &= ~CH_CD; -} + case USEINTR: /* enable interrupt setting */ + if (dgap_checknode(p)) + return -1; -/************************************************************************ - * - * TTY Entry points and helper functions - * - ************************************************************************/ + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; -/* - * 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 __iomem *bs; - uint major; - uint minor; - int rc; - ulong lock_flags; - ulong lock_flags2; - u16 head; + p = p->next; + p->type = INTRNODE; + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.useintr)) { + pr_err("bad number for useintr"); + return -1; + } + break; - major = MAJOR(tty_devnum(tty)); - minor = MINOR(tty_devnum(tty)); + case TTSIZ: /* size of tty structure */ + if (dgap_checknode(p)) + return -1; - if (major > 255) - return -EIO; + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* Get board pointer from our array of majors we have allocated */ - brd = dgap_boards_by_major[major]; - if (!brd) - return -EIO; + p = p->next; + p->type = TSNODE; - /* - * 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)); + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.ttysize)) { + pr_err("bad number for ttysize"); + return -1; + } + break; - if (rc) - return rc; + case CHSIZ: /* channel structure size */ + if (dgap_checknode(p)) + return -1; - spin_lock_irqsave(&brd->bd_lock, lock_flags); + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* The wait above should guarantee this cannot happen */ - if (brd->state != BOARD_READY) { - spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -EIO; - } + p = p->next; + p->type = CSNODE; - /* If opened device is greater than our number of ports, bail. */ - if (MINOR(tty_devnum(tty)) > brd->nasync) { - spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -EIO; - } + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.chsize)) { + pr_err("bad number for chsize"); + return -1; + } + break; - ch = brd->channels[minor]; - if (!ch) { - spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -EIO; - } + case BSSIZ: /* board structure size */ + if (dgap_checknode(p)) + return -1; - /* Grab channel lock */ - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* 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_transparent_print_major) { - un = &brd->channels[minor]->ch_pun; - un->un_type = DGAP_PRINT; - } else { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -EIO; - } + p = p->next; + p->type = BSNODE; - /* Store our unit into driver_data, so we always have it available. */ - tty->driver_data = un; + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.bssize)) { + pr_err("bad number for bssize"); + return -1; + } + break; - /* - * Error if channel info pointer is NULL. - */ - bs = ch->ch_bs; - if (!bs) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -EIO; - } + case UNTSIZ: /* sched structure size */ + if (dgap_checknode(p)) + return -1; - /* - * Initialize tty's - */ - if (!(un->un_flags & UN_ISOPEN)) { - /* Store important variables. */ - un->un_tty = tty; + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* Maybe do something here to the TTY struct as well? */ - } + p = p->next; + p->type = USNODE; - /* - * Initialize if neither terminal or printer is open. - */ - if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.unsize)) { + pr_err("bad number for schedsize"); + return -1; + } + break; - ch->ch_mforce = 0; - ch->ch_mval = 0; + case F2SIZ: /* f2200 structure size */ + if (dgap_checknode(p)) + return -1; - /* - * Flush input queue. - */ - head = readw(&(bs->rx_head)); - writew(head, &(bs->rx_tail)); + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; + + p = p->next; + p->type = FSNODE; + + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.f2size)) { + pr_err("bad number for f2200size"); + return -1; + } + break; - ch->ch_flags = 0; - ch->pscan_state = 0; - ch->pscan_savechar = 0; + case VPSIZ: /* vpix structure size */ + if (dgap_checknode(p)) + return -1; - 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]; + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); + if (!p->next) + return -1; - /* TODO: flush our TTY struct here? */ - } + p = p->next; + p->type = VSNODE; - dgap_carrier(ch); - /* - * Run param in case we changed anything - */ - dgap_param(ch, brd, un->un_type); + s = dgap_getword(in); + if (!s) { + pr_err("unexpected end of file"); + return -1; + } + if (kstrtol(s, 0, &p->u.vpixsize)) { + pr_err("bad number for vpixsize"); + return -1; + } + break; + } + } +} - /* - * follow protocol for opening port - */ +static void dgap_cleanup_nodes(void) +{ + struct cnode *p; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&brd->bd_lock, lock_flags); + p = &dgap_head; - rc = dgap_block_til_ready(tty, file, ch); + while (p) { + struct cnode *tmp = p->next; - if (!un->un_tty) - return -ENODEV; + if (p->type == NULLNODE) { + p = tmp; + continue; + } - /* No going back now, increment our unit and channel counters */ - spin_lock_irqsave(&ch->ch_lock, lock_flags); - ch->ch_open_count++; - un->un_open_count++; - un->un_flags |= (UN_ISOPEN); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + switch (p->type) { + case BNODE: + kfree(p->u.board.portstr); + kfree(p->u.board.addrstr); + kfree(p->u.board.pcibusstr); + kfree(p->u.board.pcislotstr); + kfree(p->u.board.method); + break; + case CNODE: + kfree(p->u.conc.id); + kfree(p->u.conc.connect); + break; + case MNODE: + kfree(p->u.module.id); + break; + case TNODE: + kfree(p->u.ttyname); + break; + case CUNODE: + kfree(p->u.cuname); + break; + case LNODE: + kfree(p->u.line.cable); + break; + case PNODE: + kfree(p->u.printname); + break; + } - return rc; + kfree(p->u.board.status); + kfree(p); + p = tmp; + } } /* - * dgap_block_til_ready() - * - * Wait for DCD, if needed. + * Retrives the current custom baud rate from FEP memory, + * and returns it back to the user. + * Returns 0 on error. */ -static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, - struct channel_t *ch) +static uint dgap_get_custom_baud(struct channel_t *ch) { - int retval = 0; - struct un_t *un; - ulong lock_flags; - uint old_flags; - int sleep_on_un_flags; + u8 __iomem *vaddr; + ulong offset; + uint value; - if (!tty || tty->magic != TTY_MAGIC || !file || !ch || - ch->magic != DGAP_CHANNEL_MAGIC) - return -EIO; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return 0; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -EIO; + if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC) + return 0; - spin_lock_irqsave(&ch->ch_lock, lock_flags); + if (!(ch->ch_bd->bd_flags & BD_FEP5PLUS)) + return 0; - ch->ch_wopen++; + vaddr = ch->ch_bd->re_map_membase; - /* Loop forever */ - while (1) { + if (!vaddr) + return 0; - sleep_on_un_flags = 0; + /* + * Go get from fep mem, what the fep + * believes the custom baud rate is. + */ + offset = (ioread16(vaddr + ECS_SEG) << 4) + (ch->ch_portnum * 0x28) + + LINE_SPEED; - /* - * If board has failed somehow during our sleep, - * bail with error. - */ - if (ch->ch_bd->state == BOARD_FAILED) { - retval = -EIO; - break; - } + value = readw(vaddr + offset); + return value; +} - /* If tty was hung up, break out of loop and set error. */ - if (tty_hung_up_p(file)) { - retval = -EAGAIN; - break; - } +/* + * Remap PCI memory. + */ +static int dgap_remap(struct board_t *brd) +{ + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return -EIO; - /* - * 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)) { + if (!request_mem_region(brd->membase, 0x200000, "dgap")) + return -ENOMEM; - /* - * 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 (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000, + "dgap")) { + release_mem_region(brd->membase, 0x200000); + return -ENOMEM; + } - if (file->f_flags & O_NONBLOCK) - break; + brd->re_map_membase = ioremap(brd->membase, 0x200000); + if (!brd->re_map_membase) { + release_mem_region(brd->membase, 0x200000); + release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); + return -ENOMEM; + } - if (tty->flags & (1 << TTY_IO_ERROR)) - break; + brd->re_map_port = ioremap((brd->membase + PCI_IO_OFFSET), 0x200000); + if (!brd->re_map_port) { + release_mem_region(brd->membase, 0x200000); + release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); + iounmap(brd->re_map_membase); + return -ENOMEM; + } - if (ch->ch_flags & CH_CD) - break; + return 0; +} - if (ch->ch_flags & CH_FCAR) - break; - } else { - sleep_on_un_flags = 1; - } +static void dgap_unmap(struct board_t *brd) +{ + iounmap(brd->re_map_port); + iounmap(brd->re_map_membase); + release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); + release_mem_region(brd->membase, 0x200000); +} - /* - * If there is a signal pending, the user probably - * interrupted (ctrl-c) us. - * Leave loop with error set. - */ - if (signal_pending(current)) { - retval = -ERESTARTSYS; - break; - } +/* + * dgap_parity_scan() + * + * Convert the FEP5 way of reporting parity errors and breaks into + * the Linux line discipline way. + */ +static 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; - /* - * 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; + in = cbuf; + cout = cbuf; + fout = fbuf; + + 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; - /* - * Let go of channel lock before calling schedule. - * Our poller will get any FEP events and wake us up when DCD - * eventually goes active. - */ + 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; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + 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; - /* - * 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)); - } + case 2: + /* third character of ff sequence */ - /* - * We got woken up for some reason. - * Before looping around, grab our channel lock. - */ - spin_lock_irqsave(&ch->ch_lock, lock_flags); - } + *cout++ = c; - ch->ch_wopen--; + if (ch->pscan_savechar == 0x0) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + if (c == 0x0) { + ch->ch_err_break++; + *fout++ = TTY_BREAK; + } else { + ch->ch_err_parity++; + *fout++ = TTY_PARITY; + } + } - return retval; + count += 1; + ch->pscan_state = 0; + } + } + *len = count; } -/* - * 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) + * dgap_input - Process received data. + * + * ch - Pointer to channel structure. + * + *=======================================================================*/ + +static void dgap_input(struct channel_t *ch) { struct board_t *bd; - struct channel_t *ch; - struct un_t *un; + struct bs_t __iomem *bs; + struct tty_struct *tp; + struct tty_ldisc *ld; + uint rmask; + uint head; + uint tail; + int data_len; + ulong lock_flags; + ulong lock_flags2; + int flip_len; + int len; + int n; + u8 *buf; + u8 tmpchar; + int s; - if (!tty || tty->magic != TTY_MAGIC) + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + tp = ch->ch_tun.un_tty; - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + bs = ch->ch_bs; + if (!bs) return; bd = ch->ch_bd; if (!bd || bd->magic != DGAP_BOARD_MAGIC) return; - /* flush the transmit queues */ - dgap_tty_flush_buffer(tty); -} + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); -/* - * 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; + /* + * Figure the number of characters in the buffer. + * Exit immediately if none. + */ - if (!tty || tty->magic != TTY_MAGIC) - return; + rmask = ch->ch_rsize - 1; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) + 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)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); return; + } - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + /* + * 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)) { + + writew(head, &(bs->rx_tail)); + writeb(1, &(bs->idata)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); return; + } - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) + /* + * If we are throttled, simply don't read any data. + */ + if (ch->ch_flags & CH_RXBLOCK) { + writeb(1, &(bs->idata)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); return; + } - ts = &tty->termios; + /* + * Ignore oruns. + */ + tmpchar = readb(&(bs->orun)); + if (tmpchar) { + ch->ch_err_overrun++; + writeb(0, &(bs->orun)); + } - spin_lock_irqsave(&ch->ch_lock, lock_flags); + /* 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 /* - * 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 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 ((tty->count == 1) && (un->un_open_count != 1)) { + 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 { /* - * 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. + * 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. */ - un->un_open_count = 1; + if (!ld->ops->receive_buf) { + writew(head, &(bs->rx_tail)); + len = 0; + } } - if (--un->un_open_count < 0) - un->un_open_count = 0; - - ch->ch_open_count--; - - if (ch->ch_open_count && un->un_open_count) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + if (len <= 0) { + writeb(1, &(bs->idata)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (ld) + tty_ldisc_deref(ld); return; } - /* OK, its the last close on the unit */ + 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, ch->ch_raddr + tail, s); + + tail += s; + buf += s; - un->un_flags |= UN_CLOSING; + n -= s; + /* Flip queue if needed */ + tail &= rmask; + } - tty->closing = 1; + writew(tail, &(bs->rx_tail)); + writeb(1, &(bs->idata)); + ch->ch_rxcount += len; /* - * Only officially close channel if count is 0 and - * DIGI_PRINTER bit is not set. + * 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 ((ch->ch_open_count == 0) && - !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { - - ch->ch_flags &= ~(CH_RXBLOCK); - - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - - /* wait for output to drain */ - /* This will also return if we take an interrupt */ + if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { + dgap_parity_scan(ch, ch->ch_bd->flipbuf, + ch->ch_bd->flipflagbuf, &len); - dgap_wait_for_drain(tty); + 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_tty_flush_buffer(tty); - tty_ldisc_flush(tty); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags); + /* Tell the tty layer its okay to "eat" the data now */ + tty_flip_buffer_push(tp->port); - tty->closing = 0; + if (ld) + tty_ldisc_deref(ld); - /* - * If we have HUPCL set, lower DTR and RTS - */ - if (ch->ch_c_cflag & HUPCL) { - 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. - */ - spin_unlock_irqrestore(&ch->ch_lock, - lock_flags); +static void dgap_write_wakeup(struct board_t *bd, struct channel_t *ch, + struct un_t *un, u32 mask, + unsigned long *irq_flags1, + unsigned long *irq_flags2) +{ + if (!(un->un_flags & mask)) + return; - /* .25 second delay for dropping RTS/DTR */ - schedule_timeout_interruptible(msecs_to_jiffies(250)); + un->un_flags &= ~mask; - spin_lock_irqsave(&ch->ch_lock, lock_flags); - } + if (!(un->un_flags & UN_ISOPEN)) + return; - ch->pscan_state = 0; - ch->pscan_savechar = 0; - ch->ch_baud_info = 0; + if ((un->un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + un->un_tty->ldisc->ops->write_wakeup) { + spin_unlock_irqrestore(&ch->ch_lock, *irq_flags2); + spin_unlock_irqrestore(&bd->bd_lock, *irq_flags1); - } + (un->un_tty->ldisc->ops->write_wakeup)(un->un_tty); - /* - * 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; + spin_lock_irqsave(&bd->bd_lock, *irq_flags1); + spin_lock_irqsave(&ch->ch_lock, *irq_flags2); } - - un->un_tty = NULL; - un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); - tty->driver_data = NULL; - - wake_up_interruptible(&ch->ch_flags_wait); + wake_up_interruptible(&un->un_tty->write_wait); wake_up_interruptible(&un->un_flags_wait); - - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); } -/* - * 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) +/************************************************************************ + * Determines when CARRIER changes state and takes appropriate + * action. + ************************************************************************/ +static void dgap_carrier(struct channel_t *ch) { struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - struct bs_t __iomem *bs; - u8 tbusy; - uint chars; - u16 thead, ttail, tmask, chead, ctail; - ulong lock_flags = 0; - ulong lock_flags2 = 0; - - if (!tty) - return 0; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return 0; + int virt_carrier = 0; + int phys_carrier = 0; - ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return 0; + return; bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return 0; + return; - bs = ch->ch_bs; - if (!bs) - return 0; + /* 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; + } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + if (ch->ch_mistat & D_CD(ch)) + phys_carrier = 1; - tmask = (ch->ch_tsize - 1); + if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) + virt_carrier = 1; - /* Get Transmit queue pointers */ - thead = readw(&(bs->tx_head)) & tmask; - ttail = readw(&(bs->tx_tail)) & tmask; + if (ch->ch_c_cflag & CLOCAL) + virt_carrier = 1; - /* Get tbusy flag */ - tbusy = readb(&(bs->tbusy)); + /* + * Test for a VIRTUAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { - /* Get Command queue pointers */ - chead = readw(&(ch->ch_cm->cm_head)); - ctail = readw(&(ch->ch_cm->cm_tail)); + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } /* - * 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). + * Test for a PHYSICAL carrier transition to HIGH. */ + if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { - 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. + * When carrier rises, wake any threads waiting + * for carrier in the open routine. */ - 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) { - spin_lock_irqsave(&ch->ch_lock, lock_flags); - un->un_flags |= UN_EMPTY; - writeb(1, &(bs->iempty)); - spin_unlock_irqrestore(&ch->ch_lock, - lock_flags); - } - chars = 1; - } + + 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) + tty_hangup(ch->ch_tun.un_tty); + + if (ch->ch_pun.un_open_count > 0) + tty_hangup(ch->ch_pun.un_tty); } - return chars; + /* + * 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; } -static int dgap_wait_for_drain(struct tty_struct *tty) +/*======================================================================= + * + * 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; - struct un_t *un; + ulong lock_flags; + ulong lock_flags2; struct bs_t __iomem *bs; - int ret = 0; - uint count = 1; - ulong lock_flags = 0; + u8 __iomem *event; + u8 __iomem *vaddr; + struct ev_t __iomem *eaddr; + uint head; + uint tail; + int port; + int reason; + int modem; + int b1; - if (!tty || tty->magic != TTY_MAGIC) + if (!bd || bd->magic != DGAP_BOARD_MAGIC) return -EIO; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -EIO; + spin_lock_irqsave(&bd->bd_lock, lock_flags); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -EIO; + vaddr = bd->re_map_membase; - bs = ch->ch_bs; - if (!bs) + if (!vaddr) { + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); return -EIO; + } - /* Loop until data is drained */ - while (count != 0) { - - count = dgap_tty_chars_in_buffer(tty); + eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); - if (count == 0) - break; + /* Get our head and tail */ + head = readw(&(eaddr->ev_head)); + tail = readw(&(eaddr->ev_tail)); - /* Set flag waiting for drain */ - spin_lock_irqsave(&ch->ch_lock, lock_flags); - un->un_flags |= UN_EMPTY; - writeb(1, &(bs->iempty)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + /* + * Forget it if pointers out of range. + */ - /* 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; + if (head >= EVMAX - EVSTART || tail >= EVMAX - EVSTART || + (head | tail) & 03) { + /* Let go of board lock */ + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return -EIO; } - spin_lock_irqsave(&ch->ch_lock, lock_flags); - un->un_flags &= ~(UN_EMPTY); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - - 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 channel_t *ch, struct un_t *un, - int bytes_available) -{ /* - * If its not the Transparent print device, return - * the full data amount. + * Loop to process all the events in the buffer. */ - if (un->un_type != DGAP_PRINT) - return bytes_available; + while (tail != head) { - 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; + /* + * Get interrupt information. + */ - 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; - } + event = bd->re_map_membase + tail + EVSTART; - bytes_available = min(cps_limit, bytes_available); - } + port = ioread8(event); + reason = ioread8(event + 1); + modem = ioread8(event + 2); + b1 = ioread8(event + 3); - return bytes_available; -} + /* + * Make sure the interrupt is valid. + */ + if (port >= bd->nasync) + goto next; -static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) -{ - struct channel_t *ch; - struct bs_t __iomem *bs; + if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA))) + goto next; - 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; + ch = bd->channels[port]; - 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)); + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + goto next; + + /* + * If we have made it here, the event was valid. + * Lock down the channel. + */ + spin_lock_irqsave(&ch->ch_lock, lock_flags2); + + bs = ch->ch_bs; + + if (!bs) { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + goto next; } - } -} -/* - * dgap_tty_write_room() - * - * Return space available in Tx buffer - */ -static int dgap_tty_write_room(struct tty_struct *tty) -{ - struct channel_t *ch; - struct un_t *un; - struct bs_t __iomem *bs; - u16 head, tail, tmask; - int ret; - ulong lock_flags = 0; + /* + * Process received data. + */ + if (reason & IFDATA) { - if (!tty) - return 0; + /* + * 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. + */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return 0; + dgap_input(ch); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return 0; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - bs = ch->ch_bs; - if (!bs) - return 0; + if (ch->ch_flags & CH_RACTIVE) + ch->ch_flags |= CH_RENABLE; + else + writeb(1, &(bs->idata)); - spin_lock_irqsave(&ch->ch_lock, lock_flags); + if (ch->ch_flags & CH_RWAIT) { + ch->ch_flags &= ~CH_RWAIT; - tmask = ch->ch_tsize - 1; - head = readw(&(bs->tx_head)) & tmask; - tail = readw(&(bs->tx_tail)) & tmask; + wake_up_interruptible + (&ch->ch_tun.un_flags_wait); + } + } - ret = tail - head - 1; - if (ret < 0) - ret += ch->ch_tsize; + /* + * Process Modem change signals. + */ + if (reason & IFMODEM) { + ch->ch_mistat = modem; + dgap_carrier(ch); + } + + /* + * Process break. + */ + if (reason & IFBREAK) { + + 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); + } + } - /* Limit printer to maxcps */ - ret = dgap_maxcps_room(ch, un, ret); + /* + * Process Transmit low. + */ + if (reason & IFTLW) { + dgap_write_wakeup(bd, ch, &ch->ch_tun, UN_LOW, + &lock_flags, &lock_flags2); + dgap_write_wakeup(bd, ch, &ch->ch_pun, UN_LOW, + &lock_flags, &lock_flags2); + if (ch->ch_flags & CH_WLOW) { + ch->ch_flags &= ~CH_WLOW; + wake_up_interruptible(&ch->ch_flags_wait); + } + } - /* - * 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; - } + /* + * Process Transmit empty. + */ + if (reason & IFTEM) { + dgap_write_wakeup(bd, ch, &ch->ch_tun, UN_EMPTY, + &lock_flags, &lock_flags2); + dgap_write_wakeup(bd, ch, &ch->ch_pun, UN_EMPTY, + &lock_flags, &lock_flags2); + if (ch->ch_flags & CH_WEMPTY) { + ch->ch_flags &= ~CH_WEMPTY; + wake_up_interruptible(&ch->ch_flags_wait); + } + } - if (ret < 0) - ret = 0; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - /* - * 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); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); +next: + tail = (tail + 4) & (EVMAX - EVSTART - 4); + } - return ret; -} + writew(tail, &(eaddr->ev_tail)); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); -/* - * 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. - */ - dgap_tty_write(tty, &c, 1); - return 1; + return 0; } /* - * 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. + * Our board poller function. */ -static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static void dgap_poll_tasklet(unsigned long data) { - struct channel_t *ch; - struct un_t *un; - struct bs_t __iomem *bs; - char __iomem *vaddr; - u16 head, tail, tmask, remain; - int bufcount, n; + struct board_t *bd = (struct board_t *) data; ulong lock_flags; + char __iomem *vaddr; + u16 head, tail; - if (!tty) - return 0; + if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) + return; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return 0; + if (bd->inhibit_poller) + return; - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return 0; + spin_lock_irqsave(&bd->bd_lock, lock_flags); - bs = ch->ch_bs; - if (!bs) - return 0; + vaddr = bd->re_map_membase; - if (!count) - return 0; + /* + * If board is ready, parse deeper to see if there is anything to do. + */ + if (bd->state == BOARD_READY) { - spin_lock_irqsave(&ch->ch_lock, lock_flags); + struct ev_t __iomem *eaddr; - /* 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 (!bd->re_map_membase) { + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return; + } + if (!bd->re_map_port) { + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return; + } - bufcount = tail - head - 1; - if (bufcount < 0) - bufcount += ch->ch_tsize; + if (!bd->nasync) + goto out; - /* - * Limit printer output to maxcps overall, with bursts allowed - * up to bufsize characters. - */ - bufcount = dgap_maxcps_room(ch, un, bufcount); + eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); - /* - * Take minimum of what the user wants to send, and the - * space available in the FEP buffer. - */ - count = min(count, bufcount); + /* Get our head and tail */ + head = readw(&(eaddr->ev_head)); + tail = readw(&(eaddr->ev_tail)); - /* - * Bail if no space left. - */ - if (count <= 0) { - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - return 0; - } + /* + * If there is an event pending. Go service it. + */ + if (head != tail) { + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + dgap_event(bd); + spin_lock_irqsave(&bd->bd_lock, lock_flags); + } - /* - * 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; - } +out: + /* + * If board is doing interrupts, ACK the interrupt. + */ + if (bd && bd->intr_running) + readb(bd->re_map_port + 2); - /* - * 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; + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return; } - n = count; + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); +} - /* - * 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; +/* + * dgap_found_board() + * + * A board has been found, init it. + */ +static struct board_t *dgap_found_board(struct pci_dev *pdev, int id, + int boardnum) +{ + struct board_t *brd; + unsigned int pci_irq; + int i; + int ret; - if (n >= remain) { - n -= remain; - vaddr = ch->ch_taddr + head; + /* get the board structure and prep it */ + brd = kzalloc(sizeof(struct board_t), GFP_KERNEL); + if (!brd) + return ERR_PTR(-ENOMEM); - memcpy_toio(vaddr, (u8 *) buf, remain); + /* store the info for the board we've found */ + brd->magic = DGAP_BOARD_MAGIC; + brd->boardnum = boardnum; + brd->vendor = dgap_pci_tbl[id].vendor; + brd->device = dgap_pci_tbl[id].device; + brd->pdev = pdev; + brd->pci_bus = pdev->bus->number; + brd->pci_slot = PCI_SLOT(pdev->devfn); + brd->name = dgap_ids[id].name; + brd->maxports = dgap_ids[id].maxports; + brd->type = dgap_ids[id].config_type; + brd->dpatype = dgap_ids[id].dpatype; + brd->dpastatus = BD_NOFEP; + init_waitqueue_head(&brd->state_wait); - head = ch->ch_tstart; - buf += remain; - } + spin_lock_init(&brd->bd_lock); - if (n > 0) { + brd->inhibit_poller = FALSE; + brd->wait_for_bios = 0; + brd->wait_for_fep = 0; - /* - * Move rest of data. - */ - vaddr = ch->ch_taddr + head; - remain = n; + for (i = 0; i < MAXPORTS; i++) + brd->channels[i] = NULL; + + /* store which card & revision we have */ + pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor); + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice); + pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev); + + pci_irq = pdev->irq; + brd->irq = pci_irq; - memcpy_toio(vaddr, (u8 *) buf, remain); - head += remain; + /* get the PCI Base Address Registers */ + /* Xr Jupiter and EPC use BAR 2 */ + if (brd->device == PCI_DEV_XRJ_DID || brd->device == PCI_DEV_EPCJ_DID) { + brd->membase = pci_resource_start(pdev, 2); + brd->membase_end = pci_resource_end(pdev, 2); + } + /* Everyone else uses BAR 0 */ + else { + brd->membase = pci_resource_start(pdev, 0); + brd->membase_end = pci_resource_end(pdev, 0); } - if (count) { - ch->ch_txcount += count; - head &= tmask; - writew(head, &(bs->tx_head)); + if (!brd->membase) { + ret = -ENODEV; + goto free_brd; } - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + if (brd->membase & 1) + brd->membase &= ~3; + else + brd->membase &= ~15; /* - * 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. + * 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 */ - 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; - } - - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - - return count; -} + brd->port = brd->membase + PCI_IO_OFFSET; + brd->port_end = brd->port + PCI_IO_SIZE; -/* - * Return modem signals to ld. - */ -static int dgap_tty_tiocmget(struct tty_struct *tty) -{ - struct channel_t *ch; - struct un_t *un; - int result; - u8 mstat; - ulong lock_flags; + /* + * Special initialization for non-PLX boards + */ + if (brd->device != PCI_DEV_XRJ_DID && brd->device != PCI_DEV_EPCJ_DID) { + unsigned short cmd; - if (!tty || tty->magic != TTY_MAGIC) - return -EIO; + pci_write_config_byte(pdev, 0x40, 0); + pci_write_config_byte(pdev, 0x46, 0); - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -EIO; + /* Limit burst length to 2 doubleword transactions */ + pci_write_config_byte(pdev, 0x42, 1); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -EIO; + /* + * Enable IO and mem if not already done. + * This was needed for support on Itanium. + */ + pci_read_config_word(pdev, PCI_COMMAND, &cmd); + cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); + pci_write_config_word(pdev, PCI_COMMAND, cmd); + } - spin_lock_irqsave(&ch->ch_lock, lock_flags); + /* init our poll helper tasklet */ + tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet, + (unsigned long) brd); - mstat = readb(&(ch->ch_bs->m_stat)); - /* Append any outbound signals that might be pending... */ - mstat |= ch->ch_mostat; + ret = dgap_remap(brd); + if (ret) + goto free_brd; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + pr_info("dgap: board %d: %s (rev %d), irq %ld\n", + boardnum, brd->name, brd->rev, brd->irq); - result = 0; + return brd; - 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; +free_brd: + kfree(brd); - return result; + return ERR_PTR(ret); } /* - * dgap_tty_tiocmset() + * dgap_intr() * - * Set modem signals, called by ld. + * Driver interrupt handler. */ -static int dgap_tty_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear) +static irqreturn_t dgap_intr(int irq, void *voidbrd) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + struct board_t *brd = voidbrd; - if (!tty || tty->magic != TTY_MAGIC) - return -EIO; + if (!brd) + return IRQ_NONE; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -EIO; + /* + * Check to make sure its for us. + */ + if (brd->magic != DGAP_BOARD_MAGIC) + return IRQ_NONE; - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -EIO; + brd->intr_count++; - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -EIO; + /* + * Schedule tasklet to run at a better time. + */ + tasklet_schedule(&brd->helper_tasklet); + return IRQ_HANDLED; +} - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); +/***************************************************************************** +* +* Function: +* +* dgap_poll_handler +* +* Author: +* +* Scott H Kilau +* +* Parameters: +* +* dummy -- ignored +* +* Return Values: +* +* none +* +* 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. +* +******************************************************************************/ - if (set & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval |= D_RTS(ch); - } +static void dgap_poll_handler(ulong dummy) +{ + unsigned int i; + struct board_t *brd; + unsigned long lock_flags; + ulong new_time; - if (set & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval |= D_DTR(ch); - } + dgap_poll_counter++; - if (clear & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval &= ~(D_RTS(ch)); - } + /* + * Do not start the board state machine until + * driver tells us its up and running, and has + * everything it needs. + */ + if (dgap_driver_state != DRIVER_READY) + goto schedule_poller; - if (clear & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval &= ~(D_DTR(ch)); - } + /* + * If we have just 1 board, or the system is not SMP, + * then use the typical old style poller. + * Otherwise, use our new tasklet based poller, which should + * speed things up for multiple boards. + */ + if ((dgap_numboards == 1) || (num_online_cpus() <= 1)) { + for (i = 0; i < dgap_numboards; i++) { - dgap_param(ch, bd, un->un_type); + brd = dgap_board[i]; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (brd->state == BOARD_FAILED) + continue; + if (!brd->intr_running) + /* Call the real board poller directly */ + dgap_poll_tasklet((unsigned long) brd); + } + } else { + /* + * Go thru each board, kicking off a + * tasklet for each if needed + */ + for (i = 0; i < dgap_numboards; i++) { + brd = dgap_board[i]; + + /* + * Attempt to grab the board lock. + * + * If we can't get it, no big deal, the next poll + * will get it. Basically, I just really don't want + * to spin in here, because I want to kick off my + * tasklets as fast as I can, and then get out the + * poller. + */ + if (!spin_trylock(&brd->bd_lock)) + continue; - return 0; -} + /* + * If board is in a failed state, don't bother + * scheduling a tasklet + */ + if (brd->state == BOARD_FAILED) { + spin_unlock(&brd->bd_lock); + continue; + } -/* - * 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; - ulong lock_flags; - ulong lock_flags2; + /* Schedule a poll helper task */ + if (!brd->intr_running) + tasklet_schedule(&brd->helper_tasklet); - if (!tty || tty->magic != TTY_MAGIC) - return -EIO; + /* + * Can't do DGAP_UNLOCK here, as we don't have + * lock_flags because we did a trylock above. + */ + spin_unlock(&brd->bd_lock); + } + } - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -EIO; +schedule_poller: - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -EIO; + /* + * Schedule ourself back at the nominal wakeup interval. + */ + spin_lock_irqsave(&dgap_poll_lock, lock_flags); + dgap_poll_time += dgap_jiffies_from_ms(dgap_poll_tick); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -EIO; + new_time = dgap_poll_time - jiffies; - switch (msec) { - case -1: - msec = 0xFFFF; - break; - case 0: - msec = 1; - break; - default: - msec /= 10; - break; + if ((ulong) new_time >= 2 * dgap_poll_tick) { + dgap_poll_time = + jiffies + dgap_jiffies_from_ms(dgap_poll_tick); } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); -#if 0 - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); -#endif - dgap_cmdw(ch, SBREAK, (u16) msec, 0); - - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + dgap_poll_timer.function = dgap_poll_handler; + dgap_poll_timer.data = 0; + dgap_poll_timer.expires = dgap_poll_time; + spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); - return 0; + if (!dgap_poll_stop) + add_timer(&dgap_poll_timer); } -/* - * 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) -{ - dgap_wait_for_drain(tty); -} - -/* - * dgap_send_xchar() + * dgap_cmdb - Sends a 2 byte command to the FEP. * - * send a high priority character, called by ld. - */ -static void dgap_tty_send_xchar(struct tty_struct *tty, char c) + * 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. + * + *=======================================================================*/ +static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, + u8 byte2, uint ncmds) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + char __iomem *vaddr; + struct __iomem cm_t *cm_addr; + uint count; + uint n; + u16 head; + u16 tail; - if (!tty || tty->magic != TTY_MAGIC) + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) return; - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + + if (!vaddr) return; - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) + cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + ch->ch_bd->state = BOARD_FAILED; return; + } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* + * Put the data in the circular command buffer. + */ + writeb(cmd, (vaddr + head + CMDSTART + 0)); + writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); + writeb(byte1, (vaddr + head + CMDSTART + 2)); + writeb(byte2, (vaddr + head + CMDSTART + 3)); + + head = (head + 4) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); /* - * 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... + * 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. */ -#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 + for (count = dgap_count ;;) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); -} + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); -/* - * Return modem signals to ld. - */ -static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) -{ - int result; - u8 mstat; - ulong lock_flags; - int rc; + n = (head - tail) & (CMDMAX - CMDSTART - 4); - spin_lock_irqsave(&ch->ch_lock, lock_flags); + if (n <= ncmds * sizeof(struct cm_t)) + break; - mstat = readb(&(ch->ch_bs->m_stat)); - /* Append any outbound signals that might be pending... */ - mstat |= ch->ch_mostat; + if (--count == 0) { + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); +/*======================================================================= + * + * 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. + * + *=======================================================================*/ +static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) +{ + char __iomem *vaddr; + struct __iomem cm_t *cm_addr; + uint count; + uint n; + u16 head; + u16 tail; - result = 0; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - 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; + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) + return; + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + if (!vaddr) + return; - rc = put_user(result, value); + cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); - return rc; -} + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + ch->ch_bd->state = BOARD_FAILED; + return; + } -/* - * dgap_set_modem_info() - * - * Set modem signals, called by ld. - */ -static int dgap_set_modem_info(struct channel_t *ch, struct board_t *bd, - struct un_t *un, unsigned int command, - unsigned int __user *value) -{ - int ret; - unsigned int arg; - ulong lock_flags; - ulong lock_flags2; + /* + * Put the data in the circular command buffer. + */ + writeb(cmd, (vaddr + head + CMDSTART + 0)); + writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); + writew((u16) word, (vaddr + head + CMDSTART + 2)); - ret = get_user(arg, value); - if (ret) - return ret; + head = (head + 4) & (CMDMAX - CMDSTART - 4); - switch (command) { - case TIOCMBIS: - if (arg & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval |= D_RTS(ch); - } + writew(head, &(cm_addr->cm_head)); - if (arg & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval |= D_DTR(ch); - } + /* + * 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 ;;) { - break; + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); - case TIOCMBIC: - if (arg & TIOCM_RTS) { - ch->ch_mforce |= D_RTS(ch); - ch->ch_mval &= ~(D_RTS(ch)); - } + n = (head - tail) & (CMDMAX - CMDSTART - 4); - if (arg & TIOCM_DTR) { - ch->ch_mforce |= D_DTR(ch); - ch->ch_mval &= ~(D_DTR(ch)); + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + ch->ch_bd->state = BOARD_FAILED; + return; } + udelay(10); + } +} - break; +/*======================================================================= + * + * 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 __iomem *vaddr; + struct __iomem cm_t *cm_addr; + uint count; + uint n; + u16 head; + u16 tail; - case TIOCMSET: - ch->ch_mforce = D_DTR(ch)|D_RTS(ch); + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - if (arg & TIOCM_RTS) - ch->ch_mval |= D_RTS(ch); - else - ch->ch_mval &= ~(D_RTS(ch)); + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) + return; - if (arg & TIOCM_DTR) - ch->ch_mval |= (D_DTR(ch)); - else - ch->ch_mval &= ~(D_DTR(ch)); + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + if (!vaddr) + return; - break; + cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); - default: - return -EINVAL; + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + ch->ch_bd->state = BOARD_FAILED; + return; } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* + * Put the data in the circular command buffer. + */ - dgap_param(ch, bd, un->un_type); + /* Write an FF to tell the FEP that we want an extended command */ + writeb((u8) 0xff, (vaddr + head + CMDSTART + 0)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); + writew((u16) cmd, (vaddr + head + CMDSTART + 2)); - return 0; -} + /* + * 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, (vaddr + CMDSTART)); + else + writew((u16) word, (vaddr + head + CMDSTART + 4)); -/* - * dgap_tty_digigeta() - * - * Ioctl to get the information for ditty. - * - * - * - */ -static int dgap_tty_digigeta(struct channel_t *ch, - struct digi_t __user *retinfo) -{ - struct digi_t tmp; - ulong lock_flags; + head = (head + 8) & (CMDMAX - CMDSTART - 4); - if (!retinfo) - return -EFAULT; + writew(head, &(cm_addr->cm_head)); - memset(&tmp, 0, sizeof(tmp)); + /* + * 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 ;;) { - spin_lock_irqsave(&ch->ch_lock, lock_flags); - memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + n = (head - tail) & (CMDMAX - CMDSTART - 4); - return 0; + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } } -/* - * dgap_tty_digiseta() - * - * Ioctl to set the information for ditty. +/*======================================================================= * + * 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. * - */ -static int dgap_tty_digiseta(struct channel_t *ch, struct board_t *bd, - struct un_t *un, struct digi_t __user *new_info) + *=======================================================================*/ +static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) { - struct digi_t new_digi; - ulong lock_flags = 0; - unsigned long lock_flags2; - - if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) - return -EFAULT; - - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&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; + int n; + char __iomem *taddr; + struct bs_t __iomem *bs; + u16 head; - if (ch->ch_digi.digi_maxchar < 1) - ch->ch_digi.digi_maxchar = 1; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize) - ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize; + /* + * Check parameters. + */ + bs = ch->ch_bs; + head = readw(&(bs->tx_head)); - if (ch->ch_digi.digi_onlen > DIGI_PLEN) - ch->ch_digi.digi_onlen = DIGI_PLEN; + /* + * If pointers are out of range, just return. + */ + if ((cnt > ch->ch_tsize) || + (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize) + return; - if (ch->ch_digi.digi_offlen > DIGI_PLEN) - ch->ch_digi.digi_offlen = DIGI_PLEN; + /* + * 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; - dgap_param(ch, bd, un->un_type); + if (cnt >= n) { + cnt -= n; + taddr = ch->ch_taddr + head; + memcpy_toio(taddr, buf, n); + head = ch->ch_tstart; + buf += n; + } - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + /* + * Move rest of data. + */ + taddr = ch->ch_taddr + head; + n = cnt; + memcpy_toio(taddr, buf, n); + head += cnt; - return 0; + writew(head, &(bs->tx_head)); } /* - * dgap_tty_digigetedelay() - * - * Ioctl to get the current edelay setting. - * - * - * + * Calls the firmware to reset this channel. */ -static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo) +static void dgap_firmware_reset_port(struct channel_t *ch) { - 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; + dgap_cmdb(ch, CHRESET, 0, 0, 0); - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return -EFAULT; + /* + * 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; +} - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -EFAULT; +/*======================================================================= + * + * dgap_param - Set Digi parameters. + * + * struct tty_struct * - TTY for port. + * + *=======================================================================*/ +static int dgap_param(struct channel_t *ch, struct board_t *bd, u32 un_type) +{ + u16 head; + u16 cflag; + u16 iflag; + u8 mval; + u8 hflow; - memset(&tmp, 0, sizeof(tmp)); + /* + * If baud rate is zero, flush queues, and set mval to drop DTR. + */ + if ((ch->ch_c_cflag & (CBAUD)) == 0) { - spin_lock_irqsave(&ch->ch_lock, lock_flags); - tmp = readw(&(ch->ch_bs->edelay)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + /* flush rx */ + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + /* flush tx */ + head = readw(&(ch->ch_bs->tx_head)); + writew(head, &(ch->ch_bs->tx_tail)); - return 0; -} + ch->ch_flags |= (CH_BAUD0); -/* - * dgap_tty_digisetedelay() - * - * Ioctl to set the EDELAY setting - * - */ -static int dgap_tty_digisetedelay(struct channel_t *ch, struct board_t *bd, - struct un_t *un, int __user *new_info) -{ - int new_digi; - ulong lock_flags; - ulong lock_flags2; + /* 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; - if (copy_from_user(&new_digi, new_info, sizeof(int))) - return -EFAULT; + } else if (ch->ch_custom_speed && (bd->bd_flags & BD_FEP5PLUS)) { + /* + * Tell the fep to do the command + */ - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + dgap_cmdw_ext(ch, 0xff01, ch->ch_custom_speed, 0); - writew((u16) new_digi, &(ch->ch_bs->edelay)); + /* + * Now go get from fep mem, what the fep + * believes the custom baud rate is. + */ + ch->ch_custom_speed = dgap_get_custom_baud(ch); + ch->ch_baud_info = ch->ch_custom_speed; - dgap_param(ch, bd, un->un_type); + /* 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); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + } else { + /* + * Set baud rate, character size, and parity. + */ - return 0; -} -/* - * dgap_tty_digigetcustombaud() - * - * Ioctl to get the current custom baud rate setting. - */ -static int dgap_tty_digigetcustombaud(struct channel_t *ch, struct un_t *un, - int __user *retinfo) -{ - int tmp; - ulong lock_flags; + int iindex = 0; + int jindex = 0; + int baud = 0; - if (!retinfo) - return -EFAULT; + 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 } + }; - memset(&tmp, 0, sizeof(tmp)); + /* + * Only use the TXPrint baud rate if the + * terminal unit is NOT open + */ + if (!(ch->ch_tun.un_flags & UN_ISOPEN) && + un_type == DGAP_PRINT) + baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; + else + baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; - spin_lock_irqsave(&ch->ch_lock, lock_flags); - tmp = dgap_get_custom_baud(ch); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + if (ch->ch_c_cflag & CBAUDEX) + iindex = 1; - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; + if (ch->ch_digi.digi_flags & DIGI_FAST) + iindex += 2; - return 0; -} + jindex = baud; -/* - * dgap_tty_digisetcustombaud() - * - * Ioctl to set the custom baud rate setting - */ -static int dgap_tty_digisetcustombaud(struct channel_t *ch, struct board_t *bd, - struct un_t *un, int __user *new_info) -{ - uint new_rate; - ulong lock_flags; - ulong lock_flags2; + if ((iindex >= 0) && (iindex < 4) && + (jindex >= 0) && (jindex < 16)) + baud = bauds[iindex][jindex]; + else + baud = 0; - if (copy_from_user(&new_rate, new_info, sizeof(unsigned int))) - return -EFAULT; + if (baud == 0) + baud = 9600; - if (bd->bd_flags & BD_FEP5PLUS) { + ch->ch_baud_info = baud; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* + * 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); - ch->ch_custom_speed = new_rate; + /* + * 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; - dgap_param(ch, bd, un->un_type); + 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; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - } + /* + * 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; + } - return 0; -} + if (baudpart) + cflag = (cflag & ~(CBAUD | CBAUDEX)) | baudpart; + } -/* - * 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; + cflag &= 0xffff; - if (!tty || tty->magic != TTY_MAGIC) - return; + if (cflag != ch->ch_fepcflag) { + ch->ch_fepcflag = (u16) (cflag & 0xffff); - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + /* + * Okay to have channel and board + * locks held calling this + */ + dgap_cmdw(ch, SCFLAG, (u16) cflag, 0); + } - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + /* 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); + } - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + /* + * Get input flags. + */ + iflag = ch->ch_c_iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | + INPCK | ISTRIP | IXON | IXANY | IXOFF); - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + if ((ch->ch_startc == _POSIX_VDISABLE) || + (ch->ch_stopc == _POSIX_VDISABLE)) { + iflag &= ~(IXON | IXOFF); + ch->ch_c_iflag &= ~(IXON | IXOFF); + } - 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]; + /* + * Only the IBM Xr card can switch between + * 232 and 422 modes on the fly + */ + if (bd->device == PCI_DEV_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); + } - dgap_carrier(ch); - dgap_param(ch, bd, un->un_type); + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) + iflag |= IALTPIN; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); -} + if (iflag != ch->ch_fepiflag) { + ch->ch_fepiflag = iflag; -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; + /* Okay to have channel and board locks held calling this */ + dgap_cmdw(ch, SIFLAG, (u16) ch->ch_fepiflag, 0); + } - if (!tty || tty->magic != TTY_MAGIC) - return; + /* + * Select hardware handshaking. + */ + hflow = 0; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + 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); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + if (hflow != ch->ch_hflow) { + ch->ch_hflow = hflow; - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0); + } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* + * Set RTS and/or DTR Toggle if needed, + * but only if product is FEP5+ based. + */ + if (bd->bd_flags & BD_FEP5PLUS) { + u16 hflow2 = 0; - ch->ch_flags |= (CH_RXBLOCK); -#if 1 - dgap_cmdw(ch, RPAUSE, 0, 0); -#endif + 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)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + dgap_cmdw_ext(ch, 0xff03, hflow2, 0); + } -} + /* + * Set modem control lines. + */ -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; + mval ^= ch->ch_mforce & (mval ^ ch->ch_mval); - if (!tty || tty->magic != TTY_MAGIC) - return; + if (ch->ch_mostat ^ mval) { + ch->ch_mostat = mval; - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SMODEM, (u8) mval, D_RTS(ch)|D_DTR(ch), 0); + } - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + /* + * Read modem signals, and then call carrier function. + */ + ch->ch_mistat = readb(&(ch->ch_bs->m_stat)); + dgap_carrier(ch); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + /* + * 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; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SFLOWC, ch->ch_fepstartc, ch->ch_fepstopc, 0); + } - ch->ch_flags &= ~(CH_RXBLOCK); + /* + * 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; -#if 1 - dgap_cmdw(ch, RRESUME, 0, 0); -#endif + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SAFLOWC, ch->ch_fepastartc, ch->ch_fepastopc, 0); + } - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return 0; } -static void dgap_tty_start(struct tty_struct *tty) +/* + * 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) { - struct board_t *bd; - struct channel_t *ch; + int retval = 0; struct un_t *un; ulong lock_flags; - ulong lock_flags2; + uint old_flags; + int sleep_on_un_flags; - if (!tty || tty->magic != TTY_MAGIC) - return; + if (!tty || tty->magic != TTY_MAGIC || !file || !ch || + ch->magic != DGAP_CHANNEL_MAGIC) + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + return -EIO; - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + spin_lock_irqsave(&ch->ch_lock, lock_flags); - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + ch->ch_wopen++; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* Loop forever */ + while (1) { - dgap_cmdw(ch, RESUMETX, 0, 0); + sleep_on_un_flags = 0; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); -} + /* + * If board has failed somehow during our sleep, + * bail with error. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + retval = -EIO; + break; + } -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 was hung up, break out of loop and set error. */ + if (tty_hung_up_p(file)) { + retval = -EAGAIN; + break; + } - if (!tty || tty->magic != TTY_MAGIC) - return; + /* + * 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)) { - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + /* + * 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. + */ - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + if (file->f_flags & O_NONBLOCK) + break; - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + if (tty->flags & (1 << TTY_IO_ERROR)) + break; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + if (ch->ch_flags & CH_CD) + break; - dgap_cmdw(ch, PAUSETX, 0, 0); + if (ch->ch_flags & CH_FCAR) + break; + } else { + sleep_on_un_flags = 1; + } - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); -} + /* + * If there is a signal pending, the user probably + * interrupted (ctrl-c) us. + * Leave loop with error set. + */ + if (signal_pending(current)) { + retval = -ERESTARTSYS; + break; + } -/* - * 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; + /* + * 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; - if (!tty || tty->magic != TTY_MAGIC) - return; + /* + * Let go of channel lock before calling schedule. + * Our poller will get any FEP events and wake us up when DCD + * eventually goes active. + */ - un = tty->driver_data; - if (!un || un->magic != DGAP_UNIT_MAGIC) - return; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - ch = un->un_ch; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + /* + * 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)); + } - bd = ch->ch_bd; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return; + /* + * We got woken up for some reason. + * Before looping around, grab our channel lock. + */ + spin_lock_irqsave(&ch->ch_lock, lock_flags); + } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + ch->ch_wopen--; - /* TODO: Do something here */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return retval; } /* @@ -3609,2005 +3245,2126 @@ static void dgap_tty_flush_buffer(struct tty_struct *tty) tty_wakeup(tty); } -/***************************************************************************** - * - * The IOCTL function and all of its helpers - * - *****************************************************************************/ - /* - * dgap_tty_ioctl() + * dgap_tty_hangup() * - * The usual assortment of ioctl's + * Hangup the port. Like a close, but don't wait for output to drain. */ -static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, - unsigned long arg) +static void dgap_tty_hangup(struct tty_struct *tty) { struct board_t *bd; struct channel_t *ch; struct un_t *un; - int rc; - u16 head; - ulong lock_flags = 0; - ulong lock_flags2 = 0; - void __user *uarg = (void __user *) arg; if (!tty || tty->magic != TTY_MAGIC) - return -ENODEV; + return; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return -ENODEV; + return; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -ENODEV; + return; bd = ch->ch_bd; if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -ENODEV; - - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); - - if (un->un_open_count <= 0) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return -EIO; - } - - switch (cmd) { - - /* Here are all the standard ioctl's that we MUST implement */ + return; - 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); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if (rc) - return rc; + /* flush the transmit queues */ + dgap_tty_flush_buffer(tty); +} - rc = dgap_wait_for_drain(tty); +/* + * 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; + struct channel_t *ch; + struct un_t *un; + struct bs_t __iomem *bs; + u8 tbusy; + uint chars; + u16 thead, ttail, tmask, chead, ctail; + ulong lock_flags = 0; + ulong lock_flags2 = 0; - if (rc) - return -EINTR; + if (!tty) + return 0; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return 0; - if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return 0; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return 0; + bs = ch->ch_bs; + if (!bs) return 0; - case TCSBRKP: - /* support for POSIX tcsendbreak() + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - * 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); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if (rc) - return rc; + tmask = (ch->ch_tsize - 1); - rc = dgap_wait_for_drain(tty); - if (rc) - return -EINTR; + /* Get Transmit queue pointers */ + thead = readw(&(bs->tx_head)) & tmask; + ttail = readw(&(bs->tx_tail)) & tmask; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + /* Get tbusy flag */ + tbusy = readb(&(bs->tbusy)); - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + /* Get Command queue pointers */ + chead = readw(&(ch->ch_cm->cm_head)); + ctail = readw(&(ch->ch_cm->cm_tail)); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return 0; + /* + * 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). + */ - case TIOCSBRK: + if ((ttail == thead) && (tbusy == 0) && (chead == ctail)) { + chars = 0; + } else { + if (thead >= ttail) + chars = thead - ttail; + else + chars = thead - ttail + ch->ch_tsize; /* - * 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. + * 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. */ - rc = tty_check_change(tty); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if (rc) - return rc; - - rc = dgap_wait_for_drain(tty); - if (rc) - return -EINTR; + 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) { + spin_lock_irqsave(&ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + spin_unlock_irqrestore(&ch->ch_lock, + lock_flags); + } + chars = 1; + } + } - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + return chars; +} - dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); +static int dgap_wait_for_drain(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + struct bs_t __iomem *bs; + int ret = 0; + uint count = 1; + ulong lock_flags = 0; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (!tty || tty->magic != TTY_MAGIC) + return -EIO; - return 0; + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return -EIO; - 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. - */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return 0; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return -EIO; - case TIOCGSOFTCAR: + bs = ch->ch_bs; + if (!bs) + return -EIO; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + /* Loop until data is drained */ + while (count != 0) { - rc = put_user(C_CLOCAL(tty) ? 1 : 0, - (unsigned long __user *) arg); - return rc; + count = dgap_tty_chars_in_buffer(tty); - case TIOCSSOFTCAR: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (count == 0) + break; - rc = get_user(arg, (unsigned long __user *) arg); - if (rc) - return rc; + /* Set flag waiting for drain */ + spin_lock_irqsave(&ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); - tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | - (arg ? CLOCAL : 0)); - dgap_param(ch, bd, un->un_type); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_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; + } - return 0; + spin_lock_irqsave(&ch->ch_lock, lock_flags); + un->un_flags &= ~(UN_EMPTY); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - case TIOCMGET: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_get_modem_info(ch, uarg); + return ret; +} - case TIOCMBIS: - case TIOCMBIC: - case TIOCMSET: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_set_modem_info(ch, bd, un, cmd, uarg); +/* + * 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 channel_t *ch, struct un_t *un, + int bytes_available) +{ + /* + * If its not the Transparent print device, return + * the full data amount. + */ + if (un->un_type != DGAP_PRINT) + return bytes_available; - /* - * Here are any additional ioctl's that we want to implement - */ + 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; - 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) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return rc; + 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; } - 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)); - } - } + bytes_available = min(cps_limit, bytes_available); + } - if ((arg != TCOFLUSH) && (arg != TCIOFLUSH)) { - /* pretend we didn't recognize this IOCTL */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return bytes_available; +} - return -ENOIOCTLCMD; - } +static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) +{ + struct channel_t *ch; + struct bs_t __iomem *bs; + + 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; - 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 ((event & UN_LOW) != 0) { + if ((un->un_flags & UN_LOW) == 0) { + un->un_flags |= UN_LOW; + writeb(1, &(bs->ilow)); } - 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 ((event & UN_LOW) != 0) { + if ((un->un_flags & UN_EMPTY) == 0) { + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); } - if (waitqueue_active(&tty->write_wait)) - wake_up_interruptible(&tty->write_wait); + } +} - /* Can't hold any locks when calling tty_wakeup! */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - tty_wakeup(tty); +/* + * dgap_tty_write_room() + * + * Return space available in Tx buffer + */ +static int dgap_tty_write_room(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + struct bs_t __iomem *bs; + u16 head, tail, tmask; + int ret; + ulong lock_flags = 0; - /* pretend we didn't recognize this IOCTL */ - return -ENOIOCTLCMD; + if (!tty) + return 0; - 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)); - } + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return 0; - /* now wait for all the output to drain */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - rc = dgap_wait_for_drain(tty); - if (rc) - return -EINTR; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return 0; - /* pretend we didn't recognize this */ - return -ENOIOCTLCMD; + bs = ch->ch_bs; + if (!bs) + return 0; - case TCSETAW: + spin_lock_irqsave(&ch->ch_lock, lock_flags); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - rc = dgap_wait_for_drain(tty); - if (rc) - return -EINTR; + tmask = ch->ch_tsize - 1; + head = readw(&(bs->tx_head)) & tmask; + tail = readw(&(bs->tx_tail)) & tmask; - /* pretend we didn't recognize this */ - return -ENOIOCTLCMD; + ret = tail - head - 1; + if (ret < 0) + ret += ch->ch_tsize; - 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) { - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return rc; - } + /* Limit printer to maxcps */ + ret = dgap_maxcps_room(ch, un, ret); - switch (arg) { + /* + * 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; + } - case TCOON: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - dgap_tty_start(tty); - return 0; - case TCOOFF: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - dgap_tty_stop(tty); - return 0; - case TCION: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - /* Make the ld do it */ - return -ENOIOCTLCMD; - case TCIOFF: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - /* Make the ld do it */ - return -ENOIOCTLCMD; - default: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return -EINVAL; - } + if (ret < 0) + ret = 0; - case DIGI_GETA: - /* get information for ditty */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_tty_digigeta(ch, uarg); + /* + * 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); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - case DIGI_SETAW: - case DIGI_SETAF: + return ret; +} - /* set information for ditty */ - if (cmd == (DIGI_SETAW)) { +/* + * 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; + struct un_t *un; + struct bs_t __iomem *bs; + char __iomem *vaddr; + u16 head, tail, tmask, remain; + int bufcount, n; + ulong lock_flags; - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - rc = dgap_wait_for_drain(tty); - if (rc) - return -EINTR; - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); - } else - tty_ldisc_flush(tty); - /* fall thru */ + if (!tty) + return 0; - case DIGI_SETA: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_tty_digiseta(ch, bd, un, uarg); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return 0; - case DIGI_GEDELAY: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_tty_digigetedelay(tty, uarg); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return 0; - case DIGI_SEDELAY: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_tty_digisetedelay(ch, bd, un, uarg); + bs = ch->ch_bs; + if (!bs) + return 0; - case DIGI_GETCUSTOMBAUD: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_tty_digigetcustombaud(ch, un, uarg); + if (!count) + return 0; - case DIGI_SETCUSTOMBAUD: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return dgap_tty_digisetcustombaud(ch, bd, un, uarg); + spin_lock_irqsave(&ch->ch_lock, lock_flags); - case DIGI_RESET_PORT: - dgap_firmware_reset_port(ch); - dgap_param(ch, bd, un->un_type); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return 0; + /* 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; - default: - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + bufcount = tail - head - 1; + if (bufcount < 0) + bufcount += ch->ch_tsize; + + /* + * Limit printer output to maxcps overall, with bursts allowed + * up to bufsize characters. + */ + bufcount = dgap_maxcps_room(ch, un, bufcount); + + /* + * Take minimum of what the user wants to send, and the + * space available in the FEP buffer. + */ + count = min(count, bufcount); - return -ENOIOCTLCMD; + /* + * Bail if no space left. + */ + if (count <= 0) { + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + return 0; } -} -static int dgap_alloc_flipbuf(struct board_t *brd) -{ /* - * allocate flip buffer for board. + * Output the printer ON string, if we are in terminal mode, but + * need to be in printer mode. */ - brd->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); - if (!brd->flipbuf) - return -ENOMEM; - - brd->flipflagbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); - if (!brd->flipflagbuf) { - kfree(brd->flipbuf); - return -ENOMEM; + 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; } - return 0; -} + /* + * 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; + } -static void dgap_free_flipbuf(struct board_t *brd) -{ - kfree(brd->flipbuf); - kfree(brd->flipflagbuf); -} + n = count; -/* - * Create pr and tty device entries - */ -static int dgap_tty_register_ports(struct board_t *brd) -{ - struct channel_t *ch; - int i; - int ret; + /* + * 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; - brd->serial_ports = kcalloc(brd->nasync, sizeof(*brd->serial_ports), - GFP_KERNEL); - if (!brd->serial_ports) - return -ENOMEM; + if (n >= remain) { + n -= remain; + vaddr = ch->ch_taddr + head; - brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), - GFP_KERNEL); - if (!brd->printer_ports) { - ret = -ENOMEM; - goto free_serial_ports; - } + memcpy_toio(vaddr, (u8 *) buf, remain); - for (i = 0; i < brd->nasync; i++) { - tty_port_init(&brd->serial_ports[i]); - tty_port_init(&brd->printer_ports[i]); + head = ch->ch_tstart; + buf += remain; } - ch = brd->channels[0]; - for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { - - struct device *classp; - - classp = tty_port_register_device(&brd->serial_ports[i], - brd->serial_driver, - i, NULL); - - if (IS_ERR(classp)) { - ret = PTR_ERR(classp); - goto unregister_ttys; - } + if (n > 0) { - dgap_create_tty_sysfs(&ch->ch_tun, classp); - ch->ch_tun.un_sysfs = classp; + /* + * Move rest of data. + */ + vaddr = ch->ch_taddr + head; + remain = n; - classp = tty_port_register_device(&brd->printer_ports[i], - brd->print_driver, - i, NULL); + memcpy_toio(vaddr, (u8 *) buf, remain); + head += remain; - if (IS_ERR(classp)) { - ret = PTR_ERR(classp); - goto unregister_ttys; - } + } - dgap_create_tty_sysfs(&ch->ch_pun, classp); - ch->ch_pun.un_sysfs = classp; + if (count) { + ch->ch_txcount += count; + head &= tmask; + writew(head, &(bs->tx_head)); } - dgap_create_ports_sysfiles(brd); - return 0; + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); -unregister_ttys: - while (i >= 0) { - ch = brd->channels[i]; - if (ch->ch_tun.un_sysfs) { - dgap_remove_tty_sysfs(ch->ch_tun.un_sysfs); - tty_unregister_device(brd->serial_driver, i); - } + /* + * 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 (ch->ch_pun.un_sysfs) { - dgap_remove_tty_sysfs(ch->ch_pun.un_sysfs); - tty_unregister_device(brd->print_driver, i); + 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; } - i--; } - for (i = 0; i < brd->nasync; i++) { - tty_port_destroy(&brd->serial_ports[i]); - tty_port_destroy(&brd->printer_ports[i]); + /* 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; } - kfree(brd->printer_ports); - brd->printer_ports = NULL; - -free_serial_ports: - kfree(brd->serial_ports); - brd->serial_ports = NULL; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - return ret; + return count; } /* - * Copies the BIOS code from the user to the board, - * and starts the BIOS running. + * dgap_tty_put_char() + * + * Put a character into ch->ch_buf + * + * - used by the line discipline for OPOST processing */ -static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) +static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c) { - u8 __iomem *addr; - uint offset; - unsigned int i; - - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; - - addr = brd->re_map_membase; - - /* - * clear POST area - */ - for (i = 0; i < 16; i++) - writeb(0, addr + POSTAREA + i); - /* - * Download bios + * Simply call tty_write. */ - offset = 0x1000; - 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); + dgap_tty_write(tty, &c, 1); + return 1; } /* - * Checks to see if the BIOS completed running on the card. + * Return modem signals to ld. */ -static int dgap_test_bios(struct board_t *brd) +static int dgap_tty_tiocmget(struct tty_struct *tty) { - u8 __iomem *addr; - u16 word; - u16 err1; - u16 err2; + struct channel_t *ch; + struct un_t *un; + int result; + u8 mstat; + ulong lock_flags; - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return -EINVAL; + if (!tty || tty->magic != TTY_MAGIC) + return -EIO; - addr = brd->re_map_membase; - word = readw(addr + POSTAREA); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return -EIO; - /* - * 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") - return 0; - msleep_interruptible(10); - brd->wait_for_bios++; - word = readw(addr + POSTAREA); - } + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return -EIO; - /* Gave up on board after too long of time taken */ - err1 = readw(addr + SEQUENCE); - err2 = readw(addr + ERROR); - dev_warn(&brd->pdev->dev, "%s failed diagnostics. Error #(%x,%x).\n", - brd->name, err1, err2); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOBIOS; + spin_lock_irqsave(&ch->ch_lock, lock_flags); + + mstat = readb(&(ch->ch_bs->m_stat)); + /* Append any outbound signals that might be pending... */ + mstat |= ch->ch_mostat; + + spin_unlock_irqrestore(&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; - return -EIO; + return result; } /* - * Copies the FEP code from the user to the board, - * and starts the FEP running. + * dgap_tty_tiocmset() + * + * Set modem signals, called by ld. */ -static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) +static int dgap_tty_tiocmset(struct tty_struct *tty, + unsigned int set, unsigned int clear) { - u8 __iomem *addr; - uint offset; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; + if (!tty || tty->magic != TTY_MAGIC) + return -EIO; - addr = brd->re_map_membase; + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return -EIO; - /* - * Download FEP - */ - offset = 0x1000; - memcpy_toio(addr + offset, ufep, len); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return -EIO; - /* - * 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)) { - u8 string[100]; - u8 __iomem *config; - u8 *xconfig; - unsigned int i = 0; + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return -EIO; - xconfig = dgap_create_config_string(brd, string); + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - /* Write string to board memory */ - config = addr + CONFIG; - for (; i < CONFIGSIZE; i++, config++, xconfig++) { - writeb(*xconfig, config); - if ((*xconfig & 0xff) == 0xff) - break; - } + if (set & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval |= D_RTS(ch); } - writel(0xbfc01004, (addr + 0xc34)); - writel(0x3, (addr + 0xc30)); + 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(ch, bd, un->un_type); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return 0; } /* - * Waits for the FEP to report thats its ready for us to use. + * dgap_tty_send_break() + * + * Send a Break, called by ld. */ -static int dgap_test_fep(struct board_t *brd) +static int dgap_tty_send_break(struct tty_struct *tty, int msec) { - u8 __iomem *addr; - u16 word; - u16 err1; - u16 err2; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return -EINVAL; + if (!tty || tty->magic != TTY_MAGIC) + return -EIO; - addr = brd->re_map_membase; - word = readw(addr + FEPSTAT); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return -EIO; - /* - * 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") { - /* - * Check to see if the board can support FEP5+ commands. - */ - word = readw(addr + FEP5_PLUS); - if (word == *(u16 *) "5A") - brd->bd_flags |= BD_FEP5PLUS; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return -EIO; - return 0; - } - msleep_interruptible(10); - brd->wait_for_fep++; - word = readw(addr + FEPSTAT); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return -EIO; + + switch (msec) { + case -1: + msec = 0xFFFF; + break; + case 0: + msec = 1; + break; + default: + msec /= 10; + break; } - /* Gave up on board after too long of time taken */ - err1 = readw(addr + SEQUENCE); - err2 = readw(addr + ERROR); - dev_warn(&brd->pdev->dev, - "FEPOS for %s not functioning. Error #(%x,%x).\n", - brd->name, err1, err2); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); +#if 0 + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); +#endif + dgap_cmdw(ch, SBREAK, (u16) msec, 0); - return -EIO; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return 0; } /* - * Physically forces the FEP5 card to reset itself. + * dgap_tty_wait_until_sent() + * + * wait until data has been transmitted, called by ld. */ -static void dgap_do_reset_board(struct board_t *brd) +static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout) { - u8 check; - u32 check1; - u32 check2; - unsigned int i; + dgap_wait_for_drain(tty); +} - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || - !brd->re_map_membase || !brd->re_map_port) +/* + * 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; - /* FEPRST does not vary among supported boards */ - writeb(FEPRST, brd->re_map_port); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; - for (i = 0; i <= 1000; i++) { - check = readb(brd->re_map_port) & 0xe; - if (check == FEPRST) - break; - udelay(10); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - } - if (i > 1000) { - dev_warn(&brd->pdev->dev, - "dgap: Board not resetting... Failing board.\n"); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) return; - } + + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); /* - * Make sure there really is memory out there. + * 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... */ - 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 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 - if ((check1 != 0xa55a3cc3) || (check2 != 0x5aa5c33c)) { - dev_warn(&brd->pdev->dev, - "No memory at %p for board.\n", - brd->re_map_membase); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOFEP; - return; - } + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); } -#ifdef DIGI_CONCENTRATORS_SUPPORTED /* - * Sends a concentrator image into the FEP5 board. + * Return modem signals to ld. */ -static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len) +static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) { - char __iomem *vaddr; - u16 offset; - struct downld_t *to_dp; + int result; + u8 mstat; + ulong lock_flags; + int rc; - if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return; + spin_lock_irqsave(&ch->ch_lock, lock_flags); - vaddr = brd->re_map_membase; + mstat = readb(&(ch->ch_bs->m_stat)); + /* Append any outbound signals that might be pending... */ + mstat |= ch->ch_mostat; - offset = readw((u16 *) (vaddr + DOWNREQ)); - to_dp = (struct downld_t *) (vaddr + (int) offset); - memcpy_toio(to_dp, uaddr, len); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - /* Tell card we have data for it */ - writew(0, vaddr + (DOWNREQ)); + result = 0; - brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; -} -#endif + 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; -#define EXPANSION_ROM_SIZE (64 * 1024) -#define FEP5_ROM_MAGIC (0xFEFFFFFF) + rc = put_user(result, value); -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; - u8 byte1; - u8 byte2; + return rc; +} - /* - * 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); +/* + * dgap_set_modem_info() + * + * Set modem signals, called by ld. + */ +static int dgap_set_modem_info(struct channel_t *ch, struct board_t *bd, + struct un_t *un, unsigned int command, + unsigned int __user *value) +{ + int ret; + unsigned int arg; + ulong lock_flags; + ulong lock_flags2; - /* VPD not supported, bail */ - if (!magic) - return; + ret = get_user(arg, value); + if (ret) + return ret; - /* - * 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); + switch (command) { + case TIOCMBIS: + if (arg & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval |= D_RTS(ch); + } - byte1 = readb(brd->re_map_membase); - byte2 = readb(brd->re_map_membase + 1); + if (arg & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval |= D_DTR(ch); + } - /* - * If the board correctly swapped to the OTPROM memory, - * the first 2 bytes (header) should be 0x55, 0xAA - */ - if (byte1 == 0x55 && byte2 == 0xAA) { + break; - base_offset = 0; + case TIOCMBIC: + if (arg & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval &= ~(D_RTS(ch)); + } - /* - * We have to run through all the OTPROM memory looking - * for the VPD offset. - */ - while (base_offset <= EXPANSION_ROM_SIZE) { + if (arg & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval &= ~(D_DTR(ch)); + } - /* - * 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); + break; - /* Found the VPD entry */ - if (vpd_offset) - break; + case TIOCMSET: + ch->ch_mforce = D_DTR(ch)|D_RTS(ch); - /* We didn't find a VPD entry, go to next ROM entry. */ - base_offset += image_length; + if (arg & TIOCM_RTS) + ch->ch_mval |= D_RTS(ch); + else + ch->ch_mval &= ~(D_RTS(ch)); - byte1 = readb(brd->re_map_membase + base_offset); - byte2 = readb(brd->re_map_membase + base_offset + 1); + if (arg & TIOCM_DTR) + ch->ch_mval |= (D_DTR(ch)); + else + ch->ch_mval &= ~(D_DTR(ch)); - /* - * 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; - } + 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); - } - } + default: + return -EINVAL; } - /* - * 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); + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); + + dgap_param(ch, bd, un->un_type); + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return 0; } /* - * Our board poller function. + * dgap_tty_digigeta() + * + * Ioctl to get the information for ditty. + * + * + * */ -static void dgap_poll_tasklet(unsigned long data) +static int dgap_tty_digigeta(struct channel_t *ch, + struct digi_t __user *retinfo) { - struct board_t *bd = (struct board_t *) data; + struct digi_t tmp; ulong lock_flags; - char __iomem *vaddr; - u16 head, tail; - if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) - return; + if (!retinfo) + return -EFAULT; - if (bd->inhibit_poller) - return; + memset(&tmp, 0, sizeof(tmp)); - spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags); + memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - vaddr = bd->re_map_membase; + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return -EFAULT; - /* - * If board is ready, parse deeper to see if there is anything to do. - */ - if (bd->state == BOARD_READY) { + return 0; +} - struct ev_t __iomem *eaddr; +/* + * dgap_tty_digiseta() + * + * Ioctl to set the information for ditty. + * + * + * + */ +static int dgap_tty_digiseta(struct channel_t *ch, struct board_t *bd, + struct un_t *un, struct digi_t __user *new_info) +{ + struct digi_t new_digi; + ulong lock_flags = 0; + unsigned long lock_flags2; - if (!bd->re_map_membase) { - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return; - } - if (!bd->re_map_port) { - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return; - } + if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) + return -EFAULT; + + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - if (!bd->nasync) - goto out; + memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t)); - eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); + if (ch->ch_digi.digi_maxcps < 1) + ch->ch_digi.digi_maxcps = 1; - /* Get our head and tail */ - head = readw(&(eaddr->ev_head)); - tail = readw(&(eaddr->ev_tail)); + if (ch->ch_digi.digi_maxcps > 10000) + ch->ch_digi.digi_maxcps = 10000; - /* - * If there is an event pending. Go service it. - */ - if (head != tail) { - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - dgap_event(bd); - spin_lock_irqsave(&bd->bd_lock, lock_flags); - } + if (ch->ch_digi.digi_bufsize < 10) + ch->ch_digi.digi_bufsize = 10; -out: - /* - * If board is doing interrupts, ACK the interrupt. - */ - if (bd && bd->intr_running) - readb(bd->re_map_port + 2); + if (ch->ch_digi.digi_maxchar < 1) + ch->ch_digi.digi_maxchar = 1; - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return; - } + 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(ch, bd, un->un_type); + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return 0; } -/*======================================================================= +/* + * dgap_tty_digigetedelay() * - * dgap_cmdb - Sends a 2 byte command to the FEP. + * Ioctl to get the current edelay setting. * - * 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. * - *=======================================================================*/ -static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, - u8 byte2, uint ncmds) + * + */ +static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo) { - char __iomem *vaddr; - struct __iomem cm_t *cm_addr; - uint count; - uint n; - u16 head; - u16 tail; + struct channel_t *ch; + struct un_t *un; + int tmp; + ulong lock_flags; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + if (!retinfo) + return -EFAULT; - /* - * Check if board is still alive. - */ - if (ch->ch_bd->state == BOARD_FAILED) - return; + if (!tty || tty->magic != TTY_MAGIC) + return -EFAULT; - /* - * Make sure the pointers are in range before - * writing to the FEP memory. - */ - vaddr = ch->ch_bd->re_map_membase; + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return -EFAULT; - if (!vaddr) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return -EFAULT; - cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); - head = readw(&(cm_addr->cm_head)); + memset(&tmp, 0, sizeof(tmp)); - /* - * Forget it if pointers out of range. - */ - if (head >= (CMDMAX - CMDSTART) || (head & 03)) { - ch->ch_bd->state = BOARD_FAILED; - return; - } + spin_lock_irqsave(&ch->ch_lock, lock_flags); + tmp = readw(&(ch->ch_bs->edelay)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - /* - * Put the data in the circular command buffer. - */ - writeb(cmd, (vaddr + head + CMDSTART + 0)); - writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); - writeb(byte1, (vaddr + head + CMDSTART + 2)); - writeb(byte2, (vaddr + head + CMDSTART + 3)); + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return -EFAULT; - head = (head + 4) & (CMDMAX - CMDSTART - 4); + return 0; +} - writew(head, &(cm_addr->cm_head)); +/* + * dgap_tty_digisetedelay() + * + * Ioctl to set the EDELAY setting + * + */ +static int dgap_tty_digisetedelay(struct channel_t *ch, struct board_t *bd, + struct un_t *un, int __user *new_info) +{ + int new_digi; + ulong lock_flags; + ulong lock_flags2; - /* - * 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 ;;) { + if (copy_from_user(&new_digi, new_info, sizeof(int))) + return -EFAULT; - head = readw(&(cm_addr->cm_head)); - tail = readw(&(cm_addr->cm_tail)); + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - n = (head - tail) & (CMDMAX - CMDSTART - 4); + writew((u16) new_digi, &(ch->ch_bs->edelay)); - if (n <= ncmds * sizeof(struct cm_t)) - break; + dgap_param(ch, bd, un->un_type); - if (--count == 0) { - ch->ch_bd->state = BOARD_FAILED; - return; - } - udelay(10); - } + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return 0; } -/*======================================================================= - * - * dgap_cmdw - Sends a 1 word command to the FEP. +/* + * dgap_tty_digigetcustombaud() * - * 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. + * Ioctl to get the current custom baud rate setting. + */ +static int dgap_tty_digigetcustombaud(struct channel_t *ch, struct un_t *un, + int __user *retinfo) +{ + int tmp; + ulong lock_flags; + + if (!retinfo) + return -EFAULT; + + memset(&tmp, 0, sizeof(tmp)); + + spin_lock_irqsave(&ch->ch_lock, lock_flags); + tmp = dgap_get_custom_baud(ch); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return -EFAULT; + + return 0; +} + +/* + * dgap_tty_digisetcustombaud() * - *=======================================================================*/ -static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) + * Ioctl to set the custom baud rate setting + */ +static int dgap_tty_digisetcustombaud(struct channel_t *ch, struct board_t *bd, + struct un_t *un, int __user *new_info) { - char __iomem *vaddr; - struct __iomem cm_t *cm_addr; - uint count; - uint n; - u16 head; - u16 tail; + uint new_rate; + ulong lock_flags; + ulong lock_flags2; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + if (copy_from_user(&new_rate, new_info, sizeof(unsigned int))) + return -EFAULT; - /* - * Check if board is still alive. - */ - if (ch->ch_bd->state == BOARD_FAILED) - return; + if (bd->bd_flags & BD_FEP5PLUS) { - /* - * Make sure the pointers are in range before - * writing to the FEP memory. - */ - vaddr = ch->ch_bd->re_map_membase; - if (!vaddr) - return; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); - head = readw(&(cm_addr->cm_head)); + ch->ch_custom_speed = new_rate; - /* - * Forget it if pointers out of range. - */ - if (head >= (CMDMAX - CMDSTART) || (head & 03)) { - ch->ch_bd->state = BOARD_FAILED; - return; + dgap_param(ch, bd, un->un_type); + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); } - /* - * Put the data in the circular command buffer. - */ - writeb(cmd, (vaddr + head + CMDSTART + 0)); - writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); - writew((u16) word, (vaddr + head + CMDSTART + 2)); + 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; - head = (head + 4) & (CMDMAX - CMDSTART - 4); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; - writew(head, &(cm_addr->cm_head)); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - /* - * 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 ;;) { + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; - head = readw(&(cm_addr->cm_head)); - tail = readw(&(cm_addr->cm_tail)); + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - n = (head - tail) & (CMDMAX - CMDSTART - 4); + 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]; - if (n <= ncmds * sizeof(struct cm_t)) - break; + dgap_carrier(ch); + dgap_param(ch, bd, un->un_type); - if (--count == 0) { - ch->ch_bd->state = BOARD_FAILED; - return; - } - udelay(10); - } + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); } -/*======================================================================= - * - * 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) +static void dgap_tty_throttle(struct tty_struct *tty) { - char __iomem *vaddr; - struct __iomem cm_t *cm_addr; - uint count; - uint n; - u16 head; - u16 tail; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + if (!tty || tty->magic != TTY_MAGIC) return; - /* - * Check if board is still alive. - */ - if (ch->ch_bd->state == BOARD_FAILED) + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) return; - /* - * Make sure the pointers are in range before - * writing to the FEP memory. - */ - vaddr = ch->ch_bd->re_map_membase; - if (!vaddr) + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; - cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); - head = readw(&(cm_addr->cm_head)); - - /* - * Forget it if pointers out of range. - */ - if (head >= (CMDMAX - CMDSTART) || (head & 03)) { - ch->ch_bd->state = BOARD_FAILED; + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) return; - } - /* - * Put the data in the circular command buffer. - */ + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - /* Write an FF to tell the FEP that we want an extended command */ - writeb((u8) 0xff, (vaddr + head + CMDSTART + 0)); + ch->ch_flags |= (CH_RXBLOCK); +#if 1 + dgap_cmdw(ch, RPAUSE, 0, 0); +#endif - writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); - writew((u16) cmd, (vaddr + head + CMDSTART + 2)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - /* - * 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, (vaddr + CMDSTART)); - else - writew((u16) word, (vaddr + head + CMDSTART + 4)); +} - head = (head + 8) & (CMDMAX - CMDSTART - 4); +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; - writew(head, &(cm_addr->cm_head)); + if (!tty || tty->magic != TTY_MAGIC) + return; - /* - * 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 ;;) { + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; - head = readw(&(cm_addr->cm_head)); - tail = readw(&(cm_addr->cm_tail)); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - n = (head - tail) & (CMDMAX - CMDSTART - 4); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; - if (n <= ncmds * sizeof(struct cm_t)) - break; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - if (--count == 0) { - ch->ch_bd->state = BOARD_FAILED; - return; - } - udelay(10); - } + ch->ch_flags &= ~(CH_RXBLOCK); + +#if 1 + dgap_cmdw(ch, RRESUME, 0, 0); +#endif + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); } -/*======================================================================= +/************************************************************************ * - * dgap_wmove - Write data to FEP buffer. + * TTY Entry points and helper functions * - * ch - Pointer to channel structure. - * buf - Poiter to characters to be moved. - * cnt - Number of characters to move. + ************************************************************************/ + +/* + * dgap_tty_open() * - *=======================================================================*/ -static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) + */ +static int dgap_tty_open(struct tty_struct *tty, struct file *file) { - int n; - char __iomem *taddr; + struct board_t *brd; + struct channel_t *ch; + struct un_t *un; struct bs_t __iomem *bs; + uint major; + uint minor; + int rc; + ulong lock_flags; + ulong lock_flags2; u16 head; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return; + major = MAJOR(tty_devnum(tty)); + minor = MINOR(tty_devnum(tty)); + + if (major > 255) + return -EIO; + + /* Get board pointer from our array of majors we have allocated */ + brd = dgap_boards_by_major[major]; + if (!brd) + return -EIO; /* - * Check parameters. + * If board is not yet up to a state of READY, go to + * sleep waiting for it to happen or they cancel the open. */ - bs = ch->ch_bs; - head = readw(&(bs->tx_head)); + rc = wait_event_interruptible(brd->state_wait, + (brd->state & BOARD_READY)); + + if (rc) + return rc; + + spin_lock_irqsave(&brd->bd_lock, lock_flags); + + /* The wait above should guarantee this cannot happen */ + if (brd->state != BOARD_READY) { + spin_unlock_irqrestore(&brd->bd_lock, lock_flags); + return -EIO; + } + + /* If opened device is greater than our number of ports, bail. */ + if (MINOR(tty_devnum(tty)) > brd->nasync) { + spin_unlock_irqrestore(&brd->bd_lock, lock_flags); + return -EIO; + } + + ch = brd->channels[minor]; + if (!ch) { + spin_unlock_irqrestore(&brd->bd_lock, lock_flags); + return -EIO; + } + + /* Grab channel lock */ + spin_lock_irqsave(&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_transparent_print_major) { + un = &brd->channels[minor]->ch_pun; + un->un_type = DGAP_PRINT; + } else { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&brd->bd_lock, lock_flags); + return -EIO; + } + + /* Store our unit into driver_data, so we always have it available. */ + tty->driver_data = un; /* - * If pointers are out of range, just return. + * Error if channel info pointer is NULL. */ - if ((cnt > ch->ch_tsize) || - (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize) - return; + bs = ch->ch_bs; + if (!bs) { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&brd->bd_lock, lock_flags); + return -EIO; + } /* - * 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. + * Initialize tty's */ - n = ch->ch_tstart + ch->ch_tsize - head; + if (!(un->un_flags & UN_ISOPEN)) { + /* Store important variables. */ + un->un_tty = tty; - if (cnt >= n) { - cnt -= n; - taddr = ch->ch_taddr + head; - memcpy_toio(taddr, buf, n); - head = ch->ch_tstart; - buf += n; + /* Maybe do something here to the TTY struct as well? */ } /* - * Move rest of data. + * Initialize if neither terminal or printer is open. */ - taddr = ch->ch_taddr + head; - n = cnt; - memcpy_toio(taddr, buf, n); - head += cnt; - - writew(head, &(bs->tx_head)); -} + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { -/* - * Retrives the current custom baud rate from FEP memory, - * and returns it back to the user. - * Returns 0 on error. - */ -static uint dgap_get_custom_baud(struct channel_t *ch) -{ - u8 __iomem *vaddr; - ulong offset; - uint value; + ch->ch_mforce = 0; + ch->ch_mval = 0; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return 0; + /* + * Flush input queue. + */ + head = readw(&(bs->rx_head)); + writew(head, &(bs->rx_tail)); - if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC) - return 0; + ch->ch_flags = 0; + ch->pscan_state = 0; + ch->pscan_savechar = 0; - if (!(ch->ch_bd->bd_flags & BD_FEP5PLUS)) - return 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]; - vaddr = ch->ch_bd->re_map_membase; + /* TODO: flush our TTY struct here? */ + } - if (!vaddr) - return 0; + dgap_carrier(ch); + /* + * Run param in case we changed anything + */ + dgap_param(ch, brd, un->un_type); /* - * Go get from fep mem, what the fep - * believes the custom baud rate is. + * follow protocol for opening port */ - offset = (ioread16(vaddr + ECS_SEG) << 4) + (ch->ch_portnum * 0x28) - + LINE_SPEED; - value = readw(vaddr + offset); - return value; -} + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&brd->bd_lock, lock_flags); -/* - * Calls the firmware to reset this channel. - */ -static void dgap_firmware_reset_port(struct channel_t *ch) -{ - dgap_cmdb(ch, CHRESET, 0, 0, 0); + rc = dgap_block_til_ready(tty, file, ch); - /* - * 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; + if (!un->un_tty) + return -ENODEV; + + /* No going back now, increment our unit and channel counters */ + spin_lock_irqsave(&ch->ch_lock, lock_flags); + ch->ch_open_count++; + un->un_open_count++; + un->un_flags |= (UN_ISOPEN); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + + return rc; } -/*======================================================================= - * - * dgap_param - Set Digi parameters. - * - * struct tty_struct * - TTY for port. +/* + * dgap_tty_close() * - *=======================================================================*/ -static int dgap_param(struct channel_t *ch, struct board_t *bd, u32 un_type) + */ +static void dgap_tty_close(struct tty_struct *tty, struct file *file) { - u16 head; - u16 cflag; - u16 iflag; - u8 mval; - u8 hflow; - - /* - * If baud rate is zero, flush queues, and set mval to drop DTR. - */ - if ((ch->ch_c_cflag & (CBAUD)) == 0) { + struct ktermios *ts; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; - /* flush rx */ - head = readw(&(ch->ch_bs->rx_head)); - writew(head, &(ch->ch_bs->rx_tail)); + if (!tty || tty->magic != TTY_MAGIC) + return; - /* flush tx */ - head = readw(&(ch->ch_bs->tx_head)); - writew(head, &(ch->ch_bs->tx_tail)); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; - ch->ch_flags |= (CH_BAUD0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - /* 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; + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; - } else if (ch->ch_custom_speed && (bd->bd_flags & BD_FEP5PLUS)) { - /* - * Tell the fep to do the command - */ + ts = &tty->termios; - dgap_cmdw_ext(ch, 0xff01, ch->ch_custom_speed, 0); + spin_lock_irqsave(&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)) { /* - * Now go get from fep mem, what the fep - * believes the custom baud rate is. + * 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. */ - ch->ch_custom_speed = dgap_get_custom_baud(ch); - ch->ch_baud_info = ch->ch_custom_speed; + un->un_open_count = 1; + } - /* 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); + if (--un->un_open_count < 0) + un->un_open_count = 0; - } else { - /* - * Set baud rate, character size, and parity. - */ + ch->ch_open_count--; + if (ch->ch_open_count && un->un_open_count) { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); + return; + } - int iindex = 0; - int jindex = 0; - int baud = 0; + /* OK, its the last close on the unit */ - 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 } - }; + un->un_flags |= UN_CLOSING; - /* - * Only use the TXPrint baud rate if the - * terminal unit is NOT open - */ - if (!(ch->ch_tun.un_flags & UN_ISOPEN) && - un_type == DGAP_PRINT) - baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; - else - baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; + 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)) { - if (ch->ch_c_cflag & CBAUDEX) - iindex = 1; + ch->ch_flags &= ~(CH_RXBLOCK); - if (ch->ch_digi.digi_flags & DIGI_FAST) - iindex += 2; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - jindex = baud; + /* wait for output to drain */ + /* This will also return if we take an interrupt */ - if ((iindex >= 0) && (iindex < 4) && - (jindex >= 0) && (jindex < 16)) - baud = bauds[iindex][jindex]; - else - baud = 0; + dgap_wait_for_drain(tty); - if (baud == 0) - baud = 9600; + dgap_tty_flush_buffer(tty); + tty_ldisc_flush(tty); - ch->ch_baud_info = baud; + spin_lock_irqsave(&ch->ch_lock, lock_flags); - /* - * 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); + tty->closing = 0; /* - * HUPCL bit is used by FEP to indicate fast baud - * table is to be used. + * If we have HUPCL set, lower DTR and RTS */ - if ((ch->ch_digi.digi_flags & DIGI_FAST) || - (ch->ch_c_cflag & CBAUDEX)) - cflag |= HUPCL; + if (ch->ch_c_cflag & HUPCL) { + ch->ch_mostat &= ~(D_RTS(ch)|D_DTR(ch)); + dgap_cmdb(ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0); - 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. + * Go to sleep to ensure RTS/DTR + * have been dropped for modems to see it. */ - tcflag_t tcflag = (ch->ch_c_cflag & CBAUD) | CBAUDEX; - int baudpart = 0; + spin_unlock_irqrestore(&ch->ch_lock, + lock_flags); - /* - * 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; - } + /* .25 second delay for dropping RTS/DTR */ + schedule_timeout_interruptible(msecs_to_jiffies(250)); - if (baudpart) - cflag = (cflag & ~(CBAUD | CBAUDEX)) | baudpart; + spin_lock_irqsave(&ch->ch_lock, lock_flags); } - 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); - } + ch->pscan_state = 0; + ch->pscan_savechar = 0; + ch->ch_baud_info = 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. + * turn off print device when closing print device. */ - 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); + 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; } - /* - * Only the IBM Xr card can switch between - * 232 and 422 modes on the fly - */ - if (bd->device == PCI_DEV_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); - } + un->un_tty = NULL; + un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); + tty->driver_data = NULL; - if (ch->ch_digi.digi_flags & DIGI_ALTPIN) - iflag |= IALTPIN; + wake_up_interruptible(&ch->ch_flags_wait); + wake_up_interruptible(&un->un_flags_wait); - if (iflag != ch->ch_fepiflag) { - ch->ch_fepiflag = iflag; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags); +} - /* Okay to have channel and board locks held calling this */ - dgap_cmdw(ch, SIFLAG, (u16) ch->ch_fepiflag, 0); - } +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; - /* - * Select hardware handshaking. - */ - hflow = 0; + if (!tty || tty->magic != TTY_MAGIC) + return; - 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); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; - if (hflow != ch->ch_hflow) { - ch->ch_hflow = hflow; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0); - } + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; - /* - * Set RTS and/or DTR Toggle if needed, - * but only if product is FEP5+ based. - */ - if (bd->bd_flags & BD_FEP5PLUS) { - u16 hflow2 = 0; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - 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(ch, RESUMETX, 0, 0); - dgap_cmdw_ext(ch, 0xff03, hflow2, 0); - } + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); +} - /* - * Set modem control lines. - */ +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; - mval ^= ch->ch_mforce & (mval ^ ch->ch_mval); + if (!tty || tty->magic != TTY_MAGIC) + return; - if (ch->ch_mostat ^ mval) { - ch->ch_mostat = mval; + 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; + + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, PAUSETX, 0, 0); + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); +} + +/* + * 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; - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SMODEM, (u8) mval, D_RTS(ch)|D_DTR(ch), 0); - } + if (!tty || tty->magic != TTY_MAGIC) + return; - /* - * Read modem signals, and then call carrier function. - */ - ch->ch_mistat = readb(&(ch->ch_bs->m_stat)); - dgap_carrier(ch); + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; - /* - * 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; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SFLOWC, ch->ch_fepstartc, ch->ch_fepstopc, 0); - } + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; - /* - * 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; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SAFLOWC, ch->ch_fepastartc, ch->ch_fepastopc, 0); - } + /* TODO: Do something here */ - return 0; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); } +/***************************************************************************** + * + * The IOCTL function and all of its helpers + * + *****************************************************************************/ + /* - * dgap_parity_scan() + * dgap_tty_ioctl() * - * Convert the FEP5 way of reporting parity errors and breaks into - * the Linux line discipline way. + * The usual assortment of ioctl's */ -static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, - unsigned char *fbuf, int *len) +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, + unsigned long arg) { - int l = *len; - int count = 0; - unsigned char *in, *cout, *fout; - unsigned char c; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int rc; + u16 head; + ulong lock_flags = 0; + ulong lock_flags2 = 0; + void __user *uarg = (void __user *) arg; - in = cbuf; - cout = cbuf; - fout = fbuf; + 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; + return -ENODEV; - while (l--) { - c = *in++; - switch (ch->pscan_state) { - default: - /* reset to sanity and fall through */ - ch->pscan_state = 0; + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return -ENODEV; - 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; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - 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; + if (un->un_open_count <= 0) { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return -EIO; + } - case 2: - /* third character of ff sequence */ + switch (cmd) { - *cout++ = c; + /* Here are all the standard ioctl's that we MUST implement */ - if (ch->pscan_savechar == 0x0) { + 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); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (rc) + return rc; - if (c == 0x0) { - ch->ch_err_break++; - *fout++ = TTY_BREAK; - } else { - ch->ch_err_parity++; - *fout++ = TTY_PARITY; - } - } + rc = dgap_wait_for_drain(tty); - count += 1; - ch->pscan_state = 0; - } - } - *len = count; -} + if (rc) + return -EINTR; -static void dgap_write_wakeup(struct board_t *bd, struct channel_t *ch, - struct un_t *un, u32 mask, - unsigned long *irq_flags1, - unsigned long *irq_flags2) -{ - if (!(un->un_flags & mask)) - return; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - un->un_flags &= ~mask; + if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); - if (!(un->un_flags & UN_ISOPEN)) - return; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if ((un->un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - un->un_tty->ldisc->ops->write_wakeup) { - spin_unlock_irqrestore(&ch->ch_lock, *irq_flags2); - spin_unlock_irqrestore(&bd->bd_lock, *irq_flags1); + return 0; - (un->un_tty->ldisc->ops->write_wakeup)(un->un_tty); + case TCSBRKP: + /* support for POSIX tcsendbreak() - spin_lock_irqsave(&bd->bd_lock, *irq_flags1); - spin_lock_irqsave(&ch->ch_lock, *irq_flags2); - } - wake_up_interruptible(&un->un_tty->write_wait); - wake_up_interruptible(&un->un_flags_wait); -} + * 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); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (rc) + return rc; -/*======================================================================= - * - * 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 __iomem *bs; - u8 __iomem *event; - u8 __iomem *vaddr; - struct ev_t __iomem *eaddr; - uint head; - uint tail; - int port; - int reason; - int modem; - int b1; + rc = dgap_wait_for_drain(tty); + if (rc) + return -EINTR; + + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + 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); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + if (rc) + return rc; + + rc = dgap_wait_for_drain(tty); + if (rc) + return -EINTR; - if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -EIO; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); - spin_lock_irqsave(&bd->bd_lock, lock_flags); + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); - vaddr = bd->re_map_membase; + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if (!vaddr) { + 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. + */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return -EIO; - } + return 0; - eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); + case TIOCGSOFTCAR: - /* Get our head and tail */ - head = readw(&(eaddr->ev_head)); - tail = readw(&(eaddr->ev_tail)); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - /* - * Forget it if pointers out of range. - */ + rc = put_user(C_CLOCAL(tty) ? 1 : 0, + (unsigned long __user *) arg); + return rc; - if (head >= EVMAX - EVSTART || tail >= EVMAX - EVSTART || - (head | tail) & 03) { - /* Let go of board lock */ + case TIOCSSOFTCAR: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return -EIO; - } - /* - * Loop to process all the events in the buffer. - */ - while (tail != head) { + rc = get_user(arg, (unsigned long __user *) arg); + if (rc) + return rc; + + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); + tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | + (arg ? CLOCAL : 0)); + dgap_param(ch, bd, un->un_type); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return 0; + + case TIOCMGET: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_get_modem_info(ch, uarg); + + case TIOCMBIS: + case TIOCMBIC: + case TIOCMSET: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_set_modem_info(ch, bd, un, cmd, uarg); /* - * Get interrupt information. + * Here are any additional ioctl's that we want to implement */ - event = bd->re_map_membase + tail + EVSTART; + 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) { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return rc; + } - port = ioread8(event); - reason = ioread8(event + 1); - modem = ioread8(event + 2); - b1 = ioread8(event + 3); + 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)) { + /* pretend we didn't recognize this IOCTL */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + + return -ENOIOCTLCMD; + } + + 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! */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + tty_wakeup(tty); + + /* pretend we didn't recognize this IOCTL */ + return -ENOIOCTLCMD; + + case TCSETSF: + case TCSETSW: /* - * Make sure the interrupt is valid. + * 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 (port >= bd->nasync) - goto next; + if (cmd == TCSETSF) { + /* flush rx */ + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + } - if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA))) - goto next; + /* now wait for all the output to drain */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) + return -EINTR; - ch = bd->channels[port]; + /* pretend we didn't recognize this */ + return -ENOIOCTLCMD; - if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - goto next; + case TCSETAW: + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) + return -EINTR; + + /* pretend we didn't recognize this */ + return -ENOIOCTLCMD; + case TCXONC: /* - * If we have made it here, the event was valid. - * Lock down the channel. + * 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. */ - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + rc = tty_check_change(tty); + if (rc) { + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return rc; + } - bs = ch->ch_bs; + switch (arg) { - if (!bs) { + case TCOON: spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - goto next; + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + dgap_tty_start(tty); + return 0; + case TCOOFF: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + dgap_tty_stop(tty); + return 0; + case TCION: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + /* Make the ld do it */ + return -ENOIOCTLCMD; + case TCIOFF: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + /* Make the ld do it */ + return -ENOIOCTLCMD; + default: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return -EINVAL; } - /* - * Process received data. - */ - if (reason & IFDATA) { + case DIGI_GETA: + /* get information for ditty */ + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_tty_digigeta(ch, uarg); + + case DIGI_SETAW: + case DIGI_SETAF: + + /* set information for ditty */ + if (cmd == (DIGI_SETAW)) { + + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) + return -EINTR; + spin_lock_irqsave(&bd->bd_lock, lock_flags); + spin_lock_irqsave(&ch->ch_lock, lock_flags2); + } else + tty_ldisc_flush(tty); + /* fall thru */ + + case DIGI_SETA: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_tty_digiseta(ch, bd, un, uarg); + + case DIGI_GEDELAY: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_tty_digigetedelay(tty, uarg); + + case DIGI_SEDELAY: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_tty_digisetedelay(ch, bd, un, uarg); - /* - * 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. - */ - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + case DIGI_GETCUSTOMBAUD: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_tty_digigetcustombaud(ch, un, uarg); - dgap_input(ch); + case DIGI_SETCUSTOMBAUD: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return dgap_tty_digisetcustombaud(ch, bd, un, uarg); - spin_lock_irqsave(&bd->bd_lock, lock_flags); - spin_lock_irqsave(&ch->ch_lock, lock_flags2); + case DIGI_RESET_PORT: + dgap_firmware_reset_port(ch); + dgap_param(ch, bd, un->un_type); + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + return 0; - if (ch->ch_flags & CH_RACTIVE) - ch->ch_flags |= CH_RENABLE; - else - writeb(1, &(bs->idata)); + default: + spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - if (ch->ch_flags & CH_RWAIT) { - ch->ch_flags &= ~CH_RWAIT; + return -ENOIOCTLCMD; + } +} - wake_up_interruptible - (&ch->ch_tun.un_flags_wait); - } - } +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 +}; - /* - * Process Modem change signals. - */ - if (reason & IFMODEM) { - ch->ch_mistat = modem; - dgap_carrier(ch); - } +/************************************************************************ + * + * TTY Initialization/Cleanup Functions + * + ************************************************************************/ - /* - * Process break. - */ - if (reason & IFBREAK) { +/* + * dgap_tty_register() + * + * Init the tty subsystem for this board. + */ +static int dgap_tty_register(struct board_t *brd) +{ + int rc; - 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); - } - } + brd->serial_driver = tty_alloc_driver(MAXPORTS, 0); + if (IS_ERR(brd->serial_driver)) + return PTR_ERR(brd->serial_driver); - /* - * Process Transmit low. - */ - if (reason & IFTLW) { - dgap_write_wakeup(bd, ch, &ch->ch_tun, UN_LOW, - &lock_flags, &lock_flags2); - dgap_write_wakeup(bd, ch, &ch->ch_pun, UN_LOW, - &lock_flags, &lock_flags2); - if (ch->ch_flags & CH_WLOW) { - ch->ch_flags &= ~CH_WLOW; - wake_up_interruptible(&ch->ch_flags_wait); - } - } + snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgap_%d_", + brd->boardnum); + brd->serial_driver->name = brd->serial_name; + brd->serial_driver->name_base = 0; + brd->serial_driver->major = 0; + brd->serial_driver->minor_start = 0; + brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL; + brd->serial_driver->subtype = SERIAL_TYPE_NORMAL; + brd->serial_driver->init_termios = dgap_default_termios; + brd->serial_driver->driver_name = DRVSTR; + brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV | + TTY_DRIVER_HARDWARE_BREAK); - /* - * Process Transmit empty. - */ - if (reason & IFTEM) { - dgap_write_wakeup(bd, ch, &ch->ch_tun, UN_EMPTY, - &lock_flags, &lock_flags2); - dgap_write_wakeup(bd, ch, &ch->ch_pun, UN_EMPTY, - &lock_flags, &lock_flags2); - if (ch->ch_flags & CH_WEMPTY) { - ch->ch_flags &= ~CH_WEMPTY; - wake_up_interruptible(&ch->ch_flags_wait); - } - } + /* The kernel wants space to store pointers to tty_structs */ + brd->serial_driver->ttys = + kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->serial_driver->ttys) { + rc = -ENOMEM; + goto free_serial_drv; + } - spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(brd->serial_driver, &dgap_tty_ops); -next: - tail = (tail + 4) & (EVMAX - EVSTART - 4); + /* + * 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->print_driver = tty_alloc_driver(MAXPORTS, 0); + if (IS_ERR(brd->print_driver)) { + rc = PTR_ERR(brd->print_driver); + goto free_serial_drv; } - writew(tail, &(eaddr->ev_tail)); - spin_unlock_irqrestore(&bd->bd_lock, lock_flags); + snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgap_%d_", + brd->boardnum); + brd->print_driver->name = brd->print_name; + brd->print_driver->name_base = 0; + brd->print_driver->major = 0; + brd->print_driver->minor_start = 0; + brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL; + brd->print_driver->subtype = SERIAL_TYPE_NORMAL; + brd->print_driver->init_termios = dgap_default_termios; + brd->print_driver->driver_name = DRVSTR; + brd->print_driver->flags = (TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV | + TTY_DRIVER_HARDWARE_BREAK); - return 0; -} + /* The kernel wants space to store pointers to tty_structs */ + brd->print_driver->ttys = + kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->print_driver->ttys) { + rc = -ENOMEM; + goto free_print_drv; + } -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); + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(brd->print_driver, &dgap_tty_ops); + /* Register tty devices */ + rc = tty_register_driver(brd->serial_driver); + if (rc < 0) + goto free_print_drv; -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); + /* Register Transparent Print devices */ + rc = tty_register_driver(brd->print_driver); + if (rc < 0) + goto unregister_serial_drv; + dgap_boards_by_major[brd->serial_driver->major] = brd; + brd->dgap_serial_major = brd->serial_driver->major; -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); + dgap_boards_by_major[brd->print_driver->major] = brd; + brd->dgap_transparent_print_major = brd->print_driver->major; + return 0; -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); +unregister_serial_drv: + tty_unregister_driver(brd->serial_driver); +free_print_drv: + put_tty_driver(brd->print_driver); +free_serial_drv: + put_tty_driver(brd->serial_driver); -static ssize_t dgap_driver_pollrate_show(struct device_driver *ddp, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%dms\n", dgap_poll_tick); + return rc; } -static ssize_t dgap_driver_pollrate_store(struct device_driver *ddp, - const char *buf, size_t count) +static void dgap_tty_unregister(struct board_t *brd) { - if (sscanf(buf, "%d\n", &dgap_poll_tick) != 1) - return -EINVAL; - return count; + tty_unregister_driver(brd->print_driver); + tty_unregister_driver(brd->serial_driver); + put_tty_driver(brd->print_driver); + put_tty_driver(brd->serial_driver); } -static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, - dgap_driver_pollrate_store); -static int dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) -{ - int rc = 0; - struct device_driver *driverfs = &dgap_driver->driver; +static int dgap_alloc_flipbuf(struct board_t *brd) +{ + /* + * allocate flip buffer for board. + */ + brd->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); + if (!brd->flipbuf) + return -ENOMEM; - 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_pollrate); - rc |= driver_create_file(driverfs, &driver_attr_pollcounter); + brd->flipflagbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); + if (!brd->flipflagbuf) { + kfree(brd->flipbuf); + return -ENOMEM; + } - return rc; + return 0; } -static void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver) +static void dgap_free_flipbuf(struct board_t *brd) { - 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_pollrate); - driver_remove_file(driverfs, &driver_attr_pollcounter); + kfree(brd->flipbuf); + kfree(brd->flipflagbuf); } static struct board_t *dgap_verify_board(struct device *p) @@ -5843,42 +5600,227 @@ static ssize_t dgap_ports_txcount_show(struct device *p, } 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 - */ -static void dgap_create_ports_sysfiles(struct board_t *bd) +static ssize_t dgap_tty_state_show(struct device *d, + struct device_attribute *attr, + char *buf) { - dev_set_drvdata(&bd->pdev->dev, bd); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); - device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); + 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; -/* removes all the sys files created for that port */ -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); - 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); + 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_state_show(struct device *d, - struct device_attribute *attr, - char *buf) +static ssize_t dgap_tty_rxcount_show(struct device *d, + struct device_attribute *attr, + char *buf) { struct board_t *bd; struct channel_t *ch; @@ -5898,14 +5840,13 @@ static ssize_t dgap_tty_state_show(struct device *d, if (bd->state != BOARD_READY) return 0; - return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? - "Open" : "Closed"); + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); } -static DEVICE_ATTR(state, S_IRUSR, dgap_tty_state_show, NULL); +static DEVICE_ATTR(rxcount, S_IRUSR, dgap_tty_rxcount_show, NULL); -static ssize_t dgap_tty_baud_show(struct device *d, - struct device_attribute *attr, - char *buf) +static ssize_t dgap_tty_txcount_show(struct device *d, + struct device_attribute *attr, + char *buf) { struct board_t *bd; struct channel_t *ch; @@ -5925,17 +5866,24 @@ static ssize_t dgap_tty_baud_show(struct device *d, if (bd->state != BOARD_READY) return 0; - return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_baud_info); + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); } -static DEVICE_ATTR(baud, S_IRUSR, dgap_tty_baud_show, NULL); +static DEVICE_ATTR(txcount, S_IRUSR, dgap_tty_txcount_show, NULL); -static ssize_t dgap_tty_msignals_show(struct device *d, - struct device_attribute *attr, - char *buf) +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; + int found = FALSE; + int ncount = 0; + int starto = 0; + int i; if (!d) return 0; @@ -5951,324 +5899,562 @@ static ssize_t dgap_tty_msignals_show(struct device *d, 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" : ""); + 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_num_prts(bd); i++) { + if (cn != i) + continue; + + 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)) + continue; + + return snprintf(buf, PAGE_SIZE, "%s%s%02ld\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)) + continue; + + return snprintf(buf, PAGE_SIZE, "%s%s%02ld\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 0; + + 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 +}; + + +/* this function creates the sys files that will export each signal status + * to sysfs each value will be put in a separate filename + */ +static void dgap_create_ports_sysfiles(struct board_t *bd) +{ + dev_set_drvdata(&bd->pdev->dev, bd); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); +} + +/* removes all the sys files created for that port */ +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); + 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); +} + +/* + * Copies the BIOS code from the user to the board, + * and starts the BIOS running. + */ +static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) +{ + u8 __iomem *addr; + uint offset; + unsigned int i; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + + /* + * clear POST area + */ + for (i = 0; i < 16; i++) + writeb(0, addr + POSTAREA + i); + + /* + * Download bios + */ + offset = 0x1000; + 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); +} + +/* + * Checks to see if the BIOS completed running on the card. + */ +static int dgap_test_bios(struct board_t *brd) +{ + u8 __iomem *addr; + u16 word; + u16 err1; + u16 err2; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return -EINVAL; + + addr = brd->re_map_membase; + word = readw(addr + POSTAREA); + + /* + * 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") + return 0; + msleep_interruptible(10); + brd->wait_for_bios++; + word = readw(addr + POSTAREA); + } + + /* Gave up on board after too long of time taken */ + err1 = readw(addr + SEQUENCE); + err2 = readw(addr + ERROR); + dev_warn(&brd->pdev->dev, "%s failed diagnostics. Error #(%x,%x).\n", + brd->name, err1, err2); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOBIOS; + + return -EIO; } -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) +/* + * Copies the FEP code from the user to the board, + * and starts the FEP running. + */ +static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; + u8 __iomem *addr; + uint offset; - 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 (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag); -} -static DEVICE_ATTR(iflag, S_IRUSR, dgap_tty_iflag_show, NULL); + addr = brd->re_map_membase; -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; + /* + * Download FEP + */ + offset = 0x1000; + memcpy_toio(addr + offset, ufep, len); - 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 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)) { + u8 string[100]; + u8 __iomem *config; + u8 *xconfig; + unsigned int i = 0; - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag); -} -static DEVICE_ATTR(cflag, S_IRUSR, dgap_tty_cflag_show, NULL); + xconfig = dgap_create_config_string(brd, string); -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; + /* Write string to board memory */ + config = addr + CONFIG; + for (; i < CONFIGSIZE; i++, config++, xconfig++) { + writeb(*xconfig, config); + if ((*xconfig & 0xff) == 0xff) + break; + } + } - 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; + writel(0xbfc01004, (addr + 0xc34)); + writel(0x3, (addr + 0xc30)); - 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) +/* + * Waits for the FEP to report thats its ready for us to use. + */ +static int dgap_test_fep(struct board_t *brd) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; + u8 __iomem *addr; + u16 word; + u16 err1; + u16 err2; - 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 (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return -EINVAL; - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag); -} -static DEVICE_ATTR(lflag, S_IRUSR, dgap_tty_lflag_show, NULL); + addr = brd->re_map_membase; + word = readw(addr + FEPSTAT); -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; + /* + * 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") { + /* + * Check to see if the board can support FEP5+ commands. + */ + word = readw(addr + FEP5_PLUS); + if (word == *(u16 *) "5A") + brd->bd_flags |= BD_FEP5PLUS; - 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 0; + } + msleep_interruptible(10); + brd->wait_for_fep++; + word = readw(addr + FEPSTAT); + } - return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags); + /* Gave up on board after too long of time taken */ + err1 = readw(addr + SEQUENCE); + err2 = readw(addr + ERROR); + dev_warn(&brd->pdev->dev, + "FEPOS for %s not functioning. Error #(%x,%x).\n", + brd->name, err1, err2); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + + return -EIO; } -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) +/* + * Physically forces the FEP5 card to reset itself. + */ +static void dgap_do_reset_board(struct board_t *brd) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; + u8 check; + u32 check1; + u32 check2; + unsigned int i; - 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 (!brd || (brd->magic != DGAP_BOARD_MAGIC) || + !brd->re_map_membase || !brd->re_map_port) + return; - return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); + /* 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) { + dev_warn(&brd->pdev->dev, + "dgap: Board not resetting... Failing board.\n"); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return; + } + + /* + * 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)) { + dev_warn(&brd->pdev->dev, + "No memory at %p for board.\n", + brd->re_map_membase); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return; + } } -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) +#ifdef DIGI_CONCENTRATORS_SUPPORTED +/* + * Sends a concentrator image into the FEP5 board. + */ +static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; + char __iomem *vaddr; + u16 offset; + struct downld_t *to_dp; - 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 (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; - return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); + vaddr = brd->re_map_membase; + + offset = readw((u16 *) (vaddr + DOWNREQ)); + to_dp = (struct downld_t *) (vaddr + (int) offset); + 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; } -static DEVICE_ATTR(txcount, S_IRUSR, dgap_tty_txcount_show, NULL); +#endif -static ssize_t dgap_tty_name_show(struct device *d, - struct device_attribute *attr, - char *buf) +#define EXPANSION_ROM_SIZE (64 * 1024) +#define FEP5_ROM_MAGIC (0xFEFFFFFF) + +static void dgap_get_vpd(struct board_t *brd) { - struct board_t *bd; - struct channel_t *ch; - struct un_t *un; - int cn; - int bn; - struct cnode *cptr; - int found = FALSE; - int ncount = 0; - int starto = 0; - int i; + u32 magic; + u32 base_offset; + u16 rom_offset; + u16 vpd_offset; + u16 image_length; + u16 i; + u8 byte1; + u8 byte2; - 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; + /* + * 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); - bn = bd->boardnum; - cn = ch->ch_portnum; + /* VPD not supported, bail */ + if (!magic) + return; - for (cptr = bd->bd_config; cptr; cptr = cptr->next) { + /* + * 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); - 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))) { + byte1 = readb(brd->re_map_membase); + byte2 = readb(brd->re_map_membase + 1); - found = TRUE; - if (cptr->u.board.v_start) - starto = cptr->u.board.start; - else - starto = 1; - } + /* + * If the board correctly swapped to the OTPROM memory, + * the first 2 bytes (header) should be 0x55, 0xAA + */ + if (byte1 == 0x55 && byte2 == 0xAA) { - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; + base_offset = 0; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } else - ptr1 = cptr->u.ttyname; + /* + * We have to run through all the OTPROM memory looking + * for the VPD offset. + */ + while (base_offset <= EXPANSION_ROM_SIZE) { - for (i = 0; i < dgap_config_get_num_prts(bd); i++) { - if (cn != i) - continue; + /* + * 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); - return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", - (un->un_type == DGAP_PRINT) ? - "pr" : "tty", - ptr1, i + starto); + /* 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); } } + } - if (cptr->type == CNODE) { + /* + * 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); +} - for (i = 0; i < cptr->u.conc.nport; i++) { - if (cn != (i + ncount)) - continue; - return snprintf(buf, PAGE_SIZE, "%s%s%02ld\n", - (un->un_type == DGAP_PRINT) ? - "pr" : "tty", - cptr->u.conc.id, - i + (cptr->u.conc.v_start ? - cptr->u.conc.start : 1)); - } +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); - ncount += cptr->u.conc.nport; - } - if (cptr->type == MNODE) { +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); - for (i = 0; i < cptr->u.module.nport; i++) { - if (cn != (i + ncount)) - continue; - return snprintf(buf, PAGE_SIZE, "%s%s%02ld\n", - (un->un_type == DGAP_PRINT) ? - "pr" : "tty", - cptr->u.module.id, - i + (cptr->u.module.v_start ? - cptr->u.module.start : 1)); - } +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_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) +{ + if (sscanf(buf, "%d\n", &dgap_poll_tick) != 1) + return -EINVAL; + return count; +} +static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, + dgap_driver_pollrate_store); - ncount += cptr->u.module.nport; - } - } +static int dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) +{ + int rc = 0; + struct device_driver *driverfs = &dgap_driver->driver; - return snprintf(buf, PAGE_SIZE, "%s_dgap_%d_%d\n", - (un->un_type == DGAP_PRINT) ? "pr" : "tty", bn, cn); + 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_pollrate); + rc |= driver_create_file(driverfs, &driver_attr_pollcounter); + + return rc; } -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 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_pollrate); + driver_remove_file(driverfs, &driver_attr_pollcounter); +} static struct attribute_group dgap_tty_attribute_group = { .name = NULL, @@ -6292,1064 +6478,753 @@ static void dgap_remove_tty_sysfs(struct device *c) sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); } -static void dgap_cleanup_nodes(void) -{ - struct cnode *p; - - p = &dgap_head; - - while (p) { - struct cnode *tmp = p->next; - - if (p->type == NULLNODE) { - p = tmp; - continue; - } - - switch (p->type) { - case BNODE: - kfree(p->u.board.portstr); - kfree(p->u.board.addrstr); - kfree(p->u.board.pcibusstr); - kfree(p->u.board.pcislotstr); - kfree(p->u.board.method); - break; - case CNODE: - kfree(p->u.conc.id); - kfree(p->u.conc.connect); - break; - case MNODE: - kfree(p->u.module.id); - break; - case TNODE: - kfree(p->u.ttyname); - break; - case CUNODE: - kfree(p->u.cuname); - break; - case LNODE: - kfree(p->u.line.cable); - break; - case PNODE: - kfree(p->u.printname); - break; - } - - kfree(p->u.board.status); - kfree(p); - p = tmp; - } -} /* - * Parse a configuration file read into memory as a string. + * Create pr and tty device entries */ -static int dgap_parsefile(char **in) +static int dgap_tty_register_ports(struct board_t *brd) { - struct cnode *p, *brd, *line, *conc; - int rc; - char *s; - int linecnt = 0; - - p = &dgap_head; - brd = line = conc = NULL; + struct channel_t *ch; + int i; + int ret; - /* perhaps we are adding to an existing list? */ - while (p->next) - p = p->next; + brd->serial_ports = kcalloc(brd->nasync, sizeof(*brd->serial_ports), + GFP_KERNEL); + if (!brd->serial_ports) + return -ENOMEM; - /* file must start with a BEGIN */ - while ((rc = dgap_gettok(in)) != BEGIN) { - if (rc == 0) { - pr_err("unexpected EOF"); - return -1; - } + brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), + GFP_KERNEL); + if (!brd->printer_ports) { + ret = -ENOMEM; + goto free_serial_ports; } - for (; ;) { - int board_type = 0; - int conc_type = 0; - int module_type = 0; - - rc = dgap_gettok(in); - if (rc == 0) { - pr_err("unexpected EOF"); - return -1; - } - - switch (rc) { - case BEGIN: /* should only be 1 begin */ - pr_err("unexpected config_begin\n"); - return -1; - - case END: - return 0; - - case BOARD: /* board info */ - if (dgap_checknode(p)) - return -1; - - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; - - p = p->next; - - p->type = BNODE; - p->u.board.status = kstrdup("No", GFP_KERNEL); - line = conc = NULL; - brd = p; - linecnt = -1; + for (i = 0; i < brd->nasync; i++) { + tty_port_init(&brd->serial_ports[i]); + tty_port_init(&brd->printer_ports[i]); + } - board_type = dgap_gettok(in); - if (board_type == 0) { - pr_err("board !!type not specified"); - return -1; - } + ch = brd->channels[0]; + for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { - p->u.board.type = board_type; + struct device *classp; - break; + classp = tty_port_register_device(&brd->serial_ports[i], + brd->serial_driver, + i, NULL); - case IO: /* i/o port */ - if (p->type != BNODE) { - pr_err("IO port only vaild for boards"); - return -1; - } - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.board.portstr = kstrdup(s, GFP_KERNEL); - if (kstrtol(s, 0, &p->u.board.port)) { - pr_err("bad number for IO port"); - return -1; - } - p->u.board.v_port = 1; - break; + if (IS_ERR(classp)) { + ret = PTR_ERR(classp); + goto unregister_ttys; + } - case MEM: /* memory address */ - if (p->type != BNODE) { - pr_err("memory address only vaild for boards"); - return -1; - } - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.board.addrstr = kstrdup(s, GFP_KERNEL); - if (kstrtoul(s, 0, &p->u.board.addr)) { - pr_err("bad number for memory address"); - return -1; - } - p->u.board.v_addr = 1; - break; + dgap_create_tty_sysfs(&ch->ch_tun, classp); + ch->ch_tun.un_sysfs = classp; - case PCIINFO: /* pci information */ - if (p->type != BNODE) { - pr_err("memory address only vaild for boards"); - return -1; - } - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.board.pcibusstr = kstrdup(s, GFP_KERNEL); - if (kstrtoul(s, 0, &p->u.board.pcibus)) { - pr_err("bad number for pci bus"); - return -1; - } - p->u.board.v_pcibus = 1; - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.board.pcislotstr = kstrdup(s, GFP_KERNEL); - if (kstrtoul(s, 0, &p->u.board.pcislot)) { - pr_err("bad number for pci slot"); - return -1; - } - p->u.board.v_pcislot = 1; - break; + classp = tty_port_register_device(&brd->printer_ports[i], + brd->print_driver, + i, NULL); - case METHOD: - if (p->type != BNODE) { - pr_err("install method only vaild for boards"); - return -1; - } - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.board.method = kstrdup(s, GFP_KERNEL); - p->u.board.v_method = 1; - break; + if (IS_ERR(classp)) { + ret = PTR_ERR(classp); + goto unregister_ttys; + } - case STATUS: - if (p->type != BNODE) { - pr_err("config status only vaild for boards"); - return -1; - } - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.board.status = kstrdup(s, GFP_KERNEL); - break; + dgap_create_tty_sysfs(&ch->ch_pun, classp); + ch->ch_pun.un_sysfs = classp; + } + dgap_create_ports_sysfiles(brd); - case NPORTS: /* number of ports */ - if (p->type == BNODE) { - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.board.nport)) { - pr_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) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.conc.nport)) { - pr_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) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.module.nport)) { - pr_err("bad number for number of ports"); - return -1; - } - p->u.module.v_nport = 1; - } else { - pr_err("nports only valid for concentrators or modules"); - return -1; - } - break; + return 0; - case ID: /* letter ID used in tty name */ - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } +unregister_ttys: + while (i >= 0) { + ch = brd->channels[i]; + if (ch->ch_tun.un_sysfs) { + dgap_remove_tty_sysfs(ch->ch_tun.un_sysfs); + tty_unregister_device(brd->serial_driver, i); + } - p->u.board.status = kstrdup(s, GFP_KERNEL); + if (ch->ch_pun.un_sysfs) { + dgap_remove_tty_sysfs(ch->ch_pun.un_sysfs); + tty_unregister_device(brd->print_driver, i); + } + i--; + } - if (p->type == CNODE) { - p->u.conc.id = kstrdup(s, GFP_KERNEL); - p->u.conc.v_id = 1; - } else if (p->type == MNODE) { - p->u.module.id = kstrdup(s, GFP_KERNEL); - p->u.module.v_id = 1; - } else { - pr_err("id only valid for concentrators or modules"); - return -1; - } - break; + for (i = 0; i < brd->nasync; i++) { + tty_port_destroy(&brd->serial_ports[i]); + tty_port_destroy(&brd->printer_ports[i]); + } - case STARTO: /* start offset of ID */ - if (p->type == BNODE) { - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.board.start)) { - pr_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) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.conc.start)) { - pr_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) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.module.start)) { - pr_err("bad number for start of tty count"); - return -1; - } - p->u.module.v_start = 1; - } else { - pr_err("start only valid for concentrators or modules"); - return -1; - } - break; + kfree(brd->printer_ports); + brd->printer_ports = NULL; - case TTYN: /* tty name prefix */ - if (dgap_checknode(p)) - return -1; +free_serial_ports: + kfree(brd->serial_ports); + brd->serial_ports = NULL; - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + return ret; +} - p = p->next; - p->type = TNODE; +/* + * dgap_cleanup_tty() + * + * Uninitialize the TTY portion of this driver. Free all memory and + * resources. + */ +static void dgap_cleanup_tty(struct board_t *brd) +{ + struct device *dev; + unsigned int i; - s = dgap_getword(in); - if (!s) { - pr_err("unexpeced end of file"); - return -1; - } - p->u.ttyname = kstrdup(s, GFP_KERNEL); - if (!p->u.ttyname) - return -1; + dgap_boards_by_major[brd->serial_driver->major] = NULL; + brd->dgap_serial_major = 0; + for (i = 0; i < brd->nasync; i++) { + tty_port_destroy(&brd->serial_ports[i]); + dev = brd->channels[i]->ch_tun.un_sysfs; + dgap_remove_tty_sysfs(dev); + tty_unregister_device(brd->serial_driver, i); + } + tty_unregister_driver(brd->serial_driver); + put_tty_driver(brd->serial_driver); + kfree(brd->serial_ports); - break; + dgap_boards_by_major[brd->print_driver->major] = NULL; + brd->dgap_transparent_print_major = 0; + for (i = 0; i < brd->nasync; i++) { + tty_port_destroy(&brd->printer_ports[i]); + dev = brd->channels[i]->ch_pun.un_sysfs; + dgap_remove_tty_sysfs(dev); + tty_unregister_device(brd->print_driver, i); + } + tty_unregister_driver(brd->print_driver); + put_tty_driver(brd->print_driver); + kfree(brd->printer_ports); +} - case CU: /* cu name prefix */ - if (dgap_checknode(p)) - return -1; +static int dgap_request_irq(struct board_t *brd) +{ + int rc; - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return -ENODEV; - p = p->next; - p->type = CUNODE; + /* + * Set up our interrupt handler if we are set to do interrupts. + */ + if (dgap_config_get_useintr(brd) && brd->irq) { - s = dgap_getword(in); - if (!s) { - pr_err("unexpeced end of file"); - return -1; - } - p->u.cuname = kstrdup(s, GFP_KERNEL); - if (!p->u.cuname) - return -1; + rc = request_irq(brd->irq, dgap_intr, IRQF_SHARED, "DGAP", brd); - break; + if (!rc) + brd->intr_used = 1; + } + return 0; +} - case LINE: /* line information */ - if (dgap_checknode(p)) - return -1; - if (!brd) { - pr_err("must specify board before line info"); - return -1; - } - switch (brd->u.board.type) { - case PPCM: - pr_err("line not vaild for PC/em"); - return -1; - } +static void dgap_free_irq(struct board_t *brd) +{ + if (brd->intr_used && brd->irq) + free_irq(brd->irq, brd); +} + +static int dgap_firmware_load(struct pci_dev *pdev, int card_type, + struct board_t *brd) +{ + const struct firmware *fw; + char *tmp_ptr; + int ret; + char *dgap_config_buf; + + dgap_get_vpd(brd); + dgap_do_reset_board(brd); + + if (fw_info[card_type].conf_name) { + ret = request_firmware(&fw, fw_info[card_type].conf_name, + &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "config file %s not found\n", + fw_info[card_type].conf_name); + return ret; + } - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + dgap_config_buf = kzalloc(fw->size + 1, GFP_KERNEL); + if (!dgap_config_buf) { + release_firmware(fw); + return -ENOMEM; + } - p = p->next; - p->type = LNODE; - conc = NULL; - line = p; - linecnt++; - break; + memcpy(dgap_config_buf, fw->data, fw->size); + release_firmware(fw); - case CONC: /* concentrator information */ - if (dgap_checknode(p)) - return -1; - if (!line) { - pr_err("must specify line info before concentrator"); - return -1; - } + /* + * preserve dgap_config_buf + * as dgap_parsefile would + * otherwise alter it. + */ + tmp_ptr = dgap_config_buf; - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + if (dgap_parsefile(&tmp_ptr) != 0) { + kfree(dgap_config_buf); + return -EINVAL; + } + kfree(dgap_config_buf); + } - p = p->next; - p->type = CNODE; - conc = p; + /* + * 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); - if (linecnt) - brd->u.board.conc2++; - else - brd->u.board.conc1++; + /* + * 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); - conc_type = dgap_gettok(in); - if (conc_type == 0 || conc_type != CX || - conc_type != EPC) { - pr_err("failed to set a type of concentratros"); - return -1; - } + if (!brd->bd_config) { + dev_err(&pdev->dev, "No valid configuration found\n"); + return -EINVAL; + } - p->u.conc.type = conc_type; + if (fw_info[card_type].bios_name) { + ret = request_firmware(&fw, fw_info[card_type].bios_name, + &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "bios file %s not found\n", + fw_info[card_type].bios_name); + return ret; + } + dgap_do_bios_load(brd, fw->data, fw->size); + release_firmware(fw); - break; + /* Wait for BIOS to test board... */ + ret = dgap_test_bios(brd); + if (ret) + return ret; + } - case MOD: /* EBI module */ - if (dgap_checknode(p)) - return -1; - if (!brd) { - pr_err("must specify board info before EBI modules"); - return -1; - } - switch (brd->u.board.type) { - case PPCM: - linecnt = 0; - break; - default: - if (!conc) { - pr_err("must specify concentrator info before EBI module"); - return -1; - } - } + if (fw_info[card_type].fep_name) { + ret = request_firmware(&fw, fw_info[card_type].fep_name, + &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "dgap: fep file %s not found\n", + fw_info[card_type].fep_name); + return ret; + } + dgap_do_fep_load(brd, fw->data, fw->size); + release_firmware(fw); - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + /* Wait for FEP to load on board... */ + ret = dgap_test_fep(brd); + if (ret) + return ret; + } - p = p->next; - p->type = MNODE; +#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 (linecnt) - brd->u.board.module2++; - else - brd->u.board.module1++; + if (fw_info[card_type].con_name && check && vaddr) { + ret = request_firmware(&fw, fw_info[card_type].con_name, + &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "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); - module_type = dgap_gettok(in); - if (module_type == 0 || module_type != PORTS || - module_type != MODEM) { - pr_err("failed to set a type of module"); - return -1; - } + dgap_do_conc_load(brd, (char *)fw->data, fw->size) + release_firmware(fw); + } +#endif - p->u.module.type = module_type; + return 0; +} - break; +/* + * dgap_tty_init() + * + * Init the tty subsystem. Called once per board after board has been + * downloaded and init'ed. + */ +static int dgap_tty_init(struct board_t *brd) +{ + int i; + int tlw; + uint true_count; + u8 __iomem *vaddr; + u8 modem; + struct channel_t *ch; + struct bs_t __iomem *bs; + struct cm_t __iomem *cm; + int ret; - case CABLE: - if (p->type == LNODE) { - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.line.cable = kstrdup(s, GFP_KERNEL); - p->u.line.v_cable = 1; - } - break; + /* + * Initialize board structure elements. + */ - case SPEED: /* sync line speed indication */ - if (p->type == LNODE) { - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.line.speed)) { - pr_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) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.conc.speed)) { - pr_err("bad number for line speed"); - return -1; - } - p->u.conc.v_speed = 1; - } else { - pr_err("speed valid only for lines or concentrators."); - return -1; - } - break; + vaddr = brd->re_map_membase; + true_count = readw((vaddr + NCHAN)); - case CONNECT: - if (p->type == CNODE) { - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - p->u.conc.connect = kstrdup(s, GFP_KERNEL); - p->u.conc.v_connect = 1; - } - break; - case PRINT: /* transparent print name prefix */ - if (dgap_checknode(p)) - return -1; + brd->nasync = dgap_config_get_num_prts(brd); - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + if (!brd->nasync) + brd->nasync = brd->maxports; - p = p->next; - p->type = PNODE; + if (brd->nasync > brd->maxports) + brd->nasync = brd->maxports; + + if (true_count != brd->nasync) { + dev_warn(&brd->pdev->dev, + "%s configured for %d ports, has %d ports.\n", + brd->name, brd->nasync, true_count); + + if ((brd->type == PPCM) && + (true_count == 64 || true_count == 0)) { + dev_warn(&brd->pdev->dev, + "Please make SURE the EBI cable running from the card\n"); + dev_warn(&brd->pdev->dev, + "to each EM module is plugged into EBI IN!\n"); + } - s = dgap_getword(in); - if (!s) { - pr_err("unexpeced end of file"); - return -1; - } - p->u.printname = kstrdup(s, GFP_KERNEL); - if (!p->u.printname) - return -1; + brd->nasync = true_count; - break; + /* If no ports, don't bother going any further */ + if (!brd->nasync) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return -EIO; + } + } - case CMAJOR: /* major number */ - if (dgap_checknode(p)) - return -1; + /* + * Allocate channel memory that might not have been allocated + * when the driver was first loaded. + */ + for (i = 0; i < brd->nasync; i++) { + brd->channels[i] = + kzalloc(sizeof(struct channel_t), GFP_KERNEL); + if (!brd->channels[i]) { + ret = -ENOMEM; + goto free_chan; + } + } - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + ch = brd->channels[0]; + vaddr = brd->re_map_membase; - p = p->next; - p->type = JNODE; + bs = (struct bs_t __iomem *) ((ulong) vaddr + CHANBUF); + cm = (struct cm_t __iomem *) ((ulong) vaddr + CMDBUF); - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.majornumber)) { - pr_err("bad number for major number"); - return -1; - } - break; + brd->bd_bs = bs; - case ALTPIN: /* altpin setting */ - if (dgap_checknode(p)) - return -1; + /* Set up channel variables */ + for (i = 0; i < brd->nasync; i++, ch = brd->channels[i], bs++) { - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + spin_lock_init(&ch->ch_lock); - p = p->next; - p->type = ANODE; + /* 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; - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.altpin)) { - pr_err("bad number for altpin"); - return -1; - } - break; + 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; - case USEINTR: /* enable interrupt setting */ - if (dgap_checknode(p)) - return -1; + 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; - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + /* + * 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; + } - p = p->next; - p->type = INTRNODE; - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.useintr)) { - pr_err("bad number for useintr"); - return -1; - } - break; + ch->ch_taddr = vaddr + (ioread16(&(ch->ch_bs->tx_seg)) << 4); + ch->ch_raddr = vaddr + (ioread16(&(ch->ch_bs->rx_seg)) << 4); + ch->ch_tx_win = 0; + ch->ch_rx_win = 0; + ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1; + ch->ch_rsize = readw(&(ch->ch_bs->rx_max)) + 1; + ch->ch_tstart = 0; + ch->ch_rstart = 0; - case TTSIZ: /* size of tty structure */ - if (dgap_checknode(p)) - return -1; + /* + * Set queue water marks, interrupt mask, + * and general tty parameters. + */ + tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) : + ch->ch_tsize / 2; + ch->ch_tlw = tlw; - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + dgap_cmdw(ch, STLOW, tlw, 0); - p = p->next; - p->type = TSNODE; + dgap_cmdw(ch, SRLOW, ch->ch_rsize / 2, 0); - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.ttysize)) { - pr_err("bad number for ttysize"); - return -1; - } - break; + dgap_cmdw(ch, SRHIGH, 7 * ch->ch_rsize / 8, 0); - case CHSIZ: /* channel structure size */ - if (dgap_checknode(p)) - return -1; + ch->ch_mistat = readb(&(ch->ch_bs->m_stat)); - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + 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); - p = p->next; - p->type = CSNODE; + /* Turn on all modem interrupts for now */ + modem = (DM_CD | DM_DSR | DM_CTS | DM_RI); + writeb(modem, &(ch->ch_bs->m_int)); - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.chsize)) { - pr_err("bad number for chsize"); - return -1; - } - break; + /* + * 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)); - case BSSIZ: /* board structure size */ - if (dgap_checknode(p)) - return -1; + writeb(1, &(ch->ch_bs->idata)); + } - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + return 0; - p = p->next; - p->type = BSNODE; +free_chan: + while (--i >= 0) { + kfree(brd->channels[i]); + brd->channels[i] = NULL; + } + return ret; +} - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.bssize)) { - pr_err("bad number for bssize"); - return -1; - } - break; +/* + * dgap_tty_free() + * + * Free the channles which are allocated in dgap_tty_init(). + */ +static void dgap_tty_free(struct board_t *brd) +{ + int i; - case UNTSIZ: /* sched structure size */ - if (dgap_checknode(p)) - return -1; + for (i = 0; i < brd->nasync; i++) + kfree(brd->channels[i]); +} - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; +static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int rc; + struct board_t *brd; - p = p->next; - p->type = USNODE; + if (dgap_numboards >= MAXBOARDS) + return -EPERM; - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.unsize)) { - pr_err("bad number for schedsize"); - return -1; - } - break; + rc = pci_enable_device(pdev); + if (rc) + return -EIO; - case F2SIZ: /* f2200 structure size */ - if (dgap_checknode(p)) - return -1; + brd = dgap_found_board(pdev, ent->driver_data, dgap_numboards); + if (IS_ERR(brd)) + return PTR_ERR(brd); - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + rc = dgap_firmware_load(pdev, ent->driver_data, brd); + if (rc) + goto cleanup_brd; - p = p->next; - p->type = FSNODE; + rc = dgap_alloc_flipbuf(brd); + if (rc) + goto cleanup_brd; - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.f2size)) { - pr_err("bad number for f2200size"); - return -1; - } - break; + rc = dgap_tty_register(brd); + if (rc) + goto free_flipbuf; - case VPSIZ: /* vpix structure size */ - if (dgap_checknode(p)) - return -1; + rc = dgap_request_irq(brd); + if (rc) + goto unregister_tty; - p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); - if (!p->next) - return -1; + /* + * Do tty device initialization. + */ + rc = dgap_tty_init(brd); + if (rc < 0) + goto free_irq; - p = p->next; - p->type = VSNODE; + rc = dgap_tty_register_ports(brd); + if (rc) + goto tty_free; - s = dgap_getword(in); - if (!s) { - pr_err("unexpected end of file"); - return -1; - } - if (kstrtol(s, 0, &p->u.vpixsize)) { - pr_err("bad number for vpixsize"); - return -1; - } - break; - } - } -} + brd->state = BOARD_READY; + brd->dpastatus = BD_RUNNING; -/* - * 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; + dgap_board[dgap_numboards++] = brd; - if (!string || !group) - return NULL; + return 0; - 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; - } - } - } +tty_free: + dgap_tty_free(brd); +free_irq: + dgap_free_irq(brd); +unregister_tty: + dgap_tty_unregister(brd); +free_flipbuf: + dgap_free_flipbuf(brd); +cleanup_brd: + dgap_cleanup_nodes(); + dgap_unmap(brd); + kfree(brd); - return NULL; + return rc; +} + +static void dgap_remove_one(struct pci_dev *dev) +{ + /* Do Nothing */ } +static struct pci_driver dgap_driver = { + .name = "dgap", + .probe = dgap_init_one, + .id_table = dgap_pci_tbl, + .remove = dgap_remove_one, +}; + /* - * Get a token from the input file; return 0 if end of file is reached + * dgap_init_globals() + * + * This is where we initialize the globals from the static insmod + * configuration variables. These are declared near the head of + * this file. */ -static int dgap_gettok(char **in) +static void dgap_init_globals(void) { - char *w; - struct toklist *t; + unsigned int i; - if (strstr(dgap_cword, "board")) { - w = dgap_getword(in); - snprintf(dgap_cword, MAXCWORD, "%s", w); - for (t = dgap_brdtype; t->token != 0; t++) { - if (!strcmp(w, t->string)) - return t->token; - } - } else { - while ((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; - } - } - } + for (i = 0; i < MAXBOARDS; i++) + dgap_board[i] = NULL; - return 0; + init_timer(&dgap_poll_timer); } /* - * get a word from the input stream, also keep track of current line number. - * words are separated by whitespace. + * Start of driver. */ -static char *dgap_getword(char **in) +static int dgap_start(void) { - char *ret_ptr = *in; + int rc; + unsigned long flags; + struct device *device; - char *ptr = dgap_sindex(*in, " \t\n"); + /* + * make sure that the globals are + * init'd before we do anything else + */ + dgap_init_globals(); - /* If no word found, return null */ - if (!ptr) - return NULL; + dgap_numboards = 0; - /* Mark new location for our buffer */ - *ptr = '\0'; - *in = ptr + 1; + pr_info("For the tools package please visit http://www.digi.com\n"); - /* Eat any extra spaces/tabs/newlines that might be present */ - while (*in && **in && ((**in == ' ') || - (**in == '\t') || - (**in == '\n'))) { - **in = '\0'; - *in = *in + 1; + /* + * Register our base character device into the kernel. + */ + + /* + * Register management/dpa devices + */ + rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap", &dgap_board_fops); + if (rc < 0) + return rc; + + dgap_class = class_create(THIS_MODULE, "dgap_mgmt"); + if (IS_ERR(dgap_class)) { + rc = PTR_ERR(dgap_class); + goto failed_class; } - return ret_ptr; -} + device = device_create(dgap_class, NULL, + MKDEV(DIGI_DGAP_MAJOR, 0), + NULL, "dgap_mgmt"); + if (IS_ERR(device)) { + rc = PTR_ERR(device); + goto failed_device; + } -/* - * 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 LNODE: - if (p->u.line.v_speed == 0) { - pr_err("line speed not specified"); - return 1; - } - return 0; + /* Start the poller */ + spin_lock_irqsave(&dgap_poll_lock, flags); + init_timer(&dgap_poll_timer); + dgap_poll_timer.function = dgap_poll_handler; + dgap_poll_timer.data = 0; + dgap_poll_time = jiffies + dgap_jiffies_from_ms(dgap_poll_tick); + dgap_poll_timer.expires = dgap_poll_time; + spin_unlock_irqrestore(&dgap_poll_lock, flags); - case CNODE: - if (p->u.conc.v_speed == 0) { - pr_err("concentrator line speed not specified"); - return 1; - } - if (p->u.conc.v_nport == 0) { - pr_err("number of ports on concentrator not specified"); - return 1; - } - if (p->u.conc.v_id == 0) { - pr_err("concentrator id letter not specified"); - return 1; - } - return 0; + add_timer(&dgap_poll_timer); - case MNODE: - if (p->u.module.v_nport == 0) { - pr_err("number of ports on EBI module not specified"); - return 1; - } - if (p->u.module.v_id == 0) { - pr_err("EBI module id letter not specified"); - return 1; - } - return 0; - } - return 0; + return rc; + +failed_device: + class_destroy(dgap_class); +failed_class: + unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); + return rc; } -/* - * Given a board pointer, returns whether we should use interrupts or not. - */ -static uint dgap_config_get_useintr(struct board_t *bd) +static void dgap_stop(void) { - struct cnode *p; + unsigned long lock_flags; - if (!bd) - return 0; + spin_lock_irqsave(&dgap_poll_lock, lock_flags); + dgap_poll_stop = 1; + spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); - for (p = bd->bd_config; p; p = p->next) { - if (p->type == INTRNODE) { - /* - * check for pcxr types. - */ - return p->u.useintr; - } - } + del_timer_sync(&dgap_poll_timer); - /* If not found, then don't turn on interrupts. */ - return 0; + device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); + class_destroy(dgap_class); + unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); } /* - * Given a board pointer, returns whether we turn on altpin or not. + * dgap_cleanup_board() + * + * Free all the memory associated with a board */ -static uint dgap_config_get_altpin(struct board_t *bd) +static void dgap_cleanup_board(struct board_t *brd) { - struct cnode *p; + unsigned int i; - if (!bd) - return 0; + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return; - for (p = bd->bd_config; p; p = p->next) { - if (p->type == ANODE) { - /* - * check for pcxr types. - */ - return p->u.altpin; - } - } + dgap_free_irq(brd); - /* If not found, then don't turn on interrupts. */ - return 0; + tasklet_kill(&brd->helper_tasklet); + + dgap_unmap(brd); + + /* Free all allocated channels structs */ + for (i = 0; i < MAXPORTS ; i++) + kfree(brd->channels[i]); + + kfree(brd->flipbuf); + kfree(brd->flipflagbuf); + + dgap_board[brd->boardnum] = NULL; + + kfree(brd); } + +/************************************************************************ + * + * Driver load/unload functions + * + ************************************************************************/ + /* - * Given a specific type of board, if found, detached link and - * returns the first occurrence in the list. + * init_module() + * + * Module load. This is where it all starts. */ -static struct cnode *dgap_find_config(int type, int bus, int slot) +static int dgap_init_module(void) { - struct cnode *p, *prev, *prev2, *found; - - p = &dgap_head; - - while (p->next) { - prev = p; - p = p->next; - - if (p->type != BNODE) - continue; + int rc; - if (p->u.board.type != type) - continue; + pr_info("%s, Digi International Part Number %s\n", DG_NAME, DG_PART); - if (p->u.board.v_pcibus && - p->u.board.pcibus != bus) - continue; + rc = dgap_start(); + if (rc) + return rc; - if (p->u.board.v_pcislot && - p->u.board.pcislot != slot) - continue; + rc = pci_register_driver(&dgap_driver); + if (rc) + goto err_stop; - found = p; - /* - * Keep walking thru the list till we - * find the next board. - */ - while (p->next) { - prev2 = p; - p = p->next; + rc = dgap_create_driver_sysfiles(&dgap_driver); + if (rc) + goto err_unregister; - if (p->type != BNODE) - continue; + dgap_driver_state = DRIVER_READY; - /* - * Mark the end of our 1 board - * chain of configs. - */ - prev2->next = NULL; + return 0; - /* - * Link the "next" board to the - * previous board, effectively - * "unlinking" our board from - * the main config. - */ - prev->next = p; +err_unregister: + pci_unregister_driver(&dgap_driver); +err_stop: + dgap_stop(); - return found; - } - /* - * It must be the last board in the list. - */ - prev->next = NULL; - return found; - } - return NULL; + return rc; } /* - * 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) + * dgap_cleanup_module() + * + * Module unload. This is where it all ends. */ -static uint dgap_config_get_num_prts(struct board_t *bd) +static void dgap_cleanup_module(void) { - int count = 0; - struct cnode *p; + unsigned int i; + ulong lock_flags; - if (!bd) - return 0; + spin_lock_irqsave(&dgap_poll_lock, lock_flags); + dgap_poll_stop = 1; + spin_unlock_irqrestore(&dgap_poll_lock, lock_flags); - for (p = bd->bd_config; p; p = p->next) { + /* Turn off poller right away. */ + del_timer_sync(&dgap_poll_timer); - 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; -} + dgap_remove_driver_sysfiles(&dgap_driver); -static char *dgap_create_config_string(struct board_t *bd, char *string) -{ - char *ptr = string; - struct cnode *p; - struct cnode *q; - int speed; + device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); + class_destroy(dgap_class); + unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); - if (!bd) { - *ptr = 0xff; - return string; + for (i = 0; i < dgap_numboards; ++i) { + dgap_remove_ports_sysfiles(dgap_board[i]); + dgap_cleanup_tty(dgap_board[i]); + dgap_cleanup_board(dgap_board[i]); } - for (p = bd->bd_config; p; p = p->next) { + dgap_cleanup_nodes(); - 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 && (q->type == MNODE)) { - *ptr = (p->u.conc.nport + 0x80); - ptr++; - p = q; - while (q->next && (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++; - } + if (dgap_numboards) + pci_unregister_driver(&dgap_driver); +} - *ptr = speed; - ptr++; - break; - } - } +module_init(dgap_init_module); +module_exit(dgap_cleanup_module); - *ptr = 0xff; - return string; -} +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Digi International, http://www.digi.com"); +MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); +MODULE_SUPPORTED_DEVICE("dgap"); -- cgit v1.2.3-59-g8ed1b From 5d070cf25c4ecefaaa845ee7c1c3719c90f1c370 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:26 +0000 Subject: staging: comedi: maybe force CMDF_WRITE command flag Most comedi subdevices that support asynchronous commands only support data transfer in either the "read" or "write" direction, as indicated by the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags, although a few support both directions on the same subdevice (though not simultaneously). The `struct comedi_cmd` structure passed via ioctl call to set up the command contains a `CMDF_WRITE` flag that can be used to choose the direction if the subdevice supports both directions, but the flag is optional if the subdevice only supports data transfer in one direction. If the subdevice only supports asynchronous data transfer in a sing direction, set the `CMDF_WRITE` flag to the correct state so that Comedi can make use of it later. In the case of the `COMEDI_CMDTEST` ioctl, the updated flag will be written back to the `struct comedi_cmd` in user-space. In the case of the `COMEDI_CMD` ioctl, the flag only gets written back if an error is detected while testing the command, or if the `CMDF_BOGUS` command flag is set. Since `__comedi_get_user_cmd()` is called for both ioctls, that's a good place to set the flag. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c1fe9e0e46d1..b489d9481a69 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1451,6 +1451,21 @@ static int __comedi_get_user_cmd(struct comedi_device *dev, return -EINVAL; } + /* + * Set the CMDF_WRITE flag to the correct state if the subdevice + * supports only "read" commands or only "write" commands. + */ + switch (s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) { + case SDF_CMD_READ: + cmd->flags &= ~CMDF_WRITE; + break; + case SDF_CMD_WRITE: + cmd->flags |= CMDF_WRITE; + break; + default: + break; + } + return 0; } -- cgit v1.2.3-59-g8ed1b From 8986d37ace6aed435c29084756923bdbb5148624 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:27 +0000 Subject: staging: comedi: me4000: don't clobber command flags The low-level Comedi drivers shouldn't change the `flags` member of `struct comedi_cmd` as the Comedi core also uses some of those flags. They should just ignore the flags they don't understand. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index b5115d8d6170..728447123b4c 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -833,9 +833,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, unsigned int scan_ticks; int err = 0; - /* Only rounding flags are implemented */ - cmd->flags &= CMDF_ROUND_NEAREST | CMDF_ROUND_UP | CMDF_ROUND_DOWN; - /* Round the timer arguments */ ai_round_cmd_args(dev, s, cmd, &init_ticks, &scan_ticks, &chan_ticks); -- cgit v1.2.3-59-g8ed1b From fb5a88eb9c2e20e2a68caea7ebebab65d2a13cd1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:28 +0000 Subject: staging: comedi: ni_mio_common: don't change CMDF_WRITE flag There is no need for `ni_ai_cmdtest()` or `ni_ao_cmdtest()` to set the `CMDF_WRITE` flag to the correct state as it has already been done by the core comedi module. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 18e68cd3ac53..fd61d24bc3a4 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2237,9 +2237,6 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 1 : check if triggers are trivially valid */ - if ((cmd->flags & CMDF_WRITE)) - cmd->flags &= ~CMDF_WRITE; - err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT | TRIG_EXT); err |= cfc_check_trigger_src(&cmd->scan_begin_src, @@ -3272,9 +3269,6 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 1 : check if triggers are trivially valid */ - if ((cmd->flags & CMDF_WRITE) == 0) - cmd->flags |= CMDF_WRITE; - err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT); err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER | TRIG_EXT); -- cgit v1.2.3-59-g8ed1b From f025ab9eb73e46f761f469a2bb7c26a159b3e6c9 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:29 +0000 Subject: staging: comedi: don't allow read() on async command set up for "write" If a Comedi asynchronous command has been set up for data transfer in the "write" direction on the current "read" subdevice (for those subdevices that support both directions), don't allow the "read" file operation as that would mess with the data in the comedi data buffer that is read by the low-level comedi hardware driver. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index b489d9481a69..452121b6a604 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2210,6 +2210,10 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, retval = -EACCES; goto out; } + if (async->cmd.flags & CMDF_WRITE) { + retval = -EINVAL; + goto out; + } add_wait_queue(&async->wait_head, &wait); while (nbytes > 0 && !retval) { @@ -2249,6 +2253,10 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, retval = -EACCES; break; } + if (async->cmd.flags & CMDF_WRITE) { + retval = -EINVAL; + break; + } continue; } m = copy_to_user(buf, async->prealloc_buf + -- cgit v1.2.3-59-g8ed1b From f739850941bc300ed4dc18e22d42cbb670bf69b6 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:30 +0000 Subject: staging: comedi: don't allow write() on async command set up for "read" If a Comedi asynchronous command has been set up for data transfer in the "read" direction on the current "write" subdevice (for those subdevices that support both directions), don't allow the "write" file operation as that would mess with the data in the comedi data buffer that is written by the low-level comedi hardware driver. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 452121b6a604..0ed6f1f00e7f 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2075,6 +2075,10 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, retval = -EACCES; goto out; } + if (!(async->cmd.flags & CMDF_WRITE)) { + retval = -EINVAL; + goto out; + } add_wait_queue(&async->wait_head, &wait); on_wait_queue = true; @@ -2146,6 +2150,10 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, retval = -EACCES; break; } + if (!(async->cmd.flags & CMDF_WRITE)) { + retval = -EINVAL; + break; + } continue; } -- cgit v1.2.3-59-g8ed1b From 662c722b645b22782eecdddf324c3a64d303baf3 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:31 +0000 Subject: staging: comedi: check command direction in poll() file operation `comedi_poll()` handles the poll() file operation for comedi devices. If no asynchronous command has been set up on the current "read" subdevice, it sets the `POLLIN` and `POLLRDNORM` bits in the return value to indicate that the read() file operation would not block as it would return an error. Add a check so it also does that if the asynchronous command has been set up in the "write" direction as that also causes the read() file operation to return an error. Similarly, if no asynchronous command has need set up on the current "write" subdevice, it sets the `POLLOUT` and `POLLWRNORM` bits in the return value to indicate that the write() file operation would not block as it would return an error. Add a check so it also does that if the asynchronous command has been set up in the "read" direction as that also causes the write() file operation to return an error. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 0ed6f1f00e7f..63afd78441f1 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2017,6 +2017,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) if (s && s->async) { poll_wait(file, &s->async->wait_head, wait); if (!s->busy || !comedi_is_subdevice_running(s) || + (s->async->cmd.flags & CMDF_WRITE) || comedi_buf_read_n_available(s) > 0) mask |= POLLIN | POLLRDNORM; } @@ -2028,6 +2029,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) poll_wait(file, &s->async->wait_head, wait); comedi_buf_write_alloc(s, s->async->prealloc_bufsz); if (!s->busy || !comedi_is_subdevice_running(s) || + !(s->async->cmd.flags & CMDF_WRITE) || comedi_buf_write_n_allocated(s) >= bps) mask |= POLLOUT | POLLWRNORM; } -- cgit v1.2.3-59-g8ed1b From 75f6108fa91bb80e9f7e8ead81f0cedf171d00a2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Oct 2014 12:42:32 +0000 Subject: staging: comedi: check actual data direction for COMEDI_BUFINFO ioctl `do_bufinfo_ioctl()` handled the `COMEDI_BUFINFO` ioctl. It is supposed to update the read or write positions in the buffer depending on the direction of data transfer set up by the asynchronous command. Currently it checks the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags. That's fine for most subdevices - the ones that only support one direction, but is incorrect for those subdevices that allow the command to be set up in either direction. Since we now set the `CMDF_WRITE` flag according to the data transfer direction of the current command running on the subdevice, check that flag instead. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 63afd78441f1..704ae25c5710 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -991,7 +991,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (s->busy != file) return -EACCES; - if (bi.bytes_read && (s->subdev_flags & SDF_CMD_READ)) { + if (bi.bytes_read && !(async->cmd.flags & CMDF_WRITE)) { bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read); comedi_buf_read_free(s, bi.bytes_read); @@ -1001,7 +1001,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, } } - if (bi.bytes_written && (s->subdev_flags & SDF_CMD_WRITE)) { + if (bi.bytes_written && (async->cmd.flags & CMDF_WRITE)) { bi.bytes_written = comedi_buf_write_alloc(s, bi.bytes_written); comedi_buf_write_free(s, bi.bytes_written); -- cgit v1.2.3-59-g8ed1b From ef49d8329e25ee1686520315713b86419cddcb45 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:19:34 -0700 Subject: staging: comedi: drivers: replace SDF_WRITEABLE with SDF_WRITABLE As indicated in the comedi.h uapi header, SDF_WRITEABLE was a spelling error in the API, SDF_WRITABLE is prefered. For aesthetics, replace all the SDF_WRITEABLE uses with SDF_WRITABLE. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 5 ++--- drivers/staging/comedi/drivers/addi_apci_1516.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1564.c | 4 ++-- drivers/staging/comedi/drivers/addi_apci_16xx.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2200.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +++--- drivers/staging/comedi/drivers/addi_apci_3501.c | 6 +++--- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 6 +++--- drivers/staging/comedi/drivers/addi_watchdog.c | 2 +- drivers/staging/comedi/drivers/adv_pci1723.c | 2 +- drivers/staging/comedi/drivers/c6xdigio.c | 2 +- drivers/staging/comedi/drivers/comedi_test.c | 2 +- drivers/staging/comedi/drivers/das6402.c | 4 ++-- drivers/staging/comedi/drivers/dt9812.c | 4 ++-- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 +- drivers/staging/comedi/drivers/me4000.c | 2 +- drivers/staging/comedi/drivers/me_daq.c | 4 ++-- drivers/staging/comedi/drivers/ni_usb6501.c | 2 +- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 4 ++-- drivers/staging/comedi/drivers/serial2002.c | 4 ++-- drivers/staging/comedi/drivers/vmk80xx.c | 8 ++++---- 22 files changed, 38 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index de8d74fc6335..d43129c9fda0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -66,8 +66,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; @@ -78,7 +77,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[2]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 1; s->maxdata = 0; s->len_chanlist = 1; diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index 55d00fd94c91..d8410415cc90 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -163,7 +163,7 @@ static int apci1516_auto_attach(struct comedi_device *dev, s = &dev->subdevices[1]; if (this_board->do_nchan) { s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = this_board->do_nchan; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index c328230b85ec..aa908a4a24cf 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -403,7 +403,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 32; s->maxdata = 1; s->range_table = &range_digital; @@ -431,7 +431,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 3; s->maxdata = 0; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 4162e2dc2860..a1248dab369f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -140,7 +140,7 @@ static int apci16xx_auto_attach(struct comedi_device *dev, for (i = 0; i < n_subdevs; i++) { s = &dev->subdevices[i]; s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_WRITEABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE; s->n_chan = ((i * 32) < board->n_chan) ? 32 : last; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index 7a5659fafbb3..fb20c5ea90b8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -267,7 +267,7 @@ static int apci2032_auto_attach(struct comedi_device *dev, /* Initialize the digital output subdevice */ s = &dev->subdevices[0]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 32; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index 51ab1f937bae..1f9d13661ac9 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -98,7 +98,7 @@ static int apci2200_auto_attach(struct comedi_device *dev, /* Initialize the digital output subdevice */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e5dbbdf33b40..e8da15cf4e2a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -192,7 +192,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, s = &dev->subdevices[1]; if (this_board->has_ao) { s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; s->maxdata = 0x3fff; s->range_table = &range_bipolar10; @@ -218,7 +218,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, /* Digital Output subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; @@ -227,7 +227,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, /* Timer subdevice */ s = &dev->subdevices[4]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE; s->n_chan = 1; s->maxdata = 0x00ffffff; s->insn_write = apci3120_write_insn_timer; diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 010efa3fed6c..992ac8ddbe64 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -357,7 +357,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, s = &dev->subdevices[0]; if (ao_n_chan) { s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = ao_n_chan; s->maxdata = 0x3fff; s->range_table = &apci3501_ao_range; @@ -383,7 +383,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, /* Initialize the digital output subdevice */ s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 1; s->range_table = &range_digital; @@ -392,7 +392,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, /* Initialize the timer/watchdog subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 1; s->maxdata = 0; s->len_chanlist = 1; diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index db3ee9c429ad..630d778df2c5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -849,7 +849,7 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, if (board->has_ao) { s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 4; s->maxdata = 0x0fff; s->range_table = &apci3xxx_ao_range; @@ -880,7 +880,7 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, if (board->has_dig_out) { s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; @@ -893,7 +893,7 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, if (board->has_ttl_io) { s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 24; s->maxdata = 1; s->io_bits = 0xff; /* channels 0-7 are always outputs */ diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/staging/comedi/drivers/addi_watchdog.c index 23031feaa095..0af141ab39fc 100644 --- a/drivers/staging/comedi/drivers/addi_watchdog.c +++ b/drivers/staging/comedi/drivers/addi_watchdog.c @@ -134,7 +134,7 @@ int addi_watchdog_init(struct comedi_subdevice *s, unsigned long iobase) spriv->iobase = iobase; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 1; s->maxdata = 0xff; s->insn_config = addi_watchdog_insn_config; diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 1610e2b406f3..1b54716994c5 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -241,7 +241,7 @@ static int pci1723_auto_attach(struct comedi_device *dev, s = &dev->subdevices[0]; dev->write_subdev = s; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; s->maxdata = 0xffff; s->len_chanlist = 8; diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index e03dd6e71415..e7cb7032a910 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -265,7 +265,7 @@ static int c6xdigio_attach(struct comedi_device *dev, s = &dev->subdevices[0]; /* pwm output subdevice */ s->type = COMEDI_SUBD_PWM; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 500; s->range_table = &range_unknown; diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 8c348bbf9e71..1b1399bcda5c 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -423,7 +423,7 @@ static int waveform_attach(struct comedi_device *dev, dev->write_subdev = s; /* analog output subdevice (loopback) */ s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = N_CHANS; s->maxdata = 0xffff; s->range_table = &waveform_ai_ranges; diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index ab6e40608885..f3909f3f755e 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -497,7 +497,7 @@ static int das6402_attach(struct comedi_device *dev, /* Analog Output subdevice */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = board->maxdata; s->range_table = &das6402_ao_ranges; @@ -520,7 +520,7 @@ static int das6402_attach(struct comedi_device *dev, /* Digital Input subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 8; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 77bb89fee327..06c601d8fdff 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -804,7 +804,7 @@ static int dt9812_auto_attach(struct comedi_device *dev, /* Digital Output subdevice */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 8; s->maxdata = 1; s->range_table = &range_digital; @@ -822,7 +822,7 @@ static int dt9812_auto_attach(struct comedi_device *dev, /* Analog Output subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 0x0fff; s->range_table = is_unipolar ? &range_unipolar2_5 : &range_bipolar10; diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 58a99e812818..0979f536ed39 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -689,7 +689,7 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev, s = &dev->subdevices[0]; dev->read_subdev = s; s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL | + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_CMD_READ; s->n_chan = 32; s->len_chanlist = 32; diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 728447123b4c..ae6ac49e730e 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1421,7 +1421,7 @@ static int me4000_auto_attach(struct comedi_device *dev, if (thisboard->ao_nchan) { s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_COMMON | SDF_GROUND; + s->subdev_flags = SDF_WRITABLE | SDF_COMMON | SDF_GROUND; s->n_chan = thisboard->ao_nchan; s->maxdata = 0xFFFF; /* 16 bit DAC */ s->range_table = &range_bipolar10; diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 00eaaf8ac148..9dec9c175877 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -511,7 +511,7 @@ static int me_auto_attach(struct comedi_device *dev, s = &dev->subdevices[1]; if (board->has_ao) { s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE | SDF_COMMON; s->n_chan = 4; s->maxdata = 0x0fff; s->len_chanlist = 4; @@ -528,7 +528,7 @@ static int me_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 32; s->maxdata = 1; s->len_chanlist = 32; diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/staging/comedi/drivers/ni_usb6501.c index df7ada8611f4..3b5a1b90366d 100644 --- a/drivers/staging/comedi/drivers/ni_usb6501.c +++ b/drivers/staging/comedi/drivers/ni_usb6501.c @@ -561,7 +561,7 @@ static int ni6501_auto_attach(struct comedi_device *dev, /* Counter subdevice */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL; s->n_chan = 1; s->maxdata = 0xffffffff; s->insn_read = ni6501_cnt_insn_read; diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index f6c678eef8d5..0630df367494 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -734,7 +734,7 @@ static int daqp_auto_attach(struct comedi_device *dev, s = &dev->subdevices[1]; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 0x0fff; s->range_table = &range_bipolar5; @@ -754,7 +754,7 @@ static int daqp_auto_attach(struct comedi_device *dev, s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 1; s->maxdata = 1; s->insn_bits = daqp_do_insn_bits; diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 167f82418cb4..71226ee9064e 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -742,7 +742,7 @@ static int serial2002_attach(struct comedi_device *dev, /* digital output subdevice */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 0; s->maxdata = 1; s->range_table = &range_digital; @@ -760,7 +760,7 @@ static int serial2002_attach(struct comedi_device *dev, /* analog output subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 0; s->maxdata = 1; s->range_table = NULL; diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index 71003416edcf..a19a56ee0eef 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c @@ -797,7 +797,7 @@ static int vmk80xx_init_subdevices(struct comedi_device *dev) /* Analog output subdevice */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND; s->n_chan = boardinfo->ao_nchans; s->maxdata = 0x00ff; s->range_table = boardinfo->range; @@ -819,7 +819,7 @@ static int vmk80xx_init_subdevices(struct comedi_device *dev) /* Digital output subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 8; s->maxdata = 1; s->range_table = &range_digital; @@ -834,7 +834,7 @@ static int vmk80xx_init_subdevices(struct comedi_device *dev) s->insn_read = vmk80xx_cnt_insn_read; s->insn_config = vmk80xx_cnt_insn_config; if (devpriv->model == VMK8055_MODEL) { - s->subdev_flags |= SDF_WRITEABLE; + s->subdev_flags |= SDF_WRITABLE; s->insn_write = vmk80xx_cnt_insn_write; } @@ -842,7 +842,7 @@ static int vmk80xx_init_subdevices(struct comedi_device *dev) if (devpriv->model == VMK8061_MODEL) { s = &dev->subdevices[5]; s->type = COMEDI_SUBD_PWM; - s->subdev_flags = SDF_READABLE | SDF_WRITEABLE; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = boardinfo->pwm_nchans; s->maxdata = boardinfo->pwm_maxdata; s->insn_read = vmk80xx_pwm_insn_read; -- cgit v1.2.3-59-g8ed1b From e00259182063cccbcee85315d978b8b93d5298e3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:19:35 -0700 Subject: staging: comedi: drivers: remove inappropriate SDF_* flags from subdevices The SDF_GROUND, SDF_COMMON, SDF_DIFF, and SDF_OTHER flags are only useful with the analog input and output subdevices. Remove these flags from the other subdevice types in the comedi drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 6 +++--- drivers/staging/comedi/drivers/addi_apci_3501.c | 2 +- drivers/staging/comedi/drivers/adv_pci1710.c | 4 ++-- drivers/staging/comedi/drivers/adv_pci_dio.c | 8 ++++---- drivers/staging/comedi/drivers/dyna_pci10xx.c | 4 ++-- drivers/staging/comedi/drivers/icp_multi.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index d43129c9fda0..30b132c3d092 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -54,7 +54,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[0]; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_READABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; @@ -66,7 +66,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; @@ -77,7 +77,7 @@ static int apci1500_auto_attach(struct comedi_device *dev, /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[2]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 1; s->maxdata = 0; s->len_chanlist = 1; diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 992ac8ddbe64..79245236be78 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -392,7 +392,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, /* Initialize the timer/watchdog subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 1; s->maxdata = 0; s->len_chanlist = 1; diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index c5422f376927..e05f4b5444e1 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1210,7 +1210,7 @@ static int pci1710_auto_attach(struct comedi_device *dev, if (this_board->n_dichan) { s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_READABLE; s->n_chan = this_board->n_dichan; s->maxdata = 1; s->len_chanlist = this_board->n_dichan; @@ -1222,7 +1222,7 @@ static int pci1710_auto_attach(struct comedi_device *dev, if (this_board->n_dochan) { s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE; s->n_chan = this_board->n_dochan; s->maxdata = 1; s->len_chanlist = this_board->n_dochan; diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index f2e2d7e163bf..09609d6d02da 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -930,7 +930,7 @@ static int pci1760_attach(struct comedi_device *dev) s = &dev->subdevices[0]; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_READABLE; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; @@ -939,7 +939,7 @@ static int pci1760_attach(struct comedi_device *dev) s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; @@ -978,7 +978,7 @@ static int pci_dio_add_di(struct comedi_device *dev, const struct dio_boardtype *this_board = dev->board_ptr; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags; + s->subdev_flags = SDF_READABLE | d->specflags; if (d->chans > 16) s->subdev_flags |= SDF_LSAMPL; s->n_chan = d->chans; @@ -1008,7 +1008,7 @@ static int pci_dio_add_do(struct comedi_device *dev, const struct dio_boardtype *this_board = dev->board_ptr; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE; if (d->chans > 16) s->subdev_flags |= SDF_LSAMPL; s->n_chan = d->chans; diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 608aee0c3a15..1b6324c6eb29 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -218,7 +218,7 @@ static int dyna_pci10xx_auto_attach(struct comedi_device *dev, /* digital input */ s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND; + s->subdev_flags = SDF_READABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; @@ -228,7 +228,7 @@ static int dyna_pci10xx_auto_attach(struct comedi_device *dev, /* digital output */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index f4e1c1cf4178..f9aa6a59c9a8 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -521,7 +521,7 @@ static int icp_multi_auto_attach(struct comedi_device *dev, s = &dev->subdevices[4]; s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 4; s->maxdata = 0xffff; s->len_chanlist = 4; -- cgit v1.2.3-59-g8ed1b From 453fd2b395799fa2e83e3e926ff7fee810d26f92 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:19:36 -0700 Subject: staging: comedi: drivers: digital output subdevices do not need SDF_READABLE The SDF_READABLE flag is not necessary for digital output subdevices. For consistency, remove this flag from the comedi drivers that set it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 2 +- drivers/staging/comedi/drivers/amplc_pc263.c | 2 +- drivers/staging/comedi/drivers/amplc_pci263.c | 2 +- drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +- drivers/staging/comedi/drivers/das08.c | 2 +- drivers/staging/comedi/drivers/das16m1.c | 2 +- drivers/staging/comedi/drivers/das1800.c | 2 +- drivers/staging/comedi/drivers/das800.c | 2 +- drivers/staging/comedi/drivers/icp_multi.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 18f5f7fc1bc8..1fd082bf757d 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -767,7 +767,7 @@ static int pci9111_auto_attach(struct comedi_device *dev, s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index f8e551d8fd9e..b1946ce6ecc1 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -83,7 +83,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it) s = &dev->subdevices[0]; /* digital output subdevice */ s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/staging/comedi/drivers/amplc_pci263.c index 2259bee98d48..0d2224b832ac 100644 --- a/drivers/staging/comedi/drivers/amplc_pci263.c +++ b/drivers/staging/comedi/drivers/amplc_pci263.c @@ -71,7 +71,7 @@ static int pci263_auto_attach(struct comedi_device *dev, s = &dev->subdevices[0]; /* digital output subdevice */ s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 9196680581b8..c8515d7f249b 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3868,7 +3868,7 @@ static int setup_subdevices(struct comedi_device *dev) if (thisboard->layout == LAYOUT_64XX) { s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index bdb671a66e22..cdf71f9f199c 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -507,7 +507,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) /* do */ if (thisboard->do_nchan) { s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = thisboard->do_nchan; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 54ccffca8497..80f41b7e8273 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -597,7 +597,7 @@ static int das16m1_attach(struct comedi_device *dev, s = &dev->subdevices[2]; /* do */ s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 246a18648223..bf8bfcf7034d 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1513,7 +1513,7 @@ static int das1800_attach(struct comedi_device *dev, /* do */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = thisboard->do_n_chan; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 6013099891c0..55bc494838b5 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -737,7 +737,7 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* Digital Output subdevice */ s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 4; s->maxdata = 1; s->range_table = &range_digital; diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index f9aa6a59c9a8..a412394bcdc9 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -512,7 +512,7 @@ static int icp_multi_auto_attach(struct comedi_device *dev, s = &dev->subdevices[3]; s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; -- cgit v1.2.3-59-g8ed1b From a7d3de75cf00574f8d360d51d0e1beb3c561cc89 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:21:54 -0700 Subject: staging: comedi: drivers do not need to reset the async->cur_chan The comedi core calls comedi_buf_reset() before starting an async command (*do_cmd) and after returning a subdevice to an idle state (*cancel). The drivers do not need to reset the async->cur_chan in those functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 -- drivers/staging/comedi/drivers/adl_pci9118.c | 2 -- drivers/staging/comedi/drivers/adv_pci1710.c | 2 -- drivers/staging/comedi/drivers/ni_atmio16d.c | 1 - drivers/staging/comedi/drivers/pcl812.c | 1 - drivers/staging/comedi/drivers/pcl816.c | 1 - drivers/staging/comedi/drivers/usbdux.c | 6 ------ drivers/staging/comedi/drivers/usbduxfast.c | 2 -- drivers/staging/comedi/drivers/usbduxsigma.c | 5 ----- 9 files changed, 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 975ee5fc93dc..6b65ce69c213 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -629,7 +629,6 @@ static int apci3120_cancel(struct comedi_device *dev, inb(dev->iobase + APCI3120_RESET_FIFO); inw(dev->iobase + APCI3120_RD_STATUS); devpriv->ui_AiActualScan = 0; - s->async->cur_chan = 0; devpriv->ui_DmaActualBuffer = 0; devpriv->ai_running = 0; @@ -758,7 +757,6 @@ static int apci3120_cyclic_ai(int mode, /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ devpriv->ui_AiActualScan = 0; - s->async->cur_chan = 0; devpriv->ui_DmaActualBuffer = 0; /* value for timer2 minus -2 has to be done */ diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index cb2c48522efd..83c381357c14 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -575,7 +575,6 @@ static int pci9118_ai_cancel(struct comedi_device *dev, devpriv->ai_act_scan = 0; devpriv->ai_act_dmapos = 0; - s->async->cur_chan = 0; s->async->inttrig = NULL; devpriv->ai_neverending = 0; devpriv->dma_actbuf = 0; @@ -1120,7 +1119,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_act_scan = 0; devpriv->ai_act_dmapos = 0; - s->async->cur_chan = 0; if (devpriv->usedma) { Compute_and_setup_dma(dev, s); diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index e05f4b5444e1..075df1ccb853 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -731,7 +731,6 @@ static int pci171x_ai_cancel(struct comedi_device *dev, } devpriv->ai_act_scan = 0; - s->async->cur_chan = 0; return 0; } @@ -931,7 +930,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outb(0, dev->iobase + PCI171x_CLRINT); devpriv->ai_act_scan = 0; - s->async->cur_chan = 0; devpriv->CntrlReg &= Control_CNT0; if ((cmd->flags & CMDF_WAKE_EOS) == 0) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 2bac69339202..d0ac49eaab06 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -300,7 +300,6 @@ static int atmio16d_ai_cmd(struct comedi_device *dev, * It is still uber-experimental */ reset_counters(dev); - s->async->cur_chan = 0; /* check if scanning multiple channels */ if (cmd->chanlist_len < 2) { diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index eef646253bf9..10886070f48c 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -809,7 +809,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_act_scan = 0; devpriv->ai_poll_ptr = 0; - s->async->cur_chan = 0; /* don't we want wake up every scan? */ if (cmd->flags & CMDF_WAKE_EOS) { diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index a471c3df12b4..053eed047490 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -509,7 +509,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) udelay(1); devpriv->ai_act_scan = 0; - s->async->cur_chan = 0; devpriv->ai_cmd_running = 1; devpriv->ai_poll_ptr = 0; devpriv->ai_cmd_canceled = 0; diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 579e6bce529d..40f5cd03651d 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -698,9 +698,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->ai_cmd_running) goto ai_cmd_exit; - /* set current channel of the running acquisition to zero */ - s->async->cur_chan = 0; - devpriv->dux_commands[1] = len; for (i = 0; i < len; ++i) { unsigned int chan = CR_CHAN(cmd->chanlist[i]); @@ -996,9 +993,6 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->ao_cmd_running) goto ao_cmd_exit; - /* set current channel of the running acquisition to zero */ - s->async->cur_chan = 0; - /* we count in steps of 1ms (125us) */ /* 125us mode not used yet */ if (0) { /* (devpriv->high_speed) */ diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 70ec2f552dfc..3bc9013006a0 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -479,8 +479,6 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, up(&devpriv->sem); return -EBUSY; } - /* set current channel of the running acquisition to zero */ - s->async->cur_chan = 0; /* * ignore the first buffers from the device if there diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 7b7698c3ccd2..9ee6e0a78578 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -689,8 +689,6 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev, down(&devpriv->sem); - /* set current channel of the running acquisition to zero */ - s->async->cur_chan = 0; for (i = 0; i < len; i++) { unsigned int chan = CR_CHAN(cmd->chanlist[i]); @@ -988,9 +986,6 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev, down(&devpriv->sem); - /* set current channel of the running acquisition to zero */ - s->async->cur_chan = 0; - devpriv->ao_counter = devpriv->ao_timer; if (cmd->start_src == TRIG_NOW) { -- cgit v1.2.3-59-g8ed1b From 0c8c1c0ad8edce6c0d0a7d78b5ab6cb2ee4722f1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:32:28 -0700 Subject: staging: comedi: rtd520: fix ai_read_n() async->cur_chan use This functions uses the async->cur_chan to determine if the current channel is using a bipolar range and the sample needs to be munged. The cur_chan is never incremented so all the samples are munged based on the fist channel in the cmd->chanlist. Bump the cur_chan after writing each sample. This fixes the code so that the munging will be done correctly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 888238e26073..8e87655be7bb 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -606,6 +606,8 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, int count) { struct rtd_private *devpriv = dev->private; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; int ii; for (ii = 0; ii < count; ii++) { @@ -618,7 +620,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, d = readw(devpriv->las1 + LAS1_ADC_FIFO); d = d >> 3; /* low 3 bits are marker lines */ - if (test_bit(s->async->cur_chan, devpriv->chan_is_bipolar)) + if (test_bit(async->cur_chan, devpriv->chan_is_bipolar)) /* convert to comedi unsigned data */ d = comedi_offset_munge(s, d); d &= s->maxdata; @@ -626,6 +628,9 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, if (!comedi_buf_write_samples(s, &d, 1)) return -1; + async->cur_chan++; + async->cur_chan %= cmd->chanlist_len; + if (devpriv->ai_count > 0) /* < 0, means read forever */ devpriv->ai_count--; } -- cgit v1.2.3-59-g8ed1b From c234566f776464594f6b73022497d4f5efd83e46 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 30 Oct 2014 11:32:29 -0700 Subject: staging: comedi: rtd520: remove private data 'chan_is_bipolar' member Currently this driver uses a bitmap in the private data to keep track of the unipolar/bipolar range for each channel. This is needed to determine if the data needs to be munged for bipolar samples. Remove this member from the private data and use the comedi core helper function comedi_range_is_bipolar() to determine if the data needs to be munged. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 8e87655be7bb..19596756864d 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -379,7 +379,6 @@ struct rtd_private { long ai_count; /* total transfer size (samples) */ int xfer_count; /* # to transfer data. 0->1/2FIFO */ int flags; /* flag event modes */ - DECLARE_BITMAP(chan_is_bipolar, RTD_MAX_CHANLIST); unsigned fifosz; }; @@ -438,7 +437,6 @@ static unsigned short rtd_convert_chan_gain(struct comedi_device *dev, unsigned int chanspec, int index) { const struct rtd_boardinfo *board = dev->board_ptr; - struct rtd_private *devpriv = dev->private; unsigned int chan = CR_CHAN(chanspec); unsigned int range = CR_RANGE(chanspec); unsigned int aref = CR_AREF(chanspec); @@ -451,17 +449,14 @@ static unsigned short rtd_convert_chan_gain(struct comedi_device *dev, /* +-5 range */ r |= 0x000; r |= (range & 0x7) << 4; - __set_bit(index, devpriv->chan_is_bipolar); } else if (range < board->range_uni10) { /* +-10 range */ r |= 0x100; r |= ((range - board->range_bip10) & 0x7) << 4; - __set_bit(index, devpriv->chan_is_bipolar); } else { /* +10 range */ r |= 0x200; r |= ((range - board->range_uni10) & 0x7) << 4; - __clear_bit(index, devpriv->chan_is_bipolar); } switch (aref) { @@ -561,6 +556,7 @@ static int rtd_ai_rinsn(struct comedi_device *dev, unsigned int *data) { struct rtd_private *devpriv = dev->private; + unsigned int range = CR_RANGE(insn->chanspec); int ret; int n; @@ -586,9 +582,11 @@ static int rtd_ai_rinsn(struct comedi_device *dev, /* read data */ d = readw(devpriv->las1 + LAS1_ADC_FIFO); d = d >> 3; /* low 3 bits are marker lines */ - if (test_bit(0, devpriv->chan_is_bipolar)) - /* convert to comedi unsigned data */ + + /* convert bipolar data to comedi unsigned data */ + if (comedi_range_is_bipolar(s, range)) d = comedi_offset_munge(s, d); + data[n] = d & s->maxdata; } @@ -611,6 +609,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, int ii; for (ii = 0; ii < count; ii++) { + unsigned int range = CR_RANGE(cmd->chanlist[async->cur_chan]); unsigned short d; if (0 == devpriv->ai_count) { /* done */ @@ -620,8 +619,9 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, d = readw(devpriv->las1 + LAS1_ADC_FIFO); d = d >> 3; /* low 3 bits are marker lines */ - if (test_bit(async->cur_chan, devpriv->chan_is_bipolar)) - /* convert to comedi unsigned data */ + + /* convert bipolar data to comedi unsigned data */ + if (comedi_range_is_bipolar(s, range)) d = comedi_offset_munge(s, d); d &= s->maxdata; -- cgit v1.2.3-59-g8ed1b From cf5d2af6839deb2e7765648ce139dc9677db0c18 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Oct 2014 14:32:27 +0000 Subject: staging: comedi: icp_multi: correct insn_bits returned data for DO For some unfathomable reason, the Comedi `insn_bits` handler for the digital output subdevice (`icp_multi_insn_bits_do()`) writes the digital output register and reads back the unrelated digital input register. Read back the current state of the outputs (held in `s->state`) instead. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/icp_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index a412394bcdc9..fbbcab20a48b 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -53,7 +53,7 @@ Configuration options: not applicable, uses PCI auto config #define ICP_MULTI_AI 2 /* R: Analogue input data */ #define ICP_MULTI_DAC_CSR 4 /* R/W: DAC command/status register */ #define ICP_MULTI_AO 6 /* R/W: Analogue output data */ -#define ICP_MULTI_DI 8 /* R/W: Digital inouts */ +#define ICP_MULTI_DI 8 /* R/W: Digital inputs */ #define ICP_MULTI_DO 0x0A /* R/W: Digital outputs */ #define ICP_MULTI_INT_EN 0x0C /* R/W: Interrupt enable register */ #define ICP_MULTI_INT_STAT 0x0E /* R/W: Interrupt status register */ @@ -319,7 +319,7 @@ static int icp_multi_insn_bits_do(struct comedi_device *dev, if (comedi_dio_update_state(s, data)) writew(s->state, dev->mmio + ICP_MULTI_DO); - data[1] = readw(dev->mmio + ICP_MULTI_DI); + data[1] = s->state; return insn->n; } -- cgit v1.2.3-59-g8ed1b From c1b617e017f858505ce639a8dee4d096fbcb7b6b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 09:49:30 -0700 Subject: staging: comedi: ni_mio_common: remove unused variable in ni_ao_fifo_load() The local variable 'range' 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/ni_mio_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index fd61d24bc3a4..32236ef587f5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1131,14 +1131,11 @@ static void ni_ao_fifo_load(struct comedi_device *dev, int i; unsigned short d; u32 packed_data; - int range; chan = async->cur_chan; for (i = 0; i < n; i++) { comedi_buf_read_samples(s, &d, 1); - range = CR_RANGE(cmd->chanlist[chan]); - if (devpriv->is_6xxx) { packed_data = d & 0xffff; /* 6711 only has 16 bit wide ao fifo */ -- cgit v1.2.3-59-g8ed1b From f8736ca466e2014d6e8bad478fcc5e5cb0105af0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 09:49:31 -0700 Subject: staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the core The commedi_async 'cur_chan' member is used to track the current position in the chanlist for a scan. Currently only a couple comedi drivers use this member. For aeshtetics, move the 'cur_chan' tracking into the core for non-SDF_PACKED subdevices. The 'cur_chan' will be updated after reading or writing samples to the async buffer by comedi_inc_scan_progress(). All non-SDF_PACKED subdevices will then automatiaclly track the 'cur_chan'. Some of the drivers use the 'cur_chan' to detect the end of scan event when counting scans. The COMEDI_CB_EOS event is automatically added by the core when the end of scan is detected. The drivers just need to check if the 'cur_chan' is 0 to count the number of scans completed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 7 +++++++ drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 -- drivers/staging/comedi/drivers/adl_pci9118.c | 8 ++------ drivers/staging/comedi/drivers/adv_pci1710.c | 11 +---------- drivers/staging/comedi/drivers/ni_mio_common.c | 8 -------- drivers/staging/comedi/drivers/pcl812.c | 13 ++++--------- drivers/staging/comedi/drivers/pcl816.c | 6 +----- drivers/staging/comedi/drivers/pcl818.c | 6 +----- drivers/staging/comedi/drivers/rtd520.c | 3 --- 9 files changed, 16 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index ff2df8587eca..9c55dc759af8 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -341,8 +341,15 @@ void comedi_inc_scan_progress(struct comedi_subdevice *s, unsigned int num_bytes) { struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; unsigned int scan_length = comedi_bytes_per_scan(s); + /* track the 'cur_chan' for non-SDF_PACKED subdevices */ + if (!(s->subdev_flags & SDF_PACKED)) { + async->cur_chan += comedi_bytes_to_samples(s, num_bytes); + async->cur_chan %= cmd->chanlist_len; + } + async->scan_progress += num_bytes; if (async->scan_progress >= scan_length) { async->scan_progress %= scan_length; diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 6b65ce69c213..facd2c4b922d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1167,8 +1167,6 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, devpriv->ui_AiActualScan += (s->async->cur_chan + num_samples) / cmd->scan_end_arg; - s->async->cur_chan += num_samples; - s->async->cur_chan %= cmd->scan_end_arg; comedi_buf_write_samples(s, dma_buffer, num_samples); } diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 83c381357c14..93b41e6712a6 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -483,8 +483,6 @@ static void move_block_from_dma(struct comedi_device *dev, num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples); devpriv->ai_act_scan += (s->async->cur_chan + num_samples) / cmd->scan_end_arg; - s->async->cur_chan += num_samples; - s->async->cur_chan %= cmd->scan_end_arg; comedi_buf_write_samples(s, dma_buffer, num_samples); } @@ -612,10 +610,8 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, sampl = inl(dev->iobase + PCI9118_AI_FIFO_REG); comedi_buf_write_samples(s, &sampl, 1); - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->scan_end_arg) { - /* one scan done */ - s->async->cur_chan %= cmd->scan_end_arg; + + if (s->async->cur_chan == 0) { devpriv->ai_act_scan++; if (!devpriv->ai_neverending) { /* all data sampled? */ diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 075df1ccb853..420554f79b02 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -772,11 +772,6 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, val &= s->maxdata; comedi_buf_write_samples(s, &val, 1); - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->chanlist_len) - s->async->cur_chan = 0; - - if (s->async->cur_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; if (cmd->stop_src == TRIG_COUNT && @@ -800,7 +795,6 @@ static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s, int n, int turn) { struct pci1710_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; unsigned int val; int ret; int i; @@ -817,11 +811,8 @@ static int move_block_from_fifo(struct comedi_device *dev, val &= s->maxdata; comedi_buf_write_samples(s, &val, 1); - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->chanlist_len) { - s->async->cur_chan = 0; + if (s->async->cur_chan == 0) devpriv->ai_act_scan++; - } } return 0; } diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 32236ef587f5..2dfd95126fa3 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1125,14 +1125,10 @@ static void ni_ao_fifo_load(struct comedi_device *dev, struct comedi_subdevice *s, int n) { struct ni_private *devpriv = dev->private; - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; - int chan; int i; unsigned short d; u32 packed_data; - chan = async->cur_chan; for (i = 0; i < n; i++) { comedi_buf_read_samples(s, &d, 1); @@ -1141,7 +1137,6 @@ static void ni_ao_fifo_load(struct comedi_device *dev, /* 6711 only has 16 bit wide ao fifo */ if (!devpriv->is_6711) { comedi_buf_read_samples(s, &d, 1); - chan++; i++; packed_data |= (d << 16) & 0xffff0000; } @@ -1149,10 +1144,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, } else { ni_writew(dev, d, DAC_FIFO_Data); } - chan++; - chan %= cmd->chanlist_len; } - async->cur_chan = chan; } /* diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 10886070f48c..b13e9fb7a12e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -843,12 +843,8 @@ static bool pcl812_ai_next_chan(struct comedi_device *dev, struct pcl812_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->chanlist_len) { - s->async->cur_chan = 0; + if (s->async->cur_chan == 0) devpriv->ai_act_scan++; - s->async->events |= COMEDI_CB_EOS; - } if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan >= cmd->stop_arg) { @@ -864,6 +860,7 @@ static void pcl812_handle_eoc(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; + unsigned int chan = s->async->cur_chan; unsigned int next_chan; unsigned short val; @@ -877,10 +874,8 @@ static void pcl812_handle_eoc(struct comedi_device *dev, comedi_buf_write_samples(s, &val, 1); /* Set up next channel. Added by abbotti 2010-01-20, but untested. */ - next_chan = s->async->cur_chan + 1; - if (next_chan >= cmd->chanlist_len) - next_chan = 0; - if (cmd->chanlist[s->async->cur_chan] != cmd->chanlist[next_chan]) + next_chan = s->async->cur_chan; + if (cmd->chanlist[chan] != cmd->chanlist[next_chan]) pcl812_ai_set_chan_range(dev, cmd->chanlist[next_chan], 0); pcl812_ai_next_chan(dev, s); diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 053eed047490..7cdb79826213 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -289,12 +289,8 @@ static bool pcl816_ai_next_chan(struct comedi_device *dev, struct pcl816_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->chanlist_len) { - s->async->cur_chan = 0; + if (s->async->cur_chan == 0) devpriv->ai_act_scan++; - s->async->events |= COMEDI_CB_EOS; - } if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan >= cmd->stop_arg) { diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index e6d897bf5714..dc2715ae6b18 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -525,12 +525,8 @@ static bool pcl818_ai_next_chan(struct comedi_device *dev, if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len) devpriv->act_chanlist_pos = 0; - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->chanlist_len) { - s->async->cur_chan = 0; + if (s->async->cur_chan == 0) devpriv->ai_act_scan--; - s->async->events |= COMEDI_CB_EOS; - } if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan == 0) { /* all data sampled */ diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 19596756864d..fb71fd60bc4e 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -628,9 +628,6 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, if (!comedi_buf_write_samples(s, &d, 1)) return -1; - async->cur_chan++; - async->cur_chan %= cmd->chanlist_len; - if (devpriv->ai_count > 0) /* < 0, means read forever */ devpriv->ai_count--; } -- cgit v1.2.3-59-g8ed1b From 272fe8f51fd8b8cd1637c8d2ca868cbff725405e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 09:49:32 -0700 Subject: staging: comedi: amplc_pci230: remove private data 'ai_scan_pos' This member of the private data is replicating what the comedi_async 'cur_chan' member is used for. Use that instead and remove the private data member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 44c967f43d9a..a46fffd28a3e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -491,7 +491,6 @@ struct pci230_private { spinlock_t ao_stop_spinlock; /* Spin lock for stopping AO command */ unsigned long daqio; /* PCI230's DAQ I/O space */ unsigned int ai_scan_count; /* Number of AI scans remaining */ - unsigned int ai_scan_pos; /* Current position within AI scan */ unsigned int ao_scan_count; /* Number of AO scans remaining. */ int intr_cpuid; /* ID of CPU running ISR */ unsigned short hwver; /* Hardware version (for '+' models) */ @@ -1748,13 +1747,13 @@ static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev, unsigned short adccon; if (cmd->flags & CMDF_WAKE_EOS) - wake = scanlen - devpriv->ai_scan_pos; + wake = scanlen - s->async->cur_chan; else if (cmd->stop_src != TRIG_COUNT || devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL || scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL) wake = PCI230_ADC_FIFOLEVEL_HALFFULL; else - wake = devpriv->ai_scan_count * scanlen - devpriv->ai_scan_pos; + wake = devpriv->ai_scan_count * scanlen - s->async->cur_chan; if (wake >= PCI230_ADC_FIFOLEVEL_HALFFULL) { triglev = PCI230_ADC_INT_FIFO_HALF; } else if (wake > 1 && devpriv->hwver > 0) { @@ -2064,7 +2063,7 @@ static void pci230_handle_ai(struct comedi_device *dev, scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL) { todo = PCI230_ADC_FIFOLEVEL_HALFFULL; } else { - todo = devpriv->ai_scan_count * scanlen - devpriv->ai_scan_pos; + todo = devpriv->ai_scan_count * scanlen - async->cur_chan; if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL) todo = PCI230_ADC_FIFOLEVEL_HALFFULL; } @@ -2105,13 +2104,8 @@ static void pci230_handle_ai(struct comedi_device *dev, comedi_buf_write_samples(s, &val, 1); fifoamount--; - devpriv->ai_scan_pos++; - if (devpriv->ai_scan_pos == scanlen) { - /* End of scan. */ - devpriv->ai_scan_pos = 0; + if (async->cur_chan == 0) devpriv->ai_scan_count--; - async->events |= COMEDI_CB_EOS; - } } if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) { /* End of acquisition. */ @@ -2158,7 +2152,6 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EBUSY; devpriv->ai_scan_count = cmd->stop_arg; - devpriv->ai_scan_pos = 0; /* Position within scan. */ /* * Steps: -- cgit v1.2.3-59-g8ed1b From c39e050d21d107d26183be0f22b89eccccdbe61c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:28 -0700 Subject: staging: comedi: remove use of 'bytes_per_sample()' This inline helper function has been replaced with comedi_bytes_per_sample(). The same commit (bf33eb4b4f57) introduced a couple other related helper functions a manipulate the sample size. Use the new helper functions to remove the use of 'bytes_per_sample()' and remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 14 +++++++++----- drivers/staging/comedi/comedi_fops.c | 2 +- drivers/staging/comedi/comedidev.h | 6 ------ drivers/staging/comedi/drivers.c | 4 ++-- drivers/staging/comedi/drivers/cb_pcidas.c | 2 +- drivers/staging/comedi/drivers/cb_pcidas64.c | 6 +++--- drivers/staging/comedi/drivers/das16.c | 2 +- drivers/staging/comedi/drivers/dt282x.c | 4 ++-- drivers/staging/comedi/drivers/ni_mio_common.c | 8 ++++---- drivers/staging/comedi/drivers/usbduxfast.c | 4 ++-- 10 files changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index b43424d611ad..eb3fecf85b6d 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -283,7 +283,7 @@ static unsigned int comedi_buf_munge(struct comedi_subdevice *s, { struct comedi_async *async = s->async; unsigned int count = 0; - const unsigned num_sample_bytes = bytes_per_sample(s); + const unsigned num_sample_bytes = comedi_bytes_per_sample(s); if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) { async->munge_count += num_bytes; @@ -489,7 +489,8 @@ unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, * If not, clamp the nsamples to the number that will fit, flag the * buffer overrun and add the samples that fit. */ - max_samples = comedi_buf_write_n_available(s) / bytes_per_sample(s); + max_samples = comedi_bytes_to_samples(s, + comedi_buf_write_n_available(s)); if (nsamples > max_samples) { dev_warn(s->device->class_dev, "buffer overrun\n"); s->async->events |= COMEDI_CB_OVERFLOW; @@ -499,7 +500,8 @@ unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, if (nsamples == 0) return 0; - nbytes = comedi_buf_write_alloc(s, nsamples * bytes_per_sample(s)); + nbytes = comedi_buf_write_alloc(s, + comedi_samples_to_bytes(s, nsamples)); comedi_buf_memcpy_to(s, data, nbytes); comedi_buf_write_free(s, nbytes); comedi_inc_scan_progress(s, nbytes); @@ -527,14 +529,16 @@ unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, unsigned int nbytes; /* clamp nsamples to the number of full samples available */ - max_samples = comedi_buf_read_n_available(s) / bytes_per_sample(s); + max_samples = comedi_bytes_to_samples(s, + comedi_buf_read_n_available(s)); if (nsamples > max_samples) nsamples = max_samples; if (nsamples == 0) return 0; - nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s)); + nbytes = comedi_buf_read_alloc(s, + comedi_samples_to_bytes(s, nsamples)); comedi_buf_memcpy_from(s, data, nbytes); comedi_buf_read_free(s, nbytes); comedi_inc_scan_progress(s, nbytes); diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 704ae25c5710..65894fd8b67b 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2024,7 +2024,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) s = comedi_write_subdevice(dev, minor); if (s && s->async) { - unsigned int bps = bytes_per_sample(s); + unsigned int bps = comedi_bytes_per_sample(s); poll_wait(file, &s->async->wait_head, wait); comedi_buf_write_alloc(s, s->async->prealloc_bufsz); diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d18f70203422..90af11aaef7e 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -427,12 +427,6 @@ static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice *s) return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short); } -/* to be removed */ -static inline unsigned int bytes_per_sample(struct comedi_subdevice *s) -{ - return comedi_bytes_per_sample(s); -} - /** * comedi_sample_shift - determine log2 of subdevice sample size * @s: comedi_subdevice struct diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 9c55dc759af8..9a8c5fc8e8fe 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -316,14 +316,14 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) case COMEDI_SUBD_DI: case COMEDI_SUBD_DO: case COMEDI_SUBD_DIO: - bits_per_sample = 8 * bytes_per_sample(s); + bits_per_sample = 8 * comedi_bytes_per_sample(s); num_samples = DIV_ROUND_UP(cmd->chanlist_len, bits_per_sample); break; default: num_samples = cmd->chanlist_len; break; } - return num_samples * bytes_per_sample(s); + return comedi_samples_to_bytes(s, num_samples); } EXPORT_SYMBOL_GPL(comedi_bytes_per_scan); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 53afae093c4c..1c38cd5f846c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1146,7 +1146,7 @@ static void cb_pcidas_ao_load_fifo(struct comedi_device *dev, nsamples = devpriv->ao_count; nbytes = comedi_buf_read_samples(s, devpriv->ao_buffer, nsamples); - nsamples = nbytes / bytes_per_sample(s); + nsamples = comedi_bytes_to_samples(s, nbytes); if (cmd->stop_src == TRIG_COUNT) devpriv->ao_count -= nsamples; diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index c8515d7f249b..d7b61ba6b284 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2923,14 +2923,14 @@ static unsigned int cb_pcidas64_ao_fill_buffer(struct comedi_device *dev, { struct pcidas64_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int nsamples = max_bytes / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, max_bytes); unsigned int actual_bytes; if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples) nsamples = devpriv->ao_count; actual_bytes = comedi_buf_read_samples(s, dest, nsamples); - nsamples = actual_bytes / bytes_per_sample(s); + nsamples = comedi_bytes_to_samples(s, actual_bytes); if (cmd->stop_src == TRIG_COUNT) devpriv->ao_count -= nsamples; @@ -2954,7 +2954,7 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev, if (nsamples == 0) return 0; - nbytes = nsamples * bytes_per_sample(s); + nbytes = comedi_samples_to_bytes(s, nsamples); devpriv->ao_dma_desc[buffer_index].transfer_size = cpu_to_le32(nbytes); /* set end of chain bit so we catch underruns */ next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next); diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 8e512b241653..26f54aa9d41c 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -584,7 +584,7 @@ static void das16_interrupt(struct comedi_device *dev) spin_unlock_irqrestore(&dev->spinlock, spin_flags); - nsamples = num_bytes / bytes_per_sample(s); + nsamples = comedi_bytes_to_samples(s, num_bytes); comedi_buf_write_samples(s, devpriv->dma_buffer[buffer_index], nsamples); diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 1d9fa371d03c..674e03eb1601 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -455,7 +455,7 @@ static unsigned int dt282x_ao_setup_dma(struct comedi_device *dev, { struct dt282x_private *devpriv = dev->private; void *ptr = devpriv->dma[cur_dma].buf; - unsigned int nsamples = devpriv->dma_maxsize / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, devpriv->dma_maxsize); unsigned int nbytes; nbytes = comedi_buf_read_samples(s, ptr, nsamples); @@ -491,7 +491,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev, int cur_dma = devpriv->current_dma_index; void *ptr = devpriv->dma[cur_dma].buf; int size = devpriv->dma[cur_dma].size; - unsigned int nsamples = size / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, size); int ret; outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE, diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2dfd95126fa3..63312ff42b35 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1618,12 +1618,12 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, struct ni_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned int length = num_bytes / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, num_bytes); unsigned short *array = data; unsigned int *larray = data; unsigned int i; - for (i = 0; i < length; i++) { + for (i = 0; i < nsamples; i++) { #ifdef PCIDMA if (s->subdev_flags & SDF_LSAMPL) larray[i] = le32_to_cpu(larray[i]); @@ -2732,11 +2732,11 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int chan_index) { struct comedi_cmd *cmd = &s->async->cmd; - unsigned int length = num_bytes / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, num_bytes); unsigned short *array = data; unsigned int i; - for (i = 0; i < length; i++) { + for (i = 0; i < nsamples; i++) { unsigned int range = CR_RANGE(cmd->chanlist[chan_index]); unsigned short val = array[i]; diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 3bc9013006a0..5de76aba8fd9 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -248,9 +248,9 @@ static void usbduxfast_ai_handle_urb(struct comedi_device *dev, if (devpriv->ignore) { devpriv->ignore--; } else { - unsigned int nbytes = urb->actual_length; - unsigned int nsamples = nbytes / bytes_per_sample(s); + unsigned int nsamples; + nsamples = comedi_bytes_to_samples(s, urb->actual_length); if (cmd->stop_src == TRIG_COUNT) { if (devpriv->ai_sample_count < nsamples) { nsamples = devpriv->ai_sample_count; -- cgit v1.2.3-59-g8ed1b From 836b571df7bc0bd921c503d467fd6b6d002457ec Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:29 -0700 Subject: staging: comedi: ni_mio_common: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 37 +++++++++++++++----------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 63312ff42b35..97869ce463b7 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1167,19 +1167,20 @@ static int ni_ao_fifo_half_empty(struct comedi_device *dev, struct comedi_subdevice *s) { const struct ni_board_struct *board = dev->board_ptr; - int n; + unsigned int nbytes; + unsigned int nsamples; - n = comedi_buf_read_n_available(s); - if (n == 0) { + nbytes = comedi_buf_read_n_available(s); + if (nbytes == 0) { s->async->events |= COMEDI_CB_OVERFLOW; return 0; } - n /= sizeof(short); - if (n > board->ao_fifo_depth / 2) - n = board->ao_fifo_depth / 2; + nsamples = comedi_bytes_to_samples(s, nbytes); + if (nsamples > board->ao_fifo_depth / 2) + nsamples = board->ao_fifo_depth / 2; - ni_ao_fifo_load(dev, s, n); + ni_ao_fifo_load(dev, s, nsamples); return 1; } @@ -1189,7 +1190,8 @@ static int ni_ao_prep_fifo(struct comedi_device *dev, { const struct ni_board_struct *board = dev->board_ptr; struct ni_private *devpriv = dev->private; - int n; + unsigned int nbytes; + unsigned int nsamples; /* reset fifo */ ni_stc_writew(dev, 1, DAC_FIFO_Clear); @@ -1197,17 +1199,17 @@ static int ni_ao_prep_fifo(struct comedi_device *dev, ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); /* load some data */ - n = comedi_buf_read_n_available(s); - if (n == 0) + nbytes = comedi_buf_read_n_available(s); + if (nbytes == 0) return 0; - n /= sizeof(short); - if (n > board->ao_fifo_depth) - n = board->ao_fifo_depth; + nsamples = comedi_bytes_to_samples(s, nbytes); + if (nsamples > board->ao_fifo_depth) + nsamples = board->ao_fifo_depth; - ni_ao_fifo_load(dev, s, n); + ni_ao_fifo_load(dev, s, nsamples); - return n; + return nsamples; } static void ni_ai_fifo_read(struct comedi_device *dev, @@ -2951,12 +2953,15 @@ static int ni_ao_insn_config(struct comedi_device *dev, { const struct ni_board_struct *board = dev->board_ptr; struct ni_private *devpriv = dev->private; + unsigned int nbytes; switch (data[0]) { case INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: switch (data[1]) { case COMEDI_OUTPUT: - data[2] = 1 + board->ao_fifo_depth * sizeof(short); + nbytes = comedi_samples_to_bytes(s, + board->ao_fifo_depth); + data[2] = 1 + nbytes; if (devpriv->mite) data[2] += devpriv->mite->fifo_size; break; -- cgit v1.2.3-59-g8ed1b From 5035a96f3640ee4705f69287726bfcc598212717 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:30 -0700 Subject: staging: comedi: das1800: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index bf8bfcf7034d..03b1ff9de92c 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -535,7 +535,7 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, /* figure out how many points to read */ num_bytes = devpriv->dma_transfer_size - get_dma_residue(channel); - num_samples = num_bytes / sizeof(short); + num_samples = comedi_bytes_to_samples(s, num_bytes); /* if we only need some of the points */ if (cmd->stop_src == TRIG_COUNT && devpriv->count < num_samples) -- cgit v1.2.3-59-g8ed1b From bd508fffda8fc3dbcabab9bc31817c588f7938c2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:31 -0700 Subject: staging: comedi: das16: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 26f54aa9d41c..8de27053666f 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -863,8 +863,9 @@ static void das16_ai_munge(struct comedi_device *dev, unsigned int num_bytes, unsigned int start_chan_index) { - unsigned int i, num_samples = num_bytes / sizeof(short); unsigned short *data = array; + unsigned int num_samples = comedi_bytes_to_samples(s, num_bytes); + unsigned int i; for (i = 0; i < num_samples; i++) { data[i] = le16_to_cpu(data[i]); -- cgit v1.2.3-59-g8ed1b From b7f9eb054994dbbceb40d376ad6f5701d9d31b4d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:32 -0700 Subject: staging: comedi: adv_pci1710: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 420554f79b02..107a0f137eaf 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -823,7 +823,8 @@ static void pci1710_handle_fifo(struct comedi_device *dev, const struct boardtype *this_board = dev->board_ptr; struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int m, samplesinbuf; + unsigned int nsamples; + unsigned int m; m = inw(dev->iobase + PCI171x_STATUS); if (!(m & Status_FH)) { @@ -840,16 +841,16 @@ static void pci1710_handle_fifo(struct comedi_device *dev, return; } - samplesinbuf = this_board->fifo_half_size; - if (samplesinbuf * sizeof(short) >= s->async->prealloc_bufsz) { - m = s->async->prealloc_bufsz / sizeof(short); + nsamples = this_board->fifo_half_size; + if (comedi_samples_to_bytes(s, nsamples) >= s->async->prealloc_bufsz) { + m = comedi_bytes_to_samples(s, s->async->prealloc_bufsz); if (move_block_from_fifo(dev, s, m, 0)) return; - samplesinbuf -= m; + nsamples -= m; } - if (samplesinbuf) { - if (move_block_from_fifo(dev, s, samplesinbuf, 1)) + if (nsamples) { + if (move_block_from_fifo(dev, s, nsamples, 1)) return; } -- cgit v1.2.3-59-g8ed1b From 1d3d32a7525bbc9c989f8c3e592dc206ee8b145a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:33 -0700 Subject: staging: comedi: adl_pci9118: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 93b41e6712a6..2aef881b6ee4 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -586,8 +586,9 @@ static void pci9118_ai_munge(struct comedi_device *dev, unsigned int start_chan_index) { struct pci9118_private *devpriv = dev->private; - unsigned int i, num_samples = num_bytes / sizeof(short); unsigned short *array = data; + unsigned int num_samples = comedi_bytes_to_samples(s, num_bytes); + unsigned int i; for (i = 0; i < num_samples; i++) { if (devpriv->usedma) -- cgit v1.2.3-59-g8ed1b From 287a143ab42b8d2aa3421e70192895188a23dd3e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:34 -0700 Subject: staging: comedi: adl_pci9111: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 1fd082bf757d..47934c938a4b 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -452,7 +452,7 @@ static void pci9111_ai_munge(struct comedi_device *dev, unsigned int maxdata = s->maxdata; unsigned int invert = (maxdata + 1) >> 1; unsigned int shift = (maxdata == 0xffff) ? 0 : 4; - unsigned int num_samples = num_bytes / sizeof(short); + unsigned int num_samples = comedi_bytes_to_samples(s, num_bytes); unsigned int i; for (i = 0; i < num_samples; i++) @@ -501,7 +501,7 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, if (to_read > samples - pos) to_read = samples - pos; - total += to_read * sizeof(short); + total += comedi_samples_to_bytes(s, to_read); } pos += to_read; @@ -513,7 +513,7 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, } } - devpriv->stop_counter -= total / sizeof(short); + devpriv->stop_counter -= comedi_bytes_to_samples(s, total); } static irqreturn_t pci9111_interrupt(int irq, void *p_device) -- cgit v1.2.3-59-g8ed1b From 14f7b68058184910794a9f54898e8228855f50f0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:35 -0700 Subject: staging: comedi: hwdrv_apci3120: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index facd2c4b922d..917076632433 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -947,7 +947,9 @@ static int apci3120_cyclic_ai(int mode, /* If DMA Enabled */ struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0]; struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1]; - unsigned int scan_bytes = cmd->scan_end_arg * sizeof(short); + unsigned int scan_bytes; + + scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg); devpriv->b_InterruptMode = APCI3120_DMA_MODE; -- cgit v1.2.3-59-g8ed1b From 26561101b8c82a9eaf5656e3109b0d94f790fcdb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 31 Oct 2014 12:04:36 -0700 Subject: staging: comedi: ni_at_a2150: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 5c17def29f8d..69e543a0bf22 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -168,7 +168,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d) struct comedi_cmd *cmd; unsigned int max_points, num_points, residue, leftover; unsigned short dpnt; - static const int sample_size = sizeof(devpriv->dma_buffer[0]); if (!dev->attached) { dev_err(dev->class_dev, "premature interrupt\n"); @@ -206,12 +205,12 @@ static irqreturn_t a2150_interrupt(int irq, void *d) clear_dma_ff(devpriv->dma); /* figure out how many points to read */ - max_points = devpriv->dma_transfer_size / sample_size; + max_points = comedi_bytes_to_samples(s, devpriv->dma_transfer_size); /* residue is the number of points left to be done on the dma * transfer. It should always be zero at this point unless * the stop_src is set to external triggering. */ - residue = get_dma_residue(devpriv->dma) / sample_size; + residue = comedi_bytes_to_samples(s, get_dma_residue(devpriv->dma)); num_points = max_points - residue; if (devpriv->count < num_points && cmd->stop_src == TRIG_COUNT) num_points = devpriv->count; @@ -219,7 +218,8 @@ static irqreturn_t a2150_interrupt(int irq, void *d) /* figure out how many points will be stored next time */ leftover = 0; if (cmd->stop_src == TRIG_NONE) { - leftover = devpriv->dma_transfer_size / sample_size; + leftover = comedi_bytes_to_samples(s, + devpriv->dma_transfer_size); } else if (devpriv->count > max_points) { leftover = devpriv->count - max_points; if (leftover > max_points) @@ -248,7 +248,8 @@ static irqreturn_t a2150_interrupt(int irq, void *d) /* re-enable dma */ if (leftover) { set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer)); - set_dma_count(devpriv->dma, leftover * sample_size); + set_dma_count(devpriv->dma, + comedi_samples_to_bytes(s, leftover)); enable_dma(devpriv->dma); } release_dma_lock(flags); -- cgit v1.2.3-59-g8ed1b From 4884434c0390a8b2e76d02c126932537093c87f4 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 2 Nov 2014 23:12:04 +0100 Subject: staging: comedi: drivers: comedi_bond.c: Remove unneeded #define Remove unneeded #define. This was previously included in a patch set two but patchset one was taken by mistake. Signed-off-by: Rickard Strandqvist Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 5d19861fbabc..85b2f4ab1ba4 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -61,8 +61,7 @@ struct bonded_device { }; struct comedi_bond_private { -# define MAX_BOARD_NAME 256 - char name[MAX_BOARD_NAME]; + char name[256]; struct bonded_device **devs; unsigned ndevs; unsigned nchans; -- cgit v1.2.3-59-g8ed1b From ecdd21c7b982b0c65250e1b2e7a34eb7054b3c8a Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 3 Nov 2014 16:25:43 -0800 Subject: staging: ft1000: Whitespace neatening Use normal kernel style, indentation and alignment. git diff -w shows no difference Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/boot.h | 34 +- drivers/staging/ft1000/ft1000-pcmcia/ft1000.h | 30 +- drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c | 50 +- drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c | 204 ++-- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 686 +++++------ drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 1190 ++++++++++---------- .../staging/ft1000/ft1000-usb/ft1000_download.c | 300 ++--- drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 244 ++-- drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 60 +- drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 14 +- drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 2 +- 11 files changed, 1407 insertions(+), 1407 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/boot.h b/drivers/staging/ft1000/ft1000-pcmcia/boot.h index 60c015c1c28a..e4a698528520 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/boot.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/boot.h @@ -1,28 +1,28 @@ /*--------------------------------------------------------------------------- - FT1000 driver for Flarion Flash OFDM NIC Device + FT1000 driver for Flarion Flash OFDM NIC Device - Copyright (C) 2002 Flarion Technologies, All rights reserved. + Copyright (C) 2002 Flarion Technologies, All rights reserved. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) any - later version. This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - - Suite 330, Boston, MA 02111-1307, USA. + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- - File: boot.h + File: boot.h - Description: boatloader + Description: boatloader - History: - 1/11/05 Whc Ported to Linux. + History: + 1/11/05 Whc Ported to Linux. ----------------------------------------------------------------------------*/ + ---------------------------------------------------------------------------*/ #ifndef _BOOTH_ #define _BOOTH_ diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h index 1d52738fff49..5992670f7747 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h @@ -1,21 +1,21 @@ /*--------------------------------------------------------------------------- - FT1000 driver for Flarion Flash OFDM NIC Device + FT1000 driver for Flarion Flash OFDM NIC Device - Copyright (C) 2002 Flarion Technologies, All rights reserved. + Copyright (C) 2002 Flarion Technologies, All rights reserved. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) any - later version. This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - - Suite 330, Boston, MA 02111-1307, USA. ---------------------------------------------------------------------------- - Description: Common structures and defines ----------------------------------------------------------------------------*/ + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. + --------------------------------------------------------------------------- + Description: Common structures and defines + ---------------------------------------------------------------------------*/ #ifndef _FT1000H_ #define _FT1000H_ diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c index 1f8b3ca35c69..922478e1cb57 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c @@ -1,30 +1,30 @@ /*--------------------------------------------------------------------------- - FT1000 driver for Flarion Flash OFDM NIC Device + FT1000 driver for Flarion Flash OFDM NIC Device - Copyright (C) 1999 David A. Hinds. All Rights Reserved. - Copyright (C) 2002 Flarion Technologies, All rights reserved. - Copyright (C) 2006 Patrik Ostrihon, All rights reserved. - Copyright (C) 2006 ProWeb Consulting, a.s, All rights reserved. + Copyright (C) 1999 David A. Hinds. All Rights Reserved. + Copyright (C) 2002 Flarion Technologies, All rights reserved. + Copyright (C) 2006 Patrik Ostrihon, All rights reserved. + Copyright (C) 2006 ProWeb Consulting, a.s, All rights reserved. - The initial developer of the original code is David A. Hinds - . Portions created by David A. Hinds. + The initial developer of the original code is David A. Hinds + . Portions created by David A. Hinds. - This file was modified to support the Flarion Flash OFDM NIC Device - by Wai Chan (w.chan@flarion.com). + This file was modified to support the Flarion Flash OFDM NIC Device + by Wai Chan (w.chan@flarion.com). - Port for kernel 2.6 created by Patrik Ostrihon (patrik.ostrihon@pwc.sk) + Port for kernel 2.6 created by Patrik Ostrihon (patrik.ostrihon@pwc.sk) - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) any - later version. This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - - Suite 330, Boston, MA 02111-1307, USA. ------------------------------------------------------------------------------*/ + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. + -----------------------------------------------------------------------------*/ #include #include @@ -80,11 +80,11 @@ static int ft1000_confcheck(struct pcmcia_device *link, void *priv_data) /*====================================================================== - ft1000_config() is scheduled to run after a CARD_INSERTION event - is received, to configure the PCMCIA socket, and to make the - device available to the system. + ft1000_config() is scheduled to run after a CARD_INSERTION event + is received, to configure the PCMCIA socket, and to make the + device available to the system. -======================================================================*/ + ======================================================================*/ static int ft1000_config(struct pcmcia_device *link) { diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c index c1856f7d1e26..deb12560dc09 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c @@ -1,24 +1,24 @@ /*--------------------------------------------------------------------------- - FT1000 driver for Flarion Flash OFDM NIC Device - - Copyright (C) 2002 Flarion Technologies, All rights reserved. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) any - later version. This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - - Suite 330, Boston, MA 02111-1307, USA. + FT1000 driver for Flarion Flash OFDM NIC Device + + Copyright (C) 2002 Flarion Technologies, All rights reserved. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. -------------------------------------------------------------------------- - Description: This module will handshake with the DSP bootloader to - download the DSP runtime image. + Description: This module will handshake with the DSP bootloader to + download the DSP runtime image. ----------------------------------------------------------------------------*/ + ---------------------------------------------------------------------------*/ #define __KERNEL_SYSCALLS__ @@ -114,7 +114,7 @@ struct dsp_image_info { void card_bootload(struct net_device *dev) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); unsigned long flags; u32 *pdata; u32 size; @@ -123,7 +123,7 @@ void card_bootload(struct net_device *dev) netdev_dbg(dev, "card_bootload is called\n"); - pdata = (u32 *) bootimage; + pdata = (u32 *)bootimage; size = sizeof(bootimage); /* check for odd word */ @@ -146,7 +146,7 @@ void card_bootload(struct net_device *dev) u16 get_handshake(struct net_device *dev, u16 expected_value) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); u16 handshake; u32 tempx; int loopcnt; @@ -161,12 +161,12 @@ u16 get_handshake(struct net_device *dev, u16 expected_value) } else { tempx = ntohl(ft1000_read_dpram_mag_32 - (dev, DWNLD_MAG_HANDSHAKE_LOC)); - handshake = (u16) tempx; + (dev, DWNLD_MAG_HANDSHAKE_LOC)); + handshake = (u16)tempx; } if ((handshake == expected_value) - || (handshake == HANDSHAKE_RESET_VALUE)) { + || (handshake == HANDSHAKE_RESET_VALUE)) { return handshake; } loopcnt++; @@ -180,7 +180,7 @@ u16 get_handshake(struct net_device *dev, u16 expected_value) void put_handshake(struct net_device *dev, u16 handshake_value) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); u32 tempx; if (info->AsicID == ELECTRABUZZ_ID) { @@ -188,7 +188,7 @@ void put_handshake(struct net_device *dev, u16 handshake_value) DWNLD_HANDSHAKE_LOC); ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, handshake_value); /* Handshake */ } else { - tempx = (u32) handshake_value; + tempx = (u32)handshake_value; tempx = ntohl(tempx); ft1000_write_dpram_mag_32(dev, DWNLD_MAG_HANDSHAKE_LOC, tempx); /* Handshake */ } @@ -196,7 +196,7 @@ void put_handshake(struct net_device *dev, u16 handshake_value) u16 get_request_type(struct net_device *dev) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); u16 request_type; u32 tempx; @@ -206,7 +206,7 @@ u16 get_request_type(struct net_device *dev) } else { tempx = ft1000_read_dpram_mag_32(dev, DWNLD_MAG_TYPE_LOC); tempx = ntohl(tempx); - request_type = (u16) tempx; + request_type = (u16)tempx; } return request_type; @@ -215,7 +215,7 @@ u16 get_request_type(struct net_device *dev) long get_request_value(struct net_device *dev) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); long value; u16 w_val; @@ -244,7 +244,7 @@ long get_request_value(struct net_device *dev) void put_request_value(struct net_device *dev, long lvalue) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); u16 size; u32 tempx; @@ -271,11 +271,11 @@ void put_request_value(struct net_device *dev, long lvalue) u16 hdr_checksum(struct pseudo_hdr *pHdr) { - u16 *usPtr = (u16 *) pHdr; + u16 *usPtr = (u16 *)pHdr; u16 chksum; chksum = ((((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^ - usPtr[4]) ^ usPtr[5]) ^ usPtr[6]); + usPtr[4]) ^ usPtr[5]) ^ usPtr[6]); return chksum; } @@ -283,7 +283,7 @@ u16 hdr_checksum(struct pseudo_hdr *pHdr) int card_download(struct net_device *dev, const u8 *pFileStart, size_t FileLength) { - struct ft1000_info *info = (struct ft1000_info *) netdev_priv(dev); + struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev); int Status = SUCCESS; u32 uiState; u16 handshake; @@ -322,7 +322,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, uiState = STATE_START_DWNLD; - pFileHdr5 = (struct dsp_file_hdr *) pFileStart; + pFileHdr5 = (struct dsp_file_hdr *)pFileStart; pUsFile = (u16 *) ((long)pFileStart + pFileHdr5->loader_offset); pUcFile = (u8 *) ((long)pFileStart + pFileHdr5->loader_offset); @@ -376,7 +376,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, break; } if ((word_length * 2 + (long)pUcFile) > - (long)pBootEnd) { + (long)pBootEnd) { /* * Error, beyond boot code range. */ @@ -390,8 +390,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, * Position ASIC DPRAM auto-increment pointer. */ outw(DWNLD_MAG_PS_HDR_LOC, - dev->base_addr + - FT1000_REG_DPRAM_ADDR); + dev->base_addr + + FT1000_REG_DPRAM_ADDR); if (word_length & 0x01) word_length++; word_length = word_length / 2; @@ -402,12 +402,12 @@ int card_download(struct net_device *dev, const u8 *pFileStart, (*pUsFile++ << 16); pUcFile += 4; outl(templong, - dev->base_addr + - FT1000_REG_MAG_DPDATAL); + dev->base_addr + + FT1000_REG_MAG_DPDATAL); } spin_unlock_irqrestore(&info-> - dpram_lock, - flags); + dpram_lock, + flags); break; default: Status = FAILURE; @@ -430,7 +430,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, switch (request) { case REQUEST_FILE_CHECKSUM: netdev_dbg(dev, - "ft1000_dnld: REQUEST_FOR_CHECKSUM\n"); + "ft1000_dnld: REQUEST_FOR_CHECKSUM\n"); put_request_value(dev, image_chksum); break; case REQUEST_RUN_ADDRESS: @@ -468,7 +468,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, break; } if ((word_length * 2 + (long)pUcFile) > - (long)pCodeEnd) { + (long)pCodeEnd) { /* * Error, beyond boot code range. */ @@ -479,8 +479,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, * Position ASIC DPRAM auto-increment pointer. */ outw(DWNLD_MAG_PS_HDR_LOC, - dev->base_addr + - FT1000_REG_DPRAM_ADDR); + dev->base_addr + + FT1000_REG_DPRAM_ADDR); if (word_length & 0x01) word_length++; word_length = word_length / 2; @@ -491,8 +491,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, (*pUsFile++ << 16); pUcFile += 4; outl(templong, - dev->base_addr + - FT1000_REG_MAG_DPDATAL); + dev->base_addr + + FT1000_REG_MAG_DPDATAL); } break; @@ -502,9 +502,9 @@ int card_download(struct net_device *dev, const u8 *pFileStart, (long)(info->DSPInfoBlklen + 1) / 2; put_request_value(dev, word_length); pMailBoxData = - (struct drv_msg *) &info->DSPInfoBlk[0]; + (struct drv_msg *)&info->DSPInfoBlk[0]; pUsData = - (u16 *) &pMailBoxData->data[0]; + (u16 *)&pMailBoxData->data[0]; /* Provide mutual exclusive access while reading ASIC registers. */ spin_lock_irqsave(&info->dpram_lock, flags); @@ -528,8 +528,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, * Position ASIC DPRAM auto-increment pointer. */ outw(DWNLD_MAG_PS_HDR_LOC, - dev->base_addr + - FT1000_REG_DPRAM_ADDR); + dev->base_addr + + FT1000_REG_DPRAM_ADDR); if (word_length & 0x01) word_length++; @@ -540,13 +540,13 @@ int card_download(struct net_device *dev, const u8 *pFileStart, templong |= (*pUsData++ << 16); outl(templong, - dev->base_addr + - FT1000_REG_MAG_DPDATAL); + dev->base_addr + + FT1000_REG_MAG_DPDATAL); } } spin_unlock_irqrestore(&info-> - dpram_lock, - flags); + dpram_lock, + flags); break; case REQUEST_VERSION_INFO: @@ -555,8 +555,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, put_request_value(dev, word_length); pUsFile = (u16 *) ((long)pFileStart + - pFileHdr5-> - version_data_offset); + pFileHdr5-> + version_data_offset); /* Provide mutual exclusive access while reading ASIC registers. */ spin_lock_irqsave(&info->dpram_lock, flags); @@ -564,8 +564,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, * Position ASIC DPRAM auto-increment pointer. */ outw(DWNLD_MAG_PS_HDR_LOC, - dev->base_addr + - FT1000_REG_DPRAM_ADDR); + dev->base_addr + + FT1000_REG_DPRAM_ADDR); if (word_length & 0x01) word_length++; word_length = word_length / 2; @@ -578,12 +578,12 @@ int card_download(struct net_device *dev, const u8 *pFileStart, templong |= (temp << 16); outl(templong, - dev->base_addr + - FT1000_REG_MAG_DPDATAL); + dev->base_addr + + FT1000_REG_MAG_DPDATAL); } spin_unlock_irqrestore(&info-> - dpram_lock, - flags); + dpram_lock, + flags); break; case REQUEST_CODE_BY_VERSION: @@ -592,14 +592,14 @@ int card_download(struct net_device *dev, const u8 *pFileStart, get_request_value(dev); pDspImageInfoV6 = (struct dsp_image_info *) ((long) - pFileStart - + - sizeof - (struct dsp_file_hdr)); + pFileStart + + + sizeof + (struct dsp_file_hdr)); for (imageN = 0; - imageN < - pFileHdr5->nDspImages; - imageN++) { + imageN < + pFileHdr5->nDspImages; + imageN++) { temp = (u16) (pDspImageInfoV6-> version); @@ -610,30 +610,30 @@ int card_download(struct net_device *dev, const u8 *pFileStart, templong |= (temp << 16); if (templong == - requested_version) { + requested_version) { bGoodVersion = true; pUsFile = (u16 *) ((long) - pFileStart - + - pDspImageInfoV6-> - begin_offset); + pFileStart + + + pDspImageInfoV6-> + begin_offset); pUcFile = (u8 *) ((long) - pFileStart - + - pDspImageInfoV6-> - begin_offset); + pFileStart + + + pDspImageInfoV6-> + begin_offset); pCodeEnd = (u8 *) ((long) - pFileStart - + - pDspImageInfoV6-> - end_offset); + pFileStart + + + pDspImageInfoV6-> + end_offset); run_address = pDspImageInfoV6-> run_address; @@ -645,10 +645,10 @@ int card_download(struct net_device *dev, const u8 *pFileStart, pDspImageInfoV6-> checksum; netdev_dbg(dev, - "ft1000_dnld: image_chksum = 0x%8x\n", - (unsigned - int) - image_chksum); + "ft1000_dnld: image_chksum = 0x%8x\n", + (unsigned + int) + image_chksum); break; } pDspImageInfoV6++; @@ -674,25 +674,25 @@ int card_download(struct net_device *dev, const u8 *pFileStart, break; case STATE_DONE_DWNLD: - if (((unsigned long) (pUcFile) - (unsigned long) pFileStart) >= - (unsigned long) FileLength) { + if (((unsigned long)(pUcFile) - (unsigned long) pFileStart) >= + (unsigned long)FileLength) { uiState = STATE_DONE_FILE; break; } - pHdr = (struct pseudo_hdr *) pUsFile; + pHdr = (struct pseudo_hdr *)pUsFile; if (pHdr->portdest == 0x80 /* DspOAM */ - && (pHdr->portsrc == 0x00 /* Driver */ + && (pHdr->portsrc == 0x00 /* Driver */ || pHdr->portsrc == 0x10 /* FMM */)) { uiState = STATE_SECTION_PROV; } else { netdev_dbg(dev, - "FT1000:download:Download error: Bad Port IDs in Pseudo Record\n"); + "FT1000:download:Download error: Bad Port IDs in Pseudo Record\n"); netdev_dbg(dev, "\t Port Source = 0x%2.2x\n", - pHdr->portsrc); + pHdr->portsrc); netdev_dbg(dev, "\t Port Destination = 0x%2.2x\n", - pHdr->portdest); + pHdr->portdest); Status = FAILURE; } @@ -700,7 +700,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, case STATE_SECTION_PROV: - pHdr = (struct pseudo_hdr *) pUcFile; + pHdr = (struct pseudo_hdr *)pUcFile; if (pHdr->checksum == hdr_checksum(pHdr)) { if (pHdr->portdest != 0x80 /* Dsp OAM */) { @@ -715,8 +715,8 @@ int card_download(struct net_device *dev, const u8 *pFileStart, GFP_ATOMIC); if (pbuffer) { memcpy(pbuffer, (void *)pUcFile, - (u32) (usHdrLength + - sizeof(struct pseudo_hdr))); + (u32) (usHdrLength + + sizeof(struct pseudo_hdr))); /* link provisioning data */ pprov_record = kmalloc(sizeof(struct prov_record), @@ -725,15 +725,15 @@ int card_download(struct net_device *dev, const u8 *pFileStart, pprov_record->pprov_data = pbuffer; list_add_tail(&pprov_record-> - list, - &info->prov_list); + list, + &info->prov_list); /* Move to next entry if available */ pUcFile = - (u8 *) ((unsigned long) pUcFile + - (unsigned long) ((usHdrLength + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); + (u8 *)((unsigned long) pUcFile + + (unsigned long) ((usHdrLength + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); if ((unsigned long) (pUcFile) - - (unsigned long) (pFileStart) >= - (unsigned long) FileLength) { + (unsigned long) (pFileStart) >= + (unsigned long)FileLength) { uiState = STATE_DONE_FILE; } diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 25b06d350f14..c6bee28cad73 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -1,20 +1,20 @@ /*--------------------------------------------------------------------------- - FT1000 driver for Flarion Flash OFDM NIC Device - - Copyright (C) 2002 Flarion Technologies, All rights reserved. - Copyright (C) 2006 Patrik Ostrihon, All rights reserved. - Copyright (C) 2006 ProWeb Consulting, a.s, All rights reserved. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) any - later version. This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - - Suite 330, Boston, MA 02111-1307, USA. + FT1000 driver for Flarion Flash OFDM NIC Device + + Copyright (C) 2002 Flarion Technologies, All rights reserved. + Copyright (C) 2006 Patrik Ostrihon, All rights reserved. + Copyright (C) 2006 ProWeb Consulting, a.s, All rights reserved. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) any + later version. This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. -------------------------------------------------------------------------*/ #include @@ -57,7 +57,7 @@ static const struct firmware *fw_entry; static void ft1000_hbchk(u_long data); static struct timer_list poll_timer = { - .function = ft1000_hbchk + .function = ft1000_hbchk }; static u16 cmdbuffer[1024]; @@ -72,7 +72,7 @@ static void ft1000_disable_interrupts(struct net_device *dev); /* new kernel */ MODULE_AUTHOR(""); MODULE_DESCRIPTION - ("Support for Flarion Flash OFDM NIC Device. Support for PCMCIA when used with ft1000_cs."); +("Support for Flarion Flash OFDM NIC Device. Support for PCMCIA when used with ft1000_cs."); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("FT1000"); @@ -80,15 +80,15 @@ MODULE_SUPPORTED_DEVICE("FT1000"); /*--------------------------------------------------------------------------- - Function: ft1000_read_fifo_len - Description: This function will read the ASIC Uplink FIFO status register - which will return the number of bytes remaining in the Uplink FIFO. - Sixteen bytes are subtracted to make sure that the ASIC does not - reach its threshold. - Input: - dev - network device structure - Output: - value - number of bytes available in the ASIC Uplink FIFO. + Function: ft1000_read_fifo_len + Description: This function will read the ASIC Uplink FIFO status register + which will return the number of bytes remaining in the Uplink FIFO. + Sixteen bytes are subtracted to make sure that the ASIC does not + reach its threshold. + Input: + dev - network device structure + Output: + value - number of bytes available in the ASIC Uplink FIFO. -------------------------------------------------------------------------*/ static inline u16 ft1000_read_fifo_len(struct net_device *dev) @@ -103,14 +103,14 @@ static inline u16 ft1000_read_fifo_len(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_read_dpram - Description: This function will read the specific area of dpram - (Electrabuzz ASIC only) - Input: - dev - device structure - offset - index of dpram - Output: - value - value of dpram + Function: ft1000_read_dpram + Description: This function will read the specific area of dpram + (Electrabuzz ASIC only) + Input: + dev - device structure + offset - index of dpram + Output: + value - value of dpram -------------------------------------------------------------------------*/ u16 ft1000_read_dpram(struct net_device *dev, int offset) @@ -130,19 +130,19 @@ u16 ft1000_read_dpram(struct net_device *dev, int offset) /*--------------------------------------------------------------------------- - Function: ft1000_write_dpram - Description: This function will write to a specific area of dpram - (Electrabuzz ASIC only) - Input: - dev - device structure - offset - index of dpram - value - value to write - Output: - none. + Function: ft1000_write_dpram + Description: This function will write to a specific area of dpram + (Electrabuzz ASIC only) + Input: + dev - device structure + offset - index of dpram + value - value to write + Output: + none. -------------------------------------------------------------------------*/ static inline void ft1000_write_dpram(struct net_device *dev, - int offset, u16 value) + int offset, u16 value) { struct ft1000_info *info = netdev_priv(dev); unsigned long flags; @@ -156,14 +156,14 @@ static inline void ft1000_write_dpram(struct net_device *dev, /*--------------------------------------------------------------------------- - Function: ft1000_read_dpram_mag_16 - Description: This function will read the specific area of dpram - (Magnemite ASIC only) - Input: - dev - device structure - offset - index of dpram - Output: - value - value of dpram + Function: ft1000_read_dpram_mag_16 + Description: This function will read the specific area of dpram + (Magnemite ASIC only) + Input: + dev - device structure + offset - index of dpram + Output: + value - value of dpram -------------------------------------------------------------------------*/ u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index) @@ -188,19 +188,19 @@ u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index) /*--------------------------------------------------------------------------- - Function: ft1000_write_dpram_mag_16 - Description: This function will write to a specific area of dpram - (Magnemite ASIC only) - Input: - dev - device structure - offset - index of dpram - value - value to write - Output: - none. + Function: ft1000_write_dpram_mag_16 + Description: This function will write to a specific area of dpram + (Magnemite ASIC only) + Input: + dev - device structure + offset - index of dpram + value - value to write + Output: + none. -------------------------------------------------------------------------*/ static inline void ft1000_write_dpram_mag_16(struct net_device *dev, - int offset, u16 value, int Index) + int offset, u16 value, int Index) { struct ft1000_info *info = netdev_priv(dev); unsigned long flags; @@ -218,14 +218,14 @@ static inline void ft1000_write_dpram_mag_16(struct net_device *dev, /*--------------------------------------------------------------------------- - Function: ft1000_read_dpram_mag_32 - Description: This function will read the specific area of dpram - (Magnemite ASIC only) - Input: - dev - device structure - offset - index of dpram - Output: - value - value of dpram + Function: ft1000_read_dpram_mag_32 + Description: This function will read the specific area of dpram + (Magnemite ASIC only) + Input: + dev - device structure + offset - index of dpram + Output: + value - value of dpram -------------------------------------------------------------------------*/ u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset) @@ -245,15 +245,15 @@ u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset) /*--------------------------------------------------------------------------- - Function: ft1000_write_dpram_mag_32 - Description: This function will write to a specific area of dpram - (Magnemite ASIC only) - Input: - dev - device structure - offset - index of dpram - value - value to write - Output: - none. + Function: ft1000_write_dpram_mag_32 + Description: This function will write to a specific area of dpram + (Magnemite ASIC only) + Input: + dev - device structure + offset - index of dpram + value - value to write + Output: + none. -------------------------------------------------------------------------*/ void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value) @@ -270,12 +270,12 @@ void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value) /*--------------------------------------------------------------------------- - Function: ft1000_enable_interrupts - Description: This function will enable interrupts base on the current interrupt mask. - Input: - dev - device structure - Output: - None. + Function: ft1000_enable_interrupts + Description: This function will enable interrupts base on the current interrupt mask. + Input: + dev - device structure + Output: + None. -------------------------------------------------------------------------*/ static void ft1000_enable_interrupts(struct net_device *dev) @@ -286,18 +286,18 @@ static void ft1000_enable_interrupts(struct net_device *dev) ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_DEFAULT_MASK); tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK); DEBUG(1, - "ft1000_hw:ft1000_enable_interrupts:current interrupt enable mask = 0x%x\n", - tempword); + "ft1000_hw:ft1000_enable_interrupts:current interrupt enable mask = 0x%x\n", + tempword); } /*--------------------------------------------------------------------------- - Function: ft1000_disable_interrupts - Description: This function will disable all interrupts. - Input: - dev - device structure - Output: - None. + Function: ft1000_disable_interrupts + Description: This function will disable all interrupts. + Input: + dev - device structure + Output: + None. -------------------------------------------------------------------------*/ static void ft1000_disable_interrupts(struct net_device *dev) @@ -308,19 +308,19 @@ static void ft1000_disable_interrupts(struct net_device *dev) ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_MASK_ALL); tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK); DEBUG(1, - "ft1000_hw:ft1000_disable_interrupts:current interrupt enable mask = 0x%x\n", - tempword); + "ft1000_hw:ft1000_disable_interrupts:current interrupt enable mask = 0x%x\n", + tempword); } /*--------------------------------------------------------------------------- - Function: ft1000_reset_asic - Description: This function will call the Card Service function to reset the - ASIC. - Input: - dev - device structure - Output: - none + Function: ft1000_reset_asic + Description: This function will call the Card Service function to reset the + ASIC. + Input: + dev - device structure + Output: + none -------------------------------------------------------------------------*/ static void ft1000_reset_asic(struct net_device *dev) @@ -360,13 +360,13 @@ static void ft1000_reset_asic(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_reset_card - Description: This function will reset the card - Input: - dev - device structure - Output: - status - false (card reset fail) - true (card reset successful) + Function: ft1000_reset_card + Description: This function will reset the card + Input: + dev - device structure + Output: + status - false (card reset fail) + true (card reset successful) -------------------------------------------------------------------------*/ static int ft1000_reset_card(struct net_device *dev) @@ -389,7 +389,7 @@ static int ft1000_reset_card(struct net_device *dev) /* Make sure we free any memory reserve for provisioning */ while (list_empty(&info->prov_list) == 0) { DEBUG(0, - "ft1000_hw:ft1000_reset_card:deleting provisioning record\n"); + "ft1000_hw:ft1000_reset_card:deleting provisioning record\n"); ptr = list_entry(info->prov_list.next, struct prov_record, list); list_del(&ptr->list); kfree(ptr->pprov_data); @@ -401,7 +401,7 @@ static int ft1000_reset_card(struct net_device *dev) ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT); } else { DEBUG(1, - "ft1000_hw:ft1000_reset_card:resetting ASIC and DSP\n"); + "ft1000_hw:ft1000_reset_card:resetting ASIC and DSP\n"); ft1000_write_reg(dev, FT1000_REG_RESET, (DSP_RESET_BIT | ASIC_RESET_BIT)); } @@ -438,7 +438,7 @@ static int ft1000_reset_card(struct net_device *dev) if (info->AsicID == MAGNEMITE_ID) { /* Put dsp in reset and take ASIC out of reset */ DEBUG(0, - "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n"); + "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n"); ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT); /* Setting MAGNEMITE ASIC to big endian mode */ @@ -465,7 +465,7 @@ static int ft1000_reset_card(struct net_device *dev) if (i == 50) { DEBUG(0, - "ft1000_hw:ft1000_reset_card:No FEFE detected from DSP\n"); + "ft1000_hw:ft1000_reset_card:No FEFE detected from DSP\n"); return false; } @@ -495,7 +495,7 @@ static int ft1000_reset_card(struct net_device *dev) ft1000_write_dpram(dev, FT1000_HI_HO, ho); tempword = ft1000_read_dpram(dev, FT1000_HI_HO); DEBUG(1, "ft1000_hw:ft1000_reset_asic:hi_ho value = 0x%x\n", - tempword); + tempword); } else { /* Initialize DSP heartbeat area to ho */ ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, ho_mag, @@ -504,7 +504,7 @@ static int ft1000_reset_card(struct net_device *dev) ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX); DEBUG(1, "ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", - tempword); + tempword); } info->CardReady = 1; @@ -521,14 +521,14 @@ static int ft1000_reset_card(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_chkcard - Description: This function will check if the device is presently available on - the system. - Input: - dev - device structure - Output: - status - false (device is not present) - true (device is present) + Function: ft1000_chkcard + Description: This function will check if the device is presently available on + the system. + Input: + dev - device structure + Output: + status - false (device is not present) + true (device is present) -------------------------------------------------------------------------*/ static int ft1000_chkcard(struct net_device *dev) @@ -542,7 +542,7 @@ static int ft1000_chkcard(struct net_device *dev) tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK); if (tempword == 0) { DEBUG(1, - "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n"); + "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n"); return false; } /* @@ -552,7 +552,7 @@ static int ft1000_chkcard(struct net_device *dev) tempword = ft1000_read_reg(dev, FT1000_REG_ASIC_ID); if (tempword == 0xffff) { DEBUG(1, - "ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n"); + "ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n"); return false; } return true; @@ -561,13 +561,13 @@ static int ft1000_chkcard(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_hbchk - Description: This function will perform the heart beat check of the DSP as - well as the ASIC. - Input: - dev - device structure - Output: - none + Function: ft1000_hbchk + Description: This function will perform the heart beat check of the DSP as + well as the ASIC. + Input: + dev - device structure + Output: + none -------------------------------------------------------------------------*/ static void ft1000_hbchk(u_long data) @@ -586,11 +586,11 @@ static void ft1000_hbchk(u_long data) } else { tempword = ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_HI_HO, - FT1000_MAG_HI_HO_INDX)); + (dev, FT1000_MAG_HI_HO, + FT1000_MAG_HI_HO_INDX)); } DEBUG(1, "ft1000_hw:ft1000_hbchk:hi_ho value = 0x%x\n", - tempword); + tempword); /* Let's perform another check if ho is not detected */ if (tempword != ho) { if (info->AsicID == ELECTRABUZZ_ID) { @@ -602,7 +602,7 @@ static void ft1000_hbchk(u_long data) } if (tempword != ho) { printk(KERN_INFO - "ft1000: heartbeat failed - no ho detected\n"); + "ft1000: heartbeat failed - no ho detected\n"); if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -633,7 +633,7 @@ static void ft1000_hbchk(u_long data) info->DrvErrNum = DSP_HB_INFO; if (ft1000_reset_card(dev) == 0) { printk(KERN_INFO - "ft1000: Hardware Failure Detected - PC Card disabled\n"); + "ft1000: Hardware Failure Detected - PC Card disabled\n"); info->ProgConStat = 0xff; return; } @@ -651,7 +651,7 @@ static void ft1000_hbchk(u_long data) } if (tempword & FT1000_DB_HB) { printk(KERN_INFO - "ft1000: heartbeat doorbell not clear by firmware\n"); + "ft1000: heartbeat doorbell not clear by firmware\n"); if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -682,7 +682,7 @@ static void ft1000_hbchk(u_long data) info->DrvErrNum = DSP_HB_INFO; if (ft1000_reset_card(dev) == 0) { printk(KERN_INFO - "ft1000: Hardware Failure Detected - PC Card disabled\n"); + "ft1000: Hardware Failure Detected - PC Card disabled\n"); info->ProgConStat = 0xff; return; } @@ -708,8 +708,8 @@ static void ft1000_hbchk(u_long data) } else { tempword = ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_HI_HO, - FT1000_MAG_HI_HO_INDX)); + (dev, FT1000_MAG_HI_HO, + FT1000_MAG_HI_HO_INDX)); } /* Let's write hi again if fail */ if (tempword != hi) { @@ -731,7 +731,7 @@ static void ft1000_hbchk(u_long data) if (tempword != hi) { printk(KERN_INFO - "ft1000: heartbeat failed - cannot write hi into DPRAM\n"); + "ft1000: heartbeat failed - cannot write hi into DPRAM\n"); if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -762,7 +762,7 @@ static void ft1000_hbchk(u_long data) info->DrvErrNum = DSP_HB_INFO; if (ft1000_reset_card(dev) == 0) { printk(KERN_INFO - "ft1000: Hardware Failure Detected - PC Card disabled\n"); + "ft1000: Hardware Failure Detected - PC Card disabled\n"); info->ProgConStat = 0xff; return; } @@ -778,19 +778,19 @@ static void ft1000_hbchk(u_long data) /* Schedule this module to run every 2 seconds */ poll_timer.expires = jiffies + (2 * HZ); - poll_timer.data = (u_long) dev; + poll_timer.data = (u_long)dev; add_timer(&poll_timer); } /*--------------------------------------------------------------------------- - Function: ft1000_send_cmd - Description: - Input: - Output: + Function: ft1000_send_cmd + Description: + Input: + Output: -------------------------------------------------------------------------*/ -static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype) +static void ft1000_send_cmd(struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype) { struct ft1000_info *info = netdev_priv(dev); int i; @@ -831,7 +831,7 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, /* Write pseudo header and messgae body */ for (i = 0; i < (size >> 1); i++) { DEBUG(1, "FT1000:ft1000_send_cmd:data %d = 0x%x\n", i, - *ptempbuffer); + *ptempbuffer); tempword = htons(*ptempbuffer++); ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, tempword); } @@ -845,13 +845,13 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, FT1000_DPRAM_MAG_TX_BASE + 1); for (i = 0; i < (size >> 2); i++) { DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", - *ptempbuffer); + *ptempbuffer); outw(*ptempbuffer++, - dev->base_addr + FT1000_REG_MAG_DPDATAL); + dev->base_addr + FT1000_REG_MAG_DPDATAL); DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", - *ptempbuffer); + *ptempbuffer); outw(*ptempbuffer++, - dev->base_addr + FT1000_REG_MAG_DPDATAH); + dev->base_addr + FT1000_REG_MAG_DPDATAH); } DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer); outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAL); @@ -866,19 +866,19 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, /*--------------------------------------------------------------------------- - Function: ft1000_receive_cmd - Description: This function will read a message from the dpram area. - Input: - dev - network device structure - pbuffer - caller supply address to buffer - pnxtph - pointer to next pseudo header - Output: - Status = 0 (unsuccessful) - = 1 (successful) + Function: ft1000_receive_cmd + Description: This function will read a message from the dpram area. + Input: + dev - network device structure + pbuffer - caller supply address to buffer + pnxtph - pointer to next pseudo header + Output: + Status = 0 (unsuccessful) + = 1 (successful) -------------------------------------------------------------------------*/ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, - int maxsz, u16 *pnxtph) + int maxsz, u16 *pnxtph) { struct ft1000_info *info = netdev_priv(dev); u16 size; @@ -888,20 +888,20 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, unsigned long flags; if (info->AsicID == ELECTRABUZZ_ID) { - size = ( ft1000_read_dpram(dev, *pnxtph) ) + sizeof(struct pseudo_hdr); + size = (ft1000_read_dpram(dev, *pnxtph)) + sizeof(struct pseudo_hdr); } else { size = ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_PH_LEN, - FT1000_MAG_PH_LEN_INDX)) + sizeof(struct pseudo_hdr); + (dev, FT1000_MAG_PH_LEN, + FT1000_MAG_PH_LEN_INDX)) + sizeof(struct pseudo_hdr); } if (size > maxsz) { DEBUG(1, - "FT1000:ft1000_receive_cmd:Invalid command length = %d\n", - size); + "FT1000:ft1000_receive_cmd:Invalid command length = %d\n", + size); return false; } else { - ppseudohdr = (u16 *) pbuffer; + ppseudohdr = (u16 *)pbuffer; spin_lock_irqsave(&info->dpram_lock, flags); if (info->AsicID == ELECTRABUZZ_ID) { ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, @@ -922,11 +922,11 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, for (i = 0; i <= (size >> 2); i++) { *pbuffer = inw(dev->base_addr + - FT1000_REG_MAG_DPDATAL); + FT1000_REG_MAG_DPDATAL); pbuffer++; *pbuffer = inw(dev->base_addr + - FT1000_REG_MAG_DPDATAH); + FT1000_REG_MAG_DPDATAH); pbuffer++; } /* copy odd aligned word */ @@ -954,7 +954,7 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, } if ((tempword != *ppseudohdr)) { DEBUG(1, - "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n"); + "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n"); /* Drop this message */ return false; } @@ -964,13 +964,13 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, /*--------------------------------------------------------------------------- - Function: ft1000_proc_drvmsg - Description: This function will process the various driver messages. - Input: - dev - device structure - pnxtph - pointer to next pseudo header - Output: - none + Function: ft1000_proc_drvmsg + Description: This function will process the various driver messages. + Input: + dev - device structure + pnxtph - pointer to next pseudo header + Output: + none -------------------------------------------------------------------------*/ static void ft1000_proc_drvmsg(struct net_device *dev) @@ -992,22 +992,22 @@ static void ft1000_proc_drvmsg(struct net_device *dev) u16 wrd; } convert; - if (info->AsicID == ELECTRABUZZ_ID) { - tempword = FT1000_DPRAM_RX_BASE+2; - } - else { - tempword = FT1000_DPRAM_MAG_RX_BASE; - } - if (ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword)) { + if (info->AsicID == ELECTRABUZZ_ID) { + tempword = FT1000_DPRAM_RX_BASE+2; + } + else { + tempword = FT1000_DPRAM_MAG_RX_BASE; + } + if (ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword)) { /* Get the message type which is total_len + PSEUDO header + msgtype + message body */ - pdrvmsg = (struct drv_msg *) & cmdbuffer[0]; + pdrvmsg = (struct drv_msg *)&cmdbuffer[0]; msgtype = ntohs(pdrvmsg->type); DEBUG(1, "Command message type = 0x%x\n", msgtype); switch (msgtype) { case DSP_PROVISION: DEBUG(0, - "Got a provisioning request message from DSP\n"); + "Got a provisioning request message from DSP\n"); mdelay(25); while (list_empty(&info->prov_list) == 0) { DEBUG(0, "Sending a provisioning message\n"); @@ -1025,25 +1025,25 @@ static void ft1000_proc_drvmsg(struct net_device *dev) ptr = list_entry(info->prov_list.next, struct prov_record, list); - len = *(u16 *) ptr->pprov_data; + len = *(u16 *)ptr->pprov_data; len = htons(len); - pmsg = (u16 *) ptr->pprov_data; - ppseudo_hdr = (struct pseudo_hdr *) pmsg; + pmsg = (u16 *)ptr->pprov_data; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; /* Insert slow queue sequence number */ ppseudo_hdr->seq_num = info->squeseqnum++; ppseudo_hdr->portsrc = 0; /* Calculate new checksum */ ppseudo_hdr->checksum = *pmsg++; DEBUG(1, "checksum = 0x%x\n", - ppseudo_hdr->checksum); + ppseudo_hdr->checksum); for (i = 1; i < 7; i++) { ppseudo_hdr->checksum ^= *pmsg++; DEBUG(1, "checksum = 0x%x\n", - ppseudo_hdr->checksum); + ppseudo_hdr->checksum); } - ft1000_send_cmd (dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE); + ft1000_send_cmd(dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE); list_del(&ptr->list); kfree(ptr->pprov_data); kfree(ptr); @@ -1055,18 +1055,28 @@ static void ft1000_proc_drvmsg(struct net_device *dev) info->CardReady = 1; break; case MEDIA_STATE: - pmediamsg = (struct media_msg *) & cmdbuffer[0]; + pmediamsg = (struct media_msg *)&cmdbuffer[0]; if (info->ProgConStat != 0xFF) { - if (pmediamsg->state) { - DEBUG(1, "Media is up\n"); - if (info->mediastate == 0) { - netif_carrier_on(dev); - netif_wake_queue(dev); - info->mediastate = 1; - do_gettimeofday(&tv); - info->ConTm = tv.tv_sec; + if (pmediamsg->state) { + DEBUG(1, "Media is up\n"); + if (info->mediastate == 0) { + netif_carrier_on(dev); + netif_wake_queue(dev); + info->mediastate = 1; + do_gettimeofday(&tv); + info->ConTm = tv.tv_sec; + } + } else { + DEBUG(1, "Media is down\n"); + if (info->mediastate == 1) { + info->mediastate = 0; + netif_carrier_off(dev); + netif_stop_queue(dev); + info->ConTm = 0; + } } - } else { + } + else { DEBUG(1, "Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; @@ -1075,25 +1085,15 @@ static void ft1000_proc_drvmsg(struct net_device *dev) info->ConTm = 0; } } - } - else { - DEBUG(1, "Media is down\n"); - if (info->mediastate == 1) { - info->mediastate = 0; - netif_carrier_off(dev); - netif_stop_queue(dev); - info->ConTm = 0; - } - } break; case DSP_INIT_MSG: - pdspinitmsg = (struct dsp_init_msg *) & cmdbuffer[0]; + pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[0]; memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ); DEBUG(1, "DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", - info->DspVer[0], info->DspVer[1], info->DspVer[2], - info->DspVer[3]); + info->DspVer[0], info->DspVer[1], info->DspVer[2], + info->DspVer[3]); memcpy(info->HwSerNum, pdspinitmsg->HwSerNum, - HWSERNUMSZ); + HWSERNUMSZ); memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ); memcpy(info->eui64, pdspinitmsg->eui64, EUISZ); dev->dev_addr[0] = info->eui64[0]; @@ -1104,28 +1104,28 @@ static void ft1000_proc_drvmsg(struct net_device *dev) dev->dev_addr[5] = info->eui64[7]; if (ntohs(pdspinitmsg->length) == - (sizeof(struct dsp_init_msg) - 20)) { + (sizeof(struct dsp_init_msg) - 20)) { memcpy(info->ProductMode, - pdspinitmsg->ProductMode, MODESZ); + pdspinitmsg->ProductMode, MODESZ); memcpy(info->RfCalVer, pdspinitmsg->RfCalVer, - CALVERSZ); + CALVERSZ); memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, - CALDATESZ); + CALDATESZ); DEBUG(1, "RFCalVer = 0x%2x 0x%2x\n", - info->RfCalVer[0], info->RfCalVer[1]); + info->RfCalVer[0], info->RfCalVer[1]); } - break ; + break; case DSP_STORE_INFO: DEBUG(1, "FT1000:drivermsg:Got DSP_STORE_INFO\n"); tempword = ntohs(pdrvmsg->length); info->DSPInfoBlklen = tempword; if (tempword < (MAX_DSP_SESS_REC - 4)) { - pmsg = (u16 *) & pdrvmsg->data[0]; + pmsg = (u16 *)&pdrvmsg->data[0]; for (i = 0; i < ((tempword + 1) / 2); i++) { DEBUG(1, - "FT1000:drivermsg:dsp info data = 0x%x\n", - *pmsg); + "FT1000:drivermsg:dsp info data = 0x%x\n", + *pmsg); info->DSPInfoBlk[i + 10] = *pmsg++; } } @@ -1152,8 +1152,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev) * Put message into Slow Queue * Form Pseudo header */ - pmsg = (u16 *) info->DSPInfoBlk; - ppseudo_hdr = (struct pseudo_hdr *) pmsg; + pmsg = (u16 *)info->DSPInfoBlk; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; ppseudo_hdr->length = htons(info->DSPInfoBlklen + 4); ppseudo_hdr->source = 0x10; @@ -1177,7 +1177,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) info->DSPInfoBlk[8] = 0x7200; info->DSPInfoBlk[9] = htons(info->DSPInfoBlklen); - ft1000_send_cmd (dev, (u16 *)info->DSPInfoBlk, (u16)(info->DSPInfoBlklen+4), 0); + ft1000_send_cmd(dev, (u16 *)info->DSPInfoBlk, (u16)(info->DSPInfoBlklen+4), 0); } break; @@ -1203,8 +1203,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev) * Put message into Slow Queue * Form Pseudo header */ - pmsg = (u16 *) & tempbuffer[0]; - ppseudo_hdr = (struct pseudo_hdr *) pmsg; + pmsg = (u16 *)&tempbuffer[0]; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; ppseudo_hdr->length = htons(0x0012); ppseudo_hdr->source = 0x10; ppseudo_hdr->destination = 0x20; @@ -1220,11 +1220,11 @@ static void ft1000_proc_drvmsg(struct net_device *dev) /* Insert application id */ ppseudo_hdr->portsrc = 0; /* Calculate new checksum */ - ppseudo_hdr->checksum = *pmsg++; - for (i=1; i<7; i++) { - ppseudo_hdr->checksum ^= *pmsg++; - } - pmsg = (u16 *) &tempbuffer[16]; + ppseudo_hdr->checksum = *pmsg++; + for (i = 1; i < 7; i++) { + ppseudo_hdr->checksum ^= *pmsg++; + } + pmsg = (u16 *)&tempbuffer[16]; *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG); *pmsg++ = htons(0x000e); *pmsg++ = htons(info->DSP_TIME[0]); @@ -1239,7 +1239,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) *pmsg++ = convert.wrd; *pmsg++ = htons(info->DrvErrNum); - ft1000_send_cmd (dev, (u16 *)&tempbuffer[0], (u16)(0x0012), 0); + ft1000_send_cmd(dev, (u16 *)&tempbuffer[0], (u16)(0x0012), 0); info->DrvErrNum = 0; } @@ -1252,14 +1252,14 @@ static void ft1000_proc_drvmsg(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_parse_dpram_msg - Description: This function will parse the message received from the DSP - via the DPRAM interface. - Input: - dev - device structure - Output: - status - FAILURE - SUCCESS + Function: ft1000_parse_dpram_msg + Description: This function will parse the message received from the DSP + via the DPRAM interface. + Input: + dev - device structure + Output: + status - FAILURE + SUCCESS -------------------------------------------------------------------------*/ static int ft1000_parse_dpram_msg(struct net_device *dev) @@ -1290,7 +1290,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) FT1000_DPRAM_MAG_RX_BASE); for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) { outl(info->DSPSess.MagRec[i], - dev->base_addr + FT1000_REG_MAG_DPDATA); + dev->base_addr + FT1000_REG_MAG_DPDATA); } } spin_unlock_irqrestore(&info->dpram_lock, flags); @@ -1311,7 +1311,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) if (doorbell & FT1000_DSP_ASIC_RESET) { DEBUG(0, - "FT1000:ft1000_parse_dpram_msg: Got a dsp ASIC reset message\n"); + "FT1000:ft1000_parse_dpram_msg: Got a dsp ASIC reset message\n"); ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DSP_ASIC_RESET); udelay(200); @@ -1320,7 +1320,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) if (doorbell & FT1000_DB_DPRAM_RX) { DEBUG(1, - "FT1000:ft1000_parse_dpram_msg: Got a slow queue message\n"); + "FT1000:ft1000_parse_dpram_msg: Got a slow queue message\n"); nxtph = FT1000_DPRAM_RX_BASE + 2; if (info->AsicID == ELECTRABUZZ_ID) { total_len = @@ -1328,13 +1328,13 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) } else { total_len = ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_TOTAL_LEN, - FT1000_MAG_TOTAL_LEN_INDX)); + (dev, FT1000_MAG_TOTAL_LEN, + FT1000_MAG_TOTAL_LEN_INDX)); } DEBUG(1, "FT1000:ft1000_parse_dpram_msg:total length = %d\n", - total_len); + total_len); if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) { - total_len += nxtph; + total_len += nxtph; /* * ft1000_read_reg will return a value that needs to be byteswap * in order to get DSP_QID_OFFSET. @@ -1395,7 +1395,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) /* let's clear any unexpected doorbells from DSP */ doorbell = doorbell & ~(FT1000_DB_DPRAM_RX | FT1000_ASIC_RESET_REQ | - FT1000_DB_COND_RESET | 0xff00); + FT1000_DB_COND_RESET | 0xff00); if (doorbell) { DEBUG(1, "Clearing unexpected doorbell = 0x%x\n", doorbell); ft1000_write_reg(dev, FT1000_REG_DOORBELL, doorbell); @@ -1407,14 +1407,14 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_flush_fifo - Description: This function will flush one packet from the downlink - FIFO. - Input: - dev - device structure - drv_err - driver error causing the flush fifo - Output: - None. + Function: ft1000_flush_fifo + Description: This function will flush one packet from the downlink + FIFO. + Input: + dev - device structure + drv_err - driver error causing the flush fifo + Output: + None. -------------------------------------------------------------------------*/ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) @@ -1512,7 +1512,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) */ tempword = inw(dev->base_addr + - FT1000_REG_SUP_IMASK); + FT1000_REG_SUP_IMASK); if (tempword == 0) { /* This indicates that we can not communicate with the ASIC */ info->DrvErrNum = @@ -1557,15 +1557,15 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) /*--------------------------------------------------------------------------- - Function: ft1000_copy_up_pkt - Description: This function will pull Flarion packets out of the Downlink - FIFO and convert it to an ethernet packet. The ethernet packet will - then be deliver to the TCP/IP stack. - Input: - dev - device structure - Output: - status - FAILURE - SUCCESS + Function: ft1000_copy_up_pkt + Description: This function will pull Flarion packets out of the Downlink + FIFO and convert it to an ethernet packet. The ethernet packet will + then be deliver to the TCP/IP stack. + Input: + dev - device structure + Output: + status - FAILURE + SUCCESS -------------------------------------------------------------------------*/ static int ft1000_copy_up_pkt(struct net_device *dev) @@ -1616,7 +1616,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) info->stats.rx_errors++; return FAILURE; } - pbuffer = (u8 *) skb_put(skb, len + 12); + pbuffer = (u8 *)skb_put(skb, len + 12); /* Pseudo header */ if (info->AsicID == ELECTRABUZZ_ID) { @@ -1658,7 +1658,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) if (chksum != tempword) { DEBUG(0, "Packet checksum mismatch 0x%x 0x%x\n", chksum, - tempword); + tempword); ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO); info->stats.rx_errors++; kfree_skb(skb); @@ -1685,7 +1685,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) for (i = 0; i < len / 2; i++) { tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO); *pbuffer++ = (u8) (tempword >> 8); - *pbuffer++ = (u8) tempword; + *pbuffer++ = (u8)tempword; if (ft1000_chkcard(dev) == false) { kfree_skb(skb); return FAILURE; @@ -1698,7 +1698,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) *pbuffer++ = (u8) (tempword >> 8); } } else { - ptemplong = (u32 *) pbuffer; + ptemplong = (u32 *)pbuffer; for (i = 0; i < len / 4; i++) { templong = inl(dev->base_addr + FT1000_REG_MAG_DFR); DEBUG(1, "Data = 0x%8x\n", templong); @@ -1743,17 +1743,17 @@ static int ft1000_copy_up_pkt(struct net_device *dev) /*--------------------------------------------------------------------------- - Function: ft1000_copy_down_pkt - Description: This function will take an ethernet packet and convert it to - a Flarion packet prior to sending it to the ASIC Downlink - FIFO. - Input: - dev - device structure - packet - address of ethernet packet - len - length of IP packet - Output: - status - FAILURE - SUCCESS + Function: ft1000_copy_down_pkt + Description: This function will take an ethernet packet and convert it to + a Flarion packet prior to sending it to the ASIC Downlink + FIFO. + Input: + dev - device structure + packet - address of ethernet packet + len - length of IP packet + Output: + status - FAILURE + SUCCESS -------------------------------------------------------------------------*/ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) @@ -1790,7 +1790,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) } if (len > ft1000_read_fifo_len(dev)) { DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:Transmit FIFO is fulli - pkt drop\n"); + "ft1000_hw:ft1000_copy_down_pkt:Transmit FIFO is fulli - pkt drop\n"); info->stats.tx_errors++; return SUCCESS; } @@ -1822,38 +1822,38 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) /* copy first word to UFIFO_BEG reg */ ft1000_write_reg(dev, FT1000_REG_UFIFO_BEG, pseudo.buff[0]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 0 BEG = 0x%04x\n", - pseudo.buff[0]); + pseudo.buff[0]); /* copy subsequent words to UFIFO_MID reg */ ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[1]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 1 MID = 0x%04x\n", - pseudo.buff[1]); + pseudo.buff[1]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[2]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 2 MID = 0x%04x\n", - pseudo.buff[2]); + pseudo.buff[2]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[3]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 3 MID = 0x%04x\n", - pseudo.buff[3]); + pseudo.buff[3]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[4]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 4 MID = 0x%04x\n", - pseudo.buff[4]); + pseudo.buff[4]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[5]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 5 MID = 0x%04x\n", - pseudo.buff[5]); + pseudo.buff[5]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[6]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 6 MID = 0x%04x\n", - pseudo.buff[6]); + pseudo.buff[6]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[7]); DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 7 MID = 0x%04x\n", - pseudo.buff[7]); + pseudo.buff[7]); /* Write PPP type + IP Packet into Downlink FIFO */ for (i = 0; i < (len >> 1) - 1; i++) { ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, htons(*packet)); DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", - i + 8, htons(*packet)); + "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", + i + 8, htons(*packet)); packet++; } @@ -1862,40 +1862,40 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, htons(*packet)); DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data MID = 0x%04x\n", - htons(*packet)); + "ft1000_hw:ft1000_copy_down_pkt:data MID = 0x%04x\n", + htons(*packet)); packet++; ft1000_write_reg(dev, FT1000_REG_UFIFO_END, htons(*packet)); DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", - i + 8, htons(*packet)); + "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", + i + 8, htons(*packet)); } else { ft1000_write_reg(dev, FT1000_REG_UFIFO_END, htons(*packet)); DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", - i + 8, htons(*packet)); + "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", + i + 8, htons(*packet)); } } else { - outl(*(u32 *) & pseudo.buff[0], - dev->base_addr + FT1000_REG_MAG_UFDR); + outl(*(u32 *)&pseudo.buff[0], + dev->base_addr + FT1000_REG_MAG_UFDR); DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *) & pseudo.buff[0]); - outl(*(u32 *) & pseudo.buff[2], - dev->base_addr + FT1000_REG_MAG_UFDR); + *(u32 *)&pseudo.buff[0]); + outl(*(u32 *)&pseudo.buff[2], + dev->base_addr + FT1000_REG_MAG_UFDR); DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *) & pseudo.buff[2]); - outl(*(u32 *) & pseudo.buff[4], - dev->base_addr + FT1000_REG_MAG_UFDR); + *(u32 *)&pseudo.buff[2]); + outl(*(u32 *)&pseudo.buff[4], + dev->base_addr + FT1000_REG_MAG_UFDR); DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *) & pseudo.buff[4]); - outl(*(u32 *) & pseudo.buff[6], - dev->base_addr + FT1000_REG_MAG_UFDR); + *(u32 *)&pseudo.buff[4]); + outl(*(u32 *)&pseudo.buff[6], + dev->base_addr + FT1000_REG_MAG_UFDR); DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *) & pseudo.buff[6]); + *(u32 *)&pseudo.buff[6]); - plong = (u32 *) packet; + plong = (u32 *)packet; /* Write PPP type + IP Packet into Downlink FIFO */ for (i = 0; i < (len >> 2); i++) { outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR); @@ -1904,8 +1904,8 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) /* Check for odd alignment */ if (len & 0x0003) { DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n", - *plong); + "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n", + *plong); outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR); } outl(1, dev->base_addr + FT1000_REG_MAG_UFER); @@ -1935,7 +1935,7 @@ static int ft1000_open(struct net_device *dev) /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP and ASIC */ init_timer(&poll_timer); poll_timer.expires = jiffies + (2 * HZ); - poll_timer.data = (u_long) dev; + poll_timer.data = (u_long)dev; add_timer(&poll_timer); DEBUG(0, "ft1000_hw: ft1000_open is ended2\n"); @@ -1976,9 +1976,9 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) } DEBUG(1, "ft1000_hw: ft1000_start_xmit:length of packet = %d\n", - skb->len); + skb->len); - pdata = (u8 *) skb->data; + pdata = (u8 *)skb->data; if (info->mediastate == 0) { /* Drop packet is mediastate is down */ @@ -1989,11 +1989,11 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) { /* Drop packet which has invalid size */ DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:invalid ethernet length\n"); + "ft1000_hw:ft1000_copy_down_pkt:invalid ethernet length\n"); return SUCCESS; } ft1000_copy_down_pkt(dev, (u16 *) (pdata + ENET_HEADER_SIZE - 2), - skb->len - ENET_HEADER_SIZE + 2); + skb->len - ENET_HEADER_SIZE + 2); dev_kfree_skb(skb); @@ -2038,12 +2038,12 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id) /* Check if we have packets in the Downlink FIFO */ if (info->AsicID == ELECTRABUZZ_ID) { tempword = - ft1000_read_reg(dev, - FT1000_REG_DFIFO_STAT); + ft1000_read_reg(dev, + FT1000_REG_DFIFO_STAT); } else { tempword = - ft1000_read_reg(dev, - FT1000_REG_MAG_DFSR); + ft1000_read_reg(dev, + FT1000_REG_MAG_DFSR); } if (tempword & 0x1f) { ft1000_copy_up_pkt(dev); @@ -2060,7 +2060,7 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id) ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); /* Read interrupt type */ - inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR); + inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); DEBUG(1, "ft1000_hw: interrupt status register after clear = 0x%x\n", inttype); } ft1000_enable_interrupts(dev); @@ -2103,7 +2103,7 @@ void stop_ft1000_card(struct net_device *dev) } static void ft1000_get_drvinfo(struct net_device *dev, - struct ethtool_drvinfo *info) + struct ethtool_drvinfo *info) { struct ft1000_info *ft_info; ft_info = netdev_priv(dev); @@ -2129,19 +2129,19 @@ static const struct ethtool_ops ops = { }; struct net_device *init_ft1000_card(struct pcmcia_device *link, - void *ft1000_reset) + void *ft1000_reset) { struct ft1000_info *info; struct ft1000_pcmcia *pcmcia; struct net_device *dev; static const struct net_device_ops ft1000ops = /* Slavius 21.10.2009 due to kernel changes */ - { - .ndo_open = &ft1000_open, - .ndo_stop = &ft1000_close, - .ndo_start_xmit = &ft1000_start_xmit, - .ndo_get_stats = &ft1000_stats, - }; + { + .ndo_open = &ft1000_open, + .ndo_stop = &ft1000_close, + .ndo_start_xmit = &ft1000_start_xmit, + .ndo_get_stats = &ft1000_stats, + }; DEBUG(1, "ft1000_hw: init_ft1000_card()\n"); DEBUG(1, "ft1000_hw: irq = %d\n", link->irq); @@ -2153,7 +2153,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, flarion_ft1000_cnt--; dev_info(&link->dev, - "This driver can not support more than one instance\n"); + "This driver can not support more than one instance\n"); return NULL; } @@ -2168,8 +2168,8 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, memset(info, 0, sizeof(struct ft1000_info)); - DEBUG(1, "address of dev = 0x%8x\n", (u32) dev); - DEBUG(1, "address of dev info = 0x%8x\n", (u32) info); + DEBUG(1, "address of dev = 0x%8x\n", (u32)dev); + DEBUG(1, "address of dev info = 0x%8x\n", (u32)info); DEBUG(0, "device name = %s\n", dev->name); memset(&info->stats, 0, sizeof(struct net_device_stats)); @@ -2246,7 +2246,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, ft1000_card_present = 1; dev->ethtool_ops = &ops; printk(KERN_INFO "ft1000: %s: addr 0x%04lx irq %d, MAC addr %pM\n", - dev->name, dev->base_addr, dev->irq, dev->dev_addr); + dev->name, dev->base_addr, dev->irq, dev->dev_addr); return dev; err_unreg: diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 4397ada1e387..658f3cab8e72 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -1,31 +1,31 @@ /* -*--------------------------------------------------------------------------- -* FT1000 driver for Flarion Flash OFDM NIC Device -* -* Copyright (C) 2006 Flarion Technologies, All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the Free -* Software Foundation; either version 2 of the License, or (at your option) any -* later version. This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 59 Temple Place - -* Suite 330, Boston, MA 02111-1307, USA. -*--------------------------------------------------------------------------- -* -* File: ft1000_chdev.c -* -* Description: Custom character device dispatch routines. -* -* History: -* 8/29/02 Whc Ported to Linux. -* 6/05/06 Whc Porting to Linux 2.6.9 -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * FT1000 driver for Flarion Flash OFDM NIC Device + * + * Copyright (C) 2006 Flarion Technologies, All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) any + * later version. This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - + * Suite 330, Boston, MA 02111-1307, USA. + *--------------------------------------------------------------------------- + * + * File: ft1000_chdev.c + * + * Description: Custom character device dispatch routines. + * + * History: + * 8/29/02 Whc Ported to Linux. + * 6/05/06 Whc Porting to Linux 2.6.9 + * + *--------------------------------------------------------------------------- + */ #include #include #include @@ -43,7 +43,7 @@ static int ft1000_flarion_cnt; static int ft1000_open(struct inode *inode, struct file *file); static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait); static long ft1000_ioctl(struct file *file, unsigned int command, - unsigned long argument); + unsigned long argument); static int ft1000_release(struct inode *inode, struct file *file); /* List to free receive command buffer pool */ @@ -55,8 +55,8 @@ spinlock_t free_buff_lock; int numofmsgbuf = 0; /* -* Table of entry-point routines for char device -*/ + * Table of entry-point routines for char device + */ static const struct file_operations ft1000fops = { .unlocked_ioctl = ft1000_ioctl, .poll = ft1000_poll_dev, @@ -66,104 +66,104 @@ static const struct file_operations ft1000fops = { }; /* ---------------------------------------------------------------------------- -* Function: ft1000_get_buffer -* -* Parameters: -* -* Returns: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + --------------------------------------------------------------------------- + * Function: ft1000_get_buffer + * + * Parameters: + * + * Returns: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist) { - unsigned long flags; + unsigned long flags; struct dpram_blk *ptr; - spin_lock_irqsave(&free_buff_lock, flags); - /* Check if buffer is available */ - if (list_empty(bufflist)) { - DEBUG("ft1000_get_buffer: No more buffer - %d\n", numofmsgbuf); - ptr = NULL; - } else { - numofmsgbuf--; - ptr = list_entry(bufflist->next, struct dpram_blk, list); - list_del(&ptr->list); - /* DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ - } - spin_unlock_irqrestore(&free_buff_lock, flags); - - return ptr; + spin_lock_irqsave(&free_buff_lock, flags); + /* Check if buffer is available */ + if (list_empty(bufflist)) { + DEBUG("ft1000_get_buffer: No more buffer - %d\n", numofmsgbuf); + ptr = NULL; + } else { + numofmsgbuf--; + ptr = list_entry(bufflist->next, struct dpram_blk, list); + list_del(&ptr->list); + /* DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ + } + spin_unlock_irqrestore(&free_buff_lock, flags); + + return ptr; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_free_buffer -* -* Parameters: -* -* Returns: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_free_buffer + * + * Parameters: + * + * Returns: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist) { - unsigned long flags; - - spin_lock_irqsave(&free_buff_lock, flags); - /* Put memory back to list */ - list_add_tail(&pdpram_blk->list, plist); - numofmsgbuf++; - /*DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ - spin_unlock_irqrestore(&free_buff_lock, flags); + unsigned long flags; + + spin_lock_irqsave(&free_buff_lock, flags); + /* Put memory back to list */ + list_add_tail(&pdpram_blk->list, plist); + numofmsgbuf++; + /*DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ + spin_unlock_irqrestore(&free_buff_lock, flags); } /* -*--------------------------------------------------------------------------- -* Function: ft1000_CreateDevice -* -* Parameters: dev - pointer to adapter object -* -* Returns: 0 if successful -* -* Description: Creates a private char device. -* -* Notes: Only called by init_module(). -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_CreateDevice + * + * Parameters: dev - pointer to adapter object + * + * Returns: 0 if successful + * + * Description: Creates a private char device. + * + * Notes: Only called by init_module(). + * + *--------------------------------------------------------------------------- + */ int ft1000_create_dev(struct ft1000_usb *dev) { - int result; - int i; + int result; + int i; struct dentry *dir, *file; struct ft1000_debug_dirs *tmp; - /* make a new device name */ - sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); + /* make a new device name */ + sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); - DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt); - DEBUG("DeviceCreated = %x\n", dev->DeviceCreated); + DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt); + DEBUG("DeviceCreated = %x\n", dev->DeviceCreated); - if (dev->DeviceCreated) { - DEBUG("%s: \"%s\" already registered\n", __func__, dev->DeviceName); - return -EIO; - } + if (dev->DeviceCreated) { + DEBUG("%s: \"%s\" already registered\n", __func__, dev->DeviceName); + return -EIO; + } - /* register the device */ - DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName); + /* register the device */ + DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName); tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL); if (tmp == NULL) { @@ -178,7 +178,7 @@ int ft1000_create_dev(struct ft1000_usb *dev) } file = debugfs_create_file("device", S_IRUGO | S_IWUSR, dir, - dev, &ft1000fops); + dev, &ft1000fops); if (IS_ERR(file)) { result = PTR_ERR(file); goto debug_file_fail; @@ -189,25 +189,25 @@ int ft1000_create_dev(struct ft1000_usb *dev) tmp->int_number = dev->CardNumber; list_add(&(tmp->list), &(dev->nodes.list)); - DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName); - - /* initialize application information */ - dev->appcnt = 0; - for (i=0; iapp_info[i].nTxMsg = 0; - dev->app_info[i].nRxMsg = 0; - dev->app_info[i].nTxMsgReject = 0; - dev->app_info[i].nRxMsgMiss = 0; - dev->app_info[i].fileobject = NULL; - dev->app_info[i].app_id = i+1; - dev->app_info[i].DspBCMsgFlag = 0; - dev->app_info[i].NumOfMsg = 0; - init_waitqueue_head(&dev->app_info[i].wait_dpram_msg); - INIT_LIST_HEAD(&dev->app_info[i].app_sqlist); - } - - dev->DeviceCreated = TRUE; - ft1000_flarion_cnt++; + DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName); + + /* initialize application information */ + dev->appcnt = 0; + for (i = 0; i < MAX_NUM_APP; i++) { + dev->app_info[i].nTxMsg = 0; + dev->app_info[i].nRxMsg = 0; + dev->app_info[i].nTxMsgReject = 0; + dev->app_info[i].nRxMsgMiss = 0; + dev->app_info[i].fileobject = NULL; + dev->app_info[i].app_id = i+1; + dev->app_info[i].DspBCMsgFlag = 0; + dev->app_info[i].NumOfMsg = 0; + init_waitqueue_head(&dev->app_info[i].wait_dpram_msg); + INIT_LIST_HEAD(&dev->app_info[i].app_sqlist); + } + + dev->DeviceCreated = TRUE; + ft1000_flarion_cnt++; return 0; @@ -220,33 +220,33 @@ fail: } /* -*--------------------------------------------------------------------------- -* Function: ft1000_DestroyDeviceDEBUG -* -* Parameters: dev - pointer to adapter object -* -* Description: Destroys a private char device. -* -* Notes: Only called by cleanup_module(). -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_DestroyDeviceDEBUG + * + * Parameters: dev - pointer to adapter object + * + * Description: Destroys a private char device. + * + * Notes: Only called by cleanup_module(). + * + *--------------------------------------------------------------------------- + */ void ft1000_destroy_dev(struct net_device *netdev) { struct ft1000_info *info = netdev_priv(netdev); struct ft1000_usb *dev = info->priv; - int i; + int i; struct dpram_blk *pdpram_blk; struct dpram_blk *ptr; struct list_head *pos, *q; struct ft1000_debug_dirs *dir; - DEBUG("%s called\n", __func__); + DEBUG("%s called\n", __func__); - if (dev->DeviceCreated) { - ft1000_flarion_cnt--; + if (dev->DeviceCreated) { + ft1000_flarion_cnt--; list_for_each_safe(pos, q, &dev->nodes.list) { dir = list_entry(pos, struct ft1000_debug_dirs, list); if (dir->int_number == dev->CardNumber) { @@ -257,28 +257,28 @@ void ft1000_destroy_dev(struct net_device *netdev) } } DEBUG("%s: unregistered device \"%s\"\n", __func__, - dev->DeviceName); - - /* Make sure we free any memory reserve for slow Queue */ - for (i=0; iapp_info[i].app_sqlist) == 0) { - pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list); - list_del(&pdpram_blk->list); - ft1000_free_buffer(pdpram_blk, &freercvpool); - - } - wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); - } - - /* Remove buffer allocated for receive command data */ - if (ft1000_flarion_cnt == 0) { - while (list_empty(&freercvpool) == 0) { - ptr = list_entry(freercvpool.next, struct dpram_blk, list); - list_del(&ptr->list); - kfree(ptr->pbuffer); - kfree(ptr); - } - } + dev->DeviceName); + + /* Make sure we free any memory reserve for slow Queue */ + for (i = 0; i < MAX_NUM_APP; i++) { + while (list_empty(&dev->app_info[i].app_sqlist) == 0) { + pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list); + list_del(&pdpram_blk->list); + ft1000_free_buffer(pdpram_blk, &freercvpool); + + } + wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); + } + + /* Remove buffer allocated for receive command data */ + if (ft1000_flarion_cnt == 0) { + while (list_empty(&freercvpool) == 0) { + ptr = list_entry(freercvpool.next, struct dpram_blk, list); + list_del(&ptr->list); + kfree(ptr->pbuffer); + kfree(ptr); + } + } dev->DeviceCreated = FALSE; } @@ -286,503 +286,503 @@ void ft1000_destroy_dev(struct net_device *netdev) } /* -*--------------------------------------------------------------------------- -* Function: ft1000_open -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_open + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static int ft1000_open(struct inode *inode, struct file *file) { struct ft1000_info *info; struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private; - int i,num; + int i, num; - DEBUG("%s called\n", __func__); - num = (MINOR(inode->i_rdev) & 0xf); - DEBUG("ft1000_open: minor number=%d\n", num); + DEBUG("%s called\n", __func__); + num = (MINOR(inode->i_rdev) & 0xf); + DEBUG("ft1000_open: minor number=%d\n", num); info = file->private_data = netdev_priv(dev->net); - DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt); - - /* Check if maximum number of application exceeded */ - if (dev->appcnt > MAX_NUM_APP) { - DEBUG("Maximum number of application exceeded\n"); - return -EACCES; - } - - /* Search for available application info block */ - for (i=0; iapp_info[i].fileobject == NULL)) { - break; - } - } - - /* Fail due to lack of application info block */ - if (i == MAX_NUM_APP) { - DEBUG("Could not find an application info block\n"); - return -EACCES; - } - - dev->appcnt++; - dev->app_info[i].fileobject = &file->f_owner; - dev->app_info[i].nTxMsg = 0; - dev->app_info[i].nRxMsg = 0; - dev->app_info[i].nTxMsgReject = 0; - dev->app_info[i].nRxMsgMiss = 0; + DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt); + + /* Check if maximum number of application exceeded */ + if (dev->appcnt > MAX_NUM_APP) { + DEBUG("Maximum number of application exceeded\n"); + return -EACCES; + } + + /* Search for available application info block */ + for (i = 0; i < MAX_NUM_APP; i++) { + if ((dev->app_info[i].fileobject == NULL)) { + break; + } + } + + /* Fail due to lack of application info block */ + if (i == MAX_NUM_APP) { + DEBUG("Could not find an application info block\n"); + return -EACCES; + } + + dev->appcnt++; + dev->app_info[i].fileobject = &file->f_owner; + dev->app_info[i].nTxMsg = 0; + dev->app_info[i].nRxMsg = 0; + dev->app_info[i].nTxMsgReject = 0; + dev->app_info[i].nRxMsgMiss = 0; nonseekable_open(inode, file); - return 0; + return 0; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_poll_dev -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_poll_dev + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) { - struct net_device *netdev = file->private_data; + struct net_device *netdev = file->private_data; struct ft1000_info *info = netdev_priv(netdev); struct ft1000_usb *dev = info->priv; - int i; - - /* DEBUG("ft1000_poll_dev called\n"); */ - if (ft1000_flarion_cnt == 0) { - DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n"); - return -EBADF; - } - - /* Search for matching file object */ - for (i=0; iapp_info[i].fileobject == &file->f_owner) { - /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id); */ - break; - } - } - - /* Could not find application info block */ - if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); - return -EACCES; - } - - if (list_empty(&dev->app_info[i].app_sqlist) == 0) { - DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n"); - return(POLLIN | POLLRDNORM | POLLPRI); - } - - poll_wait(file, &dev->app_info[i].wait_dpram_msg, wait); - /* DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); */ + int i; + + /* DEBUG("ft1000_poll_dev called\n"); */ + if (ft1000_flarion_cnt == 0) { + DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n"); + return -EBADF; + } + + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (dev->app_info[i].fileobject == &file->f_owner) { + /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id); */ + break; + } + } + + /* Could not find application info block */ + if (i == MAX_NUM_APP) { + DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); + return -EACCES; + } + + if (list_empty(&dev->app_info[i].app_sqlist) == 0) { + DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n"); + return(POLLIN | POLLRDNORM | POLLPRI); + } + + poll_wait(file, &dev->app_info[i].wait_dpram_msg, wait); + /* DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); */ return 0; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_ioctl -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_ioctl + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static long ft1000_ioctl(struct file *file, unsigned int command, - unsigned long argument) + unsigned long argument) { - void __user *argp = (void __user *)argument; + void __user *argp = (void __user *)argument; struct ft1000_info *info; - struct ft1000_usb *ft1000dev; - int result=0; - int cmd; - int i; - u16 tempword; - unsigned long flags; - struct timeval tv; + struct ft1000_usb *ft1000dev; + int result = 0; + int cmd; + int i; + u16 tempword; + unsigned long flags; + struct timeval tv; struct IOCTL_GET_VER get_ver_data; struct IOCTL_GET_DSP_STAT get_stat_data; - u8 ConnectionMsg[] = {0x00,0x44,0x10,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x93,0x64, - 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x02,0x37,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x01,0x7f,0x00, - 0x00,0x01,0x00,0x00}; + u8 ConnectionMsg[] = {0x00, 0x44, 0x10, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x93, 0x64, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x37, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7f, 0x00, + 0x00, 0x01, 0x00, 0x00}; - unsigned short ledStat=0; - unsigned short conStat=0; + unsigned short ledStat = 0; + unsigned short conStat = 0; - /* DEBUG("ft1000_ioctl called\n"); */ + /* DEBUG("ft1000_ioctl called\n"); */ - if (ft1000_flarion_cnt == 0) { - DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n"); - return -EBADF; - } + if (ft1000_flarion_cnt == 0) { + DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n"); + return -EBADF; + } - /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ + /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ info = file->private_data; ft1000dev = info->priv; - cmd = _IOC_NR(command); - /* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */ - - /* process the command */ - switch (cmd) { - case IOCTL_REGISTER_CMD: - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n"); - result = get_user(tempword, (__u16 __user*)argp); - if (result) { - DEBUG("result = %d failed to get_user\n", result); - break; - } - if (tempword == DSPBCMSGID) { - /* Search for matching file object */ - for (i=0; iapp_info[i].fileobject == &file->f_owner) { - ft1000dev->app_info[i].DspBCMsgFlag = 1; - DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n"); - break; - } - } - } - break; - - case IOCTL_GET_VER_CMD: - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_VER called\n"); - - get_ver_data.drv_ver = FT1000_DRV_VER; - - if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); - result = -EFAULT; - break; - } - - DEBUG("FT1000:ft1000_ioctl:driver version = 0x%x\n",(unsigned int)get_ver_data.drv_ver); - - break; - case IOCTL_CONNECT: - /* Connect Message */ - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n"); - ConnectionMsg[79] = 0xfc; - result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); - - break; - case IOCTL_DISCONNECT: - /* Disconnect Message */ - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n"); - ConnectionMsg[79] = 0xfd; - result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); - break; - case IOCTL_GET_DSP_STAT_CMD: - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */ - memset(&get_stat_data, 0, sizeof(get_stat_data)); - memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ); - memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ); - memcpy(get_stat_data.Sku, info->Sku, SKUSZ); - memcpy(get_stat_data.eui64, info->eui64, EUISZ); - - if (info->ProgConStat != 0xFF) { - ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); - get_stat_data.LedStat = ntohs(ledStat); - DEBUG("FT1000:ft1000_ioctl: LedStat = 0x%x\n", get_stat_data.LedStat); - ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX); - get_stat_data.ConStat = ntohs(conStat); - DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat); - } else { - get_stat_data.ConStat = 0x0f; - } - - - get_stat_data.nTxPkts = info->stats.tx_packets; - get_stat_data.nRxPkts = info->stats.rx_packets; - get_stat_data.nTxBytes = info->stats.tx_bytes; - get_stat_data.nRxBytes = info->stats.rx_bytes; - do_gettimeofday(&tv); - get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm); - DEBUG("Connection Time = %d\n", (int)get_stat_data.ConTm); - if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); - result = -EFAULT; - break; - } - DEBUG("ft1000_chioctl: GET_DSP_STAT succeed\n"); - break; - case IOCTL_SET_DPRAM_CMD: - { + cmd = _IOC_NR(command); + /* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */ + + /* process the command */ + switch (cmd) { + case IOCTL_REGISTER_CMD: + DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n"); + result = get_user(tempword, (__u16 __user *)argp); + if (result) { + DEBUG("result = %d failed to get_user\n", result); + break; + } + if (tempword == DSPBCMSGID) { + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + ft1000dev->app_info[i].DspBCMsgFlag = 1; + DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n"); + break; + } + } + } + break; + + case IOCTL_GET_VER_CMD: + DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_VER called\n"); + + get_ver_data.drv_ver = FT1000_DRV_VER; + + if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) { + DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); + result = -EFAULT; + break; + } + + DEBUG("FT1000:ft1000_ioctl:driver version = 0x%x\n", (unsigned int)get_ver_data.drv_ver); + + break; + case IOCTL_CONNECT: + /* Connect Message */ + DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n"); + ConnectionMsg[79] = 0xfc; + result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); + + break; + case IOCTL_DISCONNECT: + /* Disconnect Message */ + DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n"); + ConnectionMsg[79] = 0xfd; + result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); + break; + case IOCTL_GET_DSP_STAT_CMD: + /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */ + memset(&get_stat_data, 0, sizeof(get_stat_data)); + memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ); + memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ); + memcpy(get_stat_data.Sku, info->Sku, SKUSZ); + memcpy(get_stat_data.eui64, info->eui64, EUISZ); + + if (info->ProgConStat != 0xFF) { + ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); + get_stat_data.LedStat = ntohs(ledStat); + DEBUG("FT1000:ft1000_ioctl: LedStat = 0x%x\n", get_stat_data.LedStat); + ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX); + get_stat_data.ConStat = ntohs(conStat); + DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat); + } else { + get_stat_data.ConStat = 0x0f; + } + + + get_stat_data.nTxPkts = info->stats.tx_packets; + get_stat_data.nRxPkts = info->stats.rx_packets; + get_stat_data.nTxBytes = info->stats.tx_bytes; + get_stat_data.nRxBytes = info->stats.rx_bytes; + do_gettimeofday(&tv); + get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm); + DEBUG("Connection Time = %d\n", (int)get_stat_data.ConTm); + if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) { + DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); + result = -EFAULT; + break; + } + DEBUG("ft1000_chioctl: GET_DSP_STAT succeed\n"); + break; + case IOCTL_SET_DPRAM_CMD: + { struct IOCTL_DPRAM_BLK *dpram_data = NULL; /* struct IOCTL_DPRAM_COMMAND dpram_command; */ - u16 qtype; - u16 msgsz; + u16 qtype; + u16 msgsz; struct pseudo_hdr *ppseudo_hdr; - u16 *pmsg; - u16 total_len; - u16 app_index; - u16 status; + u16 *pmsg; + u16 total_len; + u16 app_index; + u16 status; - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/ + /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/ - if (ft1000_flarion_cnt == 0) - return -EBADF; + if (ft1000_flarion_cnt == 0) + return -EBADF; - if (ft1000dev->DrvMsgPend) - return -ENOTTY; + if (ft1000dev->DrvMsgPend) + return -ENOTTY; - if (ft1000dev->fProvComplete == 0) - return -EACCES; + if (ft1000dev->fProvComplete == 0) + return -EACCES; - ft1000dev->fAppMsgPend = 1; + ft1000dev->fAppMsgPend = 1; - if (info->CardReady) { + if (info->CardReady) { - /* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */ + /* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */ - /* Get the length field to see how many bytes to copy */ - result = get_user(msgsz, (__u16 __user *)argp); - if (result) - break; - msgsz = ntohs(msgsz); - /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */ - - if (msgsz > MAX_CMD_SQSIZE) { - DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz); - result = -EINVAL; - break; - } - - result = -ENOMEM; - dpram_data = kmalloc(msgsz + 2, GFP_KERNEL); - if (!dpram_data) - break; + /* Get the length field to see how many bytes to copy */ + result = get_user(msgsz, (__u16 __user *)argp); + if (result) + break; + msgsz = ntohs(msgsz); + /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */ + + if (msgsz > MAX_CMD_SQSIZE) { + DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz); + result = -EINVAL; + break; + } - if (copy_from_user(dpram_data, argp, msgsz+2)) { - DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n"); - result = -EFAULT; - } else { - /* Check if this message came from a registered application */ - for (i=0; iapp_info[i].fileobject == &file->f_owner) { - break; - } - } - if (i==MAX_NUM_APP) { - DEBUG("FT1000:No matching application fileobject\n"); - result = -EINVAL; - kfree(dpram_data); - break; - } - app_index = i; - - /* Check message qtype type which is the lower byte within qos_class */ - qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; - /* DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); */ - if (qtype) { - } else { - /* Put message into Slow Queue */ - /* Only put a message into the DPRAM if msg doorbell is available */ - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - /* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */ - if (tempword & FT1000_DB_DPRAM_TX) { - /* Suspend for 2ms and try again due to DSP doorbell busy */ - mdelay(2); - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - /* Suspend for 1ms and try again due to DSP doorbell busy */ - mdelay(1); - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - /* Suspend for 3ms and try again due to DSP doorbell busy */ - mdelay(3); - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - DEBUG("FT1000:ft1000_ioctl:Doorbell not available\n"); - result = -ENOTTY; - kfree(dpram_data); - break; - } - } - } - } - } - - /*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */ - - /* Make sure we are within the limits of the slow queue memory limitation */ - if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) { - /* Need to put sequence number plus new checksum for message */ - pmsg = (u16 *)&dpram_data->pseudohdr; - ppseudo_hdr = (struct pseudo_hdr *)pmsg; - total_len = msgsz+2; - if (total_len & 0x1) { - total_len++; - } - - /* Insert slow queue sequence number */ - ppseudo_hdr->seq_num = info->squeseqnum++; - ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; - /* Calculate new checksum */ - ppseudo_hdr->checksum = *pmsg++; - /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ - for (i=1; i<7; i++) { - ppseudo_hdr->checksum ^= *pmsg++; - /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ - } - pmsg++; - ppseudo_hdr = (struct pseudo_hdr *)pmsg; - result = card_send_command(ft1000dev,(unsigned short*)dpram_data,total_len+2); - - - ft1000dev->app_info[app_index].nTxMsg++; - } else { - result = -EINVAL; - } - } - } - } else { - DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n"); - result = -EACCES; - } - kfree(dpram_data); - - } - break; - case IOCTL_GET_DPRAM_CMD: - { + result = -ENOMEM; + dpram_data = kmalloc(msgsz + 2, GFP_KERNEL); + if (!dpram_data) + break; + + if (copy_from_user(dpram_data, argp, msgsz+2)) { + DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n"); + result = -EFAULT; + } else { + /* Check if this message came from a registered application */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + break; + } + } + if (i == MAX_NUM_APP) { + DEBUG("FT1000:No matching application fileobject\n"); + result = -EINVAL; + kfree(dpram_data); + break; + } + app_index = i; + + /* Check message qtype type which is the lower byte within qos_class */ + qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; + /* DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); */ + if (qtype) { + } else { + /* Put message into Slow Queue */ + /* Only put a message into the DPRAM if msg doorbell is available */ + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + /* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */ + if (tempword & FT1000_DB_DPRAM_TX) { + /* Suspend for 2ms and try again due to DSP doorbell busy */ + mdelay(2); + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + /* Suspend for 1ms and try again due to DSP doorbell busy */ + mdelay(1); + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + /* Suspend for 3ms and try again due to DSP doorbell busy */ + mdelay(3); + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + DEBUG("FT1000:ft1000_ioctl:Doorbell not available\n"); + result = -ENOTTY; + kfree(dpram_data); + break; + } + } + } + } + } + + /*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */ + + /* Make sure we are within the limits of the slow queue memory limitation */ + if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) { + /* Need to put sequence number plus new checksum for message */ + pmsg = (u16 *)&dpram_data->pseudohdr; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; + total_len = msgsz+2; + if (total_len & 0x1) { + total_len++; + } + + /* Insert slow queue sequence number */ + ppseudo_hdr->seq_num = info->squeseqnum++; + ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; + /* Calculate new checksum */ + ppseudo_hdr->checksum = *pmsg++; + /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ + for (i = 1; i < 7; i++) { + ppseudo_hdr->checksum ^= *pmsg++; + /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ + } + pmsg++; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; + result = card_send_command(ft1000dev, (unsigned short *)dpram_data, total_len+2); + + + ft1000dev->app_info[app_index].nTxMsg++; + } else { + result = -EINVAL; + } + } + } + } else { + DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n"); + result = -EACCES; + } + kfree(dpram_data); + + } + break; + case IOCTL_GET_DPRAM_CMD: + { struct dpram_blk *pdpram_blk; struct IOCTL_DPRAM_BLK __user *pioctl_dpram; - int msglen; - - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ - - if (ft1000_flarion_cnt == 0) - return -EBADF; - - /* Search for matching file object */ - for (i=0; iapp_info[i].fileobject == &file->f_owner) { - /*DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ - break; - } - } - - /* Could not find application info block */ - if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); - result = -EBADF; - break; - } - - result = 0; - pioctl_dpram = argp; - if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { - /* DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); */ - spin_lock_irqsave(&free_buff_lock, flags); - pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); - list_del(&pdpram_blk->list); - ft1000dev->app_info[i].NumOfMsg--; - /* DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */ - spin_unlock_irqrestore(&free_buff_lock, flags); - msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; - result = get_user(msglen, &pioctl_dpram->total_len); - if (result) - break; - msglen = htons(msglen); - /* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */ - if (copy_to_user (&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); - result = -EFAULT; + int msglen; + + /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ + + if (ft1000_flarion_cnt == 0) + return -EBADF; + + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + /*DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ + break; + } + } + + /* Could not find application info block */ + if (i == MAX_NUM_APP) { + DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); + result = -EBADF; break; - } + } + + result = 0; + pioctl_dpram = argp; + if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { + /* DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); */ + spin_lock_irqsave(&free_buff_lock, flags); + pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); + list_del(&pdpram_blk->list); + ft1000dev->app_info[i].NumOfMsg--; + /* DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */ + spin_unlock_irqrestore(&free_buff_lock, flags); + msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; + result = get_user(msglen, &pioctl_dpram->total_len); + if (result) + break; + msglen = htons(msglen); + /* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */ + if (copy_to_user(&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) { + DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); + result = -EFAULT; + break; + } - ft1000_free_buffer(pdpram_blk, &freercvpool); - result = msglen; - } - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */ - } - break; - - default: - DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command); - result = -ENOTTY; - break; - } - ft1000dev->fAppMsgPend = 0; - return result; + ft1000_free_buffer(pdpram_blk, &freercvpool); + result = msglen; + } + /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */ + } + break; + + default: + DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command); + result = -ENOTTY; + break; + } + ft1000dev->fAppMsgPend = 0; + return result; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_release -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_release + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static int ft1000_release(struct inode *inode, struct file *file) { struct ft1000_info *info; - struct net_device *dev; - struct ft1000_usb *ft1000dev; - int i; + struct net_device *dev; + struct ft1000_usb *ft1000dev; + int i; struct dpram_blk *pdpram_blk; - DEBUG("ft1000_release called\n"); + DEBUG("ft1000_release called\n"); - dev = file->private_data; + dev = file->private_data; info = netdev_priv(dev); ft1000dev = info->priv; - if (ft1000_flarion_cnt == 0) { - ft1000dev->appcnt--; - return -EBADF; - } - - /* Search for matching file object */ - for (i=0; iapp_info[i].fileobject == &file->f_owner) { - /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ - break; - } - } - - if (i==MAX_NUM_APP) - return 0; - - while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { - DEBUG("Remove and free memory queue up on slow queue\n"); - pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); - list_del(&pdpram_blk->list); - ft1000_free_buffer(pdpram_blk, &freercvpool); - } - - /* initialize application information */ - ft1000dev->appcnt--; - DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt); - ft1000dev->app_info[i].fileobject = NULL; - - return 0; + if (ft1000_flarion_cnt == 0) { + ft1000dev->appcnt--; + return -EBADF; + } + + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ + break; + } + } + + if (i == MAX_NUM_APP) + return 0; + + while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { + DEBUG("Remove and free memory queue up on slow queue\n"); + pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); + list_del(&pdpram_blk->list); + ft1000_free_buffer(pdpram_blk, &freercvpool); + } + + /* initialize application information */ + ft1000dev->appcnt--; + DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt); + ft1000dev->app_info[i].fileobject = NULL; + + return 0; } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index fe882bd69e38..2cce4224485b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1,8 +1,8 @@ /* -* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -* -* This file is part of Express Card USB Driver -*/ + * CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. + * + * This file is part of Express Card USB Driver + */ #include #include @@ -117,17 +117,17 @@ static int check_usb_db(struct ft1000_usb *ft1000dev) while (loopcnt < 10) { status = ft1000_read_register(ft1000dev, &temp, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); DEBUG("check_usb_db: read FT1000_REG_DOORBELL value is %x\n", - temp); + temp); if (temp & 0x0080) { DEBUG("FT1000:Got checkusb doorbell\n"); status = ft1000_write_register(ft1000dev, 0x0080, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); status = ft1000_write_register(ft1000dev, 0x0100, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); status = ft1000_write_register(ft1000dev, 0x8000, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); break; } loopcnt++; @@ -138,7 +138,7 @@ static int check_usb_db(struct ft1000_usb *ft1000dev) loopcnt = 0; while (loopcnt < 20) { status = ft1000_read_register(ft1000dev, &temp, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); DEBUG("FT1000:check_usb_db:Doorbell = 0x%x\n", temp); if (temp & 0x8000) { loopcnt++; @@ -164,10 +164,10 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) while (loopcnt < 100) { /* Need to clear downloader doorbell if Hartley ASIC */ status = ft1000_write_register(ft1000dev, FT1000_DB_DNLD_RX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (ft1000dev->fcodeldr) { DEBUG(" get_handshake: fcodeldr is %d\n", - ft1000dev->fcodeldr); + ft1000dev->fcodeldr); ft1000dev->fcodeldr = 0; status = check_usb_db(ft1000dev); if (status != 0) { @@ -175,12 +175,12 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) break; } status = ft1000_write_register(ft1000dev, - FT1000_DB_DNLD_RX, - FT1000_REG_DOORBELL); + FT1000_DB_DNLD_RX, + FT1000_REG_DOORBELL); } status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1); + DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1); handshake = ntohs(handshake); if (status) @@ -209,12 +209,12 @@ static void put_handshake(struct ft1000_usb *ft1000dev, u16 handshake_value) tempword = (u16)(tempx & 0xffff); status = ft1000_write_dpram16(ft1000dev, DWNLD_MAG1_HANDSHAKE_LOC, - tempword, 0); + tempword, 0); tempword = (u16)(tempx >> 16); status = ft1000_write_dpram16(ft1000dev, DWNLD_MAG1_HANDSHAKE_LOC, - tempword, 1); + tempword, 1); status = ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); } static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) @@ -230,27 +230,27 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) while (loopcnt < 100) { if (ft1000dev->usbboot == 2) { status = ft1000_read_dpram32(ft1000dev, 0, - (u8 *)&(ft1000dev->tempbuf[0]), 64); + (u8 *)&(ft1000dev->tempbuf[0]), 64); for (temp = 0; temp < 16; temp++) { DEBUG("tempbuf %d = 0x%x\n", temp, - ft1000dev->tempbuf[temp]); + ft1000dev->tempbuf[temp]); } status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_HANDSHAKE_LOC, - (u8 *)&handshake, 1); + DWNLD_MAG1_HANDSHAKE_LOC, + (u8 *)&handshake, 1); DEBUG("handshake from read_dpram16 = 0x%x\n", - handshake); + handshake); if (ft1000dev->dspalive == ft1000dev->tempbuf[6]) { handshake = 0; } else { handshake = ft1000dev->tempbuf[1]; ft1000dev->dspalive = - ft1000dev->tempbuf[6]; + ft1000dev->tempbuf[6]; } } else { status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_HANDSHAKE_LOC, - (u8 *)&handshake, 1); + DWNLD_MAG1_HANDSHAKE_LOC, + (u8 *)&handshake, 1); } loopcnt++; @@ -281,12 +281,12 @@ static u16 get_request_type(struct ft1000_usb *ft1000dev) if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, - DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); + DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); tempx = ntohl(tempx); } else { tempx = 0; status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_TYPE_LOC, (u8 *)&tempword, 1); + DWNLD_MAG1_TYPE_LOC, (u8 *)&tempword, 1); tempx |= (tempword << 16); tempx = ntohl(tempx); } @@ -304,7 +304,7 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, - DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); + DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); tempx = ntohl(tempx); } else { if (ft1000dev->usbboot == 2) { @@ -313,8 +313,8 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) } else { tempx = 0; status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_TYPE_LOC, - (u8 *)&tempword, 1); + DWNLD_MAG1_TYPE_LOC, + (u8 *)&tempword, 1); } tempx |= (tempword << 16); tempx = ntohl(tempx); @@ -332,14 +332,14 @@ static long get_request_value(struct ft1000_usb *ft1000dev) if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, - DWNLD_MAG1_SIZE_LOC, (u8 *)&value); + DWNLD_MAG1_SIZE_LOC, (u8 *)&value); value = ntohl(value); } else { status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 0); + DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 0); value = tempword; status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 1); + DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 1); value |= (tempword << 16); value = ntohl(value); } @@ -369,7 +369,7 @@ static u16 hdr_checksum(struct pseudo_hdr *pHdr) chksum = ((((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^ - usPtr[4]) ^ usPtr[5]) ^ usPtr[6]); + usPtr[4]) ^ usPtr[5]) ^ usPtr[6]); return chksum; } @@ -387,7 +387,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset) } static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, - u16 tempbuffer[], u16 dpram) + u16 tempbuffer[], u16 dpram) { int status; u16 resultbuffer[64]; @@ -395,37 +395,37 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, for (i = 0; i < 10; i++) { status = ft1000_write_dpram32(ft1000dev, dpram, - (u8 *)&tempbuffer[0], 64); + (u8 *)&tempbuffer[0], 64); if (status == 0) { /* Work around for ASIC bit stuffing problem. */ if ((tempbuffer[31] & 0xfe00) == 0xfe00) { status = ft1000_write_dpram32(ft1000dev, - dpram+12, (u8 *)&tempbuffer[24], - 64); + dpram+12, (u8 *)&tempbuffer[24], + 64); } /* Let's check the data written */ status = ft1000_read_dpram32(ft1000dev, dpram, - (u8 *)&resultbuffer[0], 64); + (u8 *)&resultbuffer[0], 64); if ((tempbuffer[31] & 0xfe00) == 0xfe00) { if (check_buffers(tempbuffer, resultbuffer, 28, - 0)) { + 0)) { DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); usleep_range(9000, 11000); break; } status = ft1000_read_dpram32(ft1000dev, - dpram+12, - (u8 *)&resultbuffer[0], 64); + dpram+12, + (u8 *)&resultbuffer[0], 64); if (check_buffers(tempbuffer, resultbuffer, 16, - 24)) { + 24)) { DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n"); usleep_range(9000, 11000); break; } } else { if (check_buffers(tempbuffer, resultbuffer, 32, - 0)) { + 0)) { DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n"); usleep_range(9000, 11000); break; @@ -445,7 +445,7 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, * long word_length - length of the buffer to be written to DPRAM */ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, - long word_length) + long word_length) { int status = 0; u16 dpram; @@ -489,13 +489,13 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, if (ft1000dev->bootmode == 0) { if (dpram >= 0x3F4) status = ft1000_write_dpram32(ft1000dev, dpram, - (u8 *)&tempbuffer[0], 8); + (u8 *)&tempbuffer[0], 8); else status = ft1000_write_dpram32(ft1000dev, dpram, - (u8 *)&tempbuffer[0], 64); + (u8 *)&tempbuffer[0], 64); } else { status = write_dpram32_and_check(ft1000dev, tempbuffer, - dpram); + dpram); if (status != 0) { DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); break; @@ -548,7 +548,7 @@ static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, } static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, - u32 *state) + u32 *state) { int status = 0; @@ -571,7 +571,7 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, } static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, - u8 **c_file, const u8 *endpoint, bool boot_case) + u8 **c_file, const u8 *endpoint, bool boot_case) { long word_length; int status = 0; @@ -602,7 +602,7 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, ft1000dev->usbboot++; if (ft1000dev->usbboot == 1) status |= ft1000_write_dpram16(ft1000dev, - DWNLD_MAG1_PS_HDR_LOC, 0, 0); + DWNLD_MAG1_PS_HDR_LOC, 0, 0); } return status; } @@ -705,14 +705,14 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; case REQUEST_CODE_SEGMENT: status = request_code_segment(ft1000dev, - &s_file, &c_file, - (const u8 *)boot_end, - true); - break; + &s_file, &c_file, + (const u8 *)boot_end, + true); + break; default: DEBUG - ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n", - request); + ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n", + request); status = -1; break; } @@ -724,7 +724,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, HANDSHAKE_RESPONSE); } else { DEBUG - ("FT1000:download:Download error: Handshake failed\n"); + ("FT1000:download:Download error: Handshake failed\n"); status = -1; } @@ -735,56 +735,56 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, ft1000dev->bootmode = 0; if (ft1000dev->usbboot) handshake = - get_handshake_usb(ft1000dev, - HANDSHAKE_REQUEST); + get_handshake_usb(ft1000dev, + HANDSHAKE_REQUEST); else handshake = - get_handshake(ft1000dev, HANDSHAKE_REQUEST); + get_handshake(ft1000dev, HANDSHAKE_REQUEST); if (handshake == HANDSHAKE_REQUEST) { /* * Get type associated with the request. */ if (ft1000dev->usbboot) request = - get_request_type_usb(ft1000dev); + get_request_type_usb(ft1000dev); else request = get_request_type(ft1000dev); switch (request) { case REQUEST_FILE_CHECKSUM: DEBUG - ("FT1000:download:image_chksum = 0x%8x\n", - image_chksum); + ("FT1000:download:image_chksum = 0x%8x\n", + image_chksum); put_request_value(ft1000dev, image_chksum); break; case REQUEST_RUN_ADDRESS: DEBUG - ("FT1000:download: REQUEST_RUN_ADDRESS\n"); + ("FT1000:download: REQUEST_RUN_ADDRESS\n"); if (correct_version) { DEBUG - ("FT1000:download:run_address = 0x%8x\n", - (int)run_address); + ("FT1000:download:run_address = 0x%8x\n", + (int)run_address); put_request_value(ft1000dev, run_address); } else { DEBUG - ("FT1000:download:Download error: Got Run address request before image offset request.\n"); + ("FT1000:download:Download error: Got Run address request before image offset request.\n"); status = -1; break; } break; case REQUEST_CODE_LENGTH: DEBUG - ("FT1000:download:REQUEST_CODE_LENGTH\n"); + ("FT1000:download:REQUEST_CODE_LENGTH\n"); if (correct_version) { DEBUG - ("FT1000:download:run_size = 0x%8x\n", - (int)run_size); + ("FT1000:download:run_size = 0x%8x\n", + (int)run_size); put_request_value(ft1000dev, run_size); } else { DEBUG - ("FT1000:download:Download error: Got Size request before image offset request.\n"); + ("FT1000:download:Download error: Got Size request before image offset request.\n"); status = -1; break; } @@ -793,47 +793,47 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, ft1000dev->usbboot = 3; /* Reposition ptrs to beginning of provisioning section */ s_file = - (u16 *) (pFileStart + - file_hdr->commands_offset); + (u16 *) (pFileStart + + file_hdr->commands_offset); c_file = - (u8 *) (pFileStart + - file_hdr->commands_offset); + (u8 *) (pFileStart + + file_hdr->commands_offset); state = STATE_DONE_DWNLD; break; case REQUEST_CODE_SEGMENT: /* DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); */ if (!correct_version) { DEBUG - ("FT1000:download:Download error: Got Code Segment request before image offset request.\n"); + ("FT1000:download:Download error: Got Code Segment request before image offset request.\n"); status = -1; break; } status = request_code_segment(ft1000dev, - &s_file, &c_file, - (const u8 *)code_end, - false); + &s_file, &c_file, + (const u8 *)code_end, + false); break; case REQUEST_MAILBOX_DATA: DEBUG - ("FT1000:download: REQUEST_MAILBOX_DATA\n"); + ("FT1000:download: REQUEST_MAILBOX_DATA\n"); /* Convert length from byte count to word count. Make sure we round up. */ word_length = - (long)(pft1000info->DSPInfoBlklen + - 1) / 2; + (long)(pft1000info->DSPInfoBlklen + + 1) / 2; put_request_value(ft1000dev, word_length); mailbox_data = - (struct drv_msg *)&(pft1000info-> - DSPInfoBlk[0]); + (struct drv_msg *)&(pft1000info-> + DSPInfoBlk[0]); /* * Position ASIC DPRAM auto-increment pointer. */ - data = (u16 *) &mailbox_data->data[0]; - dpram = (u16) DWNLD_MAG1_PS_HDR_LOC; + data = (u16 *)&mailbox_data->data[0]; + dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; if (word_length & 0x1) word_length++; @@ -844,18 +844,18 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, templong = *data++; templong |= (*data++ << 16); status = - fix_ft1000_write_dpram32 - (ft1000dev, dpram++, - (u8 *) &templong); + fix_ft1000_write_dpram32 + (ft1000dev, dpram++, + (u8 *)&templong); } break; case REQUEST_VERSION_INFO: DEBUG - ("FT1000:download:REQUEST_VERSION_INFO\n"); + ("FT1000:download:REQUEST_VERSION_INFO\n"); word_length = - file_hdr->version_data_size; + file_hdr->version_data_size; put_request_value(ft1000dev, word_length); /* @@ -863,11 +863,11 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, */ s_file = - (u16 *) (pFileStart + - file_hdr-> - version_data_offset); + (u16 *) (pFileStart + + file_hdr-> + version_data_offset); - dpram = (u16) DWNLD_MAG1_PS_HDR_LOC; + dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; if (word_length & 0x1) word_length++; @@ -879,26 +879,26 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, temp = ntohs(*s_file++); templong |= (temp << 16); status = - fix_ft1000_write_dpram32 - (ft1000dev, dpram++, - (u8 *) &templong); + fix_ft1000_write_dpram32 + (ft1000dev, dpram++, + (u8 *)&templong); } break; case REQUEST_CODE_BY_VERSION: DEBUG - ("FT1000:download:REQUEST_CODE_BY_VERSION\n"); + ("FT1000:download:REQUEST_CODE_BY_VERSION\n"); correct_version = false; requested_version = - get_request_value(ft1000dev); + get_request_value(ft1000dev); dsp_img_info = - (struct dsp_image_info *)(pFileStart - + - sizeof - (struct - dsp_file_hdr)); + (struct dsp_image_info *)(pFileStart + + + sizeof + (struct + dsp_file_hdr)); for (image = 0; image < file_hdr->nDspImages; @@ -908,29 +908,29 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, requested_version) { correct_version = true; DEBUG - ("FT1000:download: correct_version is TRUE\n"); + ("FT1000:download: correct_version is TRUE\n"); s_file = - (u16 *) (pFileStart - + - dsp_img_info-> - begin_offset); + (u16 *) (pFileStart + + + dsp_img_info-> + begin_offset); c_file = - (u8 *) (pFileStart + - dsp_img_info-> - begin_offset); + (u8 *) (pFileStart + + dsp_img_info-> + begin_offset); code_end = - (u8 *) (pFileStart + - dsp_img_info-> - end_offset); + (u8 *) (pFileStart + + dsp_img_info-> + end_offset); run_address = - dsp_img_info-> - run_address; + dsp_img_info-> + run_address; run_size = - dsp_img_info-> - image_size; + dsp_img_info-> + image_size; image_chksum = - (u32) dsp_img_info-> - checksum; + (u32)dsp_img_info-> + checksum; break; } dsp_img_info++; @@ -942,8 +942,8 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, * Error, beyond boot code range. */ DEBUG - ("FT1000:download:Download error: Bad Version Request = 0x%x.\n", - (int)requested_version); + ("FT1000:download:Download error: Bad Version Request = 0x%x.\n", + (int)requested_version); status = -1; break; } @@ -951,8 +951,8 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, default: DEBUG - ("FT1000:download:Download error: Bad request type=%d in CODE download state.\n", - request); + ("FT1000:download:Download error: Bad request type=%d in CODE download state.\n", + request); status = -1; break; } @@ -964,7 +964,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, HANDSHAKE_RESPONSE); } else { DEBUG - ("FT1000:download:Download error: Handshake failed\n"); + ("FT1000:download:Download error: Handshake failed\n"); status = -1; } @@ -990,9 +990,9 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, /* Get buffer for provisioning data */ pbuffer = - kmalloc((pseudo_header_len + - sizeof(struct pseudo_hdr)), - GFP_ATOMIC); + kmalloc((pseudo_header_len + + sizeof(struct pseudo_hdr)), + GFP_ATOMIC); if (pbuffer) { memcpy(pbuffer, (void *)c_file, (u32) (pseudo_header_len + @@ -1000,20 +1000,20 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, pseudo_hdr))); /* link provisioning data */ pprov_record = - kmalloc(sizeof(struct prov_record), - GFP_ATOMIC); + kmalloc(sizeof(struct prov_record), + GFP_ATOMIC); if (pprov_record) { pprov_record->pprov_data = - pbuffer; + pbuffer; list_add_tail(&pprov_record-> list, &pft1000info-> prov_list); /* Move to next entry if available */ c_file = - (u8 *) ((unsigned long) - c_file + - (u32) ((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); + (u8 *) ((unsigned long) + c_file + + (u32) ((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); if ((unsigned long)(c_file) - (unsigned long)(pFileStart) >= @@ -1032,8 +1032,8 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, status = -1; } DEBUG - ("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", - state, status); + ("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", + state, status); break; case STATE_DONE_PROV: @@ -1050,16 +1050,16 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; /**** - // Check if Card is present - status = Harley_Read_Register(&temp, FT1000_REG_SUP_IMASK); - if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0x0000) ) { - break; - } - - status = Harley_Read_Register(&temp, FT1000_REG_ASIC_ID); - if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0xffff) ) { - break; - } + // Check if Card is present + status = Harley_Read_Register(&temp, FT1000_REG_SUP_IMASK); + if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0x0000) ) { + break; + } + + status = Harley_Read_Register(&temp, FT1000_REG_ASIC_ID); + if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0xffff) ) { + break; + } ****/ } /* End while */ diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index 2e13e7b7ec10..da1195574640 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -1,8 +1,8 @@ /* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -* -* -* This file is part of Express Card USB Driver -*/ + * + * + * This file is part of Express Card USB Driver + */ #include #include @@ -35,16 +35,16 @@ static u8 tempbuffer[1600]; #define MAX_RCV_LOOP 100 /* send a control message via USB interface synchronously -* Parameters: ft1000_usb - device structure -* pipe - usb control message pipe -* request - control request -* requesttype - control message request type -* value - value to be written or 0 -* index - register index -* data - data buffer to hold the read/write values -* size - data size -* timeout - control message time out value -*/ + * Parameters: ft1000_usb - device structure + * pipe - usb control message pipe + * request - control request + * requesttype - control message request type + * value - value to be written or 0 + * index - register index + * data - data buffer to hold the read/write values + * size - data size + * timeout - control message time out value + */ static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe, u8 request, u8 requesttype, u16 value, u16 index, void *data, u16 size, int timeout) @@ -171,7 +171,7 @@ int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, /* write into DPRAM a number of bytes */ int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, - u8 highlow) + u8 highlow) { int ret = 0; u8 request; @@ -287,7 +287,7 @@ static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value) u16 tempword; status = ft1000_write_register(ft1000dev, HOST_INTF_BE, - FT1000_REG_SUP_CTRL); + FT1000_REG_SUP_CTRL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_CTRL); @@ -318,12 +318,12 @@ static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value) } /* send a command to ASIC -* Parameters: ft1000_usb - device structure -* ptempbuffer - command buffer -* size - command buffer size -*/ + * Parameters: ft1000_usb - device structure + * ptempbuffer - command buffer + * size - command buffer size + */ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, - int size) + int size) { int ret; unsigned short temp; @@ -355,7 +355,7 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, return ret; usleep_range(900, 1100); ret = ft1000_write_register(ft1000dev, FT1000_DB_DPRAM_TX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (ret) return ret; usleep_range(900, 1100); @@ -399,12 +399,12 @@ int dsp_reload(struct ft1000_usb *ft1000dev) msleep(1000); status = - ft1000_write_register(ft1000dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL); + ft1000_write_register(ft1000dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL); /* Let's check for FEFE */ status = - ft1000_read_dpram32(ft1000dev, FT1000_MAG_DPRAM_FEFE_INDX, - (u8 *) &templong, 4); + ft1000_read_dpram32(ft1000dev, FT1000_MAG_DPRAM_FEFE_INDX, + (u8 *)&templong, 4); DEBUG("templong (fefe) = 0x%8x\n", templong); /* call codeloader */ @@ -465,7 +465,7 @@ static int ft1000_reset_card(struct net_device *dev) while (list_empty(&info->prov_list) == 0) { DEBUG("ft1000_reset_card:deleting provisioning record\n"); ptr = - list_entry(info->prov_list.next, struct prov_record, list); + list_entry(info->prov_list.next, struct prov_record, list); list_del(&ptr->list); kfree(ptr->pprov_data); kfree(ptr); @@ -484,7 +484,7 @@ static int ft1000_reset_card(struct net_device *dev) /* Initialize DSP heartbeat area */ ft1000_write_dpram16(ft1000dev, FT1000_MAG_HI_HO, ho_mag, FT1000_MAG_HI_HO_INDX); - ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *) &tempword, + ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *)&tempword, FT1000_MAG_HI_HO_INDX); DEBUG("ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", tempword); @@ -508,8 +508,8 @@ static void ft1000_usb_transmit_complete(struct urb *urb) } /* take an ethernet packet and convert it to a Flarion -* packet prior to sending it to the ASIC Downlink FIFO. -*/ + * packet prior to sending it to the ASIC Downlink FIFO. + */ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) { struct ft1000_info *pInfo = netdev_priv(netdev); @@ -545,7 +545,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) hdr.control = 0x00; hdr.checksum = hdr.length ^ hdr.source ^ hdr.destination ^ - hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control; + hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control; memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr)); memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len); @@ -559,7 +559,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) pFt1000Dev->tx_buf, count, ft1000_usb_transmit_complete, (void *)pFt1000Dev); - t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer; + t = (u8 *)pFt1000Dev->tx_urb->transfer_buffer; ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC); @@ -574,9 +574,9 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) } /* transmit an ethernet packet -* Parameters: skb - socket buffer to be sent -* dev - network device -*/ + * Parameters: skb - socket buffer to be sent + * dev - network device + */ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ft1000_info *pInfo = netdev_priv(dev); @@ -595,10 +595,10 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) } pipe = - usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); + usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe)); - pdata = (u8 *) skb->data; + pdata = (u8 *)skb->data; if (pInfo->mediastate == 0) { /* Drop packet is mediastate is down */ @@ -814,8 +814,8 @@ int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, } /* take a packet from the FIFO up link and -* convert it into an ethernet packet and deliver it to the IP stack -*/ + * convert it into an ethernet packet and deliver it to the IP stack + */ static int ft1000_copy_up_pkt(struct urb *urb) { struct ft1000_info *info = urb->context; @@ -839,7 +839,7 @@ static int ft1000_copy_up_pkt(struct urb *urb) len = urb->transfer_buffer_length; lena = urb->actual_length; - chksum = (u16 *) ft1000dev->rx_buf; + chksum = (u16 *)ft1000dev->rx_buf; tempword = *chksum++; for (i = 1; i < 7; i++) @@ -860,7 +860,7 @@ static int ft1000_copy_up_pkt(struct urb *urb) return -1; } - pbuffer = (u8 *) skb_put(skb, len + 12); + pbuffer = (u8 *)skb_put(skb, len + 12); /* subtract the number of bytes read already */ ptemp = pbuffer; @@ -914,7 +914,7 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info) usb_rcvbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_in_endpointAddr), pFt1000Dev->rx_buf, MAX_BUF_SIZE, - (usb_complete_t) ft1000_copy_up_pkt, info); + (usb_complete_t)ft1000_copy_up_pkt, info); result = usb_submit_urb(pFt1000Dev->rx_urb, GFP_ATOMIC); @@ -976,10 +976,10 @@ static int ft1000_chkcard(struct ft1000_usb *dev) } /* read a message from the dpram area. -* Input: -* dev - network device structure -* pbuffer - caller supply address to buffer -*/ + * Input: + * dev - network device structure + * pbuffer - caller supply address to buffer + */ static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, int maxsz) { @@ -990,46 +990,46 @@ static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, u16 tempword; ret = - ft1000_read_dpram16(dev, FT1000_MAG_PH_LEN, (u8 *) &size, - FT1000_MAG_PH_LEN_INDX); + ft1000_read_dpram16(dev, FT1000_MAG_PH_LEN, (u8 *)&size, + FT1000_MAG_PH_LEN_INDX); size = ntohs(size) + PSEUDOSZ; if (size > maxsz) { DEBUG("FT1000:ft1000_receive_cmd:Invalid command length = %d\n", size); return FALSE; } - ppseudohdr = (u16 *) pbuffer; + ppseudohdr = (u16 *)pbuffer; ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE, FT1000_REG_DPRAM_ADDR); ret = - ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); + ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); pbuffer++; ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE + 1, FT1000_REG_DPRAM_ADDR); for (i = 0; i <= (size >> 2); i++) { ret = - ft1000_read_register(dev, pbuffer, - FT1000_REG_MAG_DPDATAL); + ft1000_read_register(dev, pbuffer, + FT1000_REG_MAG_DPDATAL); pbuffer++; ret = - ft1000_read_register(dev, pbuffer, - FT1000_REG_MAG_DPDATAH); + ft1000_read_register(dev, pbuffer, + FT1000_REG_MAG_DPDATAH); pbuffer++; } /* copy odd aligned word */ ret = - ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL); + ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL); pbuffer++; ret = - ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); + ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); pbuffer++; if (size & 0x0001) { /* copy odd byte from fifo */ ret = - ft1000_read_register(dev, &tempword, - FT1000_REG_DPRAM_DATA); + ft1000_read_register(dev, &tempword, + FT1000_REG_DPRAM_DATA); *pbuffer = ntohs(tempword); } /* Check if pseudo header checksum is good @@ -1066,7 +1066,7 @@ static int ft1000_dsp_prov(void *arg) /* Check if doorbell is available */ DEBUG("check if doorbell is cleared\n"); status = - ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); + ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); if (status) { DEBUG("ft1000_dsp_prov::ft1000_read_register error\n"); break; @@ -1088,13 +1088,13 @@ static int ft1000_dsp_prov(void *arg) /* Send provisioning data */ ptr = - list_entry(info->prov_list.next, struct prov_record, - list); - len = *(u16 *) ptr->pprov_data; + list_entry(info->prov_list.next, struct prov_record, + list); + len = *(u16 *)ptr->pprov_data; len = htons(len); len += PSEUDOSZ; - pmsg = (u16 *) ptr->pprov_data; + pmsg = (u16 *)ptr->pprov_data; ppseudo_hdr = (struct pseudo_hdr *)pmsg; /* Insert slow queue sequence number */ ppseudo_hdr->seq_num = info->squeseqnum++; @@ -1109,12 +1109,12 @@ static int ft1000_dsp_prov(void *arg) memcpy(&TempShortBuf[2], ppseudo_hdr, len); status = - ft1000_write_dpram32(dev, 0, - (u8 *) &TempShortBuf[0], - (unsigned short)(len + 2)); + ft1000_write_dpram32(dev, 0, + (u8 *)&TempShortBuf[0], + (unsigned short)(len + 2)); status = - ft1000_write_register(dev, FT1000_DB_DPRAM_TX, - FT1000_REG_DOORBELL); + ft1000_write_register(dev, FT1000_DB_DPRAM_TX, + FT1000_REG_DOORBELL); list_del(&ptr->list); kfree(ptr->pprov_data); @@ -1229,12 +1229,12 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) if (ntohs(pdspinitmsg->length) == (sizeof(struct dsp_init_msg) - 20)) { memcpy(info->ProductMode, pdspinitmsg->ProductMode, - MODESZ); + MODESZ); memcpy(info->RfCalVer, pdspinitmsg->RfCalVer, CALVERSZ); memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, CALDATESZ); DEBUG("RFCalVer = 0x%2x 0x%2x\n", info->RfCalVer[0], - info->RfCalVer[1]); + info->RfCalVer[1]); } break; } @@ -1252,7 +1252,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) } else { dev->fProvComplete = true; status = ft1000_write_register(dev, FT1000_DB_HB, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); DEBUG("FT1000:drivermsg:No more DSP provisioning data in dsp image\n"); } DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n"); @@ -1264,7 +1264,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) tempword = ntohs(pdrvmsg->length); info->DSPInfoBlklen = tempword; if (tempword < (MAX_DSP_SESS_REC - 4)) { - pmsg = (u16 *) &pdrvmsg->data[0]; + pmsg = (u16 *)&pdrvmsg->data[0]; for (i = 0; i < ((tempword + 1) / 2); i++) { DEBUG("FT1000:drivermsg:dsp info data = 0x%x\n", *pmsg); info->DSPInfoBlk[i + 10] = *pmsg++; @@ -1281,27 +1281,27 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) /* allow any outstanding ioctl to finish */ mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) break; } } /* Put message into Slow Queue Form Pseudo header */ - pmsg = (u16 *) info->DSPInfoBlk; + pmsg = (u16 *)info->DSPInfoBlk; *pmsg++ = 0; *pmsg++ = htons(info->DSPInfoBlklen + 20 + info->DSPInfoBlklen); ppseudo_hdr = - (struct pseudo_hdr *)(u16 *) &info->DSPInfoBlk[2]; + (struct pseudo_hdr *)(u16 *)&info->DSPInfoBlk[2]; ppseudo_hdr->length = htons(info->DSPInfoBlklen + 4 - + info->DSPInfoBlklen); + + info->DSPInfoBlklen); ppseudo_hdr->source = 0x10; ppseudo_hdr->destination = 0x20; ppseudo_hdr->portdest = 0; @@ -1323,10 +1323,10 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) info->DSPInfoBlk[10] = 0x7200; info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen); status = ft1000_write_dpram32(dev, 0, - (u8 *)&info->DSPInfoBlk[0], - (unsigned short)(info->DSPInfoBlklen + 22)); + (u8 *)&info->DSPInfoBlk[0], + (unsigned short)(info->DSPInfoBlklen + 22)); status = ft1000_write_register(dev, FT1000_DB_DPRAM_TX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); dev->DrvMsgPend = 0; break; } @@ -1337,17 +1337,17 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) /* allow any outstanding ioctl to finish */ mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) mdelay(10); } if ((tempword & FT1000_DB_DPRAM_TX) == 0) { /* Put message into Slow Queue Form Pseudo header */ - pmsg = (u16 *) &tempbuffer[0]; + pmsg = (u16 *)&tempbuffer[0]; ppseudo_hdr = (struct pseudo_hdr *)pmsg; ppseudo_hdr->length = htons(0x0012); ppseudo_hdr->source = 0x10; @@ -1368,7 +1368,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) for (i = 1; i < 7; i++) ppseudo_hdr->checksum ^= *pmsg++; - pmsg = (u16 *) &tempbuffer[16]; + pmsg = (u16 *)&tempbuffer[16]; *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG); *pmsg++ = htons(0x000e); *pmsg++ = htons(info->DSP_TIME[0]); @@ -1384,7 +1384,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) *pmsg++ = htons(info->DrvErrNum); status = card_send_command(dev, (unsigned char *)&tempbuffer[0], - (u16)(0x0012 + PSEUDOSZ)); + (u16)(0x0012 + PSEUDOSZ)); if (status) goto out; info->DrvErrNum = 0; @@ -1412,9 +1412,9 @@ static int dsp_broadcast_msg_id(struct ft1000_usb *dev) for (i = 0; i < MAX_NUM_APP; i++) { if ((dev->app_info[i].DspBCMsgFlag) - && (dev->app_info[i].fileobject) - && (dev->app_info[i].NumOfMsg - < MAX_MSG_LIMIT)) { + && (dev->app_info[i].fileobject) + && (dev->app_info[i].NumOfMsg + < MAX_MSG_LIMIT)) { pdpram_blk = ft1000_get_buffer(&freercvpool); if (pdpram_blk == NULL) { DEBUG("Out of memory in free receive command pool\n"); @@ -1422,18 +1422,18 @@ static int dsp_broadcast_msg_id(struct ft1000_usb *dev) return -1; } if (ft1000_receive_cmd(dev, pdpram_blk->pbuffer, - MAX_CMD_SQSIZE)) { + MAX_CMD_SQSIZE)) { /* Put message into the * appropriate application block */ dev->app_info[i].nRxMsg++; spin_lock_irqsave(&free_buff_lock, flags); list_add_tail(&pdpram_blk->list, - &dev->app_info[i] .app_sqlist); + &dev->app_info[i] .app_sqlist); dev->app_info[i].NumOfMsg++; spin_unlock_irqrestore(&free_buff_lock, flags); wake_up_interruptible(&dev->app_info[i] - .wait_dpram_msg); + .wait_dpram_msg); } else { dev->app_info[i].nRxMsgMiss++; ft1000_free_buffer(pdpram_blk, &freercvpool); @@ -1461,7 +1461,7 @@ static int handle_misc_portid(struct ft1000_usb *dev) /* Search for correct application block */ for (i = 0; i < MAX_NUM_APP; i++) { if (dev->app_info[i].app_id == ((struct pseudo_hdr *) - pdpram_blk->pbuffer)->portdest) + pdpram_blk->pbuffer)->portdest) break; } if (i == MAX_NUM_APP) { @@ -1502,14 +1502,14 @@ int ft1000_poll(void *dev_id) if (!status) { if (tempword & FT1000_DB_DPRAM_RX) { status = ft1000_read_dpram16(dev, - 0x200, (u8 *)&data, 0); + 0x200, (u8 *)&data, 0); size = ntohs(data) + 16 + 2; if (size % 4) { modulo = 4 - (size % 4); size = size + modulo; } status = ft1000_read_dpram16(dev, 0x201, - (u8 *)&portid, 1); + (u8 *)&portid, 1); portid &= 0xff; if (size < MAX_CMD_SQSIZE) { switch (portid) { @@ -1529,18 +1529,18 @@ int ft1000_poll(void *dev_id) } else DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size); status = ft1000_write_register(dev, - FT1000_DB_DPRAM_RX, - FT1000_REG_DOORBELL); + FT1000_DB_DPRAM_RX, + FT1000_REG_DOORBELL); } else if (tempword & FT1000_DSP_ASIC_RESET) { /* Let's reset the ASIC from the Host side as well */ status = ft1000_write_register(dev, ASIC_RESET_BIT, - FT1000_REG_RESET); + FT1000_REG_RESET); status = ft1000_read_register(dev, &tempword, - FT1000_REG_RESET); + FT1000_REG_RESET); i = 0; while (tempword & ASIC_RESET_BIT) { status = ft1000_read_register(dev, &tempword, - FT1000_REG_RESET); + FT1000_REG_RESET); usleep_range(9000, 11000); i++; if (i == 100) @@ -1553,51 +1553,51 @@ int ft1000_poll(void *dev_id) usleep_range(9000, 11000); /* Program WMARK register */ status = ft1000_write_register(dev, 0x600, - FT1000_REG_MAG_WATERMARK); + FT1000_REG_MAG_WATERMARK); /* clear ASIC reset doorbell */ status = ft1000_write_register(dev, - FT1000_DSP_ASIC_RESET, - FT1000_REG_DOORBELL); + FT1000_DSP_ASIC_RESET, + FT1000_REG_DOORBELL); usleep_range(9000, 11000); } else if (tempword & FT1000_ASIC_RESET_REQ) { DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_ASIC_RESET_REQ\n"); /* clear ASIC reset request from DSP */ status = ft1000_write_register(dev, - FT1000_ASIC_RESET_REQ, - FT1000_REG_DOORBELL); + FT1000_ASIC_RESET_REQ, + FT1000_REG_DOORBELL); status = ft1000_write_register(dev, HOST_INTF_BE, - FT1000_REG_SUP_CTRL); + FT1000_REG_SUP_CTRL); /* copy dsp session record from Adapter block */ status = ft1000_write_dpram32(dev, 0, - (u8 *)&info->DSPSess.Rec[0], 1024); + (u8 *)&info->DSPSess.Rec[0], 1024); status = ft1000_write_register(dev, 0x600, - FT1000_REG_MAG_WATERMARK); + FT1000_REG_MAG_WATERMARK); /* ring doorbell to tell DSP that * ASIC is out of reset * */ status = ft1000_write_register(dev, - FT1000_ASIC_RESET_DSP, - FT1000_REG_DOORBELL); + FT1000_ASIC_RESET_DSP, + FT1000_REG_DOORBELL); } else if (tempword & FT1000_DB_COND_RESET) { DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_COND_RESET\n"); if (!dev->fAppMsgPend) { /* Reset ASIC and DSP */ status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER0, - (u8 *)&(info->DSP_TIME[0]), - FT1000_MAG_DSP_TIMER0_INDX); + FT1000_MAG_DSP_TIMER0, + (u8 *)&(info->DSP_TIME[0]), + FT1000_MAG_DSP_TIMER0_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER1, - (u8 *)&(info->DSP_TIME[1]), - FT1000_MAG_DSP_TIMER1_INDX); + FT1000_MAG_DSP_TIMER1, + (u8 *)&(info->DSP_TIME[1]), + FT1000_MAG_DSP_TIMER1_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER2, - (u8 *)&(info->DSP_TIME[2]), - FT1000_MAG_DSP_TIMER2_INDX); + FT1000_MAG_DSP_TIMER2, + (u8 *)&(info->DSP_TIME[2]), + FT1000_MAG_DSP_TIMER2_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER3, - (u8 *)&(info->DSP_TIME[3]), - FT1000_MAG_DSP_TIMER3_INDX); + FT1000_MAG_DSP_TIMER3, + (u8 *)&(info->DSP_TIME[3]), + FT1000_MAG_DSP_TIMER3_INDX); info->CardReady = 0; info->DrvErrNum = DSP_CONDRESET_INFO; DEBUG("ft1000_hw:DSP conditional reset requested\n"); @@ -1607,7 +1607,7 @@ int ft1000_poll(void *dev_id) dev->fCondResetPend = true; } ft1000_write_register(dev, FT1000_DB_COND_RESET, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); } } return 0; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index cb644a58d9f3..e9472bebda0b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -1,30 +1,30 @@ /* -*--------------------------------------------------------------------------- -* FT1000 driver for Flarion Flash OFDM NIC Device -* -* Copyright (C) 2002 Flarion Technologies, All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the Free -* Software Foundation; either version 2 of the License, or (at your option) any -* later version. This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 59 Temple Place - -* Suite 330, Boston, MA 02111-1307, USA. -*--------------------------------------------------------------------------- -* -* File: ft1000_ioctl.h -* -* Description: Common structures and defines relating to IOCTL -* -* History: -* 11/5/02 Whc Created. -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * FT1000 driver for Flarion Flash OFDM NIC Device + * + * Copyright (C) 2002 Flarion Technologies, All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) any + * later version. This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - + * Suite 330, Boston, MA 02111-1307, USA. + *--------------------------------------------------------------------------- + * + * File: ft1000_ioctl.h + * + * Description: Common structures and defines relating to IOCTL + * + * History: + * 11/5/02 Whc Created. + * + *--------------------------------------------------------------------------- + */ #ifndef _FT1000IOCTLH_ #define _FT1000IOCTLH_ @@ -94,8 +94,8 @@ struct IOCTL_DPRAM_COMMAND { } __packed; /* -* Custom IOCTL command codes -*/ + * Custom IOCTL command codes + */ #define FT1000_MAGIC_CODE 'F' #define IOCTL_REGISTER_CMD 0 @@ -106,8 +106,8 @@ struct IOCTL_DPRAM_COMMAND { #define IOCTL_CONNECT 10 #define IOCTL_DISCONNECT 11 -#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, \ - IOCTL_GET_DSP_STAT_CMD, \ +#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, \ + IOCTL_GET_DSP_STAT_CMD, \ struct IOCTL_GET_DSP_STAT) #define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, \ struct IOCTL_GET_VER) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index 39be30c0eedf..244e3d66d599 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -109,8 +109,8 @@ static int ft1000_probe(struct usb_interface *interface, for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = - (struct usb_endpoint_descriptor *)&iface_desc-> - endpoint[i].desc; + (struct usb_endpoint_descriptor *)&iface_desc-> + endpoint[i].desc; DEBUG("endpoint %d\n", i); DEBUG("bEndpointAddress=%x, bmAttributes=%x\n", endpoint->bEndpointAddress, endpoint->bmAttributes); @@ -118,7 +118,7 @@ static int ft1000_probe(struct usb_interface *interface, && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) { ft1000dev->bulk_in_endpointAddr = - endpoint->bEndpointAddress; + endpoint->bEndpointAddress; DEBUG("ft1000_probe: in: %d\n", endpoint->bEndpointAddress); } @@ -127,7 +127,7 @@ static int ft1000_probe(struct usb_interface *interface, && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) { ft1000dev->bulk_out_endpointAddr = - endpoint->bEndpointAddress; + endpoint->bEndpointAddress; DEBUG("ft1000_probe: out: %d\n", endpoint->bEndpointAddress); } @@ -172,7 +172,7 @@ static int ft1000_probe(struct usb_interface *interface, gPollingfailed = false; ft1000dev->pPollThread = - kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll"); + kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll"); if (IS_ERR(ft1000dev->pPollThread)) { ret = PTR_ERR(ft1000dev->pPollThread); @@ -218,7 +218,7 @@ static void ft1000_disconnect(struct usb_interface *interface) DEBUG("ft1000_disconnect is called\n"); - pft1000info = (struct ft1000_info *) usb_get_intfdata(interface); + pft1000info = (struct ft1000_info *)usb_get_intfdata(interface); DEBUG("In disconnect pft1000info=%p\n", pft1000info); if (pft1000info) { @@ -233,7 +233,7 @@ static void ft1000_disconnect(struct usb_interface *interface) ft1000_destroy_dev(ft1000dev->net); unregister_netdev(ft1000dev->net); DEBUG - ("ft1000_disconnect: network device unregistered\n"); + ("ft1000_disconnect: network device unregistered\n"); free_netdev(ft1000dev->net); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index 8f7ccae57f31..418e6df91910 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -137,7 +137,7 @@ extern spinlock_t free_buff_lock; int ft1000_create_dev(struct ft1000_usb *dev); void ft1000_destroy_dev(struct net_device *dev); extern int card_send_command(struct ft1000_usb *ft1000dev, - void *ptempbuffer, int size); + void *ptempbuffer, int size); struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist); void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist); -- cgit v1.2.3-59-g8ed1b From b5d8204d00fa3bcd1f3b4b060fb90675d00baee0 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 3 Nov 2014 16:25:44 -0800 Subject: staging: ft1000: Logging message neatening Use a more common logging style. o Convert DEBUG macros to pr_debug o Add pr_fmt o Remove embedded function names from pr_debug o Convert printks to pr_ o Coalesce formats and align arguments o Add missing terminating newlines Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c | 6 +- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 340 ++++++++------------- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 136 ++++----- .../staging/ft1000/ft1000-usb/ft1000_download.c | 138 ++++----- drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 194 +++++------- drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 85 +++--- drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 2 - 7 files changed, 383 insertions(+), 518 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c index deb12560dc09..115005061765 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c @@ -20,6 +20,8 @@ ---------------------------------------------------------------------------*/ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #define __KERNEL_SYSCALLS__ #include @@ -316,7 +318,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, file_version = *(long *)pFileStart; if (file_version != 6) { - printk(KERN_ERR "ft1000: unsupported firmware version %ld\n", file_version); + pr_err("unsupported firmware version %ld\n", file_version); Status = FAILURE; } @@ -688,7 +690,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart, uiState = STATE_SECTION_PROV; } else { netdev_dbg(dev, - "FT1000:download:Download error: Bad Port IDs in Pseudo Record\n"); + "Download error: Bad Port IDs in Pseudo Record\n"); netdev_dbg(dev, "\t Port Source = 0x%2.2x\n", pHdr->portsrc); netdev_dbg(dev, "\t Port Destination = 0x%2.2x\n", diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index c6bee28cad73..11dbe369e18b 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -17,6 +17,8 @@ Suite 330, Boston, MA 02111-1307, USA. -------------------------------------------------------------------------*/ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -44,12 +46,6 @@ #include #include -#ifdef FT_DEBUG -#define DEBUG(n, args...) printk(KERN_DEBUG args); -#else -#define DEBUG(n, args...) -#endif - #include #include "ft1000.h" @@ -282,12 +278,9 @@ static void ft1000_enable_interrupts(struct net_device *dev) { u16 tempword; - DEBUG(1, "ft1000_hw:ft1000_enable_interrupts()\n"); ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_DEFAULT_MASK); tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK); - DEBUG(1, - "ft1000_hw:ft1000_enable_interrupts:current interrupt enable mask = 0x%x\n", - tempword); + pr_debug("current interrupt enable mask = 0x%x\n", tempword); } /*--------------------------------------------------------------------------- @@ -304,12 +297,9 @@ static void ft1000_disable_interrupts(struct net_device *dev) { u16 tempword; - DEBUG(1, "ft1000_hw: ft1000_disable_interrupts()\n"); ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_MASK_ALL); tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK); - DEBUG(1, - "ft1000_hw:ft1000_disable_interrupts:current interrupt enable mask = 0x%x\n", - tempword); + pr_debug("current interrupt enable mask = 0x%x\n", tempword); } /*--------------------------------------------------------------------------- @@ -329,8 +319,6 @@ static void ft1000_reset_asic(struct net_device *dev) struct ft1000_pcmcia *pcmcia = info->priv; u16 tempword; - DEBUG(1, "ft1000_hw:ft1000_reset_asic called\n"); - (*info->ft1000_reset) (pcmcia->link); /* @@ -351,10 +339,10 @@ static void ft1000_reset_asic(struct net_device *dev) } /* clear interrupts */ tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); - DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); - DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); } @@ -377,8 +365,6 @@ static int ft1000_reset_card(struct net_device *dev) unsigned long flags; struct prov_record *ptr; - DEBUG(1, "ft1000_hw:ft1000_reset_card called.....\n"); - info->CardReady = 0; info->ProgConStat = 0; info->squeseqnum = 0; @@ -388,8 +374,7 @@ static int ft1000_reset_card(struct net_device *dev) /* Make sure we free any memory reserve for provisioning */ while (list_empty(&info->prov_list) == 0) { - DEBUG(0, - "ft1000_hw:ft1000_reset_card:deleting provisioning record\n"); + pr_debug("deleting provisioning record\n"); ptr = list_entry(info->prov_list.next, struct prov_record, list); list_del(&ptr->list); kfree(ptr->pprov_data); @@ -397,11 +382,10 @@ static int ft1000_reset_card(struct net_device *dev) } if (info->AsicID == ELECTRABUZZ_ID) { - DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting DSP\n"); + pr_debug("resetting DSP\n"); ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT); } else { - DEBUG(1, - "ft1000_hw:ft1000_reset_card:resetting ASIC and DSP\n"); + pr_debug("resetting ASIC and DSP\n"); ft1000_write_reg(dev, FT1000_REG_RESET, (DSP_RESET_BIT | ASIC_RESET_BIT)); } @@ -428,17 +412,16 @@ static int ft1000_reset_card(struct net_device *dev) spin_unlock_irqrestore(&info->dpram_lock, flags); } - DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting ASIC\n"); + pr_debug("resetting ASIC\n"); mdelay(10); /* reset ASIC */ ft1000_reset_asic(dev); - DEBUG(1, "ft1000_hw:ft1000_reset_card:downloading dsp image\n"); + pr_debug("downloading dsp image\n"); if (info->AsicID == MAGNEMITE_ID) { /* Put dsp in reset and take ASIC out of reset */ - DEBUG(0, - "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n"); + pr_debug("Put DSP in reset and take ASIC out of reset\n"); ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT); /* Setting MAGNEMITE ASIC to big endian mode */ @@ -450,7 +433,7 @@ static int ft1000_reset_card(struct net_device *dev) ft1000_write_reg(dev, FT1000_REG_RESET, 0); /* FLARION_DSP_ACTIVE; */ mdelay(10); - DEBUG(0, "ft1000_hw:ft1000_reset_card:Take DSP out of reset\n"); + pr_debug("Take DSP out of reset\n"); /* Wait for 0xfefe indicating dsp ready before starting download */ for (i = 0; i < 50; i++) { @@ -464,8 +447,7 @@ static int ft1000_reset_card(struct net_device *dev) } if (i == 50) { - DEBUG(0, - "ft1000_hw:ft1000_reset_card:No FEFE detected from DSP\n"); + pr_debug("No FEFE detected from DSP\n"); return false; } @@ -476,10 +458,10 @@ static int ft1000_reset_card(struct net_device *dev) } if (card_download(dev, fw_entry->data, fw_entry->size)) { - DEBUG(1, "card download unsuccessful\n"); + pr_debug("card download unsuccessful\n"); return false; } else { - DEBUG(1, "card download successful\n"); + pr_debug("card download successful\n"); } mdelay(10); @@ -494,8 +476,7 @@ static int ft1000_reset_card(struct net_device *dev) /* Initialize DSP heartbeat area to ho */ ft1000_write_dpram(dev, FT1000_HI_HO, ho); tempword = ft1000_read_dpram(dev, FT1000_HI_HO); - DEBUG(1, "ft1000_hw:ft1000_reset_asic:hi_ho value = 0x%x\n", - tempword); + pr_debug("hi_ho value = 0x%x\n", tempword); } else { /* Initialize DSP heartbeat area to ho */ ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, ho_mag, @@ -503,8 +484,7 @@ static int ft1000_reset_card(struct net_device *dev) tempword = ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX); - DEBUG(1, "ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", - tempword); + pr_debug("hi_ho value = 0x%x\n", tempword); } info->CardReady = 1; @@ -541,8 +521,7 @@ static int ft1000_chkcard(struct net_device *dev) */ tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK); if (tempword == 0) { - DEBUG(1, - "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n"); + pr_debug("IMASK = 0 Card not detected\n"); return false; } /* @@ -551,8 +530,7 @@ static int ft1000_chkcard(struct net_device *dev) */ tempword = ft1000_read_reg(dev, FT1000_REG_ASIC_ID); if (tempword == 0xffff) { - DEBUG(1, - "ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n"); + pr_debug("Version = 0xffff Card not detected\n"); return false; } return true; @@ -589,8 +567,7 @@ static void ft1000_hbchk(u_long data) (dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX)); } - DEBUG(1, "ft1000_hw:ft1000_hbchk:hi_ho value = 0x%x\n", - tempword); + pr_debug("hi_ho value = 0x%x\n", tempword); /* Let's perform another check if ho is not detected */ if (tempword != ho) { if (info->AsicID == ELECTRABUZZ_ID) { @@ -601,8 +578,7 @@ static void ft1000_hbchk(u_long data) } } if (tempword != ho) { - printk(KERN_INFO - "ft1000: heartbeat failed - no ho detected\n"); + pr_info("heartbeat failed - no ho detected\n"); if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -632,8 +608,7 @@ static void ft1000_hbchk(u_long data) } info->DrvErrNum = DSP_HB_INFO; if (ft1000_reset_card(dev) == 0) { - printk(KERN_INFO - "ft1000: Hardware Failure Detected - PC Card disabled\n"); + pr_info("Hardware Failure Detected - PC Card disabled\n"); info->ProgConStat = 0xff; return; } @@ -650,8 +625,7 @@ static void ft1000_hbchk(u_long data) tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); } if (tempword & FT1000_DB_HB) { - printk(KERN_INFO - "ft1000: heartbeat doorbell not clear by firmware\n"); + pr_info("heartbeat doorbell not clear by firmware\n"); if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -681,8 +655,7 @@ static void ft1000_hbchk(u_long data) } info->DrvErrNum = DSP_HB_INFO; if (ft1000_reset_card(dev) == 0) { - printk(KERN_INFO - "ft1000: Hardware Failure Detected - PC Card disabled\n"); + pr_info("Hardware Failure Detected - PC Card disabled\n"); info->ProgConStat = 0xff; return; } @@ -730,8 +703,7 @@ static void ft1000_hbchk(u_long data) } if (tempword != hi) { - printk(KERN_INFO - "ft1000: heartbeat failed - cannot write hi into DPRAM\n"); + pr_info("heartbeat failed - cannot write hi into DPRAM\n"); if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -761,8 +733,7 @@ static void ft1000_hbchk(u_long data) } info->DrvErrNum = DSP_HB_INFO; if (ft1000_reset_card(dev) == 0) { - printk(KERN_INFO - "ft1000: Hardware Failure Detected - PC Card disabled\n"); + pr_info("Hardware Failure Detected - PC Card disabled\n"); info->ProgConStat = 0xff; return; } @@ -802,8 +773,8 @@ static void ft1000_send_cmd(struct net_device *dev, u16 *ptempbuffer, int size, if ((size & 0x0001)) { size++; } - DEBUG(1, "FT1000:ft1000_send_cmd:total length = %d\n", size); - DEBUG(1, "FT1000:ft1000_send_cmd:length = %d\n", ntohs(*ptempbuffer)); + pr_debug("total length = %d\n", size); + pr_debug("length = %d\n", ntohs(*ptempbuffer)); /* * put message into slow queue area * All messages are in the form total_len + pseudo header + message body @@ -830,8 +801,7 @@ static void ft1000_send_cmd(struct net_device *dev, u16 *ptempbuffer, int size, ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, size); /* Write pseudo header and messgae body */ for (i = 0; i < (size >> 1); i++) { - DEBUG(1, "FT1000:ft1000_send_cmd:data %d = 0x%x\n", i, - *ptempbuffer); + pr_debug("data %d = 0x%x\n", i, *ptempbuffer); tempword = htons(*ptempbuffer++); ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, tempword); } @@ -844,18 +814,16 @@ static void ft1000_send_cmd(struct net_device *dev, u16 *ptempbuffer, int size, ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, FT1000_DPRAM_MAG_TX_BASE + 1); for (i = 0; i < (size >> 2); i++) { - DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", - *ptempbuffer); + pr_debug("data = 0x%x\n", *ptempbuffer); outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAL); - DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", - *ptempbuffer); + pr_debug("data = 0x%x\n", *ptempbuffer); outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAH); } - DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer); + pr_debug("data = 0x%x\n", *ptempbuffer); outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAL); - DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer); + pr_debug("data = 0x%x\n", *ptempbuffer); outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAH); } spin_unlock_irqrestore(&info->dpram_lock, flags); @@ -896,9 +864,7 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, FT1000_MAG_PH_LEN_INDX)) + sizeof(struct pseudo_hdr); } if (size > maxsz) { - DEBUG(1, - "FT1000:ft1000_receive_cmd:Invalid command length = %d\n", - size); + pr_debug("Invalid command length = %d\n", size); return false; } else { ppseudohdr = (u16 *)pbuffer; @@ -915,7 +881,7 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, FT1000_DPRAM_MAG_RX_BASE); *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH); - DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer); + pr_debug("received data = 0x%x\n", *pbuffer); pbuffer++; ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, FT1000_DPRAM_MAG_RX_BASE + 1); @@ -931,10 +897,10 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, } /* copy odd aligned word */ *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL); - DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer); + pr_debug("received data = 0x%x\n", *pbuffer); pbuffer++; *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH); - DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer); + pr_debug("received data = 0x%x\n", *pbuffer); pbuffer++; } if (size & 0x0001) { @@ -953,8 +919,7 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, tempword ^= *ppseudohdr++; } if ((tempword != *ppseudohdr)) { - DEBUG(1, - "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n"); + pr_debug("Pseudo header checksum mismatch\n"); /* Drop this message */ return false; } @@ -1003,14 +968,13 @@ static void ft1000_proc_drvmsg(struct net_device *dev) /* Get the message type which is total_len + PSEUDO header + msgtype + message body */ pdrvmsg = (struct drv_msg *)&cmdbuffer[0]; msgtype = ntohs(pdrvmsg->type); - DEBUG(1, "Command message type = 0x%x\n", msgtype); + pr_debug("Command message type = 0x%x\n", msgtype); switch (msgtype) { case DSP_PROVISION: - DEBUG(0, - "Got a provisioning request message from DSP\n"); + pr_debug("Got a provisioning request message from DSP\n"); mdelay(25); while (list_empty(&info->prov_list) == 0) { - DEBUG(0, "Sending a provisioning message\n"); + pr_debug("Sending a provisioning message\n"); /* Make sure SLOWQ doorbell is clear */ tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); @@ -1035,12 +999,12 @@ static void ft1000_proc_drvmsg(struct net_device *dev) ppseudo_hdr->portsrc = 0; /* Calculate new checksum */ ppseudo_hdr->checksum = *pmsg++; - DEBUG(1, "checksum = 0x%x\n", - ppseudo_hdr->checksum); + pr_debug("checksum = 0x%x\n", + ppseudo_hdr->checksum); for (i = 1; i < 7; i++) { ppseudo_hdr->checksum ^= *pmsg++; - DEBUG(1, "checksum = 0x%x\n", - ppseudo_hdr->checksum); + pr_debug("checksum = 0x%x\n", + ppseudo_hdr->checksum); } ft1000_send_cmd(dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE); @@ -1058,7 +1022,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) pmediamsg = (struct media_msg *)&cmdbuffer[0]; if (info->ProgConStat != 0xFF) { if (pmediamsg->state) { - DEBUG(1, "Media is up\n"); + pr_debug("Media is up\n"); if (info->mediastate == 0) { netif_carrier_on(dev); netif_wake_queue(dev); @@ -1067,7 +1031,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) info->ConTm = tv.tv_sec; } } else { - DEBUG(1, "Media is down\n"); + pr_debug("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; netif_carrier_off(dev); @@ -1077,7 +1041,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) } } else { - DEBUG(1, "Media is down\n"); + pr_debug("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; netif_carrier_off(dev); @@ -1089,9 +1053,9 @@ static void ft1000_proc_drvmsg(struct net_device *dev) case DSP_INIT_MSG: pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[0]; memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ); - DEBUG(1, "DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", - info->DspVer[0], info->DspVer[1], info->DspVer[2], - info->DspVer[3]); + pr_debug("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", + info->DspVer[0], info->DspVer[1], + info->DspVer[2], info->DspVer[3]); memcpy(info->HwSerNum, pdspinitmsg->HwSerNum, HWSERNUMSZ); memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ); @@ -1111,27 +1075,26 @@ static void ft1000_proc_drvmsg(struct net_device *dev) CALVERSZ); memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, CALDATESZ); - DEBUG(1, "RFCalVer = 0x%2x 0x%2x\n", - info->RfCalVer[0], info->RfCalVer[1]); + pr_debug("RFCalVer = 0x%2x 0x%2x\n", + info->RfCalVer[0], info->RfCalVer[1]); } break; case DSP_STORE_INFO: - DEBUG(1, "FT1000:drivermsg:Got DSP_STORE_INFO\n"); + pr_debug("Got DSP_STORE_INFO\n"); tempword = ntohs(pdrvmsg->length); info->DSPInfoBlklen = tempword; if (tempword < (MAX_DSP_SESS_REC - 4)) { pmsg = (u16 *)&pdrvmsg->data[0]; for (i = 0; i < ((tempword + 1) / 2); i++) { - DEBUG(1, - "FT1000:drivermsg:dsp info data = 0x%x\n", - *pmsg); + pr_debug("dsp info data = 0x%x\n", + *pmsg); info->DSPInfoBlk[i + 10] = *pmsg++; } } break; case DSP_GET_INFO: - DEBUG(1, "FT1000:drivermsg:Got DSP_GET_INFO\n"); + pr_debug("Got DSP_GET_INFO\n"); /* * copy dsp info block to dsp * allow any outstanding ioctl to finish @@ -1182,7 +1145,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev) break; case GET_DRV_ERR_RPT_MSG: - DEBUG(1, "FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); + pr_debug("Got GET_DRV_ERR_RPT_MSG\n"); /* * copy driver error message to dsp * allow any outstanding ioctl to finish @@ -1273,7 +1236,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) unsigned long flags; doorbell = ft1000_read_reg(dev, FT1000_REG_DOORBELL); - DEBUG(1, "Doorbell = 0x%x\n", doorbell); + pr_debug("Doorbell = 0x%x\n", doorbell); if (doorbell & FT1000_ASIC_RESET_REQ) { /* Copy DSP session record from info block */ @@ -1298,7 +1261,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) /* clear ASIC RESET request */ ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_ASIC_RESET_REQ); - DEBUG(1, "Got an ASIC RESET Request\n"); + pr_debug("Got an ASIC RESET Request\n"); ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_ASIC_RESET_DSP); @@ -1310,8 +1273,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) } if (doorbell & FT1000_DSP_ASIC_RESET) { - DEBUG(0, - "FT1000:ft1000_parse_dpram_msg: Got a dsp ASIC reset message\n"); + pr_debug("Got a dsp ASIC reset message\n"); ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DSP_ASIC_RESET); udelay(200); @@ -1319,8 +1281,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) } if (doorbell & FT1000_DB_DPRAM_RX) { - DEBUG(1, - "FT1000:ft1000_parse_dpram_msg: Got a slow queue message\n"); + pr_debug("Got a slow queue message\n"); nxtph = FT1000_DPRAM_RX_BASE + 2; if (info->AsicID == ELECTRABUZZ_ID) { total_len = @@ -1331,8 +1292,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) (dev, FT1000_MAG_TOTAL_LEN, FT1000_MAG_TOTAL_LEN_INDX)); } - DEBUG(1, "FT1000:ft1000_parse_dpram_msg:total length = %d\n", - total_len); + pr_debug("total length = %d\n", total_len); if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) { total_len += nxtph; /* @@ -1351,7 +1311,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) (dev, FT1000_MAG_PORT_ID, FT1000_MAG_PORT_ID_INDX) & 0xff); } - DEBUG(1, "DSP_QID = 0x%x\n", portid); + pr_debug("DSP_QID = 0x%x\n", portid); if (portid == DRIVERID) { /* We are assumming one driver message from the DSP at a time. */ @@ -1387,7 +1347,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) FT1000_MAG_DSP_TIMER3_INDX); } info->DrvErrNum = DSP_CONDRESET_INFO; - DEBUG(1, "ft1000_hw:DSP conditional reset requested\n"); + pr_debug("DSP conditional reset requested\n"); ft1000_reset_card(dev); ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_COND_RESET); @@ -1397,7 +1357,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev) doorbell & ~(FT1000_DB_DPRAM_RX | FT1000_ASIC_RESET_REQ | FT1000_DB_COND_RESET | 0xff00); if (doorbell) { - DEBUG(1, "Clearing unexpected doorbell = 0x%x\n", doorbell); + pr_debug("Clearing unexpected doorbell = 0x%x\n", doorbell); ft1000_write_reg(dev, FT1000_REG_DOORBELL, doorbell); } @@ -1425,7 +1385,6 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) u32 templong; u16 tempword; - DEBUG(1, "ft1000:ft1000_hw:ft1000_flush_fifo called\n"); if (pcmcia->PktIntfErr > MAX_PH_ERR) { if (info->AsicID == ELECTRABUZZ_ID) { info->DSP_TIME[0] = @@ -1531,23 +1490,23 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum) } while ((tempword & 0x03) != 0x03); if (info->AsicID == ELECTRABUZZ_ID) { i++; - DEBUG(0, "Flushing FIFO complete = %x\n", tempword); + pr_debug("Flushing FIFO complete = %x\n", tempword); /* Flush last word in FIFO. */ tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO); /* Update FIFO counter for DSP */ i = i * 2; - DEBUG(0, "Flush Data byte count to dsp = %d\n", i); + pr_debug("Flush Data byte count to dsp = %d\n", i); info->fifo_cnt += i; ft1000_write_dpram(dev, FT1000_FIFO_LEN, info->fifo_cnt); } else { - DEBUG(0, "Flushing FIFO complete = %x\n", tempword); + pr_debug("Flushing FIFO complete = %x\n", tempword); /* Flush last word in FIFO */ templong = inl(dev->base_addr + FT1000_REG_MAG_DFR); tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT); - DEBUG(0, "FT1000_REG_SUP_STAT = 0x%x\n", tempword); + pr_debug("FT1000_REG_SUP_STAT = 0x%x\n", tempword); tempword = inw(dev->base_addr + FT1000_REG_MAG_DFSR); - DEBUG(0, "FT1000_REG_MAG_DFSR = 0x%x\n", tempword); + pr_debug("FT1000_REG_MAG_DFSR = 0x%x\n", tempword); } if (DrvErrNum) { pcmcia->PktIntfErr++; @@ -1581,7 +1540,6 @@ static int ft1000_copy_up_pkt(struct net_device *dev) u32 *ptemplong; u32 templong; - DEBUG(1, "ft1000_copy_up_pkt\n"); /* Read length */ if (info->AsicID == ELECTRABUZZ_ID) { tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO); @@ -1591,10 +1549,10 @@ static int ft1000_copy_up_pkt(struct net_device *dev) len = ntohs(tempword); } chksum = tempword; - DEBUG(1, "Number of Bytes in FIFO = %d\n", len); + pr_debug("Number of Bytes in FIFO = %d\n", len); if (len > ENET_MAX_SIZE) { - DEBUG(0, "size of ethernet packet invalid\n"); + pr_debug("size of ethernet packet invalid\n"); if (info->AsicID == MAGNEMITE_ID) { /* Read High word to complete 32 bit access */ tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); @@ -1607,7 +1565,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev) skb = dev_alloc_skb(len + 12 + 2); if (skb == NULL) { - DEBUG(0, "No Network buffers available\n"); + pr_debug("No Network buffers available\n"); /* Read High word to complete 32 bit access */ if (info->AsicID == MAGNEMITE_ID) { tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); @@ -1628,37 +1586,37 @@ static int ft1000_copy_up_pkt(struct net_device *dev) tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO); } else { tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); chksum ^= tempword; tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); chksum ^= tempword; tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); chksum ^= tempword; tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); chksum ^= tempword; tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); chksum ^= tempword; tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); chksum ^= tempword; /* read checksum value */ tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); - DEBUG(1, "Pseudo = 0x%x\n", tempword); + pr_debug("Pseudo = 0x%x\n", tempword); } if (chksum != tempword) { - DEBUG(0, "Packet checksum mismatch 0x%x 0x%x\n", chksum, - tempword); + pr_debug("Packet checksum mismatch 0x%x 0x%x\n", + chksum, tempword); ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO); info->stats.rx_errors++; kfree_skb(skb); @@ -1701,22 +1659,22 @@ static int ft1000_copy_up_pkt(struct net_device *dev) ptemplong = (u32 *)pbuffer; for (i = 0; i < len / 4; i++) { templong = inl(dev->base_addr + FT1000_REG_MAG_DFR); - DEBUG(1, "Data = 0x%8x\n", templong); + pr_debug("Data = 0x%8x\n", templong); *ptemplong++ = templong; } /* Need to read one more word if odd align. */ if (len & 0x0003) { templong = inl(dev->base_addr + FT1000_REG_MAG_DFR); - DEBUG(1, "Data = 0x%8x\n", templong); + pr_debug("Data = 0x%8x\n", templong); *ptemplong++ = templong; } } - DEBUG(1, "Data passed to Protocol layer:\n"); + pr_debug("Data passed to Protocol layer:\n"); for (i = 0; i < len + 12; i++) { - DEBUG(1, "Protocol Data: 0x%x\n ", *ptemp++); + pr_debug("Protocol Data: 0x%x\n", *ptemp++); } skb->dev = dev; @@ -1768,8 +1726,6 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) int i; u32 *plong; - DEBUG(1, "ft1000_hw: copy_down_pkt()\n"); - /* Check if there is room on the FIFO */ if (len > ft1000_read_fifo_len(dev)) { udelay(10); @@ -1789,8 +1745,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) udelay(20); } if (len > ft1000_read_fifo_len(dev)) { - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:Transmit FIFO is fulli - pkt drop\n"); + pr_debug("Transmit FIFO is full - pkt drop\n"); info->stats.tx_errors++; return SUCCESS; } @@ -1821,39 +1776,30 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) if (info->AsicID == ELECTRABUZZ_ID) { /* copy first word to UFIFO_BEG reg */ ft1000_write_reg(dev, FT1000_REG_UFIFO_BEG, pseudo.buff[0]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 0 BEG = 0x%04x\n", - pseudo.buff[0]); + pr_debug("data 0 BEG = 0x%04x\n", pseudo.buff[0]); /* copy subsequent words to UFIFO_MID reg */ ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[1]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 1 MID = 0x%04x\n", - pseudo.buff[1]); + pr_debug("data 1 MID = 0x%04x\n", pseudo.buff[1]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[2]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 2 MID = 0x%04x\n", - pseudo.buff[2]); + pr_debug("data 2 MID = 0x%04x\n", pseudo.buff[2]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[3]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 3 MID = 0x%04x\n", - pseudo.buff[3]); + pr_debug("data 3 MID = 0x%04x\n", pseudo.buff[3]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[4]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 4 MID = 0x%04x\n", - pseudo.buff[4]); + pr_debug("data 4 MID = 0x%04x\n", pseudo.buff[4]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[5]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 5 MID = 0x%04x\n", - pseudo.buff[5]); + pr_debug("data 5 MID = 0x%04x\n", pseudo.buff[5]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[6]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 6 MID = 0x%04x\n", - pseudo.buff[6]); + pr_debug("data 6 MID = 0x%04x\n", pseudo.buff[6]); ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[7]); - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 7 MID = 0x%04x\n", - pseudo.buff[7]); + pr_debug("data 7 MID = 0x%04x\n", pseudo.buff[7]); /* Write PPP type + IP Packet into Downlink FIFO */ for (i = 0; i < (len >> 1) - 1; i++) { ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, htons(*packet)); - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", - i + 8, htons(*packet)); + pr_debug("data %d MID = 0x%04x\n", + i + 8, htons(*packet)); packet++; } @@ -1861,39 +1807,31 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) if (len & 0x0001) { ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, htons(*packet)); - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data MID = 0x%04x\n", - htons(*packet)); + pr_debug("data MID = 0x%04x\n", htons(*packet)); packet++; ft1000_write_reg(dev, FT1000_REG_UFIFO_END, htons(*packet)); - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", - i + 8, htons(*packet)); + pr_debug("data %d MID = 0x%04x\n", + i + 8, htons(*packet)); } else { ft1000_write_reg(dev, FT1000_REG_UFIFO_END, htons(*packet)); - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n", - i + 8, htons(*packet)); + pr_debug("data %d MID = 0x%04x\n", + i + 8, htons(*packet)); } } else { outl(*(u32 *)&pseudo.buff[0], dev->base_addr + FT1000_REG_MAG_UFDR); - DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *)&pseudo.buff[0]); + pr_debug("Pseudo = 0x%8x\n", *(u32 *)&pseudo.buff[0]); outl(*(u32 *)&pseudo.buff[2], dev->base_addr + FT1000_REG_MAG_UFDR); - DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *)&pseudo.buff[2]); + pr_debug("Pseudo = 0x%8x\n", *(u32 *)&pseudo.buff[2]); outl(*(u32 *)&pseudo.buff[4], dev->base_addr + FT1000_REG_MAG_UFDR); - DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *)&pseudo.buff[4]); + pr_debug("Pseudo = 0x%8x\n", *(u32 *)&pseudo.buff[4]); outl(*(u32 *)&pseudo.buff[6], dev->base_addr + FT1000_REG_MAG_UFDR); - DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n", - *(u32 *)&pseudo.buff[6]); + pr_debug("Pseudo = 0x%8x\n", *(u32 *)&pseudo.buff[6]); plong = (u32 *)packet; /* Write PPP type + IP Packet into Downlink FIFO */ @@ -1903,9 +1841,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len) /* Check for odd alignment */ if (len & 0x0003) { - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n", - *plong); + pr_debug("data = 0x%8x\n", *plong); outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR); } outl(1, dev->base_addr + FT1000_REG_MAG_UFER); @@ -1926,11 +1862,7 @@ static struct net_device_stats *ft1000_stats(struct net_device *dev) static int ft1000_open(struct net_device *dev) { - - DEBUG(0, "ft1000_hw: ft1000_open is called\n"); - ft1000_reset_card(dev); - DEBUG(0, "ft1000_hw: ft1000_open is ended\n"); /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP and ASIC */ init_timer(&poll_timer); @@ -1938,7 +1870,6 @@ static int ft1000_open(struct net_device *dev) poll_timer.data = (u_long)dev; add_timer(&poll_timer); - DEBUG(0, "ft1000_hw: ft1000_open is ended2\n"); return 0; } @@ -1946,13 +1877,11 @@ static int ft1000_close(struct net_device *dev) { struct ft1000_info *info = netdev_priv(dev); - DEBUG(0, "ft1000_hw: ft1000_close()\n"); - info->CardReady = 0; del_timer(&poll_timer); if (ft1000_card_present == 1) { - DEBUG(0, "Media is down\n"); + pr_debug("Media is down\n"); netif_stop_queue(dev); ft1000_disable_interrupts(dev); @@ -1969,27 +1898,24 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) struct ft1000_info *info = netdev_priv(dev); u8 *pdata; - DEBUG(1, "ft1000_hw: ft1000_start_xmit()\n"); if (skb == NULL) { - DEBUG(1, "ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n"); + pr_debug("skb == NULL!!!\n"); return 0; } - DEBUG(1, "ft1000_hw: ft1000_start_xmit:length of packet = %d\n", - skb->len); + pr_debug("length of packet = %d\n", skb->len); pdata = (u8 *)skb->data; if (info->mediastate == 0) { /* Drop packet is mediastate is down */ - DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:mediastate is down\n"); + pr_debug("mediastate is down\n"); return SUCCESS; } if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) { /* Drop packet which has invalid size */ - DEBUG(1, - "ft1000_hw:ft1000_copy_down_pkt:invalid ethernet length\n"); + pr_debug("invalid ethernet length\n"); return SUCCESS; } ft1000_copy_down_pkt(dev, (u16 *) (pdata + ENET_HEADER_SIZE - 2), @@ -2008,8 +1934,6 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id) u16 inttype; int cnt; - DEBUG(1, "ft1000_hw: ft1000_interrupt()\n"); - if (info->CardReady == 0) { ft1000_disable_interrupts(dev); return IRQ_HANDLED; @@ -2031,7 +1955,7 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id) ft1000_parse_dpram_msg(dev); if (inttype & ISR_RCV) { - DEBUG(1, "Data in FIFO\n"); + pr_debug("Data in FIFO\n"); cnt = 0; do { @@ -2056,12 +1980,13 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id) } /* clear interrupts */ tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); - DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); /* Read interrupt type */ inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); - DEBUG(1, "ft1000_hw: interrupt status register after clear = 0x%x\n", inttype); + pr_debug("interrupt status register after clear = 0x%x\n", + inttype); } ft1000_enable_interrupts(dev); return IRQ_HANDLED; @@ -2073,8 +1998,6 @@ void stop_ft1000_card(struct net_device *dev) struct prov_record *ptr; /* int cnt; */ - DEBUG(0, "ft1000_hw: stop_ft1000_card()\n"); - info->CardReady = 0; ft1000_card_present = 0; netif_stop_queue(dev); @@ -2143,9 +2066,8 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, .ndo_get_stats = &ft1000_stats, }; - DEBUG(1, "ft1000_hw: init_ft1000_card()\n"); - DEBUG(1, "ft1000_hw: irq = %d\n", link->irq); - DEBUG(1, "ft1000_hw: port = 0x%04x\n", link->resource[0]->start); + pr_debug("irq = %d, port = 0x%04llx\n", + link->irq, (unsigned long long)link->resource[0]->start); flarion_ft1000_cnt++; @@ -2168,9 +2090,9 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, memset(info, 0, sizeof(struct ft1000_info)); - DEBUG(1, "address of dev = 0x%8x\n", (u32)dev); - DEBUG(1, "address of dev info = 0x%8x\n", (u32)info); - DEBUG(0, "device name = %s\n", dev->name); + pr_debug("address of dev = 0x%p\n", dev); + pr_debug("address of dev info = 0x%p\n", info); + pr_debug("device name = %s\n", dev->name); memset(&info->stats, 0, sizeof(struct net_device_stats)); @@ -2202,7 +2124,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, dev->netdev_ops = &ft1000ops; /* Slavius 21.10.2009 due to kernel changes */ - DEBUG(0, "device name = %s\n", dev->name); + pr_debug("device name = %s\n", dev->name); dev->irq = link->irq; dev->base_addr = link->resource[0]->start; @@ -2222,21 +2144,21 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, } if (register_netdev(dev) != 0) { - DEBUG(0, "ft1000: Could not register netdev"); + pr_debug("Could not register netdev\n"); goto err_reg; } info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID); if (info->AsicID == ELECTRABUZZ_ID) { - DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n"); + pr_debug("ELECTRABUZZ ASIC\n"); if (request_firmware(&fw_entry, "ft1000.img", &link->dev) != 0) { - printk(KERN_INFO "ft1000: Could not open ft1000.img\n"); + pr_info("Could not open ft1000.img\n"); goto err_unreg; } } else { - DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n"); + pr_debug("MAGNEMITE ASIC\n"); if (request_firmware(&fw_entry, "ft2000.img", &link->dev) != 0) { - printk(KERN_INFO "ft1000: Could not open ft2000.img\n"); + pr_info("Could not open ft2000.img\n"); goto err_unreg; } } @@ -2245,8 +2167,8 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, ft1000_card_present = 1; dev->ethtool_ops = &ops; - printk(KERN_INFO "ft1000: %s: addr 0x%04lx irq %d, MAC addr %pM\n", - dev->name, dev->base_addr, dev->irq, dev->dev_addr); + pr_info("%s: addr 0x%04lx irq %d, MAC addr %pM\n", + dev->name, dev->base_addr, dev->irq, dev->dev_addr); return dev; err_unreg: diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 658f3cab8e72..c8d278229940 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -26,6 +26,9 @@ * *--------------------------------------------------------------------------- */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -87,13 +90,13 @@ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist) spin_lock_irqsave(&free_buff_lock, flags); /* Check if buffer is available */ if (list_empty(bufflist)) { - DEBUG("ft1000_get_buffer: No more buffer - %d\n", numofmsgbuf); + pr_debug("No more buffer - %d\n", numofmsgbuf); ptr = NULL; } else { numofmsgbuf--; ptr = list_entry(bufflist->next, struct dpram_blk, list); list_del(&ptr->list); - /* DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ + /* pr_debug("number of free msg buffers = %d\n", numofmsgbuf); */ } spin_unlock_irqrestore(&free_buff_lock, flags); @@ -125,7 +128,7 @@ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist) /* Put memory back to list */ list_add_tail(&pdpram_blk->list, plist); numofmsgbuf++; - /*DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ + /*pr_debug("number of free msg buffers = %d\n", numofmsgbuf); */ spin_unlock_irqrestore(&free_buff_lock, flags); } @@ -153,17 +156,17 @@ int ft1000_create_dev(struct ft1000_usb *dev) /* make a new device name */ sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); - DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt); - DEBUG("DeviceCreated = %x\n", dev->DeviceCreated); + pr_debug("number of instance = %d\n", ft1000_flarion_cnt); + pr_debug("DeviceCreated = %x\n", dev->DeviceCreated); if (dev->DeviceCreated) { - DEBUG("%s: \"%s\" already registered\n", __func__, dev->DeviceName); + pr_debug("\"%s\" already registered\n", dev->DeviceName); return -EIO; } /* register the device */ - DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName); + pr_debug("\"%s\" debugfs device registration\n", dev->DeviceName); tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL); if (tmp == NULL) { @@ -189,7 +192,7 @@ int ft1000_create_dev(struct ft1000_usb *dev) tmp->int_number = dev->CardNumber; list_add(&(tmp->list), &(dev->nodes.list)); - DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName); + pr_debug("registered debugfs directory \"%s\"\n", dev->DeviceName); /* initialize application information */ dev->appcnt = 0; @@ -241,10 +244,6 @@ void ft1000_destroy_dev(struct net_device *netdev) struct list_head *pos, *q; struct ft1000_debug_dirs *dir; - DEBUG("%s called\n", __func__); - - - if (dev->DeviceCreated) { ft1000_flarion_cnt--; list_for_each_safe(pos, q, &dev->nodes.list) { @@ -256,8 +255,7 @@ void ft1000_destroy_dev(struct net_device *netdev) kfree(dir); } } - DEBUG("%s: unregistered device \"%s\"\n", __func__, - dev->DeviceName); + pr_debug("unregistered device \"%s\"\n", dev->DeviceName); /* Make sure we free any memory reserve for slow Queue */ for (i = 0; i < MAX_NUM_APP; i++) { @@ -303,17 +301,17 @@ static int ft1000_open(struct inode *inode, struct file *file) struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private; int i, num; - DEBUG("%s called\n", __func__); num = (MINOR(inode->i_rdev) & 0xf); - DEBUG("ft1000_open: minor number=%d\n", num); + pr_debug("minor number=%d\n", num); info = file->private_data = netdev_priv(dev->net); - DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt); + pr_debug("f_owner = %p number of application = %d\n", + &file->f_owner, dev->appcnt); /* Check if maximum number of application exceeded */ if (dev->appcnt > MAX_NUM_APP) { - DEBUG("Maximum number of application exceeded\n"); + pr_debug("Maximum number of application exceeded\n"); return -EACCES; } @@ -326,7 +324,7 @@ static int ft1000_open(struct inode *inode, struct file *file) /* Fail due to lack of application info block */ if (i == MAX_NUM_APP) { - DEBUG("Could not find an application info block\n"); + pr_debug("Could not find an application info block\n"); return -EACCES; } @@ -362,33 +360,32 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) struct ft1000_usb *dev = info->priv; int i; - /* DEBUG("ft1000_poll_dev called\n"); */ if (ft1000_flarion_cnt == 0) { - DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n"); + pr_debug("called with ft1000_flarion_cnt value zero\n"); return -EBADF; } /* Search for matching file object */ for (i = 0; i < MAX_NUM_APP; i++) { if (dev->app_info[i].fileobject == &file->f_owner) { - /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id); */ + /* pr_debug("Message is for AppId = %d\n", dev->app_info[i].app_id); */ break; } } /* Could not find application info block */ if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); + pr_debug("Could not find application info block\n"); return -EACCES; } if (list_empty(&dev->app_info[i].app_sqlist) == 0) { - DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n"); + pr_debug("Message detected in slow queue\n"); return(POLLIN | POLLRDNORM | POLLPRI); } poll_wait(file, &dev->app_info[i].wait_dpram_msg, wait); - /* DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); */ + /* pr_debug("Polling for data from DSP\n"); */ return 0; } @@ -429,27 +426,25 @@ static long ft1000_ioctl(struct file *file, unsigned int command, unsigned short ledStat = 0; unsigned short conStat = 0; - /* DEBUG("ft1000_ioctl called\n"); */ - if (ft1000_flarion_cnt == 0) { - DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n"); + pr_debug("called with ft1000_flarion_cnt of zero\n"); return -EBADF; } - /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ + /* pr_debug("command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ info = file->private_data; ft1000dev = info->priv; cmd = _IOC_NR(command); - /* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */ + /* pr_debug("cmd = 0x%x\n", cmd); */ /* process the command */ switch (cmd) { case IOCTL_REGISTER_CMD: - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n"); + pr_debug("IOCTL_FT1000_REGISTER called\n"); result = get_user(tempword, (__u16 __user *)argp); if (result) { - DEBUG("result = %d failed to get_user\n", result); + pr_debug("result = %d failed to get_user\n", result); break; } if (tempword == DSPBCMSGID) { @@ -457,7 +452,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, for (i = 0; i < MAX_NUM_APP; i++) { if (ft1000dev->app_info[i].fileobject == &file->f_owner) { ft1000dev->app_info[i].DspBCMsgFlag = 1; - DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n"); + pr_debug("Registered for broadcast messages\n"); break; } } @@ -465,34 +460,35 @@ static long ft1000_ioctl(struct file *file, unsigned int command, break; case IOCTL_GET_VER_CMD: - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_VER called\n"); + pr_debug("IOCTL_FT1000_GET_VER called\n"); get_ver_data.drv_ver = FT1000_DRV_VER; if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); + pr_debug("copy fault occurred\n"); result = -EFAULT; break; } - DEBUG("FT1000:ft1000_ioctl:driver version = 0x%x\n", (unsigned int)get_ver_data.drv_ver); + pr_debug("driver version = 0x%x\n", + (unsigned int)get_ver_data.drv_ver); break; case IOCTL_CONNECT: /* Connect Message */ - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n"); + pr_debug("IOCTL_FT1000_CONNECT\n"); ConnectionMsg[79] = 0xfc; result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); break; case IOCTL_DISCONNECT: /* Disconnect Message */ - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n"); + pr_debug("IOCTL_FT1000_DISCONNECT\n"); ConnectionMsg[79] = 0xfd; result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); break; case IOCTL_GET_DSP_STAT_CMD: - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */ + /* pr_debug("IOCTL_FT1000_GET_DSP_STAT\n"); */ memset(&get_stat_data, 0, sizeof(get_stat_data)); memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ); memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ); @@ -502,10 +498,10 @@ static long ft1000_ioctl(struct file *file, unsigned int command, if (info->ProgConStat != 0xFF) { ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); get_stat_data.LedStat = ntohs(ledStat); - DEBUG("FT1000:ft1000_ioctl: LedStat = 0x%x\n", get_stat_data.LedStat); + pr_debug("LedStat = 0x%x\n", get_stat_data.LedStat); ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX); get_stat_data.ConStat = ntohs(conStat); - DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat); + pr_debug("ConStat = 0x%x\n", get_stat_data.ConStat); } else { get_stat_data.ConStat = 0x0f; } @@ -517,13 +513,13 @@ static long ft1000_ioctl(struct file *file, unsigned int command, get_stat_data.nRxBytes = info->stats.rx_bytes; do_gettimeofday(&tv); get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm); - DEBUG("Connection Time = %d\n", (int)get_stat_data.ConTm); + pr_debug("Connection Time = %d\n", (int)get_stat_data.ConTm); if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); + pr_debug("copy fault occurred\n"); result = -EFAULT; break; } - DEBUG("ft1000_chioctl: GET_DSP_STAT succeed\n"); + pr_debug("GET_DSP_STAT succeed\n"); break; case IOCTL_SET_DPRAM_CMD: { @@ -537,7 +533,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, u16 app_index; u16 status; - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/ + /* pr_debug("IOCTL_FT1000_SET_DPRAM called\n");*/ if (ft1000_flarion_cnt == 0) @@ -553,17 +549,17 @@ static long ft1000_ioctl(struct file *file, unsigned int command, if (info->CardReady) { - /* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */ + /* pr_debug("try to SET_DPRAM\n"); */ /* Get the length field to see how many bytes to copy */ result = get_user(msgsz, (__u16 __user *)argp); if (result) break; msgsz = ntohs(msgsz); - /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */ + /* pr_debug("length of message = %d\n", msgsz); */ if (msgsz > MAX_CMD_SQSIZE) { - DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz); + pr_debug("bad message length = %d\n", msgsz); result = -EINVAL; break; } @@ -574,7 +570,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, break; if (copy_from_user(dpram_data, argp, msgsz+2)) { - DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n"); + pr_debug("copy fault occurred\n"); result = -EFAULT; } else { /* Check if this message came from a registered application */ @@ -584,7 +580,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, } } if (i == MAX_NUM_APP) { - DEBUG("FT1000:No matching application fileobject\n"); + pr_debug("No matching application fileobject\n"); result = -EINVAL; kfree(dpram_data); break; @@ -593,13 +589,13 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* Check message qtype type which is the lower byte within qos_class */ qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; - /* DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); */ + /* pr_debug("qtype = %d\n", qtype); */ if (qtype) { } else { /* Put message into Slow Queue */ /* Only put a message into the DPRAM if msg doorbell is available */ status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - /* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */ + /* pr_debug("READ REGISTER tempword=%x\n", tempword); */ if (tempword & FT1000_DB_DPRAM_TX) { /* Suspend for 2ms and try again due to DSP doorbell busy */ mdelay(2); @@ -615,7 +611,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, mdelay(3); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { - DEBUG("FT1000:ft1000_ioctl:Doorbell not available\n"); + pr_debug("Doorbell not available\n"); result = -ENOTTY; kfree(dpram_data); break; @@ -625,7 +621,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, } } - /*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */ + /*pr_debug("finished reading register\n"); */ /* Make sure we are within the limits of the slow queue memory limitation */ if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) { @@ -642,10 +638,10 @@ static long ft1000_ioctl(struct file *file, unsigned int command, ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; /* Calculate new checksum */ ppseudo_hdr->checksum = *pmsg++; - /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ + /* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */ for (i = 1; i < 7; i++) { ppseudo_hdr->checksum ^= *pmsg++; - /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ + /* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */ } pmsg++; ppseudo_hdr = (struct pseudo_hdr *)pmsg; @@ -659,7 +655,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, } } } else { - DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n"); + pr_debug("Card not ready take messages\n"); result = -EACCES; } kfree(dpram_data); @@ -672,7 +668,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, struct IOCTL_DPRAM_BLK __user *pioctl_dpram; int msglen; - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ + /* pr_debug("IOCTL_FT1000_GET_DPRAM called\n"); */ if (ft1000_flarion_cnt == 0) return -EBADF; @@ -680,14 +676,14 @@ static long ft1000_ioctl(struct file *file, unsigned int command, /* Search for matching file object */ for (i = 0; i < MAX_NUM_APP; i++) { if (ft1000dev->app_info[i].fileobject == &file->f_owner) { - /*DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ + /*pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ break; } } /* Could not find application info block */ if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); + pr_debug("Could not find application info block\n"); result = -EBADF; break; } @@ -695,21 +691,21 @@ static long ft1000_ioctl(struct file *file, unsigned int command, result = 0; pioctl_dpram = argp; if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { - /* DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); */ + /* pr_debug("Message detected in slow queue\n"); */ spin_lock_irqsave(&free_buff_lock, flags); pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); list_del(&pdpram_blk->list); ft1000dev->app_info[i].NumOfMsg--; - /* DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */ + /* pr_debug("NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */ spin_unlock_irqrestore(&free_buff_lock, flags); msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; result = get_user(msglen, &pioctl_dpram->total_len); if (result) break; msglen = htons(msglen); - /* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */ + /* pr_debug("msg length = %x\n", msglen); */ if (copy_to_user(&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); + pr_debug("copy fault occurred\n"); result = -EFAULT; break; } @@ -717,12 +713,12 @@ static long ft1000_ioctl(struct file *file, unsigned int command, ft1000_free_buffer(pdpram_blk, &freercvpool); result = msglen; } - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */ + /* pr_debug("IOCTL_FT1000_GET_DPRAM no message\n"); */ } break; default: - DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command); + pr_debug("unknown command: 0x%x\n", command); result = -ENOTTY; break; } @@ -750,8 +746,6 @@ static int ft1000_release(struct inode *inode, struct file *file) int i; struct dpram_blk *pdpram_blk; - DEBUG("ft1000_release called\n"); - dev = file->private_data; info = netdev_priv(dev); ft1000dev = info->priv; @@ -764,7 +758,7 @@ static int ft1000_release(struct inode *inode, struct file *file) /* Search for matching file object */ for (i = 0; i < MAX_NUM_APP; i++) { if (ft1000dev->app_info[i].fileobject == &file->f_owner) { - /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ + /* pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ break; } } @@ -773,7 +767,7 @@ static int ft1000_release(struct inode *inode, struct file *file) return 0; while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { - DEBUG("Remove and free memory queue up on slow queue\n"); + pr_debug("Remove and free memory queue up on slow queue\n"); pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); list_del(&pdpram_blk->list); ft1000_free_buffer(pdpram_blk, &freercvpool); @@ -781,7 +775,7 @@ static int ft1000_release(struct inode *inode, struct file *file) /* initialize application information */ ft1000dev->appcnt--; - DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt); + pr_debug("appcnt = %d\n", ft1000dev->appcnt); ft1000dev->app_info[i].fileobject = NULL; return 0; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 2cce4224485b..e8126325877b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -4,6 +4,8 @@ * This file is part of Express Card USB Driver */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -118,10 +120,9 @@ static int check_usb_db(struct ft1000_usb *ft1000dev) while (loopcnt < 10) { status = ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL); - DEBUG("check_usb_db: read FT1000_REG_DOORBELL value is %x\n", - temp); + pr_debug("read FT1000_REG_DOORBELL value is %x\n", temp); if (temp & 0x0080) { - DEBUG("FT1000:Got checkusb doorbell\n"); + pr_debug("Got checkusb doorbell\n"); status = ft1000_write_register(ft1000dev, 0x0080, FT1000_REG_DOORBELL); status = ft1000_write_register(ft1000dev, 0x0100, @@ -139,12 +140,12 @@ static int check_usb_db(struct ft1000_usb *ft1000dev) while (loopcnt < 20) { status = ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL); - DEBUG("FT1000:check_usb_db:Doorbell = 0x%x\n", temp); + pr_debug("Doorbell = 0x%x\n", temp); if (temp & 0x8000) { loopcnt++; msleep(10); } else { - DEBUG("check_usb_db: door bell is cleared, return 0\n"); + pr_debug("door bell is cleared, return 0\n"); return 0; } } @@ -166,12 +167,11 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) status = ft1000_write_register(ft1000dev, FT1000_DB_DNLD_RX, FT1000_REG_DOORBELL); if (ft1000dev->fcodeldr) { - DEBUG(" get_handshake: fcodeldr is %d\n", - ft1000dev->fcodeldr); + pr_debug("fcodeldr is %d\n", ft1000dev->fcodeldr); ft1000dev->fcodeldr = 0; status = check_usb_db(ft1000dev); if (status != 0) { - DEBUG("get_handshake: check_usb_db failed\n"); + pr_debug("check_usb_db failed\n"); break; } status = ft1000_write_register(ft1000dev, @@ -232,14 +232,14 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) status = ft1000_read_dpram32(ft1000dev, 0, (u8 *)&(ft1000dev->tempbuf[0]), 64); for (temp = 0; temp < 16; temp++) { - DEBUG("tempbuf %d = 0x%x\n", temp, - ft1000dev->tempbuf[temp]); + pr_debug("tempbuf %d = 0x%x\n", + temp, ft1000dev->tempbuf[temp]); } status = ft1000_read_dpram16(ft1000dev, DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1); - DEBUG("handshake from read_dpram16 = 0x%x\n", - handshake); + pr_debug("handshake from read_dpram16 = 0x%x\n", + handshake); if (ft1000dev->dspalive == ft1000dev->tempbuf[6]) { handshake = 0; } else { @@ -409,7 +409,7 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, if ((tempbuffer[31] & 0xfe00) == 0xfe00) { if (check_buffers(tempbuffer, resultbuffer, 28, 0)) { - DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); + pr_debug("DPRAM write failed 1 during bootloading\n"); usleep_range(9000, 11000); break; } @@ -419,14 +419,14 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, if (check_buffers(tempbuffer, resultbuffer, 16, 24)) { - DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n"); + pr_debug("DPRAM write failed 2 during bootloading\n"); usleep_range(9000, 11000); break; } } else { if (check_buffers(tempbuffer, resultbuffer, 32, 0)) { - DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n"); + pr_debug("DPRAM write failed 3 during bootloading\n"); usleep_range(9000, 11000); break; } @@ -453,7 +453,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, u16 tempword; u16 tempbuffer[64]; - /*DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); */ + /*pr_debug("start word_length = %d\n",(int)word_length); */ dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; tempword = *(*pUsFile); (*pUsFile)++; @@ -483,9 +483,9 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, } } - /*DEBUG("write_blk: loopcnt is %d\n", loopcnt); */ - /*DEBUG("write_blk: bootmode = %d\n", bootmode); */ - /*DEBUG("write_blk: dpram = %x\n", dpram); */ + /*pr_debug("loopcnt is %d\n", loopcnt); */ + /*pr_debug("write_blk: bootmode = %d\n", bootmode); */ + /*pr_debug("write_blk: dpram = %x\n", dpram); */ if (ft1000dev->bootmode == 0) { if (dpram >= 0x3F4) status = ft1000_write_dpram32(ft1000dev, dpram, @@ -497,7 +497,8 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, status = write_dpram32_and_check(ft1000dev, tempbuffer, dpram); if (status != 0) { - DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); + pr_debug("Write failed tempbuffer[31] = 0x%x\n", + tempbuffer[31]); break; } } @@ -508,7 +509,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, static void usb_dnld_complete(struct urb *urb) { - /* DEBUG("****** usb_dnld_complete\n"); */ + /* pr_debug("****** usb_dnld_complete\n"); */ } /* writes a block of DSP image to DPRAM @@ -552,18 +553,17 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, { int status = 0; - DEBUG("FT1000:STATE_START_DWNLD\n"); if (ft1000dev->usbboot) *hshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY); else *hshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY); if (*hshake == HANDSHAKE_DSP_BL_READY) { - DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); + pr_debug("handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY); } else if (*hshake == HANDSHAKE_TIMEOUT_VALUE) { status = -ETIMEDOUT; } else { - DEBUG("FT1000:download:Download error: Handshake failed\n"); + pr_debug("Download error: Handshake failed\n"); status = -ENETRESET; } *state = STATE_BOOT_DWNLD; @@ -576,17 +576,17 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, long word_length; int status = 0; - /*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ word_length = get_request_value(ft1000dev); - /*DEBUG("FT1000:word_length = 0x%x\n", (int)word_length); */ + /*pr_debug("word_length = 0x%x\n", (int)word_length); */ /*NdisMSleep (100); */ if (word_length > MAX_LENGTH) { - DEBUG("FT1000:download:Download error: Max length exceeded\n"); + pr_debug("Download error: Max length exceeded\n"); return -1; } if ((word_length * 2 + (long)c_file) > (long)endpoint) { /* Error, beyond boot code range.*/ - DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length); + pr_debug("Download error: Requested len=%d exceeds BOOT code boundary\n", + (int)word_length); return -1; } if (word_length & 0x1) @@ -595,7 +595,7 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, if (boot_case) { status = write_blk(ft1000dev, s_file, c_file, word_length); - /*DEBUG("write_blk returned %d\n", status); */ + /*pr_debug("write_blk returned %d\n", status); */ } else { status = write_blk_fifo(ft1000dev, s_file, c_file, word_length); if (ft1000dev->usbboot == 0) @@ -641,8 +641,6 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, struct prov_record *pprov_record; struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); - DEBUG("Entered scram_dnldr...\n"); - ft1000dev->fcodeldr = 0; ft1000dev->usbboot = 0; ft1000dev->dspalive = 0xffff; @@ -674,7 +672,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; case STATE_BOOT_DWNLD: - DEBUG("FT1000:STATE_BOOT_DWNLD\n"); + pr_debug("STATE_BOOT_DWNLD\n"); ft1000dev->bootmode = 1; handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST); if (handshake == HANDSHAKE_REQUEST) { @@ -684,22 +682,22 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, request = get_request_type(ft1000dev); switch (request) { case REQUEST_RUN_ADDRESS: - DEBUG("FT1000:REQUEST_RUN_ADDRESS\n"); + pr_debug("REQUEST_RUN_ADDRESS\n"); put_request_value(ft1000dev, loader_code_address); break; case REQUEST_CODE_LENGTH: - DEBUG("FT1000:REQUEST_CODE_LENGTH\n"); + pr_debug("REQUEST_CODE_LENGTH\n"); put_request_value(ft1000dev, loader_code_size); break; case REQUEST_DONE_BL: - DEBUG("FT1000:REQUEST_DONE_BL\n"); + pr_debug("REQUEST_DONE_BL\n"); /* Reposition ptrs to beginning of code section */ s_file = (u16 *) (boot_end); c_file = (u8 *) (boot_end); - /* DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); */ - /* DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); */ + /* pr_debug("download:s_file = 0x%8x\n", (int)s_file); */ + /* pr_debug("FT1000:download:c_file = 0x%8x\n", (int)c_file); */ state = STATE_CODE_DWNLD; ft1000dev->fcodeldr = 1; break; @@ -710,8 +708,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, true); break; default: - DEBUG - ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n", + pr_debug("Download error: Bad request type=%d in BOOT download state\n", request); status = -1; break; @@ -723,15 +720,14 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, put_handshake(ft1000dev, HANDSHAKE_RESPONSE); } else { - DEBUG - ("FT1000:download:Download error: Handshake failed\n"); + pr_debug("Download error: Handshake failed\n"); status = -1; } break; case STATE_CODE_DWNLD: - /* DEBUG("FT1000:STATE_CODE_DWNLD\n"); */ + /* pr_debug("STATE_CODE_DWNLD\n"); */ ft1000dev->bootmode = 0; if (ft1000dev->usbboot) handshake = @@ -751,40 +747,33 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, request = get_request_type(ft1000dev); switch (request) { case REQUEST_FILE_CHECKSUM: - DEBUG - ("FT1000:download:image_chksum = 0x%8x\n", + pr_debug("image_chksum = 0x%8x\n", image_chksum); put_request_value(ft1000dev, image_chksum); break; case REQUEST_RUN_ADDRESS: - DEBUG - ("FT1000:download: REQUEST_RUN_ADDRESS\n"); + pr_debug("REQUEST_RUN_ADDRESS\n"); if (correct_version) { - DEBUG - ("FT1000:download:run_address = 0x%8x\n", + pr_debug("run_address = 0x%8x\n", (int)run_address); put_request_value(ft1000dev, run_address); } else { - DEBUG - ("FT1000:download:Download error: Got Run address request before image offset request.\n"); + pr_debug("Download error: Got Run address request before image offset request\n"); status = -1; break; } break; case REQUEST_CODE_LENGTH: - DEBUG - ("FT1000:download:REQUEST_CODE_LENGTH\n"); + pr_debug("REQUEST_CODE_LENGTH\n"); if (correct_version) { - DEBUG - ("FT1000:download:run_size = 0x%8x\n", + pr_debug("run_size = 0x%8x\n", (int)run_size); put_request_value(ft1000dev, run_size); } else { - DEBUG - ("FT1000:download:Download error: Got Size request before image offset request.\n"); + pr_debug("Download error: Got Size request before image offset request\n"); status = -1; break; } @@ -801,10 +790,9 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, state = STATE_DONE_DWNLD; break; case REQUEST_CODE_SEGMENT: - /* DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); */ + /* pr_debug("REQUEST_CODE_SEGMENT - CODELOADER\n"); */ if (!correct_version) { - DEBUG - ("FT1000:download:Download error: Got Code Segment request before image offset request.\n"); + pr_debug("Download error: Got Code Segment request before image offset request\n"); status = -1; break; } @@ -817,8 +805,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; case REQUEST_MAILBOX_DATA: - DEBUG - ("FT1000:download: REQUEST_MAILBOX_DATA\n"); + pr_debug("REQUEST_MAILBOX_DATA\n"); /* Convert length from byte count to word count. Make sure we round up. */ word_length = (long)(pft1000info->DSPInfoBlklen + @@ -852,8 +839,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; case REQUEST_VERSION_INFO: - DEBUG - ("FT1000:download:REQUEST_VERSION_INFO\n"); + pr_debug("REQUEST_VERSION_INFO\n"); word_length = file_hdr->version_data_size; put_request_value(ft1000dev, @@ -887,8 +873,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; case REQUEST_CODE_BY_VERSION: - DEBUG - ("FT1000:download:REQUEST_CODE_BY_VERSION\n"); + pr_debug("REQUEST_CODE_BY_VERSION\n"); correct_version = false; requested_version = get_request_value(ft1000dev); @@ -907,8 +892,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, if (dsp_img_info->version == requested_version) { correct_version = true; - DEBUG - ("FT1000:download: correct_version is TRUE\n"); + pr_debug("correct_version is TRUE\n"); s_file = (u16 *) (pFileStart + @@ -941,8 +925,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, /* * Error, beyond boot code range. */ - DEBUG - ("FT1000:download:Download error: Bad Version Request = 0x%x.\n", + pr_debug("Download error: Bad Version Request = 0x%x.\n", (int)requested_version); status = -1; break; @@ -950,8 +933,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; default: - DEBUG - ("FT1000:download:Download error: Bad request type=%d in CODE download state.\n", + pr_debug("Download error: Bad request type=%d in CODE download state.\n", request); status = -1; break; @@ -963,20 +945,19 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, put_handshake(ft1000dev, HANDSHAKE_RESPONSE); } else { - DEBUG - ("FT1000:download:Download error: Handshake failed\n"); + pr_debug("Download error: Handshake failed\n"); status = -1; } break; case STATE_DONE_DWNLD: - DEBUG("FT1000:download:Code loader is done...\n"); + pr_debug("Code loader is done...\n"); state = STATE_SECTION_PROV; break; case STATE_SECTION_PROV: - DEBUG("FT1000:download:STATE_SECTION_PROV\n"); + pr_debug("STATE_SECTION_PROV\n"); pseudo_header = (struct pseudo_hdr *)c_file; if (pseudo_header->checksum == @@ -1031,13 +1012,12 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, /* Checksum did not compute */ status = -1; } - DEBUG - ("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", + pr_debug("after STATE_SECTION_PROV, state = %d, status= %d\n", state, status); break; case STATE_DONE_PROV: - DEBUG("FT1000:download:STATE_DONE_PROV\n"); + pr_debug("STATE_DONE_PROV\n"); state = STATE_DONE_FILE; break; @@ -1064,7 +1044,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, } /* End while */ - DEBUG("Download exiting with status = 0x%8x\n", status); + pr_debug("Download exiting with status = 0x%8x\n", status); ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX, FT1000_REG_DOORBELL); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index da1195574640..d12cfc9aa32a 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -4,6 +4,8 @@ * This file is part of Express Card USB Driver */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -52,7 +54,7 @@ static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe, int ret; if ((ft1000dev == NULL) || (ft1000dev->dev == NULL)) { - DEBUG("ft1000dev or ft1000dev->dev == NULL, failure\n"); + pr_debug("ft1000dev or ft1000dev->dev == NULL, failure\n"); return -ENODEV; } @@ -212,7 +214,7 @@ int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, *buffer++ = buf[pos++]; *buffer++ = buf[pos++]; } else { - DEBUG("fix_ft1000_read_dpram32: DPRAM32 Read failed\n"); + pr_debug("DPRAM32 Read failed\n"); *buffer++ = 0; *buffer++ = 0; *buffer++ = 0; @@ -246,7 +248,7 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer) buf[pos2++] = *buffer++; ret = ft1000_write_dpram32(ft1000dev, pos1, buf, 16); } else { - DEBUG("fix_ft1000_write_dpram32: DPRAM32 Read failed\n"); + pr_debug("DPRAM32 Read failed\n"); return ret; } @@ -270,8 +272,7 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer) for (i = 0; i < 16; i++) { if (tempbuffer[i] != resultbuffer[i]) { ret = -1; - DEBUG("%s Failed to write\n", - __func__); + pr_debug("Failed to write\n"); } } } @@ -292,14 +293,14 @@ static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value) FT1000_REG_SUP_CTRL); if (value) { - DEBUG("Reset DSP\n"); + pr_debug("Reset DSP\n"); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET); tempword |= DSP_RESET_BIT; status = ft1000_write_register(ft1000dev, tempword, FT1000_REG_RESET); } else { - DEBUG("Activate DSP\n"); + pr_debug("Activate DSP\n"); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET); tempword |= DSP_ENCRYPTED; @@ -329,7 +330,7 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, unsigned short temp; unsigned char *commandbuf; - DEBUG("card_send_command: enter card_send_command... size=%d\n", size); + pr_debug("enter card_send_command... size=%d\n", size); commandbuf = kmalloc(size + 2, GFP_KERNEL); if (!commandbuf) @@ -364,7 +365,7 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, #if 0 if ((temp & 0x0100) == 0) - DEBUG("card_send_command: Message sent\n"); + pr_debug("Message sent\n"); #endif return ret; } @@ -390,7 +391,7 @@ int dsp_reload(struct ft1000_usb *ft1000dev) status = ft1000_write_register(ft1000dev, tempword, FT1000_REG_RESET); msleep(1000); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET); - DEBUG("Reset Register = 0x%x\n", tempword); + pr_debug("Reset Register = 0x%x\n", tempword); /* Toggle DSP reset */ card_reset_dsp(ft1000dev, 1); @@ -405,7 +406,7 @@ int dsp_reload(struct ft1000_usb *ft1000dev) status = ft1000_read_dpram32(ft1000dev, FT1000_MAG_DPRAM_FEFE_INDX, (u8 *)&templong, 4); - DEBUG("templong (fefe) = 0x%8x\n", templong); + pr_debug("templong (fefe) = 0x%8x\n", templong); /* call codeloader */ status = scram_dnldr(ft1000dev, pFileStart, FileLength); @@ -415,8 +416,6 @@ int dsp_reload(struct ft1000_usb *ft1000dev) msleep(1000); - DEBUG("dsp_reload returned\n"); - return 0; } @@ -427,8 +426,6 @@ static void ft1000_reset_asic(struct net_device *dev) struct ft1000_usb *ft1000dev = info->priv; u16 tempword; - DEBUG("ft1000_hw:ft1000_reset_asic called\n"); - /* Let's use the register provided by the Magnemite ASIC to reset the * ASIC and DSP. */ @@ -442,10 +439,10 @@ static void ft1000_reset_asic(struct net_device *dev) /* clear interrupts */ ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_ISR); - DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); ft1000_write_register(ft1000dev, tempword, FT1000_REG_SUP_ISR); ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_ISR); - DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); } static int ft1000_reset_card(struct net_device *dev) @@ -455,15 +452,13 @@ static int ft1000_reset_card(struct net_device *dev) u16 tempword; struct prov_record *ptr; - DEBUG("ft1000_hw:ft1000_reset_card called.....\n"); - ft1000dev->fCondResetPend = true; info->CardReady = 0; ft1000dev->fProvComplete = false; /* Make sure we free any memory reserve for provisioning */ while (list_empty(&info->prov_list) == 0) { - DEBUG("ft1000_reset_card:deleting provisioning record\n"); + pr_debug("deleting provisioning record\n"); ptr = list_entry(info->prov_list.next, struct prov_record, list); list_del(&ptr->list); @@ -471,13 +466,13 @@ static int ft1000_reset_card(struct net_device *dev) kfree(ptr); } - DEBUG("ft1000_hw:ft1000_reset_card: reset asic\n"); + pr_debug("reset asic\n"); ft1000_reset_asic(dev); - DEBUG("ft1000_hw:ft1000_reset_card: call dsp_reload\n"); + pr_debug("call dsp_reload\n"); dsp_reload(ft1000dev); - DEBUG("dsp reload successful\n"); + pr_debug("dsp reload successful\n"); mdelay(10); @@ -486,7 +481,7 @@ static int ft1000_reset_card(struct net_device *dev) FT1000_MAG_HI_HO_INDX); ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *)&tempword, FT1000_MAG_HI_HO_INDX); - DEBUG("ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", tempword); + pr_debug("hi_ho value = 0x%x\n", tempword); info->CardReady = 1; @@ -520,14 +515,13 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) struct pseudo_hdr hdr; if (!pInfo->CardReady) { - DEBUG("ft1000_copy_down_pkt::Card Not Ready\n"); + pr_debug("Card Not Ready\n"); return -ENODEV; } count = sizeof(struct pseudo_hdr) + len; if (count > MAX_BUF_SIZE) { - DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n"); - DEBUG("size = %d\n", count); + pr_debug("Message Size Overflow! size = %d\n", count); return -EINVAL; } @@ -564,7 +558,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC); if (ret) { - DEBUG("ft1000 failed tx_urb %d\n", ret); + pr_debug("failed tx_urb %d\n", ret); return ret; } pInfo->stats.tx_packets++; @@ -585,12 +579,12 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) int maxlen, pipe; if (skb == NULL) { - DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n"); + pr_debug("skb == NULL!!!\n"); return NETDEV_TX_OK; } if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { - DEBUG("network driver is closed, return\n"); + pr_debug("network driver is closed, return\n"); goto err; } @@ -602,13 +596,13 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) if (pInfo->mediastate == 0) { /* Drop packet is mediastate is down */ - DEBUG("ft1000_hw:ft1000_start_xmit:mediastate is down\n"); + pr_debug("mediastate is down\n"); goto err; } if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) { /* Drop packet which has invalid size */ - DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n"); + pr_debug("invalid ethernet length\n"); goto err; } @@ -628,7 +622,7 @@ static int ft1000_open(struct net_device *dev) struct ft1000_usb *pFt1000Dev = pInfo->priv; struct timeval tv; - DEBUG("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); + pr_debug("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); pInfo->stats.rx_bytes = 0; pInfo->stats.tx_bytes = 0; @@ -676,11 +670,9 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) char card_nr[2]; u8 gCardIndex = 0; - DEBUG("Enter init_ft1000_netdev...\n"); - netdev = alloc_etherdev(sizeof(struct ft1000_info)); if (!netdev) { - DEBUG("init_ft1000_netdev: can not allocate network device\n"); + pr_debug("can not allocate network device\n"); return -ENOMEM; } @@ -690,7 +682,7 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) dev_alloc_name(netdev, netdev->name); - DEBUG("init_ft1000_netdev: network device name is %s\n", netdev->name); + pr_debug("network device name is %s\n", netdev->name); if (strncmp(netdev->name, "eth", 3) == 0) { card_nr[0] = netdev->name[3]; @@ -702,7 +694,7 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) } ft1000dev->CardNumber = gCardIndex; - DEBUG("card number = %d\n", ft1000dev->CardNumber); + pr_debug("card number = %d\n", ft1000dev->CardNumber); } else { netdev_err(ft1000dev->net, "ft1000: Invalid device name\n"); ret_val = -ENXIO; @@ -738,7 +730,7 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) ft1000dev->net = netdev; - DEBUG("Initialize free_buff_lock and freercvpool\n"); + pr_debug("Initialize free_buff_lock and freercvpool\n"); spin_lock_init(&free_buff_lock); /* initialize a list of buffers to be use for queuing @@ -790,7 +782,6 @@ int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, netdev = ft1000dev->net; pInfo = netdev_priv(ft1000dev->net); - DEBUG("Enter reg_ft1000_netdev...\n"); ft1000_read_register(ft1000dev, &pInfo->AsicID, FT1000_REG_ASIC_ID); @@ -799,15 +790,13 @@ int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, rc = register_netdev(netdev); if (rc) { - DEBUG("reg_ft1000_netdev: could not register network device\n"); + pr_debug("could not register network device\n"); free_netdev(netdev); return rc; } ft1000_create_dev(ft1000dev); - DEBUG("reg_ft1000_netdev returned\n"); - pInfo->CardReady = 1; return 0; @@ -832,7 +821,7 @@ static int ft1000_copy_up_pkt(struct urb *urb) u16 *chksum; if (ft1000dev->status & FT1000_STATUS_CLOSING) { - DEBUG("network driver is closed, return\n"); + pr_debug("network driver is closed, return\n"); return 0; } /* Read length */ @@ -854,7 +843,7 @@ static int ft1000_copy_up_pkt(struct urb *urb) skb = dev_alloc_skb(len + 12 + 2); if (skb == NULL) { - DEBUG("ft1000_copy_up_pkt: No Network buffers available\n"); + pr_debug("No Network buffers available\n"); info->stats.rx_errors++; ft1000_submit_rx_urb(info); return -1; @@ -905,7 +894,7 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info) struct ft1000_usb *pFt1000Dev = info->priv; if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { - DEBUG("network driver is closed, return\n"); + pr_debug("network driver is closed, return\n"); return -ENODEV; } @@ -919,8 +908,7 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info) result = usb_submit_urb(pFt1000Dev->rx_urb, GFP_ATOMIC); if (result) { - pr_err("ft1000_submit_rx_urb: submitting rx_urb %d failed\n", - result); + pr_err("submitting rx_urb %d failed\n", result); return result; } @@ -935,7 +923,7 @@ int ft1000_close(struct net_device *net) ft1000dev->status |= FT1000_STATUS_CLOSING; - DEBUG("ft1000_close: pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev); + pr_debug("pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev); netif_carrier_off(net); netif_stop_queue(net); ft1000dev->status &= ~FT1000_STATUS_CLOSING; @@ -952,7 +940,7 @@ static int ft1000_chkcard(struct ft1000_usb *dev) int status; if (dev->fCondResetPend) { - DEBUG("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n"); + pr_debug("Card is being reset, return FALSE\n"); return TRUE; } /* Mask register is used to check for device presence since it is never @@ -960,7 +948,7 @@ static int ft1000_chkcard(struct ft1000_usb *dev) */ status = ft1000_read_register(dev, &tempword, FT1000_REG_SUP_IMASK); if (tempword == 0) { - DEBUG("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n"); + pr_debug("IMASK = 0 Card not detected\n"); return FALSE; } /* The system will return the value of 0xffff for the version register @@ -969,7 +957,7 @@ static int ft1000_chkcard(struct ft1000_usb *dev) status = ft1000_read_register(dev, &tempword, FT1000_REG_ASIC_ID); if (tempword != 0x1b01) { dev->status |= FT1000_STATUS_CLOSING; - DEBUG("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n"); + pr_debug("Version = 0xffff Card not detected\n"); return FALSE; } return TRUE; @@ -994,8 +982,7 @@ static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, FT1000_MAG_PH_LEN_INDX); size = ntohs(size) + PSEUDOSZ; if (size > maxsz) { - DEBUG("FT1000:ft1000_receive_cmd:Invalid command length = %d\n", - size); + pr_debug("Invalid command length = %d\n", size); return FALSE; } ppseudohdr = (u16 *)pbuffer; @@ -1058,17 +1045,15 @@ static int ft1000_dsp_prov(void *arg) int status; u16 TempShortBuf[256]; - DEBUG("*** DspProv Entered\n"); - while (list_empty(&info->prov_list) == 0) { - DEBUG("DSP Provisioning List Entry\n"); + pr_debug("DSP Provisioning List Entry\n"); /* Check if doorbell is available */ - DEBUG("check if doorbell is cleared\n"); + pr_debug("check if doorbell is cleared\n"); status = ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); if (status) { - DEBUG("ft1000_dsp_prov::ft1000_read_register error\n"); + pr_debug("ft1000_read_register error\n"); break; } @@ -1076,7 +1061,7 @@ static int ft1000_dsp_prov(void *arg) mdelay(10); i++; if (i == 10) { - DEBUG("FT1000:ft1000_dsp_prov:message drop\n"); + pr_debug("message drop\n"); return -1; } ft1000_read_register(dev, &tempword, @@ -1084,7 +1069,7 @@ static int ft1000_dsp_prov(void *arg) } if (!(tempword & FT1000_DB_DPRAM_TX)) { - DEBUG("*** Provision Data Sent to DSP\n"); + pr_debug("*** Provision Data Sent to DSP\n"); /* Send provisioning data */ ptr = @@ -1123,7 +1108,7 @@ static int ft1000_dsp_prov(void *arg) usleep_range(9000, 11000); } - DEBUG("DSP Provisioning List Entry finished\n"); + pr_debug("DSP Provisioning List Entry finished\n"); msleep(100); @@ -1158,37 +1143,26 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) status = ft1000_read_dpram32(dev, 0x200, cmdbuffer, size); #ifdef JDEBUG - DEBUG("ft1000_proc_drvmsg:cmdbuffer\n"); - for (i = 0; i < size; i += 5) { - if ((i + 5) < size) - DEBUG("0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", cmdbuffer[i], - cmdbuffer[i + 1], cmdbuffer[i + 2], - cmdbuffer[i + 3], cmdbuffer[i + 4]); - else { - for (j = i; j < size; j++) - DEBUG("0x%x ", cmdbuffer[j]); - DEBUG("\n"); - break; - } - } + print_hex_dump_debug("cmdbuffer: ", HEX_DUMP_OFFSET, 16, 1, + cmdbuffer, size, true); #endif pdrvmsg = (struct drv_msg *)&cmdbuffer[2]; msgtype = ntohs(pdrvmsg->type); - DEBUG("ft1000_proc_drvmsg:Command message type = 0x%x\n", msgtype); + pr_debug("Command message type = 0x%x\n", msgtype); switch (msgtype) { case MEDIA_STATE:{ - DEBUG("ft1000_proc_drvmsg:Command message type = MEDIA_STATE"); + pr_debug("Command message type = MEDIA_STATE\n"); pmediamsg = (struct media_msg *)&cmdbuffer[0]; if (info->ProgConStat != 0xFF) { if (pmediamsg->state) { - DEBUG("Media is up\n"); + pr_debug("Media is up\n"); if (info->mediastate == 0) { if (dev->NetDevRegDone) netif_wake_queue(dev->net); info->mediastate = 1; } } else { - DEBUG("Media is down\n"); + pr_debug("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; if (dev->NetDevRegDone) @@ -1196,7 +1170,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) } } } else { - DEBUG("Media is down\n"); + pr_debug("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; info->ConTm = 0; @@ -1205,20 +1179,20 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) break; } case DSP_INIT_MSG:{ - DEBUG("ft1000_proc_drvmsg:Command message type = DSP_INIT_MSG"); + pr_debug("Command message type = DSP_INIT_MSG\n"); pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[2]; memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ); - DEBUG("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", - info->DspVer[0], info->DspVer[1], info->DspVer[2], - info->DspVer[3]); + pr_debug("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", + info->DspVer[0], info->DspVer[1], info->DspVer[2], + info->DspVer[3]); memcpy(info->HwSerNum, pdspinitmsg->HwSerNum, HWSERNUMSZ); memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ); memcpy(info->eui64, pdspinitmsg->eui64, EUISZ); - DEBUG("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n", - info->eui64[0], info->eui64[1], info->eui64[2], - info->eui64[3], info->eui64[4], info->eui64[5], - info->eui64[6], info->eui64[7]); + pr_debug("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n", + info->eui64[0], info->eui64[1], info->eui64[2], + info->eui64[3], info->eui64[4], info->eui64[5], + info->eui64[6], info->eui64[7]); dev->net->dev_addr[0] = info->eui64[0]; dev->net->dev_addr[1] = info->eui64[1]; dev->net->dev_addr[2] = info->eui64[2]; @@ -1233,13 +1207,13 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) memcpy(info->RfCalVer, pdspinitmsg->RfCalVer, CALVERSZ); memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, CALDATESZ); - DEBUG("RFCalVer = 0x%2x 0x%2x\n", info->RfCalVer[0], - info->RfCalVer[1]); + pr_debug("RFCalVer = 0x%2x 0x%2x\n", + info->RfCalVer[0], info->RfCalVer[1]); } break; } case DSP_PROVISION:{ - DEBUG("ft1000_proc_drvmsg:Command message type = DSP_PROVISION\n"); + pr_debug("Command message type = DSP_PROVISION\n"); /* kick off dspprov routine to start provisioning * Send provisioning data to DSP @@ -1253,20 +1227,19 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) dev->fProvComplete = true; status = ft1000_write_register(dev, FT1000_DB_HB, FT1000_REG_DOORBELL); - DEBUG("FT1000:drivermsg:No more DSP provisioning data in dsp image\n"); + pr_debug("No more DSP provisioning data in dsp image\n"); } - DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n"); + pr_debug("DSP PROVISION is done\n"); break; } case DSP_STORE_INFO:{ - DEBUG("ft1000_proc_drvmsg:Command message type = DSP_STORE_INFO"); - DEBUG("FT1000:drivermsg:Got DSP_STORE_INFO\n"); + pr_debug("Command message type = DSP_STORE_INFO"); tempword = ntohs(pdrvmsg->length); info->DSPInfoBlklen = tempword; if (tempword < (MAX_DSP_SESS_REC - 4)) { pmsg = (u16 *)&pdrvmsg->data[0]; for (i = 0; i < ((tempword + 1) / 2); i++) { - DEBUG("FT1000:drivermsg:dsp info data = 0x%x\n", *pmsg); + pr_debug("dsp info data = 0x%x\n", *pmsg); info->DSPInfoBlk[i + 10] = *pmsg++; } } else { @@ -1275,7 +1248,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) break; } case DSP_GET_INFO:{ - DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n"); + pr_debug("Got DSP_GET_INFO\n"); /* copy dsp info block to dsp */ dev->DrvMsgPend = 1; /* allow any outstanding ioctl to finish */ @@ -1331,7 +1304,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) break; } case GET_DRV_ERR_RPT_MSG:{ - DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); + pr_debug("Got GET_DRV_ERR_RPT_MSG\n"); /* copy driver error message to dsp */ dev->DrvMsgPend = 1; /* allow any outstanding ioctl to finish */ @@ -1399,7 +1372,6 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) status = 0; out: kfree(cmdbuffer); - DEBUG("return from ft1000_proc_drvmsg\n"); return status; } @@ -1417,7 +1389,7 @@ static int dsp_broadcast_msg_id(struct ft1000_usb *dev) < MAX_MSG_LIMIT)) { pdpram_blk = ft1000_get_buffer(&freercvpool); if (pdpram_blk == NULL) { - DEBUG("Out of memory in free receive command pool\n"); + pr_debug("Out of memory in free receive command pool\n"); dev->app_info[i].nRxMsgMiss++; return -1; } @@ -1437,7 +1409,7 @@ static int dsp_broadcast_msg_id(struct ft1000_usb *dev) } else { dev->app_info[i].nRxMsgMiss++; ft1000_free_buffer(pdpram_blk, &freercvpool); - DEBUG("pdpram_blk::ft1000_get_buffer NULL\n"); + pr_debug("ft1000_get_buffer NULL\n"); return -1; } } @@ -1452,7 +1424,7 @@ static int handle_misc_portid(struct ft1000_usb *dev) pdpram_blk = ft1000_get_buffer(&freercvpool); if (pdpram_blk == NULL) { - DEBUG("Out of memory in free receive command pool\n"); + pr_debug("Out of memory in free receive command pool\n"); return -1; } if (!ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE)) @@ -1465,7 +1437,8 @@ static int handle_misc_portid(struct ft1000_usb *dev) break; } if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_parse_dpram_msg: No application matching id = %d\n", ((struct pseudo_hdr *)pdpram_blk->pbuffer)->portdest); + pr_debug("No application matching id = %d\n", + ((struct pseudo_hdr *)pdpram_blk->pbuffer)->portdest); goto exit_failure; } else if (dev->app_info[i].NumOfMsg > MAX_MSG_LIMIT) { goto exit_failure; @@ -1495,7 +1468,7 @@ int ft1000_poll(void *dev_id) u16 portid; if (ft1000_chkcard(dev) == FALSE) { - DEBUG("ft1000_poll::ft1000_chkcard: failed\n"); + pr_debug("failed\n"); return -1; } status = ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); @@ -1514,7 +1487,7 @@ int ft1000_poll(void *dev_id) if (size < MAX_CMD_SQSIZE) { switch (portid) { case DRIVERID: - DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n"); + pr_debug("FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n"); status = ft1000_proc_drvmsg(dev, size); if (status != 0) return status; @@ -1527,7 +1500,8 @@ int ft1000_poll(void *dev_id) break; } } else - DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size); + pr_debug("Invalid total length for SlowQ = %d\n", + size); status = ft1000_write_register(dev, FT1000_DB_DPRAM_RX, FT1000_REG_DOORBELL); @@ -1547,7 +1521,7 @@ int ft1000_poll(void *dev_id) break; } if (i == 100) { - DEBUG("Unable to reset ASIC\n"); + pr_debug("Unable to reset ASIC\n"); return 0; } usleep_range(9000, 11000); @@ -1560,7 +1534,7 @@ int ft1000_poll(void *dev_id) FT1000_REG_DOORBELL); usleep_range(9000, 11000); } else if (tempword & FT1000_ASIC_RESET_REQ) { - DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_ASIC_RESET_REQ\n"); + pr_debug("FT1000_REG_DOORBELL message type: FT1000_ASIC_RESET_REQ\n"); /* clear ASIC reset request from DSP */ status = ft1000_write_register(dev, FT1000_ASIC_RESET_REQ, @@ -1579,7 +1553,7 @@ int ft1000_poll(void *dev_id) FT1000_ASIC_RESET_DSP, FT1000_REG_DOORBELL); } else if (tempword & FT1000_DB_COND_RESET) { - DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_COND_RESET\n"); + pr_debug("FT1000_REG_DOORBELL message type: FT1000_DB_COND_RESET\n"); if (!dev->fAppMsgPend) { /* Reset ASIC and DSP */ status = ft1000_read_dpram16(dev, @@ -1600,7 +1574,7 @@ int ft1000_poll(void *dev_id) FT1000_MAG_DSP_TIMER3_INDX); info->CardReady = 0; info->DrvErrNum = DSP_CONDRESET_INFO; - DEBUG("ft1000_hw:DSP conditional reset requested\n"); + pr_debug("DSP conditional reset requested\n"); info->ft1000_reset(dev->net); } else { dev->fProvComplete = false; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index 244e3d66d599..a6b55f42c07c 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -7,6 +7,9 @@ * $Id: *==================================================== */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -45,7 +48,7 @@ static int ft1000_poll_thread(void *arg) if (!gPollingfailed) { ret = ft1000_poll(arg); if (ret != 0) { - DEBUG("ft1000_poll_thread: polling failed\n"); + pr_debug("polling failed\n"); gPollingfailed = true; } } @@ -71,9 +74,8 @@ static int ft1000_probe(struct usb_interface *interface, return -ENOMEM; dev = interface_to_usbdev(interface); - DEBUG("ft1000_probe: usb device descriptor info:\n"); - DEBUG("ft1000_probe: number of configuration is %d\n", - dev->descriptor.bNumConfigurations); + pr_debug("usb device descriptor info - number of configuration is %d\n", + dev->descriptor.bNumConfigurations); ft1000dev->dev = dev; ft1000dev->status = 0; @@ -85,42 +87,38 @@ static int ft1000_probe(struct usb_interface *interface, goto err_fw; } - DEBUG("ft1000_probe is called\n"); numaltsetting = interface->num_altsetting; - DEBUG("ft1000_probe: number of alt settings is :%d\n", numaltsetting); + pr_debug("number of alt settings is: %d\n", numaltsetting); iface_desc = interface->cur_altsetting; - DEBUG("ft1000_probe: number of endpoints is %d\n", - iface_desc->desc.bNumEndpoints); - DEBUG("ft1000_probe: descriptor type is %d\n", - iface_desc->desc.bDescriptorType); - DEBUG("ft1000_probe: interface number is %d\n", - iface_desc->desc.bInterfaceNumber); - DEBUG("ft1000_probe: alternatesetting is %d\n", - iface_desc->desc.bAlternateSetting); - DEBUG("ft1000_probe: interface class is %d\n", - iface_desc->desc.bInterfaceClass); - DEBUG("ft1000_probe: control endpoint info:\n"); - DEBUG("ft1000_probe: descriptor0 type -- %d\n", - iface_desc->endpoint[0].desc.bmAttributes); - DEBUG("ft1000_probe: descriptor1 type -- %d\n", - iface_desc->endpoint[1].desc.bmAttributes); - DEBUG("ft1000_probe: descriptor2 type -- %d\n", - iface_desc->endpoint[2].desc.bmAttributes); + pr_debug("number of endpoints is: %d\n", + iface_desc->desc.bNumEndpoints); + pr_debug("descriptor type is: %d\n", iface_desc->desc.bDescriptorType); + pr_debug("interface number is: %d\n", + iface_desc->desc.bInterfaceNumber); + pr_debug("alternatesetting is: %d\n", + iface_desc->desc.bAlternateSetting); + pr_debug("interface class is: %d\n", iface_desc->desc.bInterfaceClass); + pr_debug("control endpoint info:\n"); + pr_debug("descriptor0 type -- %d\n", + iface_desc->endpoint[0].desc.bmAttributes); + pr_debug("descriptor1 type -- %d\n", + iface_desc->endpoint[1].desc.bmAttributes); + pr_debug("descriptor2 type -- %d\n", + iface_desc->endpoint[2].desc.bmAttributes); for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = (struct usb_endpoint_descriptor *)&iface_desc-> endpoint[i].desc; - DEBUG("endpoint %d\n", i); - DEBUG("bEndpointAddress=%x, bmAttributes=%x\n", - endpoint->bEndpointAddress, endpoint->bmAttributes); + pr_debug("endpoint %d\n", i); + pr_debug("bEndpointAddress=%x, bmAttributes=%x\n", + endpoint->bEndpointAddress, endpoint->bmAttributes); if ((endpoint->bEndpointAddress & USB_DIR_IN) && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) { ft1000dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; - DEBUG("ft1000_probe: in: %d\n", - endpoint->bEndpointAddress); + pr_debug("in: %d\n", endpoint->bEndpointAddress); } if (!(endpoint->bEndpointAddress & USB_DIR_IN) @@ -128,17 +126,17 @@ static int ft1000_probe(struct usb_interface *interface, USB_ENDPOINT_XFER_BULK)) { ft1000dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; - DEBUG("ft1000_probe: out: %d\n", - endpoint->bEndpointAddress); + pr_debug("out: %d\n", endpoint->bEndpointAddress); } } - DEBUG("bulk_in=%d, bulk_out=%d\n", ft1000dev->bulk_in_endpointAddr, - ft1000dev->bulk_out_endpointAddr); + pr_debug("bulk_in=%d, bulk_out=%d\n", + ft1000dev->bulk_in_endpointAddr, + ft1000dev->bulk_out_endpointAddr); ret = request_firmware(&dsp_fw, "ft3000.img", &dev->dev); if (ret < 0) { - pr_err("Error request_firmware().\n"); + pr_err("Error request_firmware()\n"); goto err_fw; } @@ -155,7 +153,7 @@ static int ft1000_probe(struct usb_interface *interface, FileLength = dsp_fw->size; release_firmware(dsp_fw); - DEBUG("ft1000_probe: start downloading dsp image...\n"); + pr_debug("start downloading dsp image...\n"); ret = init_ft1000_netdev(ft1000dev); if (ret) @@ -163,7 +161,7 @@ static int ft1000_probe(struct usb_interface *interface, pft1000info = netdev_priv(ft1000dev->net); - DEBUG("In probe: pft1000info=%p\n", pft1000info); + pr_debug("pft1000info=%p\n", pft1000info); ret = dsp_reload(ft1000dev); if (ret) { pr_err("Problem with DSP image loading\n"); @@ -187,10 +185,10 @@ static int ft1000_probe(struct usb_interface *interface, goto err_thread; } msleep(100); - DEBUG("ft1000_probe::Waiting for Card Ready\n"); + pr_debug("Waiting for Card Ready\n"); } - DEBUG("ft1000_probe::Card Ready!!!! Registering network device\n"); + pr_debug("Card Ready!!!! Registering network device\n"); ret = reg_ft1000_netdev(ft1000dev, interface); if (ret) @@ -216,24 +214,21 @@ static void ft1000_disconnect(struct usb_interface *interface) struct ft1000_info *pft1000info; struct ft1000_usb *ft1000dev; - DEBUG("ft1000_disconnect is called\n"); - pft1000info = (struct ft1000_info *)usb_get_intfdata(interface); - DEBUG("In disconnect pft1000info=%p\n", pft1000info); + pr_debug("In disconnect pft1000info=%p\n", pft1000info); if (pft1000info) { ft1000dev = pft1000info->priv; if (ft1000dev->pPollThread) kthread_stop(ft1000dev->pPollThread); - DEBUG("ft1000_disconnect: threads are terminated\n"); + pr_debug("threads are terminated\n"); if (ft1000dev->net) { - DEBUG("ft1000_disconnect: destroy char driver\n"); + pr_debug("destroy char driver\n"); ft1000_destroy_dev(ft1000dev->net); unregister_netdev(ft1000dev->net); - DEBUG - ("ft1000_disconnect: network device unregistered\n"); + pr_debug("network device unregistered\n"); free_netdev(ft1000dev->net); } @@ -241,7 +236,7 @@ static void ft1000_disconnect(struct usb_interface *interface) usb_free_urb(ft1000dev->rx_urb); usb_free_urb(ft1000dev->tx_urb); - DEBUG("ft1000_disconnect: urb freed\n"); + pr_debug("urb freed\n"); kfree(ft1000dev); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index 418e6df91910..fea60d5651a7 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -28,8 +28,6 @@ struct app_info_block { */ } __packed; -#define DEBUG(args...) pr_info(args) - #define FALSE 0 #define TRUE 1 -- cgit v1.2.3-59-g8ed1b From 7be921a226dcbbbd8fb6f5d63bea4856b3a11624 Mon Sep 17 00:00:00 2001 From: Jia He Date: Tue, 4 Nov 2014 09:39:58 +0800 Subject: staging: rtl8188eu: Fix coding style space related ERROR problems This fixes space related ERROR reports by checkpatch.pl Generated by $ git ls-files "drivers/staging/rtl8188eu/*.[ch]" | \ xargs ./scripts/checkpatch.pl -f --fix-inplace --strict --types=SPACING Already checked by text comparasion $git diff -w and binary comparasion of r8188eu.ko $objdiff diff Signed-off-by: Jia He Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 16 +++++----- drivers/staging/rtl8188eu/core/rtw_mlme.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 22 +++++++------- drivers/staging/rtl8188eu/core/rtw_recv.c | 12 ++++---- drivers/staging/rtl8188eu/core/rtw_security.c | 20 ++++++------- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8188eu/core/rtw_xmit.c | 10 +++---- drivers/staging/rtl8188eu/hal/bb_cfg.c | 2 +- drivers/staging/rtl8188eu/hal/fw.c | 8 ++--- drivers/staging/rtl8188eu/hal/mac_cfg.c | 2 +- drivers/staging/rtl8188eu/hal/odm.c | 8 ++--- drivers/staging/rtl8188eu/hal/odm_HWConfig.c | 2 +- drivers/staging/rtl8188eu/hal/odm_RTL8188E.c | 2 +- drivers/staging/rtl8188eu/hal/phy.c | 2 +- drivers/staging/rtl8188eu/hal/rf.c | 2 +- drivers/staging/rtl8188eu/hal/rf_cfg.c | 4 +-- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 2 +- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 +- drivers/staging/rtl8188eu/include/ieee80211_ext.h | 20 ++++++------- drivers/staging/rtl8188eu/include/osdep_service.h | 4 +-- drivers/staging/rtl8188eu/include/rtw_debug.h | 2 +- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 26 ++++++++-------- drivers/staging/rtl8188eu/include/wifi.h | 36 +++++++++++------------ drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 +-- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 2 +- 30 files changed, 112 insertions(+), 112 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index dd24138d13b1..a1cc788fe4b3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -637,7 +637,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) ether_addr_copy(psetstakey_para->addr, sta->hwaddr); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm; + psetstakey_para->algorithm = (unsigned char)psecuritypriv->dot11PrivacyAlgrthm; else GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 755d3effd0a7..f2c3ca79c0c9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -159,7 +159,7 @@ u8 *rtw_set_ie return pbuf + len + 2; } -inline u8 *rtw_set_ie_ch_switch (u8 *buf, u32 *buf_len, u8 ch_switch_mode, +inline u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt) { u8 ie_data[3]; @@ -870,7 +870,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, if (elen < 4) { if (show_errors) { DBG_88E("short vendor specific information element ignored (len=%lu)\n", - (unsigned long) elen); + (unsigned long)elen); } return -1; } @@ -890,7 +890,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ if (elen < 5) { DBG_88E("short WME information element ignored (len=%lu)\n", - (unsigned long) elen); + (unsigned long)elen); return -1; } switch (pos[4]) { @@ -905,7 +905,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("unknown WME information element ignored (subtype=%d len=%lu)\n", - pos[4], (unsigned long) elen); + pos[4], (unsigned long)elen); return -1; } break; @@ -916,7 +916,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("Unknown Microsoft information element ignored (type=%d len=%lu)\n", - pos[3], (unsigned long) elen); + pos[3], (unsigned long)elen); return -1; } break; @@ -929,13 +929,13 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("Unknown Broadcom information element ignored (type=%d len=%lu)\n", - pos[3], (unsigned long) elen); + pos[3], (unsigned long)elen); return -1; } break; default: DBG_88E("unknown vendor specific information element ignored (vendor OUI %02x:%02x:%02x len=%lu)\n", - pos[0], pos[1], pos[2], (unsigned long) elen); + pos[0], pos[1], pos[2], (unsigned long)elen); return -1; } return 0; @@ -969,7 +969,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, if (elen > left) { if (show_errors) { DBG_88E("IEEE 802.11 element parse failed (id=%d elen=%d left=%lu)\n", - id, elen, (unsigned long) left); + id, elen, (unsigned long)left); } return ParseFailed; } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index dec26a89c356..d4632da50c1d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -2115,7 +2115,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr if (0 == issued) { DBG_88E("rtw_issue_addbareq_cmd, p=%d\n", priority); psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); - rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra); + rtw_addbareq_cmd(padapter, (u8)priority, pattrib->ra); } } } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index a00ebcddc881..b0e92372fa5e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -227,7 +227,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) pmlmeext->cur_channel = padapter->registrypriv.channel; pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmlmeext->oper_channel = pmlmeext->cur_channel ; + pmlmeext->oper_channel = pmlmeext->cur_channel; pmlmeext->oper_bwmode = pmlmeext->cur_bwmode; pmlmeext->oper_ch_offset = pmlmeext->cur_ch_offset; pmlmeext->retry = 0; @@ -2000,7 +2000,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) DBG_88E("%s, alloc mgnt frame fail\n", __func__); return; } -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) spin_lock_bh(&pmlmepriv->bcn_update_lock); #endif /* if defined (CONFIG_88EU_AP_MODE) */ @@ -2027,7 +2027,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) SetFrameSubType(pframe, WIFI_BEACON); pframe += sizeof(struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { int len_diff; @@ -2042,8 +2042,8 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) ); pframe += (cur_network->IELength+len_diff); pattrib->pktlen += (cur_network->IELength+len_diff); - wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof (struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, - pattrib->pktlen-sizeof (struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); + wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, + pattrib->pktlen-sizeof(struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); if (wps_ie && wps_ielen > 0) rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); if (sr != 0) @@ -2101,7 +2101,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* todo:HT for adhoc */ _issue_bcn: -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) pmlmepriv->update_bcn = false; spin_unlock_bh(&pmlmepriv->bcn_update_lock); @@ -2130,7 +2130,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p __le16 *fctrl; unsigned char *mac, *bssid; struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2323,8 +2323,8 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_PROBEREQ); - pframe += sizeof (struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if (pssid) pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); @@ -3209,7 +3209,7 @@ exit: return ret; } -void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) +void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -3260,7 +3260,7 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); } - pframe = rtw_set_ie_ch_switch (pframe, &(pattrib->pktlen), 0, new_ch, 0); + pframe = rtw_set_ie_ch_switch(pframe, &(pattrib->pktlen), 0, new_ch, 0); pframe = rtw_set_ie_secondary_ch_offset(pframe, &(pattrib->pktlen), hal_ch_offset_to_secondary_ch_offset(ch_offset)); diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 53a054c189e4..a1619b88733f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -46,7 +46,7 @@ void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { - memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); + memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); spin_lock_init(&psta_recvpriv->lock); @@ -109,7 +109,7 @@ exit: return res; } -void _rtw_free_recv_priv (struct recv_priv *precvpriv) +void _rtw_free_recv_priv(struct recv_priv *precvpriv) { struct adapter *padapter = precvpriv->adapter; @@ -124,7 +124,7 @@ void _rtw_free_recv_priv (struct recv_priv *precvpriv) } -struct 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; struct list_head *plist, *phead; @@ -797,7 +797,7 @@ exit: return ret; } -static int ap2sta_data_frame ( +static int ap2sta_data_frame( struct adapter *adapter, struct recv_frame *precv_frame, struct sta_info **psta) @@ -1266,7 +1266,7 @@ static int validate_recv_frame(struct adapter *adapter, u8 bDumpRxPkt; struct rx_pkt_attrib *pattrib = &precv_frame->attrib; u8 *ptr = precv_frame->rx_data; - u8 ver = (unsigned char) (*ptr)&0x3; + u8 ver = (unsigned char)(*ptr)&0x3; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; @@ -1981,7 +1981,7 @@ static int process_recv_indicatepkts(struct adapter *padapter, } } } else { /* B/G mode */ - retval = wlanhdr_to_ethhdr (prframe); + retval = wlanhdr_to_ethhdr(prframe); if (retval != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n")); return retval; diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 1baa98e636e1..bd8d60a230e9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -189,7 +189,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) arcfour_encrypt(&mycontext, payload+length, crc, 4); pframe += pxmitpriv->frag_len; - pframe = (u8 *) round_up((size_t)(pframe), 4); + pframe = (u8 *)round_up((size_t)(pframe), 4); } } } @@ -258,7 +258,7 @@ static void secmicputuint32(u8 *p, u32 val) { long i; for (i = 0; i < 4; i++) { - *p++ = (u8) (val & 0xff); + *p++ = (u8)(val & 0xff); val >>= 8; } } @@ -621,14 +621,14 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); pframe += pxmitpriv->frag_len; - pframe = (u8 *) round_up((size_t)(pframe), 4); + pframe = (u8 *)round_up((size_t)(pframe), 4); } } } else { @@ -953,8 +953,8 @@ static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ for (i = 8; i < 14; i++) 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); + mic_iv[14] = (unsigned char)(payload_length / 256); + mic_iv[15] = (unsigned char)(payload_length % 256); } /************************************************/ @@ -1045,8 +1045,8 @@ static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ for (i = 8; i < 14; i++) 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); + ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */ + ctr_preload[15] = (unsigned char)(c % 256); } /************************************/ @@ -1238,11 +1238,11 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) aes_cipher(prwskey, pattrib->hdrlen, pframe, length); } else{ - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len; - pframe = (u8 *) round_up((size_t)(pframe), 8); + pframe = (u8 *)round_up((size_t)(pframe), 8); } } } else{ diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index e1dc8fa82d38..dc9d0ddf6b3a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -29,7 +29,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) { - memset((u8 *)psta, 0, sizeof (struct sta_info)); + memset((u8 *)psta, 0, sizeof(struct sta_info)); spin_lock_init(&psta->lock); INIT_LIST_HEAD(&psta->list); diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 639ace06a3d6..a0bbf9093338 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -37,7 +37,7 @@ static void _init_txservq(struct tx_servq *ptxservq) void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) { - memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); + memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv)); spin_lock_init(&psta_xmitpriv->lock); _init_txservq(&psta_xmitpriv->be_q); _init_txservq(&psta_xmitpriv->bk_q); @@ -223,7 +223,7 @@ exit: return res; } -void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) +void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) { int i; struct adapter *padapter = pxmitpriv->adapter; @@ -691,7 +691,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr payload = pframe; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - payload = (u8 *) round_up((size_t)(payload), 4); + payload = (u8 *)round_up((size_t)(payload), 4); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("=== curfragnum=%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n", curfragnum, *payload, *(payload+1), @@ -772,7 +772,7 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi return _SUCCESS; } -s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) +s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { u16 *qc; @@ -1098,7 +1098,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct addr = (size_t)(pframe); - mem_start = (unsigned char *) round_up(addr, 4) + hw_hdr_offset; + mem_start = (unsigned char *)round_up(addr, 4) + hw_hdr_offset; memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); } diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c b/drivers/staging/rtl8188eu/hal/bb_cfg.c index c2d166fa0a7f..1e963bf9e48b 100644 --- a/drivers/staging/rtl8188eu/hal/bb_cfg.c +++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c @@ -552,7 +552,7 @@ static void store_pwrindex_offset(struct adapter *Adapter, u32 regaddr, u32 bitm } } -static void rtl_addr_delay(struct adapter *adapt, u32 addr, u32 bit_mask ,u32 data) +static void rtl_addr_delay(struct adapter *adapt, u32 addr, u32 bit_mask, u32 data) { if (addr == 0xfe) { msleep(50); diff --git a/drivers/staging/rtl8188eu/hal/fw.c b/drivers/staging/rtl8188eu/hal/fw.c index 17b7f3750547..3b2875481fc5 100644 --- a/drivers/staging/rtl8188eu/hal/fw.c +++ b/drivers/staging/rtl8188eu/hal/fw.c @@ -84,7 +84,7 @@ static void _rtl88e_fw_block_write(struct adapter *adapt, static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen) { u32 fwlen = *pfwlen; - u8 remain = (u8) (fwlen % 4); + u8 remain = (u8)(fwlen % 4); remain = (remain == 0) ? 0 : (4 - remain); @@ -101,7 +101,7 @@ static void _rtl88e_fw_page_write(struct adapter *adapt, u32 page, const u8 *buffer, u32 size) { u8 value8; - u8 u8page = (u8) (page & 0x07); + u8 u8page = (u8)(page & 0x07); value8 = (usb_read8(adapt, REG_MCUFWDL + 2) & 0xF8) | u8page; @@ -193,13 +193,13 @@ int rtl88eu_download_fw(struct adapter *adapt) u32 fwsize; int err; - if (request_firmware(&fw, fw_name, device)){ + if (request_firmware(&fw, fw_name, device)) { dev_err(device, "Firmware %s not available\n", fw_name); return -ENOENT; } if (fw->size > FW_8188E_SIZE) { - dev_err(device,"Firmware size exceed 0x%X. Check it.\n", + dev_err(device, "Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE); return -1; } diff --git a/drivers/staging/rtl8188eu/hal/mac_cfg.c b/drivers/staging/rtl8188eu/hal/mac_cfg.c index c0e7fa938059..febc83a5adb8 100644 --- a/drivers/staging/rtl8188eu/hal/mac_cfg.c +++ b/drivers/staging/rtl8188eu/hal/mac_cfg.c @@ -127,7 +127,7 @@ bool rtl88eu_phy_mac_config(struct adapter *adapt) ptrarray = array_MAC_REG_8188E; for (i = 0; i < arraylength; i = i + 2) - usb_write8(adapt, ptrarray[i], (u8) ptrarray[i + 1]); + usb_write8(adapt, ptrarray[i], (u8)ptrarray[i + 1]); usb_write8(adapt, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); return true; diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index e4df83710ca6..9873998011d2 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -437,8 +437,8 @@ void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) { struct adapter *adapter = pDM_Odm->Adapter; - pDM_Odm->bCckHighPower = (bool) phy_query_bb_reg(adapter, 0x824, BIT9); - pDM_Odm->RFPathRxEnable = (u8) phy_query_bb_reg(adapter, 0xc04, 0x0F); + pDM_Odm->bCckHighPower = (bool)phy_query_bb_reg(adapter, 0x824, BIT9); + pDM_Odm->RFPathRxEnable = (u8)phy_query_bb_reg(adapter, 0xc04, 0x0F); ODM_InitDebugSetting(pDM_Odm); } @@ -529,7 +529,7 @@ void odm_DIGInit(struct odm_dm_struct *pDM_Odm) struct adapter *adapter = pDM_Odm->Adapter; struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - pDM_DigTable->CurIGValue = (u8) phy_query_bb_reg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N); + pDM_DigTable->CurIGValue = (u8)phy_query_bb_reg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N); pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; @@ -620,7 +620,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } else if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) { /* 1 Lower Bound for 88E AntDiv */ if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) { - DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; + DIG_Dynamic_MIN = (u8)pDM_DigTable->AntDiv_RSSI_max; ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d\n", pDM_DigTable->AntDiv_RSSI_max)); diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c index 4e4e21936e7c..29f87dffbad3 100644 --- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c @@ -118,7 +118,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, cck_highpwr = dm_odm->bCckHighPower; - cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ; + cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a; /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ /* The RSSI formula should be modified according to the gain table */ diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c index 5342af778eb0..d3c6873925ba 100644 --- a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c @@ -278,7 +278,7 @@ static void rtl88eu_dm_hw_ant_div(struct odm_dm_struct *dm_odm) struct rtw_dig *dig_table = &dm_odm->DM_DigTable; struct sta_info *entry; u32 i, min_rssi = 0xFF, ant_div_max_rssi = 0, max_rssi = 0; - u32 local_min_rssi,local_max_rssi; + u32 local_min_rssi, local_max_rssi; u32 main_rssi, aux_rssi; u8 RxIdleAnt = 0, target_ant = 7; diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index c4f7f358a81c..3f663fe151ba 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -478,7 +478,7 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt) /* 2.4G, decrease power */ {0, 0, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11}, /* 2.4G, increase power */ - {0, 0, -1, -2, -3, -4,-4, -4, -4, -5, -7, -8,-9, -9, -10}, + {0, 0, -1, -2, -3, -4, -4, -4, -4, -5, -7, -8, -9, -9, -10}, }; u8 thermal_mapping[2][index_mapping_NUM_88E] = { /* 2.4G, decrease power */ diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c index c2fac34c8132..eea4c8a6022b 100644 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ b/drivers/staging/rtl8188eu/hal/rf.c @@ -131,7 +131,7 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) /* powerbase1 for HT MCS rates */ static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, u8 *pwr_level_bw20, u8 *pwr_level_bw40, - u8 channel,u32 *ofdmbase, u32 *mcs_base) + u8 channel, u32 *ofdmbase, u32 *mcs_base) { struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); u32 powerbase0, powerbase1; diff --git a/drivers/staging/rtl8188eu/hal/rf_cfg.c b/drivers/staging/rtl8188eu/hal/rf_cfg.c index ddc2f55fe13f..5dc11cae2ef9 100644 --- a/drivers/staging/rtl8188eu/hal/rf_cfg.c +++ b/drivers/staging/rtl8188eu/hal/rf_cfg.c @@ -164,7 +164,7 @@ do { \ #define B3WIREDATALENGTH 0x800 #define BRFSI_RFENV 0x10 -static void rtl_rfreg_delay(struct adapter *adapt, enum rf_radio_path rfpath,u32 addr, u32 mask, u32 data) +static void rtl_rfreg_delay(struct adapter *adapt, enum rf_radio_path rfpath, u32 addr, u32 mask, u32 data) { if (addr == 0xfe) { mdelay(50); @@ -190,7 +190,7 @@ static void rtl8188e_config_rf_reg(struct adapter *adapt, u32 content = 0x1000; /*RF Content: radio_a_txt*/ u32 maskforphyset = (u32)(content & 0xE000); - rtl_rfreg_delay(adapt, RF90_PATH_A, addr| maskforphyset, + rtl_rfreg_delay(adapt, RF90_PATH_A, addr | maskforphyset, RFREG_OFFSET_MASK, data); } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index ce55d9d9f0f6..7f30dea1b53b 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -252,7 +252,7 @@ void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) { u8 opmode, macid; u16 mst_rpt = le16_to_cpu(mstatus_rpt); - opmode = (u8) mst_rpt; + opmode = (u8)mst_rpt; macid = (u8)(mst_rpt >> 8); DBG_88E("### %s: MStatus=%x MACID=%d\n", __func__, opmode, macid); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index be9eede6931d..594c1da9db23 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -399,7 +399,7 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) mem_addr += w_sz; - mem_addr = (u8 *) round_up((size_t)mem_addr, 4); + mem_addr = (u8 *)round_up((size_t)mem_addr, 4); } rtw_free_xmitframe(pxmitpriv, pxmitframe); diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index ac6abac58bfe..14650e91c78a 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -2012,7 +2012,7 @@ static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eV u8 bRSSIDump = *((u8 *)pValue); struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); if (bRSSIDump) - dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; + dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT; else dm_ocm->DebugComponents = 0; } diff --git a/drivers/staging/rtl8188eu/include/ieee80211_ext.h b/drivers/staging/rtl8188eu/include/ieee80211_ext.h index 1052d1817a97..15e53d380ad0 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211_ext.h +++ b/drivers/staging/rtl8188eu/include/ieee80211_ext.h @@ -103,24 +103,24 @@ struct wme_parameter_element { #define WPA_PUT_LE16(a, val) \ do { \ - (a)[1] = ((u16) (val)) >> 8; \ - (a)[0] = ((u16) (val)) & 0xff; \ + (a)[1] = ((u16)(val)) >> 8; \ + (a)[0] = ((u16)(val)) & 0xff; \ } while (0) #define WPA_PUT_BE32(a, val) \ do { \ - (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[3] = (u8) (((u32) (val)) & 0xff); \ + (a)[0] = (u8)((((u32) (val)) >> 24) & 0xff); \ + (a)[1] = (u8)((((u32) (val)) >> 16) & 0xff); \ + (a)[2] = (u8)((((u32) (val)) >> 8) & 0xff); \ + (a)[3] = (u8)(((u32) (val)) & 0xff); \ } while (0) #define WPA_PUT_LE32(a, val) \ do { \ - (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[0] = (u8) (((u32) (val)) & 0xff); \ + (a)[3] = (u8)((((u32) (val)) >> 24) & 0xff); \ + (a)[2] = (u8)((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8)((((u32) (val)) >> 8) & 0xff); \ + (a)[0] = (u8)(((u32) (val)) & 0xff); \ } while (0) #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *)(a), (val)) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index fed9c86890b4..82f58f87656a 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -182,8 +182,8 @@ u64 rtw_modular64(u64 x, u64 y); /* Macros for handling unaligned memory accesses */ -#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ - ((u32) (a)[2])) +#define RTW_GET_BE24(a) ((((u32)(a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ + ((u32)(a)[2])) void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h index a38616e3cad2..971bf457f32d 100644 --- a/drivers/staging/rtl8188eu/include/rtw_debug.h +++ b/drivers/staging/rtl8188eu/include/rtw_debug.h @@ -106,7 +106,7 @@ extern u32 GlobalDebugLevel; u8 *ptr = (u8 *)_hexdata; \ pr_info("%s", DRIVER_PREFIX); \ pr_info(_titlestring); \ - for (__i = 0; __i < (int)_hexdatalen; __i++ ) { \ + for (__i = 0; __i < (int)_hexdatalen; __i++) { \ pr_info("%02X%s", ptr[__i], \ (((__i + 1) % 4) == 0) ? \ " " : " "); \ diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index c5194b620da4..dec8dbc483b4 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -92,7 +92,7 @@ struct LED_871x { void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); -struct led_priv{ +struct led_priv { /* add for led control */ struct LED_871x SwLed0; u8 bRegUseLed; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index d699ca19ef16..8d72ccf5f2a0 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -448,7 +448,7 @@ struct mlme_ext_priv { int init_mlme_ext_priv(struct adapter *adapter); int init_hw_mlme_ext(struct adapter *padapter); -void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext); +void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext); extern void init_mlme_ext_timer(struct adapter *padapter); extern void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta); extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); @@ -646,8 +646,8 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, void linked_status_chk(struct adapter *padapter); -void survey_timer_hdl (void *function_context); -void link_timer_hdl (void *funtion_context); +void survey_timer_hdl(void *function_context); +void link_timer_hdl(void *funtion_context); void addba_timer_hdl(void *function_context); #define set_survey_timer(mlmeext, ms) \ @@ -708,15 +708,15 @@ u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf); #ifdef _RTW_CMD_C_ static struct cmd_hdl wlancmds[] = { - GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), join_cmd_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), createbss_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), sitesurvey_cmd_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), join_cmd_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), createbss_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL) GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl) GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), tx_beacon_hdl) @@ -787,7 +787,7 @@ static struct fwevent wlanevents[] = { {0, NULL}, {0, NULL}, {0, &rtw_survey_event_callback}, /*8*/ - {sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ + {sizeof(struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ {0, &rtw_joinbss_event_callback}, /*10*/ {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, {sizeof(struct stadel_event), &rtw_stadel_event_callback}, diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index a88ebf41bba1..8dbdfafd52b5 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -766,27 +766,27 @@ enum ht_cap_ampdu_factor { #define OP_MODE_20MHZ_HT_STA_ASSOCED 2 #define OP_MODE_MIXED 3 -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) -#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) -#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) -#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8)BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8)BIT(0)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8)BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8)BIT(2)) +#define HT_INFO_HT_PARAM_RIFS_MODE ((u8)BIT(3)) +#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8)BIT(4)) +#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8)BIT(5)) #define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ - ((u16) (0x0001 | 0x0002)) + ((u16)(0x0001 | 0x0002)) #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 -#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) -#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) -#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) - -#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) -#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) -#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16) BIT(8)) -#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) -#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) -#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) +#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8)BIT(2)) +#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8)BIT(3)) +#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8)BIT(4)) + +#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16)BIT(6)) +#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16)BIT(7)) +#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16)BIT(8)) +#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16)BIT(9)) +#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16)BIT(10)) +#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16)BIT(11)) /* ===============WPS Section=============== */ /* For WPSv1.0 */ diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 08ba7d3e6c69..f34fb29ae225 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -361,7 +361,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, param->u.crypt.err = 0; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { + if (param_len < (u32)((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { ret = -EINVAL; goto exit; } diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 08a80f759b8d..0b488d29bd37 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -527,7 +527,7 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) registry_par->channel = (u8)rtw_channel; registry_par->wireless_mode = (u8)rtw_wireless_mode; - registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; + registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense; registry_par->vcs_type = (u8)rtw_vcs_type; registry_par->rts_thresh = (u16)rtw_rts_thresh; registry_par->frag_thresh = (u16)rtw_frag_thresh; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 7da85f9c127b..d2efa9dfc8c0 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -160,10 +160,10 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) switch (haldata->UsbRxAggMode) { case USB_RX_AGG_DMA: case USB_RX_AGG_MIX: - pkt_offset = (u16) round_up(pkt_offset, 128); + pkt_offset = (u16)round_up(pkt_offset, 128); break; case USB_RX_AGG_USB: - pkt_offset = (u16) round_up(pkt_offset, 4); + pkt_offset = (u16)round_up(pkt_offset, 4); break; case USB_RX_AGG_DISABLE: default: diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 0ce47b07ef86..d5e41a52a0eb 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -46,7 +46,7 @@ void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) } -uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) +uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) { uint len = 0; -- cgit v1.2.3-59-g8ed1b From 455f0049e0c02ee0a769d967b1eba2c52e932237 Mon Sep 17 00:00:00 2001 From: George McCollister Date: Fri, 31 Oct 2014 10:44:23 -0500 Subject: iio: as3935: Remove unnecessary semicolons Signed-off-by: George McCollister Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/as3935.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index 5e780ef206f3..78244e6343f6 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -95,7 +95,7 @@ static int as3935_read(struct as3935_state *st, unsigned int reg, int *val) *val = ret; return 0; -}; +} static int as3935_write(struct as3935_state *st, unsigned int reg, @@ -107,7 +107,7 @@ static int as3935_write(struct as3935_state *st, buf[1] = val; return spi_write(st->spi, buf, 2); -}; +} static ssize_t as3935_sensor_sensitivity_show(struct device *dev, struct device_attribute *attr, @@ -122,7 +122,7 @@ static ssize_t as3935_sensor_sensitivity_show(struct device *dev, val = (val & AS3935_AFE_MASK) >> 1; return sprintf(buf, "%d\n", val); -}; +} static ssize_t as3935_sensor_sensitivity_store(struct device *dev, struct device_attribute *attr, @@ -142,7 +142,7 @@ static ssize_t as3935_sensor_sensitivity_store(struct device *dev, as3935_write(st, AS3935_AFE_GAIN, val << 1); return len; -}; +} static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR, as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0); @@ -214,7 +214,7 @@ err_read: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; -}; +} static const struct iio_trigger_ops iio_interrupt_trigger_ops = { .owner = THIS_MODULE, @@ -238,7 +238,7 @@ static void as3935_event_work(struct work_struct *work) dev_warn(&st->spi->dev, "noise level is too high"); break; } -}; +} static irqreturn_t as3935_interrupt_handler(int irq, void *private) { @@ -417,7 +417,7 @@ unregister_trigger: iio_trigger_unregister(st->trig); return ret; -}; +} static int as3935_remove(struct spi_device *spi) { @@ -429,7 +429,7 @@ static int as3935_remove(struct spi_device *spi) iio_trigger_unregister(st->trig); return 0; -}; +} static const struct spi_device_id as3935_id[] = { {"as3935", 0}, -- cgit v1.2.3-59-g8ed1b From b6d5be57024a8edcc91d0c2549d63c68d67a2257 Mon Sep 17 00:00:00 2001 From: Karol Wrona Date: Tue, 4 Nov 2014 15:29:39 +0100 Subject: staging: iio: Add notrigger mode for generic_buffer Some IIO devices do not use the triggers. This patch makes trigger setting conditional so generic_buffer can be used when triggers are disabled. Signed-off-by: Karol Wrona Signed-off-by: Jonathan Cameron --- drivers/staging/iio/Documentation/generic_buffer.c | 77 +++++++++++++--------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c index 044ea196aa6f..2671bf9433cb 100644 --- a/drivers/staging/iio/Documentation/generic_buffer.c +++ b/drivers/staging/iio/Documentation/generic_buffer.c @@ -158,11 +158,12 @@ int main(int argc, char **argv) char *buffer_access; int scan_size; int noevents = 0; + int notrigger = 0; char *dummy; struct iio_channel_info *channels; - while ((c = getopt(argc, argv, "l:w:c:et:n:")) != -1) { + while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) { switch (c) { case 'n': device_name = optarg; @@ -183,6 +184,9 @@ int main(int argc, char **argv) case 'l': buf_len = strtoul(optarg, &dummy, 10); break; + case 'g': + notrigger = 1; + break; case '?': return -1; } @@ -201,28 +205,32 @@ int main(int argc, char **argv) printf("iio device number being used is %d\n", dev_num); asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); - if (trigger_name == NULL) { - /* - * Build the trigger name. If it is device associated its - * name is _dev[n] where n matches the device - * number found above - */ - ret = asprintf(&trigger_name, - "%s-dev%d", device_name, dev_num); - if (ret < 0) { - ret = -ENOMEM; - goto error_ret; + + if (!notrigger) { + if (trigger_name == NULL) { + /* + * Build the trigger name. If it is device associated + * its name is _dev[n] where n matches + * the device number found above. + */ + ret = asprintf(&trigger_name, + "%s-dev%d", device_name, dev_num); + if (ret < 0) { + ret = -ENOMEM; + goto error_ret; + } } - } - /* Verify the trigger exists */ - trig_num = find_type_by_name(trigger_name, "trigger"); - if (trig_num < 0) { - printf("Failed to find the trigger %s\n", trigger_name); - ret = -ENODEV; - goto error_free_triggername; - } - printf("iio trigger number being used is %d\n", trig_num); + /* Verify the trigger exists */ + trig_num = find_type_by_name(trigger_name, "trigger"); + if (trig_num < 0) { + printf("Failed to find the trigger %s\n", trigger_name); + ret = -ENODEV; + goto error_free_triggername; + } + printf("iio trigger number being used is %d\n", trig_num); + } else + printf("trigger-less mode selected\n"); /* * Parse the files in scan_elements to identify what channels are @@ -246,14 +254,18 @@ int main(int argc, char **argv) ret = -ENOMEM; goto error_free_triggername; } - printf("%s %s\n", dev_dir_name, trigger_name); - /* Set the device trigger to be the data ready trigger found above */ - ret = write_sysfs_string_and_verify("trigger/current_trigger", - dev_dir_name, - trigger_name); - if (ret < 0) { - printf("Failed to write current_trigger file\n"); - goto error_free_buf_dir_name; + + if (!notrigger) { + printf("%s %s\n", dev_dir_name, trigger_name); + /* Set the device trigger to be the data ready trigger found + * above */ + ret = write_sysfs_string_and_verify("trigger/current_trigger", + dev_dir_name, + trigger_name); + if (ret < 0) { + printf("Failed to write current_trigger file\n"); + goto error_free_buf_dir_name; + } } /* Setup ring buffer parameters */ @@ -323,9 +335,10 @@ int main(int argc, char **argv) if (ret < 0) goto error_close_buffer_access; - /* Disconnect the trigger - just write a dummy name. */ - write_sysfs_string("trigger/current_trigger", - dev_dir_name, "NULL"); + if (!notrigger) + /* Disconnect the trigger - just write a dummy name. */ + write_sysfs_string("trigger/current_trigger", + dev_dir_name, "NULL"); error_close_buffer_access: close(fp); -- cgit v1.2.3-59-g8ed1b From fafb37cfae6d228c0026fcf31d02e1c3db2e78ee Mon Sep 17 00:00:00 2001 From: Naveen Krishna Chatradhi Date: Tue, 16 Sep 2014 09:58:00 +0100 Subject: iio: exyno-adc: use syscon for PMU register access This patch updates the IIO based ADC driver to use syscon and regmap APIs to access and use PMU registers instead of remapping the PMU registers in the driver. Signed-off-by: Naveen Krishna Chatradhi To: linux-iio@vger.kernel.org Acked-by: Kukjin Kim Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 43620fd4c66a..fe0317745436 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */ #define ADC_V1_CON(x) ((x) + 0x00) @@ -90,11 +92,14 @@ #define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100)) +#define EXYNOS_ADCV1_PHY_OFFSET 0x0718 +#define EXYNOS_ADCV2_PHY_OFFSET 0x0720 + struct exynos_adc { struct exynos_adc_data *data; struct device *dev; void __iomem *regs; - void __iomem *enable_reg; + struct regmap *pmu_map; struct clk *clk; struct clk *sclk; unsigned int irq; @@ -110,6 +115,7 @@ struct exynos_adc_data { int num_channels; bool needs_sclk; bool needs_adc_phy; + int phy_offset; u32 mask; void (*init_hw)(struct exynos_adc *info); @@ -183,7 +189,7 @@ static void exynos_adc_v1_init_hw(struct exynos_adc *info) u32 con1; if (info->data->needs_adc_phy) - writel(1, info->enable_reg); + regmap_write(info->pmu_map, info->data->phy_offset, 1); /* set default prescaler values and Enable prescaler */ con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; @@ -198,7 +204,7 @@ static void exynos_adc_v1_exit_hw(struct exynos_adc *info) u32 con; if (info->data->needs_adc_phy) - writel(0, info->enable_reg); + regmap_write(info->pmu_map, info->data->phy_offset, 0); con = readl(ADC_V1_CON(info->regs)); con |= ADC_V1_CON_STANDBY; @@ -225,6 +231,7 @@ static const struct exynos_adc_data exynos_adc_v1_data = { .num_channels = MAX_ADC_V1_CHANNELS, .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ .needs_adc_phy = true, + .phy_offset = EXYNOS_ADCV1_PHY_OFFSET, .init_hw = exynos_adc_v1_init_hw, .exit_hw = exynos_adc_v1_exit_hw, @@ -314,7 +321,7 @@ static void exynos_adc_v2_init_hw(struct exynos_adc *info) u32 con1, con2; if (info->data->needs_adc_phy) - writel(1, info->enable_reg); + regmap_write(info->pmu_map, info->data->phy_offset, 1); con1 = ADC_V2_CON1_SOFT_RESET; writel(con1, ADC_V2_CON1(info->regs)); @@ -332,7 +339,7 @@ static void exynos_adc_v2_exit_hw(struct exynos_adc *info) u32 con; if (info->data->needs_adc_phy) - writel(0, info->enable_reg); + regmap_write(info->pmu_map, info->data->phy_offset, 0); con = readl(ADC_V2_CON1(info->regs)); con &= ~ADC_CON_EN_START; @@ -362,6 +369,7 @@ static const struct exynos_adc_data exynos_adc_v2_data = { .num_channels = MAX_ADC_V2_CHANNELS, .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ .needs_adc_phy = true, + .phy_offset = EXYNOS_ADCV2_PHY_OFFSET, .init_hw = exynos_adc_v2_init_hw, .exit_hw = exynos_adc_v2_exit_hw, @@ -374,6 +382,7 @@ static const struct exynos_adc_data exynos3250_adc_data = { .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ .needs_sclk = true, .needs_adc_phy = true, + .phy_offset = EXYNOS_ADCV1_PHY_OFFSET, .init_hw = exynos_adc_v2_init_hw, .exit_hw = exynos_adc_v2_exit_hw, @@ -558,10 +567,13 @@ static int exynos_adc_probe(struct platform_device *pdev) if (info->data->needs_adc_phy) { - mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); - info->enable_reg = devm_ioremap_resource(&pdev->dev, mem); - if (IS_ERR(info->enable_reg)) - return PTR_ERR(info->enable_reg); + info->pmu_map = syscon_regmap_lookup_by_phandle( + pdev->dev.of_node, + "samsung,syscon-phandle"); + if (IS_ERR(info->pmu_map)) { + dev_err(&pdev->dev, "syscon regmap lookup failed.\n"); + return PTR_ERR(info->pmu_map); + } } irq = platform_get_irq(pdev, 0); -- cgit v1.2.3-59-g8ed1b From b626c8f0d909be88534ab3d25dd9fbffcc884b47 Mon Sep 17 00:00:00 2001 From: Naveen Krishna Chatradhi Date: Tue, 16 Sep 2014 09:58:00 +0100 Subject: Documentation: dt-bindings: update exynos-adc.txt with syscon handle This patch updates the DT bindings for ADC in exynos-adc.txt with the syscon phandle to the ADC nodes. Signed-off-by: Naveen Krishna Chatradhi To: devicetree@vger.kernel.org Acked-by: Kukjin Kim Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt index 709efaa30841..c36821095393 100644 --- a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt +++ b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt @@ -43,13 +43,16 @@ Required properties: compatible ADC block) - vdd-supply VDD input supply. +- samsung,syscon-phandle Contains the PMU system controller node + (To access the ADC_PHY register on Exynos5250/5420/5800/3250) + Note: child nodes can be added for auto probing from device tree. Example: adding device info in dtsi file adc: adc@12D10000 { compatible = "samsung,exynos-adc-v1"; - reg = <0x12D10000 0x100>, <0x10040718 0x4>; + reg = <0x12D10000 0x100>; interrupts = <0 106 0>; #io-channel-cells = <1>; io-channel-ranges; @@ -58,13 +61,14 @@ adc: adc@12D10000 { clock-names = "adc"; vdd-supply = <&buck5_reg>; + samsung,syscon-phandle = <&pmu_system_controller>; }; Example: adding device info in dtsi file for Exynos3250 with additional sclk adc: adc@126C0000 { compatible = "samsung,exynos3250-adc", "samsung,exynos-adc-v2; - reg = <0x126C0000 0x100>, <0x10020718 0x4>; + reg = <0x126C0000 0x100>; interrupts = <0 137 0>; #io-channel-cells = <1>; io-channel-ranges; @@ -73,6 +77,7 @@ adc: adc@126C0000 { clock-names = "adc", "sclk"; vdd-supply = <&buck5_reg>; + samsung,syscon-phandle = <&pmu_system_controller>; }; Example: Adding child nodes in dts file -- cgit v1.2.3-59-g8ed1b From db9bf4d6577f23b9a9ee4f70c07a51946ed111a7 Mon Sep 17 00:00:00 2001 From: Naveen Krishna Chatradhi Date: Tue, 16 Sep 2014 09:58:00 +0100 Subject: ARM: dts: exynos: Add sysreg phandle to ADC node Instead of using the ADC_PHY register base address, use sysreg phandle in ADC node to control ADC_PHY configuration register. This patch adds syscon node for Exynos3250, Exynos4x12, Exynos5250, and Exynos5420, Exynos5800. Signed-off-by: Naveen Krishna Chatradhi To: linux-samsung-soc@vger.kernel.org Acked-by: Kukjin Kim Signed-off-by: Jonathan Cameron --- arch/arm/boot/dts/exynos3250.dtsi | 3 ++- arch/arm/boot/dts/exynos4x12.dtsi | 3 ++- arch/arm/boot/dts/exynos5250.dtsi | 3 ++- arch/arm/boot/dts/exynos5420.dtsi | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi index 1d52de6370d5..b997a4c89eea 100644 --- a/arch/arm/boot/dts/exynos3250.dtsi +++ b/arch/arm/boot/dts/exynos3250.dtsi @@ -272,12 +272,13 @@ adc: adc@126C0000 { compatible = "samsung,exynos3250-adc", "samsung,exynos-adc-v2"; - reg = <0x126C0000 0x100>, <0x10020718 0x4>; + reg = <0x126C0000 0x100>; interrupts = <0 137 0>; clock-names = "adc", "sclk"; clocks = <&cmu CLK_TSADC>, <&cmu CLK_SCLK_TSADC>; #io-channel-cells = <1>; io-channel-ranges; + samsung,syscon-phandle = <&pmu_system_controller>; status = "disabled"; }; diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi index 861bb919f6d3..9ee77d3c4e03 100644 --- a/arch/arm/boot/dts/exynos4x12.dtsi +++ b/arch/arm/boot/dts/exynos4x12.dtsi @@ -108,13 +108,14 @@ adc: adc@126C0000 { compatible = "samsung,exynos-adc-v1"; - reg = <0x126C0000 0x100>, <0x10020718 0x4>; + reg = <0x126C0000 0x100>; interrupt-parent = <&combiner>; interrupts = <10 3>; clocks = <&clock CLK_TSADC>; clock-names = "adc"; #io-channel-cells = <1>; io-channel-ranges; + samsung,syscon-phandle = <&pmu_system_controller>; status = "disabled"; }; diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index 492e1eff37bd..8d575f24fe60 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -765,12 +765,13 @@ adc: adc@12D10000 { compatible = "samsung,exynos-adc-v1"; - reg = <0x12D10000 0x100>, <0x10040718 0x4>; + reg = <0x12D10000 0x100>; interrupts = <0 106 0>; clocks = <&clock CLK_ADC>; clock-names = "adc"; #io-channel-cells = <1>; io-channel-ranges; + samsung,syscon-phandle = <&pmu_system_controller>; status = "disabled"; }; diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi index bfe056d9148c..5fd587a842d2 100644 --- a/arch/arm/boot/dts/exynos5420.dtsi +++ b/arch/arm/boot/dts/exynos5420.dtsi @@ -541,12 +541,13 @@ adc: adc@12D10000 { compatible = "samsung,exynos-adc-v2"; - reg = <0x12D10000 0x100>, <0x10040720 0x4>; + reg = <0x12D10000 0x100>; interrupts = <0 106 0>; clocks = <&clock CLK_TSADC>; clock-names = "adc"; #io-channel-cells = <1>; io-channel-ranges; + samsung,syscon-phandle = <&pmu_system_controller>; status = "disabled"; }; -- cgit v1.2.3-59-g8ed1b From c1b501564c98a94b48f4ed936737403108dc7300 Mon Sep 17 00:00:00 2001 From: Abhilash Kesavan Date: Sat, 1 Nov 2014 09:30:43 +0530 Subject: iio: adc: exynos_adc: Add support for exynos7 The ADC on exynos7 is quite similar to ADCv2. The differences are as follows: - exynos7-adc has 8 input channels (as against 10 in ADCv2). - exynos7 does not include an ADC PHY control register. - Some ADC_CON2 register bits being used in ADCv2 are listed as reserved in exynos7-adc. This results in a different init_hw function for exynos7. Signed-off-by: Abhilash Kesavan Reviewed-by: Chanwoo Choi Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/arm/samsung/exynos-adc.txt | 2 ++ drivers/iio/adc/exynos_adc.c | 32 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt index c36821095393..f46ca9a316a2 100644 --- a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt +++ b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt @@ -16,6 +16,8 @@ Required properties: future controllers. Must be "samsung,exynos3250-adc" for controllers compatible with ADC of Exynos3250. + Must be "samsung,exynos7-adc" for + the ADC in Exynos7 and compatibles Must be "samsung,s3c2410-adc" for the ADC in s3c2410 and compatibles Must be "samsung,s3c2416-adc" for diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index fe0317745436..3a2dbb3b4926 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -390,6 +390,35 @@ static const struct exynos_adc_data exynos3250_adc_data = { .start_conv = exynos_adc_v2_start_conv, }; +static void exynos_adc_exynos7_init_hw(struct exynos_adc *info) +{ + u32 con1, con2; + + if (info->data->needs_adc_phy) + regmap_write(info->pmu_map, info->data->phy_offset, 1); + + con1 = ADC_V2_CON1_SOFT_RESET; + writel(con1, ADC_V2_CON1(info->regs)); + + con2 = readl(ADC_V2_CON2(info->regs)); + con2 &= ~ADC_V2_CON2_C_TIME(7); + con2 |= ADC_V2_CON2_C_TIME(0); + writel(con2, ADC_V2_CON2(info->regs)); + + /* Enable interrupts */ + writel(1, ADC_V2_INT_EN(info->regs)); +} + +static const struct exynos_adc_data exynos7_adc_data = { + .num_channels = MAX_ADC_V1_CHANNELS, + .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ + + .init_hw = exynos_adc_exynos7_init_hw, + .exit_hw = exynos_adc_v2_exit_hw, + .clear_irq = exynos_adc_v2_clear_irq, + .start_conv = exynos_adc_v2_start_conv, +}; + static const struct of_device_id exynos_adc_match[] = { { .compatible = "samsung,s3c2410-adc", @@ -415,6 +444,9 @@ static const struct of_device_id exynos_adc_match[] = { }, { .compatible = "samsung,exynos3250-adc", .data = &exynos3250_adc_data, + }, { + .compatible = "samsung,exynos7-adc", + .data = &exynos7_adc_data, }, {}, }; -- cgit v1.2.3-59-g8ed1b From 81ebe850a019ccb8bf0a429fb463d9bfc15ec298 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Fri, 31 Oct 2014 01:22:00 +0000 Subject: iio:pressure:bmp280: fix pressure calculation According to the datasheet and as defined in struct bmp280_comp_press, dig_p1 is of type u16, while dig_p2 to dig_p9 are of type s16. In bmp280_read_compensation_press(), values read from the device were treated as the wrong type. In bmp280_read_press() the fractional part of the measured pressure is calculated wrong. A better way is to use *val for the raw pressure and *val2 for the quotient and let the core do the proper conversion using IIO_VAL_FRACTIONAL. Signed-off-by: Hartmut Knaack Acked-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index ce29ff91bce7..75038dacfff1 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -176,15 +176,15 @@ static int bmp280_read_compensation_press(struct bmp280_data *data, return ret; } - comp->dig_p1 = (s16) le16_to_cpu(buf[0]); - comp->dig_p2 = (u16) le16_to_cpu(buf[1]); - comp->dig_p3 = (u16) le16_to_cpu(buf[2]); - comp->dig_p4 = (u16) le16_to_cpu(buf[3]); - comp->dig_p5 = (u16) le16_to_cpu(buf[4]); - comp->dig_p6 = (u16) le16_to_cpu(buf[5]); - comp->dig_p7 = (u16) le16_to_cpu(buf[6]); - comp->dig_p8 = (u16) le16_to_cpu(buf[7]); - comp->dig_p9 = (u16) le16_to_cpu(buf[8]); + comp->dig_p1 = (u16) le16_to_cpu(buf[0]); + comp->dig_p2 = (s16) le16_to_cpu(buf[1]); + comp->dig_p3 = (s16) le16_to_cpu(buf[2]); + comp->dig_p4 = (s16) le16_to_cpu(buf[3]); + comp->dig_p5 = (s16) le16_to_cpu(buf[4]); + comp->dig_p6 = (s16) le16_to_cpu(buf[5]); + comp->dig_p7 = (s16) le16_to_cpu(buf[6]); + comp->dig_p8 = (s16) le16_to_cpu(buf[7]); + comp->dig_p9 = (s16) le16_to_cpu(buf[8]); return 0; } @@ -309,10 +309,10 @@ static int bmp280_read_press(struct bmp280_data *data, adc_press = be32_to_cpu(tmp) >> 12; comp_press = bmp280_compensate_press(data, &comp, adc_press); - *val = comp_press / 256000; - *val2 = comp_press * 1000000 / 256000; + *val = comp_press; + *val2 = 256000; - return IIO_VAL_INT_PLUS_MICRO; + return IIO_VAL_FRACTIONAL; } static int bmp280_read_raw(struct iio_dev *indio_dev, -- cgit v1.2.3-59-g8ed1b From 4e4cd14e7cbead5ca20465f4a7ce973d42434a2f Mon Sep 17 00:00:00 2001 From: Darshana Padmadas Date: Wed, 5 Nov 2014 21:48:11 +0530 Subject: iio: Add ABI documentation for scaled voltage This patch adds an entry in ABI documentation for in_voltage-voltage_scale. It has at least one user driver, adis16220, in accel driver. Signed-off-by: Darshana Padmadas Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index ea7e7abbbdf4..117521dbf2b3 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -259,6 +259,7 @@ Description: What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale +What: /sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_scale What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale -- cgit v1.2.3-59-g8ed1b From 20188dd914f6694f13c5a5be051f8d6f1269ab49 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:11 -0500 Subject: staging: unisys: fix line spacing in charqueue.c Clean up the extraneous blank lines in charqueue.c. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/charqueue.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index 22241c7b4f7f..cdc9cc347782 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -25,8 +25,6 @@ #define IS_EMPTY(charqueue) (charqueue->head == charqueue->tail) - - struct CHARQUEUE_Tag { int alloc_size; int nslots; @@ -35,8 +33,6 @@ struct CHARQUEUE_Tag { unsigned char buf[0]; }; - - CHARQUEUE *visor_charqueue_create(ulong nslots) { int alloc_size = sizeof(CHARQUEUE) + nslots + 1; @@ -55,8 +51,6 @@ CHARQUEUE *visor_charqueue_create(ulong nslots) } EXPORT_SYMBOL_GPL(visor_charqueue_create); - - void visor_charqueue_enqueue(CHARQUEUE *charqueue, unsigned char c) { int alloc_slots = charqueue->nslots+1; /* 1 slot is always empty */ @@ -71,8 +65,6 @@ void visor_charqueue_enqueue(CHARQUEUE *charqueue, unsigned char c) } EXPORT_SYMBOL_GPL(visor_charqueue_enqueue); - - BOOL visor_charqueue_is_empty(CHARQUEUE *charqueue) { BOOL b; @@ -84,8 +76,6 @@ BOOL visor_charqueue_is_empty(CHARQUEUE *charqueue) } EXPORT_SYMBOL_GPL(visor_charqueue_is_empty); - - static int charqueue_dequeue_1(CHARQUEUE *charqueue) { int alloc_slots = charqueue->nslots + 1; /* 1 slot is always empty */ @@ -96,8 +86,6 @@ static int charqueue_dequeue_1(CHARQUEUE *charqueue) return charqueue->buf[charqueue->tail]; } - - int charqueue_dequeue(CHARQUEUE *charqueue) { int rc; @@ -108,8 +96,6 @@ int charqueue_dequeue(CHARQUEUE *charqueue) return rc; } - - int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n) { int rc, counter = 0, c; @@ -132,8 +118,6 @@ int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n) } EXPORT_SYMBOL_GPL(visor_charqueue_dequeue_n); - - void visor_charqueue_destroy(CHARQUEUE *charqueue) { if (charqueue == NULL) -- cgit v1.2.3-59-g8ed1b From 7a81a6e87e97c05524aa1d49d1f08dc7ca2260e5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:12 -0500 Subject: staging: unisys: refactor CHARQUEUE Remove the typedef and just use struct charqueue instead. Update all references. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/charqueue.c | 21 +++++++++++---------- drivers/staging/unisys/visorutil/charqueue.h | 17 +++++++++-------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index cdc9cc347782..7861e7326d87 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -25,7 +25,7 @@ #define IS_EMPTY(charqueue) (charqueue->head == charqueue->tail) -struct CHARQUEUE_Tag { +struct charqueue { int alloc_size; int nslots; spinlock_t lock; @@ -33,10 +33,10 @@ struct CHARQUEUE_Tag { unsigned char buf[0]; }; -CHARQUEUE *visor_charqueue_create(ulong nslots) +struct charqueue *visor_charqueue_create(ulong nslots) { - int alloc_size = sizeof(CHARQUEUE) + nslots + 1; - CHARQUEUE *cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY); + int alloc_size = sizeof(struct charqueue) + nslots + 1; + struct charqueue *cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY); if (cq == NULL) { ERRDRV("visor_charqueue_create allocation failed (alloc_size=%d)", @@ -51,7 +51,7 @@ CHARQUEUE *visor_charqueue_create(ulong nslots) } EXPORT_SYMBOL_GPL(visor_charqueue_create); -void visor_charqueue_enqueue(CHARQUEUE *charqueue, unsigned char c) +void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c) { int alloc_slots = charqueue->nslots+1; /* 1 slot is always empty */ @@ -65,7 +65,7 @@ void visor_charqueue_enqueue(CHARQUEUE *charqueue, unsigned char c) } EXPORT_SYMBOL_GPL(visor_charqueue_enqueue); -BOOL visor_charqueue_is_empty(CHARQUEUE *charqueue) +BOOL visor_charqueue_is_empty(struct charqueue *charqueue) { BOOL b; @@ -76,7 +76,7 @@ BOOL visor_charqueue_is_empty(CHARQUEUE *charqueue) } EXPORT_SYMBOL_GPL(visor_charqueue_is_empty); -static int charqueue_dequeue_1(CHARQUEUE *charqueue) +static int charqueue_dequeue_1(struct charqueue *charqueue) { int alloc_slots = charqueue->nslots + 1; /* 1 slot is always empty */ @@ -86,7 +86,7 @@ static int charqueue_dequeue_1(CHARQUEUE *charqueue) return charqueue->buf[charqueue->tail]; } -int charqueue_dequeue(CHARQUEUE *charqueue) +int charqueue_dequeue(struct charqueue *charqueue) { int rc; @@ -96,7 +96,8 @@ int charqueue_dequeue(CHARQUEUE *charqueue) return rc; } -int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n) +int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf, + int n) { int rc, counter = 0, c; @@ -118,7 +119,7 @@ int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n) } EXPORT_SYMBOL_GPL(visor_charqueue_dequeue_n); -void visor_charqueue_destroy(CHARQUEUE *charqueue) +void visor_charqueue_destroy(struct charqueue *charqueue) { if (charqueue == NULL) return; diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h index d6f16587a364..56c1f79a54b0 100644 --- a/drivers/staging/unisys/visorutil/charqueue.h +++ b/drivers/staging/unisys/visorutil/charqueue.h @@ -21,17 +21,18 @@ #include "uniklog.h" #include "timskmod.h" -/* CHARQUEUE is an opaque structure to users. +/* struct charqueue is an opaque structure to users. * Fields are declared only in the implementation .c files. */ -typedef struct CHARQUEUE_Tag CHARQUEUE; +struct charqueue; -CHARQUEUE *visor_charqueue_create(ulong nslots); -void visor_charqueue_enqueue(CHARQUEUE *charqueue, unsigned char c); -int charqueue_dequeue(CHARQUEUE *charqueue); -int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n); -BOOL visor_charqueue_is_empty(CHARQUEUE *charqueue); -void visor_charqueue_destroy(CHARQUEUE *charqueue); +struct charqueue *visor_charqueue_create(ulong nslots); +void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c); +int charqueue_dequeue(struct charqueue *charqueue); +int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf, + int n); +BOOL visor_charqueue_is_empty(struct charqueue *charqueue); +void visor_charqueue_destroy(struct charqueue *charqueue); #endif -- cgit v1.2.3-59-g8ed1b From 7146250754d9cde8480bc39e316c07ef2d63758e Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:13 -0500 Subject: staging: unisys: split double assignment in visor_charqueue_create() Split up the doubled assignment in visor_charqueue_create() into two separate assignments. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/charqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index 7861e7326d87..1ce7003c3a90 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -45,7 +45,8 @@ struct charqueue *visor_charqueue_create(ulong nslots) } cq->alloc_size = alloc_size; cq->nslots = nslots; - cq->head = cq->tail = 0; + cq->head = 0; + cq->tail = 0; spin_lock_init(&cq->lock); return cq; } -- cgit v1.2.3-59-g8ed1b From b63438c4e33149cf1dfd6f0ffb151e4dd0a65ce7 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:15 -0500 Subject: staging: unisys: remove typedef for MEMREGION Remove the typedef for this structure and just use struct memregion instead. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel.h | 2 +- .../unisys/visorchannel/visorchannel_funcs.c | 6 ++-- drivers/staging/unisys/visorchipset/parser.c | 2 +- drivers/staging/unisys/visorutil/memregion.h | 28 +++++++-------- .../staging/unisys/visorutil/memregion_direct.c | 41 +++++++++++----------- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index 9a4d7b6755d1..5061edff959a 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -66,7 +66,7 @@ char *visorchannel_id(VISORCHANNEL *channel, char *s); char *visorchannel_zoneid(VISORCHANNEL *channel, char *s); u64 visorchannel_get_clientpartition(VISORCHANNEL *channel); uuid_le visorchannel_get_uuid(VISORCHANNEL *channel); -MEMREGION *visorchannel_get_memregion(VISORCHANNEL *channel); +struct memregion *visorchannel_get_memregion(VISORCHANNEL *channel); char *visorchannel_uuid_id(uuid_le *guid, char *s); void visorchannel_debug(VISORCHANNEL *channel, int nQueues, struct seq_file *seq, u32 off); diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 5fbd5ada52e9..a50251a986a1 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -29,7 +29,7 @@ #define MYDRVNAME "visorchannel" struct VISORCHANNEL_Tag { - MEMREGION *memregion; /* from visor_memregion_create() */ + struct memregion *memregion; /* from visor_memregion_create() */ struct channel_header chan_hdr; uuid_le guid; ulong size; @@ -212,7 +212,7 @@ visorchannel_get_uuid(VISORCHANNEL *channel) } EXPORT_SYMBOL_GPL(visorchannel_get_uuid); -MEMREGION * +struct memregion * visorchannel_get_memregion(VISORCHANNEL *channel) { return channel->memregion; @@ -565,7 +565,7 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, { HOSTADDRESS addr = 0; ulong nbytes = 0, nbytes_region = 0; - MEMREGION *memregion = NULL; + struct memregion *memregion = NULL; struct channel_header hdr; struct channel_header *phdr = &hdr; int i = 0; diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index 6c2eac0346b6..9edbd3bbd186 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -47,7 +47,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, int allocbytes = sizeof(PARSER_CONTEXT) + bytes; PARSER_CONTEXT *rc = NULL; PARSER_CONTEXT *ctx = NULL; - MEMREGION *rgn = NULL; + struct memregion *rgn = NULL; struct spar_controlvm_parameters_header *phdr = NULL; if (tryAgain) diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index f4a65d2fcf02..0c3eebcf6d50 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -20,24 +20,24 @@ #include "timskmod.h" -/* MEMREGION is an opaque structure to users. +/* struct memregion is an opaque structure to users. * Fields are declared only in the implementation .c files. */ -typedef struct MEMREGION_Tag MEMREGION; +struct memregion; -MEMREGION *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes); -MEMREGION *visor_memregion_create_overlapped(MEMREGION *parent, - ulong offset, ulong nbytes); -int visor_memregion_resize(MEMREGION *memregion, ulong newsize); -int visor_memregion_read(MEMREGION *memregion, - ulong offset, void *dest, ulong nbytes); -int visor_memregion_write(MEMREGION *memregion, +struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes); +struct memregion *visor_memregion_create_overlapped(struct memregion *parent, + ulong offset, ulong nbytes); +int visor_memregion_resize(struct memregion *memregion, ulong newsize); +int visor_memregion_read(struct memregion *memregion, + ulong offset, void *dest, ulong nbytes); +int visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes); -void visor_memregion_destroy(MEMREGION *memregion); -HOSTADDRESS visor_memregion_get_physaddr(MEMREGION *memregion); -ulong visor_memregion_get_nbytes(MEMREGION *memregion); -void memregion_dump(MEMREGION *memregion, char *s, +void visor_memregion_destroy(struct memregion *memregion); +HOSTADDRESS visor_memregion_get_physaddr(struct memregion *memregion); +ulong visor_memregion_get_nbytes(struct memregion *memregion); +void memregion_dump(struct memregion *memregion, char *s, ulong off, ulong len, struct seq_file *seq); -void __iomem *visor_memregion_get_pointer(MEMREGION *memregion); +void __iomem *visor_memregion_get_pointer(struct memregion *memregion); #endif diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 65bc07b947db..73228d2da30f 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -26,7 +26,7 @@ #define MYDRVNAME "memregion" -struct MEMREGION_Tag { +struct memregion { HOSTADDRESS physaddr; ulong nbytes; void __iomem *mapped; @@ -34,14 +34,14 @@ struct MEMREGION_Tag { BOOL overlapped; }; -static BOOL mapit(MEMREGION *memregion); -static void unmapit(MEMREGION *memregion); +static BOOL mapit(struct memregion *memregion); +static void unmapit(struct memregion *memregion); -MEMREGION * +struct memregion * visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) { - MEMREGION *rc = NULL; - MEMREGION *memregion = kzalloc(sizeof(MEMREGION), + struct memregion *rc = NULL; + struct memregion *memregion = kzalloc(sizeof(struct memregion), GFP_KERNEL | __GFP_NORETRY); if (memregion == NULL) { ERRDRV("visor_memregion_create allocation failed"); @@ -66,10 +66,11 @@ Away: } EXPORT_SYMBOL_GPL(visor_memregion_create); -MEMREGION * -visor_memregion_create_overlapped(MEMREGION *parent, ulong offset, ulong nbytes) +struct memregion * +visor_memregion_create_overlapped(struct memregion *parent, ulong offset, + ulong nbytes) { - MEMREGION *memregion = NULL; + struct memregion *memregion = NULL; if (parent == NULL) { ERRDRV("%s parent is NULL", __func__); @@ -85,7 +86,7 @@ visor_memregion_create_overlapped(MEMREGION *parent, ulong offset, ulong nbytes) __func__, offset, nbytes); return NULL; } - memregion = kzalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY); + memregion = kzalloc(sizeof(struct memregion), GFP_KERNEL|__GFP_NORETRY); if (memregion == NULL) { ERRDRV("%s allocation failed", __func__); return NULL; @@ -102,7 +103,7 @@ EXPORT_SYMBOL_GPL(visor_memregion_create_overlapped); static BOOL -mapit(MEMREGION *memregion) +mapit(struct memregion *memregion) { ulong physaddr = (ulong) (memregion->physaddr); ulong nbytes = memregion->nbytes; @@ -122,7 +123,7 @@ mapit(MEMREGION *memregion) } static void -unmapit(MEMREGION *memregion) +unmapit(struct memregion *memregion) { if (memregion->mapped != NULL) { iounmap(memregion->mapped); @@ -136,28 +137,28 @@ unmapit(MEMREGION *memregion) } HOSTADDRESS -visor_memregion_get_physaddr(MEMREGION *memregion) +visor_memregion_get_physaddr(struct memregion *memregion) { return memregion->physaddr; } EXPORT_SYMBOL_GPL(visor_memregion_get_physaddr); ulong -visor_memregion_get_nbytes(MEMREGION *memregion) +visor_memregion_get_nbytes(struct memregion *memregion) { return memregion->nbytes; } EXPORT_SYMBOL_GPL(visor_memregion_get_nbytes); void __iomem * -visor_memregion_get_pointer(MEMREGION *memregion) +visor_memregion_get_pointer(struct memregion *memregion) { return memregion->mapped; } EXPORT_SYMBOL_GPL(visor_memregion_get_pointer); int -visor_memregion_resize(MEMREGION *memregion, ulong newsize) +visor_memregion_resize(struct memregion *memregion, ulong newsize) { if (newsize == memregion->nbytes) return 0; @@ -179,7 +180,7 @@ EXPORT_SYMBOL_GPL(visor_memregion_resize); static int memregion_readwrite(BOOL is_write, - MEMREGION *memregion, ulong offset, + struct memregion *memregion, ulong offset, void *local, ulong nbytes) { if (offset + nbytes > memregion->nbytes) { @@ -195,7 +196,7 @@ memregion_readwrite(BOOL is_write, } int -visor_memregion_read(MEMREGION *memregion, ulong offset, void *dest, +visor_memregion_read(struct memregion *memregion, ulong offset, void *dest, ulong nbytes) { return memregion_readwrite(FALSE, memregion, offset, dest, nbytes); @@ -203,7 +204,7 @@ visor_memregion_read(MEMREGION *memregion, ulong offset, void *dest, EXPORT_SYMBOL_GPL(visor_memregion_read); int -visor_memregion_write(MEMREGION *memregion, ulong offset, void *src, +visor_memregion_write(struct memregion *memregion, ulong offset, void *src, ulong nbytes) { return memregion_readwrite(TRUE, memregion, offset, src, nbytes); @@ -211,7 +212,7 @@ visor_memregion_write(MEMREGION *memregion, ulong offset, void *src, EXPORT_SYMBOL_GPL(visor_memregion_write); void -visor_memregion_destroy(MEMREGION *memregion) +visor_memregion_destroy(struct memregion *memregion) { if (memregion == NULL) return; -- cgit v1.2.3-59-g8ed1b From fef483891dc5aaca047fad7cf594651fbda9bef5 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:16 -0500 Subject: staging: unisys: refactor visor_memregion_create() Fix the sizeof() so it uses the variable name rather than the type, fix the argument alignment to the kzalloc(), and rename the goto label. Away => cleanup Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion_direct.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 73228d2da30f..3f1f313f0deb 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -41,8 +41,8 @@ struct memregion * visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) { struct memregion *rc = NULL; - struct memregion *memregion = kzalloc(sizeof(struct memregion), - GFP_KERNEL | __GFP_NORETRY); + struct memregion *memregion = kzalloc(sizeof(*memregion), + GFP_KERNEL | __GFP_NORETRY); if (memregion == NULL) { ERRDRV("visor_memregion_create allocation failed"); return NULL; @@ -52,10 +52,10 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) memregion->overlapped = FALSE; if (!mapit(memregion)) { rc = NULL; - goto Away; + goto cleanup; } rc = memregion; -Away: +cleanup: if (rc == NULL) { if (memregion != NULL) { visor_memregion_destroy(memregion); -- cgit v1.2.3-59-g8ed1b From 49695a534a31cd0df5f215d1250dba5bdb9ad511 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:17 -0500 Subject: staging: unisys: remove unnecessary spaces in casts in memregion_direct.c Get rid of all extra spaces between casts and their targets in this file. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion_direct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 3f1f313f0deb..f4182d4da273 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -94,7 +94,7 @@ visor_memregion_create_overlapped(struct memregion *parent, ulong offset, memregion->physaddr = parent->physaddr + offset; memregion->nbytes = nbytes; - memregion->mapped = ((u8 __iomem *) (parent->mapped)) + offset; + memregion->mapped = ((u8 __iomem *)(parent->mapped)) + offset; memregion->requested = FALSE; memregion->overlapped = TRUE; return memregion; @@ -105,7 +105,7 @@ EXPORT_SYMBOL_GPL(visor_memregion_create_overlapped); static BOOL mapit(struct memregion *memregion) { - ulong physaddr = (ulong) (memregion->physaddr); + ulong physaddr = (ulong)(memregion->physaddr); ulong nbytes = memregion->nbytes; memregion->requested = FALSE; @@ -130,7 +130,7 @@ unmapit(struct memregion *memregion) memregion->mapped = NULL; } if (memregion->requested) { - release_mem_region((ulong) (memregion->physaddr), + release_mem_region((ulong)(memregion->physaddr), memregion->nbytes); memregion->requested = FALSE; } -- cgit v1.2.3-59-g8ed1b From ab2cded1bc22943e552151af7aa4d693a633ce6b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:18 -0500 Subject: staging: unisys: remove extra blank lines in memregion_direct.c Get rid of the extra blank lines in this file. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion_direct.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index f4182d4da273..b5cbf8341f72 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -101,7 +101,6 @@ visor_memregion_create_overlapped(struct memregion *parent, ulong offset, } EXPORT_SYMBOL_GPL(visor_memregion_create_overlapped); - static BOOL mapit(struct memregion *memregion) { @@ -177,7 +176,6 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize) } EXPORT_SYMBOL_GPL(visor_memregion_resize); - static int memregion_readwrite(BOOL is_write, struct memregion *memregion, ulong offset, -- cgit v1.2.3-59-g8ed1b From 92d00cf0f52198dd364f88eda254cb140e458fe6 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:19 -0500 Subject: staging: unisys: fix line over 80 characters in mapit() The error output in mapit() in memregion_direct.c has variables past the 80 character limit. Move them to the next line, but the string constant will still go past the limit, and that's okay. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion_direct.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index b5cbf8341f72..37770aa5229d 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -109,7 +109,8 @@ mapit(struct memregion *memregion) memregion->requested = FALSE; if (!request_mem_region(physaddr, nbytes, MYDRVNAME)) - ERRDRV("cannot reserve channel memory @0x%lx for 0x%lx-- no big deal", physaddr, nbytes); + ERRDRV("cannot reserve channel memory @0x%lx for 0x%lx-- no big deal", + physaddr, nbytes); else memregion->requested = TRUE; memregion->mapped = ioremap_cache(physaddr, nbytes); -- cgit v1.2.3-59-g8ed1b From 6db05d3f9abbdb0bdf9e07bf458bd7b2bea77092 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:20 -0500 Subject: staging: unisys: fix sizeof() in visor_memregion_create_overlapped() Use the variable name rather than the type in the sizeof() call in this function. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion_direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 37770aa5229d..26faad470705 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -86,7 +86,7 @@ visor_memregion_create_overlapped(struct memregion *parent, ulong offset, __func__, offset, nbytes); return NULL; } - memregion = kzalloc(sizeof(struct memregion), GFP_KERNEL|__GFP_NORETRY); + memregion = kzalloc(sizeof(*memregion), GFP_KERNEL|__GFP_NORETRY); if (memregion == NULL) { ERRDRV("%s allocation failed", __func__); return NULL; -- cgit v1.2.3-59-g8ed1b From 622c9d97c13952a40f68d5ddab475e84ce165b4f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:21 -0500 Subject: staging: unisys: fix spacing in periodic_work.c Get rid of all extraneous blank lines in periodic_work.c. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/periodic_work.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index 3dd1c04d0e14..73c31f78df9e 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -25,8 +25,6 @@ #define MYDRVNAME "periodic_work" - - struct periodic_work { rwlock_t lock; struct delayed_work work; @@ -39,8 +37,6 @@ struct periodic_work { const char *devnam; }; - - static void periodic_work_func(struct work_struct *work) { struct periodic_work *pw; @@ -49,8 +45,6 @@ static void periodic_work_func(struct work_struct *work) (*pw->workfunc)(pw->workfuncarg); } - - struct periodic_work *visor_periodic_work_create(ulong jiffy_interval, struct workqueue_struct *workqueue, void (*workfunc)(void *), @@ -73,16 +67,12 @@ struct periodic_work *visor_periodic_work_create(ulong jiffy_interval, } EXPORT_SYMBOL_GPL(visor_periodic_work_create); - - void visor_periodic_work_destroy(struct periodic_work *pw) { kfree(pw); } EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); - - /** Call this from your periodic work worker function to schedule the next * call. * If this function returns FALSE, there was a failure and the @@ -112,8 +102,6 @@ unlock: } EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); - - /** This function returns TRUE iff new periodic work was actually started. * If this function returns FALSE, then no work was started * (either because it was already started, or because of a failure). @@ -145,13 +133,9 @@ BOOL visor_periodic_work_start(struct periodic_work *pw) unlock: write_unlock(&pw->lock); return rc; - } EXPORT_SYMBOL_GPL(visor_periodic_work_start); - - - /** This function returns TRUE iff your call actually stopped the periodic * work. * -- cgit v1.2.3-59-g8ed1b From f0b5c6d3531725edbbdde3e2c2221f1a27f00bd7 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:22 -0500 Subject: staging: unisys: fix bracketing in visor_periodic_work_stop() The last if statement in this function is missing brackets on the else clause. Add them. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/periodic_work.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index 73c31f78df9e..0908bf929401 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -207,8 +207,9 @@ BOOL visor_periodic_work_stop(struct periodic_work *pw) */ SLEEPJIFFIES(10); write_lock(&pw->lock); - } else + } else { pw->want_to_stop = FALSE; + } } write_unlock(&pw->lock); return stopped_something; -- cgit v1.2.3-59-g8ed1b From 5d2c3960b223290944d2ab90c8c8837358c3b13d Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:23 -0500 Subject: staging: unisys: fix spacing in visorkmodutils.c Remove all the extraneous blank lines from visorkmodutils.c. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/visorkmodutils.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index 64b135d83c0d..69ed4b1fce6b 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -49,12 +49,8 @@ visorutil_spar_detect(void) (edx == UNISYS_SPAR_ID_EDX); } else return 0; - } - - - static __init int visorutil_mod_init(void) { -- cgit v1.2.3-59-g8ed1b From 670db786db99abb1b4d250c8a9609b59371ddc86 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:24 -0500 Subject: staging: unisys: refactor visorutil_spar_detect() Fix the declaration line so it is just one single line, and add the missing brackets on the else clause in the if statement. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/visorkmodutils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index 69ed4b1fce6b..3ab990ba2054 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -36,8 +36,7 @@ int unisys_spar_platform; EXPORT_SYMBOL_GPL(unisys_spar_platform); -static __init uint32_t -visorutil_spar_detect(void) +static __init uint32_t visorutil_spar_detect(void) { unsigned int eax, ebx, ecx, edx; @@ -47,8 +46,9 @@ visorutil_spar_detect(void) return (ebx == UNISYS_SPAR_ID_EBX) && (ecx == UNISYS_SPAR_ID_ECX) && (edx == UNISYS_SPAR_ID_EDX); - } else + } else { return 0; + } } static __init int -- cgit v1.2.3-59-g8ed1b From 2291b26874e41a68b036cd40d46501dc2ca9df02 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 4 Nov 2014 11:25:25 -0500 Subject: staging: unisys: refactor visorutil_mod_init() Fix the function name declaration so it is just one line, and add the missing brackets to the else clause in the if statement. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/visorkmodutils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index 3ab990ba2054..556e2642d2d9 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -51,14 +51,14 @@ static __init uint32_t visorutil_spar_detect(void) } } -static __init int -visorutil_mod_init(void) +static __init int visorutil_mod_init(void) { if (visorutil_spar_detect()) { unisys_spar_platform = TRUE; return 0; - } else + } else { return -ENODEV; + } } static __exit void -- cgit v1.2.3-59-g8ed1b From 8f846b51632f54d9b6e842ee7fbbf23e2b10ace0 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Tue, 4 Nov 2014 16:13:17 -0500 Subject: staging: unisys: virtpci: Remove GET_BUS_DEV macro The GET_BUS_DEV macro contained flow control statements that are undesirable. This patch removes the macro and places the code in each function. Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virtpci/virtpci.c | 48 ++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index e212c7afb468..39b828dce503 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -303,17 +303,6 @@ static int add_vbus(struct add_vbus_guestpart *addparams) sizeof(struct vhba_config_max)); \ } -/* find bus device with the busid that matches - match_busid matches bus_id */ -#define GET_BUS_DEV(busno) { \ - sprintf(busid, "vbus%d", busno); \ - vbus = bus_find_device(&virtpci_bus_type, NULL, \ - (void *)busid, match_busid); \ - if (!vbus) { \ - LOGERR("**** FAILED to find vbus %s\n", busid); \ - return 0; \ - } \ -} - /* adds a vhba * returns 0 failure, 1 success, */ @@ -334,7 +323,14 @@ static int add_vhba(struct add_virt_guestpart *addparams) GET_SCSIADAPINFO_FROM_CHANPTR(addparams->chanptr); - GET_BUS_DEV(addparams->bus_no); + /* find bus device with the busid that matches match_busid */ + sprintf(busid, "vbus%d", addparams->bus_no); + vbus = bus_find_device(&virtpci_bus_type, NULL, + (void *)busid, match_busid); + if (!vbus) { + LOGERR("**** FAILED to find vbus %s\n", busid); + return 0; + } LOGINF("Adding vhba wwnn:%x:%x config:%d-%d-%d-%d chanptr:%p\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2, @@ -390,7 +386,14 @@ add_vnic(struct add_virt_guestpart *addparams) GET_NETADAPINFO_FROM_CHANPTR(addparams->chanptr); - GET_BUS_DEV(addparams->bus_no); + /* find bus device with the busid that matches match_busid */ + sprintf(busid, "vbus%d", addparams->bus_no); + vbus = bus_find_device(&virtpci_bus_type, NULL, + (void *)busid, match_busid); + if (!vbus) { + LOGERR("**** FAILED to find vbus %s\n", busid); + return 0; + } LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], @@ -417,7 +420,15 @@ delete_vbus(struct del_vbus_guestpart *delparams) struct device *vbus; unsigned char busid[BUS_ID_SIZE]; - GET_BUS_DEV(delparams->bus_no); + /* find bus device with the busid that matches match_busid */ + sprintf(busid, "vbus%d", delparams->bus_no); + vbus = bus_find_device(&virtpci_bus_type, NULL, + (void *)busid, match_busid); + if (!vbus) { + LOGERR("**** FAILED to find vbus %s\n", busid); + return 0; + } + /* ensure that bus has no devices? -- TBD */ LOGINF("Deleting %s\n", BUS_ID(vbus)); if (delete_vbus_device(vbus, NULL)) @@ -621,7 +632,14 @@ static int delete_all_virt(enum virtpci_dev_type devtype, unsigned char busid[BUS_ID_SIZE]; struct device *vbus; - GET_BUS_DEV(delparams->bus_no); + /* find bus device with the busid that matches match_busid */ + sprintf(busid, "vbus%d", delparams->bus_no); + vbus = bus_find_device(&virtpci_bus_type, NULL, + (void *)busid, match_busid); + if (!vbus) { + LOGERR("**** FAILED to find vbus %s\n", busid); + return 0; + } if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) { LOGERR("**** FAILED to delete all devices; devtype:%d not vhba:%d or vnic:%d\n", -- cgit v1.2.3-59-g8ed1b From ca68b110a2e0cb005f815a4d8728d1914f27b63b Mon Sep 17 00:00:00 2001 From: Ken Depro Date: Wed, 5 Nov 2014 10:57:57 -0500 Subject: staging: unisys: Remove extra blank lines from virthba files This patch removes extra blank lines from the virthba header and source files. This is the first of a set of patches that will clean up the virthba source file. The only checkpatch issue in the header file was the blank line warnings. Signed-off-by: Ken Depro Signed-off-by: Ben Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virthba/virthba.c | 2 -- drivers/staging/unisys/virthba/virthba.h | 4 ---- 2 files changed, 6 deletions(-) diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 04d3c213205f..d7a629b5f111 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -101,7 +101,6 @@ static DEF_SCSI_QCMD(virthba_queue_command) #define virthba_queue_command virthba_queue_command_lck #endif - static int virthba_slave_alloc(struct scsi_device *scsidev); static int virthba_slave_configure(struct scsi_device *scsidev); static void virthba_slave_destroy(struct scsi_device *scsidev); @@ -1323,7 +1322,6 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc, } } - /* main function for the thread that waits for scsi commands to arrive * in a specified queue */ diff --git a/drivers/staging/unisys/virthba/virthba.h b/drivers/staging/unisys/virthba/virthba.h index d4b809b0c7bc..59901668d4f4 100644 --- a/drivers/staging/unisys/virthba/virthba.h +++ b/drivers/staging/unisys/virthba/virthba.h @@ -19,13 +19,9 @@ * Unisys Virtual HBA driver header */ - - #ifndef __VIRTHBA_H__ #define __VIRTHBA_H__ - #define VIRTHBA_VERSION "01.00" - #endif /* __VIRTHBA_H__ */ -- cgit v1.2.3-59-g8ed1b From 1d87ba3bcc6a31b060e1411fa037a4d2b16fc444 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Wed, 5 Nov 2014 12:47:50 -0500 Subject: staging: unisys: remove unused functions from uislib.c Delete uislib_client_add_vnic() and uislib_client_delete_vnic(), since these are never used. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 76 ---------------------------------- 1 file changed, 76 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 354b6827bac4..7c87452a9f14 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1083,82 +1083,6 @@ uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no) } EXPORT_SYMBOL_GPL(uislib_client_inject_del_vnic); -static int -uislib_client_add_vnic(u32 busNo) -{ - BOOL busCreated = FALSE; - int devNo = 0; /* Default to 0, since only one device - * will be created for this bus... */ - struct controlvm_message msg; - - init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); - msg.hdr.flags.test_message = 1; - msg.cmd.create_bus.bus_no = busNo; - msg.cmd.create_bus.dev_count = 4; - msg.cmd.create_bus.channel_addr = 0; - msg.cmd.create_bus.channel_bytes = 0; - if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("client create_bus failed"); - return 0; - } - busCreated = TRUE; - - init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0); - msg.hdr.flags.test_message = 1; - msg.cmd.create_device.bus_no = busNo; - msg.cmd.create_device.dev_no = devNo; - msg.cmd.create_device.dev_inst_uuid = NULL_UUID_LE; - memset(&msg.cmd.create_device.intr, 0, sizeof(struct irq_info)); - msg.cmd.create_device.channel_addr = PhysicalDataChan; - msg.cmd.create_device.channel_bytes = MIN_IO_CHANNEL_SIZE; - msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid; - if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("client create_device failed"); - goto AwayCleanup; - } - - return 1; - -AwayCleanup: - if (busCreated) { - init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.hdr.flags.test_message = 1; - msg.cmd.destroy_bus.bus_no = busNo; - if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) - LOGERR("client destroy_bus failed.\n"); - } - - return 0; -} /* end uislib_client_add_vnic */ -EXPORT_SYMBOL_GPL(uislib_client_add_vnic); - -static int -uislib_client_delete_vnic(u32 busNo) -{ - int devNo = 0; /* Default to 0, since only one device - * will be created for this bus... */ - struct controlvm_message msg; - - init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0); - msg.hdr.flags.test_message = 1; - msg.cmd.destroy_device.bus_no = busNo; - msg.cmd.destroy_device.dev_no = devNo; - if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - /* Don't error exit - try to see if bus can be destroyed... */ - LOGERR("client destroy_device failed.\n"); - } - - init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0); - msg.hdr.flags.test_message = 1; - msg.cmd.destroy_bus.bus_no = busNo; - if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) - LOGERR("client destroy_bus failed.\n"); - - return 1; -} -EXPORT_SYMBOL_GPL(uislib_client_delete_vnic); -/* end client_delete_vnic */ - void * uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln) { -- cgit v1.2.3-59-g8ed1b From 5116d9fcf182536df69e2958b39a590e27ccedd2 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:49 +0000 Subject: staging: vt6655: mac remove dead variable TxRate_iwconfig Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 1 - drivers/staging/vt6655/mac.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 955dbfebe170..122a6a3f6003 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -71,7 +71,6 @@ #include "tmacro.h" #include "mac.h" -unsigned short TxRate_iwconfig;//2008-5-8 by chester /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 5391277a1a19..23162a90e9b8 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -970,7 +970,6 @@ do { \ /*--------------------- Export Functions --------------------------*/ -extern unsigned short TxRate_iwconfig;//2008-5-8 by chester void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs); bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits); -- cgit v1.2.3-59-g8ed1b From 6b5db44ecd4e1e85e18f65cba99fcf53dac85314 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:50 +0000 Subject: staging: vt6655: mac.c/h remove member type comments Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 10 ---------- drivers/staging/vt6655/mac.h | 6 ------ 2 files changed, 16 deletions(-) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 122a6a3f6003..2ea74a185789 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -71,16 +71,6 @@ #include "tmacro.h" #include "mac.h" -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - /* * Description: * Read All MAC Registers to buffer diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 23162a90e9b8..3f37014f7ed1 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -964,12 +964,6 @@ do { \ #define MACvSetRFLE_LatchBase(dwIoBase) \ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT) -/*--------------------- Export Classes ----------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs); bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits); -- cgit v1.2.3-59-g8ed1b From 87299d4c06f09ceb1fe866fe44c0c51d0d3f069e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:51 +0000 Subject: staging: vt6655: mac.c and mac.h remove dead functions. MACvReadAllRegs MACbyReadMultiAddr MACvWriteMultiAddr MACvSetMultiAddrByHash MACvResetMultiAddrByHash MACvSetRxThreshold MACvGetRxThreshold MACvSetTxThreshold MACvGetTxThreshold MACvSetDmaLength MACvGetDmaLength MACvGetLongRetryLimit MACbIsInLoopbackMode MACbCompareContext MACvOneShotTimer0MicroSec MACbTxDMAOff MACvClearBusSusInd MACvEnableBusSusEn MACbFlushSYNCFifo MACvSetDefaultKeyEntry MACvEnableDefaultKey MACvDisableDefaultKey MACvSetDefaultTKIPKeyEntry MACvSetDefaultKeyCtl Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 702 ------------------------------------------- drivers/staging/vt6655/mac.h | 32 -- 2 files changed, 734 deletions(-) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 2ea74a185789..af966065a243 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -26,30 +26,16 @@ * Date: May 21, 1996 * * Functions: - * MACvReadAllRegs - Read All MAC Registers to buffer * MACbIsRegBitsOn - Test if All test Bits On * MACbIsRegBitsOff - Test if All test Bits Off * MACbIsIntDisable - Test if MAC interrupt disable - * MACbyReadMultiAddr - Read Multicast Address Mask Pattern - * MACvWriteMultiAddr - Write Multicast Address Mask Pattern - * MACvSetMultiAddrByHash - Set Multicast Address Mask by Hash value - * MACvResetMultiAddrByHash - Clear Multicast Address Mask by Hash value - * MACvSetRxThreshold - Set Rx Threshold value - * MACvGetRxThreshold - Get Rx Threshold value - * MACvSetTxThreshold - Set Tx Threshold value - * MACvGetTxThreshold - Get Tx Threshold value - * MACvSetDmaLength - Set Dma Length value - * MACvGetDmaLength - Get Dma Length value * MACvSetShortRetryLimit - Set 802.11 Short Retry limit * MACvGetShortRetryLimit - Get 802.11 Short Retry limit * MACvSetLongRetryLimit - Set 802.11 Long Retry limit - * MACvGetLongRetryLimit - Get 802.11 Long Retry limit * MACvSetLoopbackMode - Set MAC Loopback Mode - * MACbIsInLoopbackMode - Test if MAC in Loopback mode * MACvSetPacketFilter - Set MAC Address Filter * MACvSaveContext - Save Context of MAC Registers * MACvRestoreContext - Restore Context of MAC Registers - * MACbCompareContext - Compare if values of MAC Registers same as Context * MACbSoftwareReset - Software Reset MAC * MACbSafeRxOff - Turn Off MAC Rx * MACbSafeTxOff - Turn Off MAC Tx @@ -71,40 +57,6 @@ #include "tmacro.h" #include "mac.h" -/* - * Description: - * Read All MAC Registers to buffer - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * Out: - * pbyMacRegs - buffer to read - * - * Return Value: none - * - */ -void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs) -{ - int ii; - - // read page0 register - for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++) { - VNSvInPortB(dwIoBase + ii, pbyMacRegs); - pbyMacRegs++; - } - - MACvSelectPage1(dwIoBase); - - // read page1 register - for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) { - VNSvInPortB(dwIoBase + ii, pbyMacRegs); - pbyMacRegs++; - } - - MACvSelectPage0(dwIoBase); -} - /* * Description: * Test if all test bits on @@ -175,252 +127,6 @@ bool MACbIsIntDisable(void __iomem *dwIoBase) return true; } -/* - * Description: - * Read MAC Multicast Address Mask - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * uByteidx - Index of Mask - * Out: - * none - * - * Return Value: Mask Value read - * - */ -unsigned char MACbyReadMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx) -{ - unsigned char byData; - - MACvSelectPage1(dwIoBase); - VNSvInPortB(dwIoBase + MAC_REG_MAR0 + uByteIdx, &byData); - MACvSelectPage0(dwIoBase); - return byData; -} - -/* - * Description: - * Write MAC Multicast Address Mask - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * uByteidx - Index of Mask - * byData - Mask Value to write - * Out: - * none - * - * Return Value: none - * - */ -void MACvWriteMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx, unsigned char byData) -{ - MACvSelectPage1(dwIoBase); - VNSvOutPortB(dwIoBase + MAC_REG_MAR0 + uByteIdx, byData); - MACvSelectPage0(dwIoBase); -} - -/* - * Description: - * Set this hash index into multicast address register bit - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * byHashIdx - Hash index to set - * Out: - * none - * - * Return Value: none - * - */ -void MACvSetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx) -{ - unsigned int uByteIdx; - unsigned char byBitMask; - unsigned char byOrgValue; - - // calculate byte position - uByteIdx = byHashIdx / 8; - ASSERT(uByteIdx < 8); - // calculate bit position - byBitMask = 1; - byBitMask <<= (byHashIdx % 8); - // turn on the bit - byOrgValue = MACbyReadMultiAddr(dwIoBase, uByteIdx); - MACvWriteMultiAddr(dwIoBase, uByteIdx, (unsigned char)(byOrgValue | byBitMask)); -} - -/* - * Description: - * Reset this hash index into multicast address register bit - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * byHashIdx - Hash index to clear - * Out: - * none - * - * Return Value: none - * - */ -void MACvResetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx) -{ - unsigned int uByteIdx; - unsigned char byBitMask; - unsigned char byOrgValue; - - // calculate byte position - uByteIdx = byHashIdx / 8; - ASSERT(uByteIdx < 8); - // calculate bit position - byBitMask = 1; - byBitMask <<= (byHashIdx % 8); - // turn off the bit - byOrgValue = MACbyReadMultiAddr(dwIoBase, uByteIdx); - MACvWriteMultiAddr(dwIoBase, uByteIdx, (unsigned char)(byOrgValue & (~byBitMask))); -} - -/* - * Description: - * Set Rx Threshold - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * byThreshold - Threshold Value - * Out: - * none - * - * Return Value: none - * - */ -void MACvSetRxThreshold(void __iomem *dwIoBase, unsigned char byThreshold) -{ - unsigned char byOrgValue; - - ASSERT(byThreshold < 4); - - // set FCR0 - VNSvInPortB(dwIoBase + MAC_REG_FCR0, &byOrgValue); - byOrgValue = (byOrgValue & 0xCF) | (byThreshold << 4); - VNSvOutPortB(dwIoBase + MAC_REG_FCR0, byOrgValue); -} - -/* - * Description: - * Get Rx Threshold - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * Out: - * pbyThreshold- Threshold Value Get - * - * Return Value: none - * - */ -void MACvGetRxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold) -{ - // get FCR0 - VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold); - *pbyThreshold = (*pbyThreshold >> 4) & 0x03; -} - -/* - * Description: - * Set Tx Threshold - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * byThreshold - Threshold Value - * Out: - * none - * - * Return Value: none - * - */ -void MACvSetTxThreshold(void __iomem *dwIoBase, unsigned char byThreshold) -{ - unsigned char byOrgValue; - - ASSERT(byThreshold < 4); - - // set FCR0 - VNSvInPortB(dwIoBase + MAC_REG_FCR0, &byOrgValue); - byOrgValue = (byOrgValue & 0xF3) | (byThreshold << 2); - VNSvOutPortB(dwIoBase + MAC_REG_FCR0, byOrgValue); -} - -/* - * Description: - * Get Tx Threshold - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * Out: - * pbyThreshold- Threshold Value Get - * - * Return Value: none - * - */ -void MACvGetTxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold) -{ - // get FCR0 - VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold); - *pbyThreshold = (*pbyThreshold >> 2) & 0x03; -} - -/* - * Description: - * Set Dma Length - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * byDmaLength - Dma Length Value - * Out: - * none - * - * Return Value: none - * - */ -void MACvSetDmaLength(void __iomem *dwIoBase, unsigned char byDmaLength) -{ - unsigned char byOrgValue; - - ASSERT(byDmaLength < 4); - - // set FCR0 - VNSvInPortB(dwIoBase + MAC_REG_FCR0, &byOrgValue); - byOrgValue = (byOrgValue & 0xFC) | byDmaLength; - VNSvOutPortB(dwIoBase + MAC_REG_FCR0, byOrgValue); -} - -/* - * Description: - * Get Dma Length - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * Out: - * pbyDmaLength- Dma Length Value Get - * - * Return Value: none - * - */ -void MACvGetDmaLength(void __iomem *dwIoBase, unsigned char *pbyDmaLength) -{ - // get FCR0 - VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyDmaLength); - *pbyDmaLength &= 0x03; -} - /* * Description: * Set 802.11 Short Retry Limit @@ -480,25 +186,6 @@ void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit) VNSvOutPortB(dwIoBase + MAC_REG_LRT, byRetryLimit); } -/* - * Description: - * Get 802.11 Long Retry Limit - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * Out: - * pbyRetryLimit - Retry Limit Get - * - * Return Value: none - * - */ -void MACvGetLongRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit) -{ - // get LRT - VNSvInPortB(dwIoBase + MAC_REG_LRT, pbyRetryLimit); -} - /* * Description: * Set MAC Loopback mode @@ -526,29 +213,6 @@ void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode) VNSvOutPortB(dwIoBase + MAC_REG_TEST, byOrgValue); } -/* - * Description: - * Test if MAC in Loopback mode - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * Out: - * none - * - * Return Value: true if in Loopback mode; otherwise false - * - */ -bool MACbIsInLoopbackMode(void __iomem *dwIoBase) -{ - unsigned char byOrgValue; - - VNSvInPortB(dwIoBase + MAC_REG_TEST, &byOrgValue); - if (byOrgValue & (TEST_LBINT | TEST_LBEXT)) - return true; - return false; -} - /* * Description: * Set MAC Address filter @@ -688,47 +352,6 @@ void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)); } -/* - * Description: - * Compare if MAC registers same as context buffer - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * pbyCxtBuf - Context buffer - * Out: - * none - * - * Return Value: true if all values are the same; otherwise false - * - */ -bool MACbCompareContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) -{ - unsigned long dwData; - - // compare MAC context to determine if this is a power lost init, - // return true for power remaining init, return false for power lost init - - // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR - VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)) - return false; - - VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)) - return false; - - VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)) - return false; - - VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)) - return false; - - return true; -} - /* * Description: * Software Reset MAC @@ -1208,27 +831,6 @@ void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay) VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); } -/* - * Description: - * Micro Second One shot timer via MAC - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * uDelay - Delay time - * Out: - * none - * - * Return Value: none - * - */ -void MACvOneShotTimer0MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime) -{ - VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); - VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelayTime); - VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, (TMCTL_TMD | TMCTL_TE)); -} - /* * Description: * Micro Second One shot timer via MAC @@ -1259,102 +861,6 @@ void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned lo VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); } -bool MACbTxDMAOff(void __iomem *dwIoBase, unsigned int idx) -{ - unsigned char byData; - unsigned int ww = 0; - - if (idx == TYPE_TXDMA0) { - VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0+2, DMACTL_RUN); - for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { - VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byData); - if (!(byData & DMACTL_RUN)) - break; - } - } else if (idx == TYPE_AC0DMA) { - VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL+2, DMACTL_RUN); - for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { - VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byData); - if (!(byData & DMACTL_RUN)) - break; - } - } - if (ww == W_MAX_TIMEOUT) { - DBG_PORT80(0x29); - pr_debug(" DBG_PORT80(0x29)\n"); - return false; - } - return true; -} - -void MACvClearBusSusInd(void __iomem *dwIoBase) -{ - unsigned long dwOrgValue; - unsigned int ww; - // check if BcnSusInd enabled - VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); - if (!(dwOrgValue & EnCFG_BcnSusInd)) - return; - //Set BcnSusClr - dwOrgValue = dwOrgValue | EnCFG_BcnSusClr; - VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); - for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { - VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); - if (!(dwOrgValue & EnCFG_BcnSusInd)) - break; - } - if (ww == W_MAX_TIMEOUT) { - DBG_PORT80(0x33); - pr_debug(" DBG_PORT80(0x33)\n"); - } -} - -void MACvEnableBusSusEn(void __iomem *dwIoBase) -{ - unsigned char byOrgValue; - unsigned long dwOrgValue; - unsigned int ww; - // check if BcnSusInd enabled - VNSvInPortB(dwIoBase + MAC_REG_CFG , &byOrgValue); - - //Set BcnSusEn - byOrgValue = byOrgValue | CFG_BCNSUSEN; - VNSvOutPortB(dwIoBase + MAC_REG_ENCFG, byOrgValue); - for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { - VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); - if (dwOrgValue & EnCFG_BcnSusInd) - break; - } - if (ww == W_MAX_TIMEOUT) { - DBG_PORT80(0x34); - pr_debug(" DBG_PORT80(0x34)\n"); - } -} - -bool MACbFlushSYNCFifo(void __iomem *dwIoBase) -{ - unsigned char byOrgValue; - unsigned int ww; - // Read MACCR - VNSvInPortB(dwIoBase + MAC_REG_MACCR , &byOrgValue); - - // Set SYNCFLUSH - byOrgValue = byOrgValue | MACCR_SYNCFLUSH; - VNSvOutPortB(dwIoBase + MAC_REG_MACCR, byOrgValue); - - // Check if SyncFlushOK - for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { - VNSvInPortB(dwIoBase + MAC_REG_MACCR , &byOrgValue); - if (byOrgValue & MACCR_SYNCFLUSHOK) - break; - } - if (ww == W_MAX_TIMEOUT) { - DBG_PORT80(0x35); - pr_debug(" DBG_PORT80(0x33)\n"); - } - return true; -} - bool MACbPSWakeup(void __iomem *dwIoBase) { unsigned char byOrgValue; @@ -1472,211 +978,3 @@ void MACvDisableKeyEntry(void __iomem *dwIoBase, unsigned int uEntryIdx) VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, 0); VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); } - -/* - * Description: - * Set the default Key (KeyEntry[10]) by MISCFIFO - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * - * Out: - * none - * - * Return Value: none - * - */ - -void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID) -{ - unsigned short wOffset; - unsigned long dwData; - int ii; - - if (byLocalID <= 1) - return; - - pr_debug("MACvSetDefaultKeyEntry\n"); - wOffset = MISCFIFO_KEYETRY0; - wOffset += (10 * MISCFIFO_KEYENTRYSIZE); - - wOffset++; - wOffset++; - wOffset += (uKeyIdx * 4); - // always push 128 bits - for (ii = 0; ii < 3; ii++) { - pr_debug("(%d) wOffset: %d, Data: %lX\n", - ii, wOffset+ii, *pdwKey); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, *pdwKey++); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - } - dwData = *pdwKey; - if (uKeyLen == WLAN_KEY_LEN_WEP40) - dwData |= 0x80000000; - - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+3); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - pr_debug("End. wOffset: %d, Data: %lX\n", wOffset+3, dwData); -} - -/* - * Description: - * Enable default Key (KeyEntry[10]) by MISCFIFO - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * - * Out: - * none - * - * Return Value: none - * - */ -/* - void MACvEnableDefaultKey(void __iomem *dwIoBase, unsigned char byLocalID) - { - unsigned short wOffset; - unsigned long dwData; - - if (byLocalID <= 1) - return; - - wOffset = MISCFIFO_KEYETRY0; - wOffset += (10 * MISCFIFO_KEYENTRYSIZE); - - dwData = 0xC0440000; - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - pr_debug("MACvEnableDefaultKey: wOffset: %d, Data: %lX\n", wOffset, dwData); - - } -*/ - -/* - * Description: - * Disable default Key (KeyEntry[10]) by MISCFIFO - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * - * Out: - * none - * - * Return Value: none - * - */ -void MACvDisableDefaultKey(void __iomem *dwIoBase) -{ - unsigned short wOffset; - unsigned long dwData; - - wOffset = MISCFIFO_KEYETRY0; - wOffset += (10 * MISCFIFO_KEYENTRYSIZE); - - dwData = 0x0; - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - pr_debug("MACvDisableDefaultKey: wOffset: %d, Data: %lX\n", - wOffset, dwData); -} - -/* - * Description: - * Set the default TKIP Group Key (KeyEntry[10]) by MISCFIFO - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * - * Out: - * none - * - * Return Value: none - * - */ -void MACvSetDefaultTKIPKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID) -{ - unsigned short wOffset; - unsigned long dwData; - int ii; - - if (byLocalID <= 1) - return; - - pr_debug("MACvSetDefaultTKIPKeyEntry\n"); - wOffset = MISCFIFO_KEYETRY0; - // Kyle test : change offset from 10 -> 0 - wOffset += (10 * MISCFIFO_KEYENTRYSIZE); - - dwData = 0xC0660000; - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - wOffset++; - - dwData = 0; - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - wOffset++; - - wOffset += (uKeyIdx * 4); - pr_debug("1. wOffset: %d, Data: %lX, idx:%d\n", - wOffset, *pdwKey, uKeyIdx); - // always push 128 bits - for (ii = 0; ii < 4; ii++) { - pr_debug("2.(%d) wOffset: %d, Data: %lX\n", - ii, wOffset+ii, *pdwKey); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, *pdwKey++); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); - } -} - -/* - * Description: - * Set the Key Control by MISCFIFO - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * - * Out: - * none - * - * Return Value: none - * - */ - -void MACvSetDefaultKeyCtl(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID) -{ - unsigned short wOffset; - unsigned long dwData; - - if (byLocalID <= 1) - return; - - pr_debug("MACvSetKeyEntry\n"); - wOffset = MISCFIFO_KEYETRY0; - wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); - - dwData = 0; - dwData |= wKeyCtl; - dwData <<= 16; - dwData |= 0xffff; - pr_debug("1. wOffset: %d, Data: %lX, KeyCtl:%X\n", - wOffset, dwData, wKeyCtl); - - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); - VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); - VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); -} diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 3f37014f7ed1..7d39a7ffba4c 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -964,41 +964,22 @@ do { \ #define MACvSetRFLE_LatchBase(dwIoBase) \ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT) -void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs); - bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits); bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits); bool MACbIsIntDisable(void __iomem *dwIoBase); -unsigned char MACbyReadMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx); -void MACvWriteMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx, unsigned char byData); -void MACvSetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx); -void MACvResetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx); - -void MACvSetRxThreshold(void __iomem *dwIoBase, unsigned char byThreshold); -void MACvGetRxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold); - -void MACvSetTxThreshold(void __iomem *dwIoBase, unsigned char byThreshold); -void MACvGetTxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold); - -void MACvSetDmaLength(void __iomem *dwIoBase, unsigned char byDmaLength); -void MACvGetDmaLength(void __iomem *dwIoBase, unsigned char *pbyDmaLength); - void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit); -void MACvGetShortRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit); void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit); void MACvGetLongRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit); void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode); -bool MACbIsInLoopbackMode(void __iomem *dwIoBase); void MACvSetPacketFilter(void __iomem *dwIoBase, unsigned short wFilterType); void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf); void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf); -bool MACbCompareContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf); bool MACbSoftwareReset(void __iomem *dwIoBase); bool MACbSafeSoftwareReset(void __iomem *dwIoBase); @@ -1015,27 +996,14 @@ void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAd void MACvSetCurrSyncDescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr); void MACvSetCurrATIMDescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr); void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay); -void MACvOneShotTimer0MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime); void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime); void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData); -bool MACbTxDMAOff(void __iomem *dwIoBase, unsigned int idx); - -void MACvClearBusSusInd(void __iomem *dwIoBase); -void MACvEnableBusSusEn(void __iomem *dwIoBase); - -bool MACbFlushSYNCFifo(void __iomem *dwIoBase); bool MACbPSWakeup(void __iomem *dwIoBase); void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID); void MACvDisableKeyEntry(void __iomem *dwIoBase, unsigned int uEntryIdx); -void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID); -void MACvDisableDefaultKey(void __iomem *dwIoBase); -void MACvSetDefaultTKIPKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID); -void MACvSetDefaultKeyCtl(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID); #endif // __MAC_H__ -- cgit v1.2.3-59-g8ed1b From b1c41336570f952e0b30eaa56728996d5ac50457 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:52 +0000 Subject: staging: vt6655: remove fragmentation from driver fragmentation is now handled by mac80211. Remove functions device_alloc_frag_buf device_init_defrag_cb device_free_frag_buf Removing typedef struct tagSDeFragControlBlock frag_thresh sRxDFCB cbDFCB; cbFreeDFCB; uCurrentDFCBIdx; macros FRAG_THRESH_MIN FRAG_THRESH_MAX Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 3 -- drivers/staging/vt6655/device.h | 25 ----------------- drivers/staging/vt6655/device_main.c | 53 ------------------------------------ 3 files changed, 81 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index bff77c88a792..60f051f8de8a 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -583,9 +583,6 @@ CARDvSafeResetRx( pDesc->m_rd1RD1.wReqCount = (unsigned short)(pDevice->rx_buf_sz); } - pDevice->cbDFCB = CB_MAX_RX_FRAG; - pDevice->cbFreeDFCB = pDevice->cbDFCB; - /* set perPkt mode */ MACvRx0PerPktMode(pDevice->PortOffset); MACvRx1PerPktMode(pDevice->PortOffset); diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 93d2ccb9ba67..903d782d49c9 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -177,19 +177,6 @@ typedef enum { OWNED_BY_NIC = 1 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE; -#define CB_MAX_RX_FRAG 64 -/* DeFragment Control Block, used for collecting fragments prior to reassembly */ -typedef struct tagSDeFragControlBlock { - unsigned short wSequence; - unsigned short wFragNum; - unsigned char abyAddr2[ETH_ALEN]; - unsigned int uLifetime; - struct sk_buff *skb; - unsigned char *pbyRxBuffer; - unsigned int cbFrameLength; - bool bInUse; -} SDeFragControlBlock, *PSDeFragControlBlock; - /* flags for options */ #define DEVICE_FLAGS_IP_ALIGN 0x00000001UL #define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL @@ -223,7 +210,6 @@ typedef struct __device_opt { int nTxDescs[2]; /* Number of TX descriptors 0, 1 */ int int_works; /* interrupt limits */ int rts_thresh; /* rts threshold */ - int frag_thresh; int data_rate; int channel_num; int short_retry; @@ -287,11 +273,6 @@ struct vnt_private { volatile PSRxDesc aRD1Ring; volatile PSRxDesc pCurrRD[TYPE_MAXRD]; - SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; - unsigned int cbDFCB; - unsigned int cbFreeDFCB; - unsigned int uCurrentDFCBIdx; - OPTIONS sOpts; u32 flags; @@ -364,7 +345,6 @@ struct vnt_private { unsigned short wCurrentRate; unsigned short wRTSThreshold; - unsigned short wFragmentationThreshold; unsigned char byShortRetryLimit; unsigned char byLongRetryLimit; enum nl80211_iftype op_mode; @@ -487,9 +467,4 @@ static inline PDEVICE_TD_INFO alloc_td_info(void) { return kzalloc(sizeof(DEVICE_TD_INFO), GFP_ATOMIC); } - -/*--------------------- Export Functions --------------------------*/ - -bool device_alloc_frag_buf(struct vnt_private *pDevice, - PSDeFragControlBlock pDeF); #endif diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index f0b336bb393d..6a6c15dd91ba 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -35,16 +35,13 @@ * device_intr - interrupt handle function * device_rx_srv - rx service function * device_alloc_rx_buf - rx buffer pre-allocated function - * device_alloc_frag_buf - rx fragement pre-allocated function * device_free_tx_buf - free tx buffer function - * device_free_frag_buf- free de-fragement buffer * device_init_rd0_ring- initial rd dma0 ring * device_init_rd1_ring- initial rd dma1 ring * device_init_td0_ring- initial tx dma0 ring buffer * device_init_td1_ring- initial tx dma1 ring buffer * device_init_registers- initial MAC & BBP & RF internal registers. * device_init_rings- initial tx/rx ring buffer - * device_init_defrag_cb- initial & allocate de-fragement buffer. * device_free_rings- free all allocated ring buffer * device_tx_srv- tx interrupt service function * @@ -132,12 +129,8 @@ DEVICE_PARAM(PreambleType, "Preamble Type"); DEVICE_PARAM(RTSThreshold, "RTS threshold"); -#define FRAG_THRESH_MIN 256 -#define FRAG_THRESH_MAX 2346 #define FRAG_THRESH_DEF 2346 -DEVICE_PARAM(FragThreshold, "Fragmentation threshold"); - #define DATA_RATE_MIN 0 #define DATA_RATE_MAX 13 #define DATA_RATE_DEF 13 @@ -256,7 +249,6 @@ static struct notifier_block device_notifier = { static void device_init_rd0_ring(struct vnt_private *pDevice); static void device_init_rd1_ring(struct vnt_private *pDevice); -static void device_init_defrag_cb(struct vnt_private *pDevice); static void device_init_td0_ring(struct vnt_private *pDevice); static void device_init_td1_ring(struct vnt_private *pDevice); @@ -270,7 +262,6 @@ static void device_free_td1_ring(struct vnt_private *pDevice); static void device_free_rd0_ring(struct vnt_private *pDevice); static void device_free_rd1_ring(struct vnt_private *pDevice); static void device_free_rings(struct vnt_private *pDevice); -static void device_free_frag_buf(struct vnt_private *pDevice); /*--------------------- Export Variables --------------------------*/ @@ -306,7 +297,6 @@ static void device_get_options(struct vnt_private *pDevice) pOpts->flags |= DEVICE_FLAGS_IP_ALIGN; pOpts->int_works = INT_WORKS_DEF; pOpts->rts_thresh = RTS_THRESH_DEF; - pOpts->frag_thresh = FRAG_THRESH_DEF; pOpts->data_rate = DATA_RATE_DEF; pOpts->channel_num = CHANNEL_DEF; @@ -332,7 +322,6 @@ device_set_options(struct vnt_private *pDevice) pDevice->uChannel = pDevice->sOpts.channel_num; pDevice->wRTSThreshold = pDevice->sOpts.rts_thresh; - pDevice->wFragmentationThreshold = pDevice->sOpts.frag_thresh; pDevice->byShortRetryLimit = pDevice->sOpts.short_retry; pDevice->byLongRetryLimit = pDevice->sOpts.long_retry; pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME; @@ -853,21 +842,6 @@ static void device_init_rd1_ring(struct vnt_private *pDevice) pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]); } -static void device_init_defrag_cb(struct vnt_private *pDevice) -{ - int i; - PSDeFragControlBlock pDeF; - - /* Init the fragment ctl entries */ - for (i = 0; i < CB_MAX_RX_FRAG; i++) { - pDeF = &(pDevice->sRxDFCB[i]); - if (!device_alloc_frag_buf(pDevice, pDeF)) - dev_err(&pDevice->pcid->dev, "can not alloc frag bufs\n"); - } - pDevice->cbDFCB = CB_MAX_RX_FRAG; - pDevice->cbFreeDFCB = pDevice->cbDFCB; -} - static void device_free_rd0_ring(struct vnt_private *pDevice) { int i; @@ -902,20 +876,6 @@ static void device_free_rd1_ring(struct vnt_private *pDevice) } } -static void device_free_frag_buf(struct vnt_private *pDevice) -{ - PSDeFragControlBlock pDeF; - int i; - - for (i = 0; i < CB_MAX_RX_FRAG; i++) { - pDeF = &(pDevice->sRxDFCB[i]); - - if (pDeF->skb) - dev_kfree_skb(pDeF->skb); - - } -} - static void device_init_td0_ring(struct vnt_private *pDevice) { int i; @@ -1056,17 +1016,6 @@ static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD) return true; } -bool device_alloc_frag_buf(struct vnt_private *pDevice, - PSDeFragControlBlock pDeF) -{ - pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - if (pDeF->skb == NULL) - return false; - ASSERT(pDeF->skb); - - return true; -} - static const u8 fallback_rate0[5][5] = { {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M}, {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M}, @@ -1466,7 +1415,6 @@ static int vnt_start(struct ieee80211_hw *hw) dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n"); device_init_rd0_ring(priv); device_init_rd1_ring(priv); - device_init_defrag_cb(priv); device_init_td0_ring(priv); device_init_td1_ring(priv); @@ -1494,7 +1442,6 @@ static void vnt_stop(struct ieee80211_hw *hw) device_free_td1_ring(priv); device_free_rd0_ring(priv); device_free_rd1_ring(priv); - device_free_frag_buf(priv); device_free_rings(priv); free_irq(priv->pcid->irq, priv); -- cgit v1.2.3-59-g8ed1b From 1b8e512b41d6620627d3bafeeb68d64d294c357f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:53 +0000 Subject: staging: vt6655: device_get_options remove unused device parameters IP_byte_align Channel PreambleType RTSThreshold ConnectionRate OPMode b80211hEnable Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 3 -- drivers/staging/vt6655/device_main.c | 100 ----------------------------------- 2 files changed, 103 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 903d782d49c9..2f52297724d2 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -209,9 +209,6 @@ typedef struct __device_opt { int nRxDescs1; /* Number of RX descriptors1 */ int nTxDescs[2]; /* Number of TX descriptors 0, 1 */ int int_works; /* interrupt limits */ - int rts_thresh; /* rts threshold */ - int data_rate; - int channel_num; int short_retry; int long_retry; int bbp_type; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 6a6c15dd91ba..e3b2d8fb1f6f 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -93,85 +93,16 @@ DEVICE_PARAM(TxDescriptors0, "Number of transmit descriptors0"); #define TX_DESC_DEF1 64 DEVICE_PARAM(TxDescriptors1, "Number of transmit descriptors1"); -#define IP_ALIG_DEF 0 -/* IP_byte_align[] is used for IP header unsigned long byte aligned - 0: indicate the IP header won't be unsigned long byte aligned.(Default) . - 1: indicate the IP header will be unsigned long byte aligned. - In some environment, the IP header should be unsigned long byte aligned, - or the packet will be droped when we receive it. (eg: IPVS) -*/ -DEVICE_PARAM(IP_byte_align, "Enable IP header dword aligned"); - #define INT_WORKS_DEF 20 #define INT_WORKS_MIN 10 #define INT_WORKS_MAX 64 DEVICE_PARAM(int_works, "Number of packets per interrupt services"); -#define CHANNEL_MIN 1 -#define CHANNEL_MAX 14 -#define CHANNEL_DEF 6 - -DEVICE_PARAM(Channel, "Channel number"); - -/* PreambleType[] is the preamble length used for transmit. - 0: indicate allows long preamble type - 1: indicate allows short preamble type -*/ - -#define PREAMBLE_TYPE_DEF 1 - -DEVICE_PARAM(PreambleType, "Preamble Type"); - -#define RTS_THRESH_MIN 512 -#define RTS_THRESH_MAX 2347 #define RTS_THRESH_DEF 2347 -DEVICE_PARAM(RTSThreshold, "RTS threshold"); - #define FRAG_THRESH_DEF 2346 -#define DATA_RATE_MIN 0 -#define DATA_RATE_MAX 13 -#define DATA_RATE_DEF 13 -/* datarate[] index - 0: indicate 1 Mbps 0x02 - 1: indicate 2 Mbps 0x04 - 2: indicate 5.5 Mbps 0x0B - 3: indicate 11 Mbps 0x16 - 4: indicate 6 Mbps 0x0c - 5: indicate 9 Mbps 0x12 - 6: indicate 12 Mbps 0x18 - 7: indicate 18 Mbps 0x24 - 8: indicate 24 Mbps 0x30 - 9: indicate 36 Mbps 0x48 - 10: indicate 48 Mbps 0x60 - 11: indicate 54 Mbps 0x6c - 12: indicate 72 Mbps 0x90 - 13: indicate auto rate -*/ - -DEVICE_PARAM(ConnectionRate, "Connection data rate"); - -#define OP_MODE_DEF 0 - -DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode "); - -/* OpMode[] is used for transmit. - 0: indicate infrastruct mode used - 1: indicate adhoc mode used - 2: indicate AP mode used -*/ - -/* PSMode[] - 0: indicate disable power saving mode - 1: indicate enable power saving mode -*/ - -#define PS_MODE_DEF 0 - -DEVICE_PARAM(PSMode, "Power saving mode"); - #define SHORT_RETRY_MIN 0 #define SHORT_RETRY_MAX 31 #define SHORT_RETRY_DEF 8 @@ -195,20 +126,6 @@ DEVICE_PARAM(LongRetryLimit, "long frame retry limits"); DEVICE_PARAM(BasebandType, "baseband type"); -/* 80211hEnable[] - 0: indicate disable 802.11h - 1: indicate enable 802.11h -*/ - -#define X80211h_MODE_DEF 0 - -DEVICE_PARAM(b80211hEnable, "802.11h mode"); - -/* 80211hEnable[] - 0: indicate disable 802.11h - 1: indicate enable 802.11h -*/ - #define DIVERSITY_ANT_DEF 0 DEVICE_PARAM(bDiversityANTEnable, "ANT diversity mode"); @@ -294,18 +211,11 @@ static void device_get_options(struct vnt_private *pDevice) pOpts->nRxDescs1 = RX_DESC_DEF1; pOpts->nTxDescs[0] = TX_DESC_DEF0; pOpts->nTxDescs[1] = TX_DESC_DEF1; - pOpts->flags |= DEVICE_FLAGS_IP_ALIGN; pOpts->int_works = INT_WORKS_DEF; - pOpts->rts_thresh = RTS_THRESH_DEF; - pOpts->data_rate = DATA_RATE_DEF; - pOpts->channel_num = CHANNEL_DEF; - pOpts->flags |= DEVICE_FLAGS_PREAMBLE_TYPE; - pOpts->flags |= DEVICE_FLAGS_OP_MODE; pOpts->short_retry = SHORT_RETRY_DEF; pOpts->long_retry = LONG_RETRY_DEF; pOpts->bbp_type = BBP_TYPE_DEF; - pOpts->flags |= DEVICE_FLAGS_80211h_MODE; pOpts->flags |= DEVICE_FLAGS_DiversityANT; } @@ -320,23 +230,13 @@ device_set_options(struct vnt_private *pDevice) ether_addr_copy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042); ether_addr_copy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel); - pDevice->uChannel = pDevice->sOpts.channel_num; - pDevice->wRTSThreshold = pDevice->sOpts.rts_thresh; pDevice->byShortRetryLimit = pDevice->sOpts.short_retry; pDevice->byLongRetryLimit = pDevice->sOpts.long_retry; - pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME; - pDevice->byShortPreamble = (pDevice->sOpts.flags & DEVICE_FLAGS_PREAMBLE_TYPE) ? 1 : 0; - pDevice->byOpMode = (pDevice->sOpts.flags & DEVICE_FLAGS_OP_MODE) ? 1 : 0; - pDevice->b11hEnable = (pDevice->sOpts.flags & DEVICE_FLAGS_80211h_MODE) ? 1 : 0; pDevice->bDiversityRegCtlON = (pDevice->sOpts.flags & DEVICE_FLAGS_DiversityANT) ? 1 : 0; - pDevice->uConnectionRate = pDevice->sOpts.data_rate; - if (pDevice->uConnectionRate < RATE_AUTO) - pDevice->bFixRate = true; pDevice->byBBType = pDevice->sOpts.bbp_type; pDevice->byPacketType = (VIA_PKT_TYPE)pDevice->byBBType; pDevice->byAutoFBCtrl = AUTO_FB_0; pDevice->bUpdateBBVGA = true; - pDevice->byFOETuning = 0; pDevice->byPreambleType = 0; pr_debug(" uChannel= %d\n", (int)pDevice->uChannel); -- cgit v1.2.3-59-g8ed1b From ac875c17a12141fb2845be3112b6905dd41862fa Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:54 +0000 Subject: staging: vt6655: device_set_options remove unused ethernet addresses Removing these variables abyBroadcastAddr abySNAP_RFC1042 abySNAP_Bridgetunnel Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 3 --- drivers/staging/vt6655/device_main.c | 8 -------- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 2f52297724d2..05f2993f1081 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -440,9 +440,6 @@ struct vnt_private { unsigned long uNumSQ3[MAX_RATE]; unsigned short wAntDiversityMaxRate; - unsigned char abyBroadcastAddr[ETH_ALEN]; - unsigned char abySNAP_RFC1042[ETH_ALEN]; - unsigned char abySNAP_Bridgetunnel[ETH_ALEN]; unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */ /* for 802.11h */ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index e3b2d8fb1f6f..adcd6c804c25 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -222,14 +222,6 @@ static void device_get_options(struct vnt_private *pDevice) static void device_set_options(struct vnt_private *pDevice) { - unsigned char abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - unsigned char abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - unsigned char abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - - ether_addr_copy(pDevice->abyBroadcastAddr, abyBroadcastAddr); - ether_addr_copy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042); - ether_addr_copy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel); - pDevice->byShortRetryLimit = pDevice->sOpts.short_retry; pDevice->byLongRetryLimit = pDevice->sOpts.long_retry; pDevice->bDiversityRegCtlON = (pDevice->sOpts.flags & DEVICE_FLAGS_DiversityANT) ? 1 : 0; -- cgit v1.2.3-59-g8ed1b From bfa4b0febd598546ace2082efbd119531eb09ecf Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:55 +0000 Subject: staging: vt6655: device_init_registers remove uConnectionRate The device starts up with a default rate of 54M Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index adcd6c804c25..4744cf382914 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -456,10 +456,7 @@ static void device_init_registers(struct vnt_private *pDevice) /* Set BB and packet type at the same time. */ /* Set Short Slot Time, xIFS, and RSPINF. */ - if (pDevice->uConnectionRate == RATE_AUTO) - pDevice->wCurrentRate = RATE_54M; - else - pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; + pDevice->wCurrentRate = RATE_54M; pDevice->bRadioOff = false; -- cgit v1.2.3-59-g8ed1b From 3d42d26c83b98b2c13b46be61f32756f274bfdd1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:56 +0000 Subject: staging: vt6655: baseband.c/h remove dead functions These functions are not used so remove them BBbIsRegBitsOn BBbIsRegBitsOff BBvReadAllRegs BBvLoopbackOn BBvLoopbackOff Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 162 -------------------------------------- drivers/staging/vt6655/baseband.h | 5 -- 2 files changed, 167 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index b04dfd945d41..30dd59db57d4 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -30,12 +30,7 @@ * BBvCaculateParameter - Caculate PhyLength, PhyService and Phy Signal parameter for baseband Tx * BBbReadEmbedded - Embedded read baseband register via MAC * BBbWriteEmbedded - Embedded write baseband register via MAC - * BBbIsRegBitsOn - Test if baseband register bits on - * BBbIsRegBitsOff - Test if baseband register bits off * BBbVT3253Init - VIA VT3253 baseband chip init code - * BBvReadAllRegs - Read All Baseband Registers - * BBvLoopbackOn - Turn on BaseBand Loopback mode - * BBvLoopbackOff - Turn off BaseBand Loopback mode * * Revision History: * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. @@ -2035,50 +2030,6 @@ bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned c return true; } -/* - * Description: Test if all bits are set for the Baseband register - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byBBAddr - address of register in Baseband - * byTestBits - TestBits - * Out: - * none - * - * Return Value: true if all TestBits are set; false otherwise. - * - */ -bool BBbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits) -{ - unsigned char byOrgData; - - BBbReadEmbedded(dwIoBase, byBBAddr, &byOrgData); - return (byOrgData & byTestBits) == byTestBits; -} - -/* - * Description: Test if all bits are clear for the Baseband register - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byBBAddr - address of register in Baseband - * byTestBits - TestBits - * Out: - * none - * - * Return Value: true if all TestBits are clear; false otherwise. - * - */ -bool BBbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits) -{ - unsigned char byOrgData; - - BBbReadEmbedded(dwIoBase, byBBAddr, &byOrgData); - return (byOrgData & byTestBits) == 0; -} - /* * Description: VIA VT3253 Baseband chip init function * @@ -2251,119 +2202,6 @@ bool BBbVT3253Init(struct vnt_private *pDevice) return bResult; } -/* - * Description: Read All Baseband Registers - * - * Parameters: - * In: - * dwIoBase - I/O base address - * pbyBBRegs - Point to struct that stores Baseband Registers - * Out: - * none - * - * Return Value: none - * - */ -void BBvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyBBRegs) -{ - int ii; - unsigned char byBase = 1; - - for (ii = 0; ii < BB_MAX_CONTEXT_SIZE; ii++) { - BBbReadEmbedded(dwIoBase, (unsigned char)(ii*byBase), pbyBBRegs); - pbyBBRegs += byBase; - } -} - -/* - * Description: Turn on BaseBand Loopback mode - * - * Parameters: - * In: - * dwIoBase - I/O base address - * bCCK - If CCK is set - * Out: - * none - * - * Return Value: none - * - */ - -void BBvLoopbackOn(struct vnt_private *pDevice) -{ - unsigned char byData; - void __iomem *dwIoBase = pDevice->PortOffset; - - /* CR C9 = 0x00 */ - BBbReadEmbedded(dwIoBase, 0xC9, &pDevice->byBBCRc9); /* CR201 */ - BBbWriteEmbedded(dwIoBase, 0xC9, 0); - BBbReadEmbedded(dwIoBase, 0x4D, &pDevice->byBBCR4d); /* CR77 */ - BBbWriteEmbedded(dwIoBase, 0x4D, 0x90); - - /* CR 88 = 0x02(CCK), 0x03(OFDM) */ - BBbReadEmbedded(dwIoBase, 0x88, &pDevice->byBBCR88); /* CR136 */ - - if (pDevice->uConnectionRate <= RATE_11M) { /* CCK */ - /* Enable internal digital loopback: CR33 |= 0000 0001 */ - BBbReadEmbedded(dwIoBase, 0x21, &byData); /* CR33 */ - BBbWriteEmbedded(dwIoBase, 0x21, (unsigned char)(byData | 0x01)); /* CR33 */ - /* CR154 = 0x00 */ - BBbWriteEmbedded(dwIoBase, 0x9A, 0); /* CR154 */ - - BBbWriteEmbedded(dwIoBase, 0x88, 0x02); /* CR239 */ - } else { /* OFDM */ - /* Enable internal digital loopback:CR154 |= 0000 0001 */ - BBbReadEmbedded(dwIoBase, 0x9A, &byData); /* CR154 */ - BBbWriteEmbedded(dwIoBase, 0x9A, (unsigned char)(byData | 0x01)); /* CR154 */ - /* CR33 = 0x00 */ - BBbWriteEmbedded(dwIoBase, 0x21, 0); /* CR33 */ - - BBbWriteEmbedded(dwIoBase, 0x88, 0x03); /* CR239 */ - } - - /* CR14 = 0x00 */ - BBbWriteEmbedded(dwIoBase, 0x0E, 0); /* CR14 */ - - /* Disable TX_IQUN */ - BBbReadEmbedded(pDevice->PortOffset, 0x09, &pDevice->byBBCR09); - BBbWriteEmbedded(pDevice->PortOffset, 0x09, (unsigned char)(pDevice->byBBCR09 & 0xDE)); -} - -/* - * Description: Turn off BaseBand Loopback mode - * - * Parameters: - * In: - * pDevice - Device Structure - * - * Out: - * none - * - * Return Value: none - * - */ -void BBvLoopbackOff(struct vnt_private *pDevice) -{ - unsigned char byData; - void __iomem *dwIoBase = pDevice->PortOffset; - - BBbWriteEmbedded(dwIoBase, 0xC9, pDevice->byBBCRc9); /* CR201 */ - BBbWriteEmbedded(dwIoBase, 0x88, pDevice->byBBCR88); /* CR136 */ - BBbWriteEmbedded(dwIoBase, 0x09, pDevice->byBBCR09); /* CR136 */ - BBbWriteEmbedded(dwIoBase, 0x4D, pDevice->byBBCR4d); /* CR77 */ - - if (pDevice->uConnectionRate <= RATE_11M) { /* CCK */ - /* Set the CR33 Bit2 to disable internal Loopback. */ - BBbReadEmbedded(dwIoBase, 0x21, &byData);/* CR33 */ - BBbWriteEmbedded(dwIoBase, 0x21, (unsigned char)(byData & 0xFE)); /* CR33 */ - } else { /* OFDM */ - BBbReadEmbedded(dwIoBase, 0x9A, &byData); /* CR154 */ - BBbWriteEmbedded(dwIoBase, 0x9A, (unsigned char)(byData & 0xFE)); /* CR154 */ - } - BBbReadEmbedded(dwIoBase, 0x0E, &byData); /* CR14 */ - BBbWriteEmbedded(dwIoBase, 0x0E, (unsigned char)(byData | 0x80)); /* CR14 */ -} - /* * Description: Set ShortSlotTime mode * diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index bfdd422c490f..6ce856c01907 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -80,12 +80,7 @@ void vnt_get_phy_field(struct vnt_private *, u32 frame_length, bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData); bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData); -void BBvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyBBRegs); -void BBvLoopbackOn(struct vnt_private *pDevice); -void BBvLoopbackOff(struct vnt_private *pDevice); void BBvSetShortSlotTime(struct vnt_private *pDevice); -bool BBbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits); -bool BBbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits); void BBvSetVGAGainOffset(struct vnt_private *pDevice, unsigned char byData); /* VT3253 Baseband */ -- cgit v1.2.3-59-g8ed1b From 2ee1ad7b3289d64f98da883adc68d4bf4599937b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:57 +0000 Subject: staging: vt6655: device_set_options remove dead variables uConnectionRate wRTSThreshold byOpMode b11hEnable uChannel Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 8 -------- drivers/staging/vt6655/device_main.c | 5 ----- 2 files changed, 13 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 05f2993f1081..74d2afbdc9f1 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -335,17 +335,14 @@ struct vnt_private { unsigned char byMinChannel; unsigned char byMaxChannel; - unsigned int uConnectionRate; unsigned char byPreambleType; unsigned char byShortPreamble; unsigned short wCurrentRate; - unsigned short wRTSThreshold; unsigned char byShortRetryLimit; unsigned char byLongRetryLimit; enum nl80211_iftype op_mode; - unsigned char byOpMode; bool bBSSIDFilter; unsigned short wMaxTransmitMSDULifetime; @@ -442,13 +439,8 @@ struct vnt_private { unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */ - /* for 802.11h */ - bool b11hEnable; - unsigned short wBeaconInterval; - unsigned int uChannel; - struct iw_statistics wstats; /* wireless stats */ }; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 4744cf382914..00eb89a27925 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -231,16 +231,11 @@ device_set_options(struct vnt_private *pDevice) pDevice->bUpdateBBVGA = true; pDevice->byPreambleType = 0; - pr_debug(" uChannel= %d\n", (int)pDevice->uChannel); - pr_debug(" byOpMode= %d\n", (int)pDevice->byOpMode); - pr_debug(" wRTSThreshold= %d\n", (int)pDevice->wRTSThreshold); pr_debug(" byShortRetryLimit= %d\n", (int)pDevice->byShortRetryLimit); pr_debug(" byLongRetryLimit= %d\n", (int)pDevice->byLongRetryLimit); pr_debug(" byPreambleType= %d\n", (int)pDevice->byPreambleType); pr_debug(" byShortPreamble= %d\n", (int)pDevice->byShortPreamble); - pr_debug(" uConnectionRate= %d\n", (int)pDevice->uConnectionRate); pr_debug(" byBBType= %d\n", (int)pDevice->byBBType); - pr_debug(" pDevice->b11hEnable= %d\n", (int)pDevice->b11hEnable); pr_debug(" pDevice->bDiversityRegCtlON= %d\n", (int)pDevice->bDiversityRegCtlON); } -- cgit v1.2.3-59-g8ed1b From d475d42db694b51dc655a1c8af97f84a4d3a4cf7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:58 +0000 Subject: staging: vt6655: device.h remove dead member wstats Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 74d2afbdc9f1..1393210771de 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -440,8 +440,6 @@ struct vnt_private { unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */ unsigned short wBeaconInterval; - - struct iw_statistics wstats; /* wireless stats */ }; static inline PDEVICE_RD_INFO alloc_rd_info(void) -- cgit v1.2.3-59-g8ed1b From 8514408b9b2e95711ccac08eaed02ba3ce310c03 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 5 Nov 2014 21:08:59 +0000 Subject: staging: vt6655 baseband.c camel case replace pDevice -> priv for struct vnt_private Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 472 +++++++++++++++++++------------------- 1 file changed, 236 insertions(+), 236 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 30dd59db57d4..32000d2bedb1 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1702,39 +1702,39 @@ static const unsigned short awcFrameTime[MAX_RATE] = { static unsigned long -s_ulGetRatio(struct vnt_private *pDevice); +s_ulGetRatio(struct vnt_private *priv); static void s_vChangeAntenna( - struct vnt_private *pDevice + struct vnt_private *priv ); static void s_vChangeAntenna( - struct vnt_private *pDevice + struct vnt_private *priv ) { - if (pDevice->dwRxAntennaSel == 0) { - pDevice->dwRxAntennaSel = 1; - if (pDevice->bTxRxAntInv == true) - BBvSetRxAntennaMode(pDevice->PortOffset, ANT_A); + if (priv->dwRxAntennaSel == 0) { + priv->dwRxAntennaSel = 1; + if (priv->bTxRxAntInv == true) + BBvSetRxAntennaMode(priv->PortOffset, ANT_A); else - BBvSetRxAntennaMode(pDevice->PortOffset, ANT_B); + BBvSetRxAntennaMode(priv->PortOffset, ANT_B); } else { - pDevice->dwRxAntennaSel = 0; - if (pDevice->bTxRxAntInv == true) - BBvSetRxAntennaMode(pDevice->PortOffset, ANT_B); + priv->dwRxAntennaSel = 0; + if (priv->bTxRxAntInv == true) + BBvSetRxAntennaMode(priv->PortOffset, ANT_B); else - BBvSetRxAntennaMode(pDevice->PortOffset, ANT_A); + BBvSetRxAntennaMode(priv->PortOffset, ANT_A); } - if (pDevice->dwTxAntennaSel == 0) { - pDevice->dwTxAntennaSel = 1; - BBvSetTxAntennaMode(pDevice->PortOffset, ANT_B); + if (priv->dwTxAntennaSel == 0) { + priv->dwTxAntennaSel = 1; + BBvSetTxAntennaMode(priv->PortOffset, ANT_B); } else { - pDevice->dwTxAntennaSel = 0; - BBvSetTxAntennaMode(pDevice->PortOffset, ANT_A); + priv->dwTxAntennaSel = 0; + BBvSetTxAntennaMode(priv->PortOffset, ANT_A); } } @@ -2045,13 +2045,13 @@ bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned c * */ -bool BBbVT3253Init(struct vnt_private *pDevice) +bool BBbVT3253Init(struct vnt_private *priv) { bool bResult = true; int ii; - void __iomem *dwIoBase = pDevice->PortOffset; - unsigned char byRFType = pDevice->byRFType; - unsigned char byLocalID = pDevice->byLocalID; + void __iomem *dwIoBase = priv->PortOffset; + unsigned char byRFType = priv->byRFType; + unsigned char byLocalID = priv->byLocalID; if (byRFType == RF_RFMD2959) { if (byLocalID <= REV_ID_VT3253_A1) { @@ -2068,14 +2068,14 @@ bool BBbVT3253Init(struct vnt_private *pDevice) VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0)); } - pDevice->abyBBVGA[0] = 0x18; - pDevice->abyBBVGA[1] = 0x0A; - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - pDevice->ldBmThreshold[0] = -70; - pDevice->ldBmThreshold[1] = -50; - pDevice->ldBmThreshold[2] = 0; - pDevice->ldBmThreshold[3] = 0; + priv->abyBBVGA[0] = 0x18; + priv->abyBBVGA[1] = 0x0A; + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + priv->ldBmThreshold[0] = -70; + priv->ldBmThreshold[1] = -50; + priv->ldBmThreshold[2] = 0; + priv->ldBmThreshold[3] = 0; } else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S)) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); @@ -2083,14 +2083,14 @@ bool BBbVT3253Init(struct vnt_private *pDevice) for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - pDevice->abyBBVGA[0] = 0x1C; - pDevice->abyBBVGA[1] = 0x10; - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - pDevice->ldBmThreshold[0] = -70; - pDevice->ldBmThreshold[1] = -48; - pDevice->ldBmThreshold[2] = 0; - pDevice->ldBmThreshold[3] = 0; + priv->abyBBVGA[0] = 0x1C; + priv->abyBBVGA[1] = 0x10; + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + priv->ldBmThreshold[0] = -70; + priv->ldBmThreshold[1] = -48; + priv->ldBmThreshold[2] = 0; + priv->ldBmThreshold[3] = 0; } else if (byRFType == RF_UW2451) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); @@ -2101,14 +2101,14 @@ bool BBbVT3253Init(struct vnt_private *pDevice) VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0)); - pDevice->abyBBVGA[0] = 0x14; - pDevice->abyBBVGA[1] = 0x0A; - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - pDevice->ldBmThreshold[0] = -60; - pDevice->ldBmThreshold[1] = -50; - pDevice->ldBmThreshold[2] = 0; - pDevice->ldBmThreshold[3] = 0; + priv->abyBBVGA[0] = 0x14; + priv->abyBBVGA[1] = 0x0A; + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + priv->ldBmThreshold[0] = -60; + priv->ldBmThreshold[1] = -50; + priv->ldBmThreshold[2] = 0; + priv->ldBmThreshold[3] = 0; } else if (byRFType == RF_UW2452) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); @@ -2134,14 +2134,14 @@ bool BBbVT3253Init(struct vnt_private *pDevice) for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - pDevice->abyBBVGA[0] = 0x14; - pDevice->abyBBVGA[1] = 0x0A; - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - pDevice->ldBmThreshold[0] = -60; - pDevice->ldBmThreshold[1] = -50; - pDevice->ldBmThreshold[2] = 0; - pDevice->ldBmThreshold[3] = 0; + priv->abyBBVGA[0] = 0x14; + priv->abyBBVGA[1] = 0x0A; + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + priv->ldBmThreshold[0] = -60; + priv->ldBmThreshold[1] = -50; + priv->ldBmThreshold[2] = 0; + priv->ldBmThreshold[3] = 0; /* }} RobertYu */ } else if (byRFType == RF_VT3226) { @@ -2151,14 +2151,14 @@ bool BBbVT3253Init(struct vnt_private *pDevice) for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - pDevice->abyBBVGA[0] = 0x1C; - pDevice->abyBBVGA[1] = 0x10; - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - pDevice->ldBmThreshold[0] = -70; - pDevice->ldBmThreshold[1] = -48; - pDevice->ldBmThreshold[2] = 0; - pDevice->ldBmThreshold[3] = 0; + priv->abyBBVGA[0] = 0x1C; + priv->abyBBVGA[1] = 0x10; + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + priv->ldBmThreshold[0] = -70; + priv->ldBmThreshold[1] = -48; + priv->ldBmThreshold[2] = 0; + priv->ldBmThreshold[3] = 0; /* Fix VT3226 DFC system timing issue */ MACvSetRFLE_LatchBase(dwIoBase); /* {{ RobertYu: 20050104 */ @@ -2179,19 +2179,19 @@ bool BBbVT3253Init(struct vnt_private *pDevice) for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - pDevice->abyBBVGA[0] = 0x1C; - pDevice->abyBBVGA[1] = 0x10; - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - pDevice->ldBmThreshold[0] = -70; - pDevice->ldBmThreshold[1] = -48; - pDevice->ldBmThreshold[2] = 0; - pDevice->ldBmThreshold[3] = 0; + priv->abyBBVGA[0] = 0x1C; + priv->abyBBVGA[1] = 0x10; + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + priv->ldBmThreshold[0] = -70; + priv->ldBmThreshold[1] = -48; + priv->ldBmThreshold[2] = 0; + priv->ldBmThreshold[3] = 0; /* }} RobertYu */ } else { /* No VGA Table now */ - pDevice->bUpdateBBVGA = false; - pDevice->abyBBVGA[0] = 0x1C; + priv->bUpdateBBVGA = false; + priv->abyBBVGA[0] = 0x1C; } if (byLocalID > REV_ID_VT3253_A1) { @@ -2207,7 +2207,7 @@ bool BBbVT3253Init(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * Out: * none * @@ -2215,42 +2215,42 @@ bool BBbVT3253Init(struct vnt_private *pDevice) * */ void -BBvSetShortSlotTime(struct vnt_private *pDevice) +BBvSetShortSlotTime(struct vnt_private *priv) { unsigned char byBBRxConf = 0; unsigned char byBBVGA = 0; - BBbReadEmbedded(pDevice->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ + BBbReadEmbedded(priv->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ - if (pDevice->bShortSlotTime) + if (priv->bShortSlotTime) byBBRxConf &= 0xDF; /* 1101 1111 */ else byBBRxConf |= 0x20; /* 0010 0000 */ /* patch for 3253B0 Baseband with Cardbus module */ - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byBBVGA); - if (byBBVGA == pDevice->abyBBVGA[0]) + BBbReadEmbedded(priv->PortOffset, 0xE7, &byBBVGA); + if (byBBVGA == priv->abyBBVGA[0]) byBBRxConf |= 0x20; /* 0010 0000 */ - BBbWriteEmbedded(pDevice->PortOffset, 0x0A, byBBRxConf); /* CR10 */ + BBbWriteEmbedded(priv->PortOffset, 0x0A, byBBRxConf); /* CR10 */ } -void BBvSetVGAGainOffset(struct vnt_private *pDevice, unsigned char byData) +void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData) { unsigned char byBBRxConf = 0; - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, byData); + BBbWriteEmbedded(priv->PortOffset, 0xE7, byData); - BBbReadEmbedded(pDevice->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ + BBbReadEmbedded(priv->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ /* patch for 3253B0 Baseband with Cardbus module */ - if (byData == pDevice->abyBBVGA[0]) + if (byData == priv->abyBBVGA[0]) byBBRxConf |= 0x20; /* 0010 0000 */ - else if (pDevice->bShortSlotTime) + else if (priv->bShortSlotTime) byBBRxConf &= 0xDF; /* 1101 1111 */ else byBBRxConf |= 0x20; /* 0010 0000 */ - pDevice->byBBVGACurrent = byData; - BBbWriteEmbedded(pDevice->PortOffset, 0x0A, byBBRxConf); /* CR10 */ + priv->byBBVGACurrent = byData; + BBbWriteEmbedded(priv->PortOffset, 0x0A, byBBRxConf); /* CR10 */ } /* @@ -2323,7 +2323,7 @@ BBvPowerSaveModeOFF(void __iomem *dwIoBase) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * byAntennaMode - Antenna Mode * Out: * none @@ -2356,7 +2356,7 @@ BBvSetTxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * byAntennaMode - Antenna Mode * Out: * none @@ -2388,7 +2388,7 @@ BBvSetRxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * Out: * none * @@ -2411,94 +2411,94 @@ BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID) static unsigned long -s_ulGetRatio(struct vnt_private *pDevice) +s_ulGetRatio(struct vnt_private *priv) { unsigned long ulRatio = 0; unsigned long ulMaxPacket; unsigned long ulPacketNum; /* This is a thousand-ratio */ - ulMaxPacket = pDevice->uNumSQ3[RATE_54M]; - if (pDevice->uNumSQ3[RATE_54M] != 0) { - ulPacketNum = pDevice->uNumSQ3[RATE_54M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + ulMaxPacket = priv->uNumSQ3[RATE_54M]; + if (priv->uNumSQ3[RATE_54M] != 0) { + ulPacketNum = priv->uNumSQ3[RATE_54M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_54M; } - if (pDevice->uNumSQ3[RATE_48M] > ulMaxPacket) { - ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_48M] > ulMaxPacket) { + ulPacketNum = priv->uNumSQ3[RATE_54M] + priv->uNumSQ3[RATE_48M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_48M; - ulMaxPacket = pDevice->uNumSQ3[RATE_48M]; + ulMaxPacket = priv->uNumSQ3[RATE_48M]; } - if (pDevice->uNumSQ3[RATE_36M] > ulMaxPacket) { - ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] + - pDevice->uNumSQ3[RATE_36M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_36M] > ulMaxPacket) { + ulPacketNum = priv->uNumSQ3[RATE_54M] + priv->uNumSQ3[RATE_48M] + + priv->uNumSQ3[RATE_36M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_36M; - ulMaxPacket = pDevice->uNumSQ3[RATE_36M]; + ulMaxPacket = priv->uNumSQ3[RATE_36M]; } - if (pDevice->uNumSQ3[RATE_24M] > ulMaxPacket) { - ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] + - pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_24M] > ulMaxPacket) { + ulPacketNum = priv->uNumSQ3[RATE_54M] + priv->uNumSQ3[RATE_48M] + + priv->uNumSQ3[RATE_36M] + priv->uNumSQ3[RATE_24M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_24M; - ulMaxPacket = pDevice->uNumSQ3[RATE_24M]; + ulMaxPacket = priv->uNumSQ3[RATE_24M]; } - if (pDevice->uNumSQ3[RATE_18M] > ulMaxPacket) { - ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] + - pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] + - pDevice->uNumSQ3[RATE_18M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_18M] > ulMaxPacket) { + ulPacketNum = priv->uNumSQ3[RATE_54M] + priv->uNumSQ3[RATE_48M] + + priv->uNumSQ3[RATE_36M] + priv->uNumSQ3[RATE_24M] + + priv->uNumSQ3[RATE_18M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_18M; - ulMaxPacket = pDevice->uNumSQ3[RATE_18M]; + ulMaxPacket = priv->uNumSQ3[RATE_18M]; } - if (pDevice->uNumSQ3[RATE_12M] > ulMaxPacket) { - ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] + - pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] + - pDevice->uNumSQ3[RATE_18M] + pDevice->uNumSQ3[RATE_12M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_12M] > ulMaxPacket) { + ulPacketNum = priv->uNumSQ3[RATE_54M] + priv->uNumSQ3[RATE_48M] + + priv->uNumSQ3[RATE_36M] + priv->uNumSQ3[RATE_24M] + + priv->uNumSQ3[RATE_18M] + priv->uNumSQ3[RATE_12M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_12M; - ulMaxPacket = pDevice->uNumSQ3[RATE_12M]; + ulMaxPacket = priv->uNumSQ3[RATE_12M]; } - if (pDevice->uNumSQ3[RATE_11M] > ulMaxPacket) { - ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] - - pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] - - pDevice->uNumSQ3[RATE_6M] - pDevice->uNumSQ3[RATE_9M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_11M] > ulMaxPacket) { + ulPacketNum = priv->uDiversityCnt - priv->uNumSQ3[RATE_1M] - + priv->uNumSQ3[RATE_2M] - priv->uNumSQ3[RATE_5M] - + priv->uNumSQ3[RATE_6M] - priv->uNumSQ3[RATE_9M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_11M; - ulMaxPacket = pDevice->uNumSQ3[RATE_11M]; + ulMaxPacket = priv->uNumSQ3[RATE_11M]; } - if (pDevice->uNumSQ3[RATE_9M] > ulMaxPacket) { - ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] - - pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] - - pDevice->uNumSQ3[RATE_6M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_9M] > ulMaxPacket) { + ulPacketNum = priv->uDiversityCnt - priv->uNumSQ3[RATE_1M] - + priv->uNumSQ3[RATE_2M] - priv->uNumSQ3[RATE_5M] - + priv->uNumSQ3[RATE_6M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_9M; - ulMaxPacket = pDevice->uNumSQ3[RATE_9M]; + ulMaxPacket = priv->uNumSQ3[RATE_9M]; } - if (pDevice->uNumSQ3[RATE_6M] > ulMaxPacket) { - ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] - - pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_6M] > ulMaxPacket) { + ulPacketNum = priv->uDiversityCnt - priv->uNumSQ3[RATE_1M] - + priv->uNumSQ3[RATE_2M] - priv->uNumSQ3[RATE_5M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_6M; - ulMaxPacket = pDevice->uNumSQ3[RATE_6M]; + ulMaxPacket = priv->uNumSQ3[RATE_6M]; } - if (pDevice->uNumSQ3[RATE_5M] > ulMaxPacket) { - ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] - - pDevice->uNumSQ3[RATE_2M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_5M] > ulMaxPacket) { + ulPacketNum = priv->uDiversityCnt - priv->uNumSQ3[RATE_1M] - + priv->uNumSQ3[RATE_2M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_55M; - ulMaxPacket = pDevice->uNumSQ3[RATE_5M]; + ulMaxPacket = priv->uNumSQ3[RATE_5M]; } - if (pDevice->uNumSQ3[RATE_2M] > ulMaxPacket) { - ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_2M] > ulMaxPacket) { + ulPacketNum = priv->uDiversityCnt - priv->uNumSQ3[RATE_1M]; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_2M; - ulMaxPacket = pDevice->uNumSQ3[RATE_2M]; + ulMaxPacket = priv->uNumSQ3[RATE_2M]; } - if (pDevice->uNumSQ3[RATE_1M] > ulMaxPacket) { - ulPacketNum = pDevice->uDiversityCnt; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); + if (priv->uNumSQ3[RATE_1M] > ulMaxPacket) { + ulPacketNum = priv->uDiversityCnt; + ulRatio = (ulPacketNum * 1000 / priv->uDiversityCnt); ulRatio += TOP_RATE_1M; } @@ -2506,13 +2506,13 @@ s_ulGetRatio(struct vnt_private *pDevice) } void -BBvClearAntDivSQ3Value(struct vnt_private *pDevice) +BBvClearAntDivSQ3Value(struct vnt_private *priv) { unsigned int ii; - pDevice->uDiversityCnt = 0; + priv->uDiversityCnt = 0; for (ii = 0; ii < MAX_RATE; ii++) - pDevice->uNumSQ3[ii] = 0; + priv->uNumSQ3[ii] = 0; } /* @@ -2520,7 +2520,7 @@ BBvClearAntDivSQ3Value(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * byRSR - RSR from received packet * bySQ3 - SQ3 value from received packet * Out: @@ -2530,75 +2530,75 @@ BBvClearAntDivSQ3Value(struct vnt_private *pDevice) * */ -void BBvAntennaDiversity(struct vnt_private *pDevice, +void BBvAntennaDiversity(struct vnt_private *priv, unsigned char byRxRate, unsigned char bySQ3) { - if ((byRxRate >= MAX_RATE) || (pDevice->wAntDiversityMaxRate >= MAX_RATE)) + if ((byRxRate >= MAX_RATE) || (priv->wAntDiversityMaxRate >= MAX_RATE)) return; - pDevice->uDiversityCnt++; + priv->uDiversityCnt++; - pDevice->uNumSQ3[byRxRate]++; + priv->uNumSQ3[byRxRate]++; - if (pDevice->byAntennaState == 0) { - if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) { + if (priv->byAntennaState == 0) { + if (priv->uDiversityCnt > priv->ulDiversityNValue) { pr_debug("ulDiversityNValue=[%d],54M-[%d]\n", - (int)pDevice->ulDiversityNValue, - (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate]); + (int)priv->ulDiversityNValue, + (int)priv->uNumSQ3[(int)priv->wAntDiversityMaxRate]); - if (pDevice->uNumSQ3[pDevice->wAntDiversityMaxRate] < pDevice->uDiversityCnt/2) { - pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); + if (priv->uNumSQ3[priv->wAntDiversityMaxRate] < priv->uDiversityCnt/2) { + priv->ulRatio_State0 = s_ulGetRatio(priv); pr_debug("SQ3_State0, rate = [%08x]\n", - (int)pDevice->ulRatio_State0); + (int)priv->ulRatio_State0); - if (pDevice->byTMax == 0) + if (priv->byTMax == 0) return; pr_debug("1.[%08x], uNumSQ3[%d]=%d, %d\n", - (int)pDevice->ulRatio_State0, - (int)pDevice->wAntDiversityMaxRate, - (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], - (int)pDevice->uDiversityCnt); - - s_vChangeAntenna(pDevice); - pDevice->byAntennaState = 1; - del_timer(&pDevice->TimerSQ3Tmax3); - del_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ); - add_timer(&pDevice->TimerSQ3Tmax1); + (int)priv->ulRatio_State0, + (int)priv->wAntDiversityMaxRate, + (int)priv->uNumSQ3[(int)priv->wAntDiversityMaxRate], + (int)priv->uDiversityCnt); + + s_vChangeAntenna(priv); + priv->byAntennaState = 1; + del_timer(&priv->TimerSQ3Tmax3); + del_timer(&priv->TimerSQ3Tmax2); + priv->TimerSQ3Tmax1.expires = RUN_AT(priv->byTMax * HZ); + add_timer(&priv->TimerSQ3Tmax1); } else { - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); + priv->TimerSQ3Tmax3.expires = RUN_AT(priv->byTMax3 * HZ); + add_timer(&priv->TimerSQ3Tmax3); } - BBvClearAntDivSQ3Value(pDevice); + BBvClearAntDivSQ3Value(priv); } } else { /* byAntennaState == 1 */ - if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) { - del_timer(&pDevice->TimerSQ3Tmax1); + if (priv->uDiversityCnt > priv->ulDiversityMValue) { + del_timer(&priv->TimerSQ3Tmax1); - pDevice->ulRatio_State1 = s_ulGetRatio(pDevice); + priv->ulRatio_State1 = s_ulGetRatio(priv); pr_debug("RX:SQ3_State1, rate0 = %08x,rate1 = %08x\n", - (int)pDevice->ulRatio_State0, - (int)pDevice->ulRatio_State1); + (int)priv->ulRatio_State0, + (int)priv->ulRatio_State1); - if (pDevice->ulRatio_State1 < pDevice->ulRatio_State0) { + if (priv->ulRatio_State1 < priv->ulRatio_State0) { pr_debug("2.[%08x][%08x], uNumSQ3[%d]=%d, %d\n", - (int)pDevice->ulRatio_State0, - (int)pDevice->ulRatio_State1, - (int)pDevice->wAntDiversityMaxRate, - (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], - (int)pDevice->uDiversityCnt); - - s_vChangeAntenna(pDevice); - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); + (int)priv->ulRatio_State0, + (int)priv->ulRatio_State1, + (int)priv->wAntDiversityMaxRate, + (int)priv->uNumSQ3[(int)priv->wAntDiversityMaxRate], + (int)priv->uDiversityCnt); + + s_vChangeAntenna(priv); + priv->TimerSQ3Tmax3.expires = RUN_AT(priv->byTMax3 * HZ); + priv->TimerSQ3Tmax2.expires = RUN_AT(priv->byTMax2 * HZ); + add_timer(&priv->TimerSQ3Tmax3); + add_timer(&priv->TimerSQ3Tmax2); } - pDevice->byAntennaState = 0; - BBvClearAntDivSQ3Value(pDevice); + priv->byAntennaState = 0; + BBvClearAntDivSQ3Value(priv); } } /* byAntennaState */ } @@ -2622,27 +2622,27 @@ TimerSQ3CallBack( unsigned long data ) { - struct vnt_private *pDevice = (struct vnt_private *)data; + struct vnt_private *priv = (struct vnt_private *)data; unsigned long flags; pr_debug("TimerSQ3CallBack...\n"); - spin_lock_irqsave(&pDevice->lock, flags); + spin_lock_irqsave(&priv->lock, flags); pr_debug("3.[%08x][%08x], %d\n", - (int)pDevice->ulRatio_State0, (int)pDevice->ulRatio_State1, - (int)pDevice->uDiversityCnt); + (int)priv->ulRatio_State0, (int)priv->ulRatio_State1, + (int)priv->uDiversityCnt); - s_vChangeAntenna(pDevice); - pDevice->byAntennaState = 0; - BBvClearAntDivSQ3Value(pDevice); + s_vChangeAntenna(priv); + priv->byAntennaState = 0; + BBvClearAntDivSQ3Value(priv); - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); + priv->TimerSQ3Tmax3.expires = RUN_AT(priv->byTMax3 * HZ); + priv->TimerSQ3Tmax2.expires = RUN_AT(priv->byTMax2 * HZ); + add_timer(&priv->TimerSQ3Tmax3); + add_timer(&priv->TimerSQ3Tmax2); - spin_unlock_irqrestore(&pDevice->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } /*+ @@ -2668,43 +2668,43 @@ TimerState1CallBack( unsigned long data ) { - struct vnt_private *pDevice = (struct vnt_private *)data; + struct vnt_private *priv = (struct vnt_private *)data; unsigned long flags; pr_debug("TimerState1CallBack...\n"); - spin_lock_irqsave(&pDevice->lock, flags); + spin_lock_irqsave(&priv->lock, flags); - if (pDevice->uDiversityCnt < pDevice->ulDiversityMValue/100) { - s_vChangeAntenna(pDevice); - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); + if (priv->uDiversityCnt < priv->ulDiversityMValue/100) { + s_vChangeAntenna(priv); + priv->TimerSQ3Tmax3.expires = RUN_AT(priv->byTMax3 * HZ); + priv->TimerSQ3Tmax2.expires = RUN_AT(priv->byTMax2 * HZ); + add_timer(&priv->TimerSQ3Tmax3); + add_timer(&priv->TimerSQ3Tmax2); } else { - pDevice->ulRatio_State1 = s_ulGetRatio(pDevice); + priv->ulRatio_State1 = s_ulGetRatio(priv); pr_debug("SQ3_State1, rate0 = %08x,rate1 = %08x\n", - (int)pDevice->ulRatio_State0, - (int)pDevice->ulRatio_State1); + (int)priv->ulRatio_State0, + (int)priv->ulRatio_State1); - if (pDevice->ulRatio_State1 < pDevice->ulRatio_State0) { + if (priv->ulRatio_State1 < priv->ulRatio_State0) { pr_debug("2.[%08x][%08x], uNumSQ3[%d]=%d, %d\n", - (int)pDevice->ulRatio_State0, - (int)pDevice->ulRatio_State1, - (int)pDevice->wAntDiversityMaxRate, - (int)pDevice->uNumSQ3[(int)pDevice->wAntDiversityMaxRate], - (int)pDevice->uDiversityCnt); - - s_vChangeAntenna(pDevice); - - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); + (int)priv->ulRatio_State0, + (int)priv->ulRatio_State1, + (int)priv->wAntDiversityMaxRate, + (int)priv->uNumSQ3[(int)priv->wAntDiversityMaxRate], + (int)priv->uDiversityCnt); + + s_vChangeAntenna(priv); + + priv->TimerSQ3Tmax3.expires = RUN_AT(priv->byTMax3 * HZ); + priv->TimerSQ3Tmax2.expires = RUN_AT(priv->byTMax2 * HZ); + add_timer(&priv->TimerSQ3Tmax3); + add_timer(&priv->TimerSQ3Tmax2); } } - pDevice->byAntennaState = 0; - BBvClearAntDivSQ3Value(pDevice); + priv->byAntennaState = 0; + BBvClearAntDivSQ3Value(priv); - spin_unlock_irqrestore(&pDevice->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } -- cgit v1.2.3-59-g8ed1b From deaa2c2021c2c00401933f84023bfc4c0a60e281 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Wed, 5 Nov 2014 17:58:11 +0900 Subject: staging: dgap: remove unnecessary function The dgap_init_global() initialize the dgap_board that is a global variable as static and dgap_poll_timer. But init_timer() is called twice in dgap_start() and dgap_board doesn't need to be initialized to NULL. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 293dc3320b3a..aa393d2941df 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -7018,23 +7018,6 @@ static struct pci_driver dgap_driver = { .remove = dgap_remove_one, }; -/* - * dgap_init_globals() - * - * This is where we initialize the globals from the static insmod - * configuration variables. These are declared near the head of - * this file. - */ -static void dgap_init_globals(void) -{ - unsigned int i; - - for (i = 0; i < MAXBOARDS; i++) - dgap_board[i] = NULL; - - init_timer(&dgap_poll_timer); -} - /* * Start of driver. */ @@ -7044,12 +7027,6 @@ static int dgap_start(void) unsigned long flags; struct device *device; - /* - * make sure that the globals are - * init'd before we do anything else - */ - dgap_init_globals(); - dgap_numboards = 0; pr_info("For the tools package please visit http://www.digi.com\n"); -- cgit v1.2.3-59-g8ed1b From f80bdc281e670d17cf68b556bc566f5c447a7555 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Tue, 4 Nov 2014 23:43:07 +0200 Subject: staging: media: lirc: modify print calls This patches replaces one pr_debug call by dev_dbg and changes the device used by one of the dev_err calls. Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_zilog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index 52f8e91a6383..dca806aa439f 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c @@ -1447,7 +1447,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) int ret; bool tx_probe = false; - pr_debug("%s: %s on i2c-%d (%s), client addr=0x%02x\n", + dev_dbg(&client->dev, "%s: %s on i2c-%d (%s), client addr=0x%02x\n", __func__, id->name, adap->nr, adap->name, client->addr); /* @@ -1631,7 +1631,7 @@ out_put_xx: out_put_ir: put_ir_device(ir, true); out_no_ir: - dev_err(ir->l.dev, "%s: probing IR %s on %s (i2c-%d) failed with %d\n", + dev_err(&client->dev, "%s: probing IR %s on %s (i2c-%d) failed with %d\n", __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr, ret); mutex_unlock(&ir_devices_lock); -- cgit v1.2.3-59-g8ed1b From 20f083c07565cb75a5f04e97acfc8faff2b13101 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 4 Nov 2014 18:09:00 +0000 Subject: staging: comedi: prepare support for per-file read and write subdevices Comedi devices may have several subdevices that support "read" and/or "write" asynchronous commands that use the "read" or "write" file operations for data transfer. The low-level Comedi drivers may nominate a default "read" subdevice and/or a default "write" subdevice, but it may have other subdevices that support asynchronous commands. The Comedi core provides a somewhat clunky mechanism to provide access to the asynchronous command support of the non-default subdevices. When a low-level device is "attached" to a core Comedi device, it dynamically allocates a minor device number for each of the subdevices that support asynchrounous commands and associates them with files created in SysFS named "comediX_subdY", where "X" is the minor device number of the main comedi device, and "Y" is the subdevice number. An application can open these subdevice-specific files and they behave like the regular "comediX" files except that the "read" and/or "write" subdevice may be different to the default chosen by the low-level driver. This patch adds a layer of indirection between the file object and the comedi device object to allow the current "read" and/or "write" subdevice to be altered after opening the Comedi device, on a per-file object basis. The advantage is that an application only needs to open the main Comedi device file and can then choose which subdevice it wants to "read" or "write". The main Comedi device file can be opened more than once, and each file object can choose the "read" and "write" subdevices independently. The new `struct comedi_file` is created on "open" and freed on "release". It includes pointers to the main Comedi device structure, and to the current "read" and "write" subdevice structures (which may be NULL). It also has information to keep track of when a low-level device has been attached or detached since the previous time the file object was used. In that case, the current "read" and "write" subdevices in the `struct comedi_file` will be changed to the new defaults (or set to NULL). (The change to new defaults is done by `comedi_file_reset()`. The checking for attach/detach is done by `comedi_file_check()` which will call `comedi_file_reset()` if there have been any attach/detach operations since the previous call.) A subsequent patch will add the ioctls to change the current "read" and "write" subdevices. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 127 ++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 65894fd8b67b..79b852c6d868 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -43,6 +43,22 @@ #include "comedi_internal.h" +/** + * struct comedi_file - per-file private data for comedi device + * @dev: comedi_device struct + * @read_subdev: current "read" subdevice + * @write_subdev: current "write" subdevice + * @last_detach_count: last known detach count + * @last_attached: last known attached/detached state + */ +struct comedi_file { + struct comedi_device *dev; + struct comedi_subdevice *read_subdev; + struct comedi_subdevice *write_subdev; + unsigned int last_detach_count; + bool last_attached:1; +}; + #define COMEDI_NUM_MINORS 0x100 #define COMEDI_NUM_SUBDEVICE_MINORS \ (COMEDI_NUM_MINORS - COMEDI_NUM_BOARD_MINORS) @@ -239,6 +255,54 @@ comedi_write_subdevice(const struct comedi_device *dev, unsigned int minor) return dev->write_subdev; } +static void comedi_file_reset(struct file *file) +{ + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; + struct comedi_subdevice *s, *read_s, *write_s; + unsigned int minor = iminor(file_inode(file)); + + read_s = dev->read_subdev; + write_s = dev->write_subdev; + if (minor >= COMEDI_NUM_BOARD_MINORS) { + s = comedi_subdevice_from_minor(dev, minor); + if (s == NULL || s->subdev_flags & SDF_CMD_READ) + read_s = s; + if (s == NULL || s->subdev_flags & SDF_CMD_WRITE) + write_s = s; + } + cfp->last_attached = dev->attached; + cfp->last_detach_count = dev->detach_count; + ACCESS_ONCE(cfp->read_subdev) = read_s; + ACCESS_ONCE(cfp->write_subdev) = write_s; +} + +static void comedi_file_check(struct file *file) +{ + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; + + if (cfp->last_attached != dev->attached || + cfp->last_detach_count != dev->detach_count) + comedi_file_reset(file); +} + +static struct comedi_subdevice *comedi_file_read_subdevice(struct file *file) +{ + struct comedi_file *cfp = file->private_data; + + comedi_file_check(file); + return ACCESS_ONCE(cfp->read_subdev); +} + +static struct comedi_subdevice *comedi_file_write_subdevice(struct file *file) +{ + struct comedi_file *cfp = file->private_data; + + comedi_file_check(file); + return ACCESS_ONCE(cfp->write_subdev); +} + static int resize_async_buffer(struct comedi_device *dev, struct comedi_subdevice *s, unsigned new_size) { @@ -776,7 +840,6 @@ static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo __user *arg, struct file *file) { - const unsigned minor = iminor(file_inode(file)); struct comedi_subdevice *s; struct comedi_devinfo devinfo; @@ -788,13 +851,13 @@ static int do_devinfo_ioctl(struct comedi_device *dev, strlcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN); strlcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN); - s = comedi_read_subdevice(dev, minor); + s = comedi_file_read_subdevice(file); if (s) devinfo.read_subdevice = s->index; else devinfo.read_subdevice = -1; - s = comedi_write_subdevice(dev, minor); + s = comedi_file_write_subdevice(file); if (s) devinfo.write_subdevice = s->index; else @@ -1787,8 +1850,9 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned long arg, static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - const unsigned minor = iminor(file_inode(file)); - struct comedi_device *dev = file->private_data; + unsigned minor = iminor(file_inode(file)); + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; int rc; mutex_lock(&dev->mutex); @@ -1910,8 +1974,8 @@ static struct vm_operations_struct comedi_vm_ops = { static int comedi_mmap(struct file *file, struct vm_area_struct *vma) { - const unsigned minor = iminor(file_inode(file)); - struct comedi_device *dev = file->private_data; + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; struct comedi_subdevice *s; struct comedi_async *async; struct comedi_buf_map *bm = NULL; @@ -1937,9 +2001,9 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) } if (vma->vm_flags & VM_WRITE) - s = comedi_write_subdevice(dev, minor); + s = comedi_file_write_subdevice(file); else - s = comedi_read_subdevice(dev, minor); + s = comedi_file_read_subdevice(file); if (!s) { retval = -EINVAL; goto done; @@ -2002,8 +2066,8 @@ done: static unsigned int comedi_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; - const unsigned minor = iminor(file_inode(file)); - struct comedi_device *dev = file->private_data; + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; struct comedi_subdevice *s; mutex_lock(&dev->mutex); @@ -2013,7 +2077,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) goto done; } - s = comedi_read_subdevice(dev, minor); + s = comedi_file_read_subdevice(file); if (s && s->async) { poll_wait(file, &s->async->wait_head, wait); if (!s->busy || !comedi_is_subdevice_running(s) || @@ -2022,7 +2086,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) mask |= POLLIN | POLLRDNORM; } - s = comedi_write_subdevice(dev, minor); + s = comedi_file_write_subdevice(file); if (s && s->async) { unsigned int bps = comedi_bytes_per_sample(s); @@ -2046,8 +2110,8 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, struct comedi_async *async; int n, m, count = 0, retval = 0; DECLARE_WAITQUEUE(wait, current); - const unsigned minor = iminor(file_inode(file)); - struct comedi_device *dev = file->private_data; + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; bool on_wait_queue = false; bool attach_locked; unsigned int old_detach_count; @@ -2063,7 +2127,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, goto out; } - s = comedi_write_subdevice(dev, minor); + s = comedi_file_write_subdevice(file); if (!s || !s->async) { retval = -EIO; goto out; @@ -2115,7 +2179,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, * meantime!), but check the subdevice pointer * as well just in case. */ - new_s = comedi_write_subdevice(dev, minor); + new_s = comedi_file_write_subdevice(file); if (dev->attached && old_detach_count == dev->detach_count && s == new_s && new_s->async == async) @@ -2190,8 +2254,8 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, struct comedi_async *async; int n, m, count = 0, retval = 0; DECLARE_WAITQUEUE(wait, current); - const unsigned minor = iminor(file_inode(file)); - struct comedi_device *dev = file->private_data; + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; unsigned int old_detach_count; bool become_nonbusy = false; bool attach_locked; @@ -2207,7 +2271,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, goto out; } - s = comedi_read_subdevice(dev, minor); + s = comedi_file_read_subdevice(file); if (!s || !s->async) { retval = -EIO; goto out; @@ -2304,7 +2368,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, * meantime!), but check the subdevice pointer as well just in * case. */ - new_s = comedi_read_subdevice(dev, minor); + new_s = comedi_file_read_subdevice(file); if (dev->attached && old_detach_count == dev->detach_count && s == new_s && new_s->async == async) { if (become_nonbusy || comedi_buf_n_bytes_ready(s) == 0) @@ -2322,6 +2386,7 @@ out: static int comedi_open(struct inode *inode, struct file *file) { const unsigned minor = iminor(inode); + struct comedi_file *cfp; struct comedi_device *dev = comedi_dev_get_from_minor(minor); int rc; @@ -2330,6 +2395,12 @@ static int comedi_open(struct inode *inode, struct file *file) return -ENODEV; } + cfp = kzalloc(sizeof(*cfp), GFP_KERNEL); + if (!cfp) + return -ENOMEM; + + cfp->dev = dev; + mutex_lock(&dev->mutex); if (!dev->attached && !capable(CAP_NET_ADMIN)) { dev_dbg(dev->class_dev, "not attached and not CAP_NET_ADMIN\n"); @@ -2351,26 +2422,31 @@ static int comedi_open(struct inode *inode, struct file *file) } dev->use_count++; - file->private_data = dev; + file->private_data = cfp; + comedi_file_reset(file); rc = 0; out: mutex_unlock(&dev->mutex); - if (rc) + if (rc) { comedi_dev_put(dev); + kfree(cfp); + } return rc; } static int comedi_fasync(int fd, struct file *file, int on) { - struct comedi_device *dev = file->private_data; + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; return fasync_helper(fd, file, on, &dev->async_queue); } static int comedi_close(struct inode *inode, struct file *file) { - struct comedi_device *dev = file->private_data; + struct comedi_file *cfp = file->private_data; + struct comedi_device *dev = cfp->dev; struct comedi_subdevice *s = NULL; int i; @@ -2396,6 +2472,7 @@ static int comedi_close(struct inode *inode, struct file *file) mutex_unlock(&dev->mutex); comedi_dev_put(dev); + kfree(cfp); return 0; } -- cgit v1.2.3-59-g8ed1b From c299a6789c35392dcd66f806013bab86969cf5c4 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 4 Nov 2014 18:09:01 +0000 Subject: staging: comedi: add ioctls to set per-file read and write subdevice Now that Comedi has the structures in place to support setting the current "read" and/or "write" subdevice on a per-file object basis, add new ioctls to set them. The newly chosen "read" ("write") subdevice needs to support "read" ("write") commands, and the file cannot be busy handling a "read" ("write") command on the previous subdevice (if any). Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi.h | 2 + drivers/staging/comedi/comedi_compat32.c | 2 + drivers/staging/comedi/comedi_fops.c | 90 ++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index f302ce6c93de..745574077352 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -367,6 +367,8 @@ enum comedi_support_level { #define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig) #define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo) #define COMEDI_POLL _IO(CIO, 15) +#define COMEDI_SETRSUBD _IO(CIO, 16) +#define COMEDI_SETWSUBD _IO(CIO, 17) /* structures */ diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c index 9b6f96f1591c..5a4c74f703b3 100644 --- a/drivers/staging/comedi/comedi_compat32.c +++ b/drivers/staging/comedi/comedi_compat32.c @@ -416,6 +416,8 @@ static inline int raw_ioctl(struct file *file, unsigned int cmd, case COMEDI_UNLOCK: case COMEDI_CANCEL: case COMEDI_POLL: + case COMEDI_SETRSUBD: + case COMEDI_SETWSUBD: /* No translation needed. */ rc = translated_ioctl(file, cmd, arg); break; diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 79b852c6d868..f143cb64d69e 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1847,6 +1847,90 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned long arg, return -EINVAL; } +/* + * COMEDI_SETRSUBD ioctl + * sets the current "read" subdevice on a per-file basis + * + * arg: + * subdevice number + * + * reads: + * nothing + * + * writes: + * nothing + */ +static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg, + struct file *file) +{ + struct comedi_file *cfp = file->private_data; + struct comedi_subdevice *s_old, *s_new; + + if (arg >= dev->n_subdevices) + return -EINVAL; + + s_new = &dev->subdevices[arg]; + s_old = comedi_file_read_subdevice(file); + if (s_old == s_new) + return 0; /* no change */ + + if (!(s_new->subdev_flags & SDF_CMD_READ)) + return -EINVAL; + + /* + * Check the file isn't still busy handling a "read" command on the + * old subdevice (if any). + */ + if (s_old && s_old->busy == file && s_old->async && + !(s_old->async->cmd.flags & CMDF_WRITE)) + return -EBUSY; + + ACCESS_ONCE(cfp->read_subdev) = s_new; + return 0; +} + +/* + * COMEDI_SETWSUBD ioctl + * sets the current "write" subdevice on a per-file basis + * + * arg: + * subdevice number + * + * reads: + * nothing + * + * writes: + * nothing + */ +static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg, + struct file *file) +{ + struct comedi_file *cfp = file->private_data; + struct comedi_subdevice *s_old, *s_new; + + if (arg >= dev->n_subdevices) + return -EINVAL; + + s_new = &dev->subdevices[arg]; + s_old = comedi_file_write_subdevice(file); + if (s_old == s_new) + return 0; /* no change */ + + if (!(s_new->subdev_flags & SDF_CMD_WRITE)) + return -EINVAL; + + /* + * Check the file isn't still busy handling a "write" command on the + * old subdevice (if any). + */ + if (s_old && s_old->busy == file && s_old->async && + (s_old->async->cmd.flags & CMDF_WRITE)) + return -EBUSY; + + ACCESS_ONCE(cfp->write_subdev) = s_new; + return 0; +} + static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -1941,6 +2025,12 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, case COMEDI_POLL: rc = do_poll_ioctl(dev, arg, file); break; + case COMEDI_SETRSUBD: + rc = do_setrsubd_ioctl(dev, arg, file); + break; + case COMEDI_SETWSUBD: + rc = do_setwsubd_ioctl(dev, arg, file); + break; default: rc = -ENOTTY; break; -- cgit v1.2.3-59-g8ed1b From 9b505647bf995bb2a11ad361f6d4799e05b3478e Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 4 Nov 2014 11:52:48 +0100 Subject: staging: imx-drm: remove old FSF address from license text Linux already includes a copy of the GPL, checkpatch compains about the address. Remove it from the license text. Signed-off-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-ldb.c | 5 ----- drivers/staging/imx-drm/imx-tve.c | 5 ----- drivers/staging/imx-drm/ipuv3-crtc.c | 5 ----- drivers/staging/imx-drm/parallel-display.c | 5 ----- 4 files changed, 20 deletions(-) diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index 4662e00b456a..4caa8bfe3e17 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -11,11 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. */ #include diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index f22b2ac4627e..5c436f77dd13 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -11,11 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. */ #include diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 11e84a251773..ebee59cb96d8 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -11,11 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. */ #include #include diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index ac89a18b8332..803b14c69c7d 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -11,11 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. */ #include -- cgit v1.2.3-59-g8ed1b From 54fbb2da8d4cef4f57d0cf70b84471dd61a7af5f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 4 Nov 2014 14:49:46 +0000 Subject: staging: vt6655: change tx wake queue Wake queue in the dwIsr loop of device_intr instead of device_tx_srv. This fixes an issue when ISR_TXDMA0 or ISR_AC0DMA does not occur device_tx_srv is not called and the queue gets stuck in stopped condition. On test if the queue is stuck another MACvTransmitAC0 or MACvTransmit0 in vnt_tx_packet will clear it. Check on vif that both buffers are available and the queue is stopped. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 00eb89a27925..5fc6022badb2 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1014,10 +1014,6 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) } device_free_tx_buf(pDevice, pTD); pDevice->iTDUsed[uIdx]--; - - /* Make sure queue is available */ - if (AVAIL_TD(pDevice, uIdx)) - ieee80211_wake_queues(pDevice->hw); } } @@ -1190,6 +1186,14 @@ static irqreturn_t device_intr(int irq, void *dev_instance) } } + /* If both buffers available wake the queue */ + if (pDevice->vif) { + if (AVAIL_TD(pDevice, TYPE_TXDMA0) && + AVAIL_TD(pDevice, TYPE_AC0DMA) && + ieee80211_queue_stopped(pDevice->hw, 0)) + ieee80211_wake_queues(pDevice->hw); + } + MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); MACvReceive0(pDevice->PortOffset); -- cgit v1.2.3-59-g8ed1b From f4757af8516d95aaf9c6a1238887c34914e54622 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Tue, 4 Nov 2014 22:47:19 +0100 Subject: staging: panel: Fix single-open policy race condition Fix the implementation of a single-open policy for both devices (lcd and keypad) by using atomic_t instead of plain ints. Signed-off-by: Mariusz Gorski Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 98556ce8af6a..d30ccb594785 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -404,8 +404,11 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #endif /* DEFAULT_PROFILE == 0 */ /* global variables */ -static int keypad_open_cnt; /* #times opened */ -static int lcd_open_cnt; /* #times opened */ + +/* Device single-open policy control */ +static atomic_t lcd_available = ATOMIC_INIT(1); +static atomic_t keypad_available = ATOMIC_INIT(1); + static struct pardevice *pprt; static int lcd_initialized; @@ -1347,7 +1350,7 @@ static ssize_t lcd_write(struct file *file, static int lcd_open(struct inode *inode, struct file *file) { - if (lcd_open_cnt) + if (!atomic_dec_and_test(&lcd_available)) return -EBUSY; /* open only once at a time */ if (file->f_mode & FMODE_READ) /* device is write-only */ @@ -1357,13 +1360,12 @@ static int lcd_open(struct inode *inode, struct file *file) lcd_clear_display(); lcd_must_clear = 0; } - lcd_open_cnt++; return nonseekable_open(inode, file); } static int lcd_release(struct inode *inode, struct file *file) { - lcd_open_cnt--; + atomic_inc(&lcd_available); return 0; } @@ -1627,20 +1629,19 @@ static ssize_t keypad_read(struct file *file, static int keypad_open(struct inode *inode, struct file *file) { - if (keypad_open_cnt) + if (!atomic_dec_and_test(&keypad_available)) return -EBUSY; /* open only once at a time */ if (file->f_mode & FMODE_WRITE) /* device is read-only */ return -EPERM; keypad_buflen = 0; /* flush the buffer on opening */ - keypad_open_cnt++; return 0; } static int keypad_release(struct inode *inode, struct file *file) { - keypad_open_cnt--; + atomic_inc(&keypad_available); return 0; } @@ -1663,7 +1664,7 @@ static void keypad_send_key(const char *string, int max_len) return; /* send the key to the device only if a process is attached to it. */ - if (keypad_open_cnt > 0) { + if (!atomic_read(&keypad_available)) { while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) { keypad_buffer[(keypad_start + keypad_buflen++) % KEYPAD_BUFFER] = *string++; -- cgit v1.2.3-59-g8ed1b From 1dacbe5b26268fd3eaa6dad41271d296b072f3df Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:52 -0700 Subject: staging: comedi: comedidev.h: add 'scans_done' member to comedi_async Introduce a new member to comedi_async to count the number of scans completed. This member is cleared by comedi_buf_reset() along with the other comedi_async members. It is incremented in comedi_inc_scan_progress() when the end of scan is detected. This member will be used to clean up the scan counting in the comedi drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 1 + drivers/staging/comedi/comedidev.h | 2 ++ drivers/staging/comedi/drivers.c | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index eb3fecf85b6d..19e7b229d15e 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -236,6 +236,7 @@ void comedi_buf_reset(struct comedi_subdevice *s) async->buf_read_ptr = 0; async->cur_chan = 0; + async->scans_done = 0; async->scan_progress = 0; async->munge_chan = 0; async->munge_count = 0; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 90af11aaef7e..bff5a581a287 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -121,6 +121,7 @@ struct comedi_buf_map { * @buf_read_ptr: buffer position for reader * @cur_chan: current position in chanlist for scan (for those * drivers that use it) + * @scans_done: the number of scans completed (COMEDI_CB_EOS) * @scan_progress: amount received or sent for current scan (in bytes) * @munge_chan: current position in chanlist for "munging" * @munge_count: "munge" count (in bytes, modulo 2**32) @@ -201,6 +202,7 @@ struct comedi_async { unsigned int buf_write_ptr; unsigned int buf_read_ptr; unsigned int cur_chan; + unsigned int scans_done; unsigned int scan_progress; unsigned int munge_chan; unsigned int munge_count; diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 9a8c5fc8e8fe..02a01baf5cc6 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -352,6 +352,13 @@ void comedi_inc_scan_progress(struct comedi_subdevice *s, async->scan_progress += num_bytes; if (async->scan_progress >= scan_length) { + unsigned int nscans = async->scan_progress / scan_length; + + if (async->scans_done < (UINT_MAX - nscans)) + async->scans_done += nscans; + else + async->scans_done = UINT_MAX; + async->scan_progress %= scan_length; async->events |= COMEDI_CB_EOS; } -- cgit v1.2.3-59-g8ed1b From d1c87ceb441c3328cc1d0c18e07f5aeaa446306f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:53 -0700 Subject: staging: comedi: addi_apci_2032: use comedi_async 'scans_done' to detect EOA Remove the private data member 'stop_count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_2032.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index fb20c5ea90b8..eebf4f151b39 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -47,7 +47,6 @@ struct apci2032_int_private { spinlock_t spinlock; - unsigned int stop_count; bool active; unsigned char enabled_isns; }; @@ -148,7 +147,6 @@ static int apci2032_int_cmd(struct comedi_device *dev, spin_lock_irqsave(&subpriv->spinlock, flags); subpriv->enabled_isns = enabled_isns; - subpriv->stop_count = cmd->stop_arg; subpriv->active = true; outl(enabled_isns, dev->iobase + APCI2032_INT_CTRL_REG); @@ -211,16 +209,11 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) bits |= (1 << i); } - if (comedi_buf_write_samples(s, &bits, 1)) { - if (cmd->stop_src == TRIG_COUNT && - subpriv->stop_count > 0) { - subpriv->stop_count--; - if (subpriv->stop_count == 0) { - /* end of acquisition */ - s->async->events |= COMEDI_CB_EOA; - } - } - } + comedi_buf_write_samples(s, &bits, 1); + + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; } spin_unlock(&subpriv->spinlock); -- cgit v1.2.3-59-g8ed1b From e268240387ffd868286d81848e38260c597e018e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:54 -0700 Subject: staging: comedi: amplc_dio200_common: use comedi_async 'scans_done' to detect EOA Remove the private data member 'stopcount' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index c306226790bf..26aad705aad3 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -120,7 +120,6 @@ struct dio200_subdev_intr { unsigned int ofs; unsigned int valid_isns; unsigned int enabled_isns; - unsigned int stopcount; bool active:1; }; @@ -256,7 +255,6 @@ static void dio200_read_scan_intr(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int triggered) { - struct dio200_subdev_intr *subpriv = s->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned short val; unsigned int n, ch; @@ -270,14 +268,9 @@ static void dio200_read_scan_intr(struct comedi_device *dev, comedi_buf_write_samples(s, &val, 1); - /* Check for end of acquisition. */ - if (cmd->stop_src == TRIG_COUNT) { - if (subpriv->stopcount > 0) { - subpriv->stopcount--; - if (subpriv->stopcount == 0) - s->async->events |= COMEDI_CB_EOA; - } - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; } static int dio200_handle_read_intr(struct comedi_device *dev, @@ -424,7 +417,6 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev, spin_lock_irqsave(&subpriv->spinlock, flags); subpriv->active = true; - subpriv->stopcount = cmd->stop_arg; if (cmd->start_src == TRIG_INT) s->async->inttrig = dio200_inttrig_start_intr; -- cgit v1.2.3-59-g8ed1b From 8712f901c9952bbad52e499fe350434294efbcff Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:55 -0700 Subject: staging: comedi: pcl711: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ntrig' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 48a79b8221fc..93fa4b8ddf15 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -156,7 +156,6 @@ static const struct pcl711_board boardtypes[] = { }; struct pcl711_private { - unsigned int ntrig; unsigned int divisor1; unsigned int divisor2; }; @@ -199,7 +198,6 @@ static int pcl711_ai_cancel(struct comedi_device *dev, static irqreturn_t pcl711_interrupt(int irq, void *d) { struct comedi_device *dev = d; - struct pcl711_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; unsigned int data; @@ -213,10 +211,12 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); - if (comedi_buf_write_samples(s, &data, 1)) { - if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig)) - s->async->events |= COMEDI_CB_EOA; - } + comedi_buf_write_samples(s, &data, 1); + + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; + comedi_handle_events(dev, s); return IRQ_HANDLED; @@ -369,14 +369,10 @@ static void pcl711_ai_load_counters(struct comedi_device *dev) static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pcl711_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; pcl711_set_changain(dev, s, cmd->chanlist[0]); - if (cmd->stop_src == TRIG_COUNT) - devpriv->ntrig = cmd->stop_arg; - if (cmd->scan_begin_src == TRIG_TIMER) { pcl711_ai_load_counters(dev); outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); -- cgit v1.2.3-59-g8ed1b From 5f6da288e3cc03fb50d8eadfdb3d6ed0a8467df7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:56 -0700 Subject: staging: comedi: pcl812: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_act_scan' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index b13e9fb7a12e..c3499aa47dee 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -512,7 +512,6 @@ struct pcl812_private { unsigned int last_ai_chanspec; unsigned char mode_reg_int; /* there is stored INT number for some card */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ - unsigned int ai_act_scan; /* how many scans we finished */ unsigned int dmapages; unsigned int hwdmasize; unsigned long dmabuf[2]; /* PTR to DMA buf */ @@ -807,7 +806,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_dma = 0; } - devpriv->ai_act_scan = 0; devpriv->ai_poll_ptr = 0; /* don't we want wake up every scan? */ @@ -840,15 +838,10 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static bool pcl812_ai_next_chan(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pcl812_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - if (s->async->cur_chan == 0) - devpriv->ai_act_scan++; - if (cmd->stop_src == TRIG_COUNT && - devpriv->ai_act_scan >= cmd->stop_arg) { - /* all data sampled */ + s->async->scans_done >= cmd->stop_arg) { s->async->events |= COMEDI_CB_EOA; return false; } -- cgit v1.2.3-59-g8ed1b From 64886498b2e83e9f443c4ce37398f0b1481cc966 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:57 -0700 Subject: staging: comedi: pcl816: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_act_scan' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. 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 7cdb79826213..73deb4bd5c93 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -122,7 +122,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 */ - int ai_act_scan; /* how many scans we finished */ unsigned int ai_poll_ptr; /* how many sampes transfer poll */ unsigned int divisor1; unsigned int divisor2; @@ -286,15 +285,10 @@ static int pcl816_ai_eoc(struct comedi_device *dev, static bool pcl816_ai_next_chan(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pcl816_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - if (s->async->cur_chan == 0) - devpriv->ai_act_scan++; - if (cmd->stop_src == TRIG_COUNT && - devpriv->ai_act_scan >= cmd->stop_arg) { - /* all data sampled */ + s->async->scans_done >= cmd->stop_arg) { s->async->events |= COMEDI_CB_EOA; return false; } @@ -504,7 +498,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) pcl816_ai_setup_chanlist(dev, cmd->chanlist, seglen); udelay(1); - devpriv->ai_act_scan = 0; devpriv->ai_cmd_running = 1; devpriv->ai_poll_ptr = 0; devpriv->ai_cmd_canceled = 0; -- cgit v1.2.3-59-g8ed1b From 42dafac3a5302dd4165a5532a99bbdc4b39b1b94 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:58 -0700 Subject: staging: comedi: pcl818: remove private data member 'ai_act_chan' This member of the private data is set to '0' but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/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 dc2715ae6b18..d219e04468c7 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -314,7 +314,6 @@ struct pcl818_private { 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 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 */ unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */ @@ -824,7 +823,6 @@ static int pcl818_ai_cmd(struct comedi_device *dev, devpriv->ai_data_len = s->async->prealloc_bufsz; devpriv->ai_act_scan = cmd->stop_arg; - devpriv->ai_act_chan = 0; devpriv->ai_cmd_running = 1; devpriv->ai_cmd_canceled = 0; devpriv->act_chanlist_pos = 0; -- cgit v1.2.3-59-g8ed1b From c76844e1ffd7504b6f5b9a356ac3d3d230eed8db Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:20:59 -0700 Subject: staging: comedi: pcl818: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_act_scan' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. 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, 6 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index d219e04468c7..f1e0f36424e9 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -313,7 +313,6 @@ struct pcl818_private { unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */ 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 ai_act_scan; /* how many scans we finished */ 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 */ @@ -524,11 +523,8 @@ static bool pcl818_ai_next_chan(struct comedi_device *dev, if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len) devpriv->act_chanlist_pos = 0; - if (s->async->cur_chan == 0) - devpriv->ai_act_scan--; - - if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan == 0) { - /* all data sampled */ + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) { s->async->events |= COMEDI_CB_EOA; return false; } @@ -635,6 +631,7 @@ static irqreturn_t pcl818_interrupt(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; if (!dev->attached || !devpriv->ai_cmd_running) { pcl818_ai_clear_eoc(dev); @@ -648,7 +645,7 @@ static irqreturn_t pcl818_interrupt(int irq, void *d) * being reprogrammed while a DMA transfer is in * progress. */ - devpriv->ai_act_scan = 0; + s->async->scans_done = cmd->stop_arg; s->cancel(dev, s); return IRQ_HANDLED; } @@ -822,7 +819,6 @@ static int pcl818_ai_cmd(struct comedi_device *dev, pcl818_ai_setup_chanlist(dev, cmd->chanlist, seglen); devpriv->ai_data_len = s->async->prealloc_bufsz; - devpriv->ai_act_scan = cmd->stop_arg; devpriv->ai_cmd_running = 1; devpriv->ai_cmd_canceled = 0; devpriv->act_chanlist_pos = 0; @@ -865,7 +861,8 @@ static int pcl818_ai_cancel(struct comedi_device *dev, if (devpriv->dma) { if (cmd->stop_src == TRIG_NONE || - (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan > 0)) { + (cmd->stop_src == TRIG_COUNT && + s->async->scans_done < cmd->stop_arg)) { if (!devpriv->ai_cmd_canceled) { /* * Wait for running dma transfer to end, -- cgit v1.2.3-59-g8ed1b From f831de1023d981859870b073796308c25295926c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:00 -0700 Subject: staging: comedi: adv_pci1710: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_act_scan' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 107a0f137eaf..d02df7d0c629 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -298,7 +298,6 @@ static const struct boardtype boardtypes[] = { struct pci1710_private { unsigned int CntrlReg; /* Control register */ - unsigned int ai_act_scan; /* how many scans we finished */ unsigned char ai_et; unsigned int ai_et_CntrlReg; unsigned int ai_et_MuxVal; @@ -730,15 +729,12 @@ static int pci171x_ai_cancel(struct comedi_device *dev, break; } - devpriv->ai_act_scan = 0; - return 0; } static void pci1710_handle_every_sample(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned int status; unsigned int val; @@ -772,14 +768,10 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, val &= s->maxdata; comedi_buf_write_samples(s, &val, 1); - if (s->async->cur_chan == 0) { /* one scan done */ - devpriv->ai_act_scan++; - if (cmd->stop_src == TRIG_COUNT && - devpriv->ai_act_scan >= cmd->stop_arg) { - /* all data sampled */ - s->async->events |= COMEDI_CB_EOA; - break; - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) { + s->async->events |= COMEDI_CB_EOA; + break; } } @@ -794,7 +786,6 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s, int n, int turn) { - struct pci1710_private *devpriv = dev->private; unsigned int val; int ret; int i; @@ -810,9 +801,6 @@ static int move_block_from_fifo(struct comedi_device *dev, val &= s->maxdata; comedi_buf_write_samples(s, &val, 1); - - if (s->async->cur_chan == 0) - devpriv->ai_act_scan++; } return 0; } @@ -821,7 +809,6 @@ static void pci1710_handle_fifo(struct comedi_device *dev, struct comedi_subdevice *s) { const struct boardtype *this_board = dev->board_ptr; - struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned int nsamples; unsigned int m; @@ -855,8 +842,7 @@ static void pci1710_handle_fifo(struct comedi_device *dev, } if (cmd->stop_src == TRIG_COUNT && - devpriv->ai_act_scan >= cmd->stop_arg) { - /* all data sampled */ + s->async->scans_done >= cmd->stop_arg) { s->async->events |= COMEDI_CB_EOA; comedi_handle_events(dev, s); return; @@ -921,8 +907,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); - devpriv->ai_act_scan = 0; - devpriv->CntrlReg &= Control_CNT0; if ((cmd->flags & CMDF_WAKE_EOS) == 0) devpriv->CntrlReg |= Control_ONEFH; -- cgit v1.2.3-59-g8ed1b From 09959d658ce9049579561c7cb6acedaae74f5222 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:01 -0700 Subject: staging: comedi: pcmmio: use comedi_async 'scans_done' to detect EOA Remove the private data member 'count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index df47967c2650..985fabd879aa 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -190,7 +190,6 @@ struct pcmmio_private { spinlock_t pagelock; /* protects the page registers */ spinlock_t spinlock; /* protects the member variables */ unsigned int enabled_mask; - unsigned int stop_count; unsigned int active:1; }; @@ -358,12 +357,9 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, comedi_buf_write_samples(s, &val, 1); - /* Check for end of acquisition. */ - if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count > 0) { - devpriv->stop_count--; - if (devpriv->stop_count == 0) - s->async->events |= COMEDI_CB_EOA; - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; done: spin_unlock_irqrestore(&devpriv->spinlock, flags); @@ -468,8 +464,6 @@ static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) spin_lock_irqsave(&devpriv->spinlock, flags); devpriv->active = 1; - devpriv->stop_count = cmd->stop_arg; - /* Set up start of acquisition. */ if (cmd->start_src == TRIG_INT) s->async->inttrig = pcmmio_inttrig_start_intr; -- cgit v1.2.3-59-g8ed1b From b03130b649840f5a25941a7e8ae78dea6d750c85 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:02 -0700 Subject: staging: comedi: pcmuio: use comedi_async 'scans_done' to detect EOA Remove the private data member 'stop_count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmuio.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 18c2ac28e34a..0f5483b6147f 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -130,7 +130,6 @@ struct pcmuio_asic { spinlock_t pagelock; /* protects the page registers */ spinlock_t spinlock; /* protects member variables */ unsigned int enabled_mask; - unsigned int stop_count; unsigned int active:1; }; @@ -338,14 +337,9 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, comedi_buf_write_samples(s, &val, 1); - /* Check for end of acquisition. */ - if (cmd->stop_src == TRIG_COUNT) { - if (chip->stop_count > 0) { - chip->stop_count--; - if (chip->stop_count == 0) - s->async->events |= COMEDI_CB_EOA; - } - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; done: spin_unlock_irqrestore(&chip->spinlock, flags); @@ -474,8 +468,6 @@ static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) spin_lock_irqsave(&chip->spinlock, flags); chip->active = 1; - chip->stop_count = cmd->stop_arg; - /* Set up start of acquisition. */ if (cmd->start_src == TRIG_INT) s->async->inttrig = pcmuio_inttrig_start_intr; -- cgit v1.2.3-59-g8ed1b From aee15aea0d8e879ec22142491611d98ab987d2ba Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:03 -0700 Subject: staging: comedi: s626: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_sample_count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Also, remove the unnecessary COMEDI_CB_EOS event. The core automatically detects and adds that event. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 6976bb098f54..fc7d8a572bf3 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -78,7 +78,6 @@ struct s626_buffer_dma { struct s626_private { uint8_t ai_cmd_running; /* ai_cmd is running */ - int ai_sample_count; /* number of samples to acquire */ unsigned int ai_sample_timer; /* time between samples in * units of the timer */ int ai_convert_count; /* conversion counter */ @@ -1496,16 +1495,11 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev) comedi_buf_write_samples(s, &tempdata, 1); } - /* end of scan occurs */ - async->events |= COMEDI_CB_EOS; + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ai_sample_count--; - if (devpriv->ai_sample_count <= 0) { - devpriv->ai_cmd_running = 0; - async->events |= COMEDI_CB_EOA; - } - } + if (async->events & COMEDI_CB_CANCEL_MASK) + devpriv->ai_cmd_running = 0; if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT) s626_dio_set_irq(dev, cmd->scan_begin_arg); @@ -2091,8 +2085,6 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; } - devpriv->ai_sample_count = cmd->stop_arg; - s626_reset_adc(dev, ppl); switch (cmd->start_src) { -- cgit v1.2.3-59-g8ed1b From 7c5fc7dd4780e3ff923f2117dae78517ede9290b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:04 -0700 Subject: staging: comedi: usbdux: use comedi_async 'scans_done' to detect AO EOA Remove the private data member 'ao_sample_count' and use the comedi_async 'scans_done' member to detect the analog output end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 40f5cd03651d..778201596d69 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -204,7 +204,6 @@ struct usbdux_private { /* number of samples to acquire */ int ai_sample_count; - int ao_sample_count; /* time between samples in units of the timer */ unsigned int ai_timer; unsigned int ao_timer; @@ -397,12 +396,10 @@ static void usbduxsub_ao_handle_urb(struct comedi_device *dev, if (devpriv->ao_counter == 0) { devpriv->ao_counter = devpriv->ao_timer; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ao_sample_count--; - if (devpriv->ao_sample_count < 0) { - async->events |= COMEDI_CB_EOA; - return; - } + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + async->events |= COMEDI_CB_EOA; + return; } /* transmit data to the USB bus */ @@ -1011,24 +1008,6 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_counter = devpriv->ao_timer; - if (cmd->stop_src == TRIG_COUNT) { - /* not continuous */ - /* counter */ - /* high speed also scans everything at once */ - if (0) { /* (devpriv->high_speed) */ - devpriv->ao_sample_count = cmd->stop_arg * - cmd->scan_end_arg; - } else { - /* there's no scan as the scan has been */ - /* perf inside the FX2 */ - /* data arrives as one packet */ - devpriv->ao_sample_count = cmd->stop_arg; - } - } else { - /* continous acquisition */ - devpriv->ao_sample_count = 0; - } - if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ devpriv->ao_cmd_running = 1; -- cgit v1.2.3-59-g8ed1b From 88340999de06facf5f4ae1b9f5b620ee04715a00 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:05 -0700 Subject: staging: comedi: usbdux: use comedi_async 'scans_done' to detect AI EOA Remove the private data member 'ai_sample_count' and use the comedi_async 'scans_done' member to detect the analog input end-of-acquisition. Move the EOA check so it happens after adding the samples from the current urb to the async buffer. This prevents the unnecessary resubmit of the urb when the EOA occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 778201596d69..4737dbf8e01d 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -202,8 +202,6 @@ struct usbdux_private { unsigned int ao_cmd_running:1; unsigned int pwm_cmd_running:1; - /* number of samples to acquire */ - int ai_sample_count; /* time between samples in units of the timer */ unsigned int ai_timer; unsigned int ao_timer; @@ -263,14 +261,6 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev, if (devpriv->ai_counter == 0) { devpriv->ai_counter = devpriv->ai_timer; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ai_sample_count--; - if (devpriv->ai_sample_count < 0) { - async->events |= COMEDI_CB_EOA; - return; - } - } - /* get the data from the USB bus and hand it over to comedi */ for (i = 0; i < cmd->chanlist_len; i++) { unsigned int range = CR_RANGE(cmd->chanlist[i]); @@ -284,6 +274,10 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev, if (!comedi_buf_write_samples(s, &val, 1)) return; } + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; } /* if command is still running, resubmit urb */ @@ -732,14 +726,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_counter = devpriv->ai_timer; - if (cmd->stop_src == TRIG_COUNT) { - /* data arrives as one packet */ - devpriv->ai_sample_count = cmd->stop_arg; - } else { - /* continous acquisition */ - devpriv->ai_sample_count = 0; - } - if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ devpriv->ai_cmd_running = 1; -- cgit v1.2.3-59-g8ed1b From 4b8ffac3859155b1f3c5ded5aeda41fedfe5555e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:06 -0700 Subject: staging: comedi: usbduxsigma: use comedi_async 'scans_done' to detect AO EOA Remove the private data member 'ao_sample_count' and use the comedi_async 'scans_done' member to detect the analog output end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 30 ++++------------------------ 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 9ee6e0a78578..31b280656a1a 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -166,7 +166,6 @@ struct usbduxsigma_private { /* number of samples to acquire */ int ai_sample_count; - int ao_sample_count; /* time between samples in units of the timer */ unsigned int ai_timer; unsigned int ao_timer; @@ -358,12 +357,10 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device *dev, if (devpriv->ao_counter == 0) { devpriv->ao_counter = devpriv->ao_timer; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ao_sample_count--; - if (devpriv->ao_sample_count < 0) { - async->events |= COMEDI_CB_EOA; - return; - } + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + async->events |= COMEDI_CB_EOA; + return; } /* transmit data to the USB bus */ @@ -952,25 +949,6 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev, if (devpriv->ao_timer < 1) err |= -EINVAL; - if (cmd->stop_src == TRIG_COUNT) { - /* not continuous, use counter */ - if (high_speed) { - /* high speed also scans everything at once */ - devpriv->ao_sample_count = cmd->stop_arg * - cmd->scan_end_arg; - } else { - /* - * There's no scan as the scan has been - * handled inside the FX2. Data arrives as - * one packet. - */ - devpriv->ao_sample_count = cmd->stop_arg; - } - } else { - /* continuous acquisition */ - devpriv->ao_sample_count = 0; - } - if (err) return 4; -- cgit v1.2.3-59-g8ed1b From 29ee9fbaa1bfa2e89fc7b5774f18d22bc20dd574 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:07 -0700 Subject: staging: comedi: usbduxsigma: use comedi_async 'scans_done' to detect AI EOA Remove the private data member 'ai_sample_count' and use the comedi_async 'scans_done' member to detect the analog input end-of-acquisition. Move the EOA check so it happens after adding the samples from the current urb to the async buffer. This prevents the unnecessary resubmit of the urb when the EOA occurs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 31b280656a1a..dc19435b6520 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -164,8 +164,6 @@ struct usbduxsigma_private { unsigned ao_cmd_running:1; unsigned pwm_cmd_running:1; - /* number of samples to acquire */ - int ai_sample_count; /* time between samples in units of the timer */ unsigned int ai_timer; unsigned int ao_timer; @@ -226,14 +224,6 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device *dev, if (devpriv->ai_counter == 0) { devpriv->ai_counter = devpriv->ai_timer; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ai_sample_count--; - if (devpriv->ai_sample_count < 0) { - async->events |= COMEDI_CB_EOA; - return; - } - } - /* get the state of the dio pins to allow external trigger */ dio_state = be32_to_cpu(devpriv->in_buf[0]); @@ -247,6 +237,10 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device *dev, if (!comedi_buf_write_samples(s, &val, 1)) return; } + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; } /* if command is still running, resubmit urb */ @@ -578,14 +572,6 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev, if (devpriv->ai_timer < 1) err |= -EINVAL; - if (cmd->stop_src == TRIG_COUNT) { - /* data arrives as one packet */ - devpriv->ai_sample_count = cmd->stop_arg; - } else { - /* continuous acquisition */ - devpriv->ai_sample_count = 0; - } - if (err) return 4; -- cgit v1.2.3-59-g8ed1b From 324e213a06eb527cfba7d1efe5118cbff02afd7e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:08 -0700 Subject: staging: comedi: addi_apci_3120: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_AiActualScan' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. The function v_APCI3120_InterruptDmaMoveBlock16bit() is then just a wrapper for comedi_buf_write_samples(). Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 34 ++++------------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 917076632433..c64799e3513c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -628,7 +628,6 @@ static int apci3120_cancel(struct comedi_device *dev, /* Flush FIFO */ inb(dev->iobase + APCI3120_RESET_FIFO); inw(dev->iobase + APCI3120_RD_STATUS); - devpriv->ui_AiActualScan = 0; devpriv->ui_DmaActualBuffer = 0; devpriv->ai_running = 0; @@ -756,7 +755,6 @@ static int apci3120_cyclic_ai(int mode, inb(dev->iobase + APCI3120_RESET_FIFO); /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - devpriv->ui_AiActualScan = 0; devpriv->ui_DmaActualBuffer = 0; /* value for timer2 minus -2 has to be done */ @@ -1156,23 +1154,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, return apci3120_cyclic_ai(2, dev, s); } -/* - * This function copies the data from DMA buffer to the Comedi buffer. - */ -static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned short *dma_buffer, - unsigned int num_samples) -{ - struct apci3120_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - - devpriv->ui_AiActualScan += - (s->async->cur_chan + num_samples) / cmd->scan_end_arg; - - comedi_buf_write_samples(s, dma_buffer, num_samples); -} - /* * This is a handler for the DMA interrupt. * This function copies the data to Comedi Buffer. @@ -1245,18 +1226,16 @@ static void apci3120_interrupt_dma(int irq, void *d) } if (samplesinbuf) { - v_APCI3120_InterruptDmaMoveBlock16bit(dev, s, dmabuf->virt, - samplesinbuf); + comedi_buf_write_samples(s, dmabuf->virt, samplesinbuf); if (!(cmd->flags & CMDF_WAKE_EOS)) s->async->events |= COMEDI_CB_EOS; } - if (cmd->stop_src == TRIG_COUNT) - if (devpriv->ui_AiActualScan >= cmd->stop_arg) { - /* all data sampled */ - s->async->events |= COMEDI_CB_EOA; - return; - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) { + s->async->events |= COMEDI_CB_EOA; + return; + } if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */ devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer; @@ -1386,7 +1365,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (devpriv->ai_running) { ui_Check = 0; apci3120_interrupt_handle_eos(dev); - devpriv->ui_AiActualScan++; devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister | diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e8da15cf4e2a..056b3bf82094 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -55,7 +55,6 @@ struct apci3120_dmabuf { struct apci3120_private { unsigned long amcc; unsigned long addon; - unsigned int ui_AiActualScan; unsigned int ui_AiNbrofChannels; unsigned int ui_AiChannelList[32]; unsigned int ui_AiReadData[32]; -- cgit v1.2.3-59-g8ed1b From 5e62863aea463c9bf24538315327d0922be35d64 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:21:09 -0700 Subject: staging: comedi: das800: use comedi_async 'scans_done' to detect EOA Remove the private data member 'count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 55bc494838b5..e5bdc2423445 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -219,7 +219,6 @@ static const struct das800_board das800_boards[] = { }; struct das800_private { - unsigned int count; /* number of data points left to be taken */ unsigned int divisor1; /* counter 1 value for timed conversions */ unsigned int divisor2; /* counter 2 value for timed conversions */ unsigned int do_bits; /* digital output bits */ @@ -286,9 +285,6 @@ static void das800_set_frequency(struct comedi_device *dev) static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct das800_private *devpriv = dev->private; - - devpriv->count = 0; das800_disable(dev); return 0; } @@ -399,7 +395,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct das800_board *thisboard = dev->board_ptr; - struct das800_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int gain = CR_RANGE(cmd->chanlist[0]); @@ -422,11 +417,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev, gain &= 0xf; outb(gain, dev->iobase + DAS800_GAIN); - if (cmd->stop_src == TRIG_COUNT) - devpriv->count = cmd->stop_arg * cmd->chanlist_len; - else /* TRIG_NONE */ - devpriv->count = 0; - /* enable auto channel scan, send interrupts on end of conversion * and set clock source to internal or external */ @@ -509,11 +499,13 @@ static irqreturn_t das800_interrupt(int irq, void *d) if (s->maxdata == 0x0fff) val >>= 4; /* 12-bit sample */ - /* if there are more data points to collect */ - if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { - val &= s->maxdata; - comedi_buf_write_samples(s, &val, 1); - devpriv->count--; + val &= s->maxdata; + comedi_buf_write_samples(s, &val, 1); + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + async->events |= COMEDI_CB_EOA; + break; } } @@ -524,9 +516,11 @@ static irqreturn_t das800_interrupt(int irq, void *d) return IRQ_HANDLED; } - if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { - /* Re-enable card's interrupt. - * We already have spinlock, so indirect addressing is safe */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + /* + * Re-enable card's interrupt. + * We already have spinlock, so indirect addressing is safe + */ das800_ind_write(dev, CONTROL1_INTE | devpriv->do_bits, CONTROL1); spin_unlock_irqrestore(&dev->spinlock, irq_flags); @@ -534,7 +528,6 @@ static irqreturn_t das800_interrupt(int irq, void *d) /* otherwise, stop taking data */ spin_unlock_irqrestore(&dev->spinlock, irq_flags); das800_disable(dev); - async->events |= COMEDI_CB_EOA; } comedi_handle_events(dev, s); return IRQ_HANDLED; -- cgit v1.2.3-59-g8ed1b From 0d511a3801378bd328885e38d1f5e7481f224117 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:04 -0500 Subject: staging: unisys: visorchannel: Remove multiple blank lines Remove the instances of multiple blank lines in the visorchannel files. Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/globals.h | 1 - drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h index 07653b8dea7b..581ed83fe6d0 100644 --- a/drivers/staging/unisys/visorchannel/globals.h +++ b/drivers/staging/unisys/visorchannel/globals.h @@ -25,5 +25,4 @@ #define MYDRVNAME "visorchannel" - #endif diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index a50251a986a1..b3265c80d0f3 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -504,7 +504,6 @@ Away: } EXPORT_SYMBOL_GPL(visorchannel_signalinsert); - int visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue) { -- cgit v1.2.3-59-g8ed1b From ff247e7f9b3572ea041a60a01a151a8323fc257f Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:05 -0500 Subject: staging: unisys: visorchannel: Fix alignment issues Use the appropriate whitespace for multiline statements in visorchannel_funcs.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index b3265c80d0f3..1d55254b8967 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -226,7 +226,7 @@ visorchannel_read(VISORCHANNEL *channel, ulong offset, int rc = visor_memregion_read(channel->memregion, offset, local, nbytes); if ((rc >= 0) && (offset == 0) && - (nbytes >= sizeof(struct channel_header))) { + (nbytes >= sizeof(struct channel_header))) { memcpy(&channel->chan_hdr, local, sizeof(struct channel_header)); } @@ -399,7 +399,7 @@ safe_sig_queue_validate(struct signal_queue_header *psafe_sqh, punsafe_sqh->tail = *ptail; ERRDRV("safe_sig_queue_validate: head = 0x%x, tail = 0x%x, MaxSlots = 0x%x", - *phead, *ptail, psafe_sqh->max_slots); + *phead, *ptail, psafe_sqh->max_slots); return 0; } return 1; @@ -622,9 +622,10 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, struct signal_queue_header q; errcode = visorchannel_read(channel, - off + phdr->ch_space_offset + - (i * sizeof(q)), - &q, sizeof(q)); + off + + phdr->ch_space_offset + + (i * sizeof(q)), + &q, sizeof(q)); if (errcode < 0) { seq_printf(seq, "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n", -- cgit v1.2.3-59-g8ed1b From 6e4c8d30b16e90db90b570756e15c5a3255c3837 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:06 -0500 Subject: staging: unisys: visorchannel: Remove space between cast and variable Remove the whitespace between a cast and the variable in visorchannel_funcs.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchannel/visorchannel_funcs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 1d55254b8967..eff9d0ee14c1 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -89,7 +89,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, } if (channelBytes == 0) /* we had better be a CLIENT of this channel */ - channelBytes = (ulong) p->chan_hdr.size; + channelBytes = (ulong)p->chan_hdr.size; if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) /* we had better be a CLIENT of this channel */ guid = p->chan_hdr.chtype; @@ -287,7 +287,7 @@ EXPORT_SYMBOL_GPL(visorchannel_clear); void __iomem * visorchannel_get_header(VISORCHANNEL *channel) { - return (void __iomem *) &(channel->chan_hdr); + return (void __iomem *)&(channel->chan_hdr); } EXPORT_SYMBOL_GPL(visorchannel_get_header); @@ -519,7 +519,7 @@ visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue) head = head + sig_hdr.max_slots; slots_used = (head - tail); slots_avail = sig_hdr.max_signals - slots_used; - return (int) slots_avail; + return (int)slots_avail; } EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail); @@ -530,7 +530,7 @@ visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, u32 queue) if (!sig_read_header(channel, queue, &sig_hdr)) return 0; - return (int) sig_hdr.max_signals; + return (int)sig_hdr.max_signals; } EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots); @@ -593,13 +593,13 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, } else return; } - nbytes = (ulong) (phdr->size); + nbytes = (ulong)(phdr->size); seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n", addr + off, nbytes, nbytes_region); seq_printf(seq, "Type = %pUL\n", &phdr->chtype); seq_printf(seq, "ZoneGuid = %pUL\n", &phdr->zone_uuid); seq_printf(seq, "Signature = 0x%-16.16Lx\n", - (long long) phdr->signature); + (long long)phdr->signature); seq_printf(seq, "LegacyState = %lu\n", (ulong)phdr->legacy_state); seq_printf(seq, "SrvState = %lu\n", (ulong)phdr->srv_state); seq_printf(seq, "CliStateBoot = %lu\n", (ulong)phdr->cli_state_boot); @@ -607,14 +607,14 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, seq_printf(seq, "HeaderSize = %lu\n", (ulong)phdr->header_size); seq_printf(seq, "Size = %llu\n", (long long)phdr->size); seq_printf(seq, "Features = 0x%-16.16llx\n", - (long long) phdr->features); + (long long)phdr->features); seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n", - (long long) phdr->partition_handle); + (long long)phdr->partition_handle); seq_printf(seq, "Handle = 0x%-16.16llx\n", - (long long) phdr->handle); - seq_printf(seq, "VersionId = %lu\n", (ulong) phdr->version_id); + (long long)phdr->handle); + seq_printf(seq, "VersionId = %lu\n", (ulong)phdr->version_id); seq_printf(seq, "oChannelSpace = %llu\n", - (long long) phdr->ch_space_offset); + (long long)phdr->ch_space_offset); if ((phdr->ch_space_offset == 0) || (errcode < 0)) ; else -- cgit v1.2.3-59-g8ed1b From 61a8a7bc4d86a97f588880b7f7c819f8938cabfc Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:07 -0500 Subject: staging: unisys: visorchannel: Remove unnecessary parentheses Remove extraneous parentheses around a variable in visorchannel_funcs.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index eff9d0ee14c1..66094a32f495 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -287,7 +287,7 @@ EXPORT_SYMBOL_GPL(visorchannel_clear); void __iomem * visorchannel_get_header(VISORCHANNEL *channel) { - return (void __iomem *)&(channel->chan_hdr); + return (void __iomem *)&channel->chan_hdr; } EXPORT_SYMBOL_GPL(visorchannel_get_header); -- cgit v1.2.3-59-g8ed1b From e3b7a4cacfcf6ffe6eb289628dd147b3202b5924 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:08 -0500 Subject: staging: unisys: visorchannel: Place logical continuation at the end of a line Move the || logical continuation from the start of the second line of an if statement to the end of the first line. Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 66094a32f495..29efd4dd0e82 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -388,8 +388,8 @@ safe_sig_queue_validate(struct signal_queue_header *psafe_sqh, struct signal_queue_header *punsafe_sqh, u32 *phead, u32 *ptail) { - if ((*phead >= psafe_sqh->max_slots) - || (*ptail >= psafe_sqh->max_slots)) { + if ((*phead >= psafe_sqh->max_slots) || + (*ptail >= psafe_sqh->max_slots)) { /* Choose 0 or max, maybe based on current tail value */ *phead = 0; *ptail = 0; -- cgit v1.2.3-59-g8ed1b From 83781f34a8dfff13c82c0b6729e722faba294657 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:09 -0500 Subject: staging: unisys: visorchannel: Adjust lines to contain a maximum of 80 characters Split multiple logging lines to get them closer to 80 characters per line. Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorchannel/visorchannel_funcs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 29efd4dd0e82..b9dd77b508b0 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -334,7 +334,8 @@ sig_read_header(VISORCHANNEL *channel, u32 queue, sizeof(struct signal_queue_header)) < 0) { ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d", queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)); - ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", rc); + ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", + rc); goto Away; } rc = TRUE; @@ -354,13 +355,15 @@ sig_do_data(VISORCHANNEL *channel, u32 queue, if (visor_memregion_write(channel->memregion, signal_data_offset, data, sig_hdr->signal_size) < 0) { - ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", rc); + ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", + rc); goto Away; } } else { if (visor_memregion_read(channel->memregion, signal_data_offset, data, sig_hdr->signal_size) < 0) { - ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", rc); + ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", + rc); goto Away; } } @@ -439,7 +442,8 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) goto Away; } if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) { - ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", rc); + ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", + rc); goto Away; } rc = TRUE; @@ -469,7 +473,8 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) if (sig_hdr.head == sig_hdr.tail) { sig_hdr.num_overflows++; if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows)) { - ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", rc); + ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", + rc); goto Away; } rc = FALSE; @@ -492,7 +497,8 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) goto Away; } if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) { - ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", rc); + ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", + rc); goto Away; } rc = TRUE; -- cgit v1.2.3-59-g8ed1b From c440ce1f5652d2e6fe4d8aec18ef6448ff75fdd2 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:10 -0500 Subject: staging: unisys: visorchannel: Rename goto label Away Rename the goto label used throughout visorchannel_funcs.c from Away to cleanup. Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- .../unisys/visorchannel/visorchannel_funcs.c | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index b9dd77b508b0..a0fd358e0c28 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -60,7 +60,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, if (p == NULL) { ERRDRV("allocation failed: (status=0)\n"); rc = NULL; - goto Away; + goto cleanup; } p->memregion = NULL; p->needs_lock = needs_lock; @@ -79,13 +79,13 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, if (p->memregion == NULL) { ERRDRV("visor_memregion_create failed failed: (status=0)\n"); rc = NULL; - goto Away; + goto cleanup; } if (visor_memregion_read(p->memregion, 0, &p->chan_hdr, sizeof(struct channel_header)) < 0) { ERRDRV("visor_memregion_read failed: (status=0)\n"); rc = NULL; - goto Away; + goto cleanup; } if (channelBytes == 0) /* we had better be a CLIENT of this channel */ @@ -96,13 +96,13 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, if (visor_memregion_resize(p->memregion, channelBytes) < 0) { ERRDRV("visor_memregion_resize failed: (status=0)\n"); rc = NULL; - goto Away; + goto cleanup; } p->size = channelBytes; p->guid = guid; rc = p; -Away: +cleanup: if (rc == NULL) { if (p != NULL) { @@ -255,7 +255,7 @@ visorchannel_clear(VISORCHANNEL *channel, ulong offset, u8 ch, ulong nbytes) if (buf == NULL) { ERRDRV("%s failed memory allocation", __func__); - goto Away; + goto cleanup; } memset(buf, ch, bufsize); while (nbytes > 0) { @@ -268,14 +268,14 @@ visorchannel_clear(VISORCHANNEL *channel, ulong offset, u8 ch, ulong nbytes) buf, thisbytes); if (x < 0) { rc = x; - goto Away; + goto cleanup; } written += thisbytes; nbytes -= thisbytes; } rc = 0; -Away: +cleanup: if (buf != NULL) { vfree(buf); buf = NULL; @@ -323,7 +323,7 @@ sig_read_header(VISORCHANNEL *channel, u32 queue, if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header)) { ERRDRV("oChannelSpace too small: (status=%d)\n", rc); - goto Away; + goto cleanup; } /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */ @@ -336,10 +336,10 @@ sig_read_header(VISORCHANNEL *channel, u32 queue, queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)); ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } rc = TRUE; -Away: +cleanup: return rc; } @@ -357,18 +357,18 @@ sig_do_data(VISORCHANNEL *channel, u32 queue, data, sig_hdr->signal_size) < 0) { ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } } else { if (visor_memregion_read(channel->memregion, signal_data_offset, data, sig_hdr->signal_size) < 0) { ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } } rc = TRUE; -Away: +cleanup: return rc; } @@ -419,16 +419,16 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) if (!sig_read_header(channel, queue, &sig_hdr)) { rc = FALSE; - goto Away; + goto cleanup; } if (sig_hdr.head == sig_hdr.tail) { rc = FALSE; /* no signals to remove */ - goto Away; + goto cleanup; } sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) { ERRDRV("sig_read_data failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } sig_hdr.num_received++; @@ -439,15 +439,15 @@ visorchannel_signalremove(VISORCHANNEL *channel, u32 queue, void *msg) if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail)) { ERRDRV("visor_memregion_write of Tail failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) { ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } rc = TRUE; -Away: +cleanup: if (channel->needs_lock) spin_unlock(&channel->remove_lock); @@ -466,7 +466,7 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) if (!sig_read_header(channel, queue, &sig_hdr)) { rc = FALSE; - goto Away; + goto cleanup; } sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots); @@ -475,15 +475,15 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows)) { ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } rc = FALSE; - goto Away; + goto cleanup; } if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg)) { ERRDRV("sig_write_data failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } sig_hdr.num_sent++; @@ -494,15 +494,15 @@ visorchannel_signalinsert(VISORCHANNEL *channel, u32 queue, void *msg) if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head)) { ERRDRV("visor_memregion_write of Head failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) { ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", rc); - goto Away; + goto cleanup; } rc = TRUE; -Away: +cleanup: if (channel->needs_lock) spin_unlock(&channel->insert_lock); -- cgit v1.2.3-59-g8ed1b From f36b9dfed7da05e327ca22b44468a29623922c4e Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 6 Nov 2014 14:13:11 -0500 Subject: staging: unisys: visorchannel: Add braces to else arm of if/else statement Add braces to the else arm of an if/else block in visorchannel_funcs.c Signed-off-by: Bryan Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index a0fd358e0c28..36559d5fa673 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -596,8 +596,9 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, if (off == 0) { phdr = &channel->chan_hdr; seq_puts(seq, "(following data may be stale)\n"); - } else + } else { return; + } } nbytes = (ulong)(phdr->size); seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n", -- cgit v1.2.3-59-g8ed1b From f9b64692e13b2f0d2a393e41972aa317f34a3e46 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Nov 2014 17:48:34 +0530 Subject: staging: unisys: unneeded NULL check the NULL check for memregion is not required as it has already been checked for NULL after kzalloc. so we can reach this part of the code only if memregion is not NULL. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/memregion_direct.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 26faad470705..33522cc8c22c 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -57,10 +57,8 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes) rc = memregion; cleanup: if (rc == NULL) { - if (memregion != NULL) { - visor_memregion_destroy(memregion); - memregion = NULL; - } + visor_memregion_destroy(memregion); + memregion = NULL; } return rc; } -- cgit v1.2.3-59-g8ed1b From 930a021f2ec59d2143ca86a357773128785ed16f Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Nov 2014 17:48:35 +0530 Subject: staging: unisys: dereferencing NULL pointer we can reach the label Away in total five situation and in four of of them pDevInfo is NULL. so we were basically dereferencing a NULL pointer. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index b5a0e460da07..c8f7beaac87a 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1298,7 +1298,8 @@ my_device_create(struct controlvm_message *inmsg) POSTCODE_SEVERITY_INFO); Away: /* get the bus and devNo for DiagPool channel */ - if (is_diagpool_channel(pDevInfo->chan_info.channel_type_uuid)) { + if (pDevInfo && + is_diagpool_channel(pDevInfo->chan_info.channel_type_uuid)) { g_diagpoolBusNo = busNo; g_diagpoolDevNo = devNo; LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", -- cgit v1.2.3-59-g8ed1b From 314e5caa4b41555aec20ac39dd3df1ccc799bc65 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 6 Nov 2014 20:02:00 +0000 Subject: staging: vt6655: baseband.h remove pDevice from struct vnt_private pointer Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 6ce856c01907..c41bc337c10d 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -80,11 +80,11 @@ void vnt_get_phy_field(struct vnt_private *, u32 frame_length, bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData); bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData); -void BBvSetShortSlotTime(struct vnt_private *pDevice); -void BBvSetVGAGainOffset(struct vnt_private *pDevice, unsigned char byData); +void BBvSetShortSlotTime(struct vnt_private *); +void BBvSetVGAGainOffset(struct vnt_private *, unsigned char byData); /* VT3253 Baseband */ -bool BBbVT3253Init(struct vnt_private *pDevice); +bool BBbVT3253Init(struct vnt_private *); void BBvSoftwareReset(void __iomem *dwIoBase); void BBvPowerSaveModeON(void __iomem *dwIoBase); void BBvPowerSaveModeOFF(void __iomem *dwIoBase); @@ -105,9 +105,9 @@ TimerState1CallBack( unsigned long ); -void BBvAntennaDiversity(struct vnt_private *pDevice, +void BBvAntennaDiversity(struct vnt_private *, unsigned char byRxRate, unsigned char bySQ3); void -BBvClearAntDivSQ3Value(struct vnt_private *pDevice); +BBvClearAntDivSQ3Value(struct vnt_private *); #endif /* __BASEBAND_H__ */ -- cgit v1.2.3-59-g8ed1b From a5f0eef38b574248119353667eeee69559b9c291 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 6 Nov 2014 20:02:01 +0000 Subject: staging: vt6655: baseband replace __iomem where caller is priv dereferenced. Replace with stucture vnt_private *priv in functions BBvSoftwareReset BBvSetTxAntennaMode BBvSetRxAntennaMode BBvSetDeepSleep BBvExitDeepSleep __iomem *dwIoBase will be moved into BBbWriteEmbedded and BBbReadEmbedded later. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 30 +++++++++++++++++++----------- drivers/staging/vt6655/baseband.h | 10 +++++----- drivers/staging/vt6655/card.c | 4 ++-- drivers/staging/vt6655/channel.c | 2 +- drivers/staging/vt6655/device_main.c | 6 +++--- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 32000d2bedb1..c6c811b18f46 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1719,22 +1719,22 @@ s_vChangeAntenna( if (priv->dwRxAntennaSel == 0) { priv->dwRxAntennaSel = 1; if (priv->bTxRxAntInv == true) - BBvSetRxAntennaMode(priv->PortOffset, ANT_A); + BBvSetRxAntennaMode(priv, ANT_A); else - BBvSetRxAntennaMode(priv->PortOffset, ANT_B); + BBvSetRxAntennaMode(priv, ANT_B); } else { priv->dwRxAntennaSel = 0; if (priv->bTxRxAntInv == true) - BBvSetRxAntennaMode(priv->PortOffset, ANT_B); + BBvSetRxAntennaMode(priv, ANT_B); else - BBvSetRxAntennaMode(priv->PortOffset, ANT_A); + BBvSetRxAntennaMode(priv, ANT_A); } if (priv->dwTxAntennaSel == 0) { priv->dwTxAntennaSel = 1; - BBvSetTxAntennaMode(priv->PortOffset, ANT_B); + BBvSetTxAntennaMode(priv, ANT_B); } else { priv->dwTxAntennaSel = 0; - BBvSetTxAntennaMode(priv->PortOffset, ANT_A); + BBvSetTxAntennaMode(priv, ANT_A); } } @@ -2266,8 +2266,10 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData) * */ void -BBvSoftwareReset(void __iomem *dwIoBase) +BBvSoftwareReset(struct vnt_private *priv) { + void __iomem *dwIoBase = priv->PortOffset; + BBbWriteEmbedded(dwIoBase, 0x50, 0x40); BBbWriteEmbedded(dwIoBase, 0x50, 0); BBbWriteEmbedded(dwIoBase, 0x9C, 0x01); @@ -2333,8 +2335,9 @@ BBvPowerSaveModeOFF(void __iomem *dwIoBase) */ void -BBvSetTxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode) +BBvSetTxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) { + void __iomem *dwIoBase = priv->PortOffset; unsigned char byBBTxConf; BBbReadEmbedded(dwIoBase, 0x09, &byBBTxConf); /* CR09 */ @@ -2366,8 +2369,9 @@ BBvSetTxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode) */ void -BBvSetRxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode) +BBvSetRxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) { + void __iomem *dwIoBase = priv->PortOffset; unsigned char byBBRxConf; BBbReadEmbedded(dwIoBase, 0x0A, &byBBRxConf); /* CR10 */ @@ -2396,15 +2400,19 @@ BBvSetRxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode) * */ void -BBvSetDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID) +BBvSetDeepSleep(struct vnt_private *priv, unsigned char byLocalID) { + void __iomem *dwIoBase = priv->PortOffset; + BBbWriteEmbedded(dwIoBase, 0x0C, 0x17); /* CR12 */ BBbWriteEmbedded(dwIoBase, 0x0D, 0xB9); /* CR13 */ } void -BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID) +BBvExitDeepSleep(struct vnt_private *priv, unsigned char byLocalID) { + void __iomem *dwIoBase = priv->PortOffset; + BBbWriteEmbedded(dwIoBase, 0x0C, 0x00); /* CR12 */ BBbWriteEmbedded(dwIoBase, 0x0D, 0x01); /* CR13 */ } diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index c41bc337c10d..8594347f45ac 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -85,13 +85,13 @@ void BBvSetVGAGainOffset(struct vnt_private *, unsigned char byData); /* VT3253 Baseband */ bool BBbVT3253Init(struct vnt_private *); -void BBvSoftwareReset(void __iomem *dwIoBase); +void BBvSoftwareReset(struct vnt_private *); void BBvPowerSaveModeON(void __iomem *dwIoBase); void BBvPowerSaveModeOFF(void __iomem *dwIoBase); -void BBvSetTxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode); -void BBvSetRxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode); -void BBvSetDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID); -void BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID); +void BBvSetTxAntennaMode(struct vnt_private *, unsigned char byAntennaMode); +void BBvSetRxAntennaMode(struct vnt_private *, unsigned char byAntennaMode); +void BBvSetDeepSleep(struct vnt_private *, unsigned char byLocalID); +void BBvExitDeepSleep(struct vnt_private *, unsigned char byLocalID); /* timer for antenna diversity */ diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 60f051f8de8a..0121466b941d 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -445,7 +445,7 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice) MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); - BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID); + BBvSetDeepSleep(pDevice, pDevice->byLocalID); pDevice->bRadioOff = true; pr_debug("chester power off\n"); @@ -480,7 +480,7 @@ bool CARDbRadioPowerOn(struct vnt_private *pDevice) pr_debug("chester pbRadioOff\n"); return true; } - BBvExitDeepSleep(pDevice->PortOffset, pDevice->byLocalID); + BBvExitDeepSleep(pDevice, pDevice->byLocalID); MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 6bd5f161894d..cc1bc94ceaa3 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -197,7 +197,7 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) if (pDevice->bEnablePSMode) RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel); - BBvSoftwareReset(pDevice->PortOffset); + BBvSoftwareReset(pDevice); if (pDevice->byLocalID > REV_ID_VT3253_B1) { /* set HW default power register */ diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 5fc6022badb2..397f13f10c1a 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -254,7 +254,7 @@ static void device_init_registers(struct vnt_private *pDevice) unsigned char byOFDMPwrdBm = 0; MACbShutdown(pDevice->PortOffset); - BBvSoftwareReset(pDevice->PortOffset); + BBvSoftwareReset(pDevice); /* Do MACbSoftwareReset in MACvInitialize */ MACbSoftwareReset(pDevice->PortOffset); @@ -446,8 +446,8 @@ static void device_init_registers(struct vnt_private *pDevice) BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); } - BBvSetRxAntennaMode(pDevice->PortOffset, pDevice->byRxAntennaMode); - BBvSetTxAntennaMode(pDevice->PortOffset, pDevice->byTxAntennaMode); + BBvSetRxAntennaMode(pDevice, pDevice->byRxAntennaMode); + BBvSetTxAntennaMode(pDevice, pDevice->byTxAntennaMode); /* Set BB and packet type at the same time. */ /* Set Short Slot Time, xIFS, and RSPINF. */ -- cgit v1.2.3-59-g8ed1b From 78b3c1fde09b072ee508ad26ffc237e5a3b6e6b1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 6 Nov 2014 20:02:02 +0000 Subject: staging: vt6655: baseband/rf s_bAL7230Init change __iomem for baseband functions Replace __iomem with vnt_private providing pointer for dwIoBase Change BBvPowerSaveModeON and BBvPowerSaveModeOFF to vnt_private and reference __iomem there, to be removed later. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 6 ++++-- drivers/staging/vt6655/baseband.h | 4 ++-- drivers/staging/vt6655/rf.c | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index c6c811b18f46..9d5288ca2ed2 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2289,8 +2289,9 @@ BBvSoftwareReset(struct vnt_private *priv) * */ void -BBvPowerSaveModeON(void __iomem *dwIoBase) +BBvPowerSaveModeON(struct vnt_private *priv) { + void __iomem *dwIoBase = priv->PortOffset; unsigned char byOrgData; BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); @@ -2311,8 +2312,9 @@ BBvPowerSaveModeON(void __iomem *dwIoBase) * */ void -BBvPowerSaveModeOFF(void __iomem *dwIoBase) +BBvPowerSaveModeOFF(struct vnt_private *priv) { + void __iomem *dwIoBase = priv->PortOffset; unsigned char byOrgData; BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 8594347f45ac..26f9cdcb24b8 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -86,8 +86,8 @@ void BBvSetVGAGainOffset(struct vnt_private *, unsigned char byData); /* VT3253 Baseband */ bool BBbVT3253Init(struct vnt_private *); void BBvSoftwareReset(struct vnt_private *); -void BBvPowerSaveModeON(void __iomem *dwIoBase); -void BBvPowerSaveModeOFF(void __iomem *dwIoBase); +void BBvPowerSaveModeON(struct vnt_private *); +void BBvPowerSaveModeOFF(struct vnt_private *); void BBvSetTxAntennaMode(struct vnt_private *, unsigned char byAntennaMode); void BBvSetRxAntennaMode(struct vnt_private *, unsigned char byAntennaMode); void BBvSetDeepSleep(struct vnt_private *, unsigned char byLocalID); diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index e505af91bfd0..2b1e7a09360e 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -424,8 +424,9 @@ static const unsigned long dwAL7230ChannelTable2[CB_MAX_CHANNEL] = { * Return Value: true if succeeded; false if failed. * */ -static bool s_bAL7230Init(void __iomem *dwIoBase) +static bool s_bAL7230Init(struct vnt_private *priv) { + void __iomem *dwIoBase = priv->PortOffset; int ii; bool bResult; @@ -436,7 +437,7 @@ static bool s_bAL7230Init(void __iomem *dwIoBase) MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPECTI | SOFTPWRCTL_TXPEINV)); - BBvPowerSaveModeOFF(dwIoBase); //RobertYu:20050106, have DC value for Calibration + BBvPowerSaveModeOFF(priv); /* RobertYu:20050106, have DC value for Calibration */ for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[ii]); @@ -457,7 +458,7 @@ static bool s_bAL7230Init(void __iomem *dwIoBase) SOFTPWRCTL_SWPECTI | SOFTPWRCTL_TXPEINV)); - BBvPowerSaveModeON(dwIoBase); // RobertYu:20050106 + BBvPowerSaveModeON(priv); /* RobertYu:20050106 */ // PE1: TX_ON, PE2: RX_ON, PE3: PLLON //3-wire control for power saving mode @@ -759,7 +760,7 @@ bool RFbInit( break; case RF_AIROHA7230: pDevice->byMaxPwrLevel = AL7230_PWR_IDX_LEN; - bResult = s_bAL7230Init(pDevice->PortOffset); + bResult = s_bAL7230Init(pDevice); break; case RF_NOTHING: bResult = true; -- cgit v1.2.3-59-g8ed1b From 377f5bc00f7e147f01489821e13871b5c53966ff Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 6 Nov 2014 20:02:03 +0000 Subject: staging: vt6655: BBbWriteEmbedded replace __iomem with vnt_private for callers Referencing dwIoBase inside function. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 82 +++++++++++++++++++-------------------- drivers/staging/vt6655/baseband.h | 2 +- drivers/staging/vt6655/card.c | 24 ++++++------ 3 files changed, 52 insertions(+), 56 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 9d5288ca2ed2..f1f10754963d 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2003,8 +2003,10 @@ bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned ch * Return Value: true if succeeded; false if failed. * */ -bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData) +bool BBbWriteEmbedded(struct vnt_private *priv, + unsigned char byBBAddr, unsigned char byData) { + void __iomem *dwIoBase = priv->PortOffset; unsigned short ww; unsigned char byValue; @@ -2056,14 +2058,14 @@ bool BBbVT3253Init(struct vnt_private *priv) if (byRFType == RF_RFMD2959) { if (byLocalID <= REV_ID_VT3253_A1) { for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253InitTab_RFMD[ii][0], byVT3253InitTab_RFMD[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253InitTab_RFMD[ii][0], byVT3253InitTab_RFMD[ii][1]); } else { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_RFMD[ii][0], byVT3253B0_RFMD[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_RFMD[ii][0], byVT3253B0_RFMD[ii][1]); for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]); VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0)); @@ -2078,10 +2080,10 @@ bool BBbVT3253Init(struct vnt_private *priv) priv->ldBmThreshold[3] = 0; } else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S)) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); for (ii = 0; ii < CB_VT3253B0_AGC; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); priv->abyBBVGA[0] = 0x1C; priv->abyBBVGA[1] = 0x10; @@ -2093,10 +2095,10 @@ bool BBbVT3253Init(struct vnt_private *priv) priv->ldBmThreshold[3] = 0; } else if (byRFType == RF_UW2451) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); for (ii = 0; ii < CB_VT3253B0_AGC; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0)); @@ -2111,28 +2113,28 @@ bool BBbVT3253Init(struct vnt_private *priv) priv->ldBmThreshold[3] = 0; } else if (byRFType == RF_UW2452) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); /* Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) */ /*bResult &= BBbWriteEmbedded(dwIoBase,0x09,0x41);*/ /* Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted) */ /*bResult &= BBbWriteEmbedded(dwIoBase,0x0a,0x28);*/ /* Select VC1/VC2, CR215 = 0x02->0x06 */ - bResult &= BBbWriteEmbedded(dwIoBase, 0xd7, 0x06); + bResult &= BBbWriteEmbedded(priv, 0xd7, 0x06); /* {{RobertYu:20050125, request by Jack */ - bResult &= BBbWriteEmbedded(dwIoBase, 0x90, 0x20); - bResult &= BBbWriteEmbedded(dwIoBase, 0x97, 0xeb); + bResult &= BBbWriteEmbedded(priv, 0x90, 0x20); + bResult &= BBbWriteEmbedded(priv, 0x97, 0xeb); /* }} */ /* {{RobertYu:20050221, request by Jack */ - bResult &= BBbWriteEmbedded(dwIoBase, 0xa6, 0x00); - bResult &= BBbWriteEmbedded(dwIoBase, 0xa8, 0x30); + bResult &= BBbWriteEmbedded(priv, 0xa6, 0x00); + bResult &= BBbWriteEmbedded(priv, 0xa8, 0x30); /* }} */ - bResult &= BBbWriteEmbedded(dwIoBase, 0xb0, 0x58); + bResult &= BBbWriteEmbedded(priv, 0xb0, 0x58); for (ii = 0; ii < CB_VT3253B0_AGC; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); priv->abyBBVGA[0] = 0x14; priv->abyBBVGA[1] = 0x0A; @@ -2146,10 +2148,10 @@ bool BBbVT3253Init(struct vnt_private *priv) } else if (byRFType == RF_VT3226) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); for (ii = 0; ii < CB_VT3253B0_AGC; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); priv->abyBBVGA[0] = 0x1C; priv->abyBBVGA[1] = 0x10; @@ -2164,7 +2166,7 @@ bool BBbVT3253Init(struct vnt_private *priv) /* {{ RobertYu: 20050104 */ } else if (byRFType == RF_AIROHA7230) { for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); /* {{ RobertYu:20050223, request by JerryChung */ @@ -2177,7 +2179,7 @@ bool BBbVT3253Init(struct vnt_private *priv) /* }} */ for (ii = 0; ii < CB_VT3253B0_AGC; ii++) - bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); + bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); priv->abyBBVGA[0] = 0x1C; priv->abyBBVGA[1] = 0x10; @@ -2195,8 +2197,8 @@ bool BBbVT3253Init(struct vnt_private *priv) } if (byLocalID > REV_ID_VT3253_A1) { - BBbWriteEmbedded(dwIoBase, 0x04, 0x7F); - BBbWriteEmbedded(dwIoBase, 0x0D, 0x01); + BBbWriteEmbedded(priv, 0x04, 0x7F); + BBbWriteEmbedded(priv, 0x0D, 0x01); } return bResult; @@ -2232,14 +2234,14 @@ BBvSetShortSlotTime(struct vnt_private *priv) if (byBBVGA == priv->abyBBVGA[0]) byBBRxConf |= 0x20; /* 0010 0000 */ - BBbWriteEmbedded(priv->PortOffset, 0x0A, byBBRxConf); /* CR10 */ + BBbWriteEmbedded(priv, 0x0A, byBBRxConf); /* CR10 */ } void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData) { unsigned char byBBRxConf = 0; - BBbWriteEmbedded(priv->PortOffset, 0xE7, byData); + BBbWriteEmbedded(priv, 0xE7, byData); BBbReadEmbedded(priv->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ /* patch for 3253B0 Baseband with Cardbus module */ @@ -2250,7 +2252,7 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData) else byBBRxConf |= 0x20; /* 0010 0000 */ priv->byBBVGACurrent = byData; - BBbWriteEmbedded(priv->PortOffset, 0x0A, byBBRxConf); /* CR10 */ + BBbWriteEmbedded(priv, 0x0A, byBBRxConf); /* CR10 */ } /* @@ -2268,12 +2270,10 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData) void BBvSoftwareReset(struct vnt_private *priv) { - void __iomem *dwIoBase = priv->PortOffset; - - BBbWriteEmbedded(dwIoBase, 0x50, 0x40); - BBbWriteEmbedded(dwIoBase, 0x50, 0); - BBbWriteEmbedded(dwIoBase, 0x9C, 0x01); - BBbWriteEmbedded(dwIoBase, 0x9C, 0); + BBbWriteEmbedded(priv, 0x50, 0x40); + BBbWriteEmbedded(priv, 0x50, 0); + BBbWriteEmbedded(priv, 0x9C, 0x01); + BBbWriteEmbedded(priv, 0x9C, 0); } /* @@ -2296,7 +2296,7 @@ BBvPowerSaveModeON(struct vnt_private *priv) BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); byOrgData |= BIT(0); - BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData); + BBbWriteEmbedded(priv, 0x0D, byOrgData); } /* @@ -2319,7 +2319,7 @@ BBvPowerSaveModeOFF(struct vnt_private *priv) BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); byOrgData &= ~(BIT(0)); - BBbWriteEmbedded(dwIoBase, 0x0D, byOrgData); + BBbWriteEmbedded(priv, 0x0D, byOrgData); } /* @@ -2353,7 +2353,7 @@ BBvSetTxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) byBBTxConf &= 0xFD; /* 1111 1101 */ byBBTxConf |= 0x04; } - BBbWriteEmbedded(dwIoBase, 0x09, byBBTxConf); /* CR09 */ + BBbWriteEmbedded(priv, 0x09, byBBTxConf); /* CR09 */ } /* @@ -2386,7 +2386,7 @@ BBvSetRxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) byBBRxConf &= 0xFE; /* 1111 1110 */ byBBRxConf |= 0x02; } - BBbWriteEmbedded(dwIoBase, 0x0A, byBBRxConf); /* CR10 */ + BBbWriteEmbedded(priv, 0x0A, byBBRxConf); /* CR10 */ } /* @@ -2404,19 +2404,15 @@ BBvSetRxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) void BBvSetDeepSleep(struct vnt_private *priv, unsigned char byLocalID) { - void __iomem *dwIoBase = priv->PortOffset; - - BBbWriteEmbedded(dwIoBase, 0x0C, 0x17); /* CR12 */ - BBbWriteEmbedded(dwIoBase, 0x0D, 0xB9); /* CR13 */ + BBbWriteEmbedded(priv, 0x0C, 0x17); /* CR12 */ + BBbWriteEmbedded(priv, 0x0D, 0xB9); /* CR13 */ } void BBvExitDeepSleep(struct vnt_private *priv, unsigned char byLocalID) { - void __iomem *dwIoBase = priv->PortOffset; - - BBbWriteEmbedded(dwIoBase, 0x0C, 0x00); /* CR12 */ - BBbWriteEmbedded(dwIoBase, 0x0D, 0x01); /* CR13 */ + BBbWriteEmbedded(priv, 0x0C, 0x00); /* CR12 */ + BBbWriteEmbedded(priv, 0x0D, 0x01); /* CR13 */ } static diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 26f9cdcb24b8..743ec4f6538c 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -78,7 +78,7 @@ void vnt_get_phy_field(struct vnt_private *, u32 frame_length, u16 tx_rate, u8 pkt_type, struct vnt_phy_field *); bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData); -bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData); +bool BBbWriteEmbedded(struct vnt_private *, unsigned char byBBAddr, unsigned char byData); void BBvSetShortSlotTime(struct vnt_private *); void BBvSetVGAGainOffset(struct vnt_private *, unsigned char byData); diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 0121466b941d..6f1cea03513e 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -225,20 +225,20 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->abyBBVGA[3] = 0x10; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); if (byData == 0x1C) - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); } else if (pDevice->byRFType == RF_UW2452) { MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); pDevice->abyBBVGA[0] = 0x18; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); if (byData == 0x14) { - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); - BBbWriteEmbedded(pDevice->PortOffset, 0xE1, 0x57); + BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(pDevice, 0xE1, 0x57); } } else { MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); } - BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x03); + BBbWriteEmbedded(pDevice, 0x88, 0x03); bySlot = C_SLOT_SHORT; bySIFS = C_SIFS_A; byDIFS = C_SIFS_A + 2*C_SLOT_SHORT; @@ -251,17 +251,17 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->abyBBVGA[3] = 0x00; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); if (byData == 0x20) - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); } else if (pDevice->byRFType == RF_UW2452) { pDevice->abyBBVGA[0] = 0x14; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); if (byData == 0x18) { - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); - BBbWriteEmbedded(pDevice->PortOffset, 0xE1, 0xD3); + BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(pDevice, 0xE1, 0xD3); } } - BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x02); + BBbWriteEmbedded(pDevice, 0x88, 0x02); bySlot = C_SLOT_LONG; bySIFS = C_SIFS_BG; byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; @@ -274,17 +274,17 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->abyBBVGA[3] = 0x00; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); if (byData == 0x20) - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); } else if (pDevice->byRFType == RF_UW2452) { pDevice->abyBBVGA[0] = 0x14; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); if (byData == 0x18) { - BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); - BBbWriteEmbedded(pDevice->PortOffset, 0xE1, 0xD3); + BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(pDevice, 0xE1, 0xD3); } } - BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x08); + BBbWriteEmbedded(pDevice, 0x88, 0x08); bySIFS = C_SIFS_BG; if (pDevice->bShortSlotTime) { -- cgit v1.2.3-59-g8ed1b From 8e8a9f5133cf4c31b3faae3986fb26bbc39c9216 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 6 Nov 2014 20:02:04 +0000 Subject: staging: vt6655: BBbReadEmbedded replace __iomem with vnt_private Changing callers to point to private Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 22 ++++++++++------------ drivers/staging/vt6655/baseband.h | 2 +- drivers/staging/vt6655/card.c | 12 ++++++------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index f1f10754963d..86c72ba0a0cd 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1961,8 +1961,10 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length, * Return Value: true if succeeded; false if failed. * */ -bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData) +bool BBbReadEmbedded(struct vnt_private *priv, + unsigned char byBBAddr, unsigned char *pbyData) { + void __iomem *dwIoBase = priv->PortOffset; unsigned short ww; unsigned char byValue; @@ -2222,7 +2224,7 @@ BBvSetShortSlotTime(struct vnt_private *priv) unsigned char byBBRxConf = 0; unsigned char byBBVGA = 0; - BBbReadEmbedded(priv->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ + BBbReadEmbedded(priv, 0x0A, &byBBRxConf); /* CR10 */ if (priv->bShortSlotTime) byBBRxConf &= 0xDF; /* 1101 1111 */ @@ -2230,7 +2232,7 @@ BBvSetShortSlotTime(struct vnt_private *priv) byBBRxConf |= 0x20; /* 0010 0000 */ /* patch for 3253B0 Baseband with Cardbus module */ - BBbReadEmbedded(priv->PortOffset, 0xE7, &byBBVGA); + BBbReadEmbedded(priv, 0xE7, &byBBVGA); if (byBBVGA == priv->abyBBVGA[0]) byBBRxConf |= 0x20; /* 0010 0000 */ @@ -2243,7 +2245,7 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData) BBbWriteEmbedded(priv, 0xE7, byData); - BBbReadEmbedded(priv->PortOffset, 0x0A, &byBBRxConf); /* CR10 */ + BBbReadEmbedded(priv, 0x0A, &byBBRxConf); /* CR10 */ /* patch for 3253B0 Baseband with Cardbus module */ if (byData == priv->abyBBVGA[0]) byBBRxConf |= 0x20; /* 0010 0000 */ @@ -2291,10 +2293,9 @@ BBvSoftwareReset(struct vnt_private *priv) void BBvPowerSaveModeON(struct vnt_private *priv) { - void __iomem *dwIoBase = priv->PortOffset; unsigned char byOrgData; - BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); + BBbReadEmbedded(priv, 0x0D, &byOrgData); byOrgData |= BIT(0); BBbWriteEmbedded(priv, 0x0D, byOrgData); } @@ -2314,10 +2315,9 @@ BBvPowerSaveModeON(struct vnt_private *priv) void BBvPowerSaveModeOFF(struct vnt_private *priv) { - void __iomem *dwIoBase = priv->PortOffset; unsigned char byOrgData; - BBbReadEmbedded(dwIoBase, 0x0D, &byOrgData); + BBbReadEmbedded(priv, 0x0D, &byOrgData); byOrgData &= ~(BIT(0)); BBbWriteEmbedded(priv, 0x0D, byOrgData); } @@ -2339,10 +2339,9 @@ BBvPowerSaveModeOFF(struct vnt_private *priv) void BBvSetTxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) { - void __iomem *dwIoBase = priv->PortOffset; unsigned char byBBTxConf; - BBbReadEmbedded(dwIoBase, 0x09, &byBBTxConf); /* CR09 */ + BBbReadEmbedded(priv, 0x09, &byBBTxConf); /* CR09 */ if (byAntennaMode == ANT_DIVERSITY) { /* bit 1 is diversity */ byBBTxConf |= 0x02; @@ -2373,10 +2372,9 @@ BBvSetTxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) void BBvSetRxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode) { - void __iomem *dwIoBase = priv->PortOffset; unsigned char byBBRxConf; - BBbReadEmbedded(dwIoBase, 0x0A, &byBBRxConf); /* CR10 */ + BBbReadEmbedded(priv, 0x0A, &byBBRxConf); /* CR10 */ if (byAntennaMode == ANT_DIVERSITY) { byBBRxConf |= 0x01; diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 743ec4f6538c..d9f6d63e4ab7 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -77,7 +77,7 @@ BBuGetFrameTime( void vnt_get_phy_field(struct vnt_private *, u32 frame_length, u16 tx_rate, u8 pkt_type, struct vnt_phy_field *); -bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData); +bool BBbReadEmbedded(struct vnt_private *, unsigned char byBBAddr, unsigned char *pbyData); bool BBbWriteEmbedded(struct vnt_private *, unsigned char byBBAddr, unsigned char byData); void BBvSetShortSlotTime(struct vnt_private *); diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 6f1cea03513e..1869557e41d3 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -223,14 +223,14 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->abyBBVGA[0] = 0x20; pDevice->abyBBVGA[2] = 0x10; pDevice->abyBBVGA[3] = 0x10; - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); + BBbReadEmbedded(pDevice, 0xE7, &byData); if (byData == 0x1C) BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); } else if (pDevice->byRFType == RF_UW2452) { MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); pDevice->abyBBVGA[0] = 0x18; - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); + BBbReadEmbedded(pDevice, 0xE7, &byData); if (byData == 0x14) { BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); BBbWriteEmbedded(pDevice, 0xE1, 0x57); @@ -249,13 +249,13 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->abyBBVGA[0] = 0x1C; pDevice->abyBBVGA[2] = 0x00; pDevice->abyBBVGA[3] = 0x00; - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); + BBbReadEmbedded(pDevice, 0xE7, &byData); if (byData == 0x20) BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); } else if (pDevice->byRFType == RF_UW2452) { pDevice->abyBBVGA[0] = 0x14; - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); + BBbReadEmbedded(pDevice, 0xE7, &byData); if (byData == 0x18) { BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); BBbWriteEmbedded(pDevice, 0xE1, 0xD3); @@ -272,13 +272,13 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->abyBBVGA[0] = 0x1C; pDevice->abyBBVGA[2] = 0x00; pDevice->abyBBVGA[3] = 0x00; - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); + BBbReadEmbedded(pDevice, 0xE7, &byData); if (byData == 0x20) BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); } else if (pDevice->byRFType == RF_UW2452) { pDevice->abyBBVGA[0] = 0x14; - BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); + BBbReadEmbedded(pDevice, 0xE7, &byData); if (byData == 0x18) { BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); BBbWriteEmbedded(pDevice, 0xE1, 0xD3); -- cgit v1.2.3-59-g8ed1b From 61b90995d3629f2f6b1493d10f0b6a56d17af0ad Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 6 Nov 2014 20:02:05 +0000 Subject: staging: vt6655: Fix issue of byPacketType is not set at all. set by calling CARDbyGetPktType. change CARDbIsOFDMinBasicRate to check basic_rates. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 1869557e41d3..aaa72891fc51 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -342,6 +342,8 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin); } + pDevice->byPacketType = CARDbyGetPktType(pDevice); + CARDvSetRSPINF(pDevice, ePHYType); return true; @@ -876,7 +878,7 @@ bool CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) int ii; for (ii = RATE_54M; ii >= RATE_6M; ii--) { - if ((pDevice->wBasicRate) & ((unsigned short)(1 << ii))) + if ((pDevice->basic_rates) & ((u32)(1 << ii))) return true; } return false; -- cgit v1.2.3-59-g8ed1b From 5aa1491a63d643e3eeb03b8a351a8d51d515baf7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Oct 2014 17:47:35 +0000 Subject: staging: comedi: comedidev.h: remove dummy PCI support functions Some low-level Comedi driver modules used to handle PCI devices and ISA devices in the same module with some conditional compilation. To reduce the amount of conditional compilation, some dummy inline versions of `comedi_to_pci_dev()`, `comedi_pci_enable()`, `comedi_pci_disable()`, and `comedi_pci_detach()` are defined in "comedidev.h" if `CONFIG_COMEDI_PCI_DRIVERS` is undefined. Since those Comedi low-level driver modules have since had PCI support split out into separate modules, there is no need to keep the dummy inline functions around any more, so remove them. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index bff5a581a287..0c0039a56a0c 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -603,32 +603,6 @@ void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *); module_driver(__comedi_driver, comedi_pci_driver_register, \ comedi_pci_driver_unregister, &(__pci_driver)) -#else - -/* - * Some of the comedi mixed ISA/PCI drivers call the PCI specific - * functions. Provide some dummy functions if CONFIG_COMEDI_PCI_DRIVERS - * is not enabled. - */ - -static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) -{ - return NULL; -} - -static inline int comedi_pci_enable(struct comedi_device *dev) -{ - return -ENOSYS; -} - -static inline void comedi_pci_disable(struct comedi_device *dev) -{ -} - -static inline void comedi_pci_detach(struct comedi_device *dev) -{ -} - #endif /* CONFIG_COMEDI_PCI_DRIVERS */ #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS -- cgit v1.2.3-59-g8ed1b From d51b365101d80bb99b9da723fd0cdb88e1a3ee12 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Oct 2014 17:47:36 +0000 Subject: staging: comedi: comedidev.h: remove some #ifdefs Some declarations and macro definitions in "comedidev.h" are protected by various `#ifdef`s for kernel configuration options, but the header file compiles fine without the `#ifdef`s regardless of whether those config option macros are defined or not. Remove the `#ifdef`s and compile the affected code unconditionally. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 0c0039a56a0c..b5e0ec3e4bf8 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -558,8 +558,6 @@ void comedi_driver_unregister(struct comedi_driver *); module_driver(__comedi_driver, comedi_driver_register, \ comedi_driver_unregister) -#ifdef CONFIG_COMEDI_PCI_DRIVERS - /* comedi_pci.c - comedi PCI driver specific functions */ /* @@ -603,10 +601,6 @@ void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *); module_driver(__comedi_driver, comedi_pci_driver_register, \ comedi_pci_driver_unregister, &(__pci_driver)) -#endif /* CONFIG_COMEDI_PCI_DRIVERS */ - -#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS - /* comedi_pcmcia.c - comedi PCMCIA driver specific functions */ struct pcmcia_driver; @@ -640,10 +634,6 @@ void comedi_pcmcia_driver_unregister(struct comedi_driver *, module_driver(__comedi_driver, comedi_pcmcia_driver_register, \ comedi_pcmcia_driver_unregister, &(__pcmcia_driver)) -#endif /* CONFIG_COMEDI_PCMCIA_DRIVERS */ - -#ifdef CONFIG_COMEDI_USB_DRIVERS - /* comedi_usb.c - comedi USB driver specific functions */ struct usb_driver; @@ -673,6 +663,4 @@ void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *); module_driver(__comedi_driver, comedi_usb_driver_register, \ comedi_usb_driver_unregister, &(__usb_driver)) -#endif /* CONFIG_COMEDI_USB_DRIVERS */ - #endif /* _COMEDIDEV_H */ -- cgit v1.2.3-59-g8ed1b From aae434b3c34d124abe2dc4ea86d9ba9b2bcf403a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Oct 2014 17:47:37 +0000 Subject: staging: comedi: split out PCMCIA support into new module Setting the `CONFIG_COMEDI_PCMCIA_DRIVERS` kernel configuration option makes the main "comedi" module depend on the "pcmcia" module, but many machines don't have PCMCIA slots and only a few low-level Comedi drivers need PCMCIA support. The Comedi PCMCIA support functions are all in "comedi_pcmcia.c". Turn it into a separate module so we don't have to pull in the other PCMCIA support modules unnecessarily. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 5 ++++- drivers/staging/comedi/Makefile | 3 ++- drivers/staging/comedi/comedi_pcmcia.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index b2d68ecb5e24..862b18fa2de4 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1076,11 +1076,14 @@ config COMEDI_NI_TIOCMD endif # COMEDI_PCI_DRIVERS menuconfig COMEDI_PCMCIA_DRIVERS - bool "Comedi PCMCIA drivers" + tristate "Comedi PCMCIA drivers" depends on PCMCIA ---help--- Enable support for comedi PCMCIA drivers. + To compile this support as a module, choose M here: the module will + be called comedi_pcmcia. + if COMEDI_PCMCIA_DRIVERS config COMEDI_CB_DAS16_CS diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile index fae2d9090006..cfb121a52978 100644 --- a/drivers/staging/comedi/Makefile +++ b/drivers/staging/comedi/Makefile @@ -3,11 +3,12 @@ ccflags-$(CONFIG_COMEDI_DEBUG) := -DDEBUG comedi-y := comedi_fops.o range.o drivers.o \ comedi_buf.o comedi-$(CONFIG_COMEDI_PCI_DRIVERS) += comedi_pci.o -comedi-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += comedi_pcmcia.o comedi-$(CONFIG_COMEDI_USB_DRIVERS) += comedi_usb.o comedi-$(CONFIG_PROC_FS) += proc.o comedi-$(CONFIG_COMPAT) += comedi_compat32.o +obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += comedi_pcmcia.o + obj-$(CONFIG_COMEDI) += comedi.o obj-$(CONFIG_COMEDI) += kcomedilib/ diff --git a/drivers/staging/comedi/comedi_pcmcia.c b/drivers/staging/comedi/comedi_pcmcia.c index 9d49d5d01ad9..0529bae8e5ac 100644 --- a/drivers/staging/comedi/comedi_pcmcia.c +++ b/drivers/staging/comedi/comedi_pcmcia.c @@ -16,6 +16,7 @@ * GNU General Public License for more details. */ +#include #include #include @@ -154,3 +155,18 @@ void comedi_pcmcia_driver_unregister(struct comedi_driver *comedi_driver, comedi_driver_unregister(comedi_driver); } EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister); + +static int __init comedi_pcmcia_init(void) +{ + return 0; +} +module_init(comedi_pcmcia_init); + +static void __exit comedi_pcmcia_exit(void) +{ +} +module_exit(comedi_pcmcia_exit); + +MODULE_AUTHOR("http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi PCMCIA interface module"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From ba9ac25e96241d7f059dac3fcb9175c1491e425d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Oct 2014 17:47:38 +0000 Subject: staging: comedi: split out USB support into new module Setting the `CONFIG_COMEDI_USB_DRIVERS` kernel configuration option makes the main "comedi" module depend on the "usbcore" module. But perhaps the machine has no USB controllers (or they have been disabled), in which case the "usbcore" module may have been pulled in unnecessarily. Only a few low-level Comedi drivers require USB support. The Comedi USB support functions are all in "comedi_usb.c". Turn it into a separate module so we don't have to pull in the "usbcore" and "usb_common" modules unnecessarily. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 5 ++++- drivers/staging/comedi/Makefile | 2 +- drivers/staging/comedi/comedi_usb.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 862b18fa2de4..9e22ea1f8c54 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -1155,11 +1155,14 @@ config COMEDI_QUATECH_DAQP_CS endif # COMEDI_PCMCIA_DRIVERS menuconfig COMEDI_USB_DRIVERS - bool "Comedi USB drivers" + tristate "Comedi USB drivers" depends on USB ---help--- Enable support for comedi USB drivers. + To compile this support as a module, choose M here: the module will + be called comedi_usb. + if COMEDI_USB_DRIVERS config COMEDI_DT9812 diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile index cfb121a52978..e28eaeb598be 100644 --- a/drivers/staging/comedi/Makefile +++ b/drivers/staging/comedi/Makefile @@ -3,11 +3,11 @@ ccflags-$(CONFIG_COMEDI_DEBUG) := -DDEBUG comedi-y := comedi_fops.o range.o drivers.o \ comedi_buf.o comedi-$(CONFIG_COMEDI_PCI_DRIVERS) += comedi_pci.o -comedi-$(CONFIG_COMEDI_USB_DRIVERS) += comedi_usb.o comedi-$(CONFIG_PROC_FS) += proc.o comedi-$(CONFIG_COMPAT) += comedi_compat32.o obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += comedi_pcmcia.o +obj-$(CONFIG_COMEDI_USB_DRIVERS) += comedi_usb.o obj-$(CONFIG_COMEDI) += comedi.o diff --git a/drivers/staging/comedi/comedi_usb.c b/drivers/staging/comedi/comedi_usb.c index 13f18bef6091..0b862a64c049 100644 --- a/drivers/staging/comedi/comedi_usb.c +++ b/drivers/staging/comedi/comedi_usb.c @@ -16,6 +16,7 @@ * GNU General Public License for more details. */ +#include #include #include "comedidev.h" @@ -114,3 +115,18 @@ void comedi_usb_driver_unregister(struct comedi_driver *comedi_driver, comedi_driver_unregister(comedi_driver); } EXPORT_SYMBOL_GPL(comedi_usb_driver_unregister); + +static int __init comedi_usb_init(void) +{ + return 0; +} +module_init(comedi_usb_init); + +static void __exit comedi_usb_exit(void) +{ +} +module_exit(comedi_usb_exit); + +MODULE_AUTHOR("http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi USB interface module"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From bc3fe15655c2bac782f45dce8b8c1537f07d9e81 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Oct 2014 17:47:39 +0000 Subject: staging: comedi: split out PCI support into new module Setting the `CONFIG_COMEDI_PCI_DRIVERS` kernel configuration option makes the main "comedi" module depend on the PCI support in the kernel. That's not that big a deal since PCI support in the kernel is either built into the kernel or is absent, and is not in a separate module. Still, not all low-level Comedi drivers need PCI support, so we could save a bit of space by not including it. The Comedi PCI support functions are all in "comedi_pci.c". Turn it into a separate module so the support code doesn't have to be loaded unnecessarily. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 5 ++++- drivers/staging/comedi/Makefile | 2 +- drivers/staging/comedi/comedi_pci.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 9e22ea1f8c54..cf52577349a7 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -564,11 +564,14 @@ config COMEDI_S526 endif # COMEDI_ISA_DRIVERS menuconfig COMEDI_PCI_DRIVERS - bool "Comedi PCI drivers" + tristate "Comedi PCI drivers" depends on PCI ---help--- Enable support for comedi PCI drivers. + To compile this support as a module, choose M here: the module will + be called comedi_pci. + if COMEDI_PCI_DRIVERS config COMEDI_8255_PCI diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile index e28eaeb598be..7f9dfb3923ab 100644 --- a/drivers/staging/comedi/Makefile +++ b/drivers/staging/comedi/Makefile @@ -2,10 +2,10 @@ ccflags-$(CONFIG_COMEDI_DEBUG) := -DDEBUG comedi-y := comedi_fops.o range.o drivers.o \ comedi_buf.o -comedi-$(CONFIG_COMEDI_PCI_DRIVERS) += comedi_pci.o comedi-$(CONFIG_PROC_FS) += proc.o comedi-$(CONFIG_COMPAT) += comedi_compat32.o +obj-$(CONFIG_COMEDI_PCI_DRIVERS) += comedi_pci.o obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS) += comedi_pcmcia.o obj-$(CONFIG_COMEDI_USB_DRIVERS) += comedi_usb.o diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/staging/comedi/comedi_pci.c index aa0795a2660e..6ba59c977006 100644 --- a/drivers/staging/comedi/comedi_pci.c +++ b/drivers/staging/comedi/comedi_pci.c @@ -16,6 +16,7 @@ * GNU General Public License for more details. */ +#include #include #include @@ -168,3 +169,18 @@ void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver, comedi_driver_unregister(comedi_driver); } EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister); + +static int __init comedi_pci_init(void) +{ + return 0; +} +module_init(comedi_pci_init); + +static void __exit comedi_pci_exit(void) +{ +} +module_exit(comedi_pci_exit); + +MODULE_AUTHOR("http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi PCI interface module"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From 2ee37750014220c5cc5f560e967432edb870c890 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:29 -0700 Subject: staging: comedi: drivers: introduce comedi_nscans_left() Introduce a helper function to determine the number of scans left in the async command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 2 ++ drivers/staging/comedi/drivers.c | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index b5e0ec3e4bf8..616e9b08c026 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -516,6 +516,8 @@ int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *, unsigned int comedi_dio_update_state(struct comedi_subdevice *, unsigned int *data); unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s); +unsigned int comedi_nscans_left(struct comedi_subdevice *s, + unsigned int nscans); void comedi_inc_scan_progress(struct comedi_subdevice *s, unsigned int num_bytes); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 02a01baf5cc6..00194a5092cf 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -327,6 +327,45 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) } EXPORT_SYMBOL_GPL(comedi_bytes_per_scan); +/** + * comedi_nscans_left - return the number of scans left in the command + * @s: comedi_subdevice struct + * @nscans: the expected number of scans + * + * If nscans is 0, the number of scans available in the async buffer will be + * used. Otherwise the expected number of scans will be used. + * + * If the async command has a stop_src of TRIG_COUNT, the nscans will be + * checked against the number of scans left in the command. + * + * The return value will then be either the expected number of scans or the + * number of scans remaining in the command. + */ +unsigned int comedi_nscans_left(struct comedi_subdevice *s, + unsigned int nscans) +{ + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + + if (nscans == 0) { + unsigned int nbytes = comedi_buf_read_n_available(s); + + nscans = nbytes / comedi_bytes_per_scan(s); + } + + if (cmd->stop_src == TRIG_COUNT) { + unsigned int scans_left = 0; + + if (async->scans_done < cmd->stop_arg) + scans_left = cmd->stop_arg - async->scans_done; + + if (nscans > scans_left) + nscans = scans_left; + } + return nscans; +} +EXPORT_SYMBOL_GPL(comedi_nscans_left); + /** * comedi_inc_scan_progress - update scan progress in asynchronous command * @s: comedi_subdevice struct -- cgit v1.2.3-59-g8ed1b From d682141e59676c2c31c2c8a939348369429b1042 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:30 -0700 Subject: staging: comedi: amplc_pci224: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ao_stop_count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Use the helper function comedi_nscans_left() to determine the number of scans available in the async buffer or left in the command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 43 ++++++++------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 342779f1f84a..a896f0192fbd 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -381,7 +381,6 @@ struct pci224_private { unsigned short daccon; unsigned int cached_div1; unsigned int cached_div2; - unsigned int ao_stop_count; unsigned short ao_enab; /* max 16 channels so 'short' will do */ unsigned char intsce; }; @@ -514,26 +513,18 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, { struct pci224_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int num_scans; + unsigned int num_scans = comedi_nscans_left(s, 0); unsigned int room; unsigned short dacstat; unsigned int i, n; - /* Determine number of scans available in buffer. */ - num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s); - if (cmd->stop_src == TRIG_COUNT) { - /* Fixed number of scans. */ - if (num_scans > devpriv->ao_stop_count) - num_scans = devpriv->ao_stop_count; - } - /* Determine how much room is in the FIFO (in samples). */ dacstat = inw(dev->iobase + PCI224_DACCON); switch (dacstat & PCI224_DACCON_FIFOFL_MASK) { case PCI224_DACCON_FIFOFL_EMPTY: room = PCI224_FIFO_ROOM_EMPTY; if (cmd->stop_src == TRIG_COUNT && - devpriv->ao_stop_count == 0) { + s->async->scans_done >= cmd->stop_arg) { /* FIFO empty at end of counted acquisition. */ s->async->events |= COMEDI_CB_EOA; comedi_handle_events(dev, s); @@ -574,18 +565,16 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, dev->iobase + PCI224_DACDATA); } } - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ao_stop_count -= num_scans; - if (devpriv->ao_stop_count == 0) { - /* - * Change FIFO interrupt trigger level to wait - * until FIFO is empty. - */ - devpriv->daccon = COMBINE(devpriv->daccon, - PCI224_DACCON_FIFOINTR_EMPTY, - PCI224_DACCON_FIFOINTR_MASK); - outw(devpriv->daccon, dev->iobase + PCI224_DACCON); - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) { + /* + * Change FIFO interrupt trigger level to wait + * until FIFO is empty. + */ + devpriv->daccon = COMBINE(devpriv->daccon, + PCI224_DACCON_FIFOINTR_EMPTY, + PCI224_DACCON_FIFOINTR_MASK); + outw(devpriv->daccon, dev->iobase + PCI224_DACCON); } if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) == PCI224_DACCON_TRIG_NONE) { @@ -907,14 +896,6 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->scan_begin_src == TRIG_TIMER) pci224_ao_start_pacer(dev, s); - /* - * Sort out end of acquisition. - */ - if (cmd->stop_src == TRIG_COUNT) - devpriv->ao_stop_count = cmd->stop_arg; - else /* TRIG_EXT | TRIG_NONE */ - devpriv->ao_stop_count = 0; - spin_lock_irqsave(&devpriv->ao_spinlock, flags); if (cmd->start_src == TRIG_INT) { s->async->inttrig = pci224_ao_inttrig_start; -- cgit v1.2.3-59-g8ed1b From f5345d459b4bf5382ad5e419544b7b99f6674c6f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:31 -0700 Subject: staging: comedi: comedi_test: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Use the helper function comedi_nscans_left() to check if the number of scans left in the command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 1b1399bcda5c..e56525a1c8f3 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -68,7 +68,6 @@ struct waveform_private { unsigned long usec_period; /* waveform period in microseconds */ unsigned long usec_current; /* current time (mod waveform period) */ unsigned long usec_remainder; /* usec since last scan */ - unsigned long ai_count; /* number of conversions remaining */ unsigned long state_bits; unsigned int scan_period; /* scan period in usec */ unsigned int convert_period; /* conversion period in usec */ @@ -178,7 +177,6 @@ static void waveform_ai_interrupt(unsigned long arg) unsigned long elapsed_time; unsigned int num_scans; ktime_t now; - bool stopping = false; /* check command is still active */ if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits)) @@ -193,16 +191,7 @@ static void waveform_ai_interrupt(unsigned long arg) devpriv->usec_remainder = (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period; - if (cmd->stop_src == TRIG_COUNT) { - unsigned int remaining = cmd->stop_arg - devpriv->ai_count; - - if (num_scans >= remaining) { - /* about to finish */ - num_scans = remaining; - stopping = true; - } - } - + num_scans = comedi_nscans_left(s, num_scans); for (i = 0; i < num_scans; i++) { for (j = 0; j < cmd->chanlist_len; j++) { unsigned short sample; @@ -216,11 +205,10 @@ static void waveform_ai_interrupt(unsigned long arg) } } - devpriv->ai_count += i; devpriv->usec_current += elapsed_time; devpriv->usec_current %= devpriv->usec_period; - if (stopping) + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) async->events |= COMEDI_CB_EOA; else mod_timer(&devpriv->timer, jiffies + 1); @@ -317,7 +305,6 @@ static int waveform_ai_cmd(struct comedi_device *dev, return -1; } - devpriv->ai_count = 0; devpriv->scan_period = cmd->scan_begin_arg / nano_per_micro; if (cmd->convert_src == TRIG_NOW) -- cgit v1.2.3-59-g8ed1b From a65ccf634c91005bfc2c715b09aa43c1b18ce865 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:32 -0700 Subject: staging: comedi: amplc_pci230: use comedi_async 'scans_done' to detect AO EOA Remove the private data member 'ai_count' and use the comedi_async 'scans_done' member to detect the analog output end-of-acquisition. Use the helper function comedi_nscans_left() to get the number of scans in the async buffer of left in the command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 57 +++++++++------------------ 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index a46fffd28a3e..5f4b67505932 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -491,7 +491,6 @@ struct pci230_private { spinlock_t ao_stop_spinlock; /* Spin lock for stopping AO command */ unsigned long daqio; /* PCI230's DAQ I/O space */ unsigned int ai_scan_count; /* Number of AI scans remaining */ - unsigned int ao_scan_count; /* Number of AO scans remaining. */ int intr_cpuid; /* ID of CPU running ISR */ unsigned short hwver; /* Hardware version (for '+' models) */ unsigned short adccon; /* ADCCON register value */ @@ -1073,13 +1072,12 @@ static void pci230_ao_stop(struct comedi_device *dev, static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pci230_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned short data; int i; - if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0) + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) return; for (i = 0; i < cmd->chanlist_len; i++) { @@ -1093,13 +1091,8 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, s->readback[chan] = data; } - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ao_scan_count--; - if (devpriv->ao_scan_count == 0) { - /* End of acquisition. */ - async->events |= COMEDI_CB_EOA; - } - } + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; } /* @@ -1112,7 +1105,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, struct pci230_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned int num_scans; + unsigned int num_scans = comedi_nscans_left(s, 0); unsigned int room; unsigned short dacstat; unsigned int i, n; @@ -1120,17 +1113,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, /* Get DAC FIFO status. */ dacstat = inw(devpriv->daqio + PCI230_DACCON); - /* Determine number of scans available in buffer. */ - num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s); - if (cmd->stop_src == TRIG_COUNT) { - /* Fixed number of scans. */ - if (num_scans > devpriv->ao_scan_count) - num_scans = devpriv->ao_scan_count; - if (devpriv->ao_scan_count == 0) { - /* End of acquisition. */ - events |= COMEDI_CB_EOA; - } - } + + if (cmd->stop_src == TRIG_COUNT && num_scans == 0) + events |= COMEDI_CB_EOA; + if (events == 0) { /* Check for FIFO underrun. */ if (dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) { @@ -1175,21 +1161,16 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, } } - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ao_scan_count -= num_scans; - if (devpriv->ao_scan_count == 0) { - /* - * All data for the command has been written - * to FIFO. Set FIFO interrupt trigger level - * to 'empty'. - */ - devpriv->daccon = - (devpriv->daccon & - ~PCI230P2_DAC_INT_FIFO_MASK) | - PCI230P2_DAC_INT_FIFO_EMPTY; - outw(devpriv->daccon, - devpriv->daqio + PCI230_DACCON); - } + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + /* + * All data for the command has been written + * to FIFO. Set FIFO interrupt trigger level + * to 'empty'. + */ + devpriv->daccon &= ~PCI230P2_DAC_INT_FIFO_MASK; + devpriv->daccon |= PCI230P2_DAC_INT_FIFO_EMPTY; + outw(devpriv->daccon, devpriv->daqio + PCI230_DACCON); } /* Check if FIFO underrun occurred while writing to FIFO. */ dacstat = inw(devpriv->daqio + PCI230_DACCON); @@ -1341,8 +1322,6 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EBUSY; } - devpriv->ao_scan_count = cmd->stop_arg; - /* * Set range - see analogue output range table; 0 => unipolar 10V, * 1 => bipolar +/-10V range scale -- cgit v1.2.3-59-g8ed1b From f615915ee5faf74d8912df1694e810c8269f6b3f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:33 -0700 Subject: staging: comedi: drivers: introduce comedi_nsamples_left() Introduce a helper function to calculate the number of samples remaining when the cmd->stop_src is TRIG_COUNT. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 2 ++ drivers/staging/comedi/drivers.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 616e9b08c026..77be191988ca 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -518,6 +518,8 @@ unsigned int comedi_dio_update_state(struct comedi_subdevice *, unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s); unsigned int comedi_nscans_left(struct comedi_subdevice *s, unsigned int nscans); +unsigned int comedi_nsamples_left(struct comedi_subdevice *s, + unsigned int nsamples); void comedi_inc_scan_progress(struct comedi_subdevice *s, unsigned int num_bytes); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 00194a5092cf..82ac84504589 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -366,6 +366,38 @@ unsigned int comedi_nscans_left(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_nscans_left); +/** + * comedi_nsamples_left - return the number of samples left in the command + * @s: comedi_subdevice struct + * @nsamples: the expected number of samples + * + * Returns the expected number of samples of the number of samples remaining + * in the command. + */ +unsigned int comedi_nsamples_left(struct comedi_subdevice *s, + unsigned int nsamples) +{ + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + + if (cmd->stop_src == TRIG_COUNT) { + /* +1 to force comedi_nscans_left() to return the scans left */ + unsigned int nscans = (nsamples / cmd->scan_end_arg) + 1; + unsigned int scans_left = comedi_nscans_left(s, nscans); + unsigned long long samples_left = 0; + + if (scans_left) { + samples_left = ((unsigned long long)scans_left * + cmd->scan_end_arg) - async->cur_chan; + } + + if (samples_left < nsamples) + nsamples = samples_left; + } + return nsamples; +} +EXPORT_SYMBOL_GPL(comedi_nsamples_left); + /** * comedi_inc_scan_progress - update scan progress in asynchronous command * @s: comedi_subdevice struct -- cgit v1.2.3-59-g8ed1b From c6de95f467073aa0913de9bace18946c51283826 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:34 -0700 Subject: staging: comedi: amplc_pci230: use comedi_async 'scans_done' to detect AI EOA Remove the private data member 'ai_scan_count' and use the comedi_async 'scans_done' member to detect the analog input end-of-acquisition. Use the comedi_nsamples_left() helper to work out the number of 'wake' samples in pci230_ai_update_fifo_trigger_level() and the number of 'todo' samples actually added to the async buffer in pci230_handle_ai(). Remove the unnecessary COMEDI_CB_OVERFLOW event for the hardware FIFO overflow error. The COMEDI_CB_ERROR event will terminate the command. comedi_buf_write_samples() can fail if the async buffer does not have room for the sample. The it will set the COMEDI_CB_OVERFLOW event and return 0. Detect this and quit trying to read and add more samples. The event will terminate the command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 53 +++++++++------------------ 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 5f4b67505932..fb0b70fdce7d 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -490,7 +490,6 @@ struct pci230_private { spinlock_t ai_stop_spinlock; /* Spin lock for stopping AI command */ spinlock_t ao_stop_spinlock; /* Spin lock for stopping AO command */ unsigned long daqio; /* PCI230's DAQ I/O space */ - unsigned int ai_scan_count; /* Number of AI scans remaining */ int intr_cpuid; /* ID of CPU running ISR */ unsigned short hwver; /* Hardware version (for '+' models) */ unsigned short adccon; /* ADCCON register value */ @@ -1720,19 +1719,15 @@ static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev, { struct pci230_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int scanlen = cmd->scan_end_arg; unsigned int wake; unsigned short triglev; unsigned short adccon; if (cmd->flags & CMDF_WAKE_EOS) - wake = scanlen - s->async->cur_chan; - else if (cmd->stop_src != TRIG_COUNT || - devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL || - scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL) - wake = PCI230_ADC_FIFOLEVEL_HALFFULL; + wake = cmd->scan_end_arg - s->async->cur_chan; else - wake = devpriv->ai_scan_count * scanlen - s->async->cur_chan; + wake = comedi_nsamples_left(s, PCI230_ADC_FIFOLEVEL_HALFFULL); + if (wake >= PCI230_ADC_FIFOLEVEL_HALFFULL) { triglev = PCI230_ADC_INT_FIFO_HALF; } else if (wake > 1 && devpriv->hwver > 0) { @@ -2025,8 +2020,6 @@ static void pci230_handle_ai(struct comedi_device *dev, struct pci230_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned int scanlen = cmd->scan_end_arg; - unsigned int events = 0; unsigned int status_fifo; unsigned int i; unsigned int todo; @@ -2034,20 +2027,10 @@ static void pci230_handle_ai(struct comedi_device *dev, unsigned short val; /* Determine number of samples to read. */ - if (cmd->stop_src != TRIG_COUNT) { - todo = PCI230_ADC_FIFOLEVEL_HALFFULL; - } else if (devpriv->ai_scan_count == 0) { - todo = 0; - } else if (devpriv->ai_scan_count > PCI230_ADC_FIFOLEVEL_HALFFULL || - scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL) { - todo = PCI230_ADC_FIFOLEVEL_HALFFULL; - } else { - todo = devpriv->ai_scan_count * scanlen - async->cur_chan; - if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL) - todo = PCI230_ADC_FIFOLEVEL_HALFFULL; - } + todo = comedi_nsamples_left(s, PCI230_ADC_FIFOLEVEL_HALFFULL); if (todo == 0) return; + fifoamount = 0; for (i = 0; i < todo; i++) { if (fifoamount == 0) { @@ -2059,7 +2042,7 @@ static void pci230_handle_ai(struct comedi_device *dev, * unnoticed by the caller. */ dev_err(dev->class_dev, "AI FIFO overrun\n"); - events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; + async->events |= COMEDI_CB_ERROR; break; } else if (status_fifo & PCI230_ADC_FIFO_EMPTY) { /* FIFO empty. */ @@ -2080,21 +2063,21 @@ static void pci230_handle_ai(struct comedi_device *dev, } val = pci230_ai_read(dev); - comedi_buf_write_samples(s, &val, 1); + if (!comedi_buf_write_samples(s, &val, 1)) + break; fifoamount--; - if (async->cur_chan == 0) - devpriv->ai_scan_count--; - } - if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) { - /* End of acquisition. */ - events |= COMEDI_CB_EOA; + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + async->events |= COMEDI_CB_EOA; + break; + } } - async->events |= events; - if (!(async->events & COMEDI_CB_CANCEL_MASK)) { - /* update FIFO interrupt trigger level */ + + /* update FIFO interrupt trigger level if still running */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) pci230_ai_update_fifo_trigger_level(dev, s); - } } static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) @@ -2130,8 +2113,6 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (!pci230_claim_shared(dev, res_mask, OWNER_AICMD)) return -EBUSY; - devpriv->ai_scan_count = cmd->stop_arg; - /* * Steps: * - Set channel scan list. -- cgit v1.2.3-59-g8ed1b From 979f99963cedb8a25f21ac9315082719d768379b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:35 -0700 Subject: staging: comedi: usbduxfast: use comedi_async 'scans_done' to detect AI EOA Remove the private data member 'ai_sample_count' and use the comedi_async 'scans_done' member to detect the analog input end-of-acquisition. Use the comedi_nsamples_left() helper to get the number of samples to actually add to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 5de76aba8fd9..ddc4cb9d5ed4 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -161,7 +161,6 @@ struct usbduxfast_private { uint8_t *duxbuf; int8_t *inbuf; short int ai_cmd_running; /* asynchronous command is running */ - long int ai_sample_count; /* number of samples to acquire */ int ignore; /* counter which ignores the first buffers */ struct semaphore sem; @@ -251,15 +250,12 @@ static void usbduxfast_ai_handle_urb(struct comedi_device *dev, unsigned int nsamples; nsamples = comedi_bytes_to_samples(s, urb->actual_length); - if (cmd->stop_src == TRIG_COUNT) { - if (devpriv->ai_sample_count < nsamples) { - nsamples = devpriv->ai_sample_count; - async->events |= COMEDI_CB_EOA; - } - devpriv->ai_sample_count -= nsamples; - } - + nsamples = comedi_nsamples_left(s, nsamples); comedi_buf_write_samples(s, urb->transfer_buffer, nsamples); + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; } /* if command is still running, resubmit urb for BULK transfer */ @@ -788,11 +784,6 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, return result; } - if (cmd->stop_src == TRIG_COUNT) - devpriv->ai_sample_count = cmd->stop_arg * cmd->scan_end_arg; - else /* TRIG_NONE */ - devpriv->ai_sample_count = 0; - if ((cmd->start_src == TRIG_NOW) || (cmd->start_src == TRIG_EXT)) { /* enable this acquisition operation */ devpriv->ai_cmd_running = 1; -- cgit v1.2.3-59-g8ed1b From f9f983821691fde4539c18e43634d5f9cfa8c011 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:36 -0700 Subject: staging: comedi: cb_pcidas: use comedi_async 'scans_done' to detect AI EOA Remove the private data member 'count' and use the comedi_async 'scans_done' member to detect the analog input end-of-acquisition. Use the comedi_nsamples_left() helper to get the number of samples to actually add to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 1c38cd5f846c..e211ef8650c4 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -346,8 +346,6 @@ struct cb_pcidas_private { /* divisors of master clock for analog input pacing */ unsigned int divisor1; unsigned int divisor2; - /* number of analog input samples remaining */ - unsigned int count; /* bits to write to registers */ unsigned int adc_fifo_bits; unsigned int s5933_intcsr_bits; @@ -976,9 +974,6 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, if (cmd->scan_begin_src == TRIG_TIMER || cmd->convert_src == TRIG_TIMER) cb_pcidas_ai_load_counters(dev); - /* set number of conversions */ - if (cmd->stop_src == TRIG_COUNT) - devpriv->count = cmd->chanlist_len * cmd->stop_arg; /* enable interrupts */ spin_lock_irqsave(&dev->spinlock, flags); devpriv->adc_fifo_bits |= INTE; @@ -1352,17 +1347,15 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) /* if fifo half-full */ if (status & ADHFI) { /* read data */ - num_samples = half_fifo; - if (cmd->stop_src == TRIG_COUNT && - num_samples > devpriv->count) { - num_samples = devpriv->count; - } + num_samples = comedi_nsamples_left(s, half_fifo); insw(devpriv->adc_fifo + ADCDATA, devpriv->ai_buffer, num_samples); comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples); - devpriv->count -= num_samples; - if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) async->events |= COMEDI_CB_EOA; + /* clear half-full interrupt latch */ spin_lock_irqsave(&dev->spinlock, flags); outw(devpriv->adc_fifo_bits | INT, @@ -1379,9 +1372,9 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) break; val = inw(devpriv->adc_fifo); comedi_buf_write_samples(s, &val, 1); + if (cmd->stop_src == TRIG_COUNT && - --devpriv->count == 0) { - /* end of acquisition */ + async->scans_done >= cmd->stop_arg) { async->events |= COMEDI_CB_EOA; break; } -- cgit v1.2.3-59-g8ed1b From 9e4d755cdf0e98daa186733765e5fa14395717af Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:37 -0700 Subject: staging: comedi: cb_pcidas: use comedi_async 'scans_done' to detect AO EOA Remove the private data member 'ao_count' and use the comedi_async 'scans_done' member to detect the analog output end-of-acquisition. Use the comedi_nsamples_left() helper to get the number of samples to actually read from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index e211ef8650c4..10c67fec75a0 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -356,8 +356,6 @@ struct cb_pcidas_private { /* divisors of master clock for analog output pacing */ unsigned int ao_divisor1; unsigned int ao_divisor2; - /* number of analog output samples remaining */ - unsigned int ao_count; unsigned int caldac_value[NUM_CHANNELS_8800]; unsigned int trimpot_value[NUM_CHANNELS_8402]; unsigned int dac08_value; @@ -1134,17 +1132,12 @@ static void cb_pcidas_ao_load_fifo(struct comedi_device *dev, unsigned int nsamples) { struct cb_pcidas_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; unsigned int nbytes; - if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples) - nsamples = devpriv->ao_count; - + nsamples = comedi_nsamples_left(s, nsamples); nbytes = comedi_buf_read_samples(s, devpriv->ao_buffer, nsamples); - nsamples = comedi_bytes_to_samples(s, nbytes); - if (cmd->stop_src == TRIG_COUNT) - devpriv->ao_count -= nsamples; + nsamples = comedi_bytes_to_samples(s, nbytes); outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, nsamples); } @@ -1226,9 +1219,6 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev, if (cmd->scan_begin_src == TRIG_TIMER) cb_pcidas_ao_load_counters(dev); - /* set number of conversions */ - if (cmd->stop_src == TRIG_COUNT) - devpriv->ao_count = cmd->chanlist_len * cmd->stop_arg; /* set pacer source */ spin_lock_irqsave(&dev->spinlock, flags); switch (cmd->scan_begin_src) { @@ -1286,13 +1276,13 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) devpriv->control_status + INT_ADCFIFO); spin_unlock_irqrestore(&dev->spinlock, flags); if (inw(devpriv->ao_registers + DAC_CSR) & DAC_EMPTY) { - if (cmd->stop_src == TRIG_NONE || - (cmd->stop_src == TRIG_COUNT - && devpriv->ao_count)) { + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + async->events |= COMEDI_CB_EOA; + } else { dev_err(dev->class_dev, "dac fifo underflow\n"); async->events |= COMEDI_CB_ERROR; } - async->events |= COMEDI_CB_EOA; } } else if (status & DAHFI) { cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size / 2); -- cgit v1.2.3-59-g8ed1b From ccedb44075776474c5a4f0625387f3d44b562f4e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:38 -0700 Subject: staging: comedi: cb_pcidas64: use comedi_async 'scans_done' to detect AI EOA Remove the private data member 'ai_count' and use the comedi_async 'scans_done' member to detect the analog output end-of-acquisition. Use the comedi_nsamples_left() helper to get the number of samples to actually add to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 55 +++++++--------------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index d7b61ba6b284..375bfbb60ebb 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1065,8 +1065,6 @@ struct pcidas64_private { /* local address (used by dma controller) */ uint32_t local0_iobase; uint32_t local1_iobase; - /* number of analog input samples remaining */ - unsigned int ai_count; /* dma buffers for analog input */ uint16_t *ai_buffer[MAX_AI_DMA_RING_COUNT]; /* physical addresses of ai dma buffers */ @@ -2199,10 +2197,6 @@ static void setup_sample_counters(struct comedi_device *dev, { struct pcidas64_private *devpriv = dev->private; - if (cmd->stop_src == TRIG_COUNT) { - /* set software count */ - devpriv->ai_count = cmd->stop_arg * cmd->chanlist_len; - } /* load hardware conversion counter */ if (use_hw_sample_counter(cmd)) { writew(cmd->stop_arg & 0xffff, @@ -2642,8 +2636,6 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) { struct pcidas64_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; unsigned int i; uint16_t prepost_bits; int read_segment, read_index, write_segment, write_index; @@ -2672,22 +2664,16 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) devpriv->ai_fifo_segment_length - read_index; else num_samples = write_index - read_index; - - if (cmd->stop_src == TRIG_COUNT) { - if (devpriv->ai_count == 0) - break; - if (num_samples > devpriv->ai_count) - num_samples = devpriv->ai_count; - - devpriv->ai_count -= num_samples; - } - if (num_samples < 0) { dev_err(dev->class_dev, "cb_pcidas64: bug! num_samples < 0\n"); break; } + num_samples = comedi_nsamples_left(s, num_samples); + if (num_samples == 0) + break; + for (i = 0; i < num_samples; i++) { unsigned short val; @@ -2707,29 +2693,23 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev) { struct pcidas64_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; + unsigned int nsamples; unsigned int i; - unsigned int max_transfer = 100000; uint32_t fifo_data; int write_code = readw(devpriv->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff; int read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; - if (cmd->stop_src == TRIG_COUNT) { - if (max_transfer > devpriv->ai_count) - max_transfer = devpriv->ai_count; - - } - for (i = 0; read_code != write_code && i < max_transfer;) { + nsamples = comedi_nsamples_left(s, 100000); + for (i = 0; read_code != write_code && i < nsamples;) { unsigned short val; fifo_data = readl(dev->mmio + ADC_FIFO_REG); val = fifo_data & 0xffff; comedi_buf_write_samples(s, &val, 1); i++; - if (i < max_transfer) { + if (i < nsamples) { val = (fifo_data >> 16) & 0xffff; comedi_buf_write_samples(s, &val, 1); i++; @@ -2737,7 +2717,6 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev) read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; } - devpriv->ai_count -= i; } /* empty fifo */ @@ -2755,8 +2734,7 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) { const struct pcidas64_board *thisboard = dev->board_ptr; struct pcidas64_private *devpriv = dev->private; - struct comedi_async *async = dev->read_subdev->async; - struct comedi_cmd *cmd = &async->cmd; + struct comedi_subdevice *s = dev->read_subdev; uint32_t next_transfer_addr; int j; int num_samples = 0; @@ -2777,13 +2755,8 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) devpriv->ai_buffer_bus_addr[devpriv->ai_dma_index] + DMA_BUFFER_SIZE) && j < ai_dma_ring_count(thisboard); j++) { /* transfer data from dma buffer to comedi buffer */ - num_samples = dma_transfer_size(dev); - if (cmd->stop_src == TRIG_COUNT) { - if (num_samples > devpriv->ai_count) - num_samples = devpriv->ai_count; - devpriv->ai_count -= num_samples; - } - comedi_buf_write_samples(dev->read_subdev, + num_samples = comedi_nsamples_left(s, dma_transfer_size(dev)); + comedi_buf_write_samples(s, devpriv->ai_buffer[devpriv->ai_dma_index], num_samples); devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) % @@ -2835,10 +2808,10 @@ static void handle_ai_interrupt(struct comedi_device *dev, spin_unlock_irqrestore(&dev->spinlock, flags); } /* if we are have all the data, then quit */ - if ((cmd->stop_src == TRIG_COUNT && (int)devpriv->ai_count <= 0) || - (cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) { + if ((cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) || + (cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) async->events |= COMEDI_CB_EOA; - } comedi_handle_events(dev, s); } -- cgit v1.2.3-59-g8ed1b From 0be887b92a1d7fce7ea62d09eefacdab9b4370e8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:39 -0700 Subject: staging: comedi: cb_pcidas64: use comedi_async 'scans_done' to detect AO EOA Remove the private data member 'ao_count' and use the comedi_async 'scans_done' member to detect the analog output end-of-acquisition. Use the comedi_nsamples_left() helper to get the number of samples to actually read from the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 40 +++++++--------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 375bfbb60ebb..05da5b33834a 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1085,8 +1085,6 @@ struct pcidas64_private { dma_addr_t ao_dma_desc_bus_addr; /* keeps track of buffer where the next ao sample should go */ unsigned int ao_dma_index; - /* number of analog output samples remaining */ - unsigned long ao_count; unsigned int hw_revision; /* stc chip hardware revision number */ /* last bits sent to INTR_ENABLE_REG register */ unsigned int intr_enable_bits; @@ -2848,22 +2846,6 @@ static int last_ao_dma_load_completed(struct comedi_device *dev) return 1; } -static int ao_stopped_by_error(struct comedi_device *dev, - const struct comedi_cmd *cmd) -{ - struct pcidas64_private *devpriv = dev->private; - - if (cmd->stop_src == TRIG_NONE) - return 1; - if (cmd->stop_src == TRIG_COUNT) { - if (devpriv->ao_count) - return 1; - if (last_ao_dma_load_completed(dev) == 0) - return 1; - } - return 0; -} - static inline int ao_dma_needs_restart(struct comedi_device *dev, unsigned short dma_status) { @@ -2894,20 +2876,13 @@ static unsigned int cb_pcidas64_ao_fill_buffer(struct comedi_device *dev, unsigned short *dest, unsigned int max_bytes) { - struct pcidas64_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; unsigned int nsamples = comedi_bytes_to_samples(s, max_bytes); unsigned int actual_bytes; - if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples) - nsamples = devpriv->ao_count; - + nsamples = comedi_nsamples_left(s, nsamples); actual_bytes = comedi_buf_read_samples(s, dest, nsamples); - nsamples = comedi_bytes_to_samples(s, actual_bytes); - if (cmd->stop_src == TRIG_COUNT) - devpriv->ao_count -= nsamples; - return nsamples; + return comedi_bytes_to_samples(s, actual_bytes); } static unsigned int load_ao_dma_buffer(struct comedi_device *dev, @@ -3006,8 +2981,11 @@ static void handle_ao_interrupt(struct comedi_device *dev, } if ((status & DAC_DONE_BIT)) { - async->events |= COMEDI_CB_EOA; - if (ao_stopped_by_error(dev, cmd)) + if ((cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) || + last_ao_dma_load_completed(dev)) + async->events |= COMEDI_CB_EOA; + else async->events |= COMEDI_CB_ERROR; } comedi_handle_events(dev, s); @@ -3202,7 +3180,8 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) devpriv->main_iobase + DAC_FIFO_REG); } - if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count == 0) + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) return 0; nbytes = load_ao_dma_buffer(dev, cmd); @@ -3267,7 +3246,6 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) writew(0x0, devpriv->main_iobase + DAC_CONTROL0_REG); devpriv->ao_dma_index = 0; - devpriv->ao_count = cmd->stop_arg * cmd->chanlist_len; set_dac_select_reg(dev, cmd); set_dac_interval_regs(dev, cmd); -- cgit v1.2.3-59-g8ed1b From 2d7840c70dcf526326a770d8a993c80ef7cae43f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:40 -0700 Subject: staging: comedi: quatech_daqp_cs: use comedi_async 'scans_done' to detect EOA Remove the private data member 'count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 0630df367494..f77485b28fe2 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -65,8 +65,6 @@ struct daqp_private { enum { semaphore, buffer } interrupt_mode; struct completion eos; - - int count; }; /* The DAQP communicates with the system through a 16 byte I/O window. */ @@ -194,6 +192,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) struct comedi_device *dev = dev_id; struct daqp_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; int loop_limit = 10000; int status; @@ -227,12 +226,10 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) * and stop conversion if zero */ - if (devpriv->count > 0) { - devpriv->count--; - if (devpriv->count == 0) { - s->async->events |= COMEDI_CB_EOA; - break; - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) { + s->async->events |= COMEDI_CB_EOA; + break; } if ((loop_limit--) <= 0) @@ -573,12 +570,16 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) */ if (cmd->stop_src == TRIG_COUNT) { - devpriv->count = cmd->stop_arg * cmd->scan_end_arg; - threshold = 2 * devpriv->count; - while (threshold > DAQP_FIFO_SIZE * 3 / 4) - threshold /= 2; + unsigned long long nsamples; + unsigned long long nbytes; + + nsamples = (unsigned long long)cmd->stop_arg * + cmd->scan_end_arg; + nbytes = nsamples * comedi_bytes_per_sample(s); + while (nbytes > DAQP_FIFO_SIZE * 3 / 4) + nbytes /= 2; + threshold = nbytes; } else { - devpriv->count = -1; threshold = DAQP_FIFO_SIZE / 2; } -- cgit v1.2.3-59-g8ed1b From 605d76f6eb007aeb1dbcb7429adde73f2ef1fd9f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 5 Nov 2014 10:31:41 -0700 Subject: staging: comedi: das1800: use comedi_async 'scans_done' to detect EOA Remove the private data member 'count' and use the comedi_async 'scans_done' member to detect the end-of-acquisition. Use the comedi_nsamples_left() helper to get the number of samples to actually add to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 52 +++++++++++--------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 03b1ff9de92c..be825d21a185 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -421,7 +421,6 @@ static const struct das1800_board das1800_boards[] = { }; struct das1800_private { - unsigned int count; /* number of data points left to be taken */ unsigned int divisor1; /* value to load into board's counter 1 for timed conversions */ unsigned int divisor2; /* value to load into board's counter 2 for timed conversions */ int irq_dma_bits; /* bits for control register b */ @@ -479,41 +478,33 @@ static void das1800_handle_fifo_half_full(struct comedi_device *dev, struct comedi_subdevice *s) { struct das1800_private *devpriv = dev->private; - int numPoints = 0; /* number of points to read */ - struct comedi_cmd *cmd = &s->async->cmd; + unsigned int nsamples = comedi_nsamples_left(s, FIFO_SIZE / 2); - numPoints = FIFO_SIZE / 2; - /* if we only need some of the points */ - if (cmd->stop_src == TRIG_COUNT && devpriv->count < numPoints) - numPoints = devpriv->count; - insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints); - munge_data(dev, devpriv->ai_buf0, numPoints); - comedi_buf_write_samples(s, devpriv->ai_buf0, numPoints); - if (cmd->stop_src == TRIG_COUNT) - devpriv->count -= numPoints; + insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, nsamples); + munge_data(dev, devpriv->ai_buf0, nsamples); + comedi_buf_write_samples(s, devpriv->ai_buf0, nsamples); } static void das1800_handle_fifo_not_empty(struct comedi_device *dev, struct comedi_subdevice *s) { - struct das1800_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned short dpnt; int unipolar; - struct comedi_cmd *cmd = &s->async->cmd; unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB; while (inb(dev->iobase + DAS1800_STATUS) & FNE) { - if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) - break; dpnt = inw(dev->iobase + DAS1800_FIFO); /* convert to unsigned type if we are in a bipolar mode */ if (!unipolar) ; dpnt = munge_bipolar_sample(dev, dpnt); comedi_buf_write_samples(s, &dpnt, 1); - if (cmd->stop_src == TRIG_COUNT) - devpriv->count--; + + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + break; } } @@ -524,8 +515,8 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, unsigned int channel, uint16_t *buffer) { struct das1800_private *devpriv = dev->private; - unsigned int num_bytes, num_samples; - struct comedi_cmd *cmd = &s->async->cmd; + unsigned int nbytes; + unsigned int nsamples; disable_dma(channel); @@ -534,17 +525,12 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, clear_dma_ff(channel); /* figure out how many points to read */ - num_bytes = devpriv->dma_transfer_size - get_dma_residue(channel); - num_samples = comedi_bytes_to_samples(s, num_bytes); - - /* if we only need some of the points */ - if (cmd->stop_src == TRIG_COUNT && devpriv->count < num_samples) - num_samples = devpriv->count; + nbytes = devpriv->dma_transfer_size - get_dma_residue(channel); + nsamples = comedi_bytes_to_samples(s, nbytes); + nsamples = comedi_nsamples_left(s, nsamples); - munge_data(dev, buffer, num_samples); - comedi_buf_write_samples(s, buffer, num_samples); - if (cmd->stop_src == TRIG_COUNT) - devpriv->count -= num_samples; + munge_data(dev, buffer, nsamples); + comedi_buf_write_samples(s, buffer, nsamples); } /* flushes remaining data from board when external trigger has stopped acquisition @@ -668,7 +654,8 @@ static void das1800_ai_handler(struct comedi_device *dev) else das1800_handle_fifo_not_empty(dev, s); async->events |= COMEDI_CB_EOA; - } else if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) { /* stop_src TRIG_COUNT */ + } else if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { async->events |= COMEDI_CB_EOA; } @@ -1100,9 +1087,6 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, /* interrupt fifo half full */ devpriv->irq_dma_bits |= FIMD; } - /* determine how many conversions we need */ - if (cmd->stop_src == TRIG_COUNT) - devpriv->count = cmd->stop_arg * cmd->chanlist_len; das1800_cancel(dev, s); -- cgit v1.2.3-59-g8ed1b From dc3cfcd3f4804c9bf71e3b6152df6eb957856735 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Thu, 6 Nov 2014 19:26:47 +0900 Subject: staging: dgap: set tty's flags by tty_alloc_driver() tty's flags can be set by calling tty_alloc_driver(). Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index aa393d2941df..6418cc5687de 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -5236,7 +5236,10 @@ static int dgap_tty_register(struct board_t *brd) { int rc; - brd->serial_driver = tty_alloc_driver(MAXPORTS, 0); + brd->serial_driver = tty_alloc_driver(MAXPORTS, + TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV | + TTY_DRIVER_HARDWARE_BREAK); if (IS_ERR(brd->serial_driver)) return PTR_ERR(brd->serial_driver); @@ -5250,9 +5253,6 @@ static int dgap_tty_register(struct board_t *brd) brd->serial_driver->subtype = SERIAL_TYPE_NORMAL; brd->serial_driver->init_termios = dgap_default_termios; brd->serial_driver->driver_name = DRVSTR; - brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW | - TTY_DRIVER_DYNAMIC_DEV | - TTY_DRIVER_HARDWARE_BREAK); /* The kernel wants space to store pointers to tty_structs */ brd->serial_driver->ttys = @@ -5273,7 +5273,10 @@ static int dgap_tty_register(struct board_t *brd) * again, separately so we don't get the LD confused about what major * we are when we get into the dgap_tty_open() routine. */ - brd->print_driver = tty_alloc_driver(MAXPORTS, 0); + brd->print_driver = tty_alloc_driver(MAXPORTS, + TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV | + TTY_DRIVER_HARDWARE_BREAK); if (IS_ERR(brd->print_driver)) { rc = PTR_ERR(brd->print_driver); goto free_serial_drv; @@ -5289,9 +5292,6 @@ static int dgap_tty_register(struct board_t *brd) brd->print_driver->subtype = SERIAL_TYPE_NORMAL; brd->print_driver->init_termios = dgap_default_termios; brd->print_driver->driver_name = DRVSTR; - brd->print_driver->flags = (TTY_DRIVER_REAL_RAW | - TTY_DRIVER_DYNAMIC_DEV | - TTY_DRIVER_HARDWARE_BREAK); /* The kernel wants space to store pointers to tty_structs */ brd->print_driver->ttys = -- cgit v1.2.3-59-g8ed1b From 429161d164491f430ddbc591f45dc2cd39e0e8a1 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Thu, 6 Nov 2014 19:27:11 +0900 Subject: staging: dgap: fix memory leak caused by double allocation of tty_structs The tty_struct of serial_driver and print_driver were getting allocated twice. One is allocated in tty_alloc_driver(), the other is in dgap_tty_register(). So remove these in dgap_tty_register(). Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 6418cc5687de..688aaa43e6dc 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -5254,14 +5254,6 @@ static int dgap_tty_register(struct board_t *brd) brd->serial_driver->init_termios = dgap_default_termios; brd->serial_driver->driver_name = DRVSTR; - /* The kernel wants space to store pointers to tty_structs */ - brd->serial_driver->ttys = - kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->serial_driver->ttys) { - rc = -ENOMEM; - goto free_serial_drv; - } - /* * Entry points for driver. Called by the kernel from * tty_io.c and n_tty.c. @@ -5293,14 +5285,6 @@ static int dgap_tty_register(struct board_t *brd) brd->print_driver->init_termios = dgap_default_termios; brd->print_driver->driver_name = DRVSTR; - /* The kernel wants space to store pointers to tty_structs */ - brd->print_driver->ttys = - kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->print_driver->ttys) { - rc = -ENOMEM; - goto free_print_drv; - } - /* * Entry points for driver. Called by the kernel from * tty_io.c and n_tty.c. -- cgit v1.2.3-59-g8ed1b From 4c5dbca65bb0d2f5e940ca64d0876581f411d1a6 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Thu, 6 Nov 2014 19:27:33 +0900 Subject: staging: dgap: remove useless variables for saving tty's major The board_t has a tty_struct(serial_driver and print_driver) that has a major number. When major number is compared in dgap_tty_open(), just use brd->serial_driver{print_driver}->major. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 9 ++------- drivers/staging/dgap/dgap.h | 3 --- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 688aaa43e6dc..3f23e5b1df9c 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -4477,10 +4477,10 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) spin_lock_irqsave(&ch->ch_lock, lock_flags2); /* Figure out our type */ - if (major == brd->dgap_serial_major) { + if (major == brd->serial_driver->major) { un = &brd->channels[minor]->ch_tun; un->un_type = DGAP_SERIAL; - } else if (major == brd->dgap_transparent_print_major) { + } else if (major == brd->print_driver->major) { un = &brd->channels[minor]->ch_pun; un->un_type = DGAP_PRINT; } else { @@ -5302,10 +5302,7 @@ static int dgap_tty_register(struct board_t *brd) goto unregister_serial_drv; dgap_boards_by_major[brd->serial_driver->major] = brd; - brd->dgap_serial_major = brd->serial_driver->major; - dgap_boards_by_major[brd->print_driver->major] = brd; - brd->dgap_transparent_print_major = brd->print_driver->major; return 0; @@ -6563,7 +6560,6 @@ static void dgap_cleanup_tty(struct board_t *brd) unsigned int i; dgap_boards_by_major[brd->serial_driver->major] = NULL; - brd->dgap_serial_major = 0; for (i = 0; i < brd->nasync; i++) { tty_port_destroy(&brd->serial_ports[i]); dev = brd->channels[i]->ch_tun.un_sysfs; @@ -6575,7 +6571,6 @@ static void dgap_cleanup_tty(struct board_t *brd) kfree(brd->serial_ports); dgap_boards_by_major[brd->print_driver->major] = NULL; - brd->dgap_transparent_print_major = 0; for (i = 0; i < brd->nasync; i++) { tty_port_destroy(&brd->printer_ports[i]); dev = brd->channels[i]->ch_pun.un_sysfs; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 14e2ed0fe39b..684033156e8c 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -584,9 +584,6 @@ struct board_t { struct tty_port *printer_ports; char print_name[200]; - u32 dgap_serial_major; - u32 dgap_transparent_print_major; - struct bs_t __iomem *bd_bs; /* Base structure pointer */ char *flipbuf; /* Our flip buffer, alloced if */ -- cgit v1.2.3-59-g8ed1b From 48d43be475e48f5673b89c1faa6f7855d25f9a85 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Thu, 6 Nov 2014 19:27:59 +0900 Subject: staging: dgap: introducing find_board_by_major() use find_board_by_major function instead of getting a brd from static arrary. Becasue tty's major number doesn't start zero and we can find a brd from dgap_board[]. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 3f23e5b1df9c..f38354f04d50 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -80,7 +80,6 @@ static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ static struct class *dgap_class; -static struct board_t *dgap_boards_by_major[256]; static uint dgap_count = 500; /* @@ -4409,6 +4408,22 @@ static void dgap_tty_unthrottle(struct tty_struct *tty) spin_unlock_irqrestore(&bd->bd_lock, lock_flags); } +static struct board_t *find_board_by_major(unsigned int major) +{ + unsigned int i; + + for (i = 0; i < MAXBOARDS; i++) { + struct board_t *brd = dgap_board[i]; + if (!brd) + return NULL; + if (major == brd->serial_driver->major || + major == brd->print_driver->major) + return brd; + } + + return NULL; +} + /************************************************************************ * * TTY Entry points and helper functions @@ -4435,11 +4450,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) major = MAJOR(tty_devnum(tty)); minor = MINOR(tty_devnum(tty)); - if (major > 255) - return -EIO; - - /* Get board pointer from our array of majors we have allocated */ - brd = dgap_boards_by_major[major]; + brd = find_board_by_major(major); if (!brd) return -EIO; @@ -5301,9 +5312,6 @@ static int dgap_tty_register(struct board_t *brd) if (rc < 0) goto unregister_serial_drv; - dgap_boards_by_major[brd->serial_driver->major] = brd; - dgap_boards_by_major[brd->print_driver->major] = brd; - return 0; unregister_serial_drv: @@ -6559,7 +6567,6 @@ static void dgap_cleanup_tty(struct board_t *brd) struct device *dev; unsigned int i; - dgap_boards_by_major[brd->serial_driver->major] = NULL; for (i = 0; i < brd->nasync; i++) { tty_port_destroy(&brd->serial_ports[i]); dev = brd->channels[i]->ch_tun.un_sysfs; @@ -6570,7 +6577,6 @@ static void dgap_cleanup_tty(struct board_t *brd) put_tty_driver(brd->serial_driver); kfree(brd->serial_ports); - dgap_boards_by_major[brd->print_driver->major] = NULL; for (i = 0; i < brd->nasync; i++) { tty_port_destroy(&brd->printer_ports[i]); dev = brd->channels[i]->ch_pun.un_sysfs; -- cgit v1.2.3-59-g8ed1b From 546bf3382e41b8a5a4c216ea7bdc0f517ce04e22 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:45 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_ns_to_timer() The timer divisor calculations in this driver are over complicated. There are three timers on the board. They all use the same base clock with a fixed prescaler for each timer. The base clock used depends on the board version and type: APCI-3120 Rev A boards OSC = 14.29MHz base clock (~70ns) APCI-3120 Rev B boards OSC = 20MHz base clock (50ns) APCI-3001 boards OSC = 20MHz base clock (50ns) The prescalers for each timer are: Timer 0 CLK = OSC/10 Timer 1 CLK = OSC/1000 Timer 2 CLK = OSC/1000 Add a new member to the private data, 'osc_base', to hold the base clock time. Set this member during the board attach. Introduce a helper function to calculate the divisor needed to generate a nanosecond time with a given timer. Use the new helper function in the driver to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 137 +++++---------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 71 +++++++++++ 2 files changed, 100 insertions(+), 108 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c64799e3513c..960002dbaeca 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -309,14 +309,16 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned short us_ConvertTiming, us_TmpValue, i; + unsigned int divisor; + unsigned int ns; + unsigned short us_TmpValue, i; unsigned char b_Tmp; /* fix conversion time to 10 us */ if (!devpriv->ui_EocEosConversionTime) - us_ConvertTiming = 10; + ns = 10000; else - us_ConvertTiming = (unsigned short) (devpriv->ui_EocEosConversionTime / 1000); /* nano to useconds */ + ns = devpriv->ui_EocEosConversionTime; /* Clear software registers */ devpriv->b_TimerSelectMode = 0; @@ -329,20 +331,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, } else { devpriv->tsk_Current = current; /* Save the current process task structure */ - /* - * Testing if board have the new Quartz and calculate the time value - * to set in the timer - */ - us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS); - - /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ - if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(dev->board_name, "apci3001")) { - us_ConvertTiming = (us_ConvertTiming * 2) - 2; - } else { - us_ConvertTiming = - ((us_ConvertTiming * 12926) / 10000) - 1; - } + divisor = apci3120_ns_to_timer(dev, 0, ns, CMDF_ROUND_NEAREST); us_TmpValue = (unsigned short) devpriv->b_InterruptMode; @@ -408,8 +397,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ - outw(us_ConvertTiming, - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor, dev->iobase + APCI3120_TIMER_VALUE); us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); @@ -467,8 +455,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ - outw(us_ConvertTiming, - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor, dev->iobase + APCI3120_TIMER_VALUE); /* Set the scan bit */ devpriv->b_ModeSelectRegister = @@ -719,14 +706,11 @@ static int apci3120_cyclic_ai(int mode, struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned char b_Tmp; - unsigned int ui_DelayTiming = 0; - unsigned int ui_TimerValue1 = 0; + unsigned int divisor1 = 0; unsigned int dmalen0 = 0; unsigned int dmalen1 = 0; unsigned int ui_TimerValue2 = 0; - unsigned int ui_TimerValue0; - unsigned int ui_ConvertTiming; - unsigned short us_TmpValue; + unsigned int divisor0; /* Resets the FIFO */ inb(dev->iobase + APCI3120_RESET_FIFO); @@ -759,42 +743,17 @@ static int apci3120_cyclic_ai(int mode, /* value for timer2 minus -2 has to be done */ ui_TimerValue2 = cmd->stop_arg - 2; - ui_ConvertTiming = cmd->convert_arg; - - if (mode == 2) - ui_DelayTiming = cmd->scan_begin_arg; /* Initializes the sequence array */ if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, cmd->chanlist, 0)) return -EINVAL; - us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); - - /* EL241003 Begin: add this section to replace floats calculation by integer calculations */ - /* EL250804: Testing if board APCI3120 have the new Quartz or if it is an APCI3001 */ - if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(dev->board_name, "apci3001")) { - ui_TimerValue0 = ui_ConvertTiming * 2 - 2000; - ui_TimerValue0 = ui_TimerValue0 / 1000; - - if (mode == 2) { - ui_DelayTiming = ui_DelayTiming / 1000; - ui_TimerValue1 = ui_DelayTiming * 2 - 200; - ui_TimerValue1 = ui_TimerValue1 / 100; - } - } else { - ui_ConvertTiming = ui_ConvertTiming / 1000; - ui_TimerValue0 = ui_ConvertTiming * 12926 - 10000; - ui_TimerValue0 = ui_TimerValue0 / 10000; - - if (mode == 2) { - ui_DelayTiming = ui_DelayTiming / 1000; - ui_TimerValue1 = ui_DelayTiming * 12926 - 1; - ui_TimerValue1 = ui_TimerValue1 / 1000000; - } + divisor0 = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); + if (mode == 2) { + divisor1 = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg, + cmd->flags); } - /* EL241003 End */ if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) apci3120_exttrig_enable(dev); /* activate EXT trigger */ @@ -813,8 +772,7 @@ static int apci3120_cyclic_ai(int mode, APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ - outw(((unsigned short) ui_TimerValue0), - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor0, dev->iobase + APCI3120_TIMER_VALUE); break; case 2: @@ -831,8 +789,7 @@ static int apci3120_cyclic_ai(int mode, APCI3120_SELECT_TIMER_1_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ - outw(((unsigned short) ui_TimerValue1), - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor1, dev->iobase + APCI3120_TIMER_VALUE); /* init timer0 in mode 2 */ devpriv->b_TimerSelectMode = @@ -848,8 +805,7 @@ static int apci3120_cyclic_ai(int mode, outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ - outw(((unsigned short) ui_TimerValue0), - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor0, dev->iobase + APCI3120_TIMER_VALUE); break; } @@ -1487,8 +1443,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned int ui_Timervalue2; - unsigned short us_TmpValue; + unsigned int divisor; unsigned char b_Tmp; if (!data[1]) @@ -1496,22 +1451,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, devpriv->b_Timer2Interrupt = (unsigned char) data[2]; /* save info whether to enable or disable interrupt */ - ui_Timervalue2 = data[1] / 1000; /* convert nano seconds to u seconds */ - - us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS); - - /* - * EL250804: Testing if board APCI3120 have the new Quartz or if it - * is an APCI3001 and calculate the time value to set in the timer - */ - if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(dev->board_name, "apci3001")) { - /* Calculate the time value to set in the timer */ - ui_Timervalue2 = ui_Timervalue2 / 50; - } else { - /* Calculate the time value to set in the timer */ - ui_Timervalue2 = ui_Timervalue2 / 70; - } + divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ devpriv->us_OutputRegister = @@ -1551,15 +1491,14 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw(ui_Timervalue2 & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw((ui_Timervalue2 >> 16) & 0xffff, + outw((divisor >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* timer2 in Timer mode enabled */ devpriv->b_Timer2Mode = APCI3120_TIMER; @@ -1586,8 +1525,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw(ui_Timervalue2 & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> @@ -1595,7 +1533,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw((ui_Timervalue2 >> 16) & 0xffff, + outw((divisor >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* watchdog enabled */ devpriv->b_Timer2Mode = APCI3120_WATCHDOG; @@ -1624,8 +1562,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned int ui_Timervalue2 = 0; - unsigned short us_TmpValue; + unsigned int divisor; unsigned char b_Tmp; if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) @@ -1640,11 +1577,6 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, "timer2 not configured in TIMER MODE\n"); return -EINVAL; } - - if (data[1]) - ui_Timervalue2 = data[1]; - else - ui_Timervalue2 = 0; } switch (data[0]) { @@ -1734,28 +1666,17 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, "timer2 not configured in TIMER MODE\n"); return -EINVAL; } - us_TmpValue = inw(dev->iobase + APCI3120_RD_STATUS); - /* - * EL250804: Testing if board APCI3120 have the new Quartz or if it - * is an APCI3001 and calculate the time value to set in the timer - */ - if ((us_TmpValue & 0x00B0) == 0x00B0 - || !strcmp(dev->board_name, "apci3001")) { - /* Calculate the time value to set in the timer */ - ui_Timervalue2 = ui_Timervalue2 / 50; - } else { - /* Calculate the time value to set in the timer */ - ui_Timervalue2 = ui_Timervalue2 / 70; - } + divisor = apci3120_ns_to_timer(dev, 2, data[1], + CMDF_ROUND_DOWN); + /* Writing LOW unsigned short */ b_Tmp = ((devpriv-> b_DigitalOutputRegister) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw(ui_Timervalue2 & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); + outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ b_Tmp = ((devpriv-> @@ -1763,7 +1684,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw((ui_Timervalue2 >> 16) & 0xffff, + outw((divisor >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); break; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 056b3bf82094..c770e4643ce0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -15,6 +15,7 @@ /* * PCI BAR 1 register map (dev->iobase) */ +#define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) @@ -23,6 +24,14 @@ * PCI BAR 2 register map (devpriv->addon) */ +/* + * Board revisions + */ +#define APCI3120_REVA 0xa +#define APCI3120_REVB 0xb +#define APCI3120_REVA_OSC_BASE 70 /* 70ns = 14.29MHz */ +#define APCI3120_REVB_OSC_BASE 50 /* 50ns = 20MHz */ + enum apci3120_boardid { BOARD_APCI3120, BOARD_APCI3001, @@ -55,6 +64,7 @@ struct apci3120_dmabuf { struct apci3120_private { unsigned long amcc; unsigned long addon; + unsigned int osc_base; unsigned int ui_AiNbrofChannels; unsigned int ui_AiChannelList[32]; unsigned int ui_AiReadData[32]; @@ -76,6 +86,59 @@ struct apci3120_private { struct task_struct *tsk_Current; }; +/* + * There are three timers on the board. They all use the same base + * clock with a fixed prescaler for each timer. The base clock used + * depends on the board version and type. + * + * APCI-3120 Rev A boards OSC = 14.29MHz base clock (~70ns) + * APCI-3120 Rev B boards OSC = 20MHz base clock (50ns) + * APCI-3001 boards OSC = 20MHz base clock (50ns) + * + * The prescalers for each timer are: + * Timer 0 CLK = OSC/10 + * Timer 1 CLK = OSC/1000 + * Timer 2 CLK = OSC/1000 + */ +static unsigned int apci3120_ns_to_timer(struct comedi_device *dev, + unsigned int timer, + unsigned int ns, + unsigned int flags) +{ + struct apci3120_private *devpriv = dev->private; + unsigned int prescale = (timer == 0) ? 10 : 1000; + unsigned int timer_base = devpriv->osc_base * prescale; + unsigned int divisor; + + switch (flags & CMDF_ROUND_MASK) { + case CMDF_ROUND_UP: + divisor = DIV_ROUND_UP(ns, timer_base); + break; + case CMDF_ROUND_DOWN: + divisor = ns / timer_base; + break; + case CMDF_ROUND_NEAREST: + default: + divisor = DIV_ROUND_CLOSEST(ns, timer_base); + break; + } + + if (timer == 2) { + /* timer 2 is 24-bits */ + if (divisor > 0x00ffffff) + divisor = 0x00ffffff; + } else { + /* timers 0 and 1 are 16-bits */ + if (divisor > 0xffff) + divisor = 0xffff; + } + /* the timers require a minimum divisor of 2 */ + if (divisor < 2) + divisor = 2; + + return divisor; +} + #include "addi-data/hwdrv_apci3120.c" static void apci3120_dma_alloc(struct comedi_device *dev) @@ -131,6 +194,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, const struct apci3120_board *this_board = NULL; struct apci3120_private *devpriv; struct comedi_subdevice *s; + unsigned int status; int ret; if (context < ARRAY_SIZE(apci3120_boardtypes)) @@ -165,6 +229,13 @@ static int apci3120_auto_attach(struct comedi_device *dev, } } + status = inw(dev->iobase + APCI3120_RD_STATUS); + if (APCI3120_STATUS_TO_VERSION(status) == APCI3120_REVB || + context == BOARD_APCI3001) + devpriv->osc_base = APCI3120_REVB_OSC_BASE; + else + devpriv->osc_base = APCI3120_REVA_OSC_BASE; + ret = comedi_alloc_subdevices(dev, 5); if (ret) return ret; -- cgit v1.2.3-59-g8ed1b From 36d553e47d7ea50a2a954ede3540f4417b5094c9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:46 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'b_DigitalOutputRegister' Rename this CamelCase member of the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 50 ++++++++-------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 960002dbaeca..9fca58c016c3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -391,8 +391,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, dev->iobase + APCI3120_WR_ADDRESS); /* Select Timer 0 */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); @@ -449,8 +448,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, dev->iobase + APCI3120_TIMER_CRT1); /* Select Timer 0 */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); @@ -767,8 +765,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_TIMER_CRT1); /* Select Timer 0 */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ @@ -784,8 +781,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_TIMER_CRT1); /* Select Timer 1 */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_1_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ @@ -799,8 +795,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_TIMER_CRT1); /* Select Timer 0 */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_0_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); @@ -859,16 +854,14 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_TIMER_CRT1); /* Writing LOW unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(ui_TimerValue2 & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw((ui_TimerValue2 >> 16) & 0xffff, @@ -1487,15 +1480,13 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, */ /* Writing LOW unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw((divisor >> 16) & 0xffff, @@ -1521,15 +1512,13 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, */ /* Writing LOW unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); @@ -1671,16 +1660,14 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, CMDF_ROUND_DOWN); /* Writing LOW unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); @@ -1719,16 +1706,14 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* Read the LOW unsigned short of Timer 2 register */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_LOW_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); us_TmpValue = inw(dev->iobase + APCI3120_TIMER_VALUE); /* Read the HIGH unsigned short of Timer 2 register */ - b_Tmp = ((devpriv-> - b_DigitalOutputRegister) & 0xF0) | + b_Tmp = ((devpriv->do_bits) & 0xF0) | APCI3120_SELECT_TIMER_2_HIGH_WORD; outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); @@ -1774,10 +1759,9 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, if (comedi_dio_update_state(s, data)) { /* The do channels are bits 7:4 of the do register */ - devpriv->b_DigitalOutputRegister = s->state << 4; + devpriv->do_bits = s->state << 4; - outb(devpriv->b_DigitalOutputRegister, - dev->iobase + APCI3120_DIGITAL_OUTPUT); + outb(devpriv->do_bits, dev->iobase + APCI3120_DIGITAL_OUTPUT); } data[1] = s->state; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index c770e4643ce0..f07d9ab35c9d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -72,7 +72,7 @@ struct apci3120_private { unsigned char b_DmaDoubleBuffer; unsigned int ui_DmaActualBuffer; struct apci3120_dmabuf dmabuf[2]; - unsigned char b_DigitalOutputRegister; + unsigned char do_bits; unsigned char b_TimerSelectMode; unsigned char b_ModeSelectRegister; unsigned short us_OutputRegister; -- cgit v1.2.3-59-g8ed1b From ca578bce6d940b4a653fe8ff73ba37fff0c8eaa7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:47 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_timer_write() Introduce a helper function to select a timer and write a value to it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 138 +++++---------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 35 insertions(+), 104 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 9fca58c016c3..ea825c7be944 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -200,6 +200,26 @@ static const struct comedi_lrange range_apci3120_ai = { } }; +static void apci3120_timer_write(struct comedi_device *dev, + unsigned int timer, unsigned int val) +{ + struct apci3120_private *devpriv = dev->private; + + /* write 16-bit value to timer (lower 16-bits of timer 2) */ + outb(((devpriv->do_bits) & 0xF0) | + APCI3120_CTR0_TIMER_SEL(timer), + dev->iobase + APCI3120_TIMER_CRT0); + outw(val & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); + + if (timer == 2) { + /* write upper 16-bits to timer 2 */ + outb(((devpriv->do_bits) & 0xF0) | + APCI3120_CTR0_TIMER_SEL(timer + 1), + dev->iobase + APCI3120_TIMER_CRT0); + outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); + } +} + static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -312,7 +332,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, unsigned int divisor; unsigned int ns; unsigned short us_TmpValue, i; - unsigned char b_Tmp; /* fix conversion time to 10 us */ if (!devpriv->ui_EocEosConversionTime) @@ -390,13 +409,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); - /* Select Timer 0 */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_0_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - /* Set the conversion time */ - outw(divisor, dev->iobase + APCI3120_TIMER_VALUE); + apci3120_timer_write(dev, 0, divisor); us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); @@ -447,13 +461,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* Select Timer 0 */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_0_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - /* Set the conversion time */ - outw(divisor, dev->iobase + APCI3120_TIMER_VALUE); + apci3120_timer_write(dev, 0, divisor); /* Set the scan bit */ devpriv->b_ModeSelectRegister = @@ -703,11 +712,9 @@ static int apci3120_cyclic_ai(int mode, { struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned char b_Tmp; unsigned int divisor1 = 0; unsigned int dmalen0 = 0; unsigned int dmalen1 = 0; - unsigned int ui_TimerValue2 = 0; unsigned int divisor0; /* Resets the FIFO */ @@ -739,9 +746,6 @@ static int apci3120_cyclic_ai(int mode, devpriv->ui_DmaActualBuffer = 0; - /* value for timer2 minus -2 has to be done */ - ui_TimerValue2 = cmd->stop_arg - 2; - /* Initializes the sequence array */ if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, cmd->chanlist, 0)) @@ -764,12 +768,8 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* Select Timer 0 */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_0_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); /* Set the conversion time */ - outw(divisor0, dev->iobase + APCI3120_TIMER_VALUE); + apci3120_timer_write(dev, 0, divisor0); break; case 2: @@ -780,12 +780,8 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* Select Timer 1 */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_1_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - /* Set the conversion time */ - outw(divisor1, dev->iobase + APCI3120_TIMER_VALUE); + /* Set the scan begin time */ + apci3120_timer_write(dev, 1, divisor1); /* init timer0 in mode 2 */ devpriv->b_TimerSelectMode = @@ -794,13 +790,8 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* Select Timer 0 */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_0_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - /* Set the conversion time */ - outw(divisor0, dev->iobase + APCI3120_TIMER_VALUE); + apci3120_timer_write(dev, 0, divisor0); break; } @@ -853,19 +844,8 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* Writing LOW unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw(ui_TimerValue2 & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); - - /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw((ui_TimerValue2 >> 16) & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); + /* Set the scan stop count (not sure about the -2) */ + apci3120_timer_write(dev, 2, cmd->stop_arg - 2); /* (2) Reset FC_TIMER BIT Clearing timer status register */ inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); @@ -1437,7 +1417,6 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, { struct apci3120_private *devpriv = dev->private; unsigned int divisor; - unsigned char b_Tmp; if (!data[1]) dev_err(dev->class_dev, "No timer constant!\n"); @@ -1471,26 +1450,9 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* - * Configure the timer 2 for writing the LOW unsigned short of timer - * is Delay value You must make a b_tmp variable with - * DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0 - * you can set the digital output and configure the timer 2,and if - * you don't make this, digital output are erase (Set to 0) - */ + /* Set timer 2 delay */ + apci3120_timer_write(dev, 2, divisor); - /* Writing LOW unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); - - /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw((divisor >> 16) & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); /* timer2 in Timer mode enabled */ devpriv->b_Timer2Mode = APCI3120_TIMER; @@ -1503,27 +1465,9 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, outb(devpriv->b_TimerSelectMode, dev->iobase + APCI3120_TIMER_CRT1); - /* - * Configure the timer 2 for writing the LOW unsigned short of timer - * is Delay value You must make a b_tmp variable with - * DigitalOutPutRegister because at Address_1+APCI3120_TIMER_CRT0 - * you can set the digital output and configure the timer 2,and if - * you don't make this, digital output are erase (Set to 0) - */ + /* Set timer 2 delay */ + apci3120_timer_write(dev, 2, divisor); - /* Writing LOW unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); - - /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - - outw((divisor >> 16) & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); /* watchdog enabled */ devpriv->b_Timer2Mode = APCI3120_WATCHDOG; @@ -1552,7 +1496,6 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, { struct apci3120_private *devpriv = dev->private; unsigned int divisor; - unsigned char b_Tmp; if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { @@ -1659,21 +1602,8 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); - /* Writing LOW unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - - outw(divisor & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); - - /* Writing HIGH unsigned short */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - - outw((divisor >> 16) & 0xffff, - dev->iobase + APCI3120_TIMER_VALUE); - + /* Set timer 2 delay */ + apci3120_timer_write(dev, 2, divisor); break; default: return -EINVAL; /* Not a valid input */ diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index f07d9ab35c9d..6819cc09a60e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -19,6 +19,7 @@ #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) +#define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) /* * PCI BAR 2 register map (devpriv->addon) -- cgit v1.2.3-59-g8ed1b From 6931290785bb6ecd044b08ea0e62e073051fec86 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:48 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_timer_read() Introduce a helper function to select a timer and read a value from it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 45 ++++++++++++---------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index ea825c7be944..7335a64d2d6f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -220,6 +220,29 @@ static void apci3120_timer_write(struct comedi_device *dev, } } +static unsigned int apci3120_timer_read(struct comedi_device *dev, + unsigned int timer) +{ + struct apci3120_private *devpriv = dev->private; + unsigned int val; + + /* read 16-bit value from timer (lower 16-bits of timer 2) */ + outb(((devpriv->do_bits) & 0xF0) | + APCI3120_CTR0_TIMER_SEL(timer), + dev->iobase + APCI3120_TIMER_CRT0); + val = inw(dev->iobase + APCI3120_TIMER_VALUE); + + if (timer == 2) { + /* read upper 16-bits from timer 2 */ + outb(((devpriv->do_bits) & 0xF0) | + APCI3120_CTR0_TIMER_SEL(timer + 1), + dev->iobase + APCI3120_TIMER_CRT0); + val |= (inw(dev->iobase + APCI3120_TIMER_VALUE) << 16); + } + + return val; +} + static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -1626,32 +1649,14 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned char b_Tmp; - unsigned short us_TmpValue, us_TmpValue_2, us_StatusValue; + unsigned short us_StatusValue; if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { dev_err(dev->class_dev, "timer2 not configured\n"); } if (devpriv->b_Timer2Mode == APCI3120_TIMER) { - - /* Read the LOW unsigned short of Timer 2 register */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_LOW_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - - us_TmpValue = inw(dev->iobase + APCI3120_TIMER_VALUE); - - /* Read the HIGH unsigned short of Timer 2 register */ - b_Tmp = ((devpriv->do_bits) & 0xF0) | - APCI3120_SELECT_TIMER_2_HIGH_WORD; - outb(b_Tmp, dev->iobase + APCI3120_TIMER_CRT0); - - us_TmpValue_2 = inw(dev->iobase + APCI3120_TIMER_VALUE); - - /* combining both words */ - data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16)); - + data[0] = apci3120_timer_read(dev, 2); } else { /* Read watch dog status */ us_StatusValue = inw(dev->iobase + APCI3120_RD_STATUS); -- cgit v1.2.3-59-g8ed1b From 2e2e74e17a315d376292764b323e54ec21daa18e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:49 -0700 Subject: staging: comedi: addi_apci_3120: tidy up CTR0 register defines Define the CTR0 register in the main driver source file and remove all the old defines in hwrdv_apci3120.c. For aesthetics, save the raw digital output state (devpriv->do_bits) in the digital output (*insn_bits) function and use a macro to set them when reading/writing a timer. Use the CTR0 register define in the digital output (*insn_bits) function and remove the current register define. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 38 +++++++--------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 ++ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 7335a64d2d6f..93b17252a907 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -86,16 +86,9 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_EOS_MODE 2 #define APCI3120_DMA_MODE 3 -/* DIGITAL INPUT-OUTPUT DEFINE */ - -#define APCI3120_DIGITAL_OUTPUT 0x0d #define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 -/* digital output insn_write ON /OFF selection */ -#define APCI3120_SET4DIGITALOUTPUTON 1 -#define APCI3120_SET4DIGITALOUTPUTOFF 0 - /* Enable external trigger bit in nWrAddress */ #define APCI3120_ENABLE_EXT_TRIGGER 0x8000 @@ -110,7 +103,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RESET_FIFO 0x0c #define APCI3120_TIMER_0_MODE_2 0x01 #define APCI3120_TIMER_0_MODE_4 0x2 -#define APCI3120_SELECT_TIMER_0_WORD 0x00 #define APCI3120_ENABLE_TIMER0 0x1000 #define APCI3120_CLEAR_PR 0xf0ff #define APCI3120_CLEAR_PA 0xfff0 @@ -148,8 +140,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_ENABLE_TIMER_INT 0x04 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_WRITE_MODE_SELECT 0x0e -#define APCI3120_SELECT_TIMER_0_WORD 0x00 -#define APCI3120_SELECT_TIMER_1_WORD 0x01 #define APCI3120_TIMER_1_MODE_2 0x4 /* $$ BIT FOR MODE IN nCsTimerCtr1 */ @@ -157,11 +147,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_2_MODE_2 0x10 #define APCI3120_TIMER_2_MODE_5 0x30 -/* $$ BIT FOR MODE IN nCsTimerCtr0 */ -#define APCI3120_SELECT_TIMER_2_LOW_WORD 0x02 -#define APCI3120_SELECT_TIMER_2_HIGH_WORD 0x03 - -#define APCI3120_TIMER_CRT0 0x0d #define APCI3120_TIMER_CRT1 0x0c #define APCI3120_TIMER_VALUE 0x04 @@ -206,16 +191,16 @@ static void apci3120_timer_write(struct comedi_device *dev, struct apci3120_private *devpriv = dev->private; /* write 16-bit value to timer (lower 16-bits of timer 2) */ - outb(((devpriv->do_bits) & 0xF0) | + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer), - dev->iobase + APCI3120_TIMER_CRT0); + dev->iobase + APCI3120_CTR0_REG); outw(val & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); if (timer == 2) { /* write upper 16-bits to timer 2 */ - outb(((devpriv->do_bits) & 0xF0) | + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer + 1), - dev->iobase + APCI3120_TIMER_CRT0); + dev->iobase + APCI3120_CTR0_REG); outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); } } @@ -227,16 +212,16 @@ static unsigned int apci3120_timer_read(struct comedi_device *dev, unsigned int val; /* read 16-bit value from timer (lower 16-bits of timer 2) */ - outb(((devpriv->do_bits) & 0xF0) | + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer), - dev->iobase + APCI3120_TIMER_CRT0); + dev->iobase + APCI3120_CTR0_REG); val = inw(dev->iobase + APCI3120_TIMER_VALUE); if (timer == 2) { /* read upper 16-bits from timer 2 */ - outb(((devpriv->do_bits) & 0xF0) | + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer + 1), - dev->iobase + APCI3120_TIMER_CRT0); + dev->iobase + APCI3120_CTR0_REG); val |= (inw(dev->iobase + APCI3120_TIMER_VALUE) << 16); } @@ -1693,10 +1678,9 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, struct apci3120_private *devpriv = dev->private; if (comedi_dio_update_state(s, data)) { - /* The do channels are bits 7:4 of the do register */ - devpriv->do_bits = s->state << 4; - - outb(devpriv->do_bits, dev->iobase + APCI3120_DIGITAL_OUTPUT); + devpriv->do_bits = s->state; + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits), + dev->iobase + APCI3120_CTR0_REG); } data[1] = s->state; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 6819cc09a60e..51637e1628bc 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -19,6 +19,8 @@ #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) +#define APCI3120_CTR0_REG 0x0d +#define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) /* -- cgit v1.2.3-59-g8ed1b From dd62c4373ae1cd48d0f1561646443d2aed299e21 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:50 -0700 Subject: staging: comedi: addi_apci_3120: fix counter and external interrupt disable The APCI3120_DISABLE_ALL_TIMER define define is not needed, and it's used incorrectly in apci3120_cancel(). The define is a mask of the bits needed to disable the counters. Writing the value directly sets unintended bits. Prior to writing the value, the 'devpriv->us_OutputRegister' is set to 0 and written to the register. This disables all the timers and the external trigger. Remove the unnecessary apci3120_exttrig_disable() call as well as the write of APCI3120_DISABLE_ALL_TIMER. In apci3120_interrupt(), remove the unnecessary mask and write to disable all the timers. The COMEDI_CB_EOA event will cause the core to call the (*cancel) operation which will disable the timers. Remove the unused define. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 93b17252a907..6eaf62ab5446 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -167,9 +167,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER2_SELECT_EOS 0xc0 #define APCI3120_COUNTER 3 -#define APCI3120_DISABLE_ALL_TIMER (APCI3120_DISABLE_TIMER0 & \ - APCI3120_DISABLE_TIMER1 & \ - APCI3120_DISABLE_TIMER2) /* ANALOG INPUT RANGE */ static const struct comedi_lrange range_apci3120_ai = { @@ -613,16 +610,9 @@ static int apci3120_cancel(struct comedi_device *dev, /* Disable BUS Master PCI */ outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); - /* Disable ext trigger */ - apci3120_exttrig_disable(dev); - + /* stop all counters and disable external trigger */ devpriv->us_OutputRegister = 0; - /* stop counters */ - outw(devpriv-> - us_OutputRegister & APCI3120_DISABLE_TIMER0 & - APCI3120_DISABLE_TIMER1, dev->iobase + APCI3120_WR_ADDRESS); - - outw(APCI3120_DISABLE_ALL_TIMER, dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); /* DISABLE_ALL_INTERRUPT */ outb(APCI3120_DISABLE_ALL_INTERRUPT, @@ -1346,13 +1336,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - /* stop timer 2 */ - devpriv->us_OutputRegister = - devpriv-> - us_OutputRegister & APCI3120_DISABLE_ALL_TIMER; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); - s->async->events |= COMEDI_CB_EOA; break; -- cgit v1.2.3-59-g8ed1b From 0c188e9cc9c4e7920215903779be3010ffdaf602 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:51 -0700 Subject: staging: comedi: addi_apci_3120: rename APCI3120_TIMER_VALUE For aesthetics, rename this register offset. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 ++++----- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 6eaf62ab5446..c9b416ededcc 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -149,7 +149,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_CRT1 0x0c -#define APCI3120_TIMER_VALUE 0x04 #define APCI3120_TIMER_STATUS_REGISTER 0x0d #define APCI3120_RD_STATUS 0x02 #define APCI3120_WR_ADDRESS 0x00 @@ -191,14 +190,14 @@ static void apci3120_timer_write(struct comedi_device *dev, outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer), dev->iobase + APCI3120_CTR0_REG); - outw(val & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); + outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG); if (timer == 2) { /* write upper 16-bits to timer 2 */ outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer + 1), dev->iobase + APCI3120_CTR0_REG); - outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE); + outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG); } } @@ -212,14 +211,14 @@ static unsigned int apci3120_timer_read(struct comedi_device *dev, outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer), dev->iobase + APCI3120_CTR0_REG); - val = inw(dev->iobase + APCI3120_TIMER_VALUE); + val = inw(dev->iobase + APCI3120_TIMER_REG); if (timer == 2) { /* read upper 16-bits from timer 2 */ outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | APCI3120_CTR0_TIMER_SEL(timer + 1), dev->iobase + APCI3120_CTR0_REG); - val |= (inw(dev->iobase + APCI3120_TIMER_VALUE) << 16); + val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16); } return val; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 51637e1628bc..f431e5492de8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,6 +16,7 @@ * PCI BAR 1 register map (dev->iobase) */ #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) +#define APCI3120_TIMER_REG 0x04 #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) -- cgit v1.2.3-59-g8ed1b From 486beeb488f589bc34bb0cff51415c2040abcb47 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:52 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'b_TimerSelectMode' Rename this CamelCase member of the private data and tidy up the mask/set of its bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 70 +++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c9b416ededcc..546c4c373550 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -344,7 +344,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, ns = devpriv->ui_EocEosConversionTime; /* Clear software registers */ - devpriv->b_TimerSelectMode = 0; + devpriv->timer_mode = 0; devpriv->b_ModeSelectRegister = 0; devpriv->us_OutputRegister = 0; @@ -373,11 +373,9 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 4 */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0xFC) | - APCI3120_TIMER_0_MODE_4; - outb(devpriv->b_TimerSelectMode, + devpriv->timer_mode &= 0xfc; + devpriv->timer_mode |= APCI3120_TIMER_0_MODE_4; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */ @@ -458,11 +456,9 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 2 */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0xFC) | - APCI3120_TIMER_0_MODE_2; - outb(devpriv->b_TimerSelectMode, + devpriv->timer_mode &= 0xfc; + devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Set the conversion time */ @@ -720,7 +716,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->ai_running = 1; /* clear software registers */ - devpriv->b_TimerSelectMode = 0; + devpriv->timer_mode = 0; devpriv->us_OutputRegister = 0; devpriv->b_ModeSelectRegister = 0; @@ -759,11 +755,9 @@ static int apci3120_cyclic_ai(int mode, switch (mode) { case 1: /* init timer0 in mode 2 */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2; - outb(devpriv->b_TimerSelectMode, - dev->iobase + APCI3120_TIMER_CRT1); + devpriv->timer_mode &= 0xfc; + devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor0); @@ -771,21 +765,17 @@ static int apci3120_cyclic_ai(int mode, case 2: /* init timer1 in mode 2 */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0xF3) | APCI3120_TIMER_1_MODE_2; - outb(devpriv->b_TimerSelectMode, - dev->iobase + APCI3120_TIMER_CRT1); + devpriv->timer_mode &= 0xf3; + devpriv->timer_mode |= APCI3120_TIMER_1_MODE_2; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Set the scan begin time */ apci3120_timer_write(dev, 1, divisor1); /* init timer0 in mode 2 */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0xFC) | APCI3120_TIMER_0_MODE_2; - outb(devpriv->b_TimerSelectMode, - dev->iobase + APCI3120_TIMER_CRT1); + devpriv->timer_mode &= 0xfc; + devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor0); @@ -834,12 +824,10 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* (1) Init timer 2 in mode 0 and write timer value */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0x0F) | - APCI3120_TIMER_2_MODE_0; - outb(devpriv->b_TimerSelectMode, - dev->iobase + APCI3120_TIMER_CRT1); + devpriv->timer_mode &= 0x0f; + devpriv->timer_mode |= APCI3120_TIMER_2_MODE_0; + outb(devpriv->timer_mode, + dev->iobase + APCI3120_TIMER_CRT1); /* Set the scan stop count (not sure about the -2) */ apci3120_timer_write(dev, 2, cmd->stop_arg - 2); @@ -1434,11 +1422,9 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_2; - outb(devpriv->b_TimerSelectMode, - dev->iobase + APCI3120_TIMER_CRT1); + devpriv->timer_mode &= 0x0f; + devpriv->timer_mode |= APCI3120_TIMER_2_MODE_2; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Set timer 2 delay */ apci3120_timer_write(dev, 2, divisor); @@ -1449,11 +1435,9 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, } else { /* Initialize Watch dog */ /* Set the Timer 2 in mode 5(Watchdog) */ - devpriv->b_TimerSelectMode = - (devpriv-> - b_TimerSelectMode & 0x0F) | APCI3120_TIMER_2_MODE_5; - outb(devpriv->b_TimerSelectMode, - dev->iobase + APCI3120_TIMER_CRT1); + devpriv->timer_mode &= 0x0f; + devpriv->timer_mode |= APCI3120_TIMER_2_MODE_5; + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); /* Set timer 2 delay */ apci3120_timer_write(dev, 2, divisor); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index f431e5492de8..6882f8ee67a4 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -77,7 +77,7 @@ struct apci3120_private { unsigned int ui_DmaActualBuffer; struct apci3120_dmabuf dmabuf[2]; unsigned char do_bits; - unsigned char b_TimerSelectMode; + unsigned char timer_mode; unsigned char b_ModeSelectRegister; unsigned short us_OutputRegister; unsigned char b_Timer2Mode; -- cgit v1.2.3-59-g8ed1b From 2016c534dd2f4b0599e5a8513567a34d4746cdf6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:53 -0700 Subject: staging: comedi: addi_apci_3120: tidy up timer_mode masking Define a macro that returns the mask of the timer_mode bits for a given timer. Use the macro to remove the "magic" values used to clear the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 16 ++++++++-------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 546c4c373550..a876adae58d2 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -373,7 +373,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 4 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_4; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -456,7 +456,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 2 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -755,7 +755,7 @@ static int apci3120_cyclic_ai(int mode, switch (mode) { case 1: /* init timer0 in mode 2 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -765,7 +765,7 @@ static int apci3120_cyclic_ai(int mode, case 2: /* init timer1 in mode 2 */ - devpriv->timer_mode &= 0xf3; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(1); devpriv->timer_mode |= APCI3120_TIMER_1_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -773,7 +773,7 @@ static int apci3120_cyclic_ai(int mode, apci3120_timer_write(dev, 1, divisor1); /* init timer0 in mode 2 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -824,7 +824,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* (1) Init timer 2 in mode 0 and write timer value */ - devpriv->timer_mode &= 0x0f; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); devpriv->timer_mode |= APCI3120_TIMER_2_MODE_0; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -1422,7 +1422,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ - devpriv->timer_mode &= 0x0f; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); devpriv->timer_mode |= APCI3120_TIMER_2_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -1435,7 +1435,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, } else { /* Initialize Watch dog */ /* Set the Timer 2 in mode 5(Watchdog) */ - devpriv->timer_mode &= 0x0f; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); devpriv->timer_mode |= APCI3120_TIMER_2_MODE_5; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 6882f8ee67a4..999add3928ef 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -20,6 +20,7 @@ #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) +#define APCI3120_TIMER_MODE_MASK(_t) (3 << ((_t) * 2)) #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) -- cgit v1.2.3-59-g8ed1b From e6da4c6a2db10ae79704e809ee2896e6bcf230b9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:54 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_timer_set_mode() Introduce a helper function to set the operation mode of a timer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 57 +++++++--------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +++ 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a876adae58d2..dc6eb56e0e1a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -101,8 +101,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_10_GAIN 0x30 #define APCI3120_SEQ_RAM_ADDRESS 0x06 #define APCI3120_RESET_FIFO 0x0c -#define APCI3120_TIMER_0_MODE_2 0x01 -#define APCI3120_TIMER_0_MODE_4 0x2 #define APCI3120_ENABLE_TIMER0 0x1000 #define APCI3120_CLEAR_PR 0xf0ff #define APCI3120_CLEAR_PA 0xfff0 @@ -140,14 +138,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_ENABLE_TIMER_INT 0x04 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_WRITE_MODE_SELECT 0x0e -#define APCI3120_TIMER_1_MODE_2 0x4 - -/* $$ BIT FOR MODE IN nCsTimerCtr1 */ -#define APCI3120_TIMER_2_MODE_0 0x0 -#define APCI3120_TIMER_2_MODE_2 0x10 -#define APCI3120_TIMER_2_MODE_5 0x30 - -#define APCI3120_TIMER_CRT1 0x0c #define APCI3120_TIMER_STATUS_REGISTER 0x0d #define APCI3120_RD_STATUS 0x02 @@ -224,6 +214,16 @@ static unsigned int apci3120_timer_read(struct comedi_device *dev, return val; } +static void apci3120_timer_set_mode(struct comedi_device *dev, + unsigned int timer, unsigned int mode) +{ + struct apci3120_private *devpriv = dev->private; + + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer); + devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode); + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG); +} + static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -373,10 +373,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 4 */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); - devpriv->timer_mode |= APCI3120_TIMER_0_MODE_4; - outb(devpriv->timer_mode, - dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */ devpriv->b_ModeSelectRegister = @@ -456,10 +453,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 2 */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); - devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; - outb(devpriv->timer_mode, - dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor); @@ -755,9 +749,7 @@ static int apci3120_cyclic_ai(int mode, switch (mode) { case 1: /* init timer0 in mode 2 */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); - devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor0); @@ -765,17 +757,13 @@ static int apci3120_cyclic_ai(int mode, case 2: /* init timer1 in mode 2 */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(1); - devpriv->timer_mode |= APCI3120_TIMER_1_MODE_2; - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2); /* Set the scan begin time */ apci3120_timer_write(dev, 1, divisor1); /* init timer0 in mode 2 */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); - devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor0); @@ -824,10 +812,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* (1) Init timer 2 in mode 0 and write timer value */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); - devpriv->timer_mode |= APCI3120_TIMER_2_MODE_0; - outb(devpriv->timer_mode, - dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0); /* Set the scan stop count (not sure about the -2) */ apci3120_timer_write(dev, 2, cmd->stop_arg - 2); @@ -1422,22 +1407,16 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); - devpriv->timer_mode |= APCI3120_TIMER_2_MODE_2; - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE2); /* Set timer 2 delay */ apci3120_timer_write(dev, 2, divisor); /* timer2 in Timer mode enabled */ devpriv->b_Timer2Mode = APCI3120_TIMER; - } else { /* Initialize Watch dog */ - /* Set the Timer 2 in mode 5(Watchdog) */ - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); - devpriv->timer_mode |= APCI3120_TIMER_2_MODE_5; - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); + apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE5); /* Set timer 2 delay */ apci3120_timer_write(dev, 2, divisor); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 999add3928ef..20babacd40d3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -20,6 +20,12 @@ #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) +#define APCI3120_TIMER_MODE_REG 0x0c +#define APCI3120_TIMER_MODE(_t, _m) ((_m) << ((_t) * 2)) +#define APCI3120_TIMER_MODE0 0 /* I8254_MODE0 */ +#define APCI3120_TIMER_MODE2 1 /* I8254_MODE2 */ +#define APCI3120_TIMER_MODE4 2 /* I8254_MODE4 */ +#define APCI3120_TIMER_MODE5 3 /* I8254_MODE5 */ #define APCI3120_TIMER_MODE_MASK(_t) (3 << ((_t) * 2)) #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) -- cgit v1.2.3-59-g8ed1b From b3c8ee5cbc5f995c738a5651a2b22297950be6a2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:55 -0700 Subject: staging: comedi: addi_apci_3120: move timer helpers to main driver source Move the timer read/write and set mode helpers from the included source file into the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 53 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 53 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index dc6eb56e0e1a..d4d66e490b54 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -171,59 +171,6 @@ static const struct comedi_lrange range_apci3120_ai = { } }; -static void apci3120_timer_write(struct comedi_device *dev, - unsigned int timer, unsigned int val) -{ - struct apci3120_private *devpriv = dev->private; - - /* write 16-bit value to timer (lower 16-bits of timer 2) */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer), - dev->iobase + APCI3120_CTR0_REG); - outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG); - - if (timer == 2) { - /* write upper 16-bits to timer 2 */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer + 1), - dev->iobase + APCI3120_CTR0_REG); - outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG); - } -} - -static unsigned int apci3120_timer_read(struct comedi_device *dev, - unsigned int timer) -{ - struct apci3120_private *devpriv = dev->private; - unsigned int val; - - /* read 16-bit value from timer (lower 16-bits of timer 2) */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer), - dev->iobase + APCI3120_CTR0_REG); - val = inw(dev->iobase + APCI3120_TIMER_REG); - - if (timer == 2) { - /* read upper 16-bits from timer 2 */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer + 1), - dev->iobase + APCI3120_CTR0_REG); - val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16); - } - - return val; -} - -static void apci3120_timer_set_mode(struct comedi_device *dev, - unsigned int timer, unsigned int mode) -{ - struct apci3120_private *devpriv = dev->private; - - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer); - devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode); - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG); -} - static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 20babacd40d3..e53561194bae 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -150,6 +150,59 @@ static unsigned int apci3120_ns_to_timer(struct comedi_device *dev, return divisor; } +static void apci3120_timer_write(struct comedi_device *dev, + unsigned int timer, unsigned int val) +{ + struct apci3120_private *devpriv = dev->private; + + /* write 16-bit value to timer (lower 16-bits of timer 2) */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer), + dev->iobase + APCI3120_CTR0_REG); + outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG); + + if (timer == 2) { + /* write upper 16-bits to timer 2 */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer + 1), + dev->iobase + APCI3120_CTR0_REG); + outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG); + } +} + +static unsigned int apci3120_timer_read(struct comedi_device *dev, + unsigned int timer) +{ + struct apci3120_private *devpriv = dev->private; + unsigned int val; + + /* read 16-bit value from timer (lower 16-bits of timer 2) */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer), + dev->iobase + APCI3120_CTR0_REG); + val = inw(dev->iobase + APCI3120_TIMER_REG); + + if (timer == 2) { + /* read upper 16-bits from timer 2 */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer + 1), + dev->iobase + APCI3120_CTR0_REG); + val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16); + } + + return val; +} + +static void apci3120_timer_set_mode(struct comedi_device *dev, + unsigned int timer, unsigned int mode) +{ + struct apci3120_private *devpriv = dev->private; + + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer); + devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode); + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG); +} + #include "addi-data/hwdrv_apci3120.c" static void apci3120_dma_alloc(struct comedi_device *dev) -- cgit v1.2.3-59-g8ed1b From 5a1f46c8fb2859be4fc7c225f2fca95640b6d7c3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:56 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'us_OutputRegister' Rename this CamelCase member of the private data and tidy up the mask/set of its bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 110 ++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 2 files changed, 42 insertions(+), 70 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index d4d66e490b54..4231e99260ed 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -247,10 +247,9 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, return 1; /* Code to set the PA and PR...Here it set PA to 0 */ - devpriv->us_OutputRegister = - devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR; - devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8; - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_CLEAR_PA_PR; + devpriv->ctrl = ((n_chan - 1) & 0xf) << 8; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); for (i = 0; i < n_chan; i++) { /* store range list to card */ @@ -293,7 +292,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Clear software registers */ devpriv->timer_mode = 0; devpriv->b_ModeSelectRegister = 0; - devpriv->us_OutputRegister = 0; + devpriv->ctrl = 0; if (insn->unused[0] == 222) { /* second insn read */ for (i = 0; i < insn->n; i++) @@ -348,12 +347,9 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Sets gate 0 */ - devpriv->us_OutputRegister = - (devpriv-> - us_OutputRegister & APCI3120_CLEAR_PA_PR) | - APCI3120_ENABLE_TIMER0; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_CLEAR_PA_PR; + devpriv->ctrl |= APCI3120_ENABLE_TIMER0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor); @@ -386,13 +382,9 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + APCI3120_RESET_FIFO); /* clear PA PR and disable timer 0 */ - devpriv->us_OutputRegister = - (devpriv-> - us_OutputRegister & APCI3120_CLEAR_PA_PR) | - APCI3120_DISABLE_TIMER0; - - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_CLEAR_PA_PR; + devpriv->ctrl |= APCI3120_DISABLE_TIMER0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, @@ -434,11 +426,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + APCI3120_RD_STATUS); /* Sets gate 0 */ - devpriv->us_OutputRegister = - devpriv-> - us_OutputRegister | APCI3120_ENABLE_TIMER0; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl |= APCI3120_ENABLE_TIMER0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Start conversion */ outw(0, dev->iobase + APCI3120_START_CONVERSION); @@ -496,8 +485,8 @@ static int apci3120_reset(struct comedi_device *dev) dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Disables all counters, ext trigger and clears PA, PR */ - devpriv->us_OutputRegister = 0; - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl = 0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); inw(dev->iobase + 0); /* make a dummy read */ inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ @@ -515,8 +504,8 @@ static int apci3120_exttrig_enable(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER; - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl |= APCI3120_ENABLE_EXT_TRIGGER; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); return 0; } @@ -524,8 +513,8 @@ static int apci3120_exttrig_disable(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER; - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= ~APCI3120_ENABLE_EXT_TRIGGER; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); return 0; } @@ -547,8 +536,8 @@ static int apci3120_cancel(struct comedi_device *dev, outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); /* stop all counters and disable external trigger */ - devpriv->us_OutputRegister = 0; - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl = 0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* DISABLE_ALL_INTERRUPT */ outb(APCI3120_DISABLE_ALL_INTERRUPT, @@ -658,7 +647,7 @@ static int apci3120_cyclic_ai(int mode, /* clear software registers */ devpriv->timer_mode = 0; - devpriv->us_OutputRegister = 0; + devpriv->ctrl = 0; devpriv->b_ModeSelectRegister = 0; /* Clear Timer Write TC int */ @@ -667,11 +656,10 @@ static int apci3120_cyclic_ai(int mode, /* Disables All Timer */ /* Sets PR and PA to 0 */ - devpriv->us_OutputRegister = devpriv->us_OutputRegister & - APCI3120_DISABLE_TIMER0 & - APCI3120_DISABLE_TIMER1 & APCI3120_CLEAR_PA_PR; - - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_DISABLE_TIMER0 & + APCI3120_DISABLE_TIMER1 & + APCI3120_CLEAR_PA_PR; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Resets the FIFO */ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ @@ -744,11 +732,8 @@ static int apci3120_cyclic_ai(int mode, * configure Timer2 For counting EOS Reset gate 2 of Timer 2 to * disable it (Set Bit D14 to 0) */ - devpriv->us_OutputRegister = - devpriv-> - us_OutputRegister & APCI3120_DISABLE_TIMER2; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_DISABLE_TIMER2; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* DISABLE TIMER intERRUPT */ devpriv->b_ModeSelectRegister = @@ -946,28 +931,21 @@ static int apci3120_cyclic_ai(int mode, if (devpriv->us_UseDma == APCI3120_DISABLE && cmd->stop_src == TRIG_COUNT) { /* set gate 2 to start conversion */ - devpriv->us_OutputRegister = - devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER2; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl |= APCI3120_ENABLE_TIMER2; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); } switch (mode) { case 1: /* set gate 0 to start conversion */ - devpriv->us_OutputRegister = - devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER0; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl |= APCI3120_ENABLE_TIMER0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); break; case 2: /* set gate 0 and gate 1 */ - devpriv->us_OutputRegister = - devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER1; - devpriv->us_OutputRegister = - devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER0; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl |= APCI3120_ENABLE_TIMER1 | + APCI3120_ENABLE_TIMER0; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); break; } @@ -1301,7 +1279,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } else { /* Stops the Timer */ outw(devpriv-> - us_OutputRegister & APCI3120_DISABLE_TIMER0 & + ctrl & APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1, dev->iobase + APCI3120_WR_ADDRESS); } @@ -1336,9 +1314,8 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ - devpriv->us_OutputRegister = - devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER2; - outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_DISABLE_TIMER2; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Disable TIMER Interrupt */ devpriv->b_ModeSelectRegister = @@ -1449,11 +1426,8 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* For Timer mode is Gate2 must be activated timer started */ - devpriv->us_OutputRegister = - devpriv-> - us_OutputRegister | APCI3120_ENABLE_TIMER2; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl |= APCI3120_ENABLE_TIMER2; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); } break; @@ -1482,10 +1456,8 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Reset Gate 2 */ - devpriv->us_OutputRegister = - devpriv->us_OutputRegister & APCI3120_DISABLE_TIMER_INT; - outw(devpriv->us_OutputRegister, - dev->iobase + APCI3120_WR_ADDRESS); + devpriv->ctrl &= APCI3120_DISABLE_TIMER_INT; + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Reset FC_TIMER BIT */ inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e53561194bae..e320c0826d3b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -86,7 +86,7 @@ struct apci3120_private { unsigned char do_bits; unsigned char timer_mode; unsigned char b_ModeSelectRegister; - unsigned short us_OutputRegister; + unsigned short ctrl; unsigned char b_Timer2Mode; unsigned char b_Timer2Interrupt; unsigned int ai_running:1; -- cgit v1.2.3-59-g8ed1b From c24ca0e691bd5b8e2e332577a6014de9572b9194 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:57 -0700 Subject: staging: comedi: addi_apci_3120: tidy up devpriv->ctrl use The apci3120_setup_chan_list() function sets devpriv->ctrl to the scan length (PR) and scan start (PA) values and writes the value to the register. There is no need to mask the value first. The apci3120_ai_insn_read() function calles apci3120_setup_chan_list(). There is no need to clear devpriv->ctrl first or clear any additional bits and write the register again. This also fixes an incorrect use of APCI3120_DISABLE_TIMER0 to disable the timer. apci3120_cyclic_ai() also calls apci3120_setup_chan_list() so it does not need to clear devpriv->ctrl or clear any addidional bits and write the register. Update the comments in apci3120_reset() and apci3120_cancel(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 34 ++++------------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 2 ++ 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 4231e99260ed..71fcaa4fb0c6 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -102,9 +102,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_SEQ_RAM_ADDRESS 0x06 #define APCI3120_RESET_FIFO 0x0c #define APCI3120_ENABLE_TIMER0 0x1000 -#define APCI3120_CLEAR_PR 0xf0ff -#define APCI3120_CLEAR_PA 0xfff0 -#define APCI3120_CLEAR_PA_PR (APCI3120_CLEAR_PR & APCI3120_CLEAR_PA) /* nWrMode_Select */ #define APCI3120_ENABLE_SCAN 0x8 @@ -246,9 +243,8 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, if (check) return 1; - /* Code to set the PA and PR...Here it set PA to 0 */ - devpriv->ctrl &= APCI3120_CLEAR_PA_PR; - devpriv->ctrl = ((n_chan - 1) & 0xf) << 8; + /* set scan length (PR) and scan start (PA) */ + devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); for (i = 0; i < n_chan; i++) { @@ -292,7 +288,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Clear software registers */ devpriv->timer_mode = 0; devpriv->b_ModeSelectRegister = 0; - devpriv->ctrl = 0; if (insn->unused[0] == 222) { /* second insn read */ for (i = 0; i < insn->n; i++) @@ -347,7 +342,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Sets gate 0 */ - devpriv->ctrl &= APCI3120_CLEAR_PA_PR; devpriv->ctrl |= APCI3120_ENABLE_TIMER0; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); @@ -380,11 +374,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + 0); /* Clears the FIFO */ inw(dev->iobase + APCI3120_RESET_FIFO); - /* clear PA PR and disable timer 0 */ - - devpriv->ctrl &= APCI3120_CLEAR_PA_PR; - devpriv->ctrl |= APCI3120_DISABLE_TIMER0; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, @@ -484,7 +473,7 @@ static int apci3120_reset(struct comedi_device *dev) outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - /* Disables all counters, ext trigger and clears PA, PR */ + /* disable all counters, ext trigger, and reset scan */ devpriv->ctrl = 0; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); @@ -535,7 +524,7 @@ static int apci3120_cancel(struct comedi_device *dev, /* Disable BUS Master PCI */ outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); - /* stop all counters and disable external trigger */ + /* disable all counters, ext trigger, and reset scan */ devpriv->ctrl = 0; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); @@ -647,20 +636,12 @@ static int apci3120_cyclic_ai(int mode, /* clear software registers */ devpriv->timer_mode = 0; - devpriv->ctrl = 0; devpriv->b_ModeSelectRegister = 0; /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); - /* Disables All Timer */ - /* Sets PR and PA to 0 */ - devpriv->ctrl &= APCI3120_DISABLE_TIMER0 & - APCI3120_DISABLE_TIMER1 & - APCI3120_CLEAR_PA_PR; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); - /* Resets the FIFO */ /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ inb(dev->iobase + APCI3120_RESET_FIFO); @@ -728,12 +709,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (cmd->stop_src == TRIG_COUNT) { - /* - * configure Timer2 For counting EOS Reset gate 2 of Timer 2 to - * disable it (Set Bit D14 to 0) - */ - devpriv->ctrl &= APCI3120_DISABLE_TIMER2; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + /* configure Timer2 For counting EOS */ /* DISABLE TIMER intERRUPT */ devpriv->b_ModeSelectRegister = diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e320c0826d3b..97782401e142 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -15,6 +15,8 @@ /* * PCI BAR 1 register map (dev->iobase) */ +#define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) +#define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) #define APCI3120_TIMER_REG 0x04 #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) -- cgit v1.2.3-59-g8ed1b From e0ca363a3e0beef3b111ff73bdcec1f15bea671c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:58 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER[012] For aesthetics, remove these defines and just use ~APCI3120_ENABLE_TIMER[012]. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 71fcaa4fb0c6..3575453afbc9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -131,7 +131,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 #define APCI3120_ENABLE_TIMER2 0x4000 -#define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2) #define APCI3120_ENABLE_TIMER_INT 0x04 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_WRITE_MODE_SELECT 0x0e @@ -147,9 +146,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_ENABLE_TIMER0 0x1000 #define APCI3120_ENABLE_TIMER1 0x2000 #define APCI3120_ENABLE_TIMER2 0x4000 -#define APCI3120_DISABLE_TIMER0 (~APCI3120_ENABLE_TIMER0) -#define APCI3120_DISABLE_TIMER1 (~APCI3120_ENABLE_TIMER1) -#define APCI3120_DISABLE_TIMER2 (~APCI3120_ENABLE_TIMER2) #define APCI3120_TIMER2_SELECT_EOS 0xc0 #define APCI3120_COUNTER 3 @@ -1254,10 +1250,10 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) apci3120_interrupt_dma(irq, d); } else { /* Stops the Timer */ - outw(devpriv-> - ctrl & APCI3120_DISABLE_TIMER0 & - APCI3120_DISABLE_TIMER1, - dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->ctrl & + ~APCI3120_ENABLE_TIMER0 & + ~APCI3120_ENABLE_TIMER1, + dev->iobase + APCI3120_WR_ADDRESS); } } @@ -1290,7 +1286,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ - devpriv->ctrl &= APCI3120_DISABLE_TIMER2; + devpriv->ctrl &= ~APCI3120_ENABLE_TIMER2; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Disable TIMER Interrupt */ -- cgit v1.2.3-59-g8ed1b From 20f75b5641dfb12aa8acc53afd6ed65ca49af172 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:53:59 -0700 Subject: staging: comedi: addi_apci_3120: tidy up APCI3120_ENABLE_TIMER[012] For aesthetics, replace these defines with a macro that returns the correct bit needed to set the gate bit to enable a timer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 25 +++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3575453afbc9..8e474a14a670 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -101,7 +101,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_10_GAIN 0x30 #define APCI3120_SEQ_RAM_ADDRESS 0x06 #define APCI3120_RESET_FIFO 0x0c -#define APCI3120_ENABLE_TIMER0 0x1000 /* nWrMode_Select */ #define APCI3120_ENABLE_SCAN 0x8 @@ -130,7 +129,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_WATCHDOG 2 #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 -#define APCI3120_ENABLE_TIMER2 0x4000 #define APCI3120_ENABLE_TIMER_INT 0x04 #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_WRITE_MODE_SELECT 0x0e @@ -143,9 +141,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_ENABLE_TIMER_COUNTER 0x10 #define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER) #define APCI3120_FC_TIMER 0x1000 -#define APCI3120_ENABLE_TIMER0 0x1000 -#define APCI3120_ENABLE_TIMER1 0x2000 -#define APCI3120_ENABLE_TIMER2 0x4000 #define APCI3120_TIMER2_SELECT_EOS 0xc0 #define APCI3120_COUNTER 3 @@ -338,7 +333,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* Sets gate 0 */ - devpriv->ctrl |= APCI3120_ENABLE_TIMER0; + devpriv->ctrl |= APCI3120_CTRL_GATE(0); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Set the conversion time */ @@ -411,7 +406,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + APCI3120_RD_STATUS); /* Sets gate 0 */ - devpriv->ctrl |= APCI3120_ENABLE_TIMER0; + devpriv->ctrl |= APCI3120_CTRL_GATE(0); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Start conversion */ @@ -903,20 +898,20 @@ static int apci3120_cyclic_ai(int mode, if (devpriv->us_UseDma == APCI3120_DISABLE && cmd->stop_src == TRIG_COUNT) { /* set gate 2 to start conversion */ - devpriv->ctrl |= APCI3120_ENABLE_TIMER2; + devpriv->ctrl |= APCI3120_CTRL_GATE(2); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); } switch (mode) { case 1: /* set gate 0 to start conversion */ - devpriv->ctrl |= APCI3120_ENABLE_TIMER0; + devpriv->ctrl |= APCI3120_CTRL_GATE(0); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); break; case 2: /* set gate 0 and gate 1 */ - devpriv->ctrl |= APCI3120_ENABLE_TIMER1 | - APCI3120_ENABLE_TIMER0; + devpriv->ctrl |= APCI3120_CTRL_GATE(1) | + APCI3120_CTRL_GATE(0); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); break; @@ -1251,8 +1246,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } else { /* Stops the Timer */ outw(devpriv->ctrl & - ~APCI3120_ENABLE_TIMER0 & - ~APCI3120_ENABLE_TIMER1, + ~APCI3120_CTRL_GATE(0) & + ~APCI3120_CTRL_GATE(1), dev->iobase + APCI3120_WR_ADDRESS); } @@ -1286,7 +1281,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ - devpriv->ctrl &= ~APCI3120_ENABLE_TIMER2; + devpriv->ctrl &= ~APCI3120_CTRL_GATE(2); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); /* Disable TIMER Interrupt */ @@ -1398,7 +1393,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* For Timer mode is Gate2 must be activated timer started */ - devpriv->ctrl |= APCI3120_ENABLE_TIMER2; + devpriv->ctrl |= APCI3120_CTRL_GATE(2); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 97782401e142..58db0aba088b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -15,6 +15,7 @@ /* * PCI BAR 1 register map (dev->iobase) */ +#define APCI3120_CTRL_GATE(x) (1 << (12 + (x))) #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) -- cgit v1.2.3-59-g8ed1b From 6d210c8d96b7ae073ed43c46de21329115e9090a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:00 -0700 Subject: staging: comedi: addi_apci_3120: rename APCI3120_ENABLE_EXT_TRIGGER For aesthetics, rename this define. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 ++----- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 8e474a14a670..77704685e108 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -89,9 +89,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 -/* Enable external trigger bit in nWrAddress */ -#define APCI3120_ENABLE_EXT_TRIGGER 0x8000 - /* ANALOG OUTPUT AND INPUT DEFINE */ #define APCI3120_UNIPOLAR 0x80 #define APCI3120_BIPOLAR 0x00 @@ -484,7 +481,7 @@ static int apci3120_exttrig_enable(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - devpriv->ctrl |= APCI3120_ENABLE_EXT_TRIGGER; + devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); return 0; } @@ -493,7 +490,7 @@ static int apci3120_exttrig_disable(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - devpriv->ctrl &= ~APCI3120_ENABLE_EXT_TRIGGER; + devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); return 0; } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 58db0aba088b..087ff1acf088 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -15,6 +15,7 @@ /* * PCI BAR 1 register map (dev->iobase) */ +#define APCI3120_CTRL_EXT_TRIG (1 << 15) #define APCI3120_CTRL_GATE(x) (1 << (12 + (x))) #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) -- cgit v1.2.3-59-g8ed1b From a6a1cfed89b5aca6e5ba179b3788d639ebe0c624 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:01 -0700 Subject: staging: comedi: addi_apci_3120: tidy up apci3120_exttrig_{enable,disable}() Merge these two functions and use an 'enable' parameter to determine if the external trigger needs to be enabled or disabled. This function always succeeds and the callers don't check the return. Change the return type to void. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 77704685e108..30606c947530 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -477,22 +477,15 @@ static int apci3120_reset(struct comedi_device *dev) return 0; } -static int apci3120_exttrig_enable(struct comedi_device *dev) +static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable) { struct apci3120_private *devpriv = dev->private; - devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); - return 0; -} - -static int apci3120_exttrig_disable(struct comedi_device *dev) -{ - struct apci3120_private *devpriv = dev->private; - - devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG; + if (enable) + devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG; + else + devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG; outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); - return 0; } static int apci3120_cancel(struct comedi_device *dev, @@ -649,7 +642,8 @@ static int apci3120_cyclic_ai(int mode, } if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) - apci3120_exttrig_enable(dev); /* activate EXT trigger */ + apci3120_exttrig_enable(dev, true); + switch (mode) { case 1: /* init timer0 in mode 2 */ @@ -1114,8 +1108,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) int_daq = (int_daq >> 12) & 0xF; if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { - /* Disable ext trigger */ - apci3120_exttrig_disable(dev); + apci3120_exttrig_enable(dev, false); devpriv->b_ExttrigEnable = APCI3120_DISABLE; } /* clear the timer 2 interrupt */ -- cgit v1.2.3-59-g8ed1b From 4ffa00a3cb634a363ee72339cb740ffdee389f66 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:02 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_timer_enable() Introduce a helper function to enable/disable a timer. The disable of timers 0 and 1 in apci3120_interrupt() is probably not needed. For now use the helper function to make sure the devpriv->ctrl bits are cleared correctly to disable the timers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 30606c947530..8da1db546b19 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -156,6 +156,18 @@ static const struct comedi_lrange range_apci3120_ai = { } }; +static void apci3120_timer_enable(struct comedi_device *dev, + unsigned int timer, bool enable) +{ + struct apci3120_private *devpriv = dev->private; + + if (enable) + devpriv->ctrl |= APCI3120_CTRL_GATE(timer); + else + devpriv->ctrl &= ~APCI3120_CTRL_GATE(timer); + outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); +} + static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -329,9 +341,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - /* Sets gate 0 */ - devpriv->ctrl |= APCI3120_CTRL_GATE(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 0, true); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor); @@ -402,9 +412,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + APCI3120_RD_STATUS); - /* Sets gate 0 */ - devpriv->ctrl |= APCI3120_CTRL_GATE(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 0, true); /* Start conversion */ outw(0, dev->iobase + APCI3120_START_CONVERSION); @@ -887,25 +895,17 @@ static int apci3120_cyclic_ai(int mode, } if (devpriv->us_UseDma == APCI3120_DISABLE && - cmd->stop_src == TRIG_COUNT) { - /* set gate 2 to start conversion */ - devpriv->ctrl |= APCI3120_CTRL_GATE(2); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); - } + cmd->stop_src == TRIG_COUNT) + apci3120_timer_enable(dev, 2, true); switch (mode) { case 1: - /* set gate 0 to start conversion */ - devpriv->ctrl |= APCI3120_CTRL_GATE(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 0, true); break; case 2: - /* set gate 0 and gate 1 */ - devpriv->ctrl |= APCI3120_CTRL_GATE(1) | - APCI3120_CTRL_GATE(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 1, true); + apci3120_timer_enable(dev, 0, true); break; - } return 0; @@ -1234,11 +1234,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) /* do some data transfer */ apci3120_interrupt_dma(irq, d); } else { - /* Stops the Timer */ - outw(devpriv->ctrl & - ~APCI3120_CTRL_GATE(0) & - ~APCI3120_CTRL_GATE(1), - dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 0, false); + apci3120_timer_enable(dev, 1, false); } } @@ -1270,9 +1267,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); - /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ - devpriv->ctrl &= ~APCI3120_CTRL_GATE(2); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 2, false); /* Disable TIMER Interrupt */ devpriv->b_ModeSelectRegister = @@ -1381,12 +1376,9 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ - /* For Timer mode is Gate2 must be activated timer started */ - devpriv->ctrl |= APCI3120_CTRL_GATE(2); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); - } - + /* start timer */ + if (devpriv->b_Timer2Mode == APCI3120_TIMER) + apci3120_timer_enable(dev, 2, true); break; case APCI3120_STOP: -- cgit v1.2.3-59-g8ed1b From 38abe9367fc6b047c5ffc6a7684ae8b4f3f78108 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:03 -0700 Subject: staging: comedi: addi_apci_3120: fix timer 2 disable in apci3120_write_insn_timer() The wrong define is being used to disable the gate to stop timer 2 in this function. Use the apci3120_timer_enable() helper to properly disable the timer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 8da1db546b19..3aa4bbedae7f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1404,9 +1404,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - /* Reset Gate 2 */ - devpriv->ctrl &= APCI3120_DISABLE_TIMER_INT; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + apci3120_timer_enable(dev, 2, false); /* Reset FC_TIMER BIT */ inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); -- cgit v1.2.3-59-g8ed1b From 9625742666306f866c9b56c41c25f8d35721dd29 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:04 -0700 Subject: staging: comedi: addi_apci_3120: rename APCI3120_WR_ADDRESS For aesthetics, rename this define. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 +++++------ drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3aa4bbedae7f..184bff4cabd3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -132,7 +132,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_STATUS_REGISTER 0x0d #define APCI3120_RD_STATUS 0x02 -#define APCI3120_WR_ADDRESS 0x00 #define APCI3120_ENABLE_WATCHDOG 0x20 #define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG) #define APCI3120_ENABLE_TIMER_COUNTER 0x10 @@ -165,7 +164,7 @@ static void apci3120_timer_enable(struct comedi_device *dev, devpriv->ctrl |= APCI3120_CTRL_GATE(timer); else devpriv->ctrl &= ~APCI3120_CTRL_GATE(timer); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); } static int apci3120_ai_insn_config(struct comedi_device *dev, @@ -245,7 +244,7 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, /* set scan length (PR) and scan start (PA) */ devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); for (i = 0; i < n_chan; i++) { /* store range list to card */ @@ -471,7 +470,7 @@ static int apci3120_reset(struct comedi_device *dev) /* disable all counters, ext trigger, and reset scan */ devpriv->ctrl = 0; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); inw(dev->iobase + 0); /* make a dummy read */ inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ @@ -493,7 +492,7 @@ static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable) devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG; else devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); } static int apci3120_cancel(struct comedi_device *dev, @@ -515,7 +514,7 @@ static int apci3120_cancel(struct comedi_device *dev, /* disable all counters, ext trigger, and reset scan */ devpriv->ctrl = 0; - outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); /* DISABLE_ALL_INTERRUPT */ outb(APCI3120_DISABLE_ALL_INTERRUPT, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 087ff1acf088..014a01495ae2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -15,6 +15,7 @@ /* * PCI BAR 1 register map (dev->iobase) */ +#define APCI3120_CTRL_REG 0x00 #define APCI3120_CTRL_EXT_TRIG (1 << 15) #define APCI3120_CTRL_GATE(x) (1 << (12 + (x))) #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) -- cgit v1.2.3-59-g8ed1b From a8f77b40b6c20d47816cbde84254ddef68480937 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:05 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_timer_enable() to driver source Move this helper function from the included source file into the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 12 ------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 184bff4cabd3..30e12986b6a3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -155,18 +155,6 @@ static const struct comedi_lrange range_apci3120_ai = { } }; -static void apci3120_timer_enable(struct comedi_device *dev, - unsigned int timer, bool enable) -{ - struct apci3120_private *devpriv = dev->private; - - if (enable) - devpriv->ctrl |= APCI3120_CTRL_GATE(timer); - else - devpriv->ctrl &= ~APCI3120_CTRL_GATE(timer); - outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); -} - static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 014a01495ae2..7bfb320d1312 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -208,6 +208,18 @@ static void apci3120_timer_set_mode(struct comedi_device *dev, outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG); } +static void apci3120_timer_enable(struct comedi_device *dev, + unsigned int timer, bool enable) +{ + struct apci3120_private *devpriv = dev->private; + + if (enable) + devpriv->ctrl |= APCI3120_CTRL_GATE(timer); + else + devpriv->ctrl &= ~APCI3120_CTRL_GATE(timer); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); +} + #include "addi-data/hwdrv_apci3120.c" static void apci3120_dma_alloc(struct comedi_device *dev) -- cgit v1.2.3-59-g8ed1b From b17d390661da546724fa465bbb7fcd7a5f849103 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:06 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_exttrig_enable() to driver source Move this helper function from the included source file into the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ----------- drivers/staging/comedi/drivers/addi_apci_3120.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 30e12986b6a3..3683c9ca2aad 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -472,17 +472,6 @@ static int apci3120_reset(struct comedi_device *dev) return 0; } -static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable) -{ - struct apci3120_private *devpriv = dev->private; - - if (enable) - devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG; - else - devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG; - outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); -} - static int apci3120_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 7bfb320d1312..8f7d9ef18b9c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -220,6 +220,17 @@ static void apci3120_timer_enable(struct comedi_device *dev, outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); } +static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable) +{ + struct apci3120_private *devpriv = dev->private; + + if (enable) + devpriv->ctrl |= APCI3120_CTRL_EXT_TRIG; + else + devpriv->ctrl &= ~APCI3120_CTRL_EXT_TRIG; + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); +} + #include "addi-data/hwdrv_apci3120.c" static void apci3120_dma_alloc(struct comedi_device *dev) -- cgit v1.2.3-59-g8ed1b From 24e18c85e57255f75cbbc3d8c4f8e36cd9ea7204 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:07 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_clr_timer2_interrupt() A dummy read of APCI3120_CTR0_REG clears the timer 2 interrupt. Introduce a helper function to clarify this. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 30 ++++++++-------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +++++ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3683c9ca2aad..6f547ee0b4ce 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -130,7 +130,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_WRITE_MODE_SELECT 0x0e -#define APCI3120_TIMER_STATUS_REGISTER 0x0d #define APCI3120_RD_STATUS 0x02 #define APCI3120_ENABLE_WATCHDOG 0x20 #define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG) @@ -691,8 +690,8 @@ static int apci3120_cyclic_ai(int mode, /* Set the scan stop count (not sure about the -2) */ apci3120_timer_write(dev, 2, cmd->stop_arg - 2); - /* (2) Reset FC_TIMER BIT Clearing timer status register */ - inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); + apci3120_clr_timer2_interrupt(dev); + /* enable timer counter and disable watch dog */ devpriv->b_ModeSelectRegister = (devpriv-> @@ -1067,7 +1066,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) unsigned short int_daq; unsigned int int_amcc, ui_Check, i; unsigned short us_TmpValue; - unsigned char b_DummyRead; ui_Check = 1; @@ -1087,8 +1085,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) apci3120_exttrig_enable(dev, false); devpriv->b_ExttrigEnable = APCI3120_DISABLE; } - /* clear the timer 2 interrupt */ - inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); + + apci3120_clr_timer2_interrupt(dev); if (int_amcc & MASTER_ABORT_INT) dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n"); @@ -1194,8 +1192,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } - b_DummyRead = inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); - + apci3120_clr_timer2_interrupt(dev); } if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) { @@ -1205,8 +1202,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) outl(APCI3120_CLEAR_WRITE_TC_INT, devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); - /* Clears the timer status register */ - inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); + apci3120_clr_timer2_interrupt(dev); + /* do some data transfer */ apci3120_interrupt_dma(irq, d); } else { @@ -1318,9 +1315,8 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, switch (data[0]) { case APCI3120_START: + apci3120_clr_timer2_interrupt(dev); - /* Reset FC_TIMER BIT */ - inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* Enable Timer */ devpriv->b_ModeSelectRegister = @@ -1382,9 +1378,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, apci3120_timer_enable(dev, 2, false); - /* Reset FC_TIMER BIT */ - inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); - + apci3120_clr_timer2_interrupt(dev); break; case 2: /* write new value to Timer */ @@ -1434,10 +1428,8 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, us_StatusValue = inw(dev->iobase + APCI3120_RD_STATUS); us_StatusValue = ((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1; - if (us_StatusValue == 1) { - /* RESET FC_TIMER BIT */ - inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER); - } + if (us_StatusValue == 1) + apci3120_clr_timer2_interrupt(dev); data[0] = us_StatusValue; /* when data[0] = 1 then the watch dog has rundown */ } return insn->n; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 8f7d9ef18b9c..ce94f907d9ef 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -155,6 +155,12 @@ static unsigned int apci3120_ns_to_timer(struct comedi_device *dev, return divisor; } +static void apci3120_clr_timer2_interrupt(struct comedi_device *dev) +{ + /* a dummy read of APCI3120_CTR0_REG clears the timer 2 interrupt */ + inb(dev->iobase + APCI3120_CTR0_REG); +} + static void apci3120_timer_write(struct comedi_device *dev, unsigned int timer, unsigned int val) { -- cgit v1.2.3-59-g8ed1b From 51db6bad08ea3f74768c40f254f4659f226b65e1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:08 -0700 Subject: staging: comedi: addi_apci_3120: remove unnecessary reset of the scan sequence The scan sequence does not need to be reset when the driver is attached. Remove the code in apci3120_reset() that does this. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 6f547ee0b4ce..3ebf5ecdbb5b 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -437,8 +437,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, static int apci3120_reset(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - unsigned int i; - unsigned short us_TmpValue; devpriv->ai_running = 0; devpriv->b_EocEosInterrupt = APCI3120_DISABLE; @@ -463,11 +461,6 @@ static int apci3120_reset(struct comedi_device *dev) inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */ - /* code to reset the RAM sequence */ - for (i = 0; i < 16; i++) { - us_TmpValue = i << 8; /* select the location */ - outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS); - } return 0; } -- cgit v1.2.3-59-g8ed1b From 9d5b070876ccd1f06121fa7ba5292c35a494ce24 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:09 -0700 Subject: staging: comedi: addi_apci_3120: tidy up scan chanlist programming Define the chanlist register and its bits and tidy up the programming of the scan chanlist. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 38 +++++++--------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 5 +++ 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3ebf5ecdbb5b..dd7805b7a3e4 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -71,11 +71,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY /* for transfer count enable bit */ #define AGCSTS_TC_ENABLE 0x10000000 -/* used for test on mixture of BIP/UNI ranges */ -#define APCI3120_BIPOLAR_RANGES 4 - -#define APCI3120_ADDRESS_RANGE 16 - #define APCI3120_DISABLE 0 #define APCI3120_ENABLE 1 @@ -89,14 +84,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 -/* ANALOG OUTPUT AND INPUT DEFINE */ -#define APCI3120_UNIPOLAR 0x80 -#define APCI3120_BIPOLAR 0x00 -#define APCI3120_1_GAIN 0x00 -#define APCI3120_2_GAIN 0x10 -#define APCI3120_5_GAIN 0x20 -#define APCI3120_10_GAIN 0x30 -#define APCI3120_SEQ_RAM_ADDRESS 0x06 #define APCI3120_RESET_FIFO 0x0c /* nWrMode_Select */ @@ -214,9 +201,7 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, char check) { struct apci3120_private *devpriv = dev->private; - unsigned int i; - unsigned int gain; - unsigned short us_TmpValue; + int i; /* correct channel and range number check itself comedi/range.c */ if (n_chan < 1) { @@ -233,19 +218,20 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); + /* set chanlist for scan */ for (i = 0; i < n_chan; i++) { - /* store range list to card */ - us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number */ + unsigned int chan = CR_CHAN(chanlist[i]); + unsigned int range = CR_RANGE(chanlist[i]); + unsigned int val; - if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) - us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */ - else - us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar */ + val = APCI3120_CHANLIST_MUX(chan) | + APCI3120_CHANLIST_GAIN(range) | + APCI3120_CHANLIST_INDEX(i); + + if (comedi_range_is_unipolar(s, range)) + val |= APCI3120_CHANLIST_UNIPOLAR; - gain = CR_RANGE(chanlist[i]); /* get gain number */ - us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */ - us_TmpValue |= i << 8; /* To select the RAM LOCATION */ - outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS); + outw(val, dev->iobase + APCI3120_CHANLIST_REG); } return 1; /* we can serve this with scan logic */ } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ce94f907d9ef..45add7603d1b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -22,6 +22,11 @@ #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) #define APCI3120_TIMER_REG 0x04 +#define APCI3120_CHANLIST_REG 0x06 +#define APCI3120_CHANLIST_INDEX(x) (((x) & 0xf) << 8) +#define APCI3120_CHANLIST_UNIPOLAR (1 << 7) +#define APCI3120_CHANLIST_GAIN(x) (((x) & 0x3) << 4) +#define APCI3120_CHANLIST_MUX(x) (((x) & 0xf) << 0) #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) -- cgit v1.2.3-59-g8ed1b From ea0bb9d221d14b622dedeaa10bd5f6ac525e6efd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:10 -0700 Subject: staging: comedi: addi_apci_3120: remove 'check' param from apci3120_setup_chan_list() This parameter is always passed as '0'. Remove it and refactor the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index dd7805b7a3e4..44a3fcd19b7f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -188,31 +188,18 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, return insn->n; } -/* - * This function will first check channel list is ok or not and then - * initialize the sequence RAM with the polarity, Gain,Channel number. - * If the last argument of function "check"is 1 then it only checks - * the channel list is ok or not. - */ static int apci3120_setup_chan_list(struct comedi_device *dev, struct comedi_subdevice *s, - int n_chan, - unsigned int *chanlist, - char check) + int n_chan, unsigned int *chanlist) { struct apci3120_private *devpriv = dev->private; int i; /* correct channel and range number check itself comedi/range.c */ if (n_chan < 1) { - if (!check) - dev_err(dev->class_dev, - "range/channel list is empty!\n"); + dev_err(dev->class_dev, "range/channel list is empty!\n"); return 0; } - /* All is ok, so we can setup channel/range list */ - if (check) - return 1; /* set scan length (PR) and scan start (PA) */ devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); @@ -282,7 +269,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Initialize the sequence array */ if (!apci3120_setup_chan_list(dev, s, 1, - &insn->chanspec, 0)) + &insn->chanspec)) return -EINVAL; /* Initialize Timer 0 mode 4 */ @@ -347,7 +334,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, - devpriv->ui_AiChannelList, 0)) + devpriv->ui_AiChannelList)) return -EINVAL; /* Initialize Timer 0 mode 2 */ @@ -594,7 +581,7 @@ static int apci3120_cyclic_ai(int mode, /* Initializes the sequence array */ if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, - cmd->chanlist, 0)) + cmd->chanlist)) return -EINVAL; divisor0 = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); -- cgit v1.2.3-59-g8ed1b From d0bb66aa082c23741e85df459f7444f86cd86792 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:11 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_ai_reset_fifo() A dummy read of APCI3120_TIMER_MODE_REG resets the analog input FIFO. Introduce a helper function to clarify this. It's not necessary to do a dummy read of the FIFO (base + 0) before reseting it. Remove the unnecessary dummy reads. The APCI3120_TIMER_MODE_REG is a 16-bit register. This fixes a couple 8-bit reads. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 30 +++++----------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 6 +++++ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 44a3fcd19b7f..0673e4fbc9b1 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -84,8 +84,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 -#define APCI3120_RESET_FIFO 0x0c - /* nWrMode_Select */ #define APCI3120_ENABLE_SCAN 0x8 #define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN) @@ -261,11 +259,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, switch (us_TmpValue) { case APCI3120_EOC_MODE: - - /* - * Testing the interrupt flag and set the EOC bit Clears the FIFO - */ - inw(dev->iobase + APCI3120_RESET_FIFO); + apci3120_ai_reset_fifo(dev); /* Initialize the sequence array */ if (!apci3120_setup_chan_list(dev, s, 1, @@ -321,16 +315,13 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, us_TmpValue = inw(dev->iobase + 0); *data = us_TmpValue; - inw(dev->iobase + APCI3120_RESET_FIFO); + apci3120_ai_reset_fifo(dev); } break; case APCI3120_EOS_MODE: - - inw(dev->iobase + 0); - /* Clears the FIFO */ - inw(dev->iobase + APCI3120_RESET_FIFO); + apci3120_ai_reset_fifo(dev); if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, @@ -430,8 +421,7 @@ static int apci3120_reset(struct comedi_device *dev) devpriv->ctrl = 0; outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); - inw(dev->iobase + 0); /* make a dummy read */ - inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ + apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */ return 0; @@ -461,8 +451,8 @@ static int apci3120_cancel(struct comedi_device *dev, /* DISABLE_ALL_INTERRUPT */ outb(APCI3120_DISABLE_ALL_INTERRUPT, dev->iobase + APCI3120_WRITE_MODE_SELECT); - /* Flush FIFO */ - inb(dev->iobase + APCI3120_RESET_FIFO); + + apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_RD_STATUS); devpriv->ui_DmaActualBuffer = 0; @@ -559,9 +549,6 @@ static int apci3120_cyclic_ai(int mode, unsigned int dmalen1 = 0; unsigned int divisor0; - /* Resets the FIFO */ - inb(dev->iobase + APCI3120_RESET_FIFO); - devpriv->ai_running = 1; /* clear software registers */ @@ -572,10 +559,7 @@ static int apci3120_cyclic_ai(int mode, outl(APCI3120_CLEAR_WRITE_TC_INT, devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); - /* Resets the FIFO */ - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - inb(dev->iobase + APCI3120_RESET_FIFO); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + apci3120_ai_reset_fifo(dev); devpriv->ui_DmaActualBuffer = 0; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 45add7603d1b..8dfee45a0576 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -242,6 +242,12 @@ static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable) outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); } +static void apci3120_ai_reset_fifo(struct comedi_device *dev) +{ + /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */ + inw(dev->iobase + APCI3120_TIMER_MODE_REG); +} + #include "addi-data/hwdrv_apci3120.c" static void apci3120_dma_alloc(struct comedi_device *dev) -- cgit v1.2.3-59-g8ed1b From 6ef680325566e817b12898a43471f318eba41ca0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:12 -0700 Subject: staging: comedi: addi_apci_3120: move ai range table to driver source Move the analog input comedi_lrange table from the included hwdrv_apci3120.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 14 -------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 0673e4fbc9b1..cb2856da34fb 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -125,20 +125,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER2_SELECT_EOS 0xc0 #define APCI3120_COUNTER 3 -/* ANALOG INPUT RANGE */ -static const struct comedi_lrange range_apci3120_ai = { - 8, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2), - UNI_RANGE(1) - } -}; - static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 8dfee45a0576..6c7f452a2dae 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -53,6 +53,19 @@ #define APCI3120_REVA_OSC_BASE 70 /* 70ns = 14.29MHz */ #define APCI3120_REVB_OSC_BASE 50 /* 50ns = 20MHz */ +static const struct comedi_lrange apci3120_ai_range = { + 8, { + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2), + BIP_RANGE(1), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2), + UNI_RANGE(1) + } +}; + enum apci3120_boardid { BOARD_APCI3120, BOARD_APCI3001, @@ -355,7 +368,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; s->n_chan = 16; s->maxdata = this_board->ai_is_16bit ? 0xffff : 0x0fff; - s->range_table = &range_apci3120_ai; + s->range_table = &apci3120_ai_range; s->insn_config = apci3120_ai_insn_config; s->insn_read = apci3120_ai_insn_read; if (0 /* dev->irq */) { -- cgit v1.2.3-59-g8ed1b From f85c54dbe557257b4c9f1f53f80b555378008f1f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:13 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER At the start of apci3120_ai_insn_read() the devpriv->b_ModeSelectRegister is set to '0'. Remove the unnecessary masking to clear the interrupt enable bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index cb2856da34fb..2dd8e665d471 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -92,8 +92,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT) #define APCI3120_ENABLE_EOC_INT 0x1 #define APCI3120_DISABLE_EOC_INT (~APCI3120_ENABLE_EOC_INT) -#define APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER \ - (APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) #define APCI3120_DISABLE_ALL_INTERRUPT \ (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) @@ -270,11 +268,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, APCI3120_ENABLE_EOC_INT; inw(dev->iobase + 0); - } else { - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER; } outb(devpriv->b_ModeSelectRegister, @@ -337,11 +330,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, APCI3120_ENABLE_EOS_INT; inw(dev->iobase + 0); - } else - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER; + } outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); -- cgit v1.2.3-59-g8ed1b From b2cf40a31df207dacc298bc6c559b24e28a896e2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:14 -0700 Subject: staging: comedi: addi_apci_3120: properly disable interrupts in apci3120_cancel() The APCI3120_DISABLE_ALL_INTERRUPT define is a mask value used to clear bits in devpriv->b_ModeSelectRegister to disable the interrupt sources. Writing this value directly sets unintended bits. Just set the devpriv->b_ModeSelectRegister to '0' and write that to the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 2dd8e665d471..84aff802ae18 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -92,8 +92,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT) #define APCI3120_ENABLE_EOC_INT 0x1 #define APCI3120_DISABLE_EOC_INT (~APCI3120_ENABLE_EOC_INT) -#define APCI3120_DISABLE_ALL_INTERRUPT \ - (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT) /* status register bits */ #define APCI3120_EOC 0x8000 @@ -424,8 +422,9 @@ static int apci3120_cancel(struct comedi_device *dev, outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); /* DISABLE_ALL_INTERRUPT */ - outb(APCI3120_DISABLE_ALL_INTERRUPT, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->b_ModeSelectRegister = 0; + outb(devpriv->b_ModeSelectRegister, + dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_RD_STATUS); -- cgit v1.2.3-59-g8ed1b From 627e83a7e0f5d0141cbc726ec062d2804a6e12a5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:15 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'b_ModeSelectRegister' Rename this CamelCase member of the private data and tidy up the mask/set of its bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 198 +++++++-------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 2 files changed, 62 insertions(+), 138 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 84aff802ae18..fcb92e801c8a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -226,7 +226,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Clear software registers */ devpriv->timer_mode = 0; - devpriv->b_ModeSelectRegister = 0; + devpriv->mode = 0; if (insn->unused[0] == 222) { /* second insn read */ for (i = 0; i < insn->n; i++) @@ -252,23 +252,17 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_SCAN; + devpriv->mode &= APCI3120_DISABLE_SCAN; if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* Disables the EOS,DMA and enables the EOC interrupt */ - devpriv->b_ModeSelectRegister = - (devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_EOS_INT) | - APCI3120_ENABLE_EOC_INT; + devpriv->mode &= APCI3120_DISABLE_EOS_INT; + devpriv->mode |= APCI3120_ENABLE_EOC_INT; inw(dev->iobase + 0); - } - outb(devpriv->b_ModeSelectRegister, + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_timer_enable(dev, 0, true); @@ -312,25 +306,20 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, apci3120_timer_write(dev, 0, divisor); /* Set the scan bit */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister | APCI3120_ENABLE_SCAN; - outb(devpriv->b_ModeSelectRegister, + devpriv->mode |= APCI3120_ENABLE_SCAN; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* If Interrupt function is loaded */ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* Disables the EOC,DMA and enables the EOS interrupt */ - devpriv->b_ModeSelectRegister = - (devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_EOC_INT) | - APCI3120_ENABLE_EOS_INT; + devpriv->mode &= APCI3120_DISABLE_EOC_INT; + devpriv->mode |= APCI3120_ENABLE_EOS_INT; inw(dev->iobase + 0); } - outb(devpriv->b_ModeSelectRegister, + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); inw(dev->iobase + APCI3120_RD_STATUS); @@ -386,9 +375,8 @@ static int apci3120_reset(struct comedi_device *dev) devpriv->b_ExttrigEnable = 0; /* Disable ext trigger */ /* Disable all interrupts, watchdog for the anolog output */ - devpriv->b_ModeSelectRegister = 0; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode = 0; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* disable all counters, ext trigger, and reset scan */ devpriv->ctrl = 0; @@ -422,9 +410,8 @@ static int apci3120_cancel(struct comedi_device *dev, outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); /* DISABLE_ALL_INTERRUPT */ - devpriv->b_ModeSelectRegister = 0; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode = 0; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_RD_STATUS); @@ -527,7 +514,7 @@ static int apci3120_cyclic_ai(int mode, /* clear software registers */ devpriv->timer_mode = 0; - devpriv->b_ModeSelectRegister = 0; + devpriv->mode = 0; /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, @@ -575,14 +562,10 @@ static int apci3120_cyclic_ai(int mode, break; } - /* common for all modes */ - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & - APCI3120_DISABLE_SCAN; - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + /* common for all modes */ + devpriv->mode &= APCI3120_DISABLE_SCAN; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* If DMA is disabled */ if (devpriv->us_UseDma == APCI3120_DISABLE) { @@ -590,23 +573,17 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_InterruptMode = APCI3120_EOS_MODE; devpriv->b_EocEosInterrupt = APCI3120_ENABLE; - devpriv->b_ModeSelectRegister = - (devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT) | - APCI3120_ENABLE_EOS_INT; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_EOC_INT; + devpriv->mode |= APCI3120_ENABLE_EOS_INT; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (cmd->stop_src == TRIG_COUNT) { /* configure Timer2 For counting EOS */ /* DISABLE TIMER intERRUPT */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_TIMER_INT & 0xEF; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_TIMER_INT & 0xef; + outb(devpriv->mode, + dev->iobase + APCI3120_WRITE_MODE_SELECT); /* (1) Init timer 2 in mode 0 and write timer value */ apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0); @@ -617,23 +594,14 @@ static int apci3120_cyclic_ai(int mode, apci3120_clr_timer2_interrupt(dev); /* enable timer counter and disable watch dog */ - devpriv->b_ModeSelectRegister = - (devpriv-> - b_ModeSelectRegister | - APCI3120_ENABLE_TIMER_COUNTER) & - APCI3120_DISABLE_WATCHDOG; + devpriv->mode &= APCI3120_DISABLE_WATCHDOG; + devpriv->mode |= APCI3120_ENABLE_TIMER_COUNTER; /* select EOS clock input for timer 2 */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister | - APCI3120_TIMER2_SELECT_EOS; + devpriv->mode |= APCI3120_TIMER2_SELECT_EOS; /* Enable timer2 interrupt */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister | - APCI3120_ENABLE_TIMER_INT; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode |= APCI3120_ENABLE_TIMER_INT; + outb(devpriv->mode, + dev->iobase + APCI3120_WRITE_MODE_SELECT); devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = APCI3120_ENABLE; } @@ -648,11 +616,9 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_InterruptMode = APCI3120_DMA_MODE; /* Disables the EOC, EOS interrupt */ - devpriv->b_ModeSelectRegister = devpriv->b_ModeSelectRegister & - APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; - - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_EOC_INT & + APCI3120_DISABLE_EOS_INT; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); dmalen0 = dmabuf0->size; dmalen1 = dmabuf1->size; @@ -1028,10 +994,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } else { /* Disable EOC Interrupt */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT; - outb(devpriv->b_ModeSelectRegister, + devpriv->mode &= APCI3120_DISABLE_EOC_INT; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); } } @@ -1044,13 +1008,9 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (devpriv->ai_running) { ui_Check = 0; apci3120_interrupt_handle_eos(dev); - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister | - APCI3120_ENABLE_EOS_INT; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + - APCI3120_WRITE_MODE_SELECT); + devpriv->mode |= APCI3120_ENABLE_EOS_INT; + outb(devpriv->mode, + dev->iobase + APCI3120_WRITE_MODE_SELECT); } else { ui_Check = 0; for (i = 0; i < devpriv->ui_AiNbrofChannels; @@ -1067,11 +1027,9 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } } else { - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_EOS_INT; + outb(devpriv->mode, + dev->iobase + APCI3120_WRITE_MODE_SELECT); devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */ devpriv->b_InterruptMode = APCI3120_EOC_MODE; } @@ -1082,11 +1040,9 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_EOS_INT; + outb(devpriv->mode, + dev->iobase + APCI3120_WRITE_MODE_SELECT); s->async->events |= COMEDI_CB_EOA; break; @@ -1106,14 +1062,9 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) default: /* disable Timer Interrupt */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_TIMER_INT; - - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); - + devpriv->mode &= APCI3120_DISABLE_TIMER_INT; + outb(devpriv->mode, + dev->iobase + APCI3120_WRITE_MODE_SELECT); } apci3120_clr_timer2_interrupt(dev); @@ -1167,17 +1118,12 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, apci3120_timer_enable(dev, 2, false); /* Disable TIMER Interrupt */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_TIMER_INT & 0xEF; + devpriv->mode &= APCI3120_DISABLE_TIMER_INT & 0xef; /* Disable Eoc and Eos Interrupts */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT & - APCI3120_DISABLE_EOS_INT; - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE2); @@ -1243,34 +1189,23 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* Enable Timer */ - devpriv->b_ModeSelectRegister = - devpriv->b_ModeSelectRegister & 0x0B; + devpriv->mode &= 0x0b; } else { /* start watch dog */ /* Enable WatchDog */ - devpriv->b_ModeSelectRegister = - (devpriv-> - b_ModeSelectRegister & 0x0B) | - APCI3120_ENABLE_WATCHDOG; + devpriv->mode &= 0x0b; + devpriv->mode |= APCI3120_ENABLE_WATCHDOG; } /* enable disable interrupt */ if ((devpriv->b_Timer2Interrupt) == APCI3120_ENABLE) { + devpriv->mode |= APCI3120_ENABLE_TIMER_INT; - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister | - APCI3120_ENABLE_TIMER_INT; /* save the task structure to pass info to user */ devpriv->tsk_Current = current; } else { - - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_TIMER_INT; + devpriv->mode &= APCI3120_DISABLE_TIMER_INT; } - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* start timer */ if (devpriv->b_Timer2Mode == APCI3120_TIMER) @@ -1280,25 +1215,14 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, case APCI3120_STOP: if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* Disable timer */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_TIMER_COUNTER; + devpriv->mode &= APCI3120_DISABLE_TIMER_COUNTER; } else { /* Disable WatchDog */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & - APCI3120_DISABLE_WATCHDOG; + devpriv->mode &= APCI3120_DISABLE_WATCHDOG; } /* Disable timer interrupt */ - devpriv->b_ModeSelectRegister = - devpriv-> - b_ModeSelectRegister & APCI3120_DISABLE_TIMER_INT; - - /* Write above states to register */ - outb(devpriv->b_ModeSelectRegister, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->mode &= APCI3120_DISABLE_TIMER_INT; + outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_timer_enable(dev, 2, false); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 6c7f452a2dae..e1c0535adb4b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -108,7 +108,7 @@ struct apci3120_private { struct apci3120_dmabuf dmabuf[2]; unsigned char do_bits; unsigned char timer_mode; - unsigned char b_ModeSelectRegister; + unsigned char mode; unsigned short ctrl; unsigned char b_Timer2Mode; unsigned char b_Timer2Interrupt; -- cgit v1.2.3-59-g8ed1b From 363aa5f2f47ec32d9ddc40db7312bf907b957bae Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:16 -0700 Subject: staging: comedi: addi_apci_3120: remove unnecessary devpriv->mode masking The devpriv->mode is set to '0' at the start of apci3120_ai_insn_read() and apci3120_cyclic_ai(). There is no need to clear any of the bits or do any of the additional writes of those cleared bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 23 ---------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index fcb92e801c8a..c58d4a6a0241 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -251,13 +251,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Initialize Timer 0 mode 4 */ apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); - /* Reset the scan bit and Disables the EOS, DMA, EOC interrupt */ - devpriv->mode &= APCI3120_DISABLE_SCAN; - if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - - /* Disables the EOS,DMA and enables the EOC interrupt */ - devpriv->mode &= APCI3120_DISABLE_EOS_INT; devpriv->mode |= APCI3120_ENABLE_EOC_INT; inw(dev->iobase + 0); } @@ -312,11 +306,8 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* If Interrupt function is loaded */ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - /* Disables the EOC,DMA and enables the EOS interrupt */ - devpriv->mode &= APCI3120_DISABLE_EOC_INT; devpriv->mode |= APCI3120_ENABLE_EOS_INT; inw(dev->iobase + 0); - } outb(devpriv->mode, @@ -563,8 +554,6 @@ static int apci3120_cyclic_ai(int mode, } - /* common for all modes */ - devpriv->mode &= APCI3120_DISABLE_SCAN; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* If DMA is disabled */ @@ -573,18 +562,12 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_InterruptMode = APCI3120_EOS_MODE; devpriv->b_EocEosInterrupt = APCI3120_ENABLE; - devpriv->mode &= APCI3120_DISABLE_EOC_INT; devpriv->mode |= APCI3120_ENABLE_EOS_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (cmd->stop_src == TRIG_COUNT) { /* configure Timer2 For counting EOS */ - /* DISABLE TIMER intERRUPT */ - devpriv->mode &= APCI3120_DISABLE_TIMER_INT & 0xef; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); - /* (1) Init timer 2 in mode 0 and write timer value */ apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0); @@ -594,7 +577,6 @@ static int apci3120_cyclic_ai(int mode, apci3120_clr_timer2_interrupt(dev); /* enable timer counter and disable watch dog */ - devpriv->mode &= APCI3120_DISABLE_WATCHDOG; devpriv->mode |= APCI3120_ENABLE_TIMER_COUNTER; /* select EOS clock input for timer 2 */ devpriv->mode |= APCI3120_TIMER2_SELECT_EOS; @@ -615,11 +597,6 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_InterruptMode = APCI3120_DMA_MODE; - /* Disables the EOC, EOS interrupt */ - devpriv->mode &= APCI3120_DISABLE_EOC_INT & - APCI3120_DISABLE_EOS_INT; - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); - dmalen0 = dmabuf0->size; dmalen1 = dmabuf1->size; -- cgit v1.2.3-59-g8ed1b From 81ff03ba1979b5881d2a29effcd46a81fa554340 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:17 -0700 Subject: staging: comedi: addi_apci_3120: remove devpriv->mode '0xef' magic value This mask value is the same as APCI3120_DISABLE_TIMER_COUNTER. Use that instead and remove the "magic" value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c58d4a6a0241..f351b50083f3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1095,7 +1095,8 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, apci3120_timer_enable(dev, 2, false); /* Disable TIMER Interrupt */ - devpriv->mode &= APCI3120_DISABLE_TIMER_INT & 0xef; + devpriv->mode &= APCI3120_DISABLE_TIMER_INT & + APCI3120_DISABLE_TIMER_COUNTER; /* Disable Eoc and Eos Interrupts */ devpriv->mode &= APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; -- cgit v1.2.3-59-g8ed1b From b835aac0bdcf3b9aa76c173eff7af3cb1f45e719 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:18 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_COUNTER For aesthetics, remove this define and just use ~APCI3120_ENABLE_TIMER_COUNTER. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index f351b50083f3..3eb53f1cea90 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -115,7 +115,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_ENABLE_WATCHDOG 0x20 #define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG) #define APCI3120_ENABLE_TIMER_COUNTER 0x10 -#define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER) #define APCI3120_FC_TIMER 0x1000 #define APCI3120_TIMER2_SELECT_EOS 0xc0 @@ -1096,7 +1095,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, /* Disable TIMER Interrupt */ devpriv->mode &= APCI3120_DISABLE_TIMER_INT & - APCI3120_DISABLE_TIMER_COUNTER; + ~APCI3120_ENABLE_TIMER_COUNTER; /* Disable Eoc and Eos Interrupts */ devpriv->mode &= APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; @@ -1193,7 +1192,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, case APCI3120_STOP: if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* Disable timer */ - devpriv->mode &= APCI3120_DISABLE_TIMER_COUNTER; + devpriv->mode &= ~APCI3120_ENABLE_TIMER_COUNTER; } else { /* Disable WatchDog */ devpriv->mode &= APCI3120_DISABLE_WATCHDOG; -- cgit v1.2.3-59-g8ed1b From b6eb21d6df0dbb190fb7f96a66abc902ae51ee52 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:19 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_WATCHDOG For aesthetics, remove this define and just use ~APCI3120_ENABLE_WATCHDOG. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3eb53f1cea90..f6812eab1d15 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -113,7 +113,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_STATUS 0x02 #define APCI3120_ENABLE_WATCHDOG 0x20 -#define APCI3120_DISABLE_WATCHDOG (~APCI3120_ENABLE_WATCHDOG) #define APCI3120_ENABLE_TIMER_COUNTER 0x10 #define APCI3120_FC_TIMER 0x1000 @@ -1195,7 +1194,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, devpriv->mode &= ~APCI3120_ENABLE_TIMER_COUNTER; } else { /* Disable WatchDog */ - devpriv->mode &= APCI3120_DISABLE_WATCHDOG; + devpriv->mode &= ~APCI3120_ENABLE_WATCHDOG; } /* Disable timer interrupt */ devpriv->mode &= APCI3120_DISABLE_TIMER_INT; -- cgit v1.2.3-59-g8ed1b From 604f8e10b516a85124ef86fb7c25aa997c3092d0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:20 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_INT For aesthetics, remove this define and just use ~APCI3120_ENABLE_TIMER_INT. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index f6812eab1d15..31920b6876b5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -108,7 +108,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 #define APCI3120_ENABLE_TIMER_INT 0x04 -#define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_WRITE_MODE_SELECT 0x0e #define APCI3120_RD_STATUS 0x02 @@ -1037,7 +1036,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) default: /* disable Timer Interrupt */ - devpriv->mode &= APCI3120_DISABLE_TIMER_INT; + devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); } @@ -1093,7 +1092,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, apci3120_timer_enable(dev, 2, false); /* Disable TIMER Interrupt */ - devpriv->mode &= APCI3120_DISABLE_TIMER_INT & + devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT & ~APCI3120_ENABLE_TIMER_COUNTER; /* Disable Eoc and Eos Interrupts */ @@ -1179,7 +1178,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, /* save the task structure to pass info to user */ devpriv->tsk_Current = current; } else { - devpriv->mode &= APCI3120_DISABLE_TIMER_INT; + devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT; } outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); @@ -1197,7 +1196,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, devpriv->mode &= ~APCI3120_ENABLE_WATCHDOG; } /* Disable timer interrupt */ - devpriv->mode &= APCI3120_DISABLE_TIMER_INT; + devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_timer_enable(dev, 2, false); -- cgit v1.2.3-59-g8ed1b From 1084dce74f1f69ce1b7a8715eb246d878b3a7448 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:21 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOC_INT For aesthetics, remove this define and just use ~APCI3120_ENABLE_EOC_INT. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 31920b6876b5..545bc90234d5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -91,7 +91,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT) #define APCI3120_ENABLE_EOC_INT 0x1 -#define APCI3120_DISABLE_EOC_INT (~APCI3120_ENABLE_EOC_INT) /* status register bits */ #define APCI3120_EOC 0x8000 @@ -968,7 +967,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } else { /* Disable EOC Interrupt */ - devpriv->mode &= APCI3120_DISABLE_EOC_INT; + devpriv->mode &= ~APCI3120_ENABLE_EOC_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); } @@ -1096,7 +1095,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, ~APCI3120_ENABLE_TIMER_COUNTER; /* Disable Eoc and Eos Interrupts */ - devpriv->mode &= APCI3120_DISABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; + devpriv->mode &= ~APCI3120_ENABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ -- cgit v1.2.3-59-g8ed1b From 7a945f984d88ff4a7ea33d34ed1773fcbb176699 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:22 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOS_INT For aesthetics, remove this define and just use ~APCI3120_ENABLE_EOS_INT. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 545bc90234d5..a71b70f71688 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -89,7 +89,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN) #define APCI3120_ENABLE_EOS_INT 0x2 -#define APCI3120_DISABLE_EOS_INT (~APCI3120_ENABLE_EOS_INT) #define APCI3120_ENABLE_EOC_INT 0x1 /* status register bits */ @@ -1000,7 +999,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } } else { - devpriv->mode &= APCI3120_DISABLE_EOS_INT; + devpriv->mode &= ~APCI3120_ENABLE_EOS_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */ @@ -1013,7 +1012,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: - devpriv->mode &= APCI3120_DISABLE_EOS_INT; + devpriv->mode &= ~APCI3120_ENABLE_EOS_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); @@ -1095,7 +1094,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, ~APCI3120_ENABLE_TIMER_COUNTER; /* Disable Eoc and Eos Interrupts */ - devpriv->mode &= ~APCI3120_ENABLE_EOC_INT & APCI3120_DISABLE_EOS_INT; + devpriv->mode &= ~APCI3120_ENABLE_EOC_INT & ~APCI3120_ENABLE_EOS_INT; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ -- cgit v1.2.3-59-g8ed1b From 67d3a2e715d4a89898f6f4763eb285b7ae9fea26 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:23 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_SCAN This define is not used in the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a71b70f71688..d2d0ef4efd66 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -86,7 +86,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY /* nWrMode_Select */ #define APCI3120_ENABLE_SCAN 0x8 -#define APCI3120_DISABLE_SCAN (~APCI3120_ENABLE_SCAN) #define APCI3120_ENABLE_EOS_INT 0x2 #define APCI3120_ENABLE_EOC_INT 0x1 -- cgit v1.2.3-59-g8ed1b From 1869ae026ca030340c954f6de91d05774101a103 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:24 -0700 Subject: staging: comedi: addi_apci_3120: define the "enable" bits in the mode register For aesthetics, redefine the bits in the mode register that enable interrupts and scanning. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 38 +++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 +++ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index d2d0ef4efd66..03ebe971f823 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -84,12 +84,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 -/* nWrMode_Select */ -#define APCI3120_ENABLE_SCAN 0x8 -#define APCI3120_ENABLE_EOS_INT 0x2 - -#define APCI3120_ENABLE_EOC_INT 0x1 - /* status register bits */ #define APCI3120_EOC 0x8000 #define APCI3120_EOS 0x2000 @@ -104,7 +98,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_WATCHDOG 2 #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 -#define APCI3120_ENABLE_TIMER_INT 0x04 #define APCI3120_WRITE_MODE_SELECT 0x0e #define APCI3120_RD_STATUS 0x02 @@ -246,7 +239,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - devpriv->mode |= APCI3120_ENABLE_EOC_INT; + devpriv->mode |= APCI3120_MODE_EOC_IRQ_ENA; inw(dev->iobase + 0); } @@ -294,13 +287,13 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, apci3120_timer_write(dev, 0, divisor); /* Set the scan bit */ - devpriv->mode |= APCI3120_ENABLE_SCAN; + devpriv->mode |= APCI3120_MODE_SCAN_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* If Interrupt function is loaded */ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - devpriv->mode |= APCI3120_ENABLE_EOS_INT; + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; inw(dev->iobase + 0); } @@ -556,7 +549,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_InterruptMode = APCI3120_EOS_MODE; devpriv->b_EocEosInterrupt = APCI3120_ENABLE; - devpriv->mode |= APCI3120_ENABLE_EOS_INT; + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (cmd->stop_src == TRIG_COUNT) { @@ -575,7 +568,7 @@ static int apci3120_cyclic_ai(int mode, /* select EOS clock input for timer 2 */ devpriv->mode |= APCI3120_TIMER2_SELECT_EOS; /* Enable timer2 interrupt */ - devpriv->mode |= APCI3120_ENABLE_TIMER_INT; + devpriv->mode |= APCI3120_MODE_TIMER2_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); devpriv->b_Timer2Mode = APCI3120_COUNTER; @@ -965,7 +958,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ } else { /* Disable EOC Interrupt */ - devpriv->mode &= ~APCI3120_ENABLE_EOC_INT; + devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); } @@ -979,7 +972,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (devpriv->ai_running) { ui_Check = 0; apci3120_interrupt_handle_eos(dev); - devpriv->mode |= APCI3120_ENABLE_EOS_INT; + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); } else { @@ -998,7 +991,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } } else { - devpriv->mode &= ~APCI3120_ENABLE_EOS_INT; + devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */ @@ -1011,7 +1004,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: - devpriv->mode &= ~APCI3120_ENABLE_EOS_INT; + devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); @@ -1033,7 +1026,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) default: /* disable Timer Interrupt */ - devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT; + devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); } @@ -1089,11 +1082,12 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, apci3120_timer_enable(dev, 2, false); /* Disable TIMER Interrupt */ - devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT & + devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA & ~APCI3120_ENABLE_TIMER_COUNTER; /* Disable Eoc and Eos Interrupts */ - devpriv->mode &= ~APCI3120_ENABLE_EOC_INT & ~APCI3120_ENABLE_EOS_INT; + devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA & + ~APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ @@ -1170,12 +1164,12 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, /* enable disable interrupt */ if ((devpriv->b_Timer2Interrupt) == APCI3120_ENABLE) { - devpriv->mode |= APCI3120_ENABLE_TIMER_INT; + devpriv->mode |= APCI3120_MODE_TIMER2_IRQ_ENA; /* save the task structure to pass info to user */ devpriv->tsk_Current = current; } else { - devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT; + devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; } outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); @@ -1193,7 +1187,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, devpriv->mode &= ~APCI3120_ENABLE_WATCHDOG; } /* Disable timer interrupt */ - devpriv->mode &= ~APCI3120_ENABLE_TIMER_INT; + devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_timer_enable(dev, 2, false); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e1c0535adb4b..603bebb7e059 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -40,6 +40,10 @@ #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) +#define APCI3120_MODE_SCAN_ENA (1 << 3) +#define APCI3120_MODE_TIMER2_IRQ_ENA (1 << 2) +#define APCI3120_MODE_EOS_IRQ_ENA (1 << 1) +#define APCI3120_MODE_EOC_IRQ_ENA (1 << 0) /* * PCI BAR 2 register map (devpriv->addon) -- cgit v1.2.3-59-g8ed1b From 7cbc057d85b7da51ca610381a3de77fbafc51311 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:25 -0700 Subject: staging: comedi: addi_apci_3120: define the timer 2 operation bits For aesthetics, redefine the bits in the mode register used to set the operation mode of timer 2. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 23 ++++++++-------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 ++++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 03ebe971f823..87c82e4b76f5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -101,8 +101,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_WRITE_MODE_SELECT 0x0e #define APCI3120_RD_STATUS 0x02 -#define APCI3120_ENABLE_WATCHDOG 0x20 -#define APCI3120_ENABLE_TIMER_COUNTER 0x10 #define APCI3120_FC_TIMER 0x1000 #define APCI3120_TIMER2_SELECT_EOS 0xc0 @@ -564,7 +562,7 @@ static int apci3120_cyclic_ai(int mode, apci3120_clr_timer2_interrupt(dev); /* enable timer counter and disable watch dog */ - devpriv->mode |= APCI3120_ENABLE_TIMER_COUNTER; + devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER; /* select EOS clock input for timer 2 */ devpriv->mode |= APCI3120_TIMER2_SELECT_EOS; /* Enable timer2 interrupt */ @@ -1081,9 +1079,9 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, apci3120_timer_enable(dev, 2, false); - /* Disable TIMER Interrupt */ + /* disable timer 2 interrupt and reset operation mode (timer) */ devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA & - ~APCI3120_ENABLE_TIMER_COUNTER; + ~APCI3120_MODE_TIMER2_AS_MASK; /* Disable Eoc and Eos Interrupts */ devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA & @@ -1156,10 +1154,11 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ /* Enable Timer */ devpriv->mode &= 0x0b; + devpriv->mode |= APCI3120_MODE_TIMER2_AS_TIMER; } else { /* start watch dog */ /* Enable WatchDog */ devpriv->mode &= 0x0b; - devpriv->mode |= APCI3120_ENABLE_WATCHDOG; + devpriv->mode |= APCI3120_MODE_TIMER2_AS_WDOG; } /* enable disable interrupt */ @@ -1179,15 +1178,9 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, break; case APCI3120_STOP: - if (devpriv->b_Timer2Mode == APCI3120_TIMER) { - /* Disable timer */ - devpriv->mode &= ~APCI3120_ENABLE_TIMER_COUNTER; - } else { - /* Disable WatchDog */ - devpriv->mode &= ~APCI3120_ENABLE_WATCHDOG; - } - /* Disable timer interrupt */ - devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; + /* disable timer 2 interrupt and reset operation mode (timer) */ + devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA & + ~APCI3120_MODE_TIMER2_AS_MASK; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); apci3120_timer_enable(dev, 2, false); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 603bebb7e059..ed51f41cd761 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -40,6 +40,10 @@ #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) +#define APCI3120_MODE_TIMER2_AS_TIMER (0 << 4) +#define APCI3120_MODE_TIMER2_AS_COUNTER (1 << 4) +#define APCI3120_MODE_TIMER2_AS_WDOG (2 << 4) +#define APCI3120_MODE_TIMER2_AS_MASK (3 << 4) /* sets AS_TIMER */ #define APCI3120_MODE_SCAN_ENA (1 << 3) #define APCI3120_MODE_TIMER2_IRQ_ENA (1 << 2) #define APCI3120_MODE_EOS_IRQ_ENA (1 << 1) -- cgit v1.2.3-59-g8ed1b From bd8e69e2b7bc51d5b5c97d3940ea42b3f816fb6b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:26 -0700 Subject: staging: comedi: addi_apci_3120: define the timer 2 clock select bits For aesthetics, redefine the bits in the mode register used to select the clock for timer 2. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ++++------- drivers/staging/comedi/drivers/addi_apci_3120.c | 5 +++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 87c82e4b76f5..c0ae6d31d0c9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -103,7 +103,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_STATUS 0x02 #define APCI3120_FC_TIMER 0x1000 -#define APCI3120_TIMER2_SELECT_EOS 0xc0 #define APCI3120_COUNTER 3 static int apci3120_ai_insn_config(struct comedi_device *dev, @@ -561,14 +560,12 @@ static int apci3120_cyclic_ai(int mode, apci3120_clr_timer2_interrupt(dev); - /* enable timer counter and disable watch dog */ - devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER; - /* select EOS clock input for timer 2 */ - devpriv->mode |= APCI3120_TIMER2_SELECT_EOS; - /* Enable timer2 interrupt */ - devpriv->mode |= APCI3120_MODE_TIMER2_IRQ_ENA; + devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER | + APCI3120_MODE_TIMER2_CLK_EOS | + APCI3120_MODE_TIMER2_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = APCI3120_ENABLE; } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ed51f41cd761..10155e6b322f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -40,6 +40,11 @@ #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) +#define APCI3120_MODE_TIMER2_CLK_OSC (0 << 6) +#define APCI3120_MODE_TIMER2_CLK_OUT1 (1 << 6) +#define APCI3120_MODE_TIMER2_CLK_EOC (2 << 6) +#define APCI3120_MODE_TIMER2_CLK_EOS (3 << 6) +#define APCI3120_MODE_TIMER2_CLK_MASK (3 << 6) #define APCI3120_MODE_TIMER2_AS_TIMER (0 << 4) #define APCI3120_MODE_TIMER2_AS_COUNTER (1 << 4) #define APCI3120_MODE_TIMER2_AS_WDOG (2 << 4) -- cgit v1.2.3-59-g8ed1b From aae8f725aac45e01b4708c89a462312f684ae1f4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:27 -0700 Subject: staging: comedi: addi_apci_3120: rename APCI3120_WRITE_MODE_SELECT For aesthetics, rename this define used for the mode register offset. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 42 +++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c0ae6d31d0c9..0e76b656035d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -98,7 +98,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_WATCHDOG 2 #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 -#define APCI3120_WRITE_MODE_SELECT 0x0e #define APCI3120_RD_STATUS 0x02 #define APCI3120_FC_TIMER 0x1000 @@ -240,8 +239,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + 0); } - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); apci3120_timer_enable(dev, 0, true); @@ -285,8 +283,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Set the scan bit */ devpriv->mode |= APCI3120_MODE_SCAN_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* If Interrupt function is loaded */ if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { @@ -294,8 +291,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, inw(dev->iobase + 0); } - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); inw(dev->iobase + APCI3120_RD_STATUS); @@ -351,7 +347,7 @@ static int apci3120_reset(struct comedi_device *dev) /* Disable all interrupts, watchdog for the anolog output */ devpriv->mode = 0; - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* disable all counters, ext trigger, and reset scan */ devpriv->ctrl = 0; @@ -386,7 +382,7 @@ static int apci3120_cancel(struct comedi_device *dev, /* DISABLE_ALL_INTERRUPT */ devpriv->mode = 0; - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_RD_STATUS); @@ -538,7 +534,7 @@ static int apci3120_cyclic_ai(int mode, } - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* If DMA is disabled */ if (devpriv->us_UseDma == APCI3120_DISABLE) { @@ -547,7 +543,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_EocEosInterrupt = APCI3120_ENABLE; devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); if (cmd->stop_src == TRIG_COUNT) { /* configure Timer2 For counting EOS */ @@ -563,8 +559,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER | APCI3120_MODE_TIMER2_CLK_EOS | APCI3120_MODE_TIMER2_IRQ_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = APCI3120_ENABLE; @@ -954,8 +949,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } else { /* Disable EOC Interrupt */ devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); } } @@ -969,7 +963,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) apci3120_interrupt_handle_eos(dev); devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + dev->iobase + APCI3120_MODE_REG); } else { ui_Check = 0; for (i = 0; i < devpriv->ui_AiNbrofChannels; @@ -987,8 +981,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } else { devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */ devpriv->b_InterruptMode = APCI3120_EOC_MODE; } @@ -1000,8 +993,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); s->async->events |= COMEDI_CB_EOA; break; @@ -1019,11 +1011,9 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) break; default: - /* disable Timer Interrupt */ devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); } apci3120_clr_timer2_interrupt(dev); @@ -1083,7 +1073,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, /* Disable Eoc and Eos Interrupts */ devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA & ~APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ @@ -1167,7 +1157,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, } else { devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; } - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* start timer */ if (devpriv->b_Timer2Mode == APCI3120_TIMER) @@ -1178,7 +1168,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, /* disable timer 2 interrupt and reset operation mode (timer) */ devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA & ~APCI3120_MODE_TIMER2_AS_MASK; - outb(devpriv->mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); apci3120_timer_enable(dev, 2, false); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 10155e6b322f..0f3dabfabfc8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -40,6 +40,7 @@ #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0) +#define APCI3120_MODE_REG 0x0e #define APCI3120_MODE_TIMER2_CLK_OSC (0 << 6) #define APCI3120_MODE_TIMER2_CLK_OUT1 (1 << 6) #define APCI3120_MODE_TIMER2_CLK_EOC (2 << 6) -- cgit v1.2.3-59-g8ed1b From 34c0ae09a69173a5f831ad66cb2edf1fdb42205a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:28 -0700 Subject: staging: comedi: addi_apci_3120: remove scanning from ai (*insn_read) (*insn_read) functions are supposed to do simple polled reads of a single channel. This driver tries to be tricky and allow passing a chanlist in the analog input (*insn_config) to allow the (*insn_read) to do chanlist scanning with or without interrupts. The (*insn_config) doesn't follow the comedi API and this operation mode is not part of the API. Remove the scanning support from the (*insn_read) as well as the support code in the (*insn_config) and interrupt handler. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 113 ++------------------- 1 file changed, 7 insertions(+), 106 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 0e76b656035d..2656e53999f8 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -110,43 +110,18 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned int i; - if ((data[0] != APCI3120_EOC_MODE) && (data[0] != APCI3120_EOS_MODE)) + if (data[0] != APCI3120_EOC_MODE) return -1; /* Check for Conversion time to be added */ devpriv->ui_EocEosConversionTime = data[2]; - if (data[0] == APCI3120_EOS_MODE) { - - /* Test the number of the channel */ - for (i = 0; i < data[3]; i++) { - - if (CR_CHAN(data[4 + i]) >= s->n_chan) { - dev_err(dev->class_dev, "bad channel list\n"); - return -2; - } - } - - devpriv->b_InterruptMode = APCI3120_EOS_MODE; - - if (data[1]) - devpriv->b_EocEosInterrupt = APCI3120_ENABLE; - else - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - /* Copy channel list and Range List to devpriv */ - devpriv->ui_AiNbrofChannels = data[3]; - for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) - devpriv->ui_AiChannelList[i] = data[4 + i]; - - } else { /* EOC */ - devpriv->b_InterruptMode = APCI3120_EOC_MODE; - if (data[1]) - devpriv->b_EocEosInterrupt = APCI3120_ENABLE; - else - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - } + devpriv->b_InterruptMode = APCI3120_EOC_MODE; + if (data[1]) + devpriv->b_EocEosInterrupt = APCI3120_ENABLE; + else + devpriv->b_EocEosInterrupt = APCI3120_DISABLE; return insn->n; } @@ -186,11 +161,6 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, return 1; /* we can serve this with scan logic */ } -/* - * Reads analog input in synchronous mode EOC and EOS is selected - * as per configured if no conversion time is set uses default - * conversion time 10 microsec. - */ static int apci3120_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -266,60 +236,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, } break; - - case APCI3120_EOS_MODE: - apci3120_ai_reset_fifo(dev); - - if (!apci3120_setup_chan_list(dev, s, - devpriv->ui_AiNbrofChannels, - devpriv->ui_AiChannelList)) - return -EINVAL; - - /* Initialize Timer 0 mode 2 */ - apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); - - /* Set the conversion time */ - apci3120_timer_write(dev, 0, divisor); - - /* Set the scan bit */ - devpriv->mode |= APCI3120_MODE_SCAN_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - /* If Interrupt function is loaded */ - if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - inw(dev->iobase + 0); - } - - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - inw(dev->iobase + APCI3120_RD_STATUS); - - apci3120_timer_enable(dev, 0, true); - - /* Start conversion */ - outw(0, dev->iobase + APCI3120_START_CONVERSION); - - /* Waiting of end of conversion if interrupt is not installed */ - if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) { - /* Waiting the end of conversion */ - do { - us_TmpValue = inw(dev->iobase + - APCI3120_RD_STATUS); - } while ((us_TmpValue & APCI3120_EOS) != - APCI3120_EOS); - - for (i = 0; i < devpriv->ui_AiNbrofChannels; - i++) { - /* Read the result in FIFO and write them in shared memory */ - us_TmpValue = inw(dev->iobase); - data[i] = (unsigned int) us_TmpValue; - } - - devpriv->b_InterruptMode = APCI3120_EOC_MODE; /* Restore defaults */ - } - break; - default: dev_err(dev->class_dev, "inputs wrong\n"); @@ -908,8 +824,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; unsigned short int_daq; - unsigned int int_amcc, ui_Check, i; - unsigned short us_TmpValue; + unsigned int int_amcc, ui_Check; ui_Check = 1; @@ -964,21 +879,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - } else { - ui_Check = 0; - for (i = 0; i < devpriv->ui_AiNbrofChannels; - i++) { - us_TmpValue = inw(dev->iobase + 0); - devpriv->ui_AiReadData[i] = - (unsigned int) us_TmpValue; - } - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - devpriv->b_InterruptMode = APCI3120_EOC_MODE; - - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } - } else { devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); -- cgit v1.2.3-59-g8ed1b From 46ad4793a7c8ae2c347f86427a82c1f04bc80fc6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:29 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'ui_EocEosConversionTime' This driver tries to be tricky and allow passing an analog input conversion time for the (*insn_read) in the (*insn_config). The (*insn_config) doesn't follow the comedi API and this programmable conversion time is not part of the API for (*insn_read) operations. Remove the member from the private data and use a fixed 10us (10000ns) conversion time in the (*insn_read). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 10 +--------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 2656e53999f8..9b18abf13b24 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -114,9 +114,6 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, if (data[0] != APCI3120_EOC_MODE) return -1; - /* Check for Conversion time to be added */ - devpriv->ui_EocEosConversionTime = data[2]; - devpriv->b_InterruptMode = APCI3120_EOC_MODE; if (data[1]) devpriv->b_EocEosInterrupt = APCI3120_ENABLE; @@ -172,10 +169,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, unsigned short us_TmpValue, i; /* fix conversion time to 10 us */ - if (!devpriv->ui_EocEosConversionTime) - ns = 10000; - else - ns = devpriv->ui_EocEosConversionTime; + ns = 10000; /* Clear software registers */ devpriv->timer_mode = 0; @@ -240,7 +234,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, dev_err(dev->class_dev, "inputs wrong\n"); } - devpriv->ui_EocEosConversionTime = 0; /* re initializing the variable */ } return insn->n; @@ -254,7 +247,6 @@ static int apci3120_reset(struct comedi_device *dev) devpriv->ai_running = 0; devpriv->b_EocEosInterrupt = APCI3120_DISABLE; devpriv->b_InterruptMode = APCI3120_EOC_MODE; - devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */ /* variables used in timer subdevice */ devpriv->b_Timer2Mode = 0; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 0f3dabfabfc8..13c06cd18456 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -129,7 +129,6 @@ struct apci3120_private { unsigned int ai_running:1; unsigned char b_InterruptMode; unsigned char b_EocEosInterrupt; - unsigned int ui_EocEosConversionTime; unsigned char b_ExttrigEnable; struct task_struct *tsk_Current; }; -- cgit v1.2.3-59-g8ed1b From 7ee779a237ab12b76264e11819af19b03f9c96c4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:30 -0700 Subject: staging: comedi: addi_apci_3120: remove interrupt support from ai (*insn_read) (*insn_read) functions are supposed to do simple polled reads of a single channel. This driver tries to be tricky and allow enabling interrupts in the analog input (*insn_config) to allow the (*insn_read) to read samples with the end-of-conversion interrupt. The (*insn_config) doesn't follow the comedi API and this operation mode is not part of the API. Remove the interrupt support from the (*insn_read) as well as the support code in the (*insn_config) and interrupt handler. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 74 +++++----------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 17 insertions(+), 58 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 9b18abf13b24..40ff942f1f08 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -115,10 +115,6 @@ static int apci3120_ai_insn_config(struct comedi_device *dev, return -1; devpriv->b_InterruptMode = APCI3120_EOC_MODE; - if (data[1]) - devpriv->b_EocEosInterrupt = APCI3120_ENABLE; - else - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; return insn->n; } @@ -198,11 +194,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* Initialize Timer 0 mode 4 */ apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); - if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - devpriv->mode |= APCI3120_MODE_EOC_IRQ_ENA; - inw(dev->iobase + 0); - } - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); apci3120_timer_enable(dev, 0, true); @@ -213,22 +204,17 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); - if (devpriv->b_EocEosInterrupt == APCI3120_DISABLE) { - - do { - /* Waiting for the end of conversion */ - us_TmpValue = inw(dev->iobase + - APCI3120_RD_STATUS); - } while ((us_TmpValue & APCI3120_EOC) == - APCI3120_EOC); - - /* Read the result in FIFO and put it in insn data pointer */ - us_TmpValue = inw(dev->iobase + 0); - *data = us_TmpValue; + do { + /* Waiting for the end of conversion */ + us_TmpValue = inw(dev->iobase + + APCI3120_RD_STATUS); + } while ((us_TmpValue & APCI3120_EOC) == APCI3120_EOC); - apci3120_ai_reset_fifo(dev); - } + /* Read the result in FIFO and put it in insn data pointer */ + us_TmpValue = inw(dev->iobase + 0); + *data = us_TmpValue; + apci3120_ai_reset_fifo(dev); break; default: dev_err(dev->class_dev, "inputs wrong\n"); @@ -245,7 +231,6 @@ static int apci3120_reset(struct comedi_device *dev) struct apci3120_private *devpriv = dev->private; devpriv->ai_running = 0; - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; devpriv->b_InterruptMode = APCI3120_EOC_MODE; /* variables used in timer subdevice */ @@ -298,7 +283,6 @@ static int apci3120_cancel(struct comedi_device *dev, devpriv->ai_running = 0; devpriv->b_InterruptMode = APCI3120_EOC_MODE; - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; return 0; } @@ -448,7 +432,6 @@ static int apci3120_cyclic_ai(int mode, if (devpriv->us_UseDma == APCI3120_DISABLE) { /* disable EOC and enable EOS */ devpriv->b_InterruptMode = APCI3120_EOS_MODE; - devpriv->b_EocEosInterrupt = APCI3120_ENABLE; devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); @@ -816,9 +799,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; unsigned short int_daq; - unsigned int int_amcc, ui_Check; - - ui_Check = 1; + unsigned int int_amcc; int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; /* get IRQ reasons */ int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); @@ -845,41 +826,20 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n"); /* Ckeck if EOC interrupt */ - if (((int_daq & 0x8) == 0) - && (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) { - if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { - - /* Read the AI Value */ - devpriv->ui_AiReadData[0] = inw(dev->iobase + 0); - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; - send_sig(SIGIO, devpriv->tsk_Current, 0); /* send signal to the sample */ - } else { - /* Disable EOC Interrupt */ - devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - } + if (((int_daq & 0x8) == 0) && + (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) { + /* nothing to do... EOC mode is not currently used */ } /* Check If EOS interrupt */ if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) { - - if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* enable this in without DMA ??? */ - - if (devpriv->ai_running) { - ui_Check = 0; - apci3120_interrupt_handle_eos(dev); - devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, - dev->iobase + APCI3120_MODE_REG); - } - } else { - devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; + if (devpriv->ai_running) { + apci3120_interrupt_handle_eos(dev); + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - devpriv->b_EocEosInterrupt = APCI3120_DISABLE; /* Default settings */ - devpriv->b_InterruptMode = APCI3120_EOC_MODE; } - } + /* Timer2 interrupt */ if (int_daq & 0x1) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 13c06cd18456..e7564ad8e140 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -128,7 +128,6 @@ struct apci3120_private { unsigned char b_Timer2Interrupt; unsigned int ai_running:1; unsigned char b_InterruptMode; - unsigned char b_EocEosInterrupt; unsigned char b_ExttrigEnable; struct task_struct *tsk_Current; }; -- cgit v1.2.3-59-g8ed1b From e614d1710803e47549d2189927c3b25de856cfb2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:31 -0700 Subject: staging: comedi: addi_apci_3120: remove apci3120_ai_insn_config() This function does not follow the comedi API for (*insn_config) functions. It's also no long needed. Just remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 15 --------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 40ff942f1f08..5d15acacc259 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -104,21 +104,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_COUNTER 3 -static int apci3120_ai_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3120_private *devpriv = dev->private; - - if (data[0] != APCI3120_EOC_MODE) - return -1; - - devpriv->b_InterruptMode = APCI3120_EOC_MODE; - - return insn->n; -} - static int apci3120_setup_chan_list(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e7564ad8e140..572d545e7492 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -381,7 +381,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->n_chan = 16; s->maxdata = this_board->ai_is_16bit ? 0xffff : 0x0fff; s->range_table = &apci3120_ai_range; - s->insn_config = apci3120_ai_insn_config; s->insn_read = apci3120_ai_insn_read; if (0 /* dev->irq */) { dev->read_subdev = s; -- cgit v1.2.3-59-g8ed1b From 22f75dac46e0691ef03e44d27d21d2b860cc15fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:32 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'ui_AiReadData' This member of the private data was used to return analog input samples that were acquired for the (*insn_read) using interrupts. The interrupt support code for the (*insn_read) has been removed. Remove this unused member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +--- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 5d15acacc259..51cdecb211d6 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -147,7 +147,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, struct apci3120_private *devpriv = dev->private; unsigned int divisor; unsigned int ns; - unsigned short us_TmpValue, i; + unsigned short us_TmpValue; /* fix conversion time to 10 us */ ns = 10000; @@ -157,8 +157,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, devpriv->mode = 0; if (insn->unused[0] == 222) { /* second insn read */ - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ui_AiReadData[i]; } else { devpriv->tsk_Current = current; /* Save the current process task structure */ diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 572d545e7492..dc05b2f616ca 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -115,7 +115,6 @@ struct apci3120_private { unsigned int osc_base; unsigned int ui_AiNbrofChannels; unsigned int ui_AiChannelList[32]; - unsigned int ui_AiReadData[32]; unsigned short us_UseDma; unsigned char b_DmaDoubleBuffer; unsigned int ui_DmaActualBuffer; -- cgit v1.2.3-59-g8ed1b From 89e9057b50369474c1e701faccdeedf08566ec57 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:33 -0700 Subject: staging: comedi: addi_apci_3120: fix apci3120_ai_insn_read() Now that the scanning and interrupt support have been removed from this function it can be refactored to work correctly. The comedi core expects (*insn_read) functions to read insn->n values from the hardware and return the number of samples read. This function currently just reads one sample but it returns insn->n. Fix this function to work like the core expects. Use comedi_timeout() to prevent a possible deadlock in the loop that waits for the end-of-conversion. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 90 ++++++++++------------ 1 file changed, 40 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 51cdecb211d6..5fb884835643 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -139,6 +139,19 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, return 1; /* we can serve this with scan logic */ } +static int apci3120_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + APCI3120_RD_STATUS); + if ((status & APCI3120_EOC) == 0) + return 0; + return -EBUSY; +} + static int apci3120_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -146,67 +159,44 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, { struct apci3120_private *devpriv = dev->private; unsigned int divisor; - unsigned int ns; - unsigned short us_TmpValue; - - /* fix conversion time to 10 us */ - ns = 10000; - - /* Clear software registers */ - devpriv->timer_mode = 0; - devpriv->mode = 0; - - if (insn->unused[0] == 222) { /* second insn read */ - } else { - devpriv->tsk_Current = current; /* Save the current process task structure */ - - divisor = apci3120_ns_to_timer(dev, 0, ns, CMDF_ROUND_NEAREST); - - us_TmpValue = (unsigned short) devpriv->b_InterruptMode; - - switch (us_TmpValue) { - - case APCI3120_EOC_MODE: - apci3120_ai_reset_fifo(dev); - - /* Initialize the sequence array */ - if (!apci3120_setup_chan_list(dev, s, 1, - &insn->chanspec)) - return -EINVAL; - - /* Initialize Timer 0 mode 4 */ - apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); + int ret; + int i; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + /* set mode for A/D conversions by software trigger with timer 0 */ + devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | + APCI3120_MODE_TIMER2_AS_TIMER; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - apci3120_timer_enable(dev, 0, true); + /* load chanlist for single channel scan */ + if (!apci3120_setup_chan_list(dev, s, 1, &insn->chanspec)) + return -EINVAL; - /* Set the conversion time */ - apci3120_timer_write(dev, 0, divisor); + /* + * Timer 0 is used in MODE4 (software triggered strobe) to set the + * conversion time for each acquisition. Each conversion is triggered + * when the divisor is written to the timer, The conversion is done + * when the EOC bit in the status register is '0'. + */ + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); + apci3120_timer_enable(dev, 0, true); - us_TmpValue = - (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); + /* fixed conversion time of 10 us */ + divisor = apci3120_ns_to_timer(dev, 0, 10000, CMDF_ROUND_NEAREST); - do { - /* Waiting for the end of conversion */ - us_TmpValue = inw(dev->iobase + - APCI3120_RD_STATUS); - } while ((us_TmpValue & APCI3120_EOC) == APCI3120_EOC); + apci3120_ai_reset_fifo(dev); - /* Read the result in FIFO and put it in insn data pointer */ - us_TmpValue = inw(dev->iobase + 0); - *data = us_TmpValue; + for (i = 0; i < insn->n; i++) { + /* trigger conversion */ + apci3120_timer_write(dev, 0, divisor); - apci3120_ai_reset_fifo(dev); - break; - default: - dev_err(dev->class_dev, "inputs wrong\n"); + ret = comedi_timeout(dev, s, insn, apci3120_ai_eoc, 0); + if (ret) + return ret; - } + data[i] = inw(dev->iobase + 0); } return insn->n; - } static int apci3120_reset(struct comedi_device *dev) -- cgit v1.2.3-59-g8ed1b From bb201b94cc251584bb69ed9e1f002d886f66fd4b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:34 -0700 Subject: staging: comedi: addi_apci_3120: absorb apci3120_interrupt_handle_eos() Absorb this simple function into apci3120_interrupt(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 28 +++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 5fb884835643..1913fd2f29dd 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -747,25 +747,6 @@ static void apci3120_interrupt_dma(int irq, void *d) } } -/* - * This function handles EOS interrupt. - * This function copies the acquired data(from FIFO) to Comedi buffer. - */ -static int apci3120_interrupt_handle_eos(struct comedi_device *dev) -{ - struct apci3120_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - unsigned short val; - int i; - - for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { - val = inw(dev->iobase + 0); - comedi_buf_write_samples(s, &val, 1); - } - - return 0; -} - static irqreturn_t apci3120_interrupt(int irq, void *d) { struct comedi_device *dev = d; @@ -807,7 +788,14 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) /* Check If EOS interrupt */ if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) { if (devpriv->ai_running) { - apci3120_interrupt_handle_eos(dev); + unsigned short val; + int i; + + for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { + val = inw(dev->iobase + 0); + comedi_buf_write_samples(s, &val, 1); + } + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); } -- cgit v1.2.3-59-g8ed1b From 2e8fcfdd057db84979d9c11cad94bb7e3a5d6af7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:35 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'ui_AiNbrofChannels' This member of the private data is always the cmd->chanlist_len. Use that instead and remove the member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 8 +++----- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 1913fd2f29dd..004142efd2e6 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -361,7 +361,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->ui_DmaActualBuffer = 0; /* Initializes the sequence array */ - if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, + if (!apci3120_setup_chan_list(dev, s, cmd->chanlist_len, cmd->chanlist)) return -EINVAL; @@ -605,9 +605,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - /* loading private structure with cmd structure inputs */ - devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - if (cmd->start_src == TRIG_EXT) devpriv->b_ExttrigEnable = APCI3120_ENABLE; else @@ -752,6 +749,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) struct comedi_device *dev = d; struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; unsigned short int_daq; unsigned int int_amcc; @@ -791,7 +789,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) unsigned short val; int i; - for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { + for (i = 0; i < cmd->chanlist_len; i++) { val = inw(dev->iobase + 0); comedi_buf_write_samples(s, &val, 1); } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index dc05b2f616ca..2eb7ab5da7d7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -113,7 +113,6 @@ struct apci3120_private { unsigned long amcc; unsigned long addon; unsigned int osc_base; - unsigned int ui_AiNbrofChannels; unsigned int ui_AiChannelList[32]; unsigned short us_UseDma; unsigned char b_DmaDoubleBuffer; -- cgit v1.2.3-59-g8ed1b From 08595f9da2f65530d1d9d383760dd2864a0208c1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:36 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'ui_AiChannelList' This member of the private data is no longer used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 2eb7ab5da7d7..9ff6580486e7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -113,7 +113,6 @@ struct apci3120_private { unsigned long amcc; unsigned long addon; unsigned int osc_base; - unsigned int ui_AiChannelList[32]; unsigned short us_UseDma; unsigned char b_DmaDoubleBuffer; unsigned int ui_DmaActualBuffer; -- cgit v1.2.3-59-g8ed1b From b0a0d0bc58d6e2f052350e3fe5b6c6bed6fad67b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:37 -0700 Subject: staging: comedi: addi_apci_3120: rename APCI3120_RD_STATUS For aesthetics, rename this define used for the status register offset. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 17 +++++++---------- drivers/staging/comedi/drivers/addi_apci_3120.c | 3 ++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 004142efd2e6..5deb1ff921da 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -81,7 +81,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_EOS_MODE 2 #define APCI3120_DMA_MODE 3 -#define APCI3120_RD_STATUS 0x02 #define APCI3120_RD_FIFO 0x00 /* status register bits */ @@ -99,7 +98,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 -#define APCI3120_RD_STATUS 0x02 #define APCI3120_FC_TIMER 0x1000 #define APCI3120_COUNTER 3 @@ -146,7 +144,7 @@ static int apci3120_ai_eoc(struct comedi_device *dev, { unsigned int status; - status = inw(dev->iobase + APCI3120_RD_STATUS); + status = inw(dev->iobase + APCI3120_STATUS_REG); if ((status & APCI3120_EOC) == 0) return 0; return -EBUSY; @@ -220,7 +218,7 @@ static int apci3120_reset(struct comedi_device *dev) outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); apci3120_ai_reset_fifo(dev); - inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */ + inw(dev->iobase + APCI3120_STATUS_REG); return 0; } @@ -251,7 +249,7 @@ static int apci3120_cancel(struct comedi_device *dev, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); apci3120_ai_reset_fifo(dev); - inw(dev->iobase + APCI3120_RD_STATUS); + inw(dev->iobase + APCI3120_STATUS_REG); devpriv->ui_DmaActualBuffer = 0; devpriv->ai_running = 0; @@ -753,7 +751,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) unsigned short int_daq; unsigned int int_amcc; - int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000; /* get IRQ reasons */ + int_daq = inw(dev->iobase + APCI3120_STATUS_REG) & 0xf000; int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) { @@ -1030,8 +1028,7 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, if (devpriv->b_Timer2Mode == APCI3120_TIMER) { data[0] = apci3120_timer_read(dev, 2); } else { /* Read watch dog status */ - - us_StatusValue = inw(dev->iobase + APCI3120_RD_STATUS); + us_StatusValue = inw(dev->iobase + APCI3120_STATUS_REG); us_StatusValue = ((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1; if (us_StatusValue == 1) @@ -1049,7 +1046,7 @@ static int apci3120_di_insn_bits(struct comedi_device *dev, unsigned int val; /* the input channels are bits 11:8 of the status reg */ - val = inw(dev->iobase + APCI3120_RD_STATUS); + val = inw(dev->iobase + APCI3120_STATUS_REG); data[1] = (val >> 8) & 0xf; return insn->n; @@ -1080,7 +1077,7 @@ static int apci3120_ao_ready(struct comedi_device *dev, { unsigned int status; - status = inw(dev->iobase + APCI3120_RD_STATUS); + status = inw(dev->iobase + APCI3120_STATUS_REG); if (status & 0x0001) /* waiting for DA_READY */ return 0; return -EBUSY; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 9ff6580486e7..d47b2e0f624b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -20,6 +20,7 @@ #define APCI3120_CTRL_GATE(x) (1 << (12 + (x))) #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) +#define APCI3120_STATUS_REG 0x02 #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) #define APCI3120_TIMER_REG 0x04 #define APCI3120_CHANLIST_REG 0x06 @@ -360,7 +361,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, } } - status = inw(dev->iobase + APCI3120_RD_STATUS); + status = inw(dev->iobase + APCI3120_STATUS_REG); if (APCI3120_STATUS_TO_VERSION(status) == APCI3120_REVB || context == BOARD_APCI3001) devpriv->osc_base = APCI3120_REVB_OSC_BASE; -- cgit v1.2.3-59-g8ed1b From 3da982374a85455bc16003c95827871d11d5fca1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:38 -0700 Subject: staging: comedi: addi_apci_3120: define status register bits Define the bits in the status register and use them to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 58 ++++++++++------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 9 ++++ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 5deb1ff921da..83881a61dbe0 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -83,10 +83,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_RD_FIFO 0x00 -/* status register bits */ -#define APCI3120_EOC 0x8000 -#define APCI3120_EOS 0x2000 - /* software trigger dummy register */ #define APCI3120_START_CONVERSION 0x02 @@ -98,8 +94,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_ENABLE 1 -#define APCI3120_FC_TIMER 0x1000 - #define APCI3120_COUNTER 3 static int apci3120_setup_chan_list(struct comedi_device *dev, @@ -145,7 +139,7 @@ static int apci3120_ai_eoc(struct comedi_device *dev, unsigned int status; status = inw(dev->iobase + APCI3120_STATUS_REG); - if ((status & APCI3120_EOC) == 0) + if ((status & APCI3120_STATUS_EOC_INT) == 0) return 0; return -EBUSY; } @@ -748,21 +742,20 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; - unsigned short int_daq; + unsigned int status; unsigned int int_amcc; - int_daq = inw(dev->iobase + APCI3120_STATUS_REG) & 0xf000; + status = inw(dev->iobase + APCI3120_STATUS_REG); int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); - if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) { + if (!(status & APCI3120_STATUS_INT_MASK) && + !(int_amcc & ANY_S593X_INT)) { dev_err(dev->class_dev, "IRQ from unknown source\n"); return IRQ_NONE; } outl(int_amcc | 0x00ff0000, devpriv->amcc + AMCC_OP_REG_INTCSR); - int_daq = (int_daq >> 12) & 0xF; - if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { apci3120_exttrig_enable(dev, false); devpriv->b_ExttrigEnable = APCI3120_DISABLE; @@ -775,14 +768,13 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (int_amcc & TARGET_ABORT_INT) dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n"); - /* Ckeck if EOC interrupt */ - if (((int_daq & 0x8) == 0) && - (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) { + if ((status & APCI3120_STATUS_EOC_INT) == 0 && + devpriv->b_InterruptMode == APCI3120_EOC_MODE) { /* nothing to do... EOC mode is not currently used */ } - /* Check If EOS interrupt */ - if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) { + if ((status & APCI3120_STATUS_EOS_INT) && + devpriv->b_InterruptMode == APCI3120_EOS_MODE) { if (devpriv->ai_running) { unsigned short val; int i; @@ -797,9 +789,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } } - /* Timer2 interrupt */ - if (int_daq & 0x1) { - + if (status & APCI3120_STATUS_TIMER2_INT) { switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; @@ -829,7 +819,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) apci3120_clr_timer2_interrupt(dev); } - if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) { + if ((status & APCI3120_STATUS_AMCC_INT) && + devpriv->b_InterruptMode == APCI3120_DMA_MODE) { if (devpriv->ai_running) { /* Clear Timer Write TC int */ @@ -1019,7 +1010,7 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, unsigned int *data) { struct apci3120_private *devpriv = dev->private; - unsigned short us_StatusValue; + unsigned int status; if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { @@ -1027,13 +1018,15 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, } if (devpriv->b_Timer2Mode == APCI3120_TIMER) { data[0] = apci3120_timer_read(dev, 2); - } else { /* Read watch dog status */ - us_StatusValue = inw(dev->iobase + APCI3120_STATUS_REG); - us_StatusValue = - ((us_StatusValue & APCI3120_FC_TIMER) >> 12) & 1; - if (us_StatusValue == 1) + } else { + /* Read watch dog status */ + status = inw(dev->iobase + APCI3120_STATUS_REG); + if (status & APCI3120_STATUS_TIMER2_INT) { apci3120_clr_timer2_interrupt(dev); - data[0] = us_StatusValue; /* when data[0] = 1 then the watch dog has rundown */ + data[0] = 1; + } else { + data[0] = 0; + } } return insn->n; } @@ -1043,11 +1036,10 @@ static int apci3120_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int val; + unsigned int status; - /* the input channels are bits 11:8 of the status reg */ - val = inw(dev->iobase + APCI3120_STATUS_REG); - data[1] = (val >> 8) & 0xf; + status = inw(dev->iobase + APCI3120_STATUS_REG); + data[1] = APCI3120_STATUS_TO_DI_BITS(status); return insn->n; } @@ -1078,7 +1070,7 @@ static int apci3120_ao_ready(struct comedi_device *dev, unsigned int status; status = inw(dev->iobase + APCI3120_STATUS_REG); - if (status & 0x0001) /* waiting for DA_READY */ + if (status & APCI3120_STATUS_DA_READY) return 0; return -EBUSY; } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index d47b2e0f624b..c18ee1750237 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -21,7 +21,16 @@ #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) #define APCI3120_STATUS_REG 0x02 +#define APCI3120_STATUS_EOC_INT (1 << 15) +#define APCI3120_STATUS_AMCC_INT (1 << 14) +#define APCI3120_STATUS_EOS_INT (1 << 13) +#define APCI3120_STATUS_TIMER2_INT (1 << 12) +#define APCI3120_STATUS_INT_MASK (0xf << 12) +#define APCI3120_STATUS_TO_DI_BITS(x) (((x) >> 8) & 0xf) #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) +#define APCI3120_STATUS_FIFO_FULL (1 << 2) +#define APCI3120_STATUS_FIFO_EMPTY (1 << 1) +#define APCI3120_STATUS_DA_READY (1 << 0) #define APCI3120_TIMER_REG 0x04 #define APCI3120_CHANLIST_REG 0x06 #define APCI3120_CHANLIST_INDEX(x) (((x) & 0xf) << 8) -- cgit v1.2.3-59-g8ed1b From 196540ee440d054313040925e3ed9daf39b9ec19 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:39 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'ai_running' This member of the private data was used to determine if the interrupt routine was handling data for the (*insn_read) or an async command. Now that the (*insn_read) does not use interrupts this member is not needed. Remove the member and refactor the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 41 ++++++++-------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 83881a61dbe0..7bd17c28ebae 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -195,7 +195,6 @@ static int apci3120_reset(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - devpriv->ai_running = 0; devpriv->b_InterruptMode = APCI3120_EOC_MODE; /* variables used in timer subdevice */ @@ -246,7 +245,6 @@ static int apci3120_cancel(struct comedi_device *dev, inw(dev->iobase + APCI3120_STATUS_REG); devpriv->ui_DmaActualBuffer = 0; - devpriv->ai_running = 0; devpriv->b_InterruptMode = APCI3120_EOC_MODE; return 0; @@ -338,8 +336,6 @@ static int apci3120_cyclic_ai(int mode, unsigned int dmalen1 = 0; unsigned int divisor0; - devpriv->ai_running = 1; - /* clear software registers */ devpriv->timer_mode = 0; devpriv->mode = 0; @@ -775,18 +771,16 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if ((status & APCI3120_STATUS_EOS_INT) && devpriv->b_InterruptMode == APCI3120_EOS_MODE) { - if (devpriv->ai_running) { - unsigned short val; - int i; - - for (i = 0; i < cmd->chanlist_len; i++) { - val = inw(dev->iobase + 0); - comedi_buf_write_samples(s, &val, 1); - } + unsigned short val; + int i; - devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + for (i = 0; i < cmd->chanlist_len; i++) { + val = inw(dev->iobase + 0); + comedi_buf_write_samples(s, &val, 1); } + + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); } if (status & APCI3120_STATUS_TIMER2_INT) { @@ -821,21 +815,14 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if ((status & APCI3120_STATUS_AMCC_INT) && devpriv->b_InterruptMode == APCI3120_DMA_MODE) { - if (devpriv->ai_running) { + /* Clear Timer Write TC int */ + outl(APCI3120_CLEAR_WRITE_TC_INT, + devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); - /* Clear Timer Write TC int */ - outl(APCI3120_CLEAR_WRITE_TC_INT, - devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); - - apci3120_clr_timer2_interrupt(dev); - - /* do some data transfer */ - apci3120_interrupt_dma(irq, d); - } else { - apci3120_timer_enable(dev, 0, false); - apci3120_timer_enable(dev, 1, false); - } + apci3120_clr_timer2_interrupt(dev); + /* do some data transfer */ + apci3120_interrupt_dma(irq, d); } comedi_handle_events(dev, s); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index c18ee1750237..98de447d96b7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -133,7 +133,6 @@ struct apci3120_private { unsigned short ctrl; unsigned char b_Timer2Mode; unsigned char b_Timer2Interrupt; - unsigned int ai_running:1; unsigned char b_InterruptMode; unsigned char b_ExttrigEnable; struct task_struct *tsk_Current; -- cgit v1.2.3-59-g8ed1b From ae12280db7f219d961df703d5c00dff0328c1623 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:40 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_do_insn_bits() to driver source Move this function from the included hwdrv_apci31210.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 18 ------------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 7bd17c28ebae..d577d37de0bc 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1031,24 +1031,6 @@ static int apci3120_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int apci3120_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3120_private *devpriv = dev->private; - - if (comedi_dio_update_state(s, data)) { - devpriv->do_bits = s->state; - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits), - dev->iobase + APCI3120_CTR0_REG); - } - - data[1] = s->state; - - return insn->n; -} - static int apci3120_ao_ready(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 98de447d96b7..22d17e2aafbe 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -281,6 +281,24 @@ static void apci3120_ai_reset_fifo(struct comedi_device *dev) #include "addi-data/hwdrv_apci3120.c" +static int apci3120_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci3120_private *devpriv = dev->private; + + if (comedi_dio_update_state(s, data)) { + devpriv->do_bits = s->state; + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits), + dev->iobase + APCI3120_CTR0_REG); + } + + data[1] = s->state; + + return insn->n; +} + static void apci3120_dma_alloc(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; -- cgit v1.2.3-59-g8ed1b From c737b2ce4f964aed8fc7a255a73417b00d742d65 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:41 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_di_insn_bits() to driver source Move this function from the included hwdrv_apci31210.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 13 ------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index d577d37de0bc..a206d5e583d5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1018,19 +1018,6 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, return insn->n; } -static int apci3120_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int status; - - status = inw(dev->iobase + APCI3120_STATUS_REG); - data[1] = APCI3120_STATUS_TO_DI_BITS(status); - - return insn->n; -} - static int apci3120_ao_ready(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 22d17e2aafbe..7033b0bd3ddb 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -281,6 +281,19 @@ static void apci3120_ai_reset_fifo(struct comedi_device *dev) #include "addi-data/hwdrv_apci3120.c" +static int apci3120_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int status; + + status = inw(dev->iobase + APCI3120_STATUS_REG); + data[1] = APCI3120_STATUS_TO_DI_BITS(status); + + return insn->n; +} + static int apci3120_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, -- cgit v1.2.3-59-g8ed1b From 5cf5fa957946a7d25dc4ce25dba9c8a20f8b8def Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:42 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_ao_insn_write() to driver source Move this function, and its helper function, from the included hwdrv_apci31210.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 38 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 38 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a206d5e583d5..929ef0b4620c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1017,41 +1017,3 @@ static int apci3120_read_insn_timer(struct comedi_device *dev, } return insn->n; } - -static int apci3120_ao_ready(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned long context) -{ - unsigned int status; - - status = inw(dev->iobase + APCI3120_STATUS_REG); - if (status & APCI3120_STATUS_DA_READY) - return 0; - return -EBUSY; -} - -static int apci3120_ao_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) { - unsigned int val = data[i]; - int ret; - - ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0); - if (ret) - return ret; - - outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val), - dev->iobase + APCI3120_AO_REG(chan)); - - s->readback[chan] = val; - } - - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 7033b0bd3ddb..c17a8408749f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -281,6 +281,44 @@ static void apci3120_ai_reset_fifo(struct comedi_device *dev) #include "addi-data/hwdrv_apci3120.c" +static int apci3120_ao_ready(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + APCI3120_STATUS_REG); + if (status & APCI3120_STATUS_DA_READY) + return 0; + return -EBUSY; +} + +static int apci3120_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int chan = CR_CHAN(insn->chanspec); + int i; + + for (i = 0; i < insn->n; i++) { + unsigned int val = data[i]; + int ret; + + ret = comedi_timeout(dev, s, insn, apci3120_ao_ready, 0); + if (ret) + return ret; + + outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val), + dev->iobase + APCI3120_AO_REG(chan)); + + s->readback[chan] = val; + } + + return insn->n; +} + static int apci3120_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, -- cgit v1.2.3-59-g8ed1b From 6a51cfc62f523c70b000368b32cb46fa0d24f536 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:43 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_ai_insn_read() to driver source Move this function, and its helper function, from the included hwdrv_apci31210.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 60 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 60 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 929ef0b4620c..28c5792f0e90 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -131,66 +131,6 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, return 1; /* we can serve this with scan logic */ } -static int apci3120_ai_eoc(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned long context) -{ - unsigned int status; - - status = inw(dev->iobase + APCI3120_STATUS_REG); - if ((status & APCI3120_STATUS_EOC_INT) == 0) - return 0; - return -EBUSY; -} - -static int apci3120_ai_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3120_private *devpriv = dev->private; - unsigned int divisor; - int ret; - int i; - - /* set mode for A/D conversions by software trigger with timer 0 */ - devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | - APCI3120_MODE_TIMER2_AS_TIMER; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - /* load chanlist for single channel scan */ - if (!apci3120_setup_chan_list(dev, s, 1, &insn->chanspec)) - return -EINVAL; - - /* - * Timer 0 is used in MODE4 (software triggered strobe) to set the - * conversion time for each acquisition. Each conversion is triggered - * when the divisor is written to the timer, The conversion is done - * when the EOC bit in the status register is '0'. - */ - apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); - apci3120_timer_enable(dev, 0, true); - - /* fixed conversion time of 10 us */ - divisor = apci3120_ns_to_timer(dev, 0, 10000, CMDF_ROUND_NEAREST); - - apci3120_ai_reset_fifo(dev); - - for (i = 0; i < insn->n; i++) { - /* trigger conversion */ - apci3120_timer_write(dev, 0, divisor); - - ret = comedi_timeout(dev, s, insn, apci3120_ai_eoc, 0); - if (ret) - return ret; - - data[i] = inw(dev->iobase + 0); - } - - return insn->n; -} - static int apci3120_reset(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index c17a8408749f..70363faa99d6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -281,6 +281,66 @@ static void apci3120_ai_reset_fifo(struct comedi_device *dev) #include "addi-data/hwdrv_apci3120.c" +static int apci3120_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + status = inw(dev->iobase + APCI3120_STATUS_REG); + if ((status & APCI3120_STATUS_EOC_INT) == 0) + return 0; + return -EBUSY; +} + +static int apci3120_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci3120_private *devpriv = dev->private; + unsigned int divisor; + int ret; + int i; + + /* set mode for A/D conversions by software trigger with timer 0 */ + devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | + APCI3120_MODE_TIMER2_AS_TIMER; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + + /* load chanlist for single channel scan */ + if (!apci3120_setup_chan_list(dev, s, 1, &insn->chanspec)) + return -EINVAL; + + /* + * Timer 0 is used in MODE4 (software triggered strobe) to set the + * conversion time for each acquisition. Each conversion is triggered + * when the divisor is written to the timer, The conversion is done + * when the EOC bit in the status register is '0'. + */ + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE4); + apci3120_timer_enable(dev, 0, true); + + /* fixed conversion time of 10 us */ + divisor = apci3120_ns_to_timer(dev, 0, 10000, CMDF_ROUND_NEAREST); + + apci3120_ai_reset_fifo(dev); + + for (i = 0; i < insn->n; i++) { + /* trigger conversion */ + apci3120_timer_write(dev, 0, divisor); + + ret = comedi_timeout(dev, s, insn, apci3120_ai_eoc, 0); + if (ret) + return ret; + + data[i] = inw(dev->iobase + 0); + } + + return insn->n; +} + static int apci3120_ao_ready(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, -- cgit v1.2.3-59-g8ed1b From 0a3e518102b4a252dfcfe7d602d6e99e8c77d230 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:44 -0700 Subject: staging: comedi: addi_apci_3120: remove check in apci3120_setup_chan_list() The n_chan check is not needed. This value will always be >= 1. Remove the unnecessary check. For aesthetics, rename the function and change it's return type to void. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 19 +++++-------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 3 +-- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 28c5792f0e90..3c172466a3c0 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -96,19 +96,13 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_COUNTER 3 -static int apci3120_setup_chan_list(struct comedi_device *dev, - struct comedi_subdevice *s, - int n_chan, unsigned int *chanlist) +static void apci3120_set_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + int n_chan, unsigned int *chanlist) { struct apci3120_private *devpriv = dev->private; int i; - /* correct channel and range number check itself comedi/range.c */ - if (n_chan < 1) { - dev_err(dev->class_dev, "range/channel list is empty!\n"); - return 0; - } - /* set scan length (PR) and scan start (PA) */ devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); @@ -128,7 +122,6 @@ static int apci3120_setup_chan_list(struct comedi_device *dev, outw(val, dev->iobase + APCI3120_CHANLIST_REG); } - return 1; /* we can serve this with scan logic */ } static int apci3120_reset(struct comedi_device *dev) @@ -288,10 +281,8 @@ static int apci3120_cyclic_ai(int mode, devpriv->ui_DmaActualBuffer = 0; - /* Initializes the sequence array */ - if (!apci3120_setup_chan_list(dev, s, cmd->chanlist_len, - cmd->chanlist)) - return -EINVAL; + /* load chanlist for command scan */ + apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); divisor0 = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); if (mode == 2) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 70363faa99d6..d40fdf2219a5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -310,8 +310,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* load chanlist for single channel scan */ - if (!apci3120_setup_chan_list(dev, s, 1, &insn->chanspec)) - return -EINVAL; + apci3120_set_chanlist(dev, s, 1, &insn->chanspec); /* * Timer 0 is used in MODE4 (software triggered strobe) to set the -- cgit v1.2.3-59-g8ed1b From 169f35e82ce6ba0068ecaf3671342a8201c99c32 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:45 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_set_chanlist() to driver source Move this function from the included hwdrv_apci31210.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 28 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3c172466a3c0..f7543f684016 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -96,34 +96,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_COUNTER 3 -static void apci3120_set_chanlist(struct comedi_device *dev, - struct comedi_subdevice *s, - int n_chan, unsigned int *chanlist) -{ - struct apci3120_private *devpriv = dev->private; - int i; - - /* set scan length (PR) and scan start (PA) */ - devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); - - /* set chanlist for scan */ - for (i = 0; i < n_chan; i++) { - unsigned int chan = CR_CHAN(chanlist[i]); - unsigned int range = CR_RANGE(chanlist[i]); - unsigned int val; - - val = APCI3120_CHANLIST_MUX(chan) | - APCI3120_CHANLIST_GAIN(range) | - APCI3120_CHANLIST_INDEX(i); - - if (comedi_range_is_unipolar(s, range)) - val |= APCI3120_CHANLIST_UNIPOLAR; - - outw(val, dev->iobase + APCI3120_CHANLIST_REG); - } -} - static int apci3120_reset(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index d40fdf2219a5..044d2c42bcd5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -279,6 +279,34 @@ static void apci3120_ai_reset_fifo(struct comedi_device *dev) inw(dev->iobase + APCI3120_TIMER_MODE_REG); } +static void apci3120_set_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + int n_chan, unsigned int *chanlist) +{ + struct apci3120_private *devpriv = dev->private; + int i; + + /* set scan length (PR) and scan start (PA) */ + devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); + + /* set chanlist for scan */ + for (i = 0; i < n_chan; i++) { + unsigned int chan = CR_CHAN(chanlist[i]); + unsigned int range = CR_RANGE(chanlist[i]); + unsigned int val; + + val = APCI3120_CHANLIST_MUX(chan) | + APCI3120_CHANLIST_GAIN(range) | + APCI3120_CHANLIST_INDEX(i); + + if (comedi_range_is_unipolar(s, range)) + val |= APCI3120_CHANLIST_UNIPOLAR; + + outw(val, dev->iobase + APCI3120_CHANLIST_REG); + } +} + #include "addi-data/hwdrv_apci3120.c" static int apci3120_ai_eoc(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From e451dfeb4c205f74b3bfc35d58fd1a17dff490ed Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:46 -0700 Subject: staging: comedi: addi_apci_3120: factor DMA setup out of apci3120_cyclic_ai() For aesthetics, factor the DMA setup code out of apci3120_cyclic_ai(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 295 +++++++++++---------- 1 file changed, 148 insertions(+), 147 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index f7543f684016..6377c37fde16 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -224,6 +224,153 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, return 0; } +static void apci3120_setup_dma(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct apci3120_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0]; + struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1]; + unsigned int dmalen0 = dmabuf0->size; + unsigned int dmalen1 = dmabuf1->size; + unsigned int scan_bytes; + + scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg); + + if (cmd->stop_src == TRIG_COUNT) { + /* + * Must we fill full first buffer? And must we fill + * full second buffer when first is once filled? + */ + if (dmalen0 > (cmd->stop_arg * scan_bytes)) + dmalen0 = cmd->stop_arg * scan_bytes; + else if (dmalen1 > (cmd->stop_arg * scan_bytes - dmalen0)) + dmalen1 = cmd->stop_arg * scan_bytes - dmalen0; + } + + if (cmd->flags & CMDF_WAKE_EOS) { + /* don't we want wake up every scan? */ + if (dmalen0 > scan_bytes) { + dmalen0 = scan_bytes; + if (cmd->scan_end_arg & 1) + dmalen0 += 2; + } + if (dmalen1 > scan_bytes) { + dmalen1 = scan_bytes; + if (cmd->scan_end_arg & 1) + dmalen1 -= 2; + if (dmalen1 < 4) + dmalen1 = 4; + } + } else { + /* isn't output buff smaller that our DMA buff? */ + if (dmalen0 > s->async->prealloc_bufsz) + dmalen0 = s->async->prealloc_bufsz; + if (dmalen1 > s->async->prealloc_bufsz) + dmalen1 = s->async->prealloc_bufsz; + } + dmabuf0->use_size = dmalen0; + dmabuf1->use_size = dmalen1; + + /* Initialize DMA */ + + /* + * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS + * register 1 + */ + outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + devpriv->amcc + AMCC_OP_REG_AGCSTS); + + /* changed since 16 bit interface for add on */ + /* ENABLE BUS MASTER */ + outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); + + outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); + outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); + + /* + * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux + * driver + */ + outw(0x1000, devpriv->addon + 2); + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + + /* 2 No change */ + /* A2P FIFO MANAGEMENT */ + /* A2P fifo reset & transfer control enable */ + outl(APCI3120_A2P_FIFO_MANAGEMENT, + devpriv->amcc + APCI3120_AMCC_OP_MCSR); + + /* + * 3 + * beginning address of dma buf The 32 bit address of dma buffer + * is converted into two 16 bit addresses Can done by using _attach + * and put into into an array array used may be for differnet pages + */ + + /* DMA Start Address Low */ + outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); + outw(dmabuf0->hw & 0xffff, devpriv->addon + 2); + + /* DMA Start Address High */ + outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); + outw((dmabuf0->hw >> 16) & 0xffff, devpriv->addon + 2); + + /* + * 4 + * amount of bytes to be transferred set transfer count used ADDON + * MWTC register commented testing + */ + + /* Nbr of acquisition LOW */ + outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); + outw(dmabuf0->use_size & 0xffff, devpriv->addon + 2); + + /* Nbr of acquisition HIGH */ + outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); + outw((dmabuf0->use_size >> 16) & 0xffff, devpriv->addon + 2); + + /* + * 5 + * To configure A2P FIFO testing outl( + * FIFO_ADVANCE_ON_BYTE_2, devpriv->amcc + AMCC_OP_REG_INTCSR); + */ + + /* A2P FIFO RESET */ + /* + * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux + * driver + */ + outl(0x04000000UL, devpriv->amcc + AMCC_OP_REG_MCSR); + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + + /* + * 6 + * ENABLE A2P FIFO WRITE AND ENABLE AMWEN AMWEN_ENABLE | + * A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 + */ + + /* + * 7 + * initialise end of dma interrupt AINT_WRITE_COMPL = + * ENABLE_WRITE_TC_INT(ADDI) + */ + /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */ + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT, + devpriv->amcc + AMCC_OP_REG_INTCSR); + + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ + outw(3, devpriv->addon + 4); + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + + /* A2P FIFO RESET */ + /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ + outl(0x04000000UL, devpriv->amcc + APCI3120_AMCC_OP_MCSR); + /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ +} + /* * This is used for analog input cyclic acquisition. * Performs the command operations. @@ -237,8 +384,6 @@ static int apci3120_cyclic_ai(int mode, struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned int divisor1 = 0; - unsigned int dmalen0 = 0; - unsigned int dmalen1 = 0; unsigned int divisor0; /* clear software registers */ @@ -320,152 +465,8 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_Timer2Interrupt = APCI3120_ENABLE; } } else { - /* If DMA Enabled */ - struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0]; - struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1]; - unsigned int scan_bytes; - - scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg); - devpriv->b_InterruptMode = APCI3120_DMA_MODE; - - dmalen0 = dmabuf0->size; - dmalen1 = dmabuf1->size; - - if (cmd->stop_src == TRIG_COUNT) { - /* - * Must we fill full first buffer? And must we fill - * full second buffer when first is once filled? - */ - if (dmalen0 > (cmd->stop_arg * scan_bytes)) { - dmalen0 = cmd->stop_arg * scan_bytes; - } else if (dmalen1 > (cmd->stop_arg * scan_bytes - - dmalen0)) - dmalen1 = cmd->stop_arg * scan_bytes - - dmalen0; - } - - if (cmd->flags & CMDF_WAKE_EOS) { - /* don't we want wake up every scan? */ - if (dmalen0 > scan_bytes) { - dmalen0 = scan_bytes; - if (cmd->scan_end_arg & 1) - dmalen0 += 2; - } - if (dmalen1 > scan_bytes) { - dmalen1 = scan_bytes; - if (cmd->scan_end_arg & 1) - dmalen1 -= 2; - if (dmalen1 < 4) - dmalen1 = 4; - } - } else { /* isn't output buff smaller that our DMA buff? */ - if (dmalen0 > s->async->prealloc_bufsz) - dmalen0 = s->async->prealloc_bufsz; - if (dmalen1 > s->async->prealloc_bufsz) - dmalen1 = s->async->prealloc_bufsz; - } - dmabuf0->use_size = dmalen0; - dmabuf1->use_size = dmalen1; - - /* Initialize DMA */ - - /* - * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS - * register 1 - */ - outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - devpriv->amcc + AMCC_OP_REG_AGCSTS); - - /* changed since 16 bit interface for add on */ - /* ENABLE BUS MASTER */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); - - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); - - /* - * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux - * driver - */ - outw(0x1000, devpriv->addon + 2); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - - /* 2 No change */ - /* A2P FIFO MANAGEMENT */ - /* A2P fifo reset & transfer control enable */ - outl(APCI3120_A2P_FIFO_MANAGEMENT, - devpriv->amcc + APCI3120_AMCC_OP_MCSR); - - /* - * 3 - * beginning address of dma buf The 32 bit address of dma buffer - * is converted into two 16 bit addresses Can done by using _attach - * and put into into an array array used may be for differnet pages - */ - - /* DMA Start Address Low */ - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); - outw(dmabuf0->hw & 0xffff, devpriv->addon + 2); - - /* DMA Start Address High */ - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); - outw((dmabuf0->hw >> 16) & 0xffff, devpriv->addon + 2); - - /* - * 4 - * amount of bytes to be transferred set transfer count used ADDON - * MWTC register commented testing - */ - - /* Nbr of acquisition LOW */ - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); - outw(dmabuf0->use_size & 0xffff, devpriv->addon + 2); - - /* Nbr of acquisition HIGH */ - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); - outw((dmabuf0->use_size >> 16) & 0xffff, devpriv->addon + 2); - - /* - * 5 - * To configure A2P FIFO testing outl( - * FIFO_ADVANCE_ON_BYTE_2, devpriv->amcc + AMCC_OP_REG_INTCSR); - */ - - /* A2P FIFO RESET */ - /* - * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux - * driver - */ - outl(0x04000000UL, devpriv->amcc + AMCC_OP_REG_MCSR); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - - /* - * 6 - * ENABLE A2P FIFO WRITE AND ENABLE AMWEN AMWEN_ENABLE | - * A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 - */ - - /* - * 7 - * initialise end of dma interrupt AINT_WRITE_COMPL = - * ENABLE_WRITE_TC_INT(ADDI) - */ - /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */ - outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 | - APCI3120_ENABLE_WRITE_TC_INT), - devpriv->amcc + AMCC_OP_REG_INTCSR); - - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ - outw(3, devpriv->addon + 4); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - - /* A2P FIFO RESET */ - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - outl(0x04000000UL, devpriv->amcc + APCI3120_AMCC_OP_MCSR); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + apci3120_setup_dma(dev, s); } if (devpriv->us_UseDma == APCI3120_DISABLE && -- cgit v1.2.3-59-g8ed1b From 76931af2009ef8e81fd30addf42a39d0265c45f5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:47 -0700 Subject: staging: comedi: addi_apci_3120: remove APCI3120_{ENABLE,DISABLE} These true/false defines don't add any significant clarity to the code. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 6377c37fde16..4760200ca1e0 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -71,9 +71,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY /* for transfer count enable bit */ #define AGCSTS_TC_ENABLE 0x10000000 -#define APCI3120_DISABLE 0 -#define APCI3120_ENABLE 1 - #define APCI3120_START 1 #define APCI3120_STOP 0 @@ -407,7 +404,7 @@ static int apci3120_cyclic_ai(int mode, cmd->flags); } - if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) + if (devpriv->b_ExttrigEnable) apci3120_exttrig_enable(dev, true); switch (mode) { @@ -438,7 +435,7 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* If DMA is disabled */ - if (devpriv->us_UseDma == APCI3120_DISABLE) { + if (!devpriv->us_UseDma) { /* disable EOC and enable EOS */ devpriv->b_InterruptMode = APCI3120_EOS_MODE; @@ -462,15 +459,14 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); devpriv->b_Timer2Mode = APCI3120_COUNTER; - devpriv->b_Timer2Interrupt = APCI3120_ENABLE; + devpriv->b_Timer2Interrupt = 1; } } else { devpriv->b_InterruptMode = APCI3120_DMA_MODE; apci3120_setup_dma(dev, s); } - if (devpriv->us_UseDma == APCI3120_DISABLE && - cmd->stop_src == TRIG_COUNT) + if (!devpriv->us_UseDma && cmd->stop_src == TRIG_COUNT) apci3120_timer_enable(dev, 2, true); switch (mode) { @@ -498,9 +494,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; if (cmd->start_src == TRIG_EXT) - devpriv->b_ExttrigEnable = APCI3120_ENABLE; + devpriv->b_ExttrigEnable = 1; else - devpriv->b_ExttrigEnable = APCI3120_DISABLE; + devpriv->b_ExttrigEnable = 0; if (cmd->scan_begin_src == TRIG_FOLLOW) return apci3120_cyclic_ai(1, dev, s); @@ -656,9 +652,9 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) outl(int_amcc | 0x00ff0000, devpriv->amcc + AMCC_OP_REG_INTCSR); - if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { + if (devpriv->b_ExttrigEnable) { apci3120_exttrig_enable(dev, false); - devpriv->b_ExttrigEnable = APCI3120_DISABLE; + devpriv->b_ExttrigEnable = 0; } apci3120_clr_timer2_interrupt(dev); @@ -841,7 +837,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, } /* enable disable interrupt */ - if ((devpriv->b_Timer2Interrupt) == APCI3120_ENABLE) { + if (devpriv->b_Timer2Interrupt) { devpriv->mode |= APCI3120_MODE_TIMER2_IRQ_ENA; /* save the task structure to pass info to user */ -- cgit v1.2.3-59-g8ed1b From 5c66a77e1d1da92f4b42c069d6591ecc41dbe6ba Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:48 -0700 Subject: staging: comedi: addi_apci_3120: flip 'us_UseDma' test in apci3120_cyclic_ai() For aesthetics, flip this test and do the DMA setup first. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 4760200ca1e0..31ef047b6281 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -434,8 +434,10 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - /* If DMA is disabled */ - if (!devpriv->us_UseDma) { + if (devpriv->us_UseDma) { + devpriv->b_InterruptMode = APCI3120_DMA_MODE; + apci3120_setup_dma(dev, s); + } else { /* disable EOC and enable EOS */ devpriv->b_InterruptMode = APCI3120_EOS_MODE; @@ -461,9 +463,6 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = 1; } - } else { - devpriv->b_InterruptMode = APCI3120_DMA_MODE; - apci3120_setup_dma(dev, s); } if (!devpriv->us_UseDma && cmd->stop_src == TRIG_COUNT) -- cgit v1.2.3-59-g8ed1b From b72b365666701b66d8ff09a5023b0d097d38e538 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:49 -0700 Subject: staging: comedi: addi_apci_3120: move timer 2 enable in apci3120_cyclic_ai() Move the enable of timer 2 to avoid needing the extra if() check. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 31ef047b6281..1481d18a12fa 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -462,12 +462,11 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = 1; + + apci3120_timer_enable(dev, 2, true); } } - if (!devpriv->us_UseDma && cmd->stop_src == TRIG_COUNT) - apci3120_timer_enable(dev, 2, true); - switch (mode) { case 1: apci3120_timer_enable(dev, 0, true); -- cgit v1.2.3-59-g8ed1b From fb43ceaf1d869215a0e704f0e83be993bdb07f56 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:50 -0700 Subject: staging: comedi: addi_apci_3120: move start_src check into apci3120_cyclic_ai() For aesthetics, move the check of the cmd->start_src. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 1481d18a12fa..b4d6fb467362 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -404,8 +404,12 @@ static int apci3120_cyclic_ai(int mode, cmd->flags); } - if (devpriv->b_ExttrigEnable) + if (cmd->start_src == TRIG_EXT) { + devpriv->b_ExttrigEnable = 1; apci3120_exttrig_enable(dev, true); + } else { + devpriv->b_ExttrigEnable = 0; + } switch (mode) { case 1: @@ -488,14 +492,8 @@ static int apci3120_cyclic_ai(int mode, static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - if (cmd->start_src == TRIG_EXT) - devpriv->b_ExttrigEnable = 1; - else - devpriv->b_ExttrigEnable = 0; - if (cmd->scan_begin_src == TRIG_FOLLOW) return apci3120_cyclic_ai(1, dev, s); /* TRIG_TIMER */ -- cgit v1.2.3-59-g8ed1b From aaf802fb304ccbfc68c9699ae3a800a769c3d838 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:51 -0700 Subject: staging: comedi: addi_apci_3120: absorb apci3120_cyclic_ai() This functon is called by apci3120_ai_cmd() with one additional parameter, 'mode', The 'mode' is based on the cmd->scan_begin_src. For aesthetics, absorb the function into apci3120_ai_cmd() and use the cmd->scan_begin_src directly to determine the 'mode'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 45 ++++------------------ 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b4d6fb467362..8fc78039bfac 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -368,15 +368,8 @@ static void apci3120_setup_dma(struct comedi_device *dev, /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ } -/* - * This is used for analog input cyclic acquisition. - * Performs the command operations. - * If DMA is configured does DMA initialization otherwise does the - * acquisition with EOS interrupt. - */ -static int apci3120_cyclic_ai(int mode, - struct comedi_device *dev, - struct comedi_subdevice *s) +static int apci3120_ai_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) { struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; @@ -399,7 +392,7 @@ static int apci3120_cyclic_ai(int mode, apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); divisor0 = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); - if (mode == 2) { + if (cmd->scan_begin_src == TRIG_TIMER) { divisor1 = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg, cmd->flags); } @@ -411,16 +404,13 @@ static int apci3120_cyclic_ai(int mode, devpriv->b_ExttrigEnable = 0; } - switch (mode) { - case 1: + if (cmd->scan_begin_src == TRIG_FOLLOW) { /* init timer0 in mode 2 */ apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor0); - break; - - case 2: + } else { /* TRIG_TIMER */ /* init timer1 in mode 2 */ apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2); @@ -432,8 +422,6 @@ static int apci3120_cyclic_ai(int mode, /* Set the conversion time */ apci3120_timer_write(dev, 0, divisor0); - break; - } outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); @@ -471,33 +459,14 @@ static int apci3120_cyclic_ai(int mode, } } - switch (mode) { - case 1: + if (cmd->scan_begin_src == TRIG_FOLLOW) { apci3120_timer_enable(dev, 0, true); - break; - case 2: + } else { /* TRIG_TIMER */ apci3120_timer_enable(dev, 1, true); apci3120_timer_enable(dev, 0, true); - break; } return 0; - -} - -/* - * Does asynchronous acquisition. - * Determines the mode 1 or 2. - */ -static int apci3120_ai_cmd(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct comedi_cmd *cmd = &s->async->cmd; - - if (cmd->scan_begin_src == TRIG_FOLLOW) - return apci3120_cyclic_ai(1, dev, s); - /* TRIG_TIMER */ - return apci3120_cyclic_ai(2, dev, s); } /* -- cgit v1.2.3-59-g8ed1b From dc0a05608d465eda9b340b958af40c1eae61af7b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:52 -0700 Subject: staging: comedi: addi_apci_3120: tidy up timer programming in apci3120_ai_cmd() Tidy up the programming of timers 0 and 1 so that only one local variable is required. Also, remove the unnecessary clear of devpriv->timer_mode. This value will get set correctly by each apci3120_timer_set_mode() call. It's not necessary to clear it first. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 52 ++++++++-------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 8fc78039bfac..3656f9d23ebc 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -373,12 +373,10 @@ static int apci3120_ai_cmd(struct comedi_device *dev, { struct apci3120_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int divisor1 = 0; - unsigned int divisor0; + unsigned int divisor; - /* clear software registers */ - devpriv->timer_mode = 0; devpriv->mode = 0; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, @@ -391,12 +389,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* load chanlist for command scan */ apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); - divisor0 = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); - if (cmd->scan_begin_src == TRIG_TIMER) { - divisor1 = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg, - cmd->flags); - } - if (cmd->start_src == TRIG_EXT) { devpriv->b_ExttrigEnable = 1; apci3120_exttrig_enable(dev, true); @@ -404,27 +396,24 @@ static int apci3120_ai_cmd(struct comedi_device *dev, devpriv->b_ExttrigEnable = 0; } - if (cmd->scan_begin_src == TRIG_FOLLOW) { - /* init timer0 in mode 2 */ - apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); - - /* Set the conversion time */ - apci3120_timer_write(dev, 0, divisor0); - } else { /* TRIG_TIMER */ - /* init timer1 in mode 2 */ + if (cmd->scan_begin_src == TRIG_TIMER) { + /* + * Timer 1 is used in MODE2 (rate generator) to set the + * start time for each scan. + */ + divisor = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg, + cmd->flags); apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2); - - /* Set the scan begin time */ - apci3120_timer_write(dev, 1, divisor1); - - /* init timer0 in mode 2 */ - apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); - - /* Set the conversion time */ - apci3120_timer_write(dev, 0, divisor0); + apci3120_timer_write(dev, 1, divisor); } - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + /* + * Timer 0 is used in MODE2 (rate generator) to set the conversion + * time for each acquisition. + */ + divisor = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); + apci3120_timer_write(dev, 0, divisor); if (devpriv->us_UseDma) { devpriv->b_InterruptMode = APCI3120_DMA_MODE; @@ -459,12 +448,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev, } } - if (cmd->scan_begin_src == TRIG_FOLLOW) { - apci3120_timer_enable(dev, 0, true); - } else { /* TRIG_TIMER */ + if (cmd->scan_begin_src == TRIG_TIMER) apci3120_timer_enable(dev, 1, true); - apci3120_timer_enable(dev, 0, true); - } + apci3120_timer_enable(dev, 0, true); return 0; } -- cgit v1.2.3-59-g8ed1b From 502ccab2b644f2445af463e434783e56b407f31b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:53 -0700 Subject: staging: comedi: addi_apci_3120: tidy up timer 2 programming in apci3120_ai_cmd() Tidy up the programming of timer 2. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3656f9d23ebc..54c85837160e 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -426,16 +426,20 @@ static int apci3120_ai_cmd(struct comedi_device *dev, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); if (cmd->stop_src == TRIG_COUNT) { - /* configure Timer2 For counting EOS */ - - /* (1) Init timer 2 in mode 0 and write timer value */ + /* + * Timer 2 is used in MODE0 (hardware retriggerable + * one-shot) to count the number of scans. + * + * NOTE: not sure about the -2 value + */ apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0); - - /* Set the scan stop count (not sure about the -2) */ apci3120_timer_write(dev, 2, cmd->stop_arg - 2); apci3120_clr_timer2_interrupt(dev); + apci3120_timer_enable(dev, 2, true); + + /* configure Timer 2 For counting EOS */ devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER | APCI3120_MODE_TIMER2_CLK_EOS | APCI3120_MODE_TIMER2_IRQ_ENA; @@ -443,8 +447,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = 1; - - apci3120_timer_enable(dev, 2, true); } } -- cgit v1.2.3-59-g8ed1b From 15e920fb1581c531f8d139534fa58d964d4e8b45 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:54 -0700 Subject: staging: comedi: addi_apci_3120: reset fifo after programming chanlist The APCI-3120 documentation says that the FIFO should be reset after the chanlist sequence is programmed. Reset the FIFO after programming the chanlist and remove the extra FIFO resets in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 ---- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 54c85837160e..95a1b7dad397 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -112,7 +112,6 @@ static int apci3120_reset(struct comedi_device *dev) devpriv->ctrl = 0; outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); - apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_STATUS_REG); return 0; @@ -143,7 +142,6 @@ static int apci3120_cancel(struct comedi_device *dev, devpriv->mode = 0; outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - apci3120_ai_reset_fifo(dev); inw(dev->iobase + APCI3120_STATUS_REG); devpriv->ui_DmaActualBuffer = 0; @@ -382,8 +380,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, outl(APCI3120_CLEAR_WRITE_TC_INT, devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); - apci3120_ai_reset_fifo(dev); - devpriv->ui_DmaActualBuffer = 0; /* load chanlist for command scan */ diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 044d2c42bcd5..77499b473bb4 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -305,6 +305,8 @@ static void apci3120_set_chanlist(struct comedi_device *dev, outw(val, dev->iobase + APCI3120_CHANLIST_REG); } + + apci3120_ai_reset_fifo(dev); } #include "addi-data/hwdrv_apci3120.c" @@ -352,8 +354,6 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, /* fixed conversion time of 10 us */ divisor = apci3120_ns_to_timer(dev, 0, 10000, CMDF_ROUND_NEAREST); - apci3120_ai_reset_fifo(dev); - for (i = 0; i < insn->n; i++) { /* trigger conversion */ apci3120_timer_write(dev, 0, divisor); -- cgit v1.2.3-59-g8ed1b From 1022f64e7548a3bede7c671c6d52592f05954bd5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:55 -0700 Subject: staging: comedi: addi_apci_3120: set scan length/start after programming chanlist The APCI-3120 documentation says that the PR/PA bits should be set after the chanlist sequence is programmed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 77499b473bb4..f258ceb144fb 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -286,10 +286,6 @@ static void apci3120_set_chanlist(struct comedi_device *dev, struct apci3120_private *devpriv = dev->private; int i; - /* set scan length (PR) and scan start (PA) */ - devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); - outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); - /* set chanlist for scan */ for (i = 0; i < n_chan; i++) { unsigned int chan = CR_CHAN(chanlist[i]); @@ -307,6 +303,10 @@ static void apci3120_set_chanlist(struct comedi_device *dev, } apci3120_ai_reset_fifo(dev); + + /* set scan length (PR) and scan start (PA) */ + devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); } #include "addi-data/hwdrv_apci3120.c" -- cgit v1.2.3-59-g8ed1b From fdeb2f548790074dd7f9c39275b727ad00600af8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:56 -0700 Subject: staging: comedi: addi_apci_3120: enable chanlist scanning if needed The 'SCAN_ENA' bit in the mode register needs to be set if the chanlist has more than 1 channel. Set the bit in apci3120_set_chanlist() if needed. The callers write the mode register after setting any additional bits, Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index f258ceb144fb..ec6623372721 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -307,6 +307,10 @@ static void apci3120_set_chanlist(struct comedi_device *dev, /* set scan length (PR) and scan start (PA) */ devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); + + /* enable chanlist scanning if necessary */ + if (n_chan > 1) + devpriv->mode |= APCI3120_MODE_SCAN_ENA; } #include "addi-data/hwdrv_apci3120.c" -- cgit v1.2.3-59-g8ed1b From 28215c69885fa86be8b5e8f7269edfb4f8c1c480 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:57 -0700 Subject: staging: comedi: addi_apci_3120: tidy up devpriv->mode in apci3120_ai_cmd() There is no reason for the separate updates of the mode register in this function. Refactor the code so that the mode register is only updated at the end of the function after all the necessary bits have been set. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 95a1b7dad397..c7f6130ff6a1 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -373,8 +373,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; unsigned int divisor; - devpriv->mode = 0; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + /* set default mode bits */ + devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | + APCI3120_MODE_TIMER2_AS_TIMER; /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, @@ -415,11 +416,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev, devpriv->b_InterruptMode = APCI3120_DMA_MODE; apci3120_setup_dma(dev, s); } else { - /* disable EOC and enable EOS */ devpriv->b_InterruptMode = APCI3120_EOS_MODE; devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); if (cmd->stop_src == TRIG_COUNT) { /* @@ -439,13 +438,15 @@ static int apci3120_ai_cmd(struct comedi_device *dev, devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER | APCI3120_MODE_TIMER2_CLK_EOS | APCI3120_MODE_TIMER2_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Interrupt = 1; } } + /* set mode to enable acquisition */ + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + if (cmd->scan_begin_src == TRIG_TIMER) apci3120_timer_enable(dev, 1, true); apci3120_timer_enable(dev, 0, true); -- cgit v1.2.3-59-g8ed1b From b278ea3cefc78bd3b5035b9db0c58ddcc5039de3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:58 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'b_InterruptMode' This member of the private data is not really needed. The interrupt mode can be determined by checking the devpriv->mode value to see if the interrupt is enabled. Remove the unnecessary member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 18 +++--------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c7f6130ff6a1..84600d4788c4 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -74,10 +74,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_START 1 #define APCI3120_STOP 0 -#define APCI3120_EOC_MODE 1 -#define APCI3120_EOS_MODE 2 -#define APCI3120_DMA_MODE 3 - #define APCI3120_RD_FIFO 0x00 /* software trigger dummy register */ @@ -97,8 +93,6 @@ static int apci3120_reset(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; - devpriv->b_InterruptMode = APCI3120_EOC_MODE; - /* variables used in timer subdevice */ devpriv->b_Timer2Mode = 0; devpriv->b_Timer2Interrupt = 0; @@ -145,8 +139,6 @@ static int apci3120_cancel(struct comedi_device *dev, inw(dev->iobase + APCI3120_STATUS_REG); devpriv->ui_DmaActualBuffer = 0; - devpriv->b_InterruptMode = APCI3120_EOC_MODE; - return 0; } @@ -413,11 +405,8 @@ static int apci3120_ai_cmd(struct comedi_device *dev, apci3120_timer_write(dev, 0, divisor); if (devpriv->us_UseDma) { - devpriv->b_InterruptMode = APCI3120_DMA_MODE; apci3120_setup_dma(dev, s); } else { - devpriv->b_InterruptMode = APCI3120_EOS_MODE; - devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; if (cmd->stop_src == TRIG_COUNT) { @@ -615,12 +604,12 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n"); if ((status & APCI3120_STATUS_EOC_INT) == 0 && - devpriv->b_InterruptMode == APCI3120_EOC_MODE) { + (devpriv->mode & APCI3120_MODE_EOC_IRQ_ENA)) { /* nothing to do... EOC mode is not currently used */ } if ((status & APCI3120_STATUS_EOS_INT) && - devpriv->b_InterruptMode == APCI3120_EOS_MODE) { + (devpriv->mode & APCI3120_MODE_EOS_IRQ_ENA)) { unsigned short val; int i; @@ -663,8 +652,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) apci3120_clr_timer2_interrupt(dev); } - if ((status & APCI3120_STATUS_AMCC_INT) && - devpriv->b_InterruptMode == APCI3120_DMA_MODE) { + if (status & APCI3120_STATUS_AMCC_INT) { /* Clear Timer Write TC int */ outl(APCI3120_CLEAR_WRITE_TC_INT, devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ec6623372721..a6ae42fca6c0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -133,7 +133,6 @@ struct apci3120_private { unsigned short ctrl; unsigned char b_Timer2Mode; unsigned char b_Timer2Interrupt; - unsigned char b_InterruptMode; unsigned char b_ExttrigEnable; struct task_struct *tsk_Current; }; -- cgit v1.2.3-59-g8ed1b From 3431ec2ff5e19bd6690072f91b45bef67ace0ccb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:54:59 -0700 Subject: staging: comedi: addi_apci_3120: remove private data 'b_ExttrigEnable' This member of the private data is not really needed. The devpriv->ctrl value can be checked to determine if the external trigger is enabled. Remove the unnecessary member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ++--------- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 84600d4788c4..b38bbd31ac0a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -96,7 +96,6 @@ static int apci3120_reset(struct comedi_device *dev) /* variables used in timer subdevice */ devpriv->b_Timer2Mode = 0; devpriv->b_Timer2Interrupt = 0; - devpriv->b_ExttrigEnable = 0; /* Disable ext trigger */ /* Disable all interrupts, watchdog for the anolog output */ devpriv->mode = 0; @@ -378,12 +377,8 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* load chanlist for command scan */ apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); - if (cmd->start_src == TRIG_EXT) { - devpriv->b_ExttrigEnable = 1; + if (cmd->start_src == TRIG_EXT) apci3120_exttrig_enable(dev, true); - } else { - devpriv->b_ExttrigEnable = 0; - } if (cmd->scan_begin_src == TRIG_TIMER) { /* @@ -591,10 +586,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) outl(int_amcc | 0x00ff0000, devpriv->amcc + AMCC_OP_REG_INTCSR); - if (devpriv->b_ExttrigEnable) { + if (devpriv->ctrl & APCI3120_CTRL_EXT_TRIG) apci3120_exttrig_enable(dev, false); - devpriv->b_ExttrigEnable = 0; - } apci3120_clr_timer2_interrupt(dev); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index a6ae42fca6c0..3900a90b9608 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -133,7 +133,6 @@ struct apci3120_private { unsigned short ctrl; unsigned char b_Timer2Mode; unsigned char b_Timer2Interrupt; - unsigned char b_ExttrigEnable; struct task_struct *tsk_Current; }; -- cgit v1.2.3-59-g8ed1b From 3ed69b98b9fadb337b9500ec39007e8f448d4861 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:00 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_init_dma() Introduce a helper function to handle the common code that writes the DMA start address and number of acquisitions to the AMCC Add-on registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 75 +++++++--------------- 1 file changed, 23 insertions(+), 52 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b38bbd31ac0a..09428446e728 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -210,6 +210,26 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, return 0; } +static void apci3120_init_dma(struct comedi_device *dev, + struct apci3120_dmabuf *dmabuf) +{ + struct apci3120_private *devpriv = dev->private; + + /* DMA Start Address Low */ + outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); + outw(dmabuf->hw & 0xffff, devpriv->addon + 2); + /* DMA Start Address High */ + outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); + outw((dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2); + + /* Nbr of acquisition LOW */ + outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); + outw(dmabuf->use_size & 0xffff, devpriv->addon + 2); + /* Nbr of acquisition HIGH */ + outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); + outw((dmabuf->use_size >> 16) & 0xffff, devpriv->addon + 2); +} + static void apci3120_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -288,34 +308,7 @@ static void apci3120_setup_dma(struct comedi_device *dev, outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->amcc + APCI3120_AMCC_OP_MCSR); - /* - * 3 - * beginning address of dma buf The 32 bit address of dma buffer - * is converted into two 16 bit addresses Can done by using _attach - * and put into into an array array used may be for differnet pages - */ - - /* DMA Start Address Low */ - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); - outw(dmabuf0->hw & 0xffff, devpriv->addon + 2); - - /* DMA Start Address High */ - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); - outw((dmabuf0->hw >> 16) & 0xffff, devpriv->addon + 2); - - /* - * 4 - * amount of bytes to be transferred set transfer count used ADDON - * MWTC register commented testing - */ - - /* Nbr of acquisition LOW */ - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); - outw(dmabuf0->use_size & 0xffff, devpriv->addon + 2); - - /* Nbr of acquisition HIGH */ - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); - outw((dmabuf0->use_size >> 16) & 0xffff, devpriv->addon + 2); + apci3120_init_dma(dev, dmabuf0); /* * 5 @@ -481,21 +474,7 @@ static void apci3120_interrupt_dma(int irq, void *d) outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); /* 0x1000 is out putted in windows driver */ - /* DMA Start Address Low */ - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); - outw(next_dmabuf->hw & 0xffff, devpriv->addon + 2); - - /* DMA Start Address High */ - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); - outw((next_dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2); - - /* Nbr of acquisition LOW */ - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); - outw(next_dmabuf->use_size & 0xffff, devpriv->addon + 2); - - /* Nbr of acquisition HIGH */ - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); - outw((next_dmabuf->use_size > 16) & 0xffff, devpriv->addon + 2); + apci3120_init_dma(dev, next_dmabuf); /* * To configure A2P FIFO @@ -543,15 +522,7 @@ static void apci3120_interrupt_dma(int irq, void *d) outl(APCI3120_A2P_FIFO_MANAGEMENT, devpriv->amcc + AMCC_OP_REG_MCSR); - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); - outw(dmabuf->hw & 0xffff, devpriv->addon + 2); - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); - outw((dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2); - - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); - outw(dmabuf->use_size & 0xffff, devpriv->addon + 2); - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); - outw((dmabuf->use_size >> 16) & 0xffff, devpriv->addon + 2); + apci3120_init_dma(dev, dmabuf); /* * To configure A2P FIFO -- cgit v1.2.3-59-g8ed1b From 83bec8428a40ad783603ce836615abd0f147309f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:01 -0700 Subject: staging: comedi: addi_apci_3120: introduce apci3120_addon_write() Introduce a helper function to handle the common code that writes a 32-bit value to the 16-bit add-on register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 71 +++++++++------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 09428446e728..b7c83caee0f7 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -44,8 +44,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY * ADDON RELATED ADDITIONS */ /* Constant */ -#define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW 0x00 -#define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH 0x1200 +#define APCI3120_ENABLE_TRANSFER_ADD_ON 0x12000000 #define APCI3120_A2P_FIFO_MANAGEMENT 0x04000400L #define APCI3120_AMWEN_ENABLE 0x02 #define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01 @@ -57,12 +56,9 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_DISABLE_BUS_MASTER_PCI 0x0 /* ADD_ON ::: this needed since apci supports 16 bit interface to add on */ -#define APCI3120_ADD_ON_AGCSTS_LOW 0x3C -#define APCI3120_ADD_ON_AGCSTS_HIGH (APCI3120_ADD_ON_AGCSTS_LOW + 2) -#define APCI3120_ADD_ON_MWAR_LOW 0x24 -#define APCI3120_ADD_ON_MWAR_HIGH (APCI3120_ADD_ON_MWAR_LOW + 2) -#define APCI3120_ADD_ON_MWTC_LOW 0x058 -#define APCI3120_ADD_ON_MWTC_HIGH (APCI3120_ADD_ON_MWTC_LOW + 2) +#define APCI3120_ADD_ON_MWAR 0x24 +#define APCI3120_ADD_ON_AGCSTS 0x3c +#define APCI3120_ADD_ON_MWTC 0x58 /* AMCC */ #define APCI3120_AMCC_OP_MCSR 0x3C @@ -89,6 +85,20 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_COUNTER 3 +static void apci3120_addon_write(struct comedi_device *dev, + unsigned int val, unsigned int reg) +{ + struct apci3120_private *devpriv = dev->private; + + /* 16-bit interface for AMCC add-on registers */ + + outw(reg, devpriv->addon + 0); + outw(val & 0xffff, devpriv->addon + 2); + + outw(reg + 2, devpriv->addon + 0); + outw((val >> 16) & 0xffff, devpriv->addon + 2); +} + static int apci3120_reset(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; @@ -119,10 +129,7 @@ static int apci3120_cancel(struct comedi_device *dev, outw(0, devpriv->addon + 4); /* Disable Bus Master ADD ON */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); - outw(0, devpriv->addon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); - outw(0, devpriv->addon + 2); + apci3120_addon_write(dev, 0, APCI3120_ADD_ON_AGCSTS); /* Disable BUS Master PCI */ outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); @@ -213,21 +220,11 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, static void apci3120_init_dma(struct comedi_device *dev, struct apci3120_dmabuf *dmabuf) { - struct apci3120_private *devpriv = dev->private; + /* DMA Start Address */ + apci3120_addon_write(dev, dmabuf->hw, APCI3120_ADD_ON_MWAR); - /* DMA Start Address Low */ - outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->addon + 0); - outw(dmabuf->hw & 0xffff, devpriv->addon + 2); - /* DMA Start Address High */ - outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->addon + 0); - outw((dmabuf->hw >> 16) & 0xffff, devpriv->addon + 2); - - /* Nbr of acquisition LOW */ - outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->addon + 0); - outw(dmabuf->use_size & 0xffff, devpriv->addon + 2); - /* Nbr of acquisition HIGH */ - outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->addon + 0); - outw((dmabuf->use_size >> 16) & 0xffff, devpriv->addon + 2); + /* Nbr of acquisition */ + apci3120_addon_write(dev, dmabuf->use_size, APCI3120_ADD_ON_MWTC); } static void apci3120_setup_dma(struct comedi_device *dev, @@ -287,13 +284,9 @@ static void apci3120_setup_dma(struct comedi_device *dev, outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, devpriv->amcc + AMCC_OP_REG_AGCSTS); - /* changed since 16 bit interface for add on */ /* ENABLE BUS MASTER */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); - - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); + apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON, + APCI3120_ADD_ON_AGCSTS); /* * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux @@ -468,11 +461,8 @@ static void apci3120_interrupt_dma(int irq, void *d) ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; outl(ui_Tmp, devpriv->amcc + AMCC_OP_REG_AGCSTS); - /* changed since 16 bit interface for add on */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); /* 0x1000 is out putted in windows driver */ + apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON, + APCI3120_ADD_ON_AGCSTS); apci3120_init_dma(dev, next_dmabuf); @@ -510,11 +500,8 @@ static void apci3120_interrupt_dma(int irq, void *d) outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, devpriv->amcc + AMCC_OP_REG_AGCSTS); - /* changed since 16 bit interface for add on */ - outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW, devpriv->addon + 2); - outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->addon + 0); - outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->addon + 2); + apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON, + APCI3120_ADD_ON_AGCSTS); /* * A2P FIFO MANAGEMENT * A2P fifo reset & transfer control enable -- cgit v1.2.3-59-g8ed1b From 636971fc9c95164d56f3727bd4d694991a9f01c5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:02 -0700 Subject: staging: comedi: addi_apci_3120: use amcc_s5933.h defines Use the defines for the AMCC 5933 PCI controller registers and bits instead of creating private defines in this driver. Move the generic AGCSTS_TC_ENABLE define from this driver to the header. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 151 +++++++-------------- drivers/staging/comedi/drivers/amcc_s5933.h | 2 + 2 files changed, 50 insertions(+), 103 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b7c83caee0f7..a38d7997d516 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -44,29 +44,13 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY * ADDON RELATED ADDITIONS */ /* Constant */ -#define APCI3120_ENABLE_TRANSFER_ADD_ON 0x12000000 -#define APCI3120_A2P_FIFO_MANAGEMENT 0x04000400L #define APCI3120_AMWEN_ENABLE 0x02 #define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01 #define APCI3120_FIFO_ADVANCE_ON_BYTE_2 0x20000000L -#define APCI3120_ENABLE_WRITE_TC_INT 0x00004000L -#define APCI3120_CLEAR_WRITE_TC_INT 0x00040000L #define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE 0x0 #define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0 #define APCI3120_DISABLE_BUS_MASTER_PCI 0x0 -/* ADD_ON ::: this needed since apci supports 16 bit interface to add on */ -#define APCI3120_ADD_ON_MWAR 0x24 -#define APCI3120_ADD_ON_AGCSTS 0x3c -#define APCI3120_ADD_ON_MWTC 0x58 - -/* AMCC */ -#define APCI3120_AMCC_OP_MCSR 0x3C -#define APCI3120_AMCC_OP_REG_INTCSR 0x38 - -/* for transfer count enable bit */ -#define AGCSTS_TC_ENABLE 0x10000000 - #define APCI3120_START 1 #define APCI3120_STOP 0 @@ -128,10 +112,10 @@ static int apci3120_cancel(struct comedi_device *dev, /* Disable A2P Fifo write and AMWEN signal */ outw(0, devpriv->addon + 4); - /* Disable Bus Master ADD ON */ - apci3120_addon_write(dev, 0, APCI3120_ADD_ON_AGCSTS); + /* Add-On - disable bus master */ + apci3120_addon_write(dev, 0, AMCC_OP_REG_AGCSTS); - /* Disable BUS Master PCI */ + /* AMCC - disable bus master */ outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); /* disable all counters, ext trigger, and reset scan */ @@ -220,11 +204,11 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, static void apci3120_init_dma(struct comedi_device *dev, struct apci3120_dmabuf *dmabuf) { - /* DMA Start Address */ - apci3120_addon_write(dev, dmabuf->hw, APCI3120_ADD_ON_MWAR); + /* Add-On - DMA start address */ + apci3120_addon_write(dev, dmabuf->hw, AMCC_OP_REG_AMWAR); - /* Nbr of acquisition */ - apci3120_addon_write(dev, dmabuf->use_size, APCI3120_ADD_ON_MWTC); + /* Add-On - Number of acquisitions */ + apci3120_addon_write(dev, dmabuf->use_size, AMCC_OP_REG_AMWTC); } static void apci3120_setup_dma(struct comedi_device *dev, @@ -277,70 +261,32 @@ static void apci3120_setup_dma(struct comedi_device *dev, /* Initialize DMA */ - /* - * Set Transfer count enable bit and A2P_fifo reset bit in AGCSTS - * register 1 - */ + /* AMCC- enable transfer count and reset A2P FIFO */ outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, devpriv->amcc + AMCC_OP_REG_AGCSTS); - /* ENABLE BUS MASTER */ - apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON, - APCI3120_ADD_ON_AGCSTS); - - /* - * TO VERIFIED BEGIN JK 07.05.04: Comparison between WIN32 and Linux - * driver - */ - outw(0x1000, devpriv->addon + 2); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* Add-On - enable transfer count and reset A2P FIFO */ + apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + AMCC_OP_REG_AGCSTS); - /* 2 No change */ - /* A2P FIFO MANAGEMENT */ - /* A2P fifo reset & transfer control enable */ - outl(APCI3120_A2P_FIFO_MANAGEMENT, - devpriv->amcc + APCI3120_AMCC_OP_MCSR); + /* AMCC - enable transfers and reset A2P flags */ + outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, + devpriv->amcc + AMCC_OP_REG_MCSR); apci3120_init_dma(dev, dmabuf0); - /* - * 5 - * To configure A2P FIFO testing outl( - * FIFO_ADVANCE_ON_BYTE_2, devpriv->amcc + AMCC_OP_REG_INTCSR); - */ - - /* A2P FIFO RESET */ - /* - * TO VERIFY BEGIN JK 07.05.04: Comparison between WIN32 and Linux - * driver - */ - outl(0x04000000UL, devpriv->amcc + AMCC_OP_REG_MCSR); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - - /* - * 6 - * ENABLE A2P FIFO WRITE AND ENABLE AMWEN AMWEN_ENABLE | - * A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 - */ + /* AMCC- reset A2P flags */ + outl(RESET_A2P_FLAGS, devpriv->amcc + AMCC_OP_REG_MCSR); - /* - * 7 - * initialise end of dma interrupt AINT_WRITE_COMPL = - * ENABLE_WRITE_TC_INT(ADDI) - */ - /* A2P FIFO CONFIGURATE, END OF DMA intERRUPT INIT */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | APCI3120_ENABLE_WRITE_TC_INT, + /* AMCC - enable write complete (DMA) and set FIFO advance */ + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, devpriv->amcc + AMCC_OP_REG_INTCSR); - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ outw(3, devpriv->addon + 4); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - /* A2P FIFO RESET */ - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - outl(0x04000000UL, devpriv->amcc + APCI3120_AMCC_OP_MCSR); - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + /* AMCC- reset A2P flags */ + outl(RESET_A2P_FLAGS, devpriv->amcc + AMCC_OP_REG_MCSR); } static int apci3120_ai_cmd(struct comedi_device *dev, @@ -354,9 +300,8 @@ static int apci3120_ai_cmd(struct comedi_device *dev, devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | APCI3120_MODE_TIMER2_AS_TIMER; - /* Clear Timer Write TC int */ - outl(APCI3120_CLEAR_WRITE_TC_INT, - devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); + /* AMCC- Clear write complete interrupt (DMA) */ + outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); devpriv->ui_DmaActualBuffer = 0; @@ -438,7 +383,6 @@ static void apci3120_interrupt_dma(int irq, void *d) struct comedi_cmd *cmd = &s->async->cmd; struct apci3120_dmabuf *dmabuf; unsigned int samplesinbuf; - unsigned int ui_Tmp; dmabuf = &devpriv->dmabuf[devpriv->ui_DmaActualBuffer]; @@ -458,11 +402,14 @@ static void apci3120_interrupt_dma(int irq, void *d) next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; - ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO; - outl(ui_Tmp, devpriv->amcc + AMCC_OP_REG_AGCSTS); + /* AMCC - enable transfer count and reset A2P FIFO */ + outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + devpriv->amcc + AMCC_OP_REG_AGCSTS); - apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON, - APCI3120_ADD_ON_AGCSTS); + /* Add-On - enable transfer count and reset A2P FIFO */ + apci3120_addon_write(dev, + AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + AMCC_OP_REG_AGCSTS); apci3120_init_dma(dev, next_dmabuf); @@ -472,9 +419,9 @@ static void apci3120_interrupt_dma(int irq, void *d) * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 */ outw(3, devpriv->addon + 4); - /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | - APCI3120_ENABLE_WRITE_TC_INT, + + /* AMCC - enable write complete (DMA) and set FIFO advance */ + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, devpriv->amcc + AMCC_OP_REG_INTCSR); } @@ -493,20 +440,19 @@ static void apci3120_interrupt_dma(int irq, void *d) if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */ devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer; } else { - /* - * restart DMA if is not used double buffering - * ADDED REINITIALISE THE DMA - */ + /* restart DMA if is not using double buffering */ + + /* AMCC - enable transfer count and reset A2P FIFO */ outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, devpriv->amcc + AMCC_OP_REG_AGCSTS); - apci3120_addon_write(dev, APCI3120_ENABLE_TRANSFER_ADD_ON, - APCI3120_ADD_ON_AGCSTS); - /* - * A2P FIFO MANAGEMENT - * A2P fifo reset & transfer control enable - */ - outl(APCI3120_A2P_FIFO_MANAGEMENT, + /* Add-On - enable transfer count and reset A2P FIFO */ + apci3120_addon_write(dev, + AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + AMCC_OP_REG_AGCSTS); + + /* AMCC - enable transfers and reset A2P flags */ + outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, devpriv->amcc + AMCC_OP_REG_MCSR); apci3120_init_dma(dev, dmabuf); @@ -517,9 +463,9 @@ static void apci3120_interrupt_dma(int irq, void *d) * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 */ outw(3, devpriv->addon + 4); - /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | - APCI3120_ENABLE_WRITE_TC_INT, + + /* AMCC - enable write complete (DMA) and set FIFO advance */ + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, devpriv->amcc + AMCC_OP_REG_INTCSR); } } @@ -542,7 +488,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) return IRQ_NONE; } - outl(int_amcc | 0x00ff0000, devpriv->amcc + AMCC_OP_REG_INTCSR); + outl(int_amcc | AINT_INT_MASK, devpriv->amcc + AMCC_OP_REG_INTCSR); if (devpriv->ctrl & APCI3120_CTRL_EXT_TRIG) apci3120_exttrig_enable(dev, false); @@ -604,9 +550,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } if (status & APCI3120_STATUS_AMCC_INT) { - /* Clear Timer Write TC int */ - outl(APCI3120_CLEAR_WRITE_TC_INT, - devpriv->amcc + APCI3120_AMCC_OP_REG_INTCSR); + /* AMCC- Clear write complete interrupt (DMA) */ + outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); apci3120_clr_timer2_interrupt(dev); diff --git a/drivers/staging/comedi/drivers/amcc_s5933.h b/drivers/staging/comedi/drivers/amcc_s5933.h index cf6a497b092c..d4b8c0195bd3 100644 --- a/drivers/staging/comedi/drivers/amcc_s5933.h +++ b/drivers/staging/comedi/drivers/amcc_s5933.h @@ -110,6 +110,8 @@ #define AGCSTS_TCZERO_MASK 0x000000c0 #define AGCSTS_FIFO_ST_MASK 0x0000003f +#define AGCSTS_TC_ENABLE 0x10000000 + #define AGCSTS_RESET_MBFLAGS 0x08000000 #define AGCSTS_RESET_P2A_FIFO 0x04000000 #define AGCSTS_RESET_A2P_FIFO 0x02000000 -- cgit v1.2.3-59-g8ed1b From 0c63bd5aeab4b3bbd1755d18399e541bcdcf8474 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:03 -0700 Subject: staging: comedi: addi_apci_3120: define the Add-On registers Define the add-On registers and bits and remove the "magic" numbers in the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 40 +++++++++------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 5 +++ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a38d7997d516..0e31537b1848 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -44,12 +44,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY * ADDON RELATED ADDITIONS */ /* Constant */ -#define APCI3120_AMWEN_ENABLE 0x02 -#define APCI3120_A2P_FIFO_WRITE_ENABLE 0x01 #define APCI3120_FIFO_ADVANCE_ON_BYTE_2 0x20000000L -#define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE 0x0 -#define APCI3120_DISABLE_BUS_MASTER_ADD_ON 0x0 -#define APCI3120_DISABLE_BUS_MASTER_PCI 0x0 #define APCI3120_START 1 #define APCI3120_STOP 0 @@ -76,11 +71,11 @@ static void apci3120_addon_write(struct comedi_device *dev, /* 16-bit interface for AMCC add-on registers */ - outw(reg, devpriv->addon + 0); - outw(val & 0xffff, devpriv->addon + 2); + outw(reg, devpriv->addon + APCI3120_ADDON_ADDR_REG); + outw(val & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); - outw(reg + 2, devpriv->addon + 0); - outw((val >> 16) & 0xffff, devpriv->addon + 2); + outw(reg + 2, devpriv->addon + APCI3120_ADDON_ADDR_REG); + outw((val >> 16) & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); } static int apci3120_reset(struct comedi_device *dev) @@ -109,7 +104,7 @@ static int apci3120_cancel(struct comedi_device *dev, { struct apci3120_private *devpriv = dev->private; - /* Disable A2P Fifo write and AMWEN signal */ + /* Add-On - disable DMA */ outw(0, devpriv->addon + 4); /* Add-On - disable bus master */ @@ -282,8 +277,9 @@ static void apci3120_setup_dma(struct comedi_device *dev, outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, devpriv->amcc + AMCC_OP_REG_INTCSR); - /* ENABLE A2P FIFO WRITE AND ENABLE AMWEN */ - outw(3, devpriv->addon + 4); + /* Add-On - enable DMA */ + outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA, + devpriv->addon + APCI3120_ADDON_CTRL_REG); /* AMCC- reset A2P flags */ outl(RESET_A2P_FLAGS, devpriv->amcc + AMCC_OP_REG_MCSR); @@ -413,12 +409,10 @@ static void apci3120_interrupt_dma(int irq, void *d) apci3120_init_dma(dev, next_dmabuf); - /* - * To configure A2P FIFO - * ENABLE A2P FIFO WRITE AND ENABLE AMWEN - * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 - */ - outw(3, devpriv->addon + 4); + /* Add-On - enable DMA */ + outw(APCI3120_ADDON_CTRL_AMWEN_ENA | + APCI3120_ADDON_CTRL_A2P_FIFO_ENA, + devpriv->addon + APCI3120_ADDON_CTRL_REG); /* AMCC - enable write complete (DMA) and set FIFO advance */ outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, @@ -457,12 +451,10 @@ static void apci3120_interrupt_dma(int irq, void *d) apci3120_init_dma(dev, dmabuf); - /* - * To configure A2P FIFO - * ENABLE A2P FIFO WRITE AND ENABLE AMWEN - * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 - */ - outw(3, devpriv->addon + 4); + /* Add-On - enable DMA */ + outw(APCI3120_ADDON_CTRL_AMWEN_ENA | + APCI3120_ADDON_CTRL_A2P_FIFO_ENA, + devpriv->addon + APCI3120_ADDON_CTRL_REG); /* AMCC - enable write complete (DMA) and set FIFO advance */ outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 3900a90b9608..699ba76c58ae 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -68,6 +68,11 @@ /* * PCI BAR 2 register map (devpriv->addon) */ +#define APCI3120_ADDON_ADDR_REG 0x00 +#define APCI3120_ADDON_DATA_REG 0x02 +#define APCI3120_ADDON_CTRL_REG 0x04 +#define APCI3120_ADDON_CTRL_AMWEN_ENA (1 << 1) +#define APCI3120_ADDON_CTRL_A2P_FIFO_ENA (1 << 0) /* * Board revisions -- cgit v1.2.3-59-g8ed1b From b7d62cf8123234e2f9eb644fd0be52b48a28075a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:04 -0700 Subject: staging: comedi: addi_apci_3120: move APCI3120_FIFO_ADVANCE_ON_BYTE_2 Move this define to the main driver source and convert it to a bit-shift. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 6 ------ drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 0e31537b1848..474b600400f3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -40,12 +40,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY +----------+-----------+------------------------------------------------+ */ -/* - * ADDON RELATED ADDITIONS - */ -/* Constant */ -#define APCI3120_FIFO_ADVANCE_ON_BYTE_2 0x20000000L - #define APCI3120_START 1 #define APCI3120_STOP 0 diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 699ba76c58ae..7ad7621e74e0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -11,6 +11,7 @@ * PCI BAR 0 register map (devpriv->amcc) * see amcc_s5933.h for register and bit defines */ +#define APCI3120_FIFO_ADVANCE_ON_BYTE_2 (1 << 29) /* * PCI BAR 1 register map (dev->iobase) -- cgit v1.2.3-59-g8ed1b From 994211b6ffe85a92335e199249956a06eac301fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:05 -0700 Subject: staging: comedi: addi_apci_3120: move DMA init code to apci3120_init_dma() Move the common code used to initialize DMA to apci3120_init_dma(). This follows the programming procedure described in the APCI-3120 documentation. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 99 ++++++---------------- 1 file changed, 27 insertions(+), 72 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 474b600400f3..78d3597f0a73 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -193,11 +193,33 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, static void apci3120_init_dma(struct comedi_device *dev, struct apci3120_dmabuf *dmabuf) { + struct apci3120_private *devpriv = dev->private; + + /* AMCC - enable transfer count and reset A2P FIFO */ + outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + devpriv->amcc + AMCC_OP_REG_AGCSTS); + + /* Add-On - enable transfer count and reset A2P FIFO */ + apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + AMCC_OP_REG_AGCSTS); + + /* AMCC - enable transfers and reset A2P flags */ + outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, + devpriv->amcc + AMCC_OP_REG_MCSR); + /* Add-On - DMA start address */ apci3120_addon_write(dev, dmabuf->hw, AMCC_OP_REG_AMWAR); /* Add-On - Number of acquisitions */ apci3120_addon_write(dev, dmabuf->use_size, AMCC_OP_REG_AMWTC); + + /* AMCC - enable write complete (DMA) and set FIFO advance */ + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, + devpriv->amcc + AMCC_OP_REG_INTCSR); + + /* Add-On - enable DMA */ + outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA, + devpriv->addon + APCI3120_ADDON_CTRL_REG); } static void apci3120_setup_dma(struct comedi_device *dev, @@ -248,35 +270,7 @@ static void apci3120_setup_dma(struct comedi_device *dev, dmabuf0->use_size = dmalen0; dmabuf1->use_size = dmalen1; - /* Initialize DMA */ - - /* AMCC- enable transfer count and reset A2P FIFO */ - outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - devpriv->amcc + AMCC_OP_REG_AGCSTS); - - /* Add-On - enable transfer count and reset A2P FIFO */ - apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - AMCC_OP_REG_AGCSTS); - - /* AMCC - enable transfers and reset A2P flags */ - outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, - devpriv->amcc + AMCC_OP_REG_MCSR); - apci3120_init_dma(dev, dmabuf0); - - /* AMCC- reset A2P flags */ - outl(RESET_A2P_FLAGS, devpriv->amcc + AMCC_OP_REG_MCSR); - - /* AMCC - enable write complete (DMA) and set FIFO advance */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, - devpriv->amcc + AMCC_OP_REG_INTCSR); - - /* Add-On - enable DMA */ - outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA, - devpriv->addon + APCI3120_ADDON_CTRL_REG); - - /* AMCC- reset A2P flags */ - outl(RESET_A2P_FLAGS, devpriv->amcc + AMCC_OP_REG_MCSR); } static int apci3120_ai_cmd(struct comedi_device *dev, @@ -386,33 +380,16 @@ static void apci3120_interrupt_dma(int irq, void *d) return; } samplesinbuf = samplesinbuf >> 1; /* number of received samples */ + if (devpriv->b_DmaDoubleBuffer) { - /* switch DMA buffers if is used double buffering */ struct apci3120_dmabuf *next_dmabuf; next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; - /* AMCC - enable transfer count and reset A2P FIFO */ - outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - devpriv->amcc + AMCC_OP_REG_AGCSTS); - - /* Add-On - enable transfer count and reset A2P FIFO */ - apci3120_addon_write(dev, - AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - AMCC_OP_REG_AGCSTS); - + /* start DMA on next buffer */ apci3120_init_dma(dev, next_dmabuf); - - /* Add-On - enable DMA */ - outw(APCI3120_ADDON_CTRL_AMWEN_ENA | - APCI3120_ADDON_CTRL_A2P_FIFO_ENA, - devpriv->addon + APCI3120_ADDON_CTRL_REG); - - /* AMCC - enable write complete (DMA) and set FIFO advance */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, - devpriv->amcc + AMCC_OP_REG_INTCSR); - } + if (samplesinbuf) { comedi_buf_write_samples(s, dmabuf->virt, samplesinbuf); @@ -425,34 +402,12 @@ static void apci3120_interrupt_dma(int irq, void *d) return; } - if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */ + if (devpriv->b_DmaDoubleBuffer) { + /* switch dma buffers for next interrupt */ devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer; } else { /* restart DMA if is not using double buffering */ - - /* AMCC - enable transfer count and reset A2P FIFO */ - outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - devpriv->amcc + AMCC_OP_REG_AGCSTS); - - /* Add-On - enable transfer count and reset A2P FIFO */ - apci3120_addon_write(dev, - AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - AMCC_OP_REG_AGCSTS); - - /* AMCC - enable transfers and reset A2P flags */ - outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, - devpriv->amcc + AMCC_OP_REG_MCSR); - apci3120_init_dma(dev, dmabuf); - - /* Add-On - enable DMA */ - outw(APCI3120_ADDON_CTRL_AMWEN_ENA | - APCI3120_ADDON_CTRL_A2P_FIFO_ENA, - devpriv->addon + APCI3120_ADDON_CTRL_REG); - - /* AMCC - enable write complete (DMA) and set FIFO advance */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, - devpriv->amcc + AMCC_OP_REG_INTCSR); } } -- cgit v1.2.3-59-g8ed1b From 884218c5a3ab3ebc522b53054019844dcac5fca7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:06 -0700 Subject: staging: comedi: addi_apci_3120: tidy up apci3120_reset() This function is only called during the attach of the driver and it's called after the private data has been kzalloc'd. There is no reason to clear any of the private data members. Simplify the function by just writing '0' to the necessary registers to disable all the interrupt sources and stop the timers. For aesthetics, change the return type to void. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 78d3597f0a73..f5948fd8b421 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -72,25 +72,16 @@ static void apci3120_addon_write(struct comedi_device *dev, outw((val >> 16) & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); } -static int apci3120_reset(struct comedi_device *dev) +static void apci3120_reset(struct comedi_device *dev) { - struct apci3120_private *devpriv = dev->private; - - /* variables used in timer subdevice */ - devpriv->b_Timer2Mode = 0; - devpriv->b_Timer2Interrupt = 0; - - /* Disable all interrupts, watchdog for the anolog output */ - devpriv->mode = 0; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + /* disable all interrupt sources */ + outb(0, dev->iobase + APCI3120_MODE_REG); /* disable all counters, ext trigger, and reset scan */ - devpriv->ctrl = 0; - outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); + outw(0, dev->iobase + APCI3120_CTRL_REG); + /* clear interrupt status */ inw(dev->iobase + APCI3120_STATUS_REG); - - return 0; } static int apci3120_cancel(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From ca26b42d4f8c5d9be2a4cc2bf66a19ff71ac036e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:07 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_reset() to driver source Move this function from the included hwdrv_apci31210.c source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 12 ------------ drivers/staging/comedi/drivers/addi_apci_3120.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index f5948fd8b421..c310cf32b1d8 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -72,18 +72,6 @@ static void apci3120_addon_write(struct comedi_device *dev, outw((val >> 16) & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); } -static void apci3120_reset(struct comedi_device *dev) -{ - /* disable all interrupt sources */ - outb(0, dev->iobase + APCI3120_MODE_REG); - - /* disable all counters, ext trigger, and reset scan */ - outw(0, dev->iobase + APCI3120_CTRL_REG); - - /* clear interrupt status */ - inw(dev->iobase + APCI3120_STATUS_REG); -} - static int apci3120_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 7ad7621e74e0..79a96acc8b63 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -491,6 +491,18 @@ static void apci3120_dma_free(struct comedi_device *dev) } } +static void apci3120_reset(struct comedi_device *dev) +{ + /* disable all interrupt sources */ + outb(0, dev->iobase + APCI3120_MODE_REG); + + /* disable all counters, ext trigger, and reset scan */ + outw(0, dev->iobase + APCI3120_CTRL_REG); + + /* clear interrupt status */ + inw(dev->iobase + APCI3120_STATUS_REG); +} + static int apci3120_auto_attach(struct comedi_device *dev, unsigned long context) { -- cgit v1.2.3-59-g8ed1b From e6539bbc17843b37524fbb419344653bd74b5961 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:08 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'us_UseDma' Rename this CamelCase member of the private data and convert 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/addi-data/hwdrv_apci3120.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index c310cf32b1d8..8327e2c26084 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -293,7 +293,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev, apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); apci3120_timer_write(dev, 0, divisor); - if (devpriv->us_UseDma) { + if (devpriv->use_dma) { apci3120_setup_dma(dev, s); } else { devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 79a96acc8b63..00caa1059db1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -129,7 +129,7 @@ struct apci3120_private { unsigned long amcc; unsigned long addon; unsigned int osc_base; - unsigned short us_UseDma; + unsigned int use_dma:1; unsigned char b_DmaDoubleBuffer; unsigned int ui_DmaActualBuffer; struct apci3120_dmabuf dmabuf[2]; @@ -467,7 +467,7 @@ static void apci3120_dma_alloc(struct comedi_device *dev) dmabuf->size = PAGE_SIZE << order; if (i == 0) - devpriv->us_UseDma = 1; + devpriv->use_dma = 1; if (i == 1) devpriv->b_DmaDoubleBuffer = 1; } -- cgit v1.2.3-59-g8ed1b From d65d73ff5e2973274cc216fe37adc801c900dd20 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:09 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'b_DmaDoubleBuffer' Rename this CamelCase member of the private data and convert 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/addi-data/hwdrv_apci3120.c | 4 ++-- drivers/staging/comedi/drivers/addi_apci_3120.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 8327e2c26084..02755066debe 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -360,7 +360,7 @@ static void apci3120_interrupt_dma(int irq, void *d) } samplesinbuf = samplesinbuf >> 1; /* number of received samples */ - if (devpriv->b_DmaDoubleBuffer) { + if (devpriv->use_double_buffer) { struct apci3120_dmabuf *next_dmabuf; next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; @@ -381,7 +381,7 @@ static void apci3120_interrupt_dma(int irq, void *d) return; } - if (devpriv->b_DmaDoubleBuffer) { + if (devpriv->use_double_buffer) { /* switch dma buffers for next interrupt */ devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer; } else { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 00caa1059db1..f76884559752 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -130,7 +130,7 @@ struct apci3120_private { unsigned long addon; unsigned int osc_base; unsigned int use_dma:1; - unsigned char b_DmaDoubleBuffer; + unsigned int use_double_buffer:1; unsigned int ui_DmaActualBuffer; struct apci3120_dmabuf dmabuf[2]; unsigned char do_bits; @@ -469,7 +469,7 @@ static void apci3120_dma_alloc(struct comedi_device *dev) if (i == 0) devpriv->use_dma = 1; if (i == 1) - devpriv->b_DmaDoubleBuffer = 1; + devpriv->use_double_buffer = 1; } } -- cgit v1.2.3-59-g8ed1b From d895948eb850131f83f18a2bf2d3c5e53486f7d7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:10 -0700 Subject: staging: comedi: addi_apci_3120: rename private data 'ui_DmaActualBuffer' Rename this CamelCase member of the private data and convert 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/addi-data/hwdrv_apci3120.c | 10 +++++----- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 02755066debe..ec488d163587 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -95,7 +95,7 @@ static int apci3120_cancel(struct comedi_device *dev, outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); inw(dev->iobase + APCI3120_STATUS_REG); - devpriv->ui_DmaActualBuffer = 0; + devpriv->cur_dmabuf = 0; return 0; } @@ -266,7 +266,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* AMCC- Clear write complete interrupt (DMA) */ outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); - devpriv->ui_DmaActualBuffer = 0; + devpriv->cur_dmabuf = 0; /* load chanlist for command scan */ apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); @@ -347,7 +347,7 @@ static void apci3120_interrupt_dma(int irq, void *d) struct apci3120_dmabuf *dmabuf; unsigned int samplesinbuf; - dmabuf = &devpriv->dmabuf[devpriv->ui_DmaActualBuffer]; + dmabuf = &devpriv->dmabuf[devpriv->cur_dmabuf]; samplesinbuf = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC); @@ -363,7 +363,7 @@ static void apci3120_interrupt_dma(int irq, void *d) if (devpriv->use_double_buffer) { struct apci3120_dmabuf *next_dmabuf; - next_dmabuf = &devpriv->dmabuf[1 - devpriv->ui_DmaActualBuffer]; + next_dmabuf = &devpriv->dmabuf[!devpriv->cur_dmabuf]; /* start DMA on next buffer */ apci3120_init_dma(dev, next_dmabuf); @@ -383,7 +383,7 @@ static void apci3120_interrupt_dma(int irq, void *d) if (devpriv->use_double_buffer) { /* switch dma buffers for next interrupt */ - devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer; + devpriv->cur_dmabuf = !devpriv->cur_dmabuf; } else { /* restart DMA if is not using double buffering */ apci3120_init_dma(dev, dmabuf); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index f76884559752..eec0cdba1206 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -131,7 +131,7 @@ struct apci3120_private { unsigned int osc_base; unsigned int use_dma:1; unsigned int use_double_buffer:1; - unsigned int ui_DmaActualBuffer; + unsigned int cur_dmabuf:1; struct apci3120_dmabuf dmabuf[2]; unsigned char do_bits; unsigned char timer_mode; -- cgit v1.2.3-59-g8ed1b From 4646364cc8e6346776828155ab817e254194df62 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:11 -0700 Subject: staging: comedi: addi_apci_3120: don't use timer 2 to count scans Timer 2 can be used to count the number of scans when the cmd->stop_src is TRIG_COUNT. Unfortunately that timer can also be used by userspace and this breaks the async command. Timer 2 also only works for counting the number of scans when DMA is not used. The number of scans is counted by the core using the private data membmer 'scans_done'. Use that to detect the End-Of-Scan for both DMA and none DMA modes. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 51 ++++++---------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index ec488d163587..10ab6d89a6d5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -293,35 +293,11 @@ static int apci3120_ai_cmd(struct comedi_device *dev, apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); apci3120_timer_write(dev, 0, divisor); - if (devpriv->use_dma) { + if (devpriv->use_dma) apci3120_setup_dma(dev, s); - } else { + else devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - if (cmd->stop_src == TRIG_COUNT) { - /* - * Timer 2 is used in MODE0 (hardware retriggerable - * one-shot) to count the number of scans. - * - * NOTE: not sure about the -2 value - */ - apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE0); - apci3120_timer_write(dev, 2, cmd->stop_arg - 2); - - apci3120_clr_timer2_interrupt(dev); - - apci3120_timer_enable(dev, 2, true); - - /* configure Timer 2 For counting EOS */ - devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER | - APCI3120_MODE_TIMER2_CLK_EOS | - APCI3120_MODE_TIMER2_IRQ_ENA; - - devpriv->b_Timer2Mode = APCI3120_COUNTER; - devpriv->b_Timer2Interrupt = 1; - } - } - /* set mode to enable acquisition */ outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); @@ -343,7 +319,8 @@ static void apci3120_interrupt_dma(int irq, void *d) struct comedi_device *dev = d; struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; struct apci3120_dmabuf *dmabuf; unsigned int samplesinbuf; @@ -373,13 +350,12 @@ static void apci3120_interrupt_dma(int irq, void *d) comedi_buf_write_samples(s, dmabuf->virt, samplesinbuf); if (!(cmd->flags & CMDF_WAKE_EOS)) - s->async->events |= COMEDI_CB_EOS; + async->events |= COMEDI_CB_EOS; } - if (cmd->stop_src == TRIG_COUNT && - s->async->scans_done >= cmd->stop_arg) { - s->async->events |= COMEDI_CB_EOA; + + if ((async->events & COMEDI_CB_CANCEL_MASK) || + (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)) return; - } if (devpriv->use_double_buffer) { /* switch dma buffers for next interrupt */ @@ -395,7 +371,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) struct comedi_device *dev = d; struct apci3120_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; unsigned int status; unsigned int int_amcc; @@ -442,10 +419,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (status & APCI3120_STATUS_TIMER2_INT) { switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: - devpriv->mode &= ~APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - s->async->events |= COMEDI_CB_EOA; break; case APCI3120_TIMER: @@ -478,6 +451,10 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) /* do some data transfer */ apci3120_interrupt_dma(irq, d); } + + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; + comedi_handle_events(dev, s); return IRQ_HANDLED; -- cgit v1.2.3-59-g8ed1b From ecaf4c41da4ace751f71fbb3df611a6167425b6e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:12 -0700 Subject: staging: comedi: addi_apci_3120: define the AI FIFO register Define the offset for the analog input FIFO register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +--- drivers/staging/comedi/drivers/addi_apci_3120.c | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 10ab6d89a6d5..703e4f9b1ba8 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -43,8 +43,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_START 1 #define APCI3120_STOP 0 -#define APCI3120_RD_FIFO 0x00 - /* software trigger dummy register */ #define APCI3120_START_CONVERSION 0x02 @@ -408,7 +406,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) int i; for (i = 0; i < cmd->chanlist_len; i++) { - val = inw(dev->iobase + 0); + val = inw(dev->iobase + APCI3120_AI_FIFO_REG); comedi_buf_write_samples(s, &val, 1); } diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index eec0cdba1206..322640ee91b5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -16,6 +16,7 @@ /* * PCI BAR 1 register map (dev->iobase) */ +#define APCI3120_AI_FIFO_REG 0x00 #define APCI3120_CTRL_REG 0x00 #define APCI3120_CTRL_EXT_TRIG (1 << 15) #define APCI3120_CTRL_GATE(x) (1 << (12 + (x))) @@ -370,7 +371,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, if (ret) return ret; - data[i] = inw(dev->iobase + 0); + data[i] = inw(dev->iobase + APCI3120_AI_FIFO_REG); } return insn->n; -- cgit v1.2.3-59-g8ed1b From dcb5e2c4dfa66aea823e37956ed0389491ed35ab Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:13 -0700 Subject: staging: comedi: addi_apci_3120: define the AI software trigger register Define the offset for the analog input software trigger register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 --- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 703e4f9b1ba8..0c9a6550f644 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -43,9 +43,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY #define APCI3120_START 1 #define APCI3120_STOP 0 -/* software trigger dummy register */ -#define APCI3120_START_CONVERSION 0x02 - /* TIMER DEFINE */ #define APCI3120_QUARTZ_A 70 #define APCI3120_QUARTZ_B 50 diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 322640ee91b5..ec2077cb68f0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -22,6 +22,7 @@ #define APCI3120_CTRL_GATE(x) (1 << (12 + (x))) #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) +#define APCI3120_AI_SOFTTRIG_REG 0x02 #define APCI3120_STATUS_REG 0x02 #define APCI3120_STATUS_EOC_INT (1 << 15) #define APCI3120_STATUS_AMCC_INT (1 << 14) -- cgit v1.2.3-59-g8ed1b From 15cf0617c0186c24f8d6ff7fcf2bf505878f351e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:14 -0700 Subject: staging: comedi: addi_apci_3120: fix timer (*insn_read) The timer subdevice in this driver does not follow the comedi API. Fix the (*insn_read) to work correctly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 35 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 15 +++++++++- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 0c9a6550f644..7c6dec1aaa45 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -608,38 +608,3 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, return insn->n; } - -/* - * Read the Timer value - * - * for Timer: data[0]= Timer constant - * - * for watchdog: data[0] = 0 (still running) - * = 1 (run down) - */ -static int apci3120_read_insn_timer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3120_private *devpriv = dev->private; - unsigned int status; - - if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) - && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { - dev_err(dev->class_dev, "timer2 not configured\n"); - } - if (devpriv->b_Timer2Mode == APCI3120_TIMER) { - data[0] = apci3120_timer_read(dev, 2); - } else { - /* Read watch dog status */ - status = inw(dev->iobase + APCI3120_STATUS_REG); - if (status & APCI3120_STATUS_TIMER2_INT) { - apci3120_clr_timer2_interrupt(dev); - data[0] = 1; - } else { - data[0] = 0; - } - } - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ec2077cb68f0..c67c10fc7d66 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -447,6 +447,19 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, return insn->n; } +static int apci3120_timer_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + int i; + + for (i = 0; i < insn->n; i++) + data[i] = apci3120_timer_read(dev, 2); + + return insn->n; +} + static void apci3120_dma_alloc(struct comedi_device *dev) { struct apci3120_private *devpriv = dev->private; @@ -618,8 +631,8 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->n_chan = 1; s->maxdata = 0x00ffffff; s->insn_write = apci3120_write_insn_timer; - s->insn_read = apci3120_read_insn_timer; s->insn_config = apci3120_config_insn_timer; + s->insn_read = apci3120_timer_insn_read; return 0; } -- cgit v1.2.3-59-g8ed1b From 6d31274053716b4cac60a6de7eb40aba8adeb9d5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:15 -0700 Subject: staging: comedi: addi_apci_3120: fix timer (*insn_config) The timer subdevice in this driver does not follow the comedi API. Fix the (*insn_config) to correctly arm, disarm, set the mode, and get the status of the timer. Remove the unnecessary, and broken, (*insn_write). The new (*insn_config) does not enable the interrupt for timer 2. Remove the interrupt support code for the timer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 197 +-------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 85 ++++++++- 2 files changed, 83 insertions(+), 199 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 7c6dec1aaa45..b6507427712c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -40,19 +40,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY +----------+-----------+------------------------------------------------+ */ -#define APCI3120_START 1 -#define APCI3120_STOP 0 - -/* TIMER DEFINE */ -#define APCI3120_QUARTZ_A 70 -#define APCI3120_QUARTZ_B 50 -#define APCI3120_TIMER 1 -#define APCI3120_WATCHDOG 2 -#define APCI3120_TIMER_DISABLE 0 -#define APCI3120_TIMER_ENABLE 1 - -#define APCI3120_COUNTER 3 - static void apci3120_addon_write(struct comedi_device *dev, unsigned int val, unsigned int reg) { @@ -385,8 +372,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) if (devpriv->ctrl & APCI3120_CTRL_EXT_TRIG) apci3120_exttrig_enable(dev, false); - apci3120_clr_timer2_interrupt(dev); - if (int_amcc & MASTER_ABORT_INT) dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n"); if (int_amcc & TARGET_ABORT_INT) @@ -412,28 +397,10 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) } if (status & APCI3120_STATUS_TIMER2_INT) { - switch (devpriv->b_Timer2Mode) { - case APCI3120_COUNTER: - break; - - case APCI3120_TIMER: - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, 0); - break; - - case APCI3120_WATCHDOG: - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, 0); - break; - - default: - /* disable Timer Interrupt */ - devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - } - + /* + * for safety... + * timer2 interrupts are not enabled in the driver + */ apci3120_clr_timer2_interrupt(dev); } @@ -441,8 +408,6 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) /* AMCC- Clear write complete interrupt (DMA) */ outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); - apci3120_clr_timer2_interrupt(dev); - /* do some data transfer */ apci3120_interrupt_dma(irq, d); } @@ -454,157 +419,3 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) return IRQ_HANDLED; } - -/* - * Configure Timer 2 - * - * data[0] = TIMER configure as timer - * = WATCHDOG configure as watchdog - * data[1] = Timer constant - * data[2] = Timer2 interrupt (1)enable or(0) disable - */ -static int apci3120_config_insn_timer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3120_private *devpriv = dev->private; - unsigned int divisor; - - if (!data[1]) - dev_err(dev->class_dev, "No timer constant!\n"); - - devpriv->b_Timer2Interrupt = (unsigned char) data[2]; /* save info whether to enable or disable interrupt */ - - divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); - - apci3120_timer_enable(dev, 2, false); - - /* disable timer 2 interrupt and reset operation mode (timer) */ - devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA & - ~APCI3120_MODE_TIMER2_AS_MASK; - - /* Disable Eoc and Eos Interrupts */ - devpriv->mode &= ~APCI3120_MODE_EOC_IRQ_ENA & - ~APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - if (data[0] == APCI3120_TIMER) { /* initialize timer */ - /* Set the Timer 2 in mode 2(Timer) */ - apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE2); - - /* Set timer 2 delay */ - apci3120_timer_write(dev, 2, divisor); - - /* timer2 in Timer mode enabled */ - devpriv->b_Timer2Mode = APCI3120_TIMER; - } else { /* Initialize Watch dog */ - /* Set the Timer 2 in mode 5(Watchdog) */ - apci3120_timer_set_mode(dev, 2, APCI3120_TIMER_MODE5); - - /* Set timer 2 delay */ - apci3120_timer_write(dev, 2, divisor); - - /* watchdog enabled */ - devpriv->b_Timer2Mode = APCI3120_WATCHDOG; - - } - - return insn->n; - -} - -/* - * To start and stop the timer - * - * data[0] = 1 (start) - * = 0 (stop) - * = 2 (write new value) - * data[1] = new value - * - * devpriv->b_Timer2Mode = 0 DISABLE - * = 1 Timer - * = 2 Watch dog - */ -static int apci3120_write_insn_timer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3120_private *devpriv = dev->private; - unsigned int divisor; - - if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG) - && (devpriv->b_Timer2Mode != APCI3120_TIMER)) { - dev_err(dev->class_dev, "timer2 not configured\n"); - return -EINVAL; - } - - if (data[0] == 2) { /* write new value */ - if (devpriv->b_Timer2Mode != APCI3120_TIMER) { - dev_err(dev->class_dev, - "timer2 not configured in TIMER MODE\n"); - return -EINVAL; - } - } - - switch (data[0]) { - case APCI3120_START: - apci3120_clr_timer2_interrupt(dev); - - if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ - /* Enable Timer */ - devpriv->mode &= 0x0b; - devpriv->mode |= APCI3120_MODE_TIMER2_AS_TIMER; - } else { /* start watch dog */ - /* Enable WatchDog */ - devpriv->mode &= 0x0b; - devpriv->mode |= APCI3120_MODE_TIMER2_AS_WDOG; - } - - /* enable disable interrupt */ - if (devpriv->b_Timer2Interrupt) { - devpriv->mode |= APCI3120_MODE_TIMER2_IRQ_ENA; - - /* save the task structure to pass info to user */ - devpriv->tsk_Current = current; - } else { - devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA; - } - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - /* start timer */ - if (devpriv->b_Timer2Mode == APCI3120_TIMER) - apci3120_timer_enable(dev, 2, true); - break; - - case APCI3120_STOP: - /* disable timer 2 interrupt and reset operation mode (timer) */ - devpriv->mode &= ~APCI3120_MODE_TIMER2_IRQ_ENA & - ~APCI3120_MODE_TIMER2_AS_MASK; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - apci3120_timer_enable(dev, 2, false); - - apci3120_clr_timer2_interrupt(dev); - break; - - case 2: /* write new value to Timer */ - if (devpriv->b_Timer2Mode != APCI3120_TIMER) { - dev_err(dev->class_dev, - "timer2 not configured in TIMER MODE\n"); - return -EINVAL; - } - - divisor = apci3120_ns_to_timer(dev, 2, data[1], - CMDF_ROUND_DOWN); - - /* Set timer 2 delay */ - apci3120_timer_write(dev, 2, divisor); - break; - default: - return -EINVAL; /* Not a valid input */ - } - - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index c67c10fc7d66..806f756685a8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -139,9 +139,6 @@ struct apci3120_private { unsigned char timer_mode; unsigned char mode; unsigned short ctrl; - unsigned char b_Timer2Mode; - unsigned char b_Timer2Interrupt; - struct task_struct *tsk_Current; }; /* @@ -447,6 +444,83 @@ static int apci3120_do_insn_bits(struct comedi_device *dev, return insn->n; } +static int apci3120_timer_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci3120_private *devpriv = dev->private; + unsigned int divisor; + unsigned int status; + unsigned int mode; + unsigned int timer_mode; + + switch (data[0]) { + case INSN_CONFIG_ARM: + apci3120_clr_timer2_interrupt(dev); + divisor = apci3120_ns_to_timer(dev, 2, data[1], + CMDF_ROUND_DOWN); + apci3120_timer_write(dev, 2, divisor); + apci3120_timer_enable(dev, 2, true); + break; + + case INSN_CONFIG_DISARM: + apci3120_timer_enable(dev, 2, false); + apci3120_clr_timer2_interrupt(dev); + break; + + case INSN_CONFIG_GET_COUNTER_STATUS: + data[1] = 0; + data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING | + COMEDI_COUNTER_TERMINAL_COUNT; + + if (devpriv->ctrl & APCI3120_CTRL_GATE(2)) { + data[1] |= COMEDI_COUNTER_ARMED; + data[1] |= COMEDI_COUNTER_COUNTING; + } + status = inw(dev->iobase + APCI3120_STATUS_REG); + if (status & APCI3120_STATUS_TIMER2_INT) { + data[1] &= ~COMEDI_COUNTER_COUNTING; + data[1] |= COMEDI_COUNTER_TERMINAL_COUNT; + } + break; + + case INSN_CONFIG_SET_COUNTER_MODE: + switch (data[1]) { + case I8254_MODE0: + mode = APCI3120_MODE_TIMER2_AS_COUNTER; + timer_mode = APCI3120_TIMER_MODE0; + break; + case I8254_MODE2: + mode = APCI3120_MODE_TIMER2_AS_TIMER; + timer_mode = APCI3120_TIMER_MODE2; + break; + case I8254_MODE4: + mode = APCI3120_MODE_TIMER2_AS_TIMER; + timer_mode = APCI3120_TIMER_MODE4; + break; + case I8254_MODE5: + mode = APCI3120_MODE_TIMER2_AS_WDOG; + timer_mode = APCI3120_TIMER_MODE5; + break; + default: + return -EINVAL; + } + apci3120_timer_enable(dev, 2, false); + apci3120_clr_timer2_interrupt(dev); + apci3120_timer_set_mode(dev, 2, timer_mode); + devpriv->mode &= ~APCI3120_MODE_TIMER2_AS_MASK; + devpriv->mode |= mode; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + break; + + default: + return -EINVAL; + } + + return insn->n; +} + static int apci3120_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -627,11 +701,10 @@ static int apci3120_auto_attach(struct comedi_device *dev, /* Timer subdevice */ s = &dev->subdevices[4]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_READABLE; s->n_chan = 1; s->maxdata = 0x00ffffff; - s->insn_write = apci3120_write_insn_timer; - s->insn_config = apci3120_config_insn_timer; + s->insn_config = apci3120_timer_insn_config; s->insn_read = apci3120_timer_insn_read; return 0; -- cgit v1.2.3-59-g8ed1b From 38417cc46f50dcaf9d2f1e6bfd9ff0b3531a9eba Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:16 -0700 Subject: staging: comedi: addi_apci_3120: fix cmd->convert_arg vaildation Regardless of the cmd->scan_begin_src, the minimum cmd->convert_arg value is 10000 (10us). Fix the validation in apci3120_ai_cmdtest(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b6507427712c..3ee1ecd72406 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -118,13 +118,8 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 100000); - if (cmd->scan_begin_src == TRIG_TIMER) { - if (cmd->convert_arg) - err |= cfc_check_trigger_arg_min(&cmd->convert_arg, - 10000); - } else { - err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); - } + /* minimum conversion time per sample is 10us */ + err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); -- cgit v1.2.3-59-g8ed1b From d32fc427e3b39fca4f14c9783969355c07dfdb51 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:17 -0700 Subject: staging: comedi: addi_apci_3120: move AI (*do_cmdtest) to main driver Move apci3120_ai_cmdtest() from the included source file to the main driver source file. Tidy up Step 4 a bit during the move. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 64 --------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 67 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 64 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3ee1ecd72406..3f401760aac5 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -82,70 +82,6 @@ static int apci3120_cancel(struct comedi_device *dev, return 0; } -static int apci3120_ai_cmdtest(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_cmd *cmd) -{ - int err = 0; - - /* Step 1 : check if triggers are trivially valid */ - - err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT); - err |= cfc_check_trigger_src(&cmd->scan_begin_src, - TRIG_TIMER | TRIG_FOLLOW); - err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER); - 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->start_src); - err |= cfc_check_trigger_is_unique(cmd->scan_begin_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); - - if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ - err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 100000); - - /* minimum conversion time per sample is 10us */ - err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); - - err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); - - if (cmd->stop_src == TRIG_COUNT) - err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); - 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 && - cmd->scan_begin_arg < cmd->convert_arg * cmd->scan_end_arg) { - cmd->scan_begin_arg = cmd->convert_arg * cmd->scan_end_arg; - err |= -EINVAL; - } - - if (err) - return 4; - - return 0; -} - static void apci3120_init_dma(struct comedi_device *dev, struct apci3120_dmabuf *dmabuf) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 806f756685a8..da7da56a42f6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -318,6 +318,73 @@ static void apci3120_set_chanlist(struct comedi_device *dev, #include "addi-data/hwdrv_apci3120.c" +static int apci3120_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int arg; + int err = 0; + + /* Step 1 : check if triggers are trivially valid */ + + err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT); + err |= cfc_check_trigger_src(&cmd->scan_begin_src, + TRIG_TIMER | TRIG_FOLLOW); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER); + 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->start_src); + err |= cfc_check_trigger_is_unique(cmd->scan_begin_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); + + if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 100000); + + /* minimum conversion time per sample is 10us */ + err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); + + err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + + if (cmd->stop_src == TRIG_COUNT) + err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); + 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) { + /* scan begin must be larger than the scan time */ + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg); + } + + if (err) + return 4; + + /* Step 5: check channel list if it exists */ + + return 0; +} + static int apci3120_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, -- cgit v1.2.3-59-g8ed1b From d8cdd97c8f546fbdb13f9f1dd609b94c5008b53a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:18 -0700 Subject: staging: comedi: addi_apci_3120: add copyright information Remove the copyright info from the included source file and add it to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 42 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 23 ++++++++++++ 2 files changed, 23 insertions(+), 42 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3f401760aac5..3cbcc0c9fb48 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1,45 +1,3 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -@endverbatim -*/ -/* - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstrasse 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : APCI-3120 | Compiler : GCC | - | Module name : hwdrv_apci3120.c| Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description :APCI3120 Module. Hardware abstraction Layer for APCI3120| - +-----------------------------------------------------------------------+ - | UPDATE'S | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - | | | | - +----------+-----------+------------------------------------------------+ -*/ - static void apci3120_addon_write(struct comedi_device *dev, unsigned int val, unsigned int reg) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index da7da56a42f6..0591f8b67909 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1,3 +1,26 @@ +/* + * addi_apci_3120.c + * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. + * + * ADDI-DATA GmbH + * Dieselstrasse 3 + * D-77833 Ottersweier + * Tel: +19(0)7223/9493-0 + * Fax: +49(0)7223/9493-92 + * http://www.addi-data.com + * info@addi-data.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + #include #include #include -- cgit v1.2.3-59-g8ed1b From 4ba10fc04a0bd461b31cd5032207cb38304d7b63 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:19 -0700 Subject: staging: comedi: addi_apci_3120: remove unnecessary include The header is not needed by this driver. Remove the include. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 0591f8b67909..4f1ec0bc645f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -23,7 +23,6 @@ #include #include -#include #include #include "../comedidev.h" -- cgit v1.2.3-59-g8ed1b From 0b7defa70227f7c7f313e0ea4f0eeb88c5de79a3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:20 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_addon_write() to driver Move this function from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 14 -------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 3cbcc0c9fb48..1799833cde32 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1,17 +1,3 @@ -static void apci3120_addon_write(struct comedi_device *dev, - unsigned int val, unsigned int reg) -{ - struct apci3120_private *devpriv = dev->private; - - /* 16-bit interface for AMCC add-on registers */ - - outw(reg, devpriv->addon + APCI3120_ADDON_ADDR_REG); - outw(val & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); - - outw(reg + 2, devpriv->addon + APCI3120_ADDON_ADDR_REG); - outw((val >> 16) & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); -} - static int apci3120_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 4f1ec0bc645f..dab81cbe79da 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -163,6 +163,20 @@ struct apci3120_private { unsigned short ctrl; }; +static void apci3120_addon_write(struct comedi_device *dev, + unsigned int val, unsigned int reg) +{ + struct apci3120_private *devpriv = dev->private; + + /* 16-bit interface for AMCC add-on registers */ + + outw(reg, devpriv->addon + APCI3120_ADDON_ADDR_REG); + outw(val & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); + + outw(reg + 2, devpriv->addon + APCI3120_ADDON_ADDR_REG); + outw((val >> 16) & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); +} + /* * There are three timers on the board. They all use the same base * clock with a fixed prescaler for each timer. The base clock used -- cgit v1.2.3-59-g8ed1b From ee844c51ef0451ff7646a075710b9646e943f1e7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:21 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_init_dma() to driver Move this function from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 32 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 32 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 1799833cde32..a241368d79e1 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -26,38 +26,6 @@ static int apci3120_cancel(struct comedi_device *dev, return 0; } -static void apci3120_init_dma(struct comedi_device *dev, - struct apci3120_dmabuf *dmabuf) -{ - struct apci3120_private *devpriv = dev->private; - - /* AMCC - enable transfer count and reset A2P FIFO */ - outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - devpriv->amcc + AMCC_OP_REG_AGCSTS); - - /* Add-On - enable transfer count and reset A2P FIFO */ - apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, - AMCC_OP_REG_AGCSTS); - - /* AMCC - enable transfers and reset A2P flags */ - outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, - devpriv->amcc + AMCC_OP_REG_MCSR); - - /* Add-On - DMA start address */ - apci3120_addon_write(dev, dmabuf->hw, AMCC_OP_REG_AMWAR); - - /* Add-On - Number of acquisitions */ - apci3120_addon_write(dev, dmabuf->use_size, AMCC_OP_REG_AMWTC); - - /* AMCC - enable write complete (DMA) and set FIFO advance */ - outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, - devpriv->amcc + AMCC_OP_REG_INTCSR); - - /* Add-On - enable DMA */ - outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA, - devpriv->addon + APCI3120_ADDON_CTRL_REG); -} - static void apci3120_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index dab81cbe79da..d66e91084bf7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -177,6 +177,38 @@ static void apci3120_addon_write(struct comedi_device *dev, outw((val >> 16) & 0xffff, devpriv->addon + APCI3120_ADDON_DATA_REG); } +static void apci3120_init_dma(struct comedi_device *dev, + struct apci3120_dmabuf *dmabuf) +{ + struct apci3120_private *devpriv = dev->private; + + /* AMCC - enable transfer count and reset A2P FIFO */ + outl(AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + devpriv->amcc + AMCC_OP_REG_AGCSTS); + + /* Add-On - enable transfer count and reset A2P FIFO */ + apci3120_addon_write(dev, AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO, + AMCC_OP_REG_AGCSTS); + + /* AMCC - enable transfers and reset A2P flags */ + outl(RESET_A2P_FLAGS | EN_A2P_TRANSFERS, + devpriv->amcc + AMCC_OP_REG_MCSR); + + /* Add-On - DMA start address */ + apci3120_addon_write(dev, dmabuf->hw, AMCC_OP_REG_AMWAR); + + /* Add-On - Number of acquisitions */ + apci3120_addon_write(dev, dmabuf->use_size, AMCC_OP_REG_AMWTC); + + /* AMCC - enable write complete (DMA) and set FIFO advance */ + outl(APCI3120_FIFO_ADVANCE_ON_BYTE_2 | AINT_WRITE_COMPL, + devpriv->amcc + AMCC_OP_REG_INTCSR); + + /* Add-On - enable DMA */ + outw(APCI3120_ADDON_CTRL_AMWEN_ENA | APCI3120_ADDON_CTRL_A2P_FIFO_ENA, + devpriv->addon + APCI3120_ADDON_CTRL_REG); +} + /* * There are three timers on the board. They all use the same base * clock with a fixed prescaler for each timer. The base clock used -- cgit v1.2.3-59-g8ed1b From 45062492281d2ce9fba14dc700add6abec3e5726 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:22 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_setup_dma() to driver Move this function from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 51 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 51 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a241368d79e1..771ac870eb87 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -26,57 +26,6 @@ static int apci3120_cancel(struct comedi_device *dev, return 0; } -static void apci3120_setup_dma(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct apci3120_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0]; - struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1]; - unsigned int dmalen0 = dmabuf0->size; - unsigned int dmalen1 = dmabuf1->size; - unsigned int scan_bytes; - - scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg); - - if (cmd->stop_src == TRIG_COUNT) { - /* - * Must we fill full first buffer? And must we fill - * full second buffer when first is once filled? - */ - if (dmalen0 > (cmd->stop_arg * scan_bytes)) - dmalen0 = cmd->stop_arg * scan_bytes; - else if (dmalen1 > (cmd->stop_arg * scan_bytes - dmalen0)) - dmalen1 = cmd->stop_arg * scan_bytes - dmalen0; - } - - if (cmd->flags & CMDF_WAKE_EOS) { - /* don't we want wake up every scan? */ - if (dmalen0 > scan_bytes) { - dmalen0 = scan_bytes; - if (cmd->scan_end_arg & 1) - dmalen0 += 2; - } - if (dmalen1 > scan_bytes) { - dmalen1 = scan_bytes; - if (cmd->scan_end_arg & 1) - dmalen1 -= 2; - if (dmalen1 < 4) - dmalen1 = 4; - } - } else { - /* isn't output buff smaller that our DMA buff? */ - if (dmalen0 > s->async->prealloc_bufsz) - dmalen0 = s->async->prealloc_bufsz; - if (dmalen1 > s->async->prealloc_bufsz) - dmalen1 = s->async->prealloc_bufsz; - } - dmabuf0->use_size = dmalen0; - dmabuf1->use_size = dmalen1; - - apci3120_init_dma(dev, dmabuf0); -} - static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index d66e91084bf7..b5ac5b8cf05f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -209,6 +209,57 @@ static void apci3120_init_dma(struct comedi_device *dev, devpriv->addon + APCI3120_ADDON_CTRL_REG); } +static void apci3120_setup_dma(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct apci3120_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + struct apci3120_dmabuf *dmabuf0 = &devpriv->dmabuf[0]; + struct apci3120_dmabuf *dmabuf1 = &devpriv->dmabuf[1]; + unsigned int dmalen0 = dmabuf0->size; + unsigned int dmalen1 = dmabuf1->size; + unsigned int scan_bytes; + + scan_bytes = comedi_samples_to_bytes(s, cmd->scan_end_arg); + + if (cmd->stop_src == TRIG_COUNT) { + /* + * Must we fill full first buffer? And must we fill + * full second buffer when first is once filled? + */ + if (dmalen0 > (cmd->stop_arg * scan_bytes)) + dmalen0 = cmd->stop_arg * scan_bytes; + else if (dmalen1 > (cmd->stop_arg * scan_bytes - dmalen0)) + dmalen1 = cmd->stop_arg * scan_bytes - dmalen0; + } + + if (cmd->flags & CMDF_WAKE_EOS) { + /* don't we want wake up every scan? */ + if (dmalen0 > scan_bytes) { + dmalen0 = scan_bytes; + if (cmd->scan_end_arg & 1) + dmalen0 += 2; + } + if (dmalen1 > scan_bytes) { + dmalen1 = scan_bytes; + if (cmd->scan_end_arg & 1) + dmalen1 -= 2; + if (dmalen1 < 4) + dmalen1 = 4; + } + } else { + /* isn't output buff smaller that our DMA buff? */ + if (dmalen0 > s->async->prealloc_bufsz) + dmalen0 = s->async->prealloc_bufsz; + if (dmalen1 > s->async->prealloc_bufsz) + dmalen1 = s->async->prealloc_bufsz; + } + dmabuf0->use_size = dmalen0; + dmabuf1->use_size = dmalen1; + + apci3120_init_dma(dev, dmabuf0); +} + /* * There are three timers on the board. They all use the same base * clock with a fixed prescaler for each timer. The base clock used -- cgit v1.2.3-59-g8ed1b From 18e3b50367c68fa2cbb7a93d4aa8393fcedcbab3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:23 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_ai_cmd() to driver Move this function from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 56 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 56 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 771ac870eb87..396aa47a6b08 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -26,62 +26,6 @@ static int apci3120_cancel(struct comedi_device *dev, return 0; } -static int apci3120_ai_cmd(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct apci3120_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - unsigned int divisor; - - /* set default mode bits */ - devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | - APCI3120_MODE_TIMER2_AS_TIMER; - - /* AMCC- Clear write complete interrupt (DMA) */ - outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); - - devpriv->cur_dmabuf = 0; - - /* load chanlist for command scan */ - apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); - - if (cmd->start_src == TRIG_EXT) - apci3120_exttrig_enable(dev, true); - - if (cmd->scan_begin_src == TRIG_TIMER) { - /* - * Timer 1 is used in MODE2 (rate generator) to set the - * start time for each scan. - */ - divisor = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg, - cmd->flags); - apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2); - apci3120_timer_write(dev, 1, divisor); - } - - /* - * Timer 0 is used in MODE2 (rate generator) to set the conversion - * time for each acquisition. - */ - divisor = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); - apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); - apci3120_timer_write(dev, 0, divisor); - - if (devpriv->use_dma) - apci3120_setup_dma(dev, s); - else - devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - - /* set mode to enable acquisition */ - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - if (cmd->scan_begin_src == TRIG_TIMER) - apci3120_timer_enable(dev, 1, true); - apci3120_timer_enable(dev, 0, true); - - return 0; -} - /* * This is a handler for the DMA interrupt. * This function copies the data to Comedi Buffer. diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index b5ac5b8cf05f..8fd498d0031a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -437,6 +437,62 @@ static void apci3120_set_chanlist(struct comedi_device *dev, #include "addi-data/hwdrv_apci3120.c" +static int apci3120_ai_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct apci3120_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int divisor; + + /* set default mode bits */ + devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC | + APCI3120_MODE_TIMER2_AS_TIMER; + + /* AMCC- Clear write complete interrupt (DMA) */ + outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); + + devpriv->cur_dmabuf = 0; + + /* load chanlist for command scan */ + apci3120_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist); + + if (cmd->start_src == TRIG_EXT) + apci3120_exttrig_enable(dev, true); + + if (cmd->scan_begin_src == TRIG_TIMER) { + /* + * Timer 1 is used in MODE2 (rate generator) to set the + * start time for each scan. + */ + divisor = apci3120_ns_to_timer(dev, 1, cmd->scan_begin_arg, + cmd->flags); + apci3120_timer_set_mode(dev, 1, APCI3120_TIMER_MODE2); + apci3120_timer_write(dev, 1, divisor); + } + + /* + * Timer 0 is used in MODE2 (rate generator) to set the conversion + * time for each acquisition. + */ + divisor = apci3120_ns_to_timer(dev, 0, cmd->convert_arg, cmd->flags); + apci3120_timer_set_mode(dev, 0, APCI3120_TIMER_MODE2); + apci3120_timer_write(dev, 0, divisor); + + if (devpriv->use_dma) + apci3120_setup_dma(dev, s); + else + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; + + /* set mode to enable acquisition */ + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + + if (cmd->scan_begin_src == TRIG_TIMER) + apci3120_timer_enable(dev, 1, true); + apci3120_timer_enable(dev, 0, true); + + return 0; +} + static int apci3120_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) -- cgit v1.2.3-59-g8ed1b From a68809bb8d97f6df3296298e932f07b33e939d00 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:24 -0700 Subject: staging: comedi: addi_apci_3120: use async->events to report hardware error In apci3120_interrupt_dma(), use the async->events to report the hardware error and allow the core to (*cancel) the command instead of calling the (*cancel) function directly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 396aa47a6b08..505901c6ec2a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -50,7 +50,7 @@ static void apci3120_interrupt_dma(int irq, void *d) dev_err(dev->class_dev, "Interrupted DMA transfer!\n"); if (samplesinbuf & 1) { dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n"); - apci3120_cancel(dev, s); + async->events |= COMEDI_CB_ERROR; return; } samplesinbuf = samplesinbuf >> 1; /* number of received samples */ -- cgit v1.2.3-59-g8ed1b From 676caedabd62f23ce345c044de30ca3051d8d41b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:25 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_cancel() to driver Move this function from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 28 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 505901c6ec2a..66e71d5193a2 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1,31 +1,3 @@ -static int apci3120_cancel(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct apci3120_private *devpriv = dev->private; - - /* Add-On - disable DMA */ - outw(0, devpriv->addon + 4); - - /* Add-On - disable bus master */ - apci3120_addon_write(dev, 0, AMCC_OP_REG_AGCSTS); - - /* AMCC - disable bus master */ - outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); - - /* disable all counters, ext trigger, and reset scan */ - devpriv->ctrl = 0; - outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); - - /* DISABLE_ALL_INTERRUPT */ - devpriv->mode = 0; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - - inw(dev->iobase + APCI3120_STATUS_REG); - devpriv->cur_dmabuf = 0; - - return 0; -} - /* * This is a handler for the DMA interrupt. * This function copies the data to Comedi Buffer. diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 8fd498d0031a..fd5306efc021 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -560,6 +560,34 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, return 0; } +static int apci3120_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct apci3120_private *devpriv = dev->private; + + /* Add-On - disable DMA */ + outw(0, devpriv->addon + 4); + + /* Add-On - disable bus master */ + apci3120_addon_write(dev, 0, AMCC_OP_REG_AGCSTS); + + /* AMCC - disable bus master */ + outl(0, devpriv->amcc + AMCC_OP_REG_MCSR); + + /* disable all counters, ext trigger, and reset scan */ + devpriv->ctrl = 0; + outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); + + /* DISABLE_ALL_INTERRUPT */ + devpriv->mode = 0; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + + inw(dev->iobase + APCI3120_STATUS_REG); + devpriv->cur_dmabuf = 0; + + return 0; +} + static int apci3120_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, -- cgit v1.2.3-59-g8ed1b From 76e6047088b75b773893ee23d4134ca7dc192c16 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:26 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_interrupt() to driver Move this function from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 72 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 72 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 66e71d5193a2..f18622c52e16 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -55,75 +55,3 @@ static void apci3120_interrupt_dma(int irq, void *d) apci3120_init_dma(dev, dmabuf); } } - -static irqreturn_t apci3120_interrupt(int irq, void *d) -{ - struct comedi_device *dev = d; - struct apci3120_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; - unsigned int status; - unsigned int int_amcc; - - status = inw(dev->iobase + APCI3120_STATUS_REG); - int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); - - if (!(status & APCI3120_STATUS_INT_MASK) && - !(int_amcc & ANY_S593X_INT)) { - dev_err(dev->class_dev, "IRQ from unknown source\n"); - return IRQ_NONE; - } - - outl(int_amcc | AINT_INT_MASK, devpriv->amcc + AMCC_OP_REG_INTCSR); - - if (devpriv->ctrl & APCI3120_CTRL_EXT_TRIG) - apci3120_exttrig_enable(dev, false); - - if (int_amcc & MASTER_ABORT_INT) - dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n"); - if (int_amcc & TARGET_ABORT_INT) - dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n"); - - if ((status & APCI3120_STATUS_EOC_INT) == 0 && - (devpriv->mode & APCI3120_MODE_EOC_IRQ_ENA)) { - /* nothing to do... EOC mode is not currently used */ - } - - if ((status & APCI3120_STATUS_EOS_INT) && - (devpriv->mode & APCI3120_MODE_EOS_IRQ_ENA)) { - unsigned short val; - int i; - - for (i = 0; i < cmd->chanlist_len; i++) { - val = inw(dev->iobase + APCI3120_AI_FIFO_REG); - comedi_buf_write_samples(s, &val, 1); - } - - devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; - outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); - } - - if (status & APCI3120_STATUS_TIMER2_INT) { - /* - * for safety... - * timer2 interrupts are not enabled in the driver - */ - apci3120_clr_timer2_interrupt(dev); - } - - if (status & APCI3120_STATUS_AMCC_INT) { - /* AMCC- Clear write complete interrupt (DMA) */ - outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); - - /* do some data transfer */ - apci3120_interrupt_dma(irq, d); - } - - if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) - async->events |= COMEDI_CB_EOA; - - comedi_handle_events(dev, s); - - return IRQ_HANDLED; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index fd5306efc021..fce177bd2db2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -437,6 +437,78 @@ static void apci3120_set_chanlist(struct comedi_device *dev, #include "addi-data/hwdrv_apci3120.c" +static irqreturn_t apci3120_interrupt(int irq, void *d) +{ + struct comedi_device *dev = d; + struct apci3120_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + unsigned int status; + unsigned int int_amcc; + + status = inw(dev->iobase + APCI3120_STATUS_REG); + int_amcc = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); + + if (!(status & APCI3120_STATUS_INT_MASK) && + !(int_amcc & ANY_S593X_INT)) { + dev_err(dev->class_dev, "IRQ from unknown source\n"); + return IRQ_NONE; + } + + outl(int_amcc | AINT_INT_MASK, devpriv->amcc + AMCC_OP_REG_INTCSR); + + if (devpriv->ctrl & APCI3120_CTRL_EXT_TRIG) + apci3120_exttrig_enable(dev, false); + + if (int_amcc & MASTER_ABORT_INT) + dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n"); + if (int_amcc & TARGET_ABORT_INT) + dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n"); + + if ((status & APCI3120_STATUS_EOC_INT) == 0 && + (devpriv->mode & APCI3120_MODE_EOC_IRQ_ENA)) { + /* nothing to do... EOC mode is not currently used */ + } + + if ((status & APCI3120_STATUS_EOS_INT) && + (devpriv->mode & APCI3120_MODE_EOS_IRQ_ENA)) { + unsigned short val; + int i; + + for (i = 0; i < cmd->chanlist_len; i++) { + val = inw(dev->iobase + APCI3120_AI_FIFO_REG); + comedi_buf_write_samples(s, &val, 1); + } + + devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; + outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); + } + + if (status & APCI3120_STATUS_TIMER2_INT) { + /* + * for safety... + * timer2 interrupts are not enabled in the driver + */ + apci3120_clr_timer2_interrupt(dev); + } + + if (status & APCI3120_STATUS_AMCC_INT) { + /* AMCC- Clear write complete interrupt (DMA) */ + outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); + + /* do some data transfer */ + apci3120_interrupt_dma(irq, d); + } + + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; + + comedi_handle_events(dev, s); + + return IRQ_HANDLED; +} + static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { -- cgit v1.2.3-59-g8ed1b From c78a1f487028775b146e3be89690f19b845409b7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:27 -0700 Subject: staging: comedi: addi_apci_3120: use comedi_bytes_to_samples() Use the helper function to calculate the number of samples in the DMA buffer. For aesthetics, tidy up the local variables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index f18622c52e16..c6008711c3d3 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -12,20 +12,21 @@ static void apci3120_interrupt_dma(int irq, void *d) struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; struct apci3120_dmabuf *dmabuf; - unsigned int samplesinbuf; + unsigned int nbytes; + unsigned int nsamples; dmabuf = &devpriv->dmabuf[devpriv->cur_dmabuf]; - samplesinbuf = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC); + nbytes = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC); - if (samplesinbuf < dmabuf->use_size) + if (nbytes < dmabuf->use_size) dev_err(dev->class_dev, "Interrupted DMA transfer!\n"); - if (samplesinbuf & 1) { + if (nbytes & 1) { dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n"); async->events |= COMEDI_CB_ERROR; return; } - samplesinbuf = samplesinbuf >> 1; /* number of received samples */ + nsamples = comedi_bytes_to_samples(s, nbytes); if (devpriv->use_double_buffer) { struct apci3120_dmabuf *next_dmabuf; @@ -36,8 +37,8 @@ static void apci3120_interrupt_dma(int irq, void *d) apci3120_init_dma(dev, next_dmabuf); } - if (samplesinbuf) { - comedi_buf_write_samples(s, dmabuf->virt, samplesinbuf); + if (nsamples) { + comedi_buf_write_samples(s, dmabuf->virt, nsamples); if (!(cmd->flags & CMDF_WAKE_EOS)) async->events |= COMEDI_CB_EOS; -- cgit v1.2.3-59-g8ed1b From cd68e0e2d00501ff7e59c8213bfb9bd31d42c820 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:28 -0700 Subject: staging: comedi: addi_apci_3120: move apci3120_interrupt_dma() to driver Move this function from the included source file to the main driver source file. Remove the now empty included source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 58 ---------------------- drivers/staging/comedi/drivers/addi_apci_3120.c | 53 +++++++++++++++++++- 2 files changed, 52 insertions(+), 59 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c deleted file mode 100644 index c6008711c3d3..000000000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This is a handler for the DMA interrupt. - * This function copies the data to Comedi Buffer. - * For continuous DMA it reinitializes the DMA operation. - * For single mode DMA it stop the acquisition. - */ -static void apci3120_interrupt_dma(int irq, void *d) -{ - struct comedi_device *dev = d; - struct apci3120_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async = s->async; - struct comedi_cmd *cmd = &async->cmd; - struct apci3120_dmabuf *dmabuf; - unsigned int nbytes; - unsigned int nsamples; - - dmabuf = &devpriv->dmabuf[devpriv->cur_dmabuf]; - - nbytes = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC); - - if (nbytes < dmabuf->use_size) - dev_err(dev->class_dev, "Interrupted DMA transfer!\n"); - if (nbytes & 1) { - dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n"); - async->events |= COMEDI_CB_ERROR; - return; - } - nsamples = comedi_bytes_to_samples(s, nbytes); - - if (devpriv->use_double_buffer) { - struct apci3120_dmabuf *next_dmabuf; - - next_dmabuf = &devpriv->dmabuf[!devpriv->cur_dmabuf]; - - /* start DMA on next buffer */ - apci3120_init_dma(dev, next_dmabuf); - } - - if (nsamples) { - comedi_buf_write_samples(s, dmabuf->virt, nsamples); - - if (!(cmd->flags & CMDF_WAKE_EOS)) - async->events |= COMEDI_CB_EOS; - } - - if ((async->events & COMEDI_CB_CANCEL_MASK) || - (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)) - return; - - if (devpriv->use_double_buffer) { - /* switch dma buffers for next interrupt */ - devpriv->cur_dmabuf = !devpriv->cur_dmabuf; - } else { - /* restart DMA if is not using double buffering */ - apci3120_init_dma(dev, dmabuf); - } -} diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index fce177bd2db2..9bdd7277caa1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -435,7 +435,58 @@ static void apci3120_set_chanlist(struct comedi_device *dev, devpriv->mode |= APCI3120_MODE_SCAN_ENA; } -#include "addi-data/hwdrv_apci3120.c" +static void apci3120_interrupt_dma(int irq, void *d) +{ + struct comedi_device *dev = d; + struct apci3120_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + struct apci3120_dmabuf *dmabuf; + unsigned int nbytes; + unsigned int nsamples; + + dmabuf = &devpriv->dmabuf[devpriv->cur_dmabuf]; + + nbytes = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC); + + if (nbytes < dmabuf->use_size) + dev_err(dev->class_dev, "Interrupted DMA transfer!\n"); + if (nbytes & 1) { + dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n"); + async->events |= COMEDI_CB_ERROR; + return; + } + nsamples = comedi_bytes_to_samples(s, nbytes); + + if (devpriv->use_double_buffer) { + struct apci3120_dmabuf *next_dmabuf; + + next_dmabuf = &devpriv->dmabuf[!devpriv->cur_dmabuf]; + + /* start DMA on next buffer */ + apci3120_init_dma(dev, next_dmabuf); + } + + if (nsamples) { + comedi_buf_write_samples(s, dmabuf->virt, nsamples); + + if (!(cmd->flags & CMDF_WAKE_EOS)) + async->events |= COMEDI_CB_EOS; + } + + if ((async->events & COMEDI_CB_CANCEL_MASK) || + (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)) + return; + + if (devpriv->use_double_buffer) { + /* switch dma buffers for next interrupt */ + devpriv->cur_dmabuf = !devpriv->cur_dmabuf; + } else { + /* restart DMA if is not using double buffering */ + apci3120_init_dma(dev, dmabuf); + } +} static irqreturn_t apci3120_interrupt(int irq, void *d) { -- cgit v1.2.3-59-g8ed1b From a93a0e9a30e7702229f68e516dc270507159f23b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:29 -0700 Subject: staging: comedi: addi_apci_3120: change params to apci3120_interrupt_dma() Pass the comedi_device and comedi_subdevice pointers to this function instead of the irq number and void pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 9bdd7277caa1..ea53694e0d32 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -435,11 +435,10 @@ static void apci3120_set_chanlist(struct comedi_device *dev, devpriv->mode |= APCI3120_MODE_SCAN_ENA; } -static void apci3120_interrupt_dma(int irq, void *d) +static void apci3120_interrupt_dma(struct comedi_device *dev, + struct comedi_subdevice *s) { - struct comedi_device *dev = d; struct apci3120_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; struct apci3120_dmabuf *dmabuf; @@ -549,7 +548,7 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) outl(AINT_WT_COMPLETE, devpriv->amcc + AMCC_OP_REG_INTCSR); /* do some data transfer */ - apci3120_interrupt_dma(irq, d); + apci3120_interrupt_dma(dev, s); } if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) -- cgit v1.2.3-59-g8ed1b From f50205f0478c35d9d6f3cc3e315ccdfcdaba17e4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:30 -0700 Subject: staging: comedi: addi_apci_3120: switch DMA buffers after writing samples Currently the DMA buffers are switched before writing the current samples to the async buffer. This works but when the EOA event happens we end up with an outstanding DMA operation in progress that gets terminated by the (*cancel). Avoid the outstanding DMA operation by switching the DMA buffers after writing the samples. The driver will detect the EOA event and not retart the DMA. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ea53694e0d32..ba96fe5910e1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -456,17 +456,8 @@ static void apci3120_interrupt_dma(struct comedi_device *dev, async->events |= COMEDI_CB_ERROR; return; } - nsamples = comedi_bytes_to_samples(s, nbytes); - - if (devpriv->use_double_buffer) { - struct apci3120_dmabuf *next_dmabuf; - - next_dmabuf = &devpriv->dmabuf[!devpriv->cur_dmabuf]; - - /* start DMA on next buffer */ - apci3120_init_dma(dev, next_dmabuf); - } + nsamples = comedi_bytes_to_samples(s, nbytes); if (nsamples) { comedi_buf_write_samples(s, dmabuf->virt, nsamples); @@ -479,10 +470,12 @@ static void apci3120_interrupt_dma(struct comedi_device *dev, return; if (devpriv->use_double_buffer) { - /* switch dma buffers for next interrupt */ + /* switch DMA buffers for next interrupt */ devpriv->cur_dmabuf = !devpriv->cur_dmabuf; + dmabuf = &devpriv->dmabuf[devpriv->cur_dmabuf]; + apci3120_init_dma(dev, dmabuf); } else { - /* restart DMA if is not using double buffering */ + /* restart DMA if not using double buffering */ apci3120_init_dma(dev, dmabuf); } } -- cgit v1.2.3-59-g8ed1b From c58f9bb622ca06387200a6f9ef77cdc5c531dfb2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:31 -0700 Subject: staging: comedi: addi_apci_3120: enable AI async commands The async command support should now work. Enable the hook up of the command support functions in apci3120_auto_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index ba96fe5910e1..f00b9ba070b7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1038,7 +1038,7 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->maxdata = this_board->ai_is_16bit ? 0xffff : 0x0fff; s->range_table = &apci3120_ai_range; s->insn_read = apci3120_ai_insn_read; - if (0 /* dev->irq */) { + if (dev->irq) { dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; s->len_chanlist = s->n_chan; -- cgit v1.2.3-59-g8ed1b From 34216792e006d70bcfdf1931e24e4eb2e2af9498 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Nov 2014 10:55:32 -0700 Subject: staging: comedi: addi_apci_3120: absorb apci3120_ai_reset_fifo() This function is only called by apci3120_set_chanlist(). Absorb it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3120.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index f00b9ba070b7..e9816e7a235d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -395,12 +395,6 @@ static void apci3120_exttrig_enable(struct comedi_device *dev, bool enable) outw(devpriv->ctrl, dev->iobase + APCI3120_CTRL_REG); } -static void apci3120_ai_reset_fifo(struct comedi_device *dev) -{ - /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */ - inw(dev->iobase + APCI3120_TIMER_MODE_REG); -} - static void apci3120_set_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist) @@ -424,7 +418,8 @@ static void apci3120_set_chanlist(struct comedi_device *dev, outw(val, dev->iobase + APCI3120_CHANLIST_REG); } - apci3120_ai_reset_fifo(dev); + /* a dummy read of APCI3120_TIMER_MODE_REG resets the ai FIFO */ + inw(dev->iobase + APCI3120_TIMER_MODE_REG); /* set scan length (PR) and scan start (PA) */ devpriv->ctrl = APCI3120_CTRL_PR(n_chan - 1) | APCI3120_CTRL_PA(0); -- cgit v1.2.3-59-g8ed1b From c78a964c251bb82aa3454440e082b91a836105ae Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Nov 2014 16:50:45 +0530 Subject: staging: rtl8188eu: unneeded return variable a variable is declared and initialized and then never updated in the function.This default value is then used as the return from the function. So removed that unneeded return variable and returning that default initial value directly. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 6 ++---- drivers/staging/rtl8188eu/core/rtw_recv.c | 6 ++---- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++-- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 9 +++------ 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b0e92372fa5e..990c168d3d6d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -371,7 +371,6 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c int init_mlme_ext_priv(struct adapter *padapter) { - int res = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -397,7 +396,7 @@ int init_mlme_ext_priv(struct adapter *padapter) pmlmeext->active_keep_alive_check = true; - return res; + return _SUCCESS; } void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) @@ -1554,7 +1553,6 @@ unsigned int OnAtim(struct adapter *padapter, struct 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->rx_data; @@ -1587,7 +1585,7 @@ unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_f } exit: - return ret; + return _FAIL; } unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index a1619b88733f..bd79e9e7105a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -1373,7 +1373,6 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) u8 *psnap_type; struct ieee80211_snap_hdr *psnap; - int ret = _SUCCESS; struct adapter *adapter = precvframe->adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *ptr = precvframe->rx_data; @@ -1428,7 +1427,7 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) memcpy(ptr+12, &be_tmp, 2); } - return ret; + return _SUCCESS; } /* perform defrag */ @@ -1624,7 +1623,6 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); - int ret = _SUCCESS; nr_subframes = 0; pattrib = &prframe->attrib; @@ -1728,7 +1726,7 @@ exit: prframe->len = 0; rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ - return ret; + return _SUCCESS; } static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index f34fb29ae225..24a8f5ac96e5 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1416,7 +1416,7 @@ static int rtw_wx_set_rate(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - int i, ret = 0; + int i; u8 datarates[NumRates]; u32 target_rate = wrqu->bitrate.value; u32 fixed = wrqu->bitrate.fixed; @@ -1489,7 +1489,7 @@ set_rate: RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i])); } - return ret; + return 0; } static int rtw_wx_get_rate(struct net_device *dev, diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 0b488d29bd37..88a909c9e457 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -512,7 +512,6 @@ void rtw_proc_remove_one(struct net_device *dev) static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) { - uint status = _SUCCESS; struct registry_priv *registry_par = &padapter->registrypriv; @@ -582,7 +581,7 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) snprintf(registry_par->ifname, 16, "%s", ifname); snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; - return status; + return _SUCCESS; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) @@ -760,7 +759,6 @@ void rtw_stop_drv_threads(struct adapter *padapter) static u8 rtw_init_default_value(struct adapter *padapter) { - u8 ret = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -803,12 +801,11 @@ static u8 rtw_init_default_value(struct adapter *padapter) padapter->bWritePortCancel = false; padapter->bRxRSSIDisplay = 0; padapter->bNotifyChannelChange = 0; - return ret; + return _SUCCESS; } u8 rtw_reset_drv_sw(struct adapter *padapter) { - u8 ret8 = _SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; @@ -833,7 +830,7 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) rtw_set_signal_stat_timer(&padapter->recvpriv); - return ret8; + return _SUCCESS; } u8 rtw_init_drv_sw(struct adapter *padapter) -- cgit v1.2.3-59-g8ed1b From d48037f9169f653d1124eb75157293d875e7e57f Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Nov 2014 16:50:46 +0530 Subject: staging: rtl8188eu: unneeded NULL check before these NULL checks we are already checking it for NULL, and if it is NULL then we are jumping to the error label and handling the error before returning. So we can reach this part of the code only if the variable is known to be not NULL, and if we already know that it is not NULL, then no need to check it again. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 +--- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 30 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index a0bbf9093338..7a71df167464 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1025,8 +1025,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct /* adding icv, if necessary... */ if (pattrib->iv_len) { - if (psta != NULL) { - switch (pattrib->encrypt) { + switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); @@ -1043,7 +1042,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct else AES_IV(pattrib->iv, psta->dot11txpn, 0); break; - } } memcpy(pframe, pattrib->iv, pattrib->iv_len); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index dab4c337a863..01566210bbd2 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -155,6 +155,8 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) bool fw_ps_awake = true; u8 hw_init_completed = false; struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct mlme_priv *pmlmepriv = NULL; + u8 bLinked = false; hw_init_completed = Adapter->hw_init_completed; @@ -170,22 +172,20 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) fw_ps_awake = false; /* ODM */ - if (hw_init_completed) { - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - u8 bLinked = false; - - if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) { - if (Adapter->stapriv.asoc_sta_count > 2) - bLinked = true; - } else {/* Station mode */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) - bLinked = true; - } - - ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); - ODM_DMWatchdog(&hal_data->odmpriv); + pmlmepriv = &Adapter->mlmepriv; + + if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | + WIFI_ADHOC_MASTER_STATE))) { + if (Adapter->stapriv.asoc_sta_count > 2) + bLinked = true; + } else {/* Station mode */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) + bLinked = true; } + + ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); + ODM_DMWatchdog(&hal_data->odmpriv); skip_dm: /* Check GPIO to determine current RF on/off and Pbc status. */ /* Check Hardware Radio ON/OFF or not */ -- cgit v1.2.3-59-g8ed1b From a86a659fb67c67b4294b2ea4d941714608b5f6e3 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Nov 2014 16:12:18 +0900 Subject: staging: lustre: Remove unnecessary semicolon This patch remove unnecessary semicolons from macro. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index b911e7643874..852d78721ca9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -42,8 +42,8 @@ #define LMV_MAX_TGT_COUNT 128 -#define lmv_init_lock(lmv) mutex_lock(&lmv->init_mutex); -#define lmv_init_unlock(lmv) mutex_unlock(&lmv->init_mutex); +#define lmv_init_lock(lmv) mutex_lock(&lmv->init_mutex) +#define lmv_init_unlock(lmv) mutex_unlock(&lmv->init_mutex) #define LL_IT2STR(it) \ ((it) ? ldlm_it2str((it)->it_op) : "0") -- cgit v1.2.3-59-g8ed1b From dbd18138a01b0284eaff31490f84735a72986a34 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 8 Nov 2014 16:12:19 +0900 Subject: staging: lustre: Remove unnecessary parentheses. This patch remove unnecessary parentheses. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 9543c15f990e..dc170d87851b 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -925,7 +925,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, __u32 index; memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); - if ((index >= count)) + if (index >= count) return -ENODEV; if (lmv->tgts[index] == NULL || -- cgit v1.2.3-59-g8ed1b From 1ef3988da44a5bb0e66eab6f97cf8f60b6e624d5 Mon Sep 17 00:00:00 2001 From: Niklas Svensson Date: Sat, 8 Nov 2014 16:49:18 +0100 Subject: staging: skein: fixed sparse warnings related to static declarations drivers/staging/skein/skein_generic.c:30:5: warning: symbol 'skein256_update' was not declared. Should it be static? drivers/staging/skein/skein_generic.c:65:5: warning: symbol 'skein512_update' was not declared. Should it be static? drivers/staging/skein/skein_generic.c:100:5: warning: symbol 'skein1024_update' was not declared. Should it be static? Signed-off-by: Niklas Svensson Acked-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/skein/skein_generic.c b/drivers/staging/skein/skein_generic.c index 60d16b639b91..85bd7d0168b0 100644 --- a/drivers/staging/skein/skein_generic.c +++ b/drivers/staging/skein/skein_generic.c @@ -27,7 +27,7 @@ static int skein256_init(struct shash_desc *desc) SKEIN256_DIGEST_BIT_SIZE); } -int skein256_update(struct shash_desc *desc, const u8 *data, +static int skein256_update(struct shash_desc *desc, const u8 *data, unsigned int len) { return skein_256_update((struct skein_256_ctx *)shash_desc_ctx(desc), @@ -62,7 +62,7 @@ static int skein512_init(struct shash_desc *desc) SKEIN512_DIGEST_BIT_SIZE); } -int skein512_update(struct shash_desc *desc, const u8 *data, +static int skein512_update(struct shash_desc *desc, const u8 *data, unsigned int len) { return skein_512_update((struct skein_512_ctx *)shash_desc_ctx(desc), @@ -97,7 +97,7 @@ static int skein1024_init(struct shash_desc *desc) SKEIN1024_DIGEST_BIT_SIZE); } -int skein1024_update(struct shash_desc *desc, const u8 *data, +static int skein1024_update(struct shash_desc *desc, const u8 *data, unsigned int len) { return skein_1024_update((struct skein_1024_ctx *)shash_desc_ctx(desc), -- cgit v1.2.3-59-g8ed1b From 9d9b211fcf441f813a255534786539a1aeae4e14 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Sun, 9 Nov 2014 11:54:06 +0800 Subject: drivers: staging: lustre: Kconfig: Let LUSTRE_LLITE_LLOOP depend on all !"*_64K*" page It does not support 64K page, so let it disabled for 64K page under all architectures. The related error (with allmodconfig under tile): CC [M] drivers/staging/lustre/lustre/llite/lloop.o In file included from drivers/staging/lustre/lustre/llite/../include/../../include/linux/libcfs/libcfs.h:160:0, from drivers/staging/lustre/lustre/llite/../include/lustre_lib.h:52, from drivers/staging/lustre/lustre/llite/lloop.c:106: drivers/staging/lustre/lustre/llite/lloop.c: In function 'loop_set_fd': drivers/staging/lustre/lustre/llite/../include/../../include/linux/libcfs/libcfs_private.h:411:54: error: duplicate case value #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) ^ drivers/staging/lustre/lustre/llite/lloop.c:525:2: note: in expansion of macro 'CLASSERT' CLASSERT(PAGE_CACHE_SIZE < (1 << (sizeof(unsigned short) * 8))); ^ drivers/staging/lustre/lustre/llite/../include/../../include/linux/libcfs/libcfs_private.h:411:41: error: previously used here #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) ^ drivers/staging/lustre/lustre/llite/lloop.c:525:2: note: in expansion of macro 'CLASSERT' CLASSERT(PAGE_CACHE_SIZE < (1 << (sizeof(unsigned short) * 8))); ^ Use "find ./ | grep Kconfig | xargs grep --color 64K" to find all 64K page macros. Signed-off-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 4f65ba1158bf..6725467ef4d0 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -57,5 +57,5 @@ config LUSTRE_TRANSLATE_ERRNOS config LUSTRE_LLITE_LLOOP tristate "Lustre virtual block device" depends on LUSTRE_FS && BLOCK - depends on !PPC_64K_PAGES && !ARM64_64K_PAGES + depends on !PPC_64K_PAGES && !ARM64_64K_PAGES && !MICROBLAZE_64K_PAGES && !PAGE_SIZE_64KB && !IA64_PAGE_SIZE_64KB && !PARISC_PAGE_SIZE_64KB default m -- cgit v1.2.3-59-g8ed1b From 337832b7919469db17d3ebf60e3875e6915cae75 Mon Sep 17 00:00:00 2001 From: Domagoj Trsan Date: Mon, 17 Nov 2014 09:44:56 +0100 Subject: staging: skein: fix sparse warnings related to shift operator Fix warnings: drivers/staging/skein/skein_base.h:89:30: warning: shift too big (50) for type int ... drivers/staging/skein/skein_base.h:89:30: warning: shift too big (39)for type int drivers/staging/skein/skein_base.h:89:19: warning: too many warnings Signed-off-by: Domagoj Trsan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/skein/skein_base.h b/drivers/staging/skein/skein_base.h index 993b951172f6..3c7f8ad3627d 100644 --- a/drivers/staging/skein/skein_base.h +++ b/drivers/staging/skein/skein_base.h @@ -84,7 +84,7 @@ struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; -static inline int rotl_64(int x, int N) +static inline u64 rotl_64(u64 x, u8 N) { return (x << N) | (x >> (64 - N)); } -- cgit v1.2.3-59-g8ed1b From 490e0e898ba4c625bbf53d691cb8554a1a494063 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 9 Nov 2014 10:06:32 +0100 Subject: staging: lustre: osc: remove final uses of the GOTO macro The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ identifier lbl; identifier rc; constant c; @@ - GOTO(lbl,\(rc\|c\)); + goto lbl; @@ identifier lbl; expression rc; @@ - GOTO(lbl,rc); + rc; + goto lbl; // In one case (OES_INV), consecutive gotos were factorized and a break was removed. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_cache.c | 168 +++++++++++++++++--------- 1 file changed, 110 insertions(+), 58 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index ec04935c65ea..f8c8b666d4f3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -178,76 +178,113 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, int page_count; int rc = 0; - if (!osc_object_is_locked(obj)) - GOTO(out, rc = 9); + if (!osc_object_is_locked(obj)) { + rc = 9; + goto out; + } - if (ext->oe_state >= OES_STATE_MAX) - GOTO(out, rc = 10); + if (ext->oe_state >= OES_STATE_MAX) { + rc = 10; + goto out; + } - if (atomic_read(&ext->oe_refc) <= 0) - GOTO(out, rc = 20); + if (atomic_read(&ext->oe_refc) <= 0) { + rc = 20; + goto out; + } - if (atomic_read(&ext->oe_refc) < atomic_read(&ext->oe_users)) - GOTO(out, rc = 30); + if (atomic_read(&ext->oe_refc) < atomic_read(&ext->oe_users)) { + rc = 30; + goto out; + } switch (ext->oe_state) { case OES_INV: if (ext->oe_nr_pages > 0 || !list_empty(&ext->oe_pages)) - GOTO(out, rc = 35); - GOTO(out, rc = 0); - break; + rc = 35; + else + rc = 0; + goto out; case OES_ACTIVE: - if (atomic_read(&ext->oe_users) == 0) - GOTO(out, rc = 40); - if (ext->oe_hp) - GOTO(out, rc = 50); - if (ext->oe_fsync_wait && !ext->oe_urgent) - GOTO(out, rc = 55); + if (atomic_read(&ext->oe_users) == 0) { + rc = 40; + goto out; + } + if (ext->oe_hp) { + rc = 50; + goto out; + } + if (ext->oe_fsync_wait && !ext->oe_urgent) { + rc = 55; + goto out; + } break; case OES_CACHE: - if (ext->oe_grants == 0) - GOTO(out, rc = 60); - if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp) - GOTO(out, rc = 65); + if (ext->oe_grants == 0) { + rc = 60; + goto out; + } + if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp) { + rc = 65; + goto out; + } default: - if (atomic_read(&ext->oe_users) > 0) - GOTO(out, rc = 70); + if (atomic_read(&ext->oe_users) > 0) { + rc = 70; + goto out; + } } - if (ext->oe_max_end < ext->oe_end || ext->oe_end < ext->oe_start) - GOTO(out, rc = 80); + if (ext->oe_max_end < ext->oe_end || ext->oe_end < ext->oe_start) { + rc = 80; + goto out; + } - if (ext->oe_osclock == NULL && ext->oe_grants > 0) - GOTO(out, rc = 90); + if (ext->oe_osclock == NULL && ext->oe_grants > 0) { + rc = 90; + goto out; + } if (ext->oe_osclock) { struct cl_lock_descr *descr; descr = &ext->oe_osclock->cll_descr; if (!(descr->cld_start <= ext->oe_start && - descr->cld_end >= ext->oe_max_end)) - GOTO(out, rc = 100); + descr->cld_end >= ext->oe_max_end)) { + rc = 100; + goto out; + } } - if (ext->oe_nr_pages > ext->oe_mppr) - GOTO(out, rc = 105); + if (ext->oe_nr_pages > ext->oe_mppr) { + rc = 105; + goto out; + } /* Do not verify page list if extent is in RPC. This is because an * in-RPC extent is supposed to be exclusively accessible w/o lock. */ - if (ext->oe_state > OES_CACHE) - GOTO(out, rc = 0); + if (ext->oe_state > OES_CACHE) { + rc = 0; + goto out; + } - if (!extent_debug) - GOTO(out, rc = 0); + if (!extent_debug) { + rc = 0; + goto out; + } page_count = 0; list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) { pgoff_t index = oap2cl_page(oap)->cp_index; ++page_count; - if (index > ext->oe_end || index < ext->oe_start) - GOTO(out, rc = 110); + if (index > ext->oe_end || index < ext->oe_start) { + rc = 110; + goto out; + } + } + if (page_count != ext->oe_nr_pages) { + rc = 120; + goto out; } - if (page_count != ext->oe_nr_pages) - GOTO(out, rc = 120); out: if (rc != 0) @@ -774,8 +811,10 @@ restart: rc = osc_extent_wait(env, conflict, OES_INV); osc_extent_put(env, conflict); conflict = NULL; - if (rc < 0) - GOTO(out, found = ERR_PTR(rc)); + if (rc < 0) { + found = ERR_PTR(rc); + goto out; + } goto restart; } @@ -932,7 +971,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, io->ci_obj = cl_object_top(osc2cl(obj)); rc = cl_io_init(env, io, CIT_MISC, io->ci_obj); if (rc < 0) - GOTO(out, rc); + goto out; /* discard all pages with index greater then trunc_index */ list_for_each_entry_safe(oap, tmp, &ext->oe_pages, @@ -1112,21 +1151,27 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) osc_object_lock(obj); LASSERT(sanity_check_nolock(ext) == 0); end_chunk = ext->oe_end >> ppc_bits; - if (chunk > end_chunk + 1) - GOTO(out, rc = -ERANGE); + if (chunk > end_chunk + 1) { + rc = -ERANGE; + goto out; + } - if (end_chunk >= chunk) - GOTO(out, rc = 0); + if (end_chunk >= chunk) { + rc = 0; + goto out; + } LASSERT(end_chunk + 1 == chunk); /* try to expand this extent to cover @index */ end_index = min(ext->oe_max_end, ((chunk + 1) << ppc_bits) - 1); next = next_extent(ext); - if (next != NULL && next->oe_start <= end_index) + if (next != NULL && next->oe_start <= end_index) { /* complex mode - overlapped with the next extent, * this case will be handled by osc_extent_find() */ - GOTO(out, rc = -EAGAIN); + rc = -EAGAIN; + goto out; + } ext->oe_end = end_index; ext->oe_grants += chunksize; @@ -1495,12 +1540,16 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, * of queued writes and create a discontiguous rpc stream */ if (OBD_FAIL_CHECK(OBD_FAIL_OSC_NO_GRANT) || cli->cl_dirty_max < PAGE_CACHE_SIZE || - cli->cl_ar.ar_force_sync || loi->loi_ar.ar_force_sync) - GOTO(out, rc = -EDQUOT); + cli->cl_ar.ar_force_sync || loi->loi_ar.ar_force_sync) { + rc = -EDQUOT; + goto out; + } /* Hopefully normal case - cache space and write credits available */ - if (osc_enter_cache_try(cli, oap, bytes, 0)) - GOTO(out, rc = 0); + if (osc_enter_cache_try(cli, oap, bytes, 0)) { + rc = 0; + goto out; + } /* We can get here for two reasons: too many dirty pages in cache, or * run out of grants. In both cases we should write dirty pages out. @@ -1528,16 +1577,18 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, /* l_wait_event is interrupted by signal */ if (rc < 0) { list_del_init(&ocw.ocw_entry); - GOTO(out, rc); + goto out; } LASSERT(list_empty(&ocw.ocw_entry)); rc = ocw.ocw_rc; if (rc != -EDQUOT) - GOTO(out, rc); - if (osc_enter_cache_try(cli, oap, bytes, 0)) - GOTO(out, rc = 0); + goto out; + if (osc_enter_cache_try(cli, oap, bytes, 0)) { + rc = 0; + goto out; + } } out: client_obd_list_unlock(&cli->cl_loi_list_lock); @@ -2399,14 +2450,15 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, * one making the extent active, we could deadlock waiting for * the page writeback to clear but it won't because the extent * is active and won't be written out. */ - GOTO(out, rc = -EAGAIN); + rc = -EAGAIN; + goto out; default: break; } rc = cl_page_prep(env, io, cl_page_top(cp), CRT_WRITE); if (rc) - GOTO(out, rc); + goto out; spin_lock(&oap->oap_lock); oap->oap_async_flags |= ASYNC_READY|ASYNC_URGENT; -- cgit v1.2.3-59-g8ed1b From b4f0065ed344c57370e506e5464fafb66cd27990 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 9 Nov 2014 10:06:34 +0100 Subject: staging: lustre: libcfs: remove final uses of the GOTO macro Remove the goto logging function, as it is no longer used. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/debug.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 2c15a9e7332f..859129d8ddc8 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -460,11 +460,3 @@ void libcfs_debug_set_level(unsigned int debug_level) } EXPORT_SYMBOL(libcfs_debug_set_level); - -void libcfs_log_goto(struct libcfs_debug_msg_data *msgdata, const char *label, - long_ptr_t rc) -{ - libcfs_debug_msg(msgdata, "Process leaving via %s (rc=%lu : %ld : %#lx)\n", - label, (ulong_ptr_t)rc, rc, rc); -} -EXPORT_SYMBOL(libcfs_log_goto); -- cgit v1.2.3-59-g8ed1b From 71583c3ef0acb3b88368353ab6007b2fa1fcd02e Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 9 Nov 2014 10:06:33 +0100 Subject: staging: lustre: libcfs_debug.h: remove final uses of the GOTO macro Remove the GOTO macro, as it is no longer used. Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 8888b2756174..2e5a9e5965b1 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -242,18 +242,6 @@ do { \ #define LCONSOLE_EMERG(format, ...) CDEBUG(D_CONSOLE | D_EMERG, format, ## __VA_ARGS__) -void libcfs_log_goto(struct libcfs_debug_msg_data *, const char *, long_ptr_t); -#define GOTO(label, rc) \ -do { \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - libcfs_log_goto(&msgdata, #label, (long_ptr_t)(rc)); \ - } else { \ - (void)(rc); \ - } \ - goto label; \ -} while (0) - int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, const char *format1, ...) __attribute__ ((format (printf, 2, 3))); -- cgit v1.2.3-59-g8ed1b From 3ff28049970d3808b44b1e2116f2ebbb08ffa0df Mon Sep 17 00:00:00 2001 From: Balavasu Kuppusammyprathaban Date: Wed, 12 Nov 2014 15:42:34 +0530 Subject: staging: lustre: lustre: ptlrpc: Remove unnecessary braces Fixes the following checkpatch warning: WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Balavasu Kuppusammyprathaban Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 38cc931a189c..6c8815f4b99b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -2215,10 +2215,8 @@ EXPORT_SYMBOL(ptlrpc_set_wait); */ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) { - if (request == NULL) { + if (request == NULL) return; - } - LASSERTF(!request->rq_receiving_reply, "req %p\n", request); LASSERTF(request->rq_rqbd == NULL, "req %p\n", request);/* client-side */ LASSERTF(list_empty(&request->rq_list), "req %p\n", request); -- cgit v1.2.3-59-g8ed1b From 565f3d2fd09a6e9c7615ae369beedabcf0e86b53 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Mon, 17 Nov 2014 11:54:40 -0800 Subject: drivers: staging: lustre: lnet: api-nc.c: Fix Style Warnings Remove an unecessary return statement in a void function. Remove an unecessary space between a function name and the parentheses. Signed-off-by: Thomas Wood Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 5e6e4e22ed31..faceb9505d84 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -277,7 +277,7 @@ lnet_find_lnd_by_type(int type) struct list_head *tmp; /* holding lnd mutex */ - list_for_each (tmp, &the_lnet.ln_lnds) { + list_for_each(tmp, &the_lnet.ln_lnds) { lnd = list_entry(tmp, lnd_t, lnd_list); if ((int)lnd->lnd_type == type) @@ -1645,7 +1645,6 @@ lnet_destroy_ping_info(void) offsetof(lnet_ping_info_t, pi_ni[the_lnet.ln_ping_info->pi_nnis])); the_lnet.ln_ping_info = NULL; - return; } int -- cgit v1.2.3-59-g8ed1b From 962dbfd6144ab04750018b689eddf0857fbc11cb Mon Sep 17 00:00:00 2001 From: Juston Li Date: Tue, 18 Nov 2014 17:03:51 -0800 Subject: staging: lustre: mdc: use __FMODE_EXEC macro FMODE_EXEC is type fmode_t but is used in operations with integers which leads to sparse warnings: drivers/staging/lustre/lustre/mdc/mdc_lib.c:198:21: warning: restricted fmode_t degrades to integer drivers/staging/lustre/lustre/mdc/mdc_locks.c:300:49: warning: restricted fmode_t degrades to integer Fix by using __FMODE_EXEC macro defined in fs.h. Note the same warnings occurs with other fmode flags here but they don't have a corresponding int macro. Changes since v1: remove ifdefs. FMODE_EXEC and __FMODE_EXEC should always be defined in fs.h Signed-off-by: Juston Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 4 +--- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index e8732cc30ce2..4e59995e0042 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -194,10 +194,8 @@ static __u64 mds_pack_open_flags(__u64 flags, __u32 mode) cr_flags |= MDS_OPEN_SYNC; if (flags & O_DIRECTORY) cr_flags |= MDS_OPEN_DIRECTORY; -#ifdef FMODE_EXEC - if (flags & FMODE_EXEC) + if (flags & __FMODE_EXEC) cr_flags |= MDS_FMODE_EXEC; -#endif if (cl_is_lov_delay_create(flags)) cr_flags |= MDS_OPEN_DELAY_CREATE; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index b58147ee62b6..8c9b4f5494e9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -296,10 +296,8 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, } else { if (it->it_flags & (FMODE_WRITE|MDS_OPEN_TRUNC)) mode = LCK_CW; -#ifdef FMODE_EXEC - else if (it->it_flags & FMODE_EXEC) + else if (it->it_flags & __FMODE_EXEC) mode = LCK_PR; -#endif else mode = LCK_CR; } -- cgit v1.2.3-59-g8ed1b From 2d00bd17a2702fff623ecc005bd0f9c29e6cb508 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 23 Nov 2014 11:28:50 -0800 Subject: staging: lustre: Coalesce string fragments Join the string fragments to make it easier to grep. Ignored all the 80+ column lines. Added many missing spaces when coalescing formats. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 34 ++--- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 3 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 49 +++--- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 89 +++++------ .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 15 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 82 +++++----- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 3 +- drivers/staging/lustre/lnet/lnet/router.c | 34 ++--- drivers/staging/lustre/lnet/lnet/router_proc.c | 9 +- drivers/staging/lustre/lnet/selftest/console.c | 6 +- drivers/staging/lustre/lnet/selftest/framework.c | 25 ++- drivers/staging/lustre/lnet/selftest/module.c | 4 +- drivers/staging/lustre/lnet/selftest/rpc.c | 29 ++-- drivers/staging/lustre/lustre/include/linux/obd.h | 3 +- .../staging/lustre/lustre/include/lustre_disk.h | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 4 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 168 +++++++++------------ drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 11 +- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 10 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 37 ++--- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 19 +-- drivers/staging/lustre/lustre/libcfs/debug.c | 8 +- drivers/staging/lustre/lustre/libcfs/hash.c | 3 +- .../staging/lustre/lustre/libcfs/linux/linux-cpu.c | 32 ++-- .../lustre/lustre/libcfs/linux/linux-debug.c | 6 +- .../lustre/lustre/libcfs/linux/linux-tcpip.c | 3 +- drivers/staging/lustre/lustre/libcfs/tracefile.c | 38 +++-- drivers/staging/lustre/lustre/llite/dcache.c | 6 +- drivers/staging/lustre/lustre/llite/dir.c | 25 ++- drivers/staging/lustre/lustre/llite/file.c | 16 +- drivers/staging/lustre/lustre/llite/llite_capa.c | 3 +- drivers/staging/lustre/lustre/llite/llite_close.c | 16 +- .../staging/lustre/lustre/llite/llite_internal.h | 12 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 58 +++---- drivers/staging/lustre/lustre/llite/llite_mmap.c | 9 +- drivers/staging/lustre/lustre/llite/llite_rmtacl.c | 7 +- drivers/staging/lustre/lustre/llite/lloop.c | 4 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 29 ++-- drivers/staging/lustre/lustre/llite/namei.c | 14 +- drivers/staging/lustre/lustre/llite/rw.c | 20 +-- drivers/staging/lustre/lustre/llite/statahead.c | 11 +- drivers/staging/lustre/lustre/llite/symlink.c | 4 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 5 +- drivers/staging/lustre/lustre/llite/vvp_page.c | 3 +- drivers/staging/lustre/lustre/llite/xattr.c | 3 +- drivers/staging/lustre/lustre/lmv/lmv_fld.c | 3 +- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 8 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 36 ++--- drivers/staging/lustre/lustre/lov/lov_ea.c | 5 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 32 ++-- drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +- drivers/staging/lustre/lustre/obdclass/capa.c | 8 +- drivers/staging/lustre/lustre/obdclass/cl_io.c | 3 +- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 6 +- drivers/staging/lustre/lustre/obdclass/genops.c | 18 +-- .../lustre/lustre/obdclass/linux/linux-sysctl.c | 5 +- drivers/staging/lustre/lustre/obdclass/llog.c | 4 +- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 10 +- drivers/staging/lustre/lustre/obdclass/llog_swab.c | 3 +- .../lustre/lustre/obdclass/lprocfs_status.c | 10 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 3 +- .../staging/lustre/lustre/obdclass/obd_config.c | 9 +- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 38 ++--- .../staging/lustre/lustre/obdecho/echo_client.c | 3 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 6 +- drivers/staging/lustre/lustre/osc/osc_object.c | 3 +- drivers/staging/lustre/lustre/osc/osc_page.c | 11 +- drivers/staging/lustre/lustre/osc/osc_request.c | 47 +++--- drivers/staging/lustre/lustre/ptlrpc/client.c | 44 +++--- drivers/staging/lustre/lustre/ptlrpc/events.c | 7 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 115 ++++++-------- drivers/staging/lustre/lustre/ptlrpc/layout.c | 24 ++- drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 3 +- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 13 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 7 +- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 33 ++-- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 33 ++-- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 18 +-- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 7 +- drivers/staging/lustre/lustre/ptlrpc/recover.c | 7 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 22 ++- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 3 +- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 90 +++++------ 88 files changed, 688 insertions(+), 1013 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index bc479a721a60..62b575deac3a 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -930,8 +930,7 @@ kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why) list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) { conn = list_entry(ctmp, kib_conn_t, ibc_list); - CDEBUG(D_NET, "Closing conn -> %s, " - "version: %x, reason: %d\n", + CDEBUG(D_NET, "Closing conn -> %s, version: %x, reason: %d\n", libcfs_nid2str(peer->ibp_nid), conn->ibc_version, why); @@ -958,8 +957,7 @@ kiblnd_close_stale_conns_locked (kib_peer_t *peer, conn->ibc_incarnation == incarnation) continue; - CDEBUG(D_NET, "Closing stale conn -> %s version: %x, " - "incarnation:%#llx(%x, %#llx)\n", + CDEBUG(D_NET, "Closing stale conn -> %s version: %x, incarnation:%#llx(%x, %#llx)\n", libcfs_nid2str(peer->ibp_nid), conn->ibc_version, conn->ibc_incarnation, version, incarnation); @@ -1599,8 +1597,7 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages, if (fps->fps_increasing) { spin_unlock(&fps->fps_lock); - CDEBUG(D_NET, "Another thread is allocating new " - "FMR pool, waiting for her to complete\n"); + CDEBUG(D_NET, "Another thread is allocating new FMR pool, waiting for her to complete\n"); schedule(); goto again; @@ -1801,8 +1798,7 @@ kiblnd_pool_alloc_node(kib_poolset_t *ps) if (ps->ps_increasing) { /* another thread is allocating a new pool */ spin_unlock(&ps->ps_lock); - CDEBUG(D_NET, "Another thread is allocating new " - "%s pool, waiting for her to complete\n", + CDEBUG(D_NET, "Another thread is allocating new %s pool, waiting for her to complete\n", ps->ps_name); schedule(); goto again; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 14c9c8d18d02..b48d7edf5669 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1116,8 +1116,7 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type, } if (tx->tx_nwrq == IBLND_RDMA_FRAGS(conn->ibc_version)) { - CERROR("RDMA too fragmented for %s (%d): " - "%d/%d src %d/%d dst frags\n", + CERROR("RDMA too fragmented for %s (%d): %d/%d src %d/%d dst frags\n", libcfs_nid2str(conn->ibc_peer->ibp_nid), IBLND_RDMA_FRAGS(conn->ibc_version), srcidx, srcrd->rd_nfrags, @@ -2254,8 +2253,8 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) if (ni == NULL || /* no matching net */ ni->ni_nid != reqmsg->ibm_dstnid || /* right NET, wrong NID! */ net->ibn_dev != ibdev) { /* wrong device */ - CERROR("Can't accept %s on %s (%s:%d:%pI4h): " - "bad dst nid %s\n", libcfs_nid2str(nid), + CERROR("Can't accept %s on %s (%s:%d:%pI4h): bad dst nid %s\n", + libcfs_nid2str(nid), ni == NULL ? "NA" : libcfs_nid2str(ni->ni_nid), ibdev->ibd_ifname, ibdev->ibd_nnets, &ibdev->ibd_ifip, @@ -2295,8 +2294,7 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) if (reqmsg->ibm_u.connparams.ibcp_max_frags != IBLND_RDMA_FRAGS(version)) { - CERROR("Can't accept %s(version %x): " - "incompatible max_frags %d (%d wanted)\n", + CERROR("Can't accept %s(version %x): incompatible max_frags %d (%d wanted)\n", libcfs_nid2str(nid), version, reqmsg->ibm_u.connparams.ibcp_max_frags, IBLND_RDMA_FRAGS(version)); @@ -2502,8 +2500,7 @@ kiblnd_reconnect (kib_conn_t *conn, int version, break; } - CNETERR("%s: retrying (%s), %x, %x, " - "queue_dep: %d, max_frag: %d, msg_size: %d\n", + CNETERR("%s: retrying (%s), %x, %x, queue_dep: %d, max_frag: %d, msg_size: %d\n", libcfs_nid2str(peer->ibp_nid), reason, IBLND_MSG_VERSION, version, cp != NULL? cp->ibcp_queue_depth :IBLND_MSG_QUEUE_SIZE(version), @@ -2679,8 +2676,7 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob) } if (ver != msg->ibm_version) { - CERROR("%s replied version %x is different with " - "requested version %x\n", + CERROR("%s replied version %x is different with requested version %x\n", libcfs_nid2str(peer->ibp_nid), msg->ibm_version, ver); rc = -EPROTO; goto failed; @@ -2724,8 +2720,7 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob) read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); if (rc != 0) { - CERROR("Bad connection reply from %s, rc = %d, " - "version: %x max_frags: %d\n", + CERROR("Bad connection reply from %s, rc = %d, version: %x max_frags: %d\n", libcfs_nid2str(peer->ibp_nid), rc, msg->ibm_version, msg->ibm_u.connparams.ibcp_max_frags); goto failed; @@ -3060,8 +3055,7 @@ kiblnd_check_conns (int idx) } if (timedout) { - CERROR("Timed out RDMA with %s (%lu): " - "c: %u, oc: %u, rc: %u\n", + CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n", libcfs_nid2str(peer->ibp_nid), cfs_duration_sec(cfs_time_current() - peer->ibp_last_alive), @@ -3334,10 +3328,8 @@ kiblnd_scheduler(void *arg) rc = cfs_cpt_bind(lnet_cpt_table(), sched->ibs_cpt); if (rc != 0) { - CWARN("Failed to bind on CPT %d, please verify whether " - "all CPUs are healthy and reload modules if necessary, " - "otherwise your system might under risk of low " - "performance\n", sched->ibs_cpt); + CWARN("Failed to bind on CPT %d, please verify whether all CPUs are healthy and reload modules if necessary, otherwise your system might under risk of low performance\n", + sched->ibs_cpt); } spin_lock_irqsave(&sched->ibs_lock, flags); @@ -3369,8 +3361,7 @@ kiblnd_scheduler(void *arg) rc = ib_req_notify_cq(conn->ibc_cq, IB_CQ_NEXT_COMP); if (rc < 0) { - CWARN("%s: ib_req_notify_cq failed: %d, " - "closing connection\n", + CWARN("%s: ib_req_notify_cq failed: %d, closing connection\n", libcfs_nid2str(conn->ibc_peer->ibp_nid), rc); kiblnd_close_conn(conn, -EIO); kiblnd_conn_decref(conn); @@ -3383,8 +3374,7 @@ kiblnd_scheduler(void *arg) } if (rc < 0) { - CWARN("%s: ib_poll_cq failed: %d, " - "closing connection\n", + CWARN("%s: ib_poll_cq failed: %d, closing connection\n", libcfs_nid2str(conn->ibc_peer->ibp_nid), rc); kiblnd_close_conn(conn, -EIO); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index cefdfb6b1bec..8b4a8e9a29b4 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -222,8 +222,7 @@ kiblnd_tunables_init (void) *kiblnd_tunables.kib_concurrent_sends = *kiblnd_tunables.kib_peertxcredits / 2; if (*kiblnd_tunables.kib_concurrent_sends < *kiblnd_tunables.kib_peertxcredits) { - CWARN("Concurrent sends %d is lower than message queue size: %d, " - "performance may drop slightly.\n", + CWARN("Concurrent sends %d is lower than message queue size: %d, performance may drop slightly.\n", *kiblnd_tunables.kib_concurrent_sends, *kiblnd_tunables.kib_peertxcredits); } diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 8ac6410e2ae2..9188b34e6948 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -337,8 +337,7 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) &route->ksnr_ipaddr, &conn->ksnc_myipaddr); } else { - CDEBUG(D_NET, "Rebinding %s %pI4h from " - "%pI4h to %pI4h\n", + CDEBUG(D_NET, "Rebinding %s %pI4h from %pI4h to %pI4h\n", libcfs_id2str(peer->ksnp_id), &route->ksnr_ipaddr, &route->ksnr_myipaddr, @@ -974,8 +973,7 @@ ksocknal_accept (lnet_ni_t *ni, struct socket *sock) LIBCFS_ALLOC(cr, sizeof(*cr)); if (cr == NULL) { - LCONSOLE_ERROR_MSG(0x12f, "Dropping connection request from " - "%pI4h: memory exhausted\n", + LCONSOLE_ERROR_MSG(0x12f, "Dropping connection request from %pI4h: memory exhausted\n", &peer_ip); return -ENOMEM; } @@ -1288,8 +1286,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route, * socket callbacks. */ - CDEBUG(D_NET, "New conn %s p %d.x %pI4h -> %pI4h/%d" - " incarnation:%lld sched[%d:%d]\n", + CDEBUG(D_NET, "New conn %s p %d.x %pI4h -> %pI4h/%d incarnation:%lld sched[%d:%d]\n", libcfs_id2str(peerid), conn->ksnc_proto->pro_version, &conn->ksnc_myipaddr, &conn->ksnc_ipaddr, conn->ksnc_port, incarnation, cpt, @@ -1638,37 +1635,32 @@ ksocknal_destroy_conn (ksock_conn_t *conn) case SOCKNAL_RX_LNET_PAYLOAD: last_rcv = conn->ksnc_rx_deadline - cfs_time_seconds(*ksocknal_tunables.ksnd_timeout); - CERROR("Completing partial receive from %s[%d]" - ", ip %pI4h:%d, with error, wanted: %d, left: %d, " - "last alive is %ld secs ago\n", + CERROR("Completing partial receive from %s[%d], ip %pI4h:%d, with error, wanted: %d, left: %d, last alive is %ld secs ago\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type, &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left, cfs_duration_sec(cfs_time_sub(cfs_time_current(), - last_rcv))); + last_rcv))); lnet_finalize (conn->ksnc_peer->ksnp_ni, conn->ksnc_cookie, -EIO); break; case SOCKNAL_RX_LNET_HEADER: if (conn->ksnc_rx_started) - CERROR("Incomplete receive of lnet header from %s" - ", ip %pI4h:%d, with error, protocol: %d.x.\n", + CERROR("Incomplete receive of lnet header from %s, ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version); break; case SOCKNAL_RX_KSM_HEADER: if (conn->ksnc_rx_started) - CERROR("Incomplete receive of ksock message from %s" - ", ip %pI4h:%d, with error, protocol: %d.x.\n", + CERROR("Incomplete receive of ksock message from %s, ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version); break; case SOCKNAL_RX_SLOP: if (conn->ksnc_rx_started) - CERROR("Incomplete receive of slops from %s" - ", ip %pI4h:%d, with error\n", + CERROR("Incomplete receive of slops from %s, ip %pI4h:%d, with error\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); break; @@ -2511,22 +2503,21 @@ ksocknal_debug_peerhash (lnet_ni_t *ni) ksock_route_t *route; ksock_conn_t *conn; - CWARN ("Active peer on shutdown: %s, ref %d, scnt %d, " - "closing %d, accepting %d, err %d, zcookie %llu, " - "txq %d, zc_req %d\n", libcfs_id2str(peer->ksnp_id), - atomic_read(&peer->ksnp_refcount), - peer->ksnp_sharecount, peer->ksnp_closing, - peer->ksnp_accepting, peer->ksnp_error, - peer->ksnp_zc_next_cookie, - !list_empty(&peer->ksnp_tx_queue), - !list_empty(&peer->ksnp_zc_req_list)); + CWARN("Active peer on shutdown: %s, ref %d, scnt %d, closing %d, accepting %d, err %d, zcookie %llu, txq %d, zc_req %d\n", + libcfs_id2str(peer->ksnp_id), + atomic_read(&peer->ksnp_refcount), + peer->ksnp_sharecount, peer->ksnp_closing, + peer->ksnp_accepting, peer->ksnp_error, + peer->ksnp_zc_next_cookie, + !list_empty(&peer->ksnp_tx_queue), + !list_empty(&peer->ksnp_zc_req_list)); list_for_each (tmp, &peer->ksnp_routes) { route = list_entry(tmp, ksock_route_t, ksnr_list); - CWARN ("Route: ref %d, schd %d, conn %d, cnted %d, " - "del %d\n", atomic_read(&route->ksnr_refcount), - route->ksnr_scheduled, route->ksnr_connecting, - route->ksnr_connected, route->ksnr_deleted); + CWARN("Route: ref %d, schd %d, conn %d, cnted %d, del %d\n", + atomic_read(&route->ksnr_refcount), + route->ksnr_scheduled, route->ksnr_connecting, + route->ksnr_connected, route->ksnr_deleted); } list_for_each (tmp, &peer->ksnp_conns) { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index d29f5f134b89..e6c1d3647952 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -551,19 +551,16 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) if (!conn->ksnc_closing) { switch (rc) { case -ECONNRESET: - LCONSOLE_WARN("Host %pI4h reset our connection " - "while we were sending data; it may have " - "rebooted.\n", + LCONSOLE_WARN("Host %pI4h reset our connection while we were sending data; it may have rebooted.\n", &conn->ksnc_ipaddr); break; default: - LCONSOLE_WARN("There was an unexpected network error " - "while writing to %pI4h: %d.\n", + LCONSOLE_WARN("There was an unexpected network error while writing to %pI4h: %d.\n", &conn->ksnc_ipaddr, rc); break; } - CDEBUG(D_NET, "[%p] Error %d on write to %s" - " ip %pI4h:%d\n", conn, rc, + CDEBUG(D_NET, "[%p] Error %d on write to %s ip %pI4h:%d\n", + conn, rc, libcfs_id2str(conn->ksnc_peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); @@ -799,8 +796,7 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer) if (!(route->ksnr_retry_interval == 0 || /* first attempt */ cfs_time_aftereq(now, route->ksnr_timeout))) { CDEBUG(D_NET, - "Too soon to retry route %pI4h " - "(cnted %d, interval %ld, %ld secs later)\n", + "Too soon to retry route %pI4h (cnted %d, interval %ld, %ld secs later)\n", &route->ksnr_ipaddr, route->ksnr_connected, route->ksnr_retry_interval, @@ -874,8 +870,8 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) write_unlock_bh(g_lock); if ((id.pid & LNET_PID_USERFLAG) != 0) { - CERROR("Refusing to create a connection to " - "userspace process %s\n", libcfs_id2str(id)); + CERROR("Refusing to create a connection to userspace process %s\n", + libcfs_id2str(id)); return -EHOSTUNREACH; } @@ -1132,18 +1128,17 @@ ksocknal_process_receive (ksock_conn_t *conn) LASSERT (rc != -EAGAIN); if (rc == 0) - CDEBUG(D_NET, "[%p] EOF from %s" - " ip %pI4h:%d\n", conn, - libcfs_id2str(conn->ksnc_peer->ksnp_id), - &conn->ksnc_ipaddr, - conn->ksnc_port); + CDEBUG(D_NET, "[%p] EOF from %s ip %pI4h:%d\n", + conn, + libcfs_id2str(conn->ksnc_peer->ksnp_id), + &conn->ksnc_ipaddr, + conn->ksnc_port); else if (!conn->ksnc_closing) - CERROR("[%p] Error %d on read from %s" - " ip %pI4h:%d\n", - conn, rc, - libcfs_id2str(conn->ksnc_peer->ksnp_id), - &conn->ksnc_ipaddr, - conn->ksnc_port); + CERROR("[%p] Error %d on read from %s ip %pI4h:%d\n", + conn, rc, + libcfs_id2str(conn->ksnc_peer->ksnp_id), + &conn->ksnc_ipaddr, + conn->ksnc_port); /* it's not an error if conn is being closed */ ksocknal_close_conn_and_siblings (conn, @@ -1724,10 +1719,10 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, hello->kshm_magic != __swab32(LNET_PROTO_MAGIC) && hello->kshm_magic != le32_to_cpu (LNET_PROTO_TCP_MAGIC)) { /* Unexpected magic! */ - CERROR("Bad magic(1) %#08x (%#08x expected) from " - "%pI4h\n", __cpu_to_le32 (hello->kshm_magic), - LNET_PROTO_TCP_MAGIC, - &conn->ksnc_ipaddr); + CERROR("Bad magic(1) %#08x (%#08x expected) from %pI4h\n", + __cpu_to_le32 (hello->kshm_magic), + LNET_PROTO_TCP_MAGIC, + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1755,10 +1750,9 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, ksocknal_send_hello(ni, conn, ni->ni_nid, hello); } - CERROR("Unknown protocol version (%d.x expected)" - " from %pI4h\n", - conn->ksnc_proto->pro_version, - &conn->ksnc_ipaddr); + CERROR("Unknown protocol version (%d.x expected) from %pI4h\n", + conn->ksnc_proto->pro_version, + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1778,8 +1772,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, *incarnation = hello->kshm_src_incarnation; if (hello->kshm_src_nid == LNET_NID_ANY) { - CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY" - "from %pI4h\n", &conn->ksnc_ipaddr); + CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY from %pI4h\n", + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1810,10 +1804,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (peerid->pid != recv_id.pid || peerid->nid != recv_id.nid) { - LCONSOLE_ERROR_MSG(0x130, "Connected successfully to %s on host" - " %pI4h, but they claimed they were " - "%s; please check your Lustre " - "configuration.\n", + LCONSOLE_ERROR_MSG(0x130, "Connected successfully to %s on host %pI4h, but they claimed they were %s; please check your Lustre configuration.\n", libcfs_id2str(*peerid), &conn->ksnc_ipaddr, libcfs_id2str(recv_id)); @@ -2199,8 +2190,7 @@ ksocknal_connd (void *arg) if (ksocknal_connect(route)) { /* consecutive retry */ if (cons_retry++ > SOCKNAL_INSANITY_RECONN) { - CWARN("massive consecutive " - "re-connecting to %pI4h\n", + CWARN("massive consecutive re-connecting to %pI4h\n", &route->ksnr_ipaddr); cons_retry = 0; } @@ -2264,25 +2254,20 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) switch (error) { case ECONNRESET: - CNETERR("A connection with %s " - "(%pI4h:%d) was reset; " - "it may have rebooted.\n", + CNETERR("A connection with %s (%pI4h:%d) was reset; it may have rebooted.\n", libcfs_id2str(peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); break; case ETIMEDOUT: - CNETERR("A connection with %s " - "(%pI4h:%d) timed out; the " - "network or node may be down.\n", + CNETERR("A connection with %s (%pI4h:%d) timed out; the network or node may be down.\n", libcfs_id2str(peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); break; default: - CNETERR("An unexpected network error %d " - "occurred with %s " - "(%pI4h:%d\n", error, + CNETERR("An unexpected network error %d occurred with %s (%pI4h:%d\n", + error, libcfs_id2str(peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); @@ -2297,8 +2282,7 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) conn->ksnc_rx_deadline)) { /* Timed out incomplete incoming message */ ksocknal_conn_addref(conn); - CNETERR("Timeout receiving from %s (%pI4h:%d), " - "state %d wanted %d left %d\n", + CNETERR("Timeout receiving from %s (%pI4h:%d), state %d wanted %d left %d\n", libcfs_id2str(peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port, @@ -2315,8 +2299,7 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) /* Timed out messages queued for sending or * buffered in the socket's send buffer */ ksocknal_conn_addref(conn); - CNETERR("Timeout sending data to %s (%pI4h:%d) " - "the network or that node may be down.\n", + CNETERR("Timeout sending data to %s (%pI4h:%d) the network or that node may be down.\n", libcfs_id2str(peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); @@ -2500,9 +2483,7 @@ ksocknal_check_peer_timeouts (int idx) spin_unlock(&peer->ksnp_lock); read_unlock(&ksocknal_data.ksnd_global_lock); - CERROR("Total %d stale ZC_REQs for peer %s detected; the " - "oldest(%p) timed out %ld secs ago, " - "resid: %d, wmem: %d\n", + CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n", n, libcfs_nid2str(peer->ksnp_id.nid), tx, cfs_duration_sec(cfs_time_current() - deadline), resid, conn->ksnc_sock->sk->sk_wmem_queued); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 9dde548070af..ea9d80f40cab 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -515,8 +515,8 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) hello->kshm_nips * sizeof(__u32), lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO payload (%d)" - " to %pI4h/%d\n", rc, hello->kshm_nips, + CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n", + rc, hello->kshm_nips, &conn->ksnc_ipaddr, conn->ksnc_port); } out: @@ -560,8 +560,8 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) hello->kshm_nips * sizeof(__u32), lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO payload (%d)" - " to %pI4h/%d\n", rc, hello->kshm_nips, + CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n", + rc, hello->kshm_nips, &conn->ksnc_ipaddr, conn->ksnc_port); } @@ -595,10 +595,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, /* ...and check we got what we expected */ if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) { - CERROR("Expecting a HELLO hdr," - " but got type %d from %pI4h\n", - le32_to_cpu (hdr->type), - &conn->ksnc_ipaddr); + CERROR("Expecting a HELLO hdr, but got type %d from %pI4h\n", + le32_to_cpu(hdr->type), + &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 5754725f0745..c8c1ed84fe5c 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -668,8 +668,7 @@ lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) rc = (ni->ni_lnd->lnd_eager_recv)(ni, msg->msg_private, msg, &msg->msg_private); if (rc != 0) { - CERROR("recv from %s / send to %s aborted: " - "eager_recv failed %d\n", + CERROR("recv from %s / send to %s aborted: eager_recv failed %d\n", libcfs_nid2str(msg->msg_rxpeer->lp_nid), libcfs_id2str(msg->msg_target), rc); LASSERT(rc < 0); /* required by my callers */ @@ -753,8 +752,7 @@ lnet_peer_alive_locked(lnet_peer_t *lp) if (time_before(now, next_query)) { if (lp->lp_alive) - CWARN("Unexpected aliveness of peer %s: " - "%d < %d (%d/%d)\n", + CWARN("Unexpected aliveness of peer %s: %d < %d (%d/%d)\n", libcfs_nid2str(lp->lp_nid), (int)now, (int)next_query, lnet_queryinterval, @@ -817,8 +815,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) (msg->msg_md->md_flags & LNET_MD_FLAG_ABORTED) != 0) { lnet_net_unlock(cpt); - CNETERR("Aborting message for %s: LNetM[DE]Unlink() already " - "called on the MD/ME.\n", + CNETERR("Aborting message for %s: LNetM[DE]Unlink() already called on the MD/ME.\n", libcfs_id2str(msg->msg_target)); if (do_send) lnet_finalize(ni, msg, -ECANCELED); @@ -1220,8 +1217,8 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) src_ni = lnet_nid2ni_locked(src_nid, cpt); if (src_ni == NULL) { lnet_net_unlock(cpt); - LCONSOLE_WARN("Can't send to %s: src %s is not a " - "local nid\n", libcfs_nid2str(dst_nid), + LCONSOLE_WARN("Can't send to %s: src %s is not a local nid\n", + libcfs_nid2str(dst_nid), libcfs_nid2str(src_nid)); return -EINVAL; } @@ -1283,8 +1280,7 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) lnet_ni_decref_locked(src_ni, cpt); lnet_net_unlock(cpt); - LCONSOLE_WARN("No route to %s via %s " - "(all routers down)\n", + LCONSOLE_WARN("No route to %s via %s (all routers down)\n", libcfs_id2str(msg->msg_target), libcfs_nid2str(src_nid)); return -EHOSTUNREACH; @@ -1676,8 +1672,7 @@ lnet_print_hdr(lnet_hdr_t *hdr) break; case LNET_MSG_PUT: - CWARN(" Ptl index %d, ack md %#llx.%#llx, " - "match bits %llu\n", + CWARN(" Ptl index %d, ack md %#llx.%#llx, match bits %llu\n", hdr->msg.put.ptl_index, hdr->msg.put.ack_wmd.wh_interface_cookie, hdr->msg.put.ack_wmd.wh_object_cookie, @@ -1688,8 +1683,8 @@ lnet_print_hdr(lnet_hdr_t *hdr) break; case LNET_MSG_GET: - CWARN(" Ptl index %d, return md %#llx.%#llx, " - "match bits %llu\n", hdr->msg.get.ptl_index, + CWARN(" Ptl index %d, return md %#llx.%#llx, match bits %llu\n", + hdr->msg.get.ptl_index, hdr->msg.get.return_wmd.wh_interface_cookie, hdr->msg.get.return_wmd.wh_object_cookie, hdr->msg.get.match_bits); @@ -1699,16 +1694,14 @@ lnet_print_hdr(lnet_hdr_t *hdr) break; case LNET_MSG_ACK: - CWARN(" dst md %#llx.%#llx, " - "manipulated length %d\n", + CWARN(" dst md %#llx.%#llx, manipulated length %d\n", hdr->msg.ack.dst_wmd.wh_interface_cookie, hdr->msg.ack.dst_wmd.wh_object_cookie, hdr->msg.ack.mlength); break; case LNET_MSG_REPLY: - CWARN(" dst md %#llx.%#llx, " - "length %d\n", + CWARN(" dst md %#llx.%#llx, length %d\n", hdr->msg.reply.dst_wmd.wh_interface_cookie, hdr->msg.reply.dst_wmd.wh_object_cookie, hdr->payload_length); @@ -1757,8 +1750,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, case LNET_MSG_REPLY: if (payload_length > (__u32)(for_me ? LNET_MAX_PAYLOAD : LNET_MTU)) { - CERROR("%s, src %s: bad %s payload %d " - "(%d max expected)\n", + CERROR("%s, src %s: bad %s payload %d (%d max expected)\n", libcfs_nid2str(from_nid), libcfs_nid2str(src_nid), lnet_msgtyp2str(type), @@ -1794,40 +1786,36 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, if (!for_me) { if (LNET_NIDNET(dest_nid) == LNET_NIDNET(ni->ni_nid)) { /* should have gone direct */ - CERROR("%s, src %s: Bad dest nid %s " - "(should have been sent direct)\n", - libcfs_nid2str(from_nid), - libcfs_nid2str(src_nid), - libcfs_nid2str(dest_nid)); + CERROR("%s, src %s: Bad dest nid %s (should have been sent direct)\n", + libcfs_nid2str(from_nid), + libcfs_nid2str(src_nid), + libcfs_nid2str(dest_nid)); return -EPROTO; } if (lnet_islocalnid(dest_nid)) { /* dest is another local NI; sender should have used * this node's NID on its own network */ - CERROR("%s, src %s: Bad dest nid %s " - "(it's my nid but on a different network)\n", - libcfs_nid2str(from_nid), - libcfs_nid2str(src_nid), - libcfs_nid2str(dest_nid)); + CERROR("%s, src %s: Bad dest nid %s (it's my nid but on a different network)\n", + libcfs_nid2str(from_nid), + libcfs_nid2str(src_nid), + libcfs_nid2str(dest_nid)); return -EPROTO; } if (rdma_req && type == LNET_MSG_GET) { - CERROR("%s, src %s: Bad optimized GET for %s " - "(final destination must be me)\n", - libcfs_nid2str(from_nid), - libcfs_nid2str(src_nid), - libcfs_nid2str(dest_nid)); + CERROR("%s, src %s: Bad optimized GET for %s (final destination must be me)\n", + libcfs_nid2str(from_nid), + libcfs_nid2str(src_nid), + libcfs_nid2str(dest_nid)); return -EPROTO; } if (!the_lnet.ln_routing) { - CERROR("%s, src %s: Dropping message for %s " - "(routing not enabled)\n", - libcfs_nid2str(from_nid), - libcfs_nid2str(src_nid), - libcfs_nid2str(dest_nid)); + CERROR("%s, src %s: Dropping message for %s (routing not enabled)\n", + libcfs_nid2str(from_nid), + libcfs_nid2str(src_nid), + libcfs_nid2str(dest_nid)); goto drop; } } @@ -1882,8 +1870,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, rc = lnet_nid2peer_locked(&msg->msg_rxpeer, from_nid, cpt); if (rc != 0) { lnet_net_unlock(cpt); - CERROR("%s, src %s: Dropping %s " - "(error %d looking up sender)\n", + CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n", libcfs_nid2str(from_nid), libcfs_nid2str(src_nid), lnet_msgtyp2str(type), rc); lnet_msg_free(msg); @@ -2003,12 +1990,11 @@ lnet_recv_delayed_msg_list(struct list_head *head) LASSERT(msg->msg_rxpeer != NULL); LASSERT(msg->msg_hdr.type == LNET_MSG_PUT); - CDEBUG(D_NET, "Resuming delayed PUT from %s portal %d " - "match %llu offset %d length %d.\n", - libcfs_id2str(id), msg->msg_hdr.msg.put.ptl_index, - msg->msg_hdr.msg.put.match_bits, - msg->msg_hdr.msg.put.offset, - msg->msg_hdr.payload_length); + CDEBUG(D_NET, "Resuming delayed PUT from %s portal %d match %llu offset %d length %d.\n", + libcfs_id2str(id), msg->msg_hdr.msg.put.ptl_index, + msg->msg_hdr.msg.put.match_bits, + msg->msg_hdr.msg.put.offset, + msg->msg_hdr.payload_length); lnet_recv_put(msg->msg_rxpeer->lp_ni, msg); } diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 720c73be4d3c..19ed696344fe 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -192,8 +192,7 @@ lnet_try_match_md(lnet_libmd_t *md, } /* Commit to this ME/MD */ - CDEBUG(D_NET, "Incoming %s index %x from %s of " - "length %d/%d into md %#llx [%d] + %d\n", + CDEBUG(D_NET, "Incoming %s index %x from %s of length %d/%d into md %#llx [%d] + %d\n", (info->mi_opc == LNET_MD_OP_PUT) ? "put" : "get", info->mi_portal, libcfs_id2str(info->mi_id), mlength, info->mi_rlength, md->md_lh.lh_cookie, md->md_niov, offset); diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index b5b8fb576bfb..59fb6bff0266 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -457,8 +457,7 @@ lnet_check_routes(void) lnet_net_unlock(cpt); - CERROR("Routes to %s via %s and %s not " - "supported\n", + CERROR("Routes to %s via %s and %s not supported\n", libcfs_net2str(net), libcfs_nid2str(nid1), libcfs_nid2str(nid2)); @@ -959,8 +958,7 @@ lnet_ping_router_locked (lnet_peer_t *rtr) secs = lnet_router_check_interval(rtr); CDEBUG(D_NET, - "rtr %s %d: deadline %lu ping_notsent %d alive %d " - "alive_count %d lp_ping_timestamp %lu\n", + "rtr %s %d: deadline %lu ping_notsent %d alive %d alive_count %d lp_ping_timestamp %lu\n", libcfs_nid2str(rtr->lp_nid), secs, rtr->lp_ping_deadline, rtr->lp_ping_notsent, rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp); @@ -1010,9 +1008,7 @@ lnet_router_checker_start(void) if (check_routers_before_use && dead_router_check_interval <= 0) { - LCONSOLE_ERROR_MSG(0x10a, "'dead_router_check_interval' must be" - " set if 'check_routers_before_use' is set" - "\n"); + LCONSOLE_ERROR_MSG(0x10a, "'dead_router_check_interval' must be set if 'check_routers_before_use' is set\n"); return -EINVAL; } @@ -1370,8 +1366,8 @@ lnet_nrb_tiny_calculate(int npages) if (tiny_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, - "tiny_router_buffers=%d invalid when " - "routing enabled\n", tiny_router_buffers); + "tiny_router_buffers=%d invalid when routing enabled\n", + tiny_router_buffers); return -1; } @@ -1389,8 +1385,8 @@ lnet_nrb_small_calculate(int npages) if (small_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, - "small_router_buffers=%d invalid when " - "routing enabled\n", small_router_buffers); + "small_router_buffers=%d invalid when routing enabled\n", + small_router_buffers); return -1; } @@ -1408,8 +1404,8 @@ lnet_nrb_large_calculate(int npages) if (large_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, - "large_router_buffers=%d invalid when " - "routing enabled\n", large_router_buffers); + "large_router_buffers=%d invalid when routing enabled\n", + large_router_buffers); return -1; } @@ -1442,8 +1438,7 @@ lnet_rtrpools_alloc(int im_a_router) } else if (!strcmp(forwarding, "enabled")) { /* explicitly enabled */ } else { - LCONSOLE_ERROR_MSG(0x10b, "'forwarding' not set to either " - "'enabled' or 'disabled'\n"); + LCONSOLE_ERROR_MSG(0x10b, "'forwarding' not set to either 'enabled' or 'disabled'\n"); return -EINVAL; } @@ -1520,11 +1515,10 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) /* can't do predictions... */ if (cfs_time_after(when, now)) { - CWARN ("Ignoring prediction from %s of %s %s " - "%ld seconds in the future\n", - (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid), - libcfs_nid2str(nid), alive ? "up" : "down", - cfs_duration_sec(cfs_time_sub(when, now))); + CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n", + (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid), + libcfs_nid2str(nid), alive ? "up" : "down", + cfs_duration_sec(cfs_time_sub(when, now))); return -EINVAL; } diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index d9645f6bce49..46cde7036f1d 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -791,20 +791,17 @@ static struct lnet_portal_rotors portal_rotors[] = { { .pr_value = LNET_PTL_ROTOR_ON, .pr_name = "ON", - .pr_desc = "round-robin dispatch all PUT messages for " - "wildcard portals" + .pr_desc = "round-robin dispatch all PUT messages for wildcard portals" }, { .pr_value = LNET_PTL_ROTOR_RR_RT, .pr_name = "RR_RT", - .pr_desc = "round-robin dispatch routed PUT message for " - "wildcard portals" + .pr_desc = "round-robin dispatch routed PUT message for wildcard portals" }, { .pr_value = LNET_PTL_ROTOR_HASH_RT, .pr_name = "HASH_RT", - .pr_desc = "dispatch routed PUT message by hashing source " - "NID for wildcard portals" + .pr_desc = "dispatch routed PUT message by hashing source NID for wildcard portals" }, { .pr_value = -1, diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 5dad9f1f9462..49cb6543d538 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -1208,8 +1208,7 @@ again: lstcon_rpc_trans_destroy(trans); /* return if any error */ - CDEBUG(D_NET, "Failed to add test %s, " - "RPC error %d, framework error %d\n", + CDEBUG(D_NET, "Failed to add test %s, RPC error %d, framework error %d\n", transop == LST_TRANS_TSBCLIADD ? "client" : "server", lstcon_trans_stat()->trs_rpc_errno, lstcon_trans_stat()->trs_fwk_errno); @@ -1885,8 +1884,7 @@ lstcon_session_feats_check(unsigned feats) spin_unlock(&console_session.ses_rpc_lock); if (rc != 0) { - CERROR("remote features %x do not match with " - "session features %x of console\n", + CERROR("remote features %x do not match with session features %x of console\n", feats, console_session.ses_features); } diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 82cc94b9cef2..cc9d1826ae66 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -291,8 +291,7 @@ sfw_server_rpc_done(struct srpc_server_rpc *rpc) int status = rpc->srpc_status; CDEBUG (D_NET, - "Incoming framework RPC done: " - "service %s, peer %s, status %s:%d\n", + "Incoming framework RPC done: service %s, peer %s, status %s:%d\n", sv->sv_name, libcfs_id2str(rpc->srpc_peer), swi_state2str(rpc->srpc_wi.swi_state), status); @@ -310,8 +309,7 @@ sfw_client_rpc_fini (srpc_client_rpc_t *rpc) LASSERT (atomic_read(&rpc->crpc_refcount) == 0); CDEBUG (D_NET, - "Outgoing framework RPC done: " - "service %d, peer %s, status %s:%d:%d\n", + "Outgoing framework RPC done: service %d, peer %s, status %s:%d:%d\n", rpc->crpc_service, libcfs_id2str(rpc->crpc_dest), swi_state2str(rpc->crpc_wi.swi_state), rpc->crpc_aborted, rpc->crpc_status); @@ -575,8 +573,8 @@ sfw_load_test(struct sfw_test_instance *tsi) rc = srpc_service_add_buffers(svc, nbuf); if (rc != 0) { - CWARN("Failed to reserve enough buffers: " - "service %s, %d needed: %d\n", svc->sv_name, nbuf, rc); + CWARN("Failed to reserve enough buffers: service %s, %d needed: %d\n", + svc->sv_name, nbuf, rc); /* NB: this error handler is not strictly correct, because * it may release more buffers than already allocated, * but it doesn't matter because request portal should @@ -1270,8 +1268,7 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc) if (sn != NULL && sn->sn_features != request->msg_ses_feats) { - CNETERR("Features of framework RPC don't match " - "features of current session: %x/%x\n", + CNETERR("Features of framework RPC don't match features of current session: %x/%x\n", request->msg_ses_feats, sn->sn_features); reply->msg_body.reply.status = EPROTO; reply->msg_body.reply.sid = sn->sn_id; @@ -1348,8 +1345,7 @@ sfw_bulk_ready(struct srpc_server_rpc *rpc, int status) spin_lock(&sfw_data.fw_lock); if (status != 0) { - CERROR("Bulk transfer failed for RPC: " - "service %s, peer %s, status %d\n", + CERROR("Bulk transfer failed for RPC: service %s, peer %s, status %d\n", sv->sv_name, libcfs_id2str(rpc->srpc_peer), status); spin_unlock(&sfw_data.fw_lock); return -EIO; @@ -1664,12 +1660,10 @@ sfw_startup (void) } if (session_timeout == 0) - CWARN ("Zero session_timeout specified " - "- test sessions never expire.\n"); + CWARN("Zero session_timeout specified - test sessions never expire.\n"); if (rpc_timeout == 0) - CWARN ("Zero rpc_timeout specified " - "- test RPC never expire.\n"); + CWARN("Zero rpc_timeout specified - test RPC never expire.\n"); memset(&sfw_data, 0, sizeof(struct smoketest_framework)); @@ -1727,8 +1721,7 @@ sfw_startup (void) rc = srpc_service_add_buffers(sv, sv->sv_wi_total); if (rc != 0) { - CWARN("Failed to reserve enough buffers: " - "service %s, %d needed: %d\n", + CWARN("Failed to reserve enough buffers: service %s, %d needed: %d\n", sv->sv_name, sv->sv_wi_total, rc); error = -ENOMEM; } diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 92520c2e08fd..c6ef5b0d8de1 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -119,8 +119,8 @@ lnet_selftest_init(void) rc = cfs_wi_sched_create("lst_t", lnet_cpt_table(), i, nthrs, &lst_sched_test[i]); if (rc != 0) { - CERROR("Failed to create CPT affinity WI scheduler " - "%d for LST\n", i); + CERROR("Failed to create CPT affinity WI scheduler %d for LST\n", + i); goto error; } } diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index c9a1a45923ed..f753add7bfb3 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -678,9 +678,7 @@ srpc_finish_service(struct srpc_service *sv) rpc = list_entry(scd->scd_rpc_active.next, struct srpc_server_rpc, srpc_list); - CNETERR("Active RPC %p on shutdown: sv %s, peer %s, " - "wi %s scheduled %d running %d, " - "ev fired %d type %d status %d lnet %d\n", + CNETERR("Active RPC %p on shutdown: sv %s, peer %s, wi %s scheduled %d running %d, ev fired %d type %d status %d lnet %d\n", rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer), swi_state2str(rpc->srpc_wi.swi_state), rpc->srpc_wi.swi_workitem.wi_scheduled, @@ -1236,20 +1234,18 @@ srpc_send_rpc (swi_workitem_t *wi) if (reply->msg_type != type || (reply->msg_magic != SRPC_MSG_MAGIC && reply->msg_magic != __swab32(SRPC_MSG_MAGIC))) { - CWARN ("Bad message from %s: type %u (%d expected)," - " magic %u (%d expected).\n", - libcfs_id2str(rpc->crpc_dest), - reply->msg_type, type, - reply->msg_magic, SRPC_MSG_MAGIC); + CWARN("Bad message from %s: type %u (%d expected), magic %u (%d expected).\n", + libcfs_id2str(rpc->crpc_dest), + reply->msg_type, type, + reply->msg_magic, SRPC_MSG_MAGIC); rc = -EBADMSG; break; } if (do_bulk && reply->msg_body.reply.status != 0) { - CWARN ("Remote error %d at %s, unlink bulk buffer in " - "case peer didn't initiate bulk transfer\n", - reply->msg_body.reply.status, - libcfs_id2str(rpc->crpc_dest)); + CWARN("Remote error %d at %s, unlink bulk buffer in case peer didn't initiate bulk transfer\n", + reply->msg_body.reply.status, + libcfs_id2str(rpc->crpc_dest)); LNetMDUnlink(rpc->crpc_bulk.bk_mdh); } @@ -1504,11 +1500,10 @@ srpc_lnet_ev_handler(lnet_event_t *ev) msg->msg_type != __swab32(type)) || (msg->msg_magic != SRPC_MSG_MAGIC && msg->msg_magic != __swab32(SRPC_MSG_MAGIC))) { - CERROR ("Dropping RPC (%s) from %s: " - "status %d mlength %d type %u magic %u.\n", - sv->sv_name, libcfs_id2str(ev->initiator), - ev->status, ev->mlength, - msg->msg_type, msg->msg_magic); + CERROR("Dropping RPC (%s) from %s: status %d mlength %d type %u magic %u.\n", + sv->sv_name, libcfs_id2str(ev->initiator), + ev->status, ev->mlength, + msg->msg_type, msg->msg_magic); /* NB can't call srpc_service_recycle_buffer here since * it may call LNetM[DE]Attach. The invalid magic tells diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 9d7e28ace42d..9cd8683573ce 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -87,8 +87,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, if (task == NULL) continue; - LCONSOLE_WARN("%s:%d: lock %p was acquired" - " by <%s:%d:%s:%d> for %lu seconds.\n", + LCONSOLE_WARN("%s:%d: lock %p was acquired by <%s:%d:%s:%d> for %lu seconds.\n", current->comm, current->pid, lock, task->comm, task->pid, lock->func, lock->line, diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 515b835ce14d..9b2833131744 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -368,8 +368,7 @@ static inline void check_lcd(char *obd_name, int index, if (strnlen((char*)lcd->lcd_uuid, length) == length) { lcd->lcd_uuid[length - 1] = '\0'; - LCONSOLE_ERROR("the client UUID (%s) on %s for exports" - "stored in last_rcvd(index = %d) is bad!\n", + LCONSOLE_ERROR("the client UUID (%s) on %s for exports stored in last_rcvd(index = %d) is bad!\n", lcd->lcd_uuid, obd_name, index); } } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index b798daa094bc..e00478b9b50b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -619,8 +619,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) return 0; } - LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " - "sleeping"); + LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, sleeping"); fwd.fwd_lock = lock; obd = class_exp2obd(lock->l_conn_export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index c21e30a074b9..249f3116d74a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -858,8 +858,8 @@ void ldlm_dump_export_locks(struct obd_export *exp) if (!list_empty(&exp->exp_locks_list)) { struct ldlm_lock *lock; - CERROR("dumping locks for export %p," - "ignore if the unmount doesn't hang\n", exp); + CERROR("dumping locks for export %p,ignore if the unmount doesn't hang\n", + exp); list_for_each_entry(lock, &exp->exp_locks_list, l_exp_refs_link) LDLM_ERROR(lock, "lock:"); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 6140130b6056..2c4af89eee7e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -811,8 +811,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) /* If we received a blocked AST and this was the last reference, * run the callback. */ if ((lock->l_flags & LDLM_FL_NS_SRV) && lock->l_export) - CERROR("FL_CBPENDING set on non-local lock--just a " - "warning\n"); + CERROR("FL_CBPENDING set on non-local lock--just a warning\n"); LDLM_DEBUG(lock, "final decref done on cbpending lock"); @@ -1641,8 +1640,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, ldlm_grant_lock(lock, NULL); goto out; } else { - CERROR("This is client-side-only module, cannot handle " - "LDLM_NAMESPACE_SERVER resource type lock.\n"); + CERROR("This is client-side-only module, cannot handle LDLM_NAMESPACE_SERVER resource type lock.\n"); LBUG(); } @@ -1904,8 +1902,7 @@ void ldlm_reprocess_all(struct ldlm_resource *res) LIST_HEAD(rpc_list); if (!ns_is_client(ldlm_res_to_ns(res))) { - CERROR("This is client-side-only module, cannot handle " - "LDLM_NAMESPACE_SERVER resource type lock.\n"); + CERROR("This is client-side-only module, cannot handle LDLM_NAMESPACE_SERVER resource type lock.\n"); LBUG(); } } @@ -2038,8 +2035,7 @@ int ldlm_cancel_locks_for_export_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd, ecl->ecl_loop++; if ((ecl->ecl_loop & -ecl->ecl_loop) == ecl->ecl_loop) { CDEBUG(D_INFO, - "Cancel lock %p for export %p (loop %d), still have " - "%d locks left on hash table.\n", + "Cancel lock %p for export %p (loop %d), still have %d locks left on hash table.\n", lock, exp, ecl->ecl_loop, atomic_read(&hs->hs_count)); } @@ -2169,8 +2165,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, lock->l_completion_ast(lock, 0, NULL); } } else { - CERROR("This is client-side-only module, cannot handle " - "LDLM_NAMESPACE_SERVER resource type lock.\n"); + CERROR("This is client-side-only module, cannot handle LDLM_NAMESPACE_SERVER resource type lock.\n"); LBUG(); } unlock_res_and_lock(lock); @@ -2229,18 +2224,15 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, if (resource == NULL) { libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " - "res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s " - "remote: %#llx expref: %d pid: %u timeout: %lu " - "lvb_type: %d\n", - lock, - lock->l_handle.h_cookie, atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); va_end(args); return; } @@ -2248,90 +2240,78 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, switch (resource->lr_type) { case LDLM_EXTENT: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" rrc: %d type: %s [%llu->%llu] " - "(req %llu->%llu) flags: %#llx nid: %s remote: " - "%#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_extent.start, - lock->l_policy_data.l_extent.end, - lock->l_req_extent.start, lock->l_req_extent.end, - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_extent.start, + lock->l_policy_data.l_extent.end, + lock->l_req_extent.start, lock->l_req_extent.end, + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; case LDLM_FLOCK: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" rrc: %d type: %s pid: %d " - "[%llu->%llu] flags: %#llx nid: %s " - "remote: %#llx expref: %d pid: %u timeout: %lu\n", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_flock.pid, - lock->l_policy_data.l_flock.start, - lock->l_policy_data.l_flock.end, - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout); + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_flock.pid, + lock->l_policy_data.l_flock.start, + lock->l_policy_data.l_flock.end, + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout); break; case LDLM_IBITS: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" bits %#llx rrc: %d type: %s " - "flags: %#llx nid: %s remote: %#llx expref: %d " - "pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), - lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - lock->l_policy_data.l_inodebits.bits, - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + ldlm_lock_to_ns_name(lock), + lock, lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + lock->l_policy_data.l_inodebits.bits, + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; default: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s " - "res: "DLDLMRES" rrc: %d type: %s flags: %#llx " - "nid: %s remote: %#llx expref: %d pid: %u " - "timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), - lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + ldlm_lock_to_ns_name(lock), + lock, lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; } va_end(args); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 91cf7ebae114..5fb9d842f7b9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -210,9 +210,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, LASSERT(lock->l_lvb_data != NULL); if (unlikely(lock->l_lvb_len < lvb_len)) { - LDLM_ERROR(lock, "Replied LVB is larger than " - "expectation, expected = %d, " - "replied = %d", + LDLM_ERROR(lock, "Replied LVB is larger than expectation, expected = %d, replied = %d", lock->l_lvb_len, lvb_len); rc = -EINVAL; goto out; @@ -639,8 +637,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) lock = ldlm_handle2lock_long(&dlm_req->lock_handle[0], 0); if (!lock) { - CDEBUG(D_DLMTRACE, "callback on lock %#llx - lock " - "disappeared\n", dlm_req->lock_handle[0].cookie); + CDEBUG(D_DLMTRACE, "callback on lock %#llx - lock disappeared\n", + dlm_req->lock_handle[0].cookie); rc = ldlm_callback_reply(req, -EINVAL); ldlm_callback_errmsg(req, "Operate with invalid parameter", rc, &dlm_req->lock_handle[0]); @@ -663,8 +661,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) if (((lock->l_flags & LDLM_FL_CANCELING) && (lock->l_flags & LDLM_FL_BL_DONE)) || (lock->l_flags & LDLM_FL_FAILED)) { - LDLM_DEBUG(lock, "callback on lock " - "%#llx - lock disappeared\n", + LDLM_DEBUG(lock, "callback on lock %#llx - lock disappeared\n", dlm_req->lock_handle[0].cookie); unlock_res_and_lock(lock); LDLM_LOCK_RELEASE(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index c80c76a6e181..0e1ab06d2543 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -614,8 +614,8 @@ int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, lprocfs_counter_add(pl->pl_stats, LDLM_POOL_SHRINK_FREED_STAT, cancel); - CDEBUG(D_DLMTRACE, "%s: request to shrink %d locks, " - "shrunk %d\n", pl->pl_name, nr, cancel); + CDEBUG(D_DLMTRACE, "%s: request to shrink %d locks, shrunk %d\n", + pl->pl_name, nr, cancel); } } return cancel; @@ -1194,10 +1194,8 @@ int ldlm_pools_recalc(ldlm_side_t client) * of limit. */ if (nr_l >= 2 * (LDLM_POOL_HOST_L / 3)) { - CWARN("\"Modest\" pools eat out 2/3 of server locks " - "limit (%d of %lu). This means that you have too " - "many clients for this amount of server RAM. " - "Upgrade server!\n", nr_l, LDLM_POOL_HOST_L); + CWARN("\"Modest\" pools eat out 2/3 of server locks limit (%d of %lu). This means that you have too many clients for this amount of server RAM. Upgrade server!\n", + nr_l, LDLM_POOL_HOST_L); equal = 1; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 9ce437b18793..95e71a0922f3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -102,9 +102,7 @@ int ldlm_expired_completion_wait(void *data) lock->l_last_activity, cfs_time_sub(get_seconds(), lock->l_last_activity)); - LDLM_DEBUG(lock, "lock timed out (enqueued at "CFS_TIME_T", " - CFS_DURATION_T"s ago); not entering recovery in " - "server code, just going back to sleep", + LDLM_DEBUG(lock, "lock timed out (enqueued at " CFS_TIME_T ", " CFS_DURATION_T "s ago); not entering recovery in server code, just going back to sleep", lock->l_last_activity, cfs_time_sub(get_seconds(), lock->l_last_activity)); @@ -191,8 +189,7 @@ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data) return ldlm_completion_tail(lock); } - LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " - "going forward"); + LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, going forward"); ldlm_reprocess_all(lock->l_resource); return 0; } @@ -240,8 +237,7 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) return 0; } - LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " - "sleeping"); + LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, sleeping"); noreproc: @@ -324,8 +320,7 @@ int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock) if (rc < 0) CERROR("ldlm_cli_cancel: %d\n", rc); } else { - LDLM_DEBUG(lock, "Lock still has references, will be " - "cancelled later"); + LDLM_DEBUG(lock, "Lock still has references, will be cancelled later"); } return 0; } @@ -483,8 +478,7 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, if (need_cancel) LDLM_DEBUG(lock, - "setting FL_LOCAL_ONLY | LDLM_FL_FAILED | " - "LDLM_FL_ATOMIC_CB | LDLM_FL_CBPENDING"); + "setting FL_LOCAL_ONLY | LDLM_FL_FAILED | LDLM_FL_ATOMIC_CB | LDLM_FL_CBPENDING"); else LDLM_DEBUG(lock, "lock was granted or failed in race"); @@ -557,8 +551,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, rc = size; goto cleanup; } else if (unlikely(size > lvb_len)) { - LDLM_ERROR(lock, "Replied LVB is larger than " - "expectation, expected = %d, replied = %d", + LDLM_ERROR(lock, "Replied LVB is larger than expectation, expected = %d, replied = %d", lvb_len, size); rc = -EINVAL; goto cleanup; @@ -1107,8 +1100,7 @@ static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock) unlock_res_and_lock(lock); if (local_only) { - CDEBUG(D_DLMTRACE, "not sending request (at caller's " - "instruction)\n"); + CDEBUG(D_DLMTRACE, "not sending request (at caller's instruction)\n"); rc = LDLM_FL_LOCAL_ONLY; } ldlm_lock_cancel(lock); @@ -1223,8 +1215,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, rc = ptlrpc_queue_wait(req); } if (rc == LUSTRE_ESTALE) { - CDEBUG(D_DLMTRACE, "client/server (nid %s) " - "out of sync -- not fatal\n", + CDEBUG(D_DLMTRACE, "client/server (nid %s) out of sync -- not fatal\n", libcfs_nid2str(req->rq_import-> imp_connection->c_peer.nid)); rc = 0; @@ -1235,8 +1226,8 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, } else if (rc != ELDLM_OK) { /* -ESHUTDOWN is common on umount */ CDEBUG_LIMIT(rc == -ESHUTDOWN ? D_DLMTRACE : D_ERROR, - "Got rc %d from cancel RPC: " - "canceling anyway\n", rc); + "Got rc %d from cancel RPC: canceling anyway\n", + rc); break; } sent = count; @@ -2114,8 +2105,7 @@ static int replay_lock_interpret(const struct lu_env *env, lock = ldlm_handle2lock(&aa->lock_handle); if (!lock) { - CERROR("received replay ack for unknown local cookie %#llx" - " remote cookie %#llx from server %s id %s\n", + CERROR("received replay ack for unknown local cookie %#llx remote cookie %#llx from server %s id %s\n", aa->lock_handle.cookie, reply->lock_handle.cookie, req->rq_export->exp_client_uuid.uuid, libcfs_id2str(req->rq_peer)); @@ -2243,9 +2233,8 @@ static void ldlm_cancel_unused_locks_for_replay(struct ldlm_namespace *ns) int canceled; LIST_HEAD(cancels); - CDEBUG(D_DLMTRACE, "Dropping as many unused locks as possible before" - "replay for namespace %s (%d)\n", - ldlm_ns_name(ns), ns->ns_nr_unused); + CDEBUG(D_DLMTRACE, "Dropping as many unused locks as possible before replay for namespace %s (%d)\n", + ldlm_ns_name(ns), ns->ns_nr_unused); /* We don't need to care whether or not LRU resize is enabled * because the LDLM_CANCEL_NO_WAIT policy doesn't use the diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 8b20a838b7f2..397adbe3ce0e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -215,8 +215,8 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file, LDLM_CANCEL_PASSED); if (canceled < unused) { CDEBUG(D_DLMTRACE, - "not all requested locks are canceled, " - "requested: %d, canceled: %d\n", unused, + "not all requested locks are canceled, requested: %d, canceled: %d\n", + unused, canceled); return -EINVAL; } @@ -735,8 +735,7 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, } else { ldlm_resource_unlink_lock(lock); unlock_res(res); - LDLM_DEBUG(lock, "Freeing a lock still held by a " - "client node"); + LDLM_DEBUG(lock, "Freeing a lock still held by a client node"); ldlm_lock_destroy(lock); } LDLM_LOCK_RELEASE(lock); @@ -818,16 +817,14 @@ force_wait: /* Forced cleanups should be able to reclaim all references, * so it's safe to wait forever... we can't leak locks... */ if (force && rc == -ETIMEDOUT) { - LCONSOLE_ERROR("Forced cleanup waiting for %s " - "namespace with %d resources in use, " - "(rc=%d)\n", ldlm_ns_name(ns), + LCONSOLE_ERROR("Forced cleanup waiting for %s namespace with %d resources in use, (rc=%d)\n", + ldlm_ns_name(ns), atomic_read(&ns->ns_bref), rc); goto force_wait; } if (atomic_read(&ns->ns_bref)) { - LCONSOLE_ERROR("Cleanup waiting for %s namespace " - "with %d resources in use, (rc=%d)\n", + LCONSOLE_ERROR("Cleanup waiting for %s namespace with %d resources in use, (rc=%d)\n", ldlm_ns_name(ns), atomic_read(&ns->ns_bref), rc); return ELDLM_NAMESPACE_EXISTS; @@ -1404,8 +1401,8 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res) LDLM_DEBUG_LIMIT(level, lock, "###"); if (!(level & D_CANTMASK) && ++granted > ldlm_dump_granted_max) { - CDEBUG(level, "only dump %d granted locks to " - "avoid DDOS.\n", granted); + CDEBUG(level, "only dump %d granted locks to avoid DDOS.\n", + granted); break; } } diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 859129d8ddc8..a7a7ac626aaf 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -318,9 +318,7 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) if (t >= 1 && matched == n) { /* don't print warning for lctl set_param debug=0 or -1 */ if (m != 0 && m != -1) - CWARN("You are trying to use a numerical value for the " - "mask - this will be deprecated in a future " - "release.\n"); + CWARN("You are trying to use a numerical value for the mask - this will be deprecated in a future release.\n"); *mask = m; return 0; } @@ -375,8 +373,8 @@ void libcfs_debug_dumplog(void) (void *)(long)current_pid(), "libcfs_debug_dumper"); if (IS_ERR(dumper)) - pr_err("LustreError: cannot start log dump thread:" - " %ld\n", PTR_ERR(dumper)); + pr_err("LustreError: cannot start log dump thread: %ld\n", + PTR_ERR(dumper)); else schedule(); diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 32da78357c7e..2d1e6729e996 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1121,8 +1121,7 @@ cfs_hash_destroy(struct cfs_hash *hs) cfs_hash_bd_for_each_hlist(hs, &bd, hhead) { hlist_for_each_safe(hnode, pos, hhead) { LASSERTF(!cfs_hash_with_assert_empty(hs), - "hash %s bucket %u(%u) is not " - " empty: %u items left\n", + "hash %s bucket %u(%u) is not empty: %u items left\n", hs->hs_name, bd.bd_bucket->hsb_index, bd.bd_offset, bd.bd_bucket->hsb_count); /* can't assert key valicate, because we diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 224c65b5ce4e..05f7595f18aa 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -333,8 +333,8 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) /* caller doesn't know the partition ID */ cpt = cptab->ctb_cpu2cpt[cpu]; if (cpt < 0) { /* not set in this CPT-table */ - CDEBUG(D_INFO, "Try to unset cpu %d which is " - "not in CPT-table %p\n", cpt, cptab); + CDEBUG(D_INFO, "Try to unset cpu %d which is not in CPT-table %p\n", + cpt, cptab); return; } @@ -384,8 +384,8 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask) int i; if (cpus_weight(*mask) == 0 || any_online_cpu(*mask) == NR_CPUS) { - CDEBUG(D_INFO, "No online CPU is found in the CPU mask " - "for CPU partition %d\n", cpt); + CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n", + cpt); return 0; } @@ -579,9 +579,8 @@ cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) } if (any_online_cpu(*cpumask) == NR_CPUS) { - CERROR("No online CPU found in CPU partition %d, did someone " - "do CPU hotplug on system? You might need to reload " - "Lustre modules to keep system working well.\n", cpt); + CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n", + cpt); return -EINVAL; } @@ -737,16 +736,12 @@ cfs_cpt_table_create(int ncpt) ncpt = rc; if (ncpt > num_online_cpus() || ncpt > 4 * rc) { - CWARN("CPU partition number %d is larger than suggested " - "value (%d), your system may have performance" - "issue or run out of memory while under pressure\n", + CWARN("CPU partition number %d is larger than suggested value (%d), your system may have performance issue or run out of memory while under pressure\n", ncpt, rc); } if (num_online_cpus() % ncpt != 0) { - CERROR("CPU number %d is not multiple of cpu_npartition %d, " - "please try different cpu_npartitions value or" - "set pattern string by cpu_pattern=STRING\n", + CERROR("CPU number %d is not multiple of cpu_npartition %d, please try different cpu_npartitions value or set pattern string by cpu_pattern=STRING\n", (int)num_online_cpus(), ncpt); goto failed; } @@ -796,8 +791,7 @@ cfs_cpt_table_create(int ncpt) if (cpt != ncpt || num != cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)) { - CERROR("Expect %d(%d) CPU partitions but got %d(%d), " - "CPU hotplug/unplug while setting?\n", + CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n", cptab->ctb_nparts, num, cpt, cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)); goto failed; @@ -808,8 +802,7 @@ cfs_cpt_table_create(int ncpt) return cptab; failed: - CERROR("Failed to setup CPU-partition-table with %d " - "CPU-partitions, online HW nodes: %d, HW cpus: %d.\n", + CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, online HW nodes: %d, HW cpus: %d.\n", ncpt, num_online_nodes(), num_online_cpus()); if (mask != NULL) @@ -975,9 +968,8 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids; mutex_unlock(&cpt_data.cpt_mutex); CDEBUG(warn ? D_WARNING : D_INFO, - "Lustre: can't support CPU plug-out well now, " - "performance and stability could be impacted " - "[CPU %u action: %lx]\n", cpu, action); + "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", + cpu, action); } return NOTIFY_OK; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 3298ddf6d3be..12005a71aa73 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -87,8 +87,7 @@ void libcfs_run_debug_log_upcall(char *file) rc = call_usermodehelper(argv[0], argv, envp, 1); if (rc < 0 && rc != -ENOENT) { - CERROR("Error %d invoking LNET debug log upcall %s %s; " - "check /proc/sys/lnet/debug_log_upcall\n", + CERROR("Error %d invoking LNET debug log upcall %s %s; check /proc/sys/lnet/debug_log_upcall\n", rc, argv[0], argv[1]); } else { CDEBUG(D_HA, "Invoked LNET debug log upcall %s %s\n", @@ -114,8 +113,7 @@ void libcfs_run_upcall(char **argv) rc = call_usermodehelper(argv[0], argv, envp, 1); if (rc < 0 && rc != -ENOENT) { - CERROR("Error %d invoking LNET upcall %s %s%s%s%s%s%s%s%s; " - "check /proc/sys/lnet/upcall\n", + CERROR("Error %d invoking LNET upcall %s %s%s%s%s%s%s%s%s; check /proc/sys/lnet/upcall\n", rc, argv[0], argv[1], argc < 3 ? "" : ",", argc < 3 ? "" : argv[2], argc < 4 ? "" : ",", argc < 4 ? "" : argv[3], diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 939b33dd6520..b91a1f95bbd0 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -279,8 +279,7 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); if (rc != 0) { - CERROR("Can't set socket send timeout " - "%ld.%06d: %d\n", + CERROR("Can't set socket send timeout %ld.%06d: %d\n", (long)tv.tv_sec, (int)tv.tv_usec, rc); return rc; } diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 7e3f6a45da00..5fded5a363bd 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -196,8 +196,7 @@ static void cfs_tcd_shrink(struct cfs_trace_cpu_data *tcd) */ if (printk_ratelimit()) - printk(KERN_WARNING "debug daemon buffer overflowed; " - "discarding 10%% of pages (%d of %ld)\n", + printk(KERN_WARNING "debug daemon buffer overflowed; discarding 10%% of pages (%d of %ld)\n", pgcount + 1, tcd->tcd_cur_pages); INIT_LIST_HEAD(&pc.pc_pages); @@ -357,8 +356,8 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, } if (*(string_buf+needed-1) != '\n') - printk(KERN_INFO "format at %s:%d:%s doesn't end in " - "newline\n", file, msgdata->msg_line, msgdata->msg_fn); + printk(KERN_INFO "format at %s:%d:%s doesn't end in newline\n", + file, msgdata->msg_line, msgdata->msg_fn); header.ph_len = known_size + needed; debug_buf = (char *)page_address(tage->page) + tage->used; @@ -715,8 +714,8 @@ int cfs_tracefile_dump_all_pages(char *filename) kunmap(tage->page); if (rc != (int)tage->used) { - printk(KERN_WARNING "wanted to write %u but wrote " - "%d\n", tage->used, rc); + printk(KERN_WARNING "wanted to write %u but wrote %d\n", + tage->used, rc); put_pages_back(&pc); __LASSERT(list_empty(&pc.pc_pages)); break; @@ -875,8 +874,8 @@ int cfs_trace_daemon_command(char *str) strcpy(cfs_tracefile, str); printk(KERN_INFO - "Lustre: debug daemon will attempt to start writing " - "to %s (%lukB max)\n", cfs_tracefile, + "Lustre: debug daemon will attempt to start writing to %s (%lukB max)\n", + cfs_tracefile, (long)(cfs_tracefile_size >> 10)); cfs_trace_start_thread(); @@ -914,15 +913,15 @@ int cfs_trace_set_debug_mb(int mb) if (mb < num_possible_cpus()) { printk(KERN_WARNING - "Lustre: %d MB is too small for debug buffer size, " - "setting it to %d MB.\n", mb, num_possible_cpus()); + "Lustre: %d MB is too small for debug buffer size, setting it to %d MB.\n", + mb, num_possible_cpus()); mb = num_possible_cpus(); } if (mb > limit) { printk(KERN_WARNING - "Lustre: %d MB is too large for debug buffer size, " - "setting it to %d MB.\n", mb, limit); + "Lustre: %d MB is too large for debug buffer size, setting it to %d MB.\n", + mb, limit); mb = limit; } @@ -1004,8 +1003,8 @@ static int tracefiled(void *arg) if (IS_ERR(filp)) { rc = PTR_ERR(filp); filp = NULL; - printk(KERN_WARNING "couldn't open %s: " - "%d\n", cfs_tracefile, rc); + printk(KERN_WARNING "couldn't open %s: %d\n", + cfs_tracefile, rc); } } cfs_tracefile_read_unlock(); @@ -1034,8 +1033,8 @@ static int tracefiled(void *arg) kunmap(tage->page); if (rc != (int)tage->used) { - printk(KERN_WARNING "wanted to write %u " - "but wrote %d\n", tage->used, rc); + printk(KERN_WARNING "wanted to write %u but wrote %d\n", + tage->used, rc); put_pages_back(&pc); __LASSERT(list_empty(&pc.pc_pages)); } @@ -1047,8 +1046,7 @@ static int tracefiled(void *arg) if (!list_empty(&pc.pc_pages)) { int i; - printk(KERN_ALERT "Lustre: trace pages aren't " - " empty\n"); + printk(KERN_ALERT "Lustre: trace pages aren't empty\n"); printk(KERN_ERR "total cpus(%d): ", num_possible_cpus()); for (i = 0; i < num_possible_cpus(); i++) @@ -1061,8 +1059,8 @@ static int tracefiled(void *arg) i = 0; list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) - printk(KERN_ERR "page %d belongs to cpu " - "%d\n", ++i, tage->cpu); + printk(KERN_ERR "page %d belongs to cpu %d\n", + ++i, tage->cpu); printk(KERN_ERR "There are %d pages unwritten\n", i); } diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 439e4875b05c..5f03c5fbb098 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -259,9 +259,9 @@ void ll_invalidate_aliases(struct inode *inode) ll_lock_dcache(inode); ll_d_hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) { - CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p " - "inode %p flags %d\n", dentry->d_name.len, - dentry->d_name.name, dentry, dentry->d_parent, + CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p inode %p flags %d\n", + dentry->d_name.len, dentry->d_name.name, + dentry, dentry->d_parent, dentry->d_inode, dentry->d_flags); if (unlikely(dentry == dentry->d_sb->s_root)) { diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 661b2cf2f804..1f181c80838c 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -228,8 +228,8 @@ static int ll_dir_filler(void *_hash, struct page *page0) if (ll_pagevec_add(&lru_pvec, page) == 0) ll_pagevec_lru_add_file(&lru_pvec); } else { - CDEBUG(D_VFSTRACE, "page %lu add to page cache failed:" - " %d\n", offset, ret); + CDEBUG(D_VFSTRACE, "page %lu add to page cache failed: %d\n", + offset, ret); } page_cache_release(page); } @@ -600,8 +600,8 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx) int api32 = ll_need_32bit_api(sbi); int rc; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu " - " 32bit_api %d\n", inode->i_ino, inode->i_generation, + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu 32bit_api %d\n", + inode->i_ino, inode->i_generation, inode, (unsigned long)lfd->lfd_pos, i_size_read(inode), api32); if (lfd->lfd_pos == MDS_DIR_END_OFF) { @@ -715,10 +715,9 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, break; } default: { - CDEBUG(D_IOCTL, "bad userland LOV MAGIC:" - " %#08x != %#08x nor %#08x\n", - lump->lmm_magic, LOV_USER_MAGIC_V1, - LOV_USER_MAGIC_V3); + CDEBUG(D_IOCTL, "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n", + lump->lmm_magic, LOV_USER_MAGIC_V1, + LOV_USER_MAGIC_V3); return -EINVAL; } } @@ -814,8 +813,8 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, rc = md_getattr(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc < 0) { - CDEBUG(D_INFO, "md_getattr failed on inode " - "%lu/%u: rc %d\n", inode->i_ino, + CDEBUG(D_INFO, "md_getattr failed on inode %lu/%u: rc %d\n", + inode->i_ino, inode->i_generation, rc); goto out; } @@ -1013,8 +1012,7 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) copy->hc_hai.hai_action == HSMA_ARCHIVE); iput(inode); if (rc) { - CDEBUG(D_HSM, "Could not read file data version. " - "Request could not be confirmed.\n"); + CDEBUG(D_HSM, "Could not read file data version. Request could not be confirmed.\n"); if (hpk.hpk_errval == 0) hpk.hpk_errval = -rc; goto progress; @@ -1028,8 +1026,7 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) * to check anyway. */ if ((copy->hc_hai.hai_action == HSMA_ARCHIVE) && (copy->hc_data_version != data_version)) { - CDEBUG(D_HSM, "File data version mismatched. " - "File content was changed during archiving. " + CDEBUG(D_HSM, "File data version mismatched. File content was changed during archiving. " DFID", start:%#llx current:%#llx\n", PFID(©->hc_hai.hai_fid), copy->hc_data_version, data_version); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index a5acc98a1c99..234c7143008a 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -170,8 +170,8 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, * OSTs and send setattr to back to MDS. */ rc = ll_som_update(inode, op_data); if (rc) { - CERROR("inode %lu mdc Size-on-MDS update failed: " - "rc = %d\n", inode->i_ino, rc); + CERROR("inode %lu mdc Size-on-MDS update failed: rc = %d\n", + inode->i_ino, rc); rc = 0; } } else if (rc) { @@ -989,8 +989,8 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, struct ost_id *oi = lsm ? &lsm->lsm_oi : &obdo->o_oi; obdo_refresh_inode(inode, obdo, obdo->o_valid); - CDEBUG(D_INODE, "objid "DOSTID" size %llu, blocks %llu," - " blksize %lu\n", POSTID(oi), i_size_read(inode), + CDEBUG(D_INODE, "objid " DOSTID " size %llu, blocks %llu, blksize %lu\n", + POSTID(oi), i_size_read(inode), (unsigned long long)inode->i_blocks, 1UL << inode->i_blkbits); } @@ -1418,8 +1418,8 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc < 0) { - CDEBUG(D_INFO, "md_getattr_name failed " - "on %s: rc %d\n", filename, rc); + CDEBUG(D_INFO, "md_getattr_name failed on %s: rc %d\n", + filename, rc); goto out; } @@ -2233,8 +2233,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (cmd == LL_IOC_SETFLAGS) { if ((flags & LL_FILE_IGNORE_LOCK) && !(file->f_flags & O_DIRECT)) { - CERROR("%s: unable to disable locking on " - "non-O_DIRECT file\n", current->comm); + CERROR("%s: unable to disable locking on non-O_DIRECT file\n", + current->comm); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index b1e39ee412cd..aec9a44120c0 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -540,8 +540,7 @@ static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) if (rc == -EIO && !capa_is_expired(ocapa)) { delay_capa_renew(ocapa, 120); DEBUG_CAPA(D_ERROR, &ocapa->c_capa, - "renewal failed: -EIO, " - "retry in 2 mins"); + "renewal failed: -EIO, retry in 2 mins"); ll_capa_renewal_retries++; goto retry; } else { diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 84e0003f2daf..21b4a5026776 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -90,8 +90,7 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) struct ll_close_queue *lcq = ll_i2sbi(inode)->ll_lcq; if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) - CWARN("ino %lu/%u(flags %u) som valid it just after " - "recovery\n", + CWARN("ino %lu/%u(flags %u) som valid it just after recovery\n", inode->i_ino, inode->i_generation, lli->lli_flags); /* DONE_WRITING is allowed and inode has no dirty page. */ @@ -124,8 +123,8 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) op_data->op_flags |= MF_SOM_CHANGE; /* Check if Size-on-MDS attributes are valid. */ if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) - CERROR("ino %lu/%u(flags %u) som valid it just after " - "recovery\n", inode->i_ino, inode->i_generation, + CERROR("ino %lu/%u(flags %u) som valid it just after recovery\n", + inode->i_ino, inode->i_generation, lli->lli_flags); if (!cl_local_size(inode)) { @@ -218,8 +217,8 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) LASSERT(op_data != NULL); if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) - CERROR("ino %lu/%u(flags %u) som valid it just after " - "recovery\n", inode->i_ino, inode->i_generation, + CERROR("ino %lu/%u(flags %u) som valid it just after recovery\n", + inode->i_ino, inode->i_generation, lli->lli_flags); OBDO_ALLOC(oa); @@ -238,9 +237,8 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) if (rc) { oa->o_valid = 0; if (rc != -ENOENT) - CERROR("inode_getattr failed (%d): unable to " - "send a Size-on-MDS attribute update " - "for inode %lu/%u\n", rc, inode->i_ino, + CERROR("inode_getattr failed (%d): unable to send a Size-on-MDS attribute update for inode %lu/%u\n", + rc, inode->i_ino, inode->i_generation); } else { CDEBUG(D_INODE, "Size-on-MDS update on "DFID"\n", diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 2845aab282ea..79fc29b3710c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1435,8 +1435,8 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, * case the dcache being cleared */ if (it->d.lustre.it_remote_lock_mode) { handle.cookie = it->d.lustre.it_remote_lock_handle; - CDEBUG(D_DLMTRACE, "setting l_data to inode %p" - "(%lu/%u) for remote lock %#llx\n", inode, + CDEBUG(D_DLMTRACE, "setting l_data to inode %p(%lu/%u) for remote lock %#llx\n", + inode, inode->i_ino, inode->i_generation, handle.cookie); md_set_lock_data(exp, &handle.cookie, inode, NULL); @@ -1444,8 +1444,8 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, handle.cookie = it->d.lustre.it_lock_handle; - CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)" - " for lock %#llx\n", inode, inode->i_ino, + CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u) for lock %#llx\n", + inode, inode->i_ino, inode->i_generation, handle.cookie); md_set_lock_data(exp, &handle.cookie, inode, @@ -1489,8 +1489,8 @@ static inline void __d_lustre_invalidate(struct dentry *dentry) */ static inline void d_lustre_invalidate(struct dentry *dentry, int nested) { - CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p " - "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry, + CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p refc %d\n", + dentry->d_name.len, dentry->d_name.name, dentry, dentry->d_parent, dentry->d_inode, d_count(dentry)); spin_lock_nested(&dentry->d_lock, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index afb433a33d25..3b0336029da3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -253,10 +253,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { - LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing " - "recovery, of which this client is not a " - "part. Please wait for recovery to complete," - " abort, or time out.\n", md); + LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", + md); goto out; } else if (err) { CERROR("cannot connect to %s: rc = %d\n", md, err); @@ -268,8 +266,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = obd_fid_init(sbi->ll_md_exp->exp_obd, sbi->ll_md_exp, LUSTRE_SEQ_METADATA); if (err) { - CERROR("%s: Can't init metadata layer FID infrastructure, " - "rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); + CERROR("%s: Can't init metadata layer FID infrastructure, rc = %d\n", + sbi->ll_md_exp->exp_obd->obd_name, err); goto out_md; } @@ -297,10 +295,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL); obd_connect_flags2str(buf, PAGE_CACHE_SIZE, valid ^ CLIENT_CONNECT_MDT_REQD, ","); - LCONSOLE_ERROR_MSG(0x170, "Server %s does not support " - "feature(s) needed for correct operation " - "of this client (%s). Please upgrade " - "server or downgrade client.\n", + LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n", sbi->ll_md_exp->exp_obd->obd_name, buf); OBD_FREE(buf, PAGE_CACHE_SIZE); err = -EPROTO; @@ -326,8 +321,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if ((sbi->ll_flags & LL_SBI_USER_XATTR) && !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) { - LCONSOLE_INFO("Disabling user_xattr feature because " - "it is not supported on the server\n"); + LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } @@ -352,8 +346,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, } else { if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { sbi->ll_flags &= ~LL_SBI_RMT_CLIENT; - LCONSOLE_INFO("client claims to be remote, but server " - "rejected, forced to be local.\n"); + LCONSOLE_INFO("client claims to be remote, but server rejected, forced to be local.\n"); } } @@ -430,8 +423,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (sbi->ll_flags & LL_SBI_RMT_CLIENT) data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE; - CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d " - "ocd_grant: %d\n", data->ocd_connect_flags, + CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d\n", + data->ocd_connect_flags, data->ocd_version, data->ocd_grant); obd->obd_upcall.onu_owner = &sbi->ll_lco; @@ -442,10 +435,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { - LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing " - "recovery, of which this client is not a " - "part. Please wait for recovery to " - "complete, abort, or time out.\n", dt); + LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", + dt); goto out_md; } else if (err) { CERROR("%s: Cannot connect to %s: rc = %d\n", @@ -458,8 +449,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = obd_fid_init(sbi->ll_dt_exp->exp_obd, sbi->ll_dt_exp, LUSTRE_SEQ_METADATA); if (err) { - CERROR("%s: Can't init data layer FID infrastructure, " - "rc = %d\n", sbi->ll_dt_exp->exp_obd->obd_name, err); + CERROR("%s: Can't init data layer FID infrastructure, rc = %d\n", + sbi->ll_dt_exp->exp_obd->obd_name, err); goto out_dt; } @@ -699,8 +690,8 @@ void lustre_dump_dentry(struct dentry *dentry, int recur) list_for_each(tmp, &dentry->d_subdirs) subdirs++; - CERROR("dentry %p dump: name=%.*s parent=%.*s (%p), inode=%p, count=%u," - " flags=0x%x, fsdata=%p, %d subdirs\n", dentry, + CERROR("dentry %p dump: name=%.*s parent=%.*s (%p), inode=%p, count=%u, flags=0x%x, fsdata=%p, %d subdirs\n", + dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_parent->d_name.len, dentry->d_parent->d_name.name, dentry->d_parent, dentry->d_inode, d_count(dentry), @@ -1023,9 +1014,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */ lprof = class_get_profile(profilenm); if (lprof == NULL) { - LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be" - " read from the MGS. Does that filesystem " - "exist?\n", profilenm); + LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be read from the MGS. Does that filesystem exist?\n", + profilenm); err = -EINVAL; goto out_free; } @@ -1141,8 +1131,7 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) } else { inode = lock->l_resource->lr_lvb_inode; LDLM_DEBUG_LIMIT(inode->i_state & I_FREEING ? D_INFO : - D_WARNING, lock, "lr_lvb_inode %p is " - "bogus: magic %08x", + D_WARNING, lock, "lr_lvb_inode %p is bogus: magic %08x", lock->l_resource->lr_lvb_inode, lli->lli_inode_magic); inode = NULL; @@ -1763,9 +1752,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) if (lli->lli_flags & (LLIF_DONE_WRITING | LLIF_EPOCH_PENDING | LLIF_SOM_DIRTY)) { - CERROR("ino %lu flags %u still has " - "size authority! do not trust " - "the size got from MDS\n", + CERROR("ino %lu flags %u still has size authority! do not trust the size got from MDS\n", inode->i_ino, lli->lli_flags); } else { /* Use old size assignment to avoid @@ -1867,8 +1854,7 @@ void ll_delete_inode(struct inode *inode) spin_lock_irq(&inode->i_data.tree_lock); spin_unlock_irq(&inode->i_data.tree_lock); LASSERTF(inode->i_data.nrpages == 0, - "inode=%lu/%u(%p) nrpages=%lu, see " - "http://jira.whamcloud.com/browse/LU-118\n", + "inode=%lu/%u(%p) nrpages=%lu, see http://jira.whamcloud.com/browse/LU-118\n", inode->i_ino, inode->i_generation, inode, inode->i_data.nrpages); } @@ -2418,8 +2404,8 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret) } CDEBUG(D_WARNING, - "%s: dirty page discard: %s/fid: "DFID"/%s may get corrupted " - "(rc %d)\n", ll_get_fsname(page->mapping->host->i_sb, NULL, 0), + "%s: dirty page discard: %s/fid: " DFID "/%s may get corrupted (rc %d)\n", + ll_get_fsname(page->mapping->host->i_sb, NULL, 0), s2lsi(page->mapping->host->i_sb)->lsi_lmd->lmd_dev, PFID(&obj->cob_header.coh_lu.loh_fid), (path && !IS_ERR(path)) ? path : "", ioret); diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index ae605a6d9dc2..e72b14daccef 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -234,8 +234,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, */ unlock_page(vmpage); - CDEBUG(D_MMAP, "Race on page_mkwrite %p/%lu, page has " - "been written out, retry.\n", + CDEBUG(D_MMAP, "Race on page_mkwrite %p/%lu, page has been written out, retry.\n", vmpage, vmpage->index); *retry = true; @@ -366,8 +365,7 @@ restart: vmf->page = NULL; if (!printed && ++count > 16) { - CWARN("the page is under heavy contention," - "maybe your app(%s) needs revising :-)\n", + CWARN("the page is under heavy contention, maybe your app(%s) needs revising :-)\n", current->comm); printed = true; } @@ -393,8 +391,7 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) result = ll_page_mkwrite0(vma, vmf->page, &retry); if (!printed && ++count > 16) { - CWARN("app(%s): the page %lu of file %lu is under heavy" - " contention.\n", + CWARN("app(%s): the page %lu of file %lu is under heavy contention.\n", current->comm, vmf->pgoff, vma->vm_file->f_dentry->d_inode->i_ino); printed = true; diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index 586f49a374ec..f4da156f3874 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -131,8 +131,8 @@ int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops) spin_lock(&rct->rct_lock); e = __rct_search(rct, key); if (unlikely(e != NULL)) { - CWARN("Unexpected stale rmtacl_entry found: " - "[key: %d] [ops: %d]\n", (int)key, ops); + CWARN("Unexpected stale rmtacl_entry found: [key: %d] [ops: %d]\n", + (int)key, ops); rce_free(e); } list_add_tail(&rce->rce_list, &rct->rct_entries[rce_hashfunc(key)]); @@ -263,8 +263,7 @@ int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type, spin_lock(&et->et_lock); e = __et_search_del(et, key, fid, type); if (unlikely(e != NULL)) { - CWARN("Unexpected stale eacl_entry found: " - "[key: %d] [fid: "DFID"] [type: %d]\n", + CWARN("Unexpected stale eacl_entry found: [key: %d] [fid: " DFID "] [type: %d]\n", (int)key, PFID(fid), type); ee_free(e); } diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index e0f39fec2787..b6325c01890b 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -778,8 +778,8 @@ static int __init lloop_init(void) if (max_loop < 1 || max_loop > 256) { max_loop = MAX_LOOP_DEFAULT; - CWARN("lloop: invalid max_loop (must be between" - " 1 and 256), using default (%u)\n", max_loop); + CWARN("lloop: invalid max_loop (must be between 1 and 256), using default (%u)\n", + max_loop); } lloop_major = register_blkdev(0, "lloop"); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 4dc1bfa5c1cf..e6a909e6faf0 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -284,8 +284,7 @@ static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file, if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages) { - CERROR("can't set file readahead more than" - "max_read_ahead_mb %lu MB\n", + CERROR("can't set file readahead more than max_read_ahead_mb %lu MB\n", sbi->ll_ra_info.ra_max_pages); return -ERANGE; } @@ -330,9 +329,8 @@ static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file, * algorithm does this anyway so it's pointless to set it larger. */ if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages_per_file) { - CERROR("can't set max_read_ahead_whole_mb more than " - "max_read_ahead_per_file_mb: %lu\n", - sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT)); + CERROR("can't set max_read_ahead_whole_mb more than max_read_ahead_per_file_mb: %lu\n", + sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT)); return -ERANGE; } @@ -619,8 +617,8 @@ static ssize_t ll_statahead_max_seq_write(struct file *file, if (val >= 0 && val <= LL_SA_RPC_MAX) sbi->ll_sa_max = val; else - CERROR("Bad statahead_max value %d. Valid values are in the " - "range [0, %d]\n", val, LL_SA_RPC_MAX); + CERROR("Bad statahead_max value %d. Valid values are in the range [0, %d]\n", + val, LL_SA_RPC_MAX); return count; } @@ -770,8 +768,8 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) while (flags != 0) { if (ARRAY_SIZE(str) <= i) { - CERROR("%s: Revise array LL_SBI_FLAGS to match sbi " - "flags please.\n", ll_get_fsname(sb, NULL, 0)); + CERROR("%s: Revise array LL_SBI_FLAGS to match sbi flags please.\n", + ll_get_fsname(sb, NULL, 0)); return -EINVAL; } @@ -1143,8 +1141,8 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents, read_cum += r; write_cum += w; end = 1 << (i + LL_HIST_START - units); - seq_printf(seq, "%4lu%c - %4lu%c%c: %14lu %4lu %4lu | " - "%14lu %4lu %4lu\n", start, *unitp, end, *unitp, + seq_printf(seq, "%4lu%c - %4lu%c%c: %14lu %4lu %4lu | %14lu %4lu %4lu\n", + start, *unitp, end, *unitp, (i == LL_HIST_MAX - 1) ? '+' : ' ', r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), pct(write_cum, write_tot)); @@ -1170,8 +1168,7 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) if (!sbi->ll_rw_stats_on) { seq_printf(seq, "disabled\n" - "write anything in this file to activate, " - "then 0 or \"[D/d]isabled\" to deactivate\n"); + "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); return 0; } seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", @@ -1249,8 +1246,7 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) if (!sbi->ll_rw_stats_on) { seq_printf(seq, "disabled\n" - "write anything in this file to activate, " - "then 0 or \"[D/d]isabled\" to deactivate\n"); + "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); return 0; } seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", @@ -1428,8 +1424,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) if (!sbi->ll_rw_stats_on) { seq_printf(seq, "disabled\n" - "write anything in this file to activate, " - "then 0 or \"[D/d]isabled\" to deactivate\n"); + "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); return 0; } spin_lock(&sbi->ll_process_lock); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 2971a26370be..671d0cd2a6a2 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -104,8 +104,8 @@ static int ll_set_inode(struct inode *inode, void *opaque) lli->lli_fid = body->fid1; if (unlikely(!(body->valid & OBD_MD_FLTYPE))) { - CERROR("Can not initialize inode "DFID" without object type: " - "valid = %#llx\n", PFID(&lli->lli_fid), body->valid); + CERROR("Can not initialize inode " DFID " without object type: valid = %#llx\n", + PFID(&lli->lli_fid), body->valid); return -EINVAL; } @@ -619,8 +619,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, long long lookup_flags = LOOKUP_OPEN; int rc = 0; - CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),file %p," - "open_flags %x,mode %x opened %d\n", + CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),file %p,open_flags %x,mode %x opened %d\n", dentry->d_name.len, dentry->d_name.name, dir->i_ino, dir->i_generation, dir, file, open_flags, mode, *opened); @@ -863,8 +862,7 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry, { int rc; - CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)," - "flags=%u, excl=%d\n", + CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),flags=%u, excl=%d\n", dentry->d_name.len, dentry->d_name.name, dir->i_ino, dir->i_generation, dir, mode, want_excl); @@ -1151,8 +1149,8 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, int err; CDEBUG(D_VFSTRACE, - "VFS Op:oldname=%.*s,src_dir=%lu/%u(%p),newname=%.*s," - "tgt_dir=%lu/%u(%p)\n", src_name->len, src_name->name, + "VFS Op:oldname=%.*s,src_dir=%lu/%u(%p),newname=%.*s,tgt_dir=%lu/%u(%p)\n", + src_name->len, src_name->name, src->i_ino, src->i_generation, src, tgt_name->len, tgt_name->name, tgt->i_ino, tgt->i_generation, tgt); diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 613d772357ac..10a0421366d0 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -121,8 +121,8 @@ static struct ll_cl_context *ll_cl_init(struct file *file, /* this is too bad. Someone is trying to write the * page w/o holding inode mutex. This means we can * add dirty pages into cache during truncate */ - CERROR("Proc %s is dirting page w/o inode lock, this" - "will break truncate.\n", current->comm); + CERROR("Proc %s is dirtying page w/o inode lock, this will break truncate\n", + current->comm); dump_stack(); LBUG(); return ERR_PTR(-EIO); @@ -606,8 +606,8 @@ stride_pg_count(pgoff_t st_off, unsigned long st_len, unsigned long st_pgs, else pg_count = start_left + st_pgs * (end - start - 1) + end_left; - CDEBUG(D_READA, "st_off %lu, st_len %lu st_pgs %lu off %lu length %lu" - "pgcount %lu\n", st_off, st_len, st_pgs, off, length, pg_count); + CDEBUG(D_READA, "st_off %lu, st_len %lu st_pgs %lu off %lu length %lu pgcount %lu\n", + st_off, st_len, st_pgs, off, length, pg_count); return pg_count; } @@ -667,10 +667,10 @@ static int ll_read_ahead_pages(const struct lu_env *env, /* FIXME: This assertion only is valid when it is for * forward read-ahead, it will be fixed when backward * read-ahead is implemented */ - LASSERTF(page_idx > ria->ria_stoff, "Invalid page_idx %lu" - "rs %lu re %lu ro %lu rl %lu rp %lu\n", page_idx, - ria->ria_start, ria->ria_end, ria->ria_stoff, - ria->ria_length, ria->ria_pages); + LASSERTF(page_idx > ria->ria_stoff, "Invalid page_idx %lu rs %lu re %lu ro %lu rl %lu rp %lu\n", + page_idx, + ria->ria_start, ria->ria_end, ria->ria_stoff, + ria->ria_length, ria->ria_pages); offset = page_idx - ria->ria_stoff; offset = offset % (ria->ria_length); if (offset > ria->ria_pages) { @@ -927,8 +927,8 @@ static void ras_stride_increase_window(struct ll_readahead_state *ras, LASSERT(ras->ras_stride_length > 0); LASSERTF(ras->ras_window_start + ras->ras_window_len - >= ras->ras_stride_offset, "window_start %lu, window_len %lu" - " stride_offset %lu\n", ras->ras_window_start, + >= ras->ras_stride_offset, "window_start %lu, window_len %lu stride_offset %lu\n", + ras->ras_window_start, ras->ras_window_len, ras->ras_stride_offset); stride_len = ras->ras_window_start + ras->ras_window_len - diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 85d451f17c02..c4bd09edb0ce 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -1491,10 +1491,7 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) sai->sai_consecutive_miss++; if (sa_low_hit(sai) && thread_is_running(thread)) { atomic_inc(&sbi->ll_sa_wrong); - CDEBUG(D_READA, "Statahead for dir "DFID" hit " - "ratio too low: hit/miss %llu/%llu" - ", sent/replied %llu/%llu, stopping " - "statahead thread\n", + CDEBUG(D_READA, "Statahead for dir " DFID " hit ratio too low: hit/miss %llu/%llu, sent/replied %llu/%llu, stopping statahead thread\n", PFID(&lli->lli_fid), sai->sai_hit, sai->sai_miss, sai->sai_sent, sai->sai_replied); @@ -1612,8 +1609,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } else if ((*dentryp)->d_inode != inode) { /* revalidate, but inode is recreated */ CDEBUG(D_READA, - "stale dentry %.*s inode %lu/%u, " - "statahead inode %lu/%u\n", + "stale dentry %.*s inode %lu/%u, statahead inode %lu/%u\n", (*dentryp)->d_name.len, (*dentryp)->d_name.name, (*dentryp)->d_inode->i_ino, @@ -1666,8 +1662,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, if (unlikely(sai->sai_inode != parent->d_inode)) { struct ll_inode_info *nlli = ll_i2info(parent->d_inode); - CWARN("Race condition, someone changed %.*s just now: " - "old parent "DFID", new parent "DFID"\n", + CWARN("Race condition, someone changed %.*s just now: old parent " DFID ", new parent " DFID "\n", (*dentryp)->d_name.len, (*dentryp)->d_name.name, PFID(&lli->lli_fid), PFID(&nlli->lli_fid)); dput(parent); diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index eccd3a717a4d..686b6a574cc5 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -100,8 +100,8 @@ static int ll_readlink_internal(struct inode *inode, if (*symname == NULL || strnlen(*symname, symlen) != symlen - 1) { /* not full/NULL terminated */ - CERROR("inode %lu: symlink not NULL terminated string" - "of length %d\n", inode->i_ino, symlen - 1); + CERROR("inode %lu: symlink not NULL terminated string of length %d\n", + inode->i_ino, symlen - 1); rc = -EPROTO; goto failed; } diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 168aafb95f25..5675ff0a883f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -720,9 +720,8 @@ static int vvp_io_fault_start(const struct lu_env *env, last_index = cl_index(obj, size - 1); if (last_index < fio->ft_index) { CDEBUG(D_PAGE, - "llite: mkwrite and truncate race happened: " - "%p: 0x%lx 0x%lx\n", - vmpage->mapping, fio->ft_index, last_index); + "llite: mkwrite and truncate race happened: %p: 0x%lx 0x%lx\n", + vmpage->mapping, fio->ft_index, last_index); /* * We need to return if we are * passed the end of the file. This will propagate diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 4626346f6ee1..954ed08c6af2 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -376,8 +376,7 @@ static int vvp_page_print(const struct lu_env *env, struct ccc_page *vp = cl2ccc_page(slice); struct page *vmpage = vp->cpg_page; - (*printer)(env, cookie, LUSTRE_VVP_NAME"-page@%p(%d:%d:%d) " - "vm@%p ", + (*printer)(env, cookie, LUSTRE_VVP_NAME "-page@%p(%d:%d:%d) vm@%p ", vp, vp->cpg_defer_uptodate, vp->cpg_ra_used, vp->cpg_write_queued, vmpage); if (vmpage != NULL) { diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 3ad979635c60..56ab3e6f83dd 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -201,8 +201,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, #endif if (rc) { if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) { - LCONSOLE_INFO("Disabling user_xattr feature because " - "it is not supported on the server\n"); + LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } return rc; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index e8421f04beda..ee235926f52b 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -75,8 +75,7 @@ int lmv_fld_lookup(struct lmv_obd *lmv, *mds, PFID(fid)); if (*mds >= lmv->desc.ld_tgt_count) { - CERROR("FLD lookup got invalid mds #%x (max: %x) " - "for fid="DFID"\n", *mds, lmv->desc.ld_tgt_count, + CERROR("FLD lookup got invalid mds #%x (max: %x) for fid=" DFID "\n", *mds, lmv->desc.ld_tgt_count, PFID(fid)); rc = -EINVAL; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 5106124b7d92..d22d57b4ff38 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -186,8 +186,8 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, return rc; } - CDEBUG(D_INODE, "OPEN_INTENT with fid1="DFID", fid2="DFID"," - " name='%s' -> mds #%d\n", PFID(&op_data->op_fid1), + CDEBUG(D_INODE, "OPEN_INTENT with fid1=" DFID ", fid2=" DFID ", name='%s' -> mds #%d\n", + PFID(&op_data->op_fid1), PFID(&op_data->op_fid2), op_data->op_name, tgt->ltd_idx); rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it, flags, @@ -226,8 +226,8 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, * this is normal situation, we should not print error here, * only debug info. */ - CDEBUG(D_INODE, "Can't handle remote %s: dir "DFID"("DFID"):" - "%*s: %d\n", LL_IT2STR(it), PFID(&op_data->op_fid2), + CDEBUG(D_INODE, "Can't handle remote %s: dir " DFID "(" DFID "):%*s: %d\n", + LL_IT2STR(it), PFID(&op_data->op_fid2), PFID(&op_data->op_fid1), op_data->op_namelen, op_data->op_name, rc); return rc; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index dc170d87851b..9f3837412cdf 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -325,8 +325,8 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, rc = md_init_ea_size(lmv->tgts[i]->ltd_exp, easize, def_easize, cookiesize, def_cookiesize); if (rc) { - CERROR("%s: obd_init_ea_size() failed on MDT target %d:" - " rc = %d.\n", obd->obd_name, i, rc); + CERROR("%s: obd_init_ea_size() failed on MDT target %d: rc = %d.\n", + obd->obd_name, i, rc); break; } } @@ -427,8 +427,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) mdc_obd->obd_type->typ_name, mdc_obd->obd_name); if (mdc_symlink == NULL) { - CERROR("Could not register LMV target " - "/proc/fs/lustre/%s/%s/target_obds/%s.", + CERROR("Could not register LMV target /proc/fs/lustre/%s/%s/target_obds/%s.", obd->obd_type->typ_name, obd->obd_name, mdc_obd->obd_name); lprocfs_remove(&lmv_proc_dir); @@ -474,8 +473,8 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, if ((index < lmv->tgts_size) && (lmv->tgts[index] != NULL)) { tgt = lmv->tgts[index]; - CERROR("%s: UUID %s already assigned at LOV target index %d:" - " rc = %d\n", obd->obd_name, + CERROR("%s: UUID %s already assigned at LOV target index %d: rc = %d\n", + obd->obd_name, obd_uuid2str(&tgt->ltd_uuid), index, -EEXIST); lmv_init_unlock(lmv); return -EEXIST; @@ -600,8 +599,7 @@ int lmv_check_connect(struct obd_device *obd) --lmv->desc.ld_active_tgt_count; rc2 = obd_disconnect(tgt->ltd_exp); if (rc2) { - CERROR("LMV target %s disconnect on " - "MDC idx %d: error %d\n", + CERROR("LMV target %s disconnect on MDC idx %d: error %d\n", tgt->ltd_uuid.uuid, i, rc2); } } @@ -865,10 +863,9 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, if (err) { if (lmv->tgts[i]->ltd_active) { /* permanent error */ - CERROR("error: iocontrol MDC %s on MDT" - "idx %d cmd %x: err = %d\n", - lmv->tgts[i]->ltd_uuid.uuid, - i, cmd, err); + CERROR("error: iocontrol MDC %s on MDTidx %d cmd %x: err = %d\n", + lmv->tgts[i]->ltd_uuid.uuid, + i, cmd, err); rc = err; lk->lk_flags |= LK_FLG_STOP; /* unregister from previous MDS */ @@ -1147,10 +1144,9 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, return err; } else if (err) { if (lmv->tgts[i]->ltd_active) { - CERROR("error: iocontrol MDC %s on MDT" - "idx %d cmd %x: err = %d\n", - lmv->tgts[i]->ltd_uuid.uuid, - i, cmd, err); + CERROR("error: iocontrol MDC %s on MDTidx %d cmd %x: err = %d\n", + lmv->tgts[i]->ltd_uuid.uuid, + i, cmd, err); if (!rc) rc = err; } @@ -1234,8 +1230,8 @@ static int lmv_placement_policy(struct obd_device *obd, if (lum->lum_type == LMV_STRIPE_TYPE && lum->lum_stripe_offset != -1) { if (lum->lum_stripe_offset >= lmv->desc.ld_tgt_count) { - CERROR("%s: Stripe_offset %d > MDT count %d:" - " rc = %d\n", obd->obd_name, + CERROR("%s: Stripe_offset %d > MDT count %d: rc = %d\n", + obd->obd_name, lum->lum_stripe_offset, lmv->desc.ld_tgt_count, -ERANGE); return -ERANGE; @@ -1298,8 +1294,8 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, rc = lmv_placement_policy(obd, op_data, &mds); if (rc) { - CERROR("Can't get target for allocating fid, " - "rc %d\n", rc); + CERROR("Can't get target for allocating fid, rc %d\n", + rc); return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 9e21e5efcdb6..e9ec39c5a6c2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -348,9 +348,8 @@ const struct lsm_operations lsm_v3_ops = { void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm) { - CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes %#llx, magic 0x%08X," - " stripe_size %u, stripe_count %u, refc: %d," - " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm, + CDEBUG(level, "lsm %p, objid " DOSTID ", maxbytes %#llx, magic 0x%08X, stripe_size %u, stripe_count %u, refc: %d, layout_gen %u, pool [" LOV_POOLNAMEF "]\n", + lsm, POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic, lsm->lsm_stripe_size, lsm->lsm_stripe_count, atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen, diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 71ad166e2cbc..ea503d2a19f8 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -168,8 +168,8 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (imp->imp_invalid) { - CDEBUG(D_CONFIG, "not connecting OSC %s; administratively " - "disabled\n", obd_uuid2str(tgt_uuid)); + CDEBUG(D_CONFIG, "not connecting OSC %s; administratively disabled\n", + obd_uuid2str(tgt_uuid)); return 0; } @@ -201,10 +201,9 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, osc_obd->obd_type->typ_name, osc_obd->obd_name); if (osc_symlink == NULL) { - CERROR("could not register LOV target " - "/proc/fs/lustre/%s/%s/target_obds/%s.", - obd->obd_type->typ_name, obd->obd_name, - osc_obd->obd_name); + CERROR("could not register LOV target /proc/fs/lustre/%s/%s/target_obds/%s.", + obd->obd_type->typ_name, obd->obd_name, + osc_obd->obd_name); lprocfs_remove(&lov_proc_dir); obd->obd_proc_private = NULL; } @@ -726,8 +725,7 @@ void lov_fix_desc_stripe_size(__u64 *val) { if (*val < LOV_MIN_STRIPE_SIZE) { if (*val != 0) - LCONSOLE_INFO("Increasing default stripe size to " - "minimum %u\n", + LCONSOLE_INFO("Increasing default stripe size to minimum %u\n", LOV_DESC_STRIPE_SIZE_DEFAULT); *val = LOV_DESC_STRIPE_SIZE_DEFAULT; } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) { @@ -899,8 +897,7 @@ static int lov_cleanup(struct obd_device *obd) /* We should never get here - these should have been removed in the disconnect. */ - CERROR("lov tgt %d not cleaned!" - " deathrow=%d, lovrc=%d\n", + CERROR("lov tgt %d not cleaned! deathrow=%d, lovrc=%d\n", i, lov->lov_death_row, atomic_read(&lov->lov_refcount)); lov_del_target(obd, i, NULL, 0); @@ -1175,8 +1172,8 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, list_for_each(pos, &lovset->set_list) { req = list_entry(pos, struct lov_request, rq_link); - CDEBUG(D_INFO, "objid "DOSTID"[%d] has subobj "DOSTID" at idx" - "%u\n", POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe, + CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n", + POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe, POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx); rc = obd_getattr_async(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, rqset); @@ -1255,8 +1252,8 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; - CDEBUG(D_INFO, "objid "DOSTID"[%d] has subobj "DOSTID" at idx" - "%u\n", POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe, + CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n", + POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe, POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx); rc = obd_setattr_async(lov->lov_tgts[req->rq_idx]->ltd_exp, @@ -1567,8 +1564,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (lov->lov_tgts[i]->ltd_active) { CDEBUG(err == -ENOTTY ? D_IOCTL : D_WARNING, - "iocontrol OSC %s on OST " - "idx %d cmd %x: err = %d\n", + "iocontrol OSC %s on OST idx %d cmd %x: err = %d\n", lov_uuid2str(lov, i), i, cmd, err); if (!rc) @@ -2265,8 +2261,8 @@ static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, /* Skip quota check on the administratively disabled OSTs. */ if (!lov->lov_tgts[i]->ltd_activate) { - CWARN("lov idx %d was administratively disabled, " - "skip quotacheck on it.\n", i); + CWARN("lov idx %d was administratively disabled, skip quotacheck on it.\n", + i); continue; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index bbef5c96d605..60d2b0f12693 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -734,8 +734,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = PTR_ERR(kthread_run(mgc_requeue_thread, NULL, "ll_cfg_requeue")); if (IS_ERR_VALUE(rc)) { - CERROR("%s: Cannot start requeue thread (%d)," - "no more log updates!\n", + CERROR("%s: Cannot start requeue thread (%d),no more log updates!\n", obd->obd_name, rc); goto err_cleanup; } @@ -1019,8 +1018,7 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, sptlrpc_flavor2name(&cli->cl_flvr_mgc, str, sizeof(str)); - LCONSOLE_ERROR("asking sptlrpc flavor %s to MGS but " - "currently %s is in use\n", + LCONSOLE_ERROR("asking sptlrpc flavor %s to MGS but currently %s is in use\n", (char *) val, str); rc = -EPERM; } diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 8d80ea4833c0..d206b1046a18 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -272,8 +272,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) tfm = crypto_alloc_hash(alg->ha_name, 0, 0); if (IS_ERR(tfm)) { - CERROR("crypto_alloc_tfm failed, check whether your kernel" - "has crypto support!\n"); + CERROR("crypto_alloc_tfm failed, check whether your kernel has crypto support!\n"); return PTR_ERR(tfm); } keylen = alg->ha_keylen; @@ -412,9 +411,8 @@ void _debug_capa(struct lustre_capa *c, va_list args; va_start(args, fmt); libcfs_debug_vmsg2(msgdata, fmt, args, - " capability@%p fid "DFID" opc %#llx uid %llu" - " gid %llu flags %u alg %d keyid %u timeout %u " - "expiry %u\n", c, PFID(capa_fid(c)), capa_opc(c), + " capability@%p fid " DFID " opc %#llx uid %llu gid %llu flags %u alg %d keyid %u timeout %u expiry %u\n", + c, PFID(capa_fid(c)), capa_opc(c), capa_uid(c), capa_gid(c), capa_flags(c), capa_alg(c), capa_keyid(c), capa_timeout(c), capa_expiry(c)); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index f2383a497cbe..3141b6043708 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -1622,8 +1622,7 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, atomic_read(&anchor->csi_sync_nr) == 0, &lwi); if (rc < 0) { - CERROR("SYNC IO failed with error: %d, try to cancel " - "%d remaining pages\n", + CERROR("SYNC IO failed with error: %d, try to cancel %d remaining pages\n", rc, atomic_read(&anchor->csi_sync_nr)); (void)cl_io_cancel(env, io, queue); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index b204531ef710..b081167f9767 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -129,8 +129,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env, const char *func, const int line) { struct cl_object_header *h = cl_object_header(lock->cll_descr.cld_obj); - CDEBUG(level, "%s: %p@(%d %p %d %d %d %d %d %lx)" - "(%p/%d/%d) at %s():%d\n", + CDEBUG(level, "%s: %p@(%d %p %d %d %d %d %d %lx)(%p/%d/%d) at %s():%d\n", prefix, lock, atomic_read(&lock->cll_ref), lock->cll_guarder, lock->cll_depth, lock->cll_state, lock->cll_error, lock->cll_holds, diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 7265ecbc6f9d..89a3fb2e56b2 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -144,13 +144,11 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, CERROR("%s%salloc of %s (%llu bytes) failed at %s:%d\n", ptr ? "force " :"", type, name, (__u64)size, file, line); - CERROR("%llu total bytes and %llu total pages " - "(%llu bytes) allocated by Lustre, " - "%d total bytes by LNET\n", + CERROR("%llu total bytes and %llu total pages (%llu bytes) allocated by Lustre, %d total bytes by LNET\n", obd_memory_sum(), obd_pages_sum() << PAGE_CACHE_SHIFT, obd_pages_sum(), - atomic_read(&libcfs_kmemory)); + atomic_read(&libcfs_kmemory)); return 1; } return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index ac8db2f98078..736ca410aca3 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -1087,8 +1087,7 @@ void __class_export_del_lock_ref(struct obd_export *exp, struct ldlm_lock *lock) spin_lock(&exp->exp_locks_list_guard); LASSERT(lock->l_exp_refs_nr > 0); if (lock->l_exp_refs_target != exp) { - LCONSOLE_WARN("lock %p, " - "mismatching export pointers: %p, %p\n", + LCONSOLE_WARN("lock %p, mismatching export pointers: %p, %p\n", lock, lock->l_exp_refs_target, exp); } if (-- lock->l_exp_refs_nr == 0) { @@ -1259,8 +1258,7 @@ static void class_disconnect_export_list(struct list_head *list, } class_export_get(exp); - CDEBUG(D_HA, "%s: disconnecting export at %s (%p), " - "last request at "CFS_TIME_T"\n", + CDEBUG(D_HA, "%s: disconnecting export at %s (%p), last request at " CFS_TIME_T "\n", exp->exp_obd->obd_name, obd_export_nid2str(exp), exp, exp->exp_last_request_time); /* release one export reference anyway */ @@ -1284,8 +1282,8 @@ void class_disconnect_exports(struct obd_device *obd) spin_unlock(&obd->obd_dev_lock); if (!list_empty(&work_list)) { - CDEBUG(D_HA, "OBD device %d (%p) has exports, " - "disconnecting them\n", obd->obd_minor, obd); + CDEBUG(D_HA, "OBD device %d (%p) has exports, disconnecting them\n", + obd->obd_minor, obd); class_disconnect_export_list(&work_list, exp_flags_from_obd(obd)); } else @@ -1422,8 +1420,8 @@ int obd_export_evict_by_nid(struct obd_device *obd, const char *nid) LASSERTF(doomed_exp != obd->obd_self_export, "self-export is hashed by NID?\n"); exports_evicted++; - LCONSOLE_WARN("%s: evicting %s (at %s) by administrative " - "request\n", obd->obd_name, + LCONSOLE_WARN("%s: evicting %s (at %s) by administrative request\n", + obd->obd_name, obd_uuid2str(&doomed_exp->exp_client_uuid), obd_export_nid2str(doomed_exp)); class_fail_export(doomed_exp); @@ -1546,9 +1544,7 @@ void obd_exports_barrier(struct obd_device *obd) set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(cfs_time_seconds(waited)); if (waited > 5 && IS_PO2(waited)) { - LCONSOLE_WARN("%s is waiting for obd_unlinked_exports " - "more than %d seconds. " - "The obd refcount = %d. Is it stuck?\n", + LCONSOLE_WARN("%s is waiting for obd_unlinked_exports more than %d seconds. The obd refcount = %d. Is it stuck?\n", obd->obd_name, waited, atomic_read(&obd->obd_refcount)); dump_exports(obd, 1); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 38a9b319355e..dd46e7358160 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -202,9 +202,8 @@ static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write, /* Don't allow them to let dirty pages exceed 90% of system * memory and set a hard minimum of 4MB. */ if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) { - CERROR("Refusing to set max dirty pages to %u, which " - "is more than 90%% of available RAM; setting " - "to %lu\n", obd_max_dirty_pages, + CERROR("Refusing to set max dirty pages to %u, which is more than 90%% of available RAM; setting to %lu\n", + obd_max_dirty_pages, ((totalram_pages / 10) * 9)); obd_max_dirty_pages = ((totalram_pages / 10) * 9); } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) { diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 3ab05292152c..114be4a78ccf 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -346,8 +346,8 @@ repeat: } if (rec->lrh_len == 0 || rec->lrh_len > LLOG_CHUNK_SIZE) { - CWARN("invalid length %d in llog record for " - "index %d/%d\n", rec->lrh_len, + CWARN("invalid length %d in llog record for index %d/%d\n", + rec->lrh_len, rec->lrh_index, index); rc = -EINVAL; goto out; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index 6e139cf372c4..4b850fc5f5d9 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -228,8 +228,7 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle) (llh->llh_count == 1)) { rc = llog_destroy(env, loghandle); if (rc) - CERROR("%s: failure destroying log during " - "cleanup: rc = %d\n", + CERROR("%s: failure destroying log during cleanup: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); @@ -746,8 +745,7 @@ int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle, llog_cat_set_first_idx(cathandle, index); rc = llog_cancel_rec(env, cathandle, index); if (rc == 0) - CDEBUG(D_HA, "cancel plain log at index" - " %u of catalog "DOSTID"\n", + CDEBUG(D_HA, "cancel plain log at index %u of catalog " DOSTID "\n", index, POSTID(&cathandle->lgh_id.lgl_oi)); return rc; } @@ -810,8 +808,8 @@ int llog_cat_init_and_process(const struct lu_env *env, rc = llog_process_or_fork(env, llh, cat_cancel_cb, NULL, NULL, false); if (rc) - CERROR("%s: llog_process() with cat_cancel_cb failed: rc = " - "%d\n", llh->lgh_ctxt->loc_obd->obd_name, rc); + CERROR("%s: llog_process() with cat_cancel_cb failed: rc = %d\n", + llh->lgh_ctxt->loc_obd->obd_name, rc); return 0; } EXPORT_SYMBOL(llog_cat_init_and_process); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index bfac8387021e..d3ec90e85eb9 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -400,8 +400,7 @@ void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) } marker->cm_createtime = createtime; marker->cm_canceltime = canceltime; - CDEBUG(D_CONFIG, "Find old cfg_marker(Srv32b,Clt64b) " - "for target %s, converting\n", + CDEBUG(D_CONFIG, "Find old cfg_marker(Srv32b,Clt64b) for target %s, converting\n", marker->cm_tgtname); } else if (swab) { __swab64s(&marker->cm_createtime); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 686bc182a9bb..3b7dfc367722 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1400,8 +1400,8 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) * LPROCFS_OBD_OP_INIT(.., .., opname) * is missing from the list above. */ LASSERTF(stats->ls_cnt_header[i].lc_name != NULL, - "Missing obd_stat initializer obd_op " - "operation at offset %d.\n", i - num_private_stats); + "Missing obd_stat initializer obd_op operation at offset %d.\n", + i - num_private_stats); } rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats); if (rc < 0) { @@ -1486,8 +1486,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, for (i = num_private_stats; i < num_stats; i++) { if (stats->ls_cnt_header[i].lc_name == NULL) { - CERROR("Missing md_stat initializer md_op " - "operation at offset %d. Aborting.\n", + CERROR("Missing md_stat initializer md_op operation at offset %d. Aborting.\n", i - num_private_stats); LBUG(); } @@ -1607,8 +1606,7 @@ LPROC_SEQ_FOPS_RO(lproc_exp_hash); int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) { return seq_printf(m, "%s\n", - "Write into this file to clear all nid stats and " - "stale nid entries"); + "Write into this file to clear all nid stats and stale nid entries"); } EXPORT_SYMBOL(lprocfs_nid_stats_clear_read); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 2fc037cfb62f..83bf168c2939 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -866,8 +866,7 @@ static int lu_htable_order(void) /* clear off unreasonable cache setting. */ if (lu_cache_percent == 0 || lu_cache_percent > LU_CACHE_PERCENT_MAX) { - CWARN("obdclass: invalid lu_cache_percent: %u, it must be in" - " the range of (0, %u]. Will use default value: %u.\n", + CWARN("obdclass: invalid lu_cache_percent: %u, it must be in the range of (0, %u]. Will use default value: %u.\n", lu_cache_percent, LU_CACHE_PERCENT_MAX, LU_CACHE_PERCENT_DEFAULT); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 47213a970e7d..6ce9adc2f11c 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1443,8 +1443,7 @@ int class_config_llog_handler(const struct lu_env *env, if (!(clli->cfg_flags & CFG_F_COMPAT146) && !(clli->cfg_flags & CFG_F_MARKER) && (lcfg->lcfg_command != LCFG_MARKER)) { - CWARN("Config not inside markers, ignoring! " - "(inst: %p, uuid: %s, flags: %#x)\n", + CWARN("Config not inside markers, ignoring! (inst: %p, uuid: %s, flags: %#x)\n", clli->cfg_instance, clli->cfg_uuid.uuid, clli->cfg_flags); clli->cfg_flags |= CFG_F_SKIP; @@ -1467,14 +1466,12 @@ int class_config_llog_handler(const struct lu_env *env, if ((lcfg->lcfg_command == LCFG_ATTACH && typename && strcmp(typename, "mds") == 0)) { - CWARN("For 1.8 interoperability, rename obd " - "type from mds to mdt\n"); + CWARN("For 1.8 interoperability, rename obd type from mds to mdt\n"); typename[2] = 't'; } if ((lcfg->lcfg_command == LCFG_SETUP && index && strcmp(index, "type") == 0)) { - CDEBUG(D_INFO, "For 1.8 interoperability, " - "set this index to '0'\n"); + CDEBUG(D_INFO, "For 1.8 interoperability, set this index to '0'\n"); index[0] = '0'; index[1] = 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 1260c8713bc6..4f39cdee1b5c 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -100,19 +100,12 @@ int lustre_process_log(struct super_block *sb, char *logname, OBD_FREE_PTR(bufs); if (rc == -EINVAL) - LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s'" - "failed from the MGS (%d). Make sure this " - "client and the MGS are running compatible " - "versions of Lustre.\n", + LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n", mgc->obd_name, logname, rc); if (rc) - LCONSOLE_ERROR_MSG(0x15c, "%s: The configuration from log '%s' " - "failed (%d). This may be the result of " - "communication errors between this node and " - "the MGS, a bad configuration, or other " - "errors. See the syslog for more " - "information.\n", mgc->obd_name, logname, + LCONSOLE_ERROR_MSG(0x15c, "%s: The configuration from log '%s' failed (%d). This may be the result of communication errors between this node and the MGS, a bad configuration, or other errors. See the syslog for more information.\n", + mgc->obd_name, logname, rc); /* class_obd_list(); */ @@ -297,11 +290,8 @@ int lustre_start_mgc(struct super_block *sb) if (has_ir ^ !(*flags & LMD_FLG_NOIR)) { /* LMD_FLG_NOIR is for test purpose only */ LCONSOLE_WARN( - "Trying to mount a client with IR setting " - "not compatible with current mgc. " - "Force to use current mgc setting that is " - "IR %s.\n", - has_ir ? "enabled" : "disabled"); + "Trying to mount a client with IR setting not compatible with current mgc. Force to use current mgc setting that is IR %s.\n", + has_ir ? "enabled" : "disabled"); if (has_ir) *flags &= ~LMD_FLG_NOIR; else @@ -998,16 +988,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) LASSERT(lmd); if (!options) { - LCONSOLE_ERROR_MSG(0x162, "Missing mount data: check that " - "/sbin/mount.lustre is installed.\n"); + LCONSOLE_ERROR_MSG(0x162, "Missing mount data: check that /sbin/mount.lustre is installed.\n"); return -EINVAL; } /* Options should be a string - try to detect old lmd data */ if ((raw->lmd_magic & 0xffffff00) == (LMD_MAGIC & 0xffffff00)) { - LCONSOLE_ERROR_MSG(0x163, "You're using an old version of " - "/sbin/mount.lustre. Please install " - "version %s\n", LUSTRE_VERSION_STRING); + LCONSOLE_ERROR_MSG(0x163, "You're using an old version of /sbin/mount.lustre. Please install version %s\n", + LUSTRE_VERSION_STRING); return -EINVAL; } lmd->lmd_magic = LMD_MAGIC; @@ -1139,8 +1127,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } if (!devname) { - LCONSOLE_ERROR_MSG(0x164, "Can't find the device name " - "(need mount option 'device=...')\n"); + LCONSOLE_ERROR_MSG(0x164, "Can't find the device name (need mount option 'device=...')\n"); goto invalid; } @@ -1232,9 +1219,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) if (client_fill_super == NULL) request_module("lustre"); if (client_fill_super == NULL) { - LCONSOLE_ERROR_MSG(0x165, "Nothing registered for " - "client mount! Is the 'lustre' " - "module loaded?\n"); + LCONSOLE_ERROR_MSG(0x165, "Nothing registered for client mount! Is the 'lustre' module loaded?\n"); lustre_put_lsi(sb); rc = -ENODEV; } else { @@ -1249,8 +1234,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) /* c_f_s will call lustre_common_put_super on failure */ } } else { - CERROR("This is client-side-only module, " - "cannot handle server mount.\n"); + CERROR("This is client-side-only module, cannot handle server mount.\n"); rc = -EINVAL; } diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index a6ad87557512..5f6d9441bc44 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -871,8 +871,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, spin_lock(&ec->ec_lock); while (!list_empty(&ec->ec_objects)) { spin_unlock(&ec->ec_lock); - CERROR("echo_client still has objects at cleanup time, " - "wait for 1 second\n"); + CERROR("echo_client still has objects at cleanup time, wait for 1 second\n"); set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(cfs_time_seconds(1)); lu_site_purge(env, &ed->ed_site->cs_lu, -1); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index f8c8b666d4f3..370e6d4896c6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1611,8 +1611,8 @@ void osc_wake_cache_waiters(struct client_obd *cli) if ((cli->cl_dirty + PAGE_CACHE_SIZE > cli->cl_dirty_max) || (atomic_read(&obd_dirty_pages) + 1 > obd_max_dirty_pages)) { - CDEBUG(D_CACHE, "no dirty room: dirty: %ld " - "osc max %ld, sys max %d\n", cli->cl_dirty, + CDEBUG(D_CACHE, "no dirty room: dirty: %ld osc max %ld, sys max %d\n", + cli->cl_dirty, cli->cl_dirty_max, obd_max_dirty_pages); goto wakeup; } diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 8138856fda8c..a7f08bc48166 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1067,14 +1067,12 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, * conflicts, we do not wait but return 0 so the * request is send to the server */ - CDEBUG(D_DLMTRACE, "group lock %p is conflicted " - "with %p, no wait, send to server\n", + CDEBUG(D_DLMTRACE, "group lock %p is conflicted with %p, no wait, send to server\n", lock, conflict); cl_lock_put(env, conflict); rc = 0; } else { - CDEBUG(D_DLMTRACE, "lock %p is conflicted with %p, " - "will wait\n", + CDEBUG(D_DLMTRACE, "lock %p is conflicted with %p, will wait\n", lock, conflict); LASSERT(lock->cll_conflict == NULL); lu_ref_add(&conflict->cll_reference, "cancel-wait", diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 69000584619d..92c202f70395 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -140,8 +140,7 @@ static int osc_object_print(const struct lu_env *env, void *cookie, struct lov_oinfo *oinfo = osc->oo_oinfo; struct osc_async_rc *ar = &oinfo->loi_ar; - (*p)(env, cookie, "id: "DOSTID" " - "idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ", + (*p)(env, cookie, "id: " DOSTID " idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ", POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, oinfo->loi_ost_gen, oinfo->loi_kms_valid, oinfo->loi_kms, ar->ar_rc, ar->ar_force_sync, ar->ar_min_xid); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index fcd079b1af01..76ba58b09c5d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -369,12 +369,7 @@ static int osc_page_print(const struct lu_env *env, struct osc_object *obj = cl2osc(slice->cpl_obj); struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; - return (*printer)(env, cookie, LUSTRE_OSC_NAME"-page@%p: " - "1< %#x %d %u %s %s > " - "2< %llu %u %u %#x %#x | %p %p %p > " - "3< %s %p %d %lu %d > " - "4< %d %d %d %lu %s | %s %s %s %s > " - "5< %s %s %s %s | %d %s | %d %s %s>\n", + return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %s %p %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n", opg, /* 1 */ oap->oap_magic, oap->oap_cmd, @@ -550,8 +545,8 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, LINVRNT(osc_page_protected(env, opg, crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1)); - LASSERTF(oap->oap_magic == OAP_MAGIC, "Bad oap magic: oap %p, " - "magic 0x%x\n", oap, oap->oap_magic); + LASSERTF(oap->oap_magic == OAP_MAGIC, "Bad oap magic: oap %p, magic 0x%x\n", + oap, oap->oap_magic); LASSERT(oap->oap_async_flags & ASYNC_READY); LASSERT(oap->oap_async_flags & ASYNC_COUNT_STABLE); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index ca16c081e9df..b9450b95f1c5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1078,9 +1078,9 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) cli->cl_chunkbits = max_t(int, PAGE_CACHE_SHIFT, ocd->ocd_blocksize); client_obd_list_unlock(&cli->cl_loi_list_lock); - CDEBUG(D_CACHE, "%s, setting cl_avail_grant: %ld cl_lost_grant: %ld." - "chunk bits: %d.\n", cli->cl_import->imp_obd->obd_name, - cli->cl_avail_grant, cli->cl_lost_grant, cli->cl_chunkbits); + CDEBUG(D_CACHE, "%s, setting cl_avail_grant: %ld cl_lost_grant: %ld chunk bits: %d\n", + cli->cl_import->imp_obd->obd_name, + cli->cl_avail_grant, cli->cl_lost_grant, cli->cl_chunkbits); if (ocd->ocd_connect_flags & OBD_CONNECT_GRANT_SHRINK && list_empty(&cli->cl_grant_shrink_list)) @@ -1171,8 +1171,7 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) /* warn if we try to combine flags that we don't know to be * safe to combine */ if (unlikely((p1->flag & mask) != (p2->flag & mask))) { - CWARN("Saw flags 0x%x and 0x%x in the same brw, please " - "report this at http://bugs.whamcloud.com/\n", + CWARN("Saw flags 0x%x and 0x%x in the same brw, please report this at http://bugs.whamcloud.com/\n", p1->flag, p2->flag); } return 0; @@ -1343,8 +1342,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, "i: %d/%d pg: %p off: %llu, count: %u\n", i, page_count, pg, pg->off, pg->count); LASSERTF(i == 0 || pg->off > pg_prev->off, - "i %d p_c %u pg %p [pri %lu ind %lu] off %llu" - " prev_pg %p [pri %lu ind %lu] off %llu\n", + "i %d p_c %u pg %p [pri %lu ind %lu] off %llu prev_pg %p [pri %lu ind %lu] off %llu\n", i, page_count, pg->pg, page_private(pg->pg), pg->pg->index, pg->off, pg_prev->pg, page_private(pg_prev->pg), @@ -1467,16 +1465,16 @@ static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, cksum_type); if (cksum_type != client_cksum_type) - msg = "the server did not use the checksum type specified in " - "the original request - likely a protocol problem"; + msg = "the server did not use the checksum type specified in the original request - likely a protocol problem" + ; else if (new_cksum == server_cksum) - msg = "changed on the client after we checksummed it - " - "likely false positive due to mmap IO (bug 11742)"; + msg = "changed on the client after we checksummed it - likely false positive due to mmap IO (bug 11742)" + ; else if (new_cksum == client_cksum) msg = "changed in transit before arrival at OST"; else - msg = "changed in transit AND doesn't match the original - " - "likely false positive due to mmap IO (bug 11742)"; + msg = "changed in transit AND doesn't match the original - likely false positive due to mmap IO (bug 11742)" + ; LCONSOLE_ERROR_MSG(0x132, "BAD WRITE CHECKSUM: %s: from %s inode "DFID " object "DOSTID" extent [%llu-%llu]\n", @@ -1486,8 +1484,8 @@ static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, POSTID(&oa->o_oi), pga[0]->off, pga[page_count-1]->off + pga[page_count-1]->count - 1); - CERROR("original client csum %x (type %x), server csum %x (type %x), " - "client csum now %x\n", client_cksum, client_cksum_type, + CERROR("original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", + client_cksum, client_cksum_type, server_cksum, cksum_type, new_cksum); return 1; } @@ -1601,23 +1599,21 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } if (server_cksum != client_cksum) { - LCONSOLE_ERROR_MSG(0x133, "%s: BAD READ CHECKSUM: from " - "%s%s%s inode "DFID" object "DOSTID - " extent [%llu-%llu]\n", + LCONSOLE_ERROR_MSG(0x133, "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID " object " DOSTID " extent [%llu-%llu]\n", req->rq_import->imp_obd->obd_name, libcfs_nid2str(peer->nid), via, router, body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_seq : (__u64)0, + body->oa.o_parent_seq : (__u64)0, body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_oid : 0, + body->oa.o_parent_oid : 0, body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_ver : 0, + body->oa.o_parent_ver : 0, POSTID(&body->oa.o_oi), aa->aa_ppga[0]->off, aa->aa_ppga[aa->aa_page_count-1]->off + aa->aa_ppga[aa->aa_page_count-1]->count - - 1); + 1); CERROR("client %x, server %x, cksum_type %x\n", client_cksum, server_cksum, cksum_type); cksum_counter = 0; @@ -1771,8 +1767,7 @@ static int brw_interpret(const struct lu_env *env, if (osc_recoverable_error(rc)) { if (req->rq_import_generation != req->rq_import->imp_generation) { - CDEBUG(D_HA, "%s: resend cross eviction for object: " - ""DOSTID", rc = %d.\n", + CDEBUG(D_HA, "%s: resend cross eviction for object: " DOSTID ", rc = %d.\n", req->rq_import->imp_obd->obd_name, POSTID(&aa->aa_oa->o_oi), rc); } else if (rc == -EINPROGRESS || @@ -3013,8 +3008,8 @@ static int osc_reconnect(const struct lu_env *env, cli->cl_lost_grant = 0; client_obd_list_unlock(&cli->cl_loi_list_lock); - CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d" - " ocd_grant: %d, lost: %ld.\n", data->ocd_connect_flags, + CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d, lost: %ld.\n", + data->ocd_connect_flags, data->ocd_version, data->ocd_grant, lost_grant); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 6c8815f4b99b..dc9e406f3212 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -265,8 +265,7 @@ static void ptlrpc_at_adj_service(struct ptlrpc_request *req, so just keep minimal history here */ oldse = at_measured(&at->iat_service_estimate[idx], serv_est); if (oldse != 0) - CDEBUG(D_ADAPTTO, "The RPC service estimate for %s ptl %d " - "has changed from %d to %d\n", + CDEBUG(D_ADAPTTO, "The RPC service estimate for %s ptl %d has changed from %d to %d\n", req->rq_import->imp_obd->obd_name, req->rq_request_portal, oldse, at_get(&at->iat_service_estimate[idx])); } @@ -297,8 +296,7 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req, oldnl = at_measured(&at->iat_net_latency, nl); if (oldnl != 0) - CDEBUG(D_ADAPTTO, "The network latency for %s (nid %s) " - "has changed from %d to %d\n", + CDEBUG(D_ADAPTTO, "The network latency for %s (nid %s) has changed from %d to %d\n", req->rq_import->imp_obd->obd_name, obd_uuid2str( &req->rq_import->imp_connection->c_remote_uuid), @@ -371,8 +369,8 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) ptlrpc_at_get_net_latency(req); DEBUG_REQ(D_ADAPTTO, req, - "Early reply #%d, new deadline in "CFS_DURATION_T"s " - "("CFS_DURATION_T"s)", req->rq_early_count, + "Early reply #%d, new deadline in " CFS_DURATION_T "s (" CFS_DURATION_T "s)", + req->rq_early_count, cfs_time_sub(req->rq_deadline, get_seconds()), cfs_time_sub(req->rq_deadline, olddl)); @@ -445,8 +443,8 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) LASSERTF(list_empty(&pool->prp_req_list) || size == pool->prp_rq_size, - "Trying to change pool size with nonempty pool " - "from %d to %d bytes\n", pool->prp_rq_size, size); + "Trying to change pool size with nonempty pool from %d to %d bytes\n", + pool->prp_rq_size, size); spin_lock(&pool->prp_lock); pool->prp_rq_size = size; @@ -1146,11 +1144,10 @@ static int ptlrpc_check_status(struct ptlrpc_request *req) struct obd_import *imp = req->rq_import; __u32 opc = lustre_msg_get_opc(req->rq_reqmsg); if (ptlrpc_console_allow(req)) - LCONSOLE_ERROR_MSG(0x011, "%s: Communicating with %s," - " operation %s failed with %d.\n", + LCONSOLE_ERROR_MSG(0x011, "%s: Communicating with %s, operation %s failed with %d.\n", imp->imp_obd->obd_name, libcfs_nid2str( - imp->imp_connection->c_peer.nid), + imp->imp_connection->c_peer.nid), ll_opcode2str(opc), err); return err < 0 ? err : -EINVAL; } @@ -1206,8 +1203,7 @@ static int after_reply(struct ptlrpc_request *req) if (req->rq_reply_truncate) { if (ptlrpc_no_resend(req)) { - DEBUG_REQ(D_ERROR, req, "reply buffer overflow," - " expected: %d, actual size: %d", + DEBUG_REQ(D_ERROR, req, "reply buffer overflow, expected: %d, actual size: %d", req->rq_nob_received, req->rq_repbuf_len); return -EOVERFLOW; } @@ -1259,8 +1255,7 @@ static int after_reply(struct ptlrpc_request *req) /* new xid is already allocated for bulk in * ptlrpc_check_set() */ req->rq_xid = ptlrpc_next_xid(); - DEBUG_REQ(D_RPCTRACE, req, "Allocating new xid for " - "resend on EINPROGRESS"); + DEBUG_REQ(D_RPCTRACE, req, "Allocating new xid for resend on EINPROGRESS"); } /* Readjust the timeout for current conditions */ @@ -1412,8 +1407,8 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) req->rq_waiting = 1; spin_unlock(&req->rq_lock); - DEBUG_REQ(D_HA, req, "req from PID %d waiting for recovery: " - "(%s != %s)", lustre_msg_get_status(req->rq_reqmsg), + DEBUG_REQ(D_HA, req, "req from PID %d waiting for recovery: (%s != %s)", + lustre_msg_get_status(req->rq_reqmsg), ptlrpc_import_state_name(req->rq_send_state), ptlrpc_import_state_name(imp->imp_state)); LASSERT(list_empty(&req->rq_list)); @@ -1450,8 +1445,8 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) } } - CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc" - " %s:%s:%d:%llu:%s:%d\n", current_comm(), + CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n", + current_comm(), imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, libcfs_nid2str(imp->imp_connection->c_peer.nid), @@ -1828,12 +1823,11 @@ interpret: ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE); CDEBUG(req->rq_reqmsg != NULL ? D_RPCTRACE : 0, - "Completed RPC pname:cluuid:pid:xid:nid:" - "opc %s:%s:%d:%llu:%s:%d\n", - current_comm(), imp->imp_obd->obd_uuid.uuid, - lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, - libcfs_nid2str(imp->imp_connection->c_peer.nid), - lustre_msg_get_opc(req->rq_reqmsg)); + "Completed RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n", + current_comm(), imp->imp_obd->obd_uuid.uuid, + lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, + libcfs_nid2str(imp->imp_connection->c_peer.nid), + lustre_msg_get_opc(req->rq_reqmsg)); spin_lock(&imp->imp_lock); /* Request already may be not on sending or delaying list. This diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 32dfffa76a5e..7f8644e01112 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -128,8 +128,8 @@ void reply_in_callback(lnet_event_t *ev) ((lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT))) { /* Early reply */ DEBUG_REQ(D_ADAPTTO, req, - "Early reply received: mlen=%u offset=%d replen=%d " - "replied=%d unlinked=%d", ev->mlength, ev->offset, + "Early reply received: mlen=%u offset=%d replen=%d replied=%d unlinked=%d", + ev->mlength, ev->offset, req->rq_replen, req->rq_replied, ev->unlinked); req->rq_early_count++; /* number received, client side */ @@ -313,8 +313,7 @@ void request_in_callback(lnet_event_t *ev) } req = ptlrpc_request_cache_alloc(GFP_ATOMIC); if (req == NULL) { - CERROR("Can't allocate incoming request descriptor: " - "Dropping %s RPC from %s\n", + CERROR("Can't allocate incoming request descriptor: Dropping %s RPC from %s\n", service->srv_name, libcfs_id2str(ev->initiator)); return; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 2e7e7171ca63..4ceb90db02a3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -157,18 +157,14 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) &target_start, &target_len); if (imp->imp_replayable) { - LCONSOLE_WARN("%s: Connection to %.*s (at %s) was " - "lost; in progress operations using this " - "service will wait for recovery to complete\n", - imp->imp_obd->obd_name, target_len, target_start, - libcfs_nid2str(imp->imp_connection->c_peer.nid)); + LCONSOLE_WARN("%s: Connection to %.*s (at %s) was lost; in progress operations using this service will wait for recovery to complete\n", + imp->imp_obd->obd_name, target_len, target_start, + libcfs_nid2str(imp->imp_connection->c_peer.nid)); } else { - LCONSOLE_ERROR_MSG(0x166, "%s: Connection to " - "%.*s (at %s) was lost; in progress " - "operations using this service will fail\n", - imp->imp_obd->obd_name, - target_len, target_start, - libcfs_nid2str(imp->imp_connection->c_peer.nid)); + LCONSOLE_ERROR_MSG(0x166, "%s: Connection to %.*s (at %s) was lost; in progress operations using this service will fail\n", + imp->imp_obd->obd_name, + target_len, target_start, + libcfs_nid2str(imp->imp_connection->c_peer.nid)); } IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON); spin_unlock(&imp->imp_lock); @@ -328,8 +324,8 @@ void ptlrpc_invalidate_import(struct obd_import *imp) * sluggish nets). Let's check this. If there * is no inflight and unregistering != 0, this * is bug. */ - LASSERTF(count == 0, "Some RPCs are still " - "unregistering: %d\n", count); + LASSERTF(count == 0, "Some RPCs are still unregistering: %d\n", + count); /* Let's save one loop as soon as inflight have * dropped to zero. No new inflights possible at @@ -353,12 +349,11 @@ void ptlrpc_invalidate_import(struct obd_import *imp) "still on delayed list"); } - CERROR("%s: RPCs in \"%s\" phase found (%d). " - "Network is sluggish? Waiting them " - "to error out.\n", cli_tgt, + CERROR("%s: RPCs in \"%s\" phase found (%d). Network is sluggish? Waiting them to error out.\n", + cli_tgt, ptlrpc_phase2str(RQ_PHASE_UNREGISTERING), atomic_read(&imp-> - imp_unregistering)); + imp_unregistering)); } spin_unlock(&imp->imp_lock); } @@ -413,8 +408,7 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) if (ptlrpc_set_import_discon(imp, conn_cnt)) { if (!imp->imp_replayable) { - CDEBUG(D_HA, "import %s@%s for %s not replayable, " - "auto-deactivating\n", + CDEBUG(D_HA, "import %s@%s for %s not replayable, auto-deactivating\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid, imp->imp_obd->obd_name); @@ -541,8 +535,8 @@ static int import_select_connection(struct obd_import *imp) at_reset(at, CONNECTION_SWITCH_MAX); } LASSERT(imp_conn->oic_last_attempt); - CDEBUG(D_HA, "%s: tried all connections, increasing latency " - "to %ds\n", imp->imp_obd->obd_name, at_get(at)); + CDEBUG(D_HA, "%s: tried all connections, increasing latency to %ds\n", + imp->imp_obd->obd_name, at_get(at)); } imp_conn->oic_last_attempt = cfs_time_current_64(); @@ -564,8 +558,7 @@ static int import_select_connection(struct obd_import *imp) deuuidify(obd2cli_tgt(imp->imp_obd), NULL, &target_start, &target_len); - CDEBUG(D_HA, "%s: Connection changing to" - " %.*s (at %s)\n", + CDEBUG(D_HA, "%s: Connection changing to %.*s (at %s)\n", imp->imp_obd->obd_name, target_len, target_start, libcfs_nid2str(imp_conn->oic_conn->c_peer.nid)); @@ -935,14 +928,13 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, lustre_msg_get_handle( request->rq_repmsg)->cookie); } else { - LCONSOLE_WARN("Evicted from %s (at %s) " - "after server handle changed from %#llx to %#llx\n", + LCONSOLE_WARN("Evicted from %s (at %s) after server handle changed from %#llx to %#llx\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection-> \ c_remote_uuid.uuid, imp->imp_remote_handle.cookie, lustre_msg_get_handle( - request->rq_repmsg)->cookie); + request->rq_repmsg)->cookie); } @@ -962,8 +954,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, } if (imp->imp_invalid) { - CDEBUG(D_HA, "%s: reconnected but import is invalid; " - "marking evicted\n", imp->imp_obd->obd_name); + CDEBUG(D_HA, "%s: reconnected but import is invalid; marking evicted\n", + imp->imp_obd->obd_name); IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED); } else if (MSG_CONNECT_RECOVERING & msg_flags) { CDEBUG(D_HA, "%s: reconnected to %s during replay\n", @@ -985,8 +977,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, imp->imp_last_replay_transno = 0; IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY); } else { - DEBUG_REQ(D_HA, request, "%s: evicting (reconnect/recover flags" - " not set: %x)", imp->imp_obd->obd_name, msg_flags); + DEBUG_REQ(D_HA, request, "%s: evicting (reconnect/recover flags not set: %x)", + imp->imp_obd->obd_name, msg_flags); imp->imp_remote_handle = *lustre_msg_get_handle(request->rq_repmsg); IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED); @@ -994,17 +986,13 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, /* Sanity checks for a reconnected import. */ if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) { - CERROR("imp_replayable flag does not match server " - "after reconnect. We should LBUG right here.\n"); + CERROR("imp_replayable flag does not match server after reconnect. We should LBUG right here.\n"); } if (lustre_msg_get_last_committed(request->rq_repmsg) > 0 && lustre_msg_get_last_committed(request->rq_repmsg) < aa->pcaa_peer_committed) { - CERROR("%s went back in time (transno %lld" - " was previously committed, server now claims %lld" - ")! See https://bugzilla.lustre.org/show_bug.cgi?" - "id=9646\n", + CERROR("%s went back in time (transno %lld was previously committed, server now claims %lld)! See https://bugzilla.lustre.org/show_bug.cgi?id=9646\n", obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed, lustre_msg_get_last_committed(request->rq_repmsg)); } @@ -1013,8 +1001,7 @@ finish: rc = ptlrpc_import_recovery_state_machine(imp); if (rc != 0) { if (rc == -ENOTCONN) { - CDEBUG(D_HA, "evicted/aborted by %s@%s during recovery;" - "invalidating and reconnecting\n", + CDEBUG(D_HA, "evicted/aborted by %s@%s during recovery; invalidating and reconnecting\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid); ptlrpc_connect_import(imp); @@ -1034,9 +1021,7 @@ finish: if ((imp->imp_connect_flags_orig & OBD_CONNECT_IBITS) && !(ocd->ocd_connect_flags & OBD_CONNECT_IBITS)) { - LCONSOLE_WARN("%s: MDS %s does not support ibits " - "lock, either very old or invalid: " - "requested %llx, replied %llx\n", + LCONSOLE_WARN("%s: MDS %s does not support ibits lock, either very old or invalid: requested %llx, replied %llx\n", imp->imp_obd->obd_name, imp->imp_connection->c_remote_uuid.uuid, imp->imp_connect_flags_orig, @@ -1052,13 +1037,12 @@ finish: LUSTRE_VERSION_OFFSET_WARN)) { /* Sigh, some compilers do not like #ifdef in the middle of macro arguments */ - const char *older = "older. Consider upgrading server " - "or downgrading client"; - const char *newer = "newer than client version. " - "Consider upgrading client"; + const char *older = "older. Consider upgrading server or downgrading client" + ; + const char *newer = "newer than client version. Consider upgrading client" + ; - LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) " - "is much %s (%s)\n", + LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) is much %s (%s)\n", obd2cli_tgt(imp->imp_obd), OBD_OCD_VERSION_MAJOR(ocd->ocd_version), OBD_OCD_VERSION_MINOR(ocd->ocd_version), @@ -1095,10 +1079,7 @@ finish: * the checksum types it doesn't support */ if ((ocd->ocd_cksum_types & cksum_types_supported_client()) == 0) { - LCONSOLE_WARN("The negotiation of the checksum " - "algorithm to use with server %s " - "failed (%x/%x), disabling " - "checksums\n", + LCONSOLE_WARN("The negotiation of the checksum algorithm to use with server %s failed (%x/%x), disabling checksums\n", obd2cli_tgt(imp->imp_obd), ocd->ocd_cksum_types, cksum_types_supported_client()); @@ -1191,17 +1172,13 @@ out: * connection from liblustre clients, so we * should never see this from VFS context */ - LCONSOLE_ERROR_MSG(0x16a, "Server %s version " - "(%d.%d.%d.%d)" - " refused connection from this client " - "with an incompatible version (%s). " - "Client must be recompiled\n", - obd2cli_tgt(imp->imp_obd), - OBD_OCD_VERSION_MAJOR(ocd->ocd_version), - OBD_OCD_VERSION_MINOR(ocd->ocd_version), - OBD_OCD_VERSION_PATCH(ocd->ocd_version), - OBD_OCD_VERSION_FIX(ocd->ocd_version), - LUSTRE_VERSION_STRING); + LCONSOLE_ERROR_MSG(0x16a, "Server %s version (%d.%d.%d.%d) refused connection from this client with an incompatible version (%s). Client must be recompiled\n", + obd2cli_tgt(imp->imp_obd), + OBD_OCD_VERSION_MAJOR(ocd->ocd_version), + OBD_OCD_VERSION_MINOR(ocd->ocd_version), + OBD_OCD_VERSION_PATCH(ocd->ocd_version), + OBD_OCD_VERSION_FIX(ocd->ocd_version), + LUSTRE_VERSION_STRING); ptlrpc_deactivate_import(imp); IMPORT_SET_STATE(imp, LUSTRE_IMP_CLOSED); } @@ -1237,8 +1214,7 @@ static int completed_replay_interpret(const struct lu_env *env, "%s: version recovery fails, reconnecting\n", req->rq_import->imp_obd->obd_name); } else { - CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, " - "reconnecting\n", + CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, reconnecting\n", req->rq_import->imp_obd->obd_name, req->rq_status); } @@ -1343,9 +1319,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) /* Don't care about MGC eviction */ if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_MGC_NAME) != 0) { - LCONSOLE_ERROR_MSG(0x167, "%s: This client was evicted " - "by %.*s; in progress operations " - "using this service will fail.\n", + LCONSOLE_ERROR_MSG(0x167, "%s: This client was evicted by %.*s; in progress operations using this service will fail.\n", imp->imp_obd->obd_name, target_len, target_start); } @@ -1455,8 +1429,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) break; default: rc = -EINVAL; - CERROR("%s: don't know how to disconnect from %s " - "(connect_op %d): rc = %d\n", + CERROR("%s: don't know how to disconnect from %s (connect_op %d): rc = %d\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), imp->imp_connect_op, rc); return rc; @@ -1607,8 +1580,8 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) at->at_current = max(at->at_current, at_min); if (at->at_current != old) - CDEBUG(D_OTHER, "AT %p change: old=%u new=%u delta=%d " - "(val=%u) hist %u %u %u %u\n", at, + CDEBUG(D_OTHER, "AT %p change: old=%u new=%u delta=%d (val=%u) hist %u %u %u %u\n", + at, old, at->at_current, at->at_current - old, val, at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]); diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 78364ec4fbf0..252f3e13d04a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -1886,8 +1886,8 @@ swabber_dumper_helper(struct req_capsule *pill, swabber(value); ptlrpc_buf_set_swabbed(pill->rc_req, inout, offset); if (dump) { - CDEBUG(D_RPCTRACE, "Dump of swabbed field %s " - "follows\n", field->rmf_name); + CDEBUG(D_RPCTRACE, "Dump of swabbed field %s follows\n", + field->rmf_name); field->rmf_dumper(value); } @@ -1903,8 +1903,7 @@ swabber_dumper_helper(struct req_capsule *pill, i < n; i++, p += field->rmf_size) { if (dump) { - CDEBUG(D_RPCTRACE, "Dump of %sarray field %s, " - "element %d follows\n", + CDEBUG(D_RPCTRACE, "Dump of %sarray field %s, element %d follows\n", do_swab ? "unswabbed " : "", field->rmf_name, i); field->rmf_dumper(p); } @@ -1912,8 +1911,8 @@ swabber_dumper_helper(struct req_capsule *pill, continue; swabber(p); if (dump) { - CDEBUG(D_RPCTRACE, "Dump of swabbed array field %s, " - "element %d follows\n", field->rmf_name, i); + CDEBUG(D_RPCTRACE, "Dump of swabbed array field %s, element %d follows\n", + field->rmf_name, i); field->rmf_dumper(value); } } @@ -1972,8 +1971,7 @@ static void *__req_capsule_get(struct req_capsule *pill, */ len = lustre_msg_buflen(msg, offset); if ((len % field->rmf_size) != 0) { - CERROR("%s: array field size mismatch " - "%d modulo %d != 0 (%d)\n", + CERROR("%s: array field size mismatch %d modulo %d != 0 (%d)\n", field->rmf_name, len, field->rmf_size, loc); return NULL; } @@ -1986,8 +1984,7 @@ static void *__req_capsule_get(struct req_capsule *pill, if (value == NULL) { DEBUG_REQ(D_ERROR, pill->rc_req, - "Wrong buffer for field `%s' (%d of %d) " - "in format `%s': %d vs. %d (%s)\n", + "Wrong buffer for field `%s' (%d of %d) in format `%s': %d vs. %d (%s)\n", field->rmf_name, offset, lustre_msg_bufcount(msg), fmt->rf_name, lustre_msg_buflen(msg, offset), len, rcl_names[loc]); @@ -2020,8 +2017,8 @@ void __req_capsule_dump(struct req_capsule *pill, enum req_location loc) * have a specific dumper */ len = req_capsule_get_size(pill, field, loc); - CDEBUG(D_RPCTRACE, "Field %s has no dumper function;" - "field size is %d\n", field->rmf_name, len); + CDEBUG(D_RPCTRACE, "Field %s has no dumper function; field size is %d\n", + field->rmf_name, len); } else { /* It's the dumping side-effect that we're interested in */ (void) __req_capsule_get(pill, field, loc, NULL, 1); @@ -2173,8 +2170,7 @@ void req_capsule_set_size(struct req_capsule *pill, (size > 0)) { if ((field->rmf_flags & RMF_F_STRUCT_ARRAY) && (size % field->rmf_size != 0)) { - CERROR("%s: array field size mismatch " - "%d %% %d != 0 (%d)\n", + CERROR("%s: array field size mismatch %d %% %d != 0 (%d)\n", field->rmf_name, size, field->rmf_size, loc); LBUG(); } else if (!(field->rmf_flags & RMF_F_STRUCT_ARRAY) && diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index 56f825fbb17c..e9baf5bbee3a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -334,8 +334,7 @@ static int llog_client_read_header(const struct lu_env *env, llh_hdr->lrh_type, LLOG_HDR_MAGIC); rc = -EIO; } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) { - CERROR("incorrectly sized log header: %#x " - "(expecting %#x)\n", + CERROR("incorrectly sized log header: %#x (expecting %#x)\n", llh_hdr->lrh_len, LLOG_CHUNK_SIZE); CERROR("you may need to re-run lconf --write_conf.\n"); rc = -EIO; diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 0c3f667d498f..4011e0050fcb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -745,8 +745,7 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, svcpt->scp_service->srv_name, svcpt->scp_cpt, srhi->srhi_seq, srhi->srhi_req->rq_history_seq); LASSERTF(!list_empty(&svcpt->scp_hist_reqs), - "%s:%d: seek offset %llu, request seq %llu, " - "last culled %llu\n", + "%s:%d: seek offset %llu, request seq %llu, last culled %llu\n", svcpt->scp_service->srv_name, svcpt->scp_cpt, seq, srhi->srhi_seq, svcpt->scp_hist_seq_culled); e = &srhi->srhi_req->rq_history_list; @@ -813,8 +812,8 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) int i; if (sizeof(loff_t) != sizeof(__u64)) { /* can't support */ - CWARN("Failed to read request history because size of loff_t " - "%d can't match size of u64\n", (int)sizeof(loff_t)); + CWARN("Failed to read request history because size of loff_t %d can't match size of u64\n", + (int)sizeof(loff_t)); return NULL; } @@ -1297,14 +1296,12 @@ int lprocfs_wr_import(struct file *file, const char *buffer, if (*endptr) { CERROR("config: wrong instance # %s\n", ptr); } else if (inst != imp->imp_connect_data.ocd_instance) { - CDEBUG(D_INFO, "IR: %s is connecting to an obsoleted " - "target(%u/%u), reconnecting...\n", + CDEBUG(D_INFO, "IR: %s is connecting to an obsoleted target(%u/%u), reconnecting...\n", imp->imp_obd->obd_name, imp->imp_connect_data.ocd_instance, inst); do_reconn = 1; } else { - CDEBUG(D_INFO, "IR: %s has already been connecting to " - "new target(%u)\n", + CDEBUG(D_INFO, "IR: %s has already been connecting to new target(%u)\n", imp->imp_obd->obd_name, inst); } } diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index c1e8aa4d5ec4..f715e9a8b996 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -224,8 +224,8 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) total_md - desc->bd_md_count); spin_unlock(&desc->bd_lock); - CDEBUG(D_NET, "Setup %u bulk %s buffers: %u pages %u bytes, " - "xid x%#llx-%#llx, portal %u\n", desc->bd_md_count, + CDEBUG(D_NET, "Setup %u bulk %s buffers: %u pages %u bytes, xid x%#llx-%#llx, portal %u\n", + desc->bd_md_count, desc->bd_type == BULK_GET_SOURCE ? "get-source" : "put-sink", desc->bd_iov_count, desc->bd_nob, desc->bd_last_xid, req->rq_xid, desc->bd_portal); @@ -337,8 +337,7 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) if (req->rq_reqmsg && !(lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)) { - CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x " - "req_flags=%#x magic=%d:%x/%x len=%d\n", + CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x req_flags=%#x magic=%d:%x/%x len=%d\n", flags, lustre_msg_get_flags(req->rq_reqmsg), lustre_msg_is_v1(req->rq_reqmsg), lustre_msg_get_magic(req->rq_reqmsg), diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 181301bd2083..d5fd7215c72f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -770,8 +770,8 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, tmp = nrs_policy_find_locked(nrs, policy->pol_desc->pd_name); if (tmp != NULL) { - CERROR("NRS policy %s has been registered, can't register it " - "for %s\n", policy->pol_desc->pd_name, + CERROR("NRS policy %s has been registered, can't register it for %s\n", + policy->pol_desc->pd_name, svcpt->scp_service->srv_name); nrs_policy_put_locked(tmp); @@ -882,8 +882,7 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) if (nrs_policy_compatible(svc, desc)) { rc = nrs_policy_register(nrs, desc); if (rc != 0) { - CERROR("Failed to register NRS policy %s for " - "partition %d of service %s: %d\n", + CERROR("Failed to register NRS policy %s for partition %d of service %s: %d\n", desc->pd_name, svcpt->scp_cpt, svc->srv_name, rc); /** @@ -1082,8 +1081,7 @@ again: if (rc == -ENOENT) { rc = 0; } else if (rc != 0) { - CERROR("Failed to unregister NRS policy %s for " - "partition %d of service %s: %d\n", + CERROR("Failed to unregister NRS policy %s for partition %d of service %s: %d\n", desc->pd_name, svcpt->scp_cpt, svcpt->scp_service->srv_name, rc); return rc; @@ -1145,18 +1143,15 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) if ((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) && (conf->nc_flags & (PTLRPC_NRS_FL_FALLBACK | PTLRPC_NRS_FL_REG_START))) { - CERROR("NRS: failing to register policy %s. Please check " - "policy flags; external policies cannot act as fallback " - "policies, or be started immediately upon registration " - "without interaction with lprocfs\n", conf->nc_name); + CERROR("NRS: failing to register policy %s. Please check policy flags; external policies cannot act as fallback policies, or be started immediately upon registration without interaction with lprocfs\n", + conf->nc_name); return -EINVAL; } mutex_lock(&nrs_core.nrs_mutex); if (nrs_policy_find_desc_locked(conf->nc_name) != NULL) { - CERROR("NRS: failing to register policy %s which has already " - "been registered with NRS core!\n", + CERROR("NRS: failing to register policy %s which has already been registered with NRS core!\n", conf->nc_name); rc = -EEXIST; goto fail; @@ -1209,8 +1204,7 @@ again: nrs = nrs_svcpt2nrs(svcpt, hp); rc = nrs_policy_register(nrs, desc); if (rc != 0) { - CERROR("Failed to register NRS policy %s for " - "partition %d of service %s: %d\n", + CERROR("Failed to register NRS policy %s for partition %d of service %s: %d\n", desc->pd_name, svcpt->scp_cpt, svcpt->scp_service->srv_name, rc); @@ -1281,8 +1275,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) LASSERT(conf != NULL); if (conf->nc_flags & PTLRPC_NRS_FL_FALLBACK) { - CERROR("Unable to unregister a fallback policy, unless the " - "PTLRPC service is stopping.\n"); + CERROR("Unable to unregister a fallback policy, unless the PTLRPC service is stopping.\n"); return -EPERM; } @@ -1292,8 +1285,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) desc = nrs_policy_find_desc_locked(conf->nc_name); if (desc == NULL) { - CERROR("Failing to unregister NRS policy %s which has " - "not been registered with NRS core!\n", + CERROR("Failing to unregister NRS policy %s which has not been registered with NRS core!\n", conf->nc_name); rc = -ENOENT; goto not_exist; @@ -1304,9 +1296,8 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) rc = nrs_policy_unregister_locked(desc); if (rc < 0) { if (rc == -EBUSY) - CERROR("Please first stop policy %s on all service " - "partitions and then retry to unregister the " - "policy.\n", conf->nc_name); + CERROR("Please first stop policy %s on all service partitions and then retry to unregister the policy.\n", + conf->nc_name); goto fail; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 60552f4e9798..2f45f7657830 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -412,8 +412,8 @@ void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size) buflen = m->lm_buflens[n]; if (unlikely(buflen < min_size)) { - CERROR("msg %p buffer[%d] size %d too small " - "(required %d, opc=%d)\n", m, n, buflen, min_size, + CERROR("msg %p buffer[%d] size %d too small (required %d, opc=%d)\n", + m, n, buflen, min_size, n == MSG_PTLRPC_BODY_OFF ? -1 : lustre_msg_get_opc(m)); return NULL; } @@ -749,21 +749,19 @@ char *lustre_msg_string(struct lustre_msg *m, int index, int max_len) slen = strnlen(str, blen); if (slen == blen) { /* not NULL terminated */ - CERROR("can't unpack non-NULL terminated string in " - "msg %p buffer[%d] len %d\n", m, index, blen); + CERROR("can't unpack non-NULL terminated string in msg %p buffer[%d] len %d\n", + m, index, blen); return NULL; } if (max_len == 0) { if (slen != blen - 1) { - CERROR("can't unpack short string in msg %p " - "buffer[%d] len %d: strlen %d\n", + CERROR("can't unpack short string in msg %p buffer[%d] len %d: strlen %d\n", m, index, blen, slen); return NULL; } } else if (slen > max_len) { - CERROR("can't unpack oversized string in msg %p " - "buffer[%d] len %d strlen %d: max %d expected\n", + CERROR("can't unpack oversized string in msg %p buffer[%d] len %d strlen %d: max %d expected\n", m, index, blen, slen, max_len); return NULL; } @@ -2258,8 +2256,8 @@ void lustre_swab_quota_body(struct quota_body *b) void dump_ioo(struct obd_ioobj *ioo) { CDEBUG(D_RPCTRACE, - "obd_ioobj: ioo_oid="DOSTID", ioo_max_brw=%#x, " - "ioo_bufct=%d\n", POSTID(&ioo->ioo_oid), ioo->ioo_max_brw, + "obd_ioobj: ioo_oid=" DOSTID ", ioo_max_brw=%#x, ioo_bufct=%d\n", + POSTID(&ioo->ioo_oid), ioo->ioo_max_brw, ioo->ioo_bufcnt); } EXPORT_SYMBOL(dump_ioo); @@ -2330,8 +2328,7 @@ void dump_obdo(struct obdo *oa) CDEBUG(D_RPCTRACE, "obdo: o_handle = %lld\n", oa->o_handle.cookie); if (valid & OBD_MD_FLCOOKIE) - CDEBUG(D_RPCTRACE, "obdo: o_lcookie = " - "(llog_cookie dumping not yet implemented)\n"); + CDEBUG(D_RPCTRACE, "obdo: o_lcookie = (llog_cookie dumping not yet implemented)\n"); } EXPORT_SYMBOL(dump_obdo); @@ -2395,17 +2392,15 @@ void _debug_req(struct ptlrpc_request *req, va_start(args, fmt); libcfs_debug_vmsg2(msgdata, fmt, args, - " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d" - " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d " - "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n", + " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %d dl " CFS_TIME_T " ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", req, req->rq_xid, req->rq_transno, req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, req->rq_import ? - req->rq_import->imp_obd->obd_name : - req->rq_export ? - req->rq_export->exp_client_uuid.uuid : - "", + req->rq_import->imp_obd->obd_name : + req->rq_export ? + req->rq_export->exp_client_uuid.uuid : + "", libcfs_nid2str(nid), req->rq_request_portal, req->rq_reply_portal, req->rq_reqlen, req->rq_replen, diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index b9cbbbd5322e..340d98a64137 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -206,8 +206,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp, spin_unlock(&imp->imp_lock); - CDEBUG(level == LUSTRE_IMP_FULL ? D_INFO : D_HA, "%s->%s: level %s/%u " - "force %u force_next %u deactive %u pingable %u suppress %u\n", + CDEBUG(level == LUSTRE_IMP_FULL ? D_INFO : D_HA, "%s->%s: level %s/%u force %u force_next %u deactive %u pingable %u suppress %u\n", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd), ptlrpc_import_state_name(level), level, force, force_next, imp->imp_deactive, imp->imp_pingable, suppress); @@ -220,8 +219,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp, } else if (level != LUSTRE_IMP_FULL || imp->imp_obd->obd_no_recov || imp_is_deactive(imp)) { - CDEBUG(D_HA, "%s->%s: not pinging (in recovery " - "or recovery disabled: %s)\n", + CDEBUG(D_HA, "%s->%s: not pinging (in recovery or recovery disabled: %s)\n", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd), ptlrpc_import_state_name(level)); if (force) { @@ -334,11 +332,7 @@ int ptlrpc_start_pinger(void) thread_is_running(&pinger_thread), &lwi); if (suppress_pings) - CWARN("Pings will be suppressed at the request of the " - "administrator. The configuration shall meet the " - "additional requirements described in the manual. " - "(Search for the \"suppress_pings\" kernel module " - "parameter.)\n"); + CWARN("Pings will be suppressed at the request of the administrator. The configuration shall meet the additional requirements described in the manual. (Search for the \"suppress_pings\" kernel module parameter.)\n"); return 0; } @@ -623,11 +617,7 @@ static int ping_evictor_main(void *arg) if (expire_time > exp->exp_last_request_time) { class_export_get(exp); spin_unlock(&obd->obd_dev_lock); - LCONSOLE_WARN("%s: haven't heard from client %s" - " (at %s) in %ld seconds. I think" - " it's dead, and I am evicting" - " it. exp %p, cur %ld expire %ld" - " last %ld\n", + LCONSOLE_WARN("%s: haven't heard from client %s (at %s) in %ld seconds. I think it's dead, and I am evicting it. exp %p, cur %ld expire %ld last %ld\n", obd->obd_name, obd_uuid2str(&exp->exp_client_uuid), obd_export_nid2str(exp), diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 357ea9f8bd57..cbcc541cac43 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -356,10 +356,9 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) if (atomic_read(&ps->set_new_count)) { rc = ptlrpcd_steal_rqset(set, ps); if (rc > 0) - CDEBUG(D_RPCTRACE, "transfer %d" - " async RPCs [%d->%d]\n", - rc, partner->pc_index, - pc->pc_index); + CDEBUG(D_RPCTRACE, "transfer %d async RPCs [%d->%d]\n", + rc, partner->pc_index, + pc->pc_index); } ptlrpc_reqset_put(ps); } while (rc == 0 && pc->pc_cursor != first); diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index e1bc77b83ffb..7b1d72947330 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -237,8 +237,7 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) if (ptlrpc_set_import_discon(imp, lustre_msg_get_conn_cnt(failed_req->rq_reqmsg))) { if (!imp->imp_replayable) { - CDEBUG(D_HA, "import %s@%s for %s not replayable, " - "auto-deactivating\n", + CDEBUG(D_HA, "import %s@%s for %s not replayable, auto-deactivating\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid, imp->imp_obd->obd_name); @@ -274,8 +273,8 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) /* When deactivating, mark import invalid, and abort in-flight * requests. */ if (!active) { - LCONSOLE_WARN("setting import %s INACTIVE by administrator " - "request\n", obd2cli_tgt(imp->imp_obd)); + LCONSOLE_WARN("setting import %s INACTIVE by administrator request\n", + obd2cli_tgt(imp->imp_obd)); /* set before invalidate to avoid messages about imp_inval * set without imp_deactive in ptlrpc_import_delay_req */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 6ac8a8330c7c..21e9dc9d5580 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -456,8 +456,8 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, LASSERT(req->rq_reqlen); LASSERT(req->rq_replen); - CDEBUG(D_SEC, "req %p: switch ctx %p(%u->%s) -> %p(%u->%s), " - "switch sec %p(%s) -> %p(%s)\n", req, + CDEBUG(D_SEC, "req %p: switch ctx %p(%u->%s) -> %p(%u->%s), switch sec %p(%s) -> %p(%s)\n", + req, oldctx, oldctx->cc_vcred.vc_uid, sec2target_str(oldctx->cc_sec), newctx, newctx->cc_vcred.vc_uid, sec2target_str(newctx->cc_sec), oldctx->cc_sec, oldctx->cc_sec->ps_policy->sp_name, @@ -1841,8 +1841,8 @@ int sptlrpc_target_export_check(struct obd_export *exp, req->rq_svc_ctx, &flavor); } else { - CDEBUG(D_SEC, "exp %p (%x|%x|%x): is current flavor, " - "install rvs ctx\n", exp, exp->exp_flvr.sf_rpc, + CDEBUG(D_SEC, "exp %p (%x|%x|%x): is current flavor, install rvs ctx\n", + exp, exp->exp_flvr.sf_rpc, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc); spin_unlock(&exp->exp_lock); @@ -1855,13 +1855,12 @@ int sptlrpc_target_export_check(struct obd_export *exp, if (exp->exp_flvr_expire[0]) { if (exp->exp_flvr_expire[0] >= get_seconds()) { if (flavor_allowed(&exp->exp_flvr_old[0], req)) { - CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the " - "middle one ("CFS_DURATION_T")\n", exp, + CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the middle one (" CFS_DURATION_T ")\n", exp, exp->exp_flvr.sf_rpc, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_expire[0] - - get_seconds()); + get_seconds()); spin_unlock(&exp->exp_lock); return 0; } @@ -1880,13 +1879,13 @@ int sptlrpc_target_export_check(struct obd_export *exp, if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) { if (exp->exp_flvr_expire[1] >= get_seconds()) { if (flavor_allowed(&exp->exp_flvr_old[1], req)) { - CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the " - "oldest one ("CFS_DURATION_T")\n", exp, + CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the oldest one (" CFS_DURATION_T ")\n", + exp, exp->exp_flvr.sf_rpc, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_expire[1] - - get_seconds()); + get_seconds()); spin_unlock(&exp->exp_lock); return 0; } @@ -1906,8 +1905,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, spin_unlock(&exp->exp_lock); - CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with " - "unauthorized flavor %x, expect %x|%x(%+ld)|%x(%+ld)\n", + CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with unauthorized flavor %x, expect %x|%x(%+ld)|%x(%+ld)\n", exp, exp->exp_obd->obd_name, req, req->rq_auth_gss, req->rq_ctx_init, req->rq_ctx_fini, req->rq_auth_usr_root, req->rq_auth_usr_mdt, req->rq_auth_usr_ost, diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index cc68a1cf24e3..0dabd83fd46f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -772,8 +772,7 @@ void sptlrpc_enc_pool_fini(void) if (page_pools.epp_st_access > 0) { CDEBUG(D_SEC, - "max pages %lu, grows %u, grow fails %u, shrinks %u, " - "access %lu, missing %lu, max qlen %u, max wait " + "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait " CFS_TIME_T"/%d\n", page_pools.epp_st_max_pages, page_pools.epp_st_grows, page_pools.epp_st_grow_fails, diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 3d72b810c45c..a79cd53010a4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -938,8 +938,8 @@ int plain_svc_wrap_bulk(struct ptlrpc_request *req, rc = plain_generate_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg, tokenv); if (rc) { - CERROR("bulk read: server failed to compute " - "checksum: %d\n", rc); + CERROR("bulk read: server failed to compute checksum: %d\n", + rc); } else { if (OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_RECEIVE)) corrupt_bulk_data(desc); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index a8df8a792333..635b12b22cef 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -580,8 +580,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, svc->srv_nthrs_cpt_init = init; if (nthrs * svc->srv_ncpts > tc->tc_nthrs_max) { - CDEBUG(D_OTHER, "%s: This service may have more threads (%d) " - "than the given soft limit (%d)\n", + CDEBUG(D_OTHER, "%s: This service may have more threads (%d) than the given soft limit (%d)\n", svc->srv_name, nthrs * svc->srv_ncpts, tc->tc_nthrs_max); } @@ -1251,8 +1250,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) /* deadline is when the client expects us to reply, margin is the difference between clients' and servers' expectations */ DEBUG_REQ(D_ADAPTTO, req, - "%ssending early reply (deadline %+lds, margin %+lds) for " - "%d+%d", AT_OFF ? "AT off - not " : "", + "%ssending early reply (deadline %+lds, margin %+lds) for %d+%d", + AT_OFF ? "AT off - not " : "", olddl, olddl - at_get(&svcpt->scp_at_estimate), at_get(&svcpt->scp_at_estimate), at_extra); @@ -1260,17 +1259,15 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) return 0; if (olddl < 0) { - DEBUG_REQ(D_WARNING, req, "Already past deadline (%+lds), " - "not sending early reply. Consider increasing " - "at_early_margin (%d)?", olddl, at_early_margin); + DEBUG_REQ(D_WARNING, req, "Already past deadline (%+lds), not sending early reply. Consider increasing at_early_margin (%d)?", + olddl, at_early_margin); /* Return an error so we're not re-added to the timed list. */ return -ETIMEDOUT; } if (!(lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)) { - DEBUG_REQ(D_INFO, req, "Wanted to ask client for more time, " - "but no AT support"); + DEBUG_REQ(D_INFO, req, "Wanted to ask client for more time, but no AT support"); return -ENOSYS; } @@ -1296,8 +1293,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) * we may be past adaptive_max */ if (req->rq_deadline >= req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate)) { - DEBUG_REQ(D_WARNING, req, "Couldn't add any time " - "(%ld/%ld), not sending early reply\n", + DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%ld), not sending early reply\n", olddl, req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate) - get_seconds()); @@ -1329,8 +1325,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) LASSERT(atomic_read(&req->rq_refcount)); /** if it is last refcount then early reply isn't needed */ if (atomic_read(&req->rq_refcount) == 1) { - DEBUG_REQ(D_ADAPTTO, reqcopy, "Normal reply already sent out, " - "abort sending early reply\n"); + DEBUG_REQ(D_ADAPTTO, reqcopy, "Normal reply already sent out, abort sending early reply\n"); rc = -EINVAL; goto out; } @@ -1454,16 +1449,14 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) spin_unlock(&svcpt->scp_at_lock); - CDEBUG(D_ADAPTTO, "timeout in %+ds, asking for %d secs on %d early " - "replies\n", first, at_extra, counter); + CDEBUG(D_ADAPTTO, "timeout in %+ds, asking for %d secs on %d early replies\n", + first, at_extra, counter); if (first < 0) { /* We're already past request deadlines before we even get a chance to send early replies */ - LCONSOLE_WARN("%s: This server is not able to keep up with " - "request traffic (cpu-bound).\n", + LCONSOLE_WARN("%s: This server is not able to keep up with request traffic (cpu-bound).\n", svcpt->scp_service->srv_name); - CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, " - "delay="CFS_DURATION_T"(jiff)\n", + CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=" CFS_DURATION_T "(jiff)\n", counter, svcpt->scp_nreqs_incoming, svcpt->scp_nreqs_active, at_get(&svcpt->scp_at_estimate), delay); @@ -1825,8 +1818,7 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, if (rc == 0) { rc = sptlrpc_target_export_check(req->rq_export, req); if (rc) - DEBUG_REQ(D_ERROR, req, "DROPPING req with " - "illegal security flavor,"); + DEBUG_REQ(D_ERROR, req, "DROPPING req with illegal security flavor,"); } if (rc) @@ -1942,18 +1934,17 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, /* Discard requests queued for longer than the deadline. The deadline is increased if we send an early reply. */ if (get_seconds() > request->rq_deadline) { - DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s" - ": deadline "CFS_DURATION_T":"CFS_DURATION_T"s ago\n", + DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s: deadline " CFS_DURATION_T ":" CFS_DURATION_T "s ago\n", libcfs_id2str(request->rq_peer), cfs_time_sub(request->rq_deadline, - request->rq_arrival_time.tv_sec), + request->rq_arrival_time.tv_sec), cfs_time_sub(get_seconds(), - request->rq_deadline)); + request->rq_deadline)); goto put_conn; } - CDEBUG(D_RPCTRACE, "Handling RPC pname:cluuid+ref:pid:xid:nid:opc " - "%s:%s+%d:%d:x%llu:%s:%d\n", current_comm(), + CDEBUG(D_RPCTRACE, "Handling RPC pname:cluuid+ref:pid:xid:nid:opc %s:%s+%d:%d:x%llu:%s:%d\n", + current_comm(), (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? @@ -1986,26 +1977,24 @@ 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%llu:%s:%d Request processed in " - "%ldus (%ldus total) trans %llu rc %d/%d\n", - current_comm(), - (request->rq_export ? - (char *)request->rq_export->exp_client_uuid.uuid : "0"), - (request->rq_export ? - atomic_read(&request->rq_export->exp_refcount) : -99), - lustre_msg_get_status(request->rq_reqmsg), - request->rq_xid, - libcfs_id2str(request->rq_peer), - lustre_msg_get_opc(request->rq_reqmsg), - timediff, - cfs_timeval_sub(&work_end, &request->rq_arrival_time, NULL), - (request->rq_repmsg ? - lustre_msg_get_transno(request->rq_repmsg) : - request->rq_transno), - request->rq_status, - (request->rq_repmsg ? - lustre_msg_get_status(request->rq_repmsg) : -999)); + CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc %s:%s+%d:%d:x%llu:%s:%d Request processed in %ldus (%ldus total) trans %llu rc %d/%d\n", + current_comm(), + (request->rq_export ? + (char *)request->rq_export->exp_client_uuid.uuid : "0"), + (request->rq_export ? + atomic_read(&request->rq_export->exp_refcount) : -99), + lustre_msg_get_status(request->rq_reqmsg), + request->rq_xid, + libcfs_id2str(request->rq_peer), + lustre_msg_get_opc(request->rq_reqmsg), + timediff, + cfs_timeval_sub(&work_end, &request->rq_arrival_time, NULL), + (request->rq_repmsg ? + lustre_msg_get_transno(request->rq_repmsg) : + request->rq_transno), + request->rq_status, + (request->rq_repmsg ? + lustre_msg_get_status(request->rq_repmsg) : -999)); if (likely(svc->srv_stats != NULL && request->rq_reqmsg != NULL)) { __u32 op = lustre_msg_get_opc(request->rq_reqmsg); int opc = opcode_offset(op); @@ -2557,8 +2546,8 @@ static int ptlrpc_start_hr_threads(void) if (!IS_ERR_VALUE(rc)) continue; - CERROR("Reply handling thread %d:%d Failed on starting: " - "rc = %d\n", i, j, rc); + CERROR("Reply handling thread %d:%d Failed on starting: rc = %d\n", + i, j, rc); ptlrpc_stop_hr_threads(); return rc; } @@ -2920,8 +2909,7 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) rc = l_wait_event(svcpt->scp_waitq, svcpt->scp_nrqbds_posted == 0, &lwi); if (rc == -ETIMEDOUT) { - CWARN("Service %s waiting for " - "request buffers\n", + CWARN("Service %s waiting for request buffers\n", svcpt->scp_service->srv_name); } spin_lock(&svcpt->scp_lock); -- cgit v1.2.3-59-g8ed1b From 2595fa367fe76719d3d7338e040f55734300f678 Mon Sep 17 00:00:00 2001 From: Giedrius Statkevicius Date: Sun, 23 Nov 2014 22:50:14 +0200 Subject: staging: lustre: Fix sparse warnings for lnet/lnet/router.c Fix the following sparse errors: drivers/staging/lustre/lnet/lnet/router.c:756:1: warning: symbol 'lnet_wait_known_routerstate' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:788:1: warning: symbol 'lnet_update_ni_status_locked' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:828:1: warning: symbol 'lnet_destroy_rc_data' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:848:16: warning: symbol 'lnet_create_rc_data_locked' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:1228:1: warning: symbol 'lnet_destroy_rtrbuf' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:1238:15: warning: symbol 'lnet_new_rtrbuf' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:1274:1: warning: symbol 'lnet_rtrpool_free_bufs' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:1303:1: warning: symbol 'lnet_rtrpool_alloc_bufs' was not declared. Should it be static? drivers/staging/lustre/lnet/lnet/router.c:1337:1: warning: symbol 'lnet_rtrpool_init' was not declared. Should it be static? Signed-off-by: Giedrius Statkevicius Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 59fb6bff0266..c667b5b76761 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -751,7 +751,7 @@ lnet_router_checker_event(lnet_event_t *event) lnet_net_unlock(lp->lp_cpt); } -void +static void lnet_wait_known_routerstate(void) { lnet_peer_t *rtr; @@ -783,7 +783,7 @@ lnet_wait_known_routerstate(void) } } -void +static void lnet_update_ni_status_locked(void) { lnet_ni_t *ni; @@ -823,7 +823,7 @@ lnet_update_ni_status_locked(void) } } -void +static void lnet_destroy_rc_data(lnet_rc_data_t *rcd) { LASSERT(list_empty(&rcd->rcd_list)); @@ -844,7 +844,7 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd) LIBCFS_FREE(rcd, sizeof(*rcd)); } -lnet_rc_data_t * +static lnet_rc_data_t * lnet_create_rc_data_locked(lnet_peer_t *gateway) { lnet_rc_data_t *rcd = NULL; @@ -1220,7 +1220,7 @@ rescan: return 0; } -void +static void lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages) { int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); @@ -1231,7 +1231,7 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages) LIBCFS_FREE(rb, sz); } -lnet_rtrbuf_t * +static lnet_rtrbuf_t * lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) { int npages = rbp->rbp_npages; @@ -1266,7 +1266,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) return rb; } -void +static void lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp) { int npages = rbp->rbp_npages; @@ -1295,7 +1295,7 @@ lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp) rbp->rbp_nbuffers = rbp->rbp_credits = 0; } -int +static int lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) { lnet_rtrbuf_t *rb; @@ -1329,7 +1329,7 @@ lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) return 0; } -void +static void lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages) { INIT_LIST_HEAD(&rbp->rbp_msgs); -- cgit v1.2.3-59-g8ed1b From deae03af12795179e9858b2f7575eb2b8c12768c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:37 -0500 Subject: staging: rtl8723au: Remove unused rtw_calculate_wlan_pkt_size_by_attribue23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 17 ----------------- drivers/staging/rtl8723au/include/rtw_xmit.h | 2 -- 2 files changed, 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index a0f7e2787afe..b3bf86ebeeca 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1042,23 +1042,6 @@ s32 rtw_txframes_sta_ac_pending23a(struct rtw_adapter *padapter, return ptxservq->qcnt; } -/* - * Calculate wlan 802.11 packet MAX size from pkt_attrib - * This function doesn't consider fragment case - */ -u32 rtw_calculate_wlan_pkt_size_by_attribue23a(struct pkt_attrib *pattrib) -{ - u32 len = 0; - - len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ - len += SNAP_SIZE + sizeof(u16); /* LLC */ - len += pattrib->pktlen; - if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) len += 8; /* MIC */ - len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ - - return len; -} - /* This sub-routine will perform all the following: diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 73e5f9cbfac0..36184320aa86 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -354,8 +354,6 @@ struct xmit_frame *rtw_dequeue_xframe23a(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry); s32 rtw_xmit23a_classifier(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); -u32 rtw_calculate_wlan_pkt_size_by_attribue23a(struct pkt_attrib *pattrib); -#define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue23a(&f->attrib) s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe); s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); -- cgit v1.2.3-59-g8ed1b From 641f39a07cee88965c3aedbc4502e82b15b0e058 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:38 -0500 Subject: staging rtl8723au: rtw_put_smap23a(): Use common SNAP header defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index b3bf86ebeeca..18a9f34cd94d 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -22,9 +22,6 @@ #include #include -static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; -static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; - static void _init_txservq(struct tx_servq *ptxservq) { @@ -1244,23 +1241,14 @@ exit: */ s32 rtw_put_snap23a(u8 *data, u16 h_proto) { - struct ieee80211_snap_hdr *snap; - u8 *oui; - - snap = (struct ieee80211_snap_hdr *)data; - snap->dsap = 0xaa; - snap->ssap = 0xaa; - snap->ctrl = 0x03; - - if (h_proto == 0x8137 || h_proto == 0x80f3) - oui = P802_1H_OUI; + if (h_proto == ETH_P_IPX || h_proto == ETH_P_AARP) + ether_addr_copy(data, bridge_tunnel_header); else - oui = RFC1042_OUI; - snap->oui[0] = oui[0]; - snap->oui[1] = oui[1]; - snap->oui[2] = oui[2]; - *(u16 *)(data + SNAP_SIZE) = htons(h_proto); - return SNAP_SIZE + sizeof(u16); + ether_addr_copy(data, rfc1042_header); + + data += ETH_ALEN; + *(__be16 *)data = htons(h_proto); + return ETH_ALEN + sizeof(u16); } void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) -- cgit v1.2.3-59-g8ed1b From 01ca2e9df902aeb60c246abd54fcea22006bbc42 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:39 -0500 Subject: staging: rtl8723au: rtw_put_snap23a(): Use put_unaligned to set protocol Reported-by: Arend van Spriel Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 18a9f34cd94d..f8b124322fc3 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1247,7 +1247,7 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto) ether_addr_copy(data, rfc1042_header); data += ETH_ALEN; - *(__be16 *)data = htons(h_proto); + put_unaligned_be16(h_proto, data); return ETH_ALEN + sizeof(u16); } -- cgit v1.2.3-59-g8ed1b From 848ad5d305671931efff0fee0a72123830203011 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:40 -0500 Subject: staging: rtl8723au: rtw_put_snap23a(): Make it static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 40 ++++++++++++++-------------- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index f8b124322fc3..5cbfab45c5ce 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1039,6 +1039,25 @@ s32 rtw_txframes_sta_ac_pending23a(struct rtw_adapter *padapter, return ptxservq->qcnt; } +/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header + * IEEE LLC/SNAP header contains 8 octets + * First 3 octets comprise the LLC portion + * SNAP portion, 5 octets, is divided into two fields: + * Organizationally Unique Identifier(OUI), 3 octets, + * type, defined by that organization, 2 octets. + */ +static int rtw_put_snap(u8 *data, u16 h_proto) +{ + if (h_proto == ETH_P_IPX || h_proto == ETH_P_AARP) + ether_addr_copy(data, bridge_tunnel_header); + else + ether_addr_copy(data, rfc1042_header); + + data += ETH_ALEN; + put_unaligned_be16(h_proto, data); + return ETH_ALEN + sizeof(u16); +} + /* This sub-routine will perform all the following: @@ -1162,7 +1181,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, mpdu_len -= pattrib->iv_len; } if (frg_inx == 0) { - llc_sz = rtw_put_snap23a(pframe, pattrib->ether_type); + llc_sz = rtw_put_snap(pframe, pattrib->ether_type); pframe += llc_sz; mpdu_len -= llc_sz; } @@ -1232,25 +1251,6 @@ exit: return res; } -/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header - * IEEE LLC/SNAP header contains 8 octets - * First 3 octets comprise the LLC portion - * SNAP portion, 5 octets, is divided into two fields: - * Organizationally Unique Identifier(OUI), 3 octets, - * type, defined by that organization, 2 octets. - */ -s32 rtw_put_snap23a(u8 *data, u16 h_proto) -{ - if (h_proto == ETH_P_IPX || h_proto == ETH_P_AARP) - ether_addr_copy(data, bridge_tunnel_header); - else - ether_addr_copy(data, rfc1042_header); - - data += ETH_ALEN; - put_unaligned_be16(h_proto, data); - return ETH_ALEN + sizeof(u16); -} - void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) { struct xmit_priv *pxmitpriv = &padapter->xmitpriv; diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 36184320aa86..87097c459137 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -340,7 +340,6 @@ s32 rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); void rtw_count_tx_stats23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe, int sz); void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len); -s32 rtw_put_snap23a(u8 *data, u16 h_proto); struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv); struct xmit_frame *rtw_alloc_xmitframe23a_once(struct xmit_priv *pxmitpriv); s32 rtw_free_xmitframe23a(struct xmit_priv *pxmitpriv, -- cgit v1.2.3-59-g8ed1b From a0c5ff0bafd513dce0038902b2bb54edc8250a31 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:41 -0500 Subject: staging: rtl8723au: portctrl(): Remove a pile of unnecessary clutter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 40 ++++--------------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index de98da5baa2b..9d6539325839 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -568,59 +568,27 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =" "%d\n", adapter->securitypriv.dot11AuthAlgrthm)); + prtnframe = precv_frame; + if (auth_alg == dot11AuthAlgrthm_8021X) { /* get ether_type */ ptr = pfhdr->pkt->data + pfhdr->attrib.hdrlen; ether_type = (ptr[6] << 8) | ptr[7]; - if ((psta != NULL) && (psta->ieee8021x_blocked)) { + if (psta && psta->ieee8021x_blocked) { /* blocked */ /* only accept EAPOL frame */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked ==" "1\n")); - if (ether_type == eapol_type) { - prtnframe = precv_frame; - } else { + if (ether_type != eapol_type) { /* free this frame */ rtw_free_recvframe23a(precv_frame); prtnframe = NULL; } - } else { - /* 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->attrib.privacy)); - - if (pattrib->bdecrypted == 0) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("portctrl:prxstat->decrypted =%x\n", - pattrib->bdecrypted)); - } - - prtnframe = precv_frame; - /* check is the EAPOL frame or not (Rekey) */ - if (ether_type == eapol_type) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, - ("########portctrl:ether_type == " - "0x888e\n")); - /* check Rekey */ - - prtnframe = precv_frame; - } else { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("########portctrl:ether_type = 0x%04x" - "\n", ether_type)); - } } - } else { - prtnframe = precv_frame; } return prtnframe; -- cgit v1.2.3-59-g8ed1b From 22f42e2aa248dc9f3f214d7d39e0e5bf1afc39fb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:42 -0500 Subject: staging: rtl8723au: rtw_dump_xframe(): Use proper ETH_P_* types Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index a67850fe6e5d..cf31d29d478a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -306,10 +306,10 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter, struct pkt_attrib *pattrib = &pxmitframe->attrib; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - if ((pxmitframe->frame_tag == DATA_FRAMETAG) && - (pxmitframe->attrib.ether_type != 0x0806) && - (pxmitframe->attrib.ether_type != 0x888e) && - (pxmitframe->attrib.dhcp_pkt != 1)) + if (pxmitframe->frame_tag == DATA_FRAMETAG && + pxmitframe->attrib.ether_type != ETH_P_ARP && + pxmitframe->attrib.ether_type != ETH_P_PAE && + pxmitframe->attrib.dhcp_pkt != 1) rtw_issue_addbareq_cmd23a(padapter, pxmitframe); mem_addr = pxmitframe->buf_addr; -- cgit v1.2.3-59-g8ed1b From b81f3f26c523d5672f9d67ad8cc8f8f9bb0b72bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:43 -0500 Subject: staging: rtl8723au: pxmitframe->frame_tag is never set to a value > 8 No point of masking out high bits since we never set the value to anything exceeding bits 0-3. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 5cbfab45c5ce..1f4ebb36f653 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1291,7 +1291,7 @@ void rtw_count_tx_stats23a(struct rtw_adapter *padapter, struct xmit_frame *pxmi struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + if (pxmitframe->frame_tag == DATA_FRAMETAG) { pxmitpriv->tx_bytes += sz; pmlmepriv->LinkDetectInfo.NumTxOkInPeriod++; diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index cf31d29d478a..9cdd9e5d9f76 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -163,7 +163,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag memset(ptxdesc, 0, sizeof(struct tx_desc)); - if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + if (pxmitframe->frame_tag == DATA_FRAMETAG) { /* offset 4 */ ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id&0x1f); @@ -215,7 +215,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate23a(pmlmeext->tx_rate)); } - } else if ((pxmitframe->frame_tag&0x0f) == MGNT_FRAMETAG) { + } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) { /* offset 4 */ ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id&0x1f); @@ -240,10 +240,11 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw5 |= cpu_to_le32(0x00180000);/* retry limit = 6 */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate23a(pmlmeext->tx_rate)); - } else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { + } else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) { DBG_8723A("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); } else { - DBG_8723A("pxmitframe->frame_tag = %d\n", pxmitframe->frame_tag); + DBG_8723A("pxmitframe->frame_tag = %d\n", + pxmitframe->frame_tag); /* offset 4 */ ptxdesc->txdw1 |= cpu_to_le32((4)&0x1f);/* CAM_ID(MAC_ID) */ @@ -392,7 +393,7 @@ bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, pxmitbuf->priv_data = pxmitframe; - if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + if (pxmitframe->frame_tag == DATA_FRAMETAG) { if (pxmitframe->attrib.priority <= 15)/* TID0~15 */ res = rtw_xmitframe_coalesce23a(padapter, pxmitframe->pkt, pxmitframe); -- cgit v1.2.3-59-g8ed1b From e2e0c12e49295cdb126e49d624df3194bf71ee66 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:44 -0500 Subject: staging: rtl8723au: Remove unused rtl8723a_update_txdesc() and child functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 248 ---------------------- drivers/staging/rtl8723au/include/rtl8723a_xmit.h | 1 - 2 files changed, 249 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 9a75eb6bb5a3..8196a3315df4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1975,254 +1975,6 @@ static void rtl8723a_cal_txdesc_chksum(struct tx_desc *ptxdesc) ptxdesc->txdw7 |= cpu_to_le32(checksum & 0x0000ffff); } -static void fill_txdesc_sectype(struct pkt_attrib *pattrib, - struct txdesc_8723a *ptxdesc) -{ - if ((pattrib->encrypt > 0) && !pattrib->bswenc) { - switch (pattrib->encrypt) { - /* SEC_TYPE */ - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - case WLAN_CIPHER_SUITE_TKIP: - ptxdesc->sectype = 1; - break; - - case WLAN_CIPHER_SUITE_CCMP: - ptxdesc->sectype = 3; - break; - - case 0: - default: - break; - } - } -} - -static void fill_txdesc_vcs(struct pkt_attrib *pattrib, - struct txdesc_8723a *ptxdesc) -{ - /* DBG_8723A("cvs_mode =%d\n", pattrib->vcs_mode); */ - - switch (pattrib->vcs_mode) { - case RTS_CTS: - ptxdesc->rtsen = 1; - break; - - case CTS_TO_SELF: - ptxdesc->cts2self = 1; - break; - - case NONE_VCS: - default: - break; - } - - if (pattrib->vcs_mode) { - ptxdesc->hw_rts_en = 1; /* ENABLE HW RTS */ - - /* Set RTS BW */ - if (pattrib->ht_en) { - if (pattrib->bwmode & HT_CHANNEL_WIDTH_40) - ptxdesc->rts_bw = 1; - - switch (pattrib->ch_offset) { - case HAL_PRIME_CHNL_OFFSET_DONT_CARE: - ptxdesc->rts_sc = 0; - break; - - case HAL_PRIME_CHNL_OFFSET_LOWER: - ptxdesc->rts_sc = 1; - break; - - case HAL_PRIME_CHNL_OFFSET_UPPER: - ptxdesc->rts_sc = 2; - break; - - default: - ptxdesc->rts_sc = 3; /* Duplicate */ - break; - } - } - } -} - -static void fill_txdesc_phy(struct pkt_attrib *pattrib, - struct txdesc_8723a *ptxdesc) -{ - if (pattrib->ht_en) { - if (pattrib->bwmode & HT_CHANNEL_WIDTH_40) - ptxdesc->data_bw = 1; - - switch (pattrib->ch_offset) { - case HAL_PRIME_CHNL_OFFSET_DONT_CARE: - ptxdesc->data_sc = 0; - break; - - case HAL_PRIME_CHNL_OFFSET_LOWER: - ptxdesc->data_sc = 1; - break; - - case HAL_PRIME_CHNL_OFFSET_UPPER: - ptxdesc->data_sc = 2; - break; - - default: - ptxdesc->data_sc = 3; /* Duplicate */ - break; - } - } -} - -static void rtl8723a_fill_default_txdesc(struct xmit_frame *pxmitframe, - u8 *pbuf) -{ - struct rtw_adapter *padapter; - struct hal_data_8723a *pHalData; - struct dm_priv *pdmpriv; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - struct pkt_attrib *pattrib; - struct txdesc_8723a *ptxdesc; - s32 bmcst; - - padapter = pxmitframe->padapter; - pHalData = GET_HAL_DATA(padapter); - pdmpriv = &pHalData->dmpriv; - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - - pattrib = &pxmitframe->attrib; - bmcst = is_multicast_ether_addr(pattrib->ra); - - ptxdesc = (struct txdesc_8723a *)pbuf; - - if (pxmitframe->frame_tag == DATA_FRAMETAG) { - ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */ - - if (pattrib->ampdu_en == true) - ptxdesc->agg_en = 1; /* AGG EN */ - else - ptxdesc->bk = 1; /* AGG BK */ - - ptxdesc->qsel = pattrib->qsel; - ptxdesc->rate_id = pattrib->raid; - - fill_txdesc_sectype(pattrib, ptxdesc); - - ptxdesc->seq = pattrib->seqnum; - - if ((pattrib->ether_type != 0x888e) && - (pattrib->ether_type != 0x0806) && - (pattrib->dhcp_pkt != 1)) { - /* Non EAP & ARP & DHCP type data packet */ - - fill_txdesc_vcs(pattrib, ptxdesc); - fill_txdesc_phy(pattrib, ptxdesc); - - ptxdesc->rtsrate = 8; /* RTS Rate = 24M */ - ptxdesc->data_ratefb_lmt = 0x1F; - ptxdesc->rts_ratefb_lmt = 0xF; - - /* use REG_INIDATA_RATE_SEL value */ - ptxdesc->datarate = - pdmpriv->INIDATA_RATE[pattrib->mac_id]; - - } else { - /* EAP data packet and ARP packet. */ - /* Use the 1M data rate to send the EAP/ARP packet. */ - /* This will maybe make the handshake smooth. */ - - ptxdesc->bk = 1; /* AGG BK */ - ptxdesc->userate = 1; /* driver uses rate */ - if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT) - ptxdesc->data_short = 1; - ptxdesc->datarate = MRateToHwRate23a(pmlmeext->tx_rate); - } - } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) { -/* RT_TRACE(_module_hal_xmit_c_, _drv_notice_, - ("%s: MGNT_FRAMETAG\n", __func__)); */ - - ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */ - ptxdesc->qsel = pattrib->qsel; - ptxdesc->rate_id = pattrib->raid; /* Rate ID */ - ptxdesc->seq = pattrib->seqnum; - ptxdesc->userate = 1; /* driver uses rate, 1M */ - ptxdesc->rty_lmt_en = 1; /* retry limit enable */ - ptxdesc->data_rt_lmt = 6; /* retry limit = 6 */ - - /* CCX-TXRPT ack for xmit mgmt frames. */ - if (pxmitframe->ack_report) - ptxdesc->ccx = 1; - - ptxdesc->datarate = MRateToHwRate23a(pmlmeext->tx_rate); - } else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) { - RT_TRACE(_module_hal_xmit_c_, _drv_warning_, - ("%s: TXAGG_FRAMETAG\n", __func__)); - } else { - RT_TRACE(_module_hal_xmit_c_, _drv_warning_, - ("%s: frame_tag = 0x%x\n", __func__, - pxmitframe->frame_tag)); - - ptxdesc->macid = 4; /* CAM_ID(MAC_ID) */ - ptxdesc->rate_id = 6; /* Rate ID */ - ptxdesc->seq = pattrib->seqnum; - ptxdesc->userate = 1; /* driver uses rate */ - ptxdesc->datarate = MRateToHwRate23a(pmlmeext->tx_rate); - } - - ptxdesc->pktlen = pattrib->last_txcmdsz; - ptxdesc->offset = TXDESC_SIZE + OFFSET_SZ; - if (bmcst) - ptxdesc->bmc = 1; - ptxdesc->ls = 1; - ptxdesc->fs = 1; - ptxdesc->own = 1; - - /* 2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */ - /* (1) The sequence number of each non-Qos frame / broadcast / - * multicast / mgnt frame should be controled by Hw because Fw - * will also send null data which we cannot control when Fw LPS enable. - * --> default enable non-Qos data sequense number. - 2010.06.23. by tynli. */ - /* (2) Enable HW SEQ control for beacon packet, - * because we use Hw beacon. */ - /* (3) Use HW Qos SEQ to control the seq num of Ext port - * non-Qos packets. */ - /* 2010.06.23. Added by tynli. */ - if (!pattrib->qos_en) { - /* Hw set sequence number */ - ptxdesc->hwseq_en = 1; /* HWSEQ_EN */ - ptxdesc->hwseq_sel = 0; /* HWSEQ_SEL */ - } -} - -/* - * Description: - * - * Parameters: - * pxmitframe xmitframe - * pbuf where to fill tx desc - */ -void rtl8723a_update_txdesc(struct xmit_frame *pxmitframe, u8 *pbuf) -{ - struct tx_desc *pdesc; - - pdesc = (struct tx_desc *)pbuf; - memset(pdesc, 0, sizeof(struct tx_desc)); - - rtl8723a_fill_default_txdesc(pxmitframe, pbuf); - - pdesc->txdw0 = cpu_to_le32(pdesc->txdw0); - pdesc->txdw1 = cpu_to_le32(pdesc->txdw1); - pdesc->txdw2 = cpu_to_le32(pdesc->txdw2); - pdesc->txdw3 = cpu_to_le32(pdesc->txdw3); - pdesc->txdw4 = cpu_to_le32(pdesc->txdw4); - pdesc->txdw5 = cpu_to_le32(pdesc->txdw5); - pdesc->txdw6 = cpu_to_le32(pdesc->txdw6); - pdesc->txdw7 = cpu_to_le32(pdesc->txdw7); - rtl8723a_cal_txdesc_chksum(pdesc); -} - /* * Description: In normal chip, we should send some packet to Hw which * will be used by Fw in FW LPS mode. The function is to fill the Tx diff --git a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h index 815560c6e1d7..7db29f40ab70 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h @@ -212,7 +212,6 @@ struct txrpt_ccx_8723a { #define txrpt_ccx_qtime_8723a(txrpt_ccx) ((txrpt_ccx)->ccx_qtime0+((txrpt_ccx)->ccx_qtime1<<8)) void handle_txrpt_ccx_8723a(struct rtw_adapter *adapter, void *buf); -void rtl8723a_update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem); void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); int rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); -- cgit v1.2.3-59-g8ed1b From 729048268b8b92fc4b2fb2cfe5e6b14ff118bdd6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:45 -0500 Subject: staging: rtl8723au: Remove no-op function Hal_InitChannelPlan23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/hal/usb_halinit.c | 4 ---- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 -- 3 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8196a3315df4..5c143fc8be76 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1954,10 +1954,6 @@ Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, pHalData->EEPROMThermalMeter); } -void Hal_InitChannelPlan23a(struct rtw_adapter *padapter) -{ -} - static void rtl8723a_cal_txdesc_chksum(struct tx_desc *ptxdesc) { u16 *usPtr = (u16 *) ptxdesc; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index adc2953fcaf4..1c7ce85e7838 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1276,10 +1276,6 @@ static void readAdapterInfo(struct rtw_adapter *padapter) pEEPROM->bautoload_fail_flag); Hal_EfuseParseXtal_8723A(padapter, hwinfo, pEEPROM->bautoload_fail_flag); - /* */ - /* The following part initialize some vars by PG info. */ - /* */ - Hal_InitChannelPlan23a(padapter); /* hal_CustomizedBehavior_8723U(Adapter); */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index ee203a572cb7..72af134f74fd 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -518,8 +518,6 @@ void Hal_EfuseParseRateIndicationOption(struct rtw_adapter *padapter, u8 *hwinfo void Hal_EfuseParseXtal_8723A(struct rtw_adapter *pAdapter, u8 *hwinfo, u8 AutoLoadFail); void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, bool AutoLoadFail); -void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); - /* register */ void SetBcnCtrlReg23a(struct rtw_adapter *padapter, u8 SetBits, u8 ClearBits); void rtl8723a_InitBeaconParameters(struct rtw_adapter *padapter); -- cgit v1.2.3-59-g8ed1b From b518cb97b84f56108bc42d69dce8fc3478880829 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 10 Nov 2014 18:11:46 -0500 Subject: staging: rtl8723au: Remove sw led handling The rtl8723au relies on hw led support, so no point carrying a large unused sw led infrastructure around. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 2 - drivers/staging/rtl8723au/core/rtw_cmd.c | 6 - drivers/staging/rtl8723au/core/rtw_led.c | 1865 ---------------------- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 - drivers/staging/rtl8723au/core/rtw_recv.c | 3 - drivers/staging/rtl8723au/core/rtw_xmit.c | 2 - drivers/staging/rtl8723au/hal/rtl8723au_led.c | 124 -- drivers/staging/rtl8723au/hal/usb_halinit.c | 18 - drivers/staging/rtl8723au/include/drv_types.h | 2 - drivers/staging/rtl8723au/include/rtl8723a_led.h | 30 - drivers/staging/rtl8723au/include/rtw_cmd.h | 1 - drivers/staging/rtl8723au/include/rtw_led.h | 181 --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 11 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 - 14 files changed, 2252 deletions(-) delete mode 100644 drivers/staging/rtl8723au/core/rtw_led.c delete mode 100644 drivers/staging/rtl8723au/hal/rtl8723au_led.c delete mode 100644 drivers/staging/rtl8723au/include/rtl8723a_led.h delete mode 100644 drivers/staging/rtl8723au/include/rtw_led.h diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index a9aae2163639..b184108680eb 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -2,7 +2,6 @@ r8723au-y := \ core/rtw_cmd.o \ core/rtw_efuse.o \ core/rtw_ieee80211.o \ - core/rtw_led.o \ core/rtw_mlme.o \ core/rtw_mlme_ext.o \ core/rtw_pwrctrl.o \ @@ -34,7 +33,6 @@ r8723au-y := \ hal/rtl8723a_rxdesc.o \ hal/rtl8723a_sreset.o \ hal/rtl8723a_xmit.o \ - hal/rtl8723au_led.o \ hal/rtl8723au_recv.o \ hal/rtl8723au_xmit.o \ hal/usb_halinit.o \ diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 44eae8e6bd9d..77d43a5960a1 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -391,8 +391,6 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, mod_timer(&pmlmepriv->scan_to_timer, jiffies + msecs_to_jiffies(SCANNING_TIMEOUT)); - rtw_led_control(padapter, LED_CTL_SITE_SURVEY); - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ } else _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); @@ -417,8 +415,6 @@ int rtw_createbss_cmd23a(struct rtw_adapter *padapter) pdev_network = &padapter->registrypriv.dev_network; - rtw_led_control(padapter, LED_CTL_START_TO_LINK); - if (pmlmepriv->assoc_ssid.ssid_len == 0) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", @@ -467,8 +463,6 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, ifmode = pnetwork->network.ifmode; - rtw_led_control(padapter, LED_CTL_START_TO_LINK); - if (pmlmepriv->assoc_ssid.ssid_len == 0) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n")); diff --git a/drivers/staging/rtl8723au/core/rtw_led.c b/drivers/staging/rtl8723au/core/rtw_led.c deleted file mode 100644 index 92ab1f8ded96..000000000000 --- a/drivers/staging/rtl8723au/core/rtw_led.c +++ /dev/null @@ -1,1865 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - ******************************************************************************/ - -#include -#include - -/* */ -/* Description: */ -/* Callback function of LED BlinkTimer, */ -/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl23a */ -/* */ -static void BlinkTimerCallback(unsigned long data) -{ - struct led_8723a *pLed = (struct led_8723a *)data; - struct rtw_adapter *padapter = pLed->padapter; - - /* DBG_8723A("%s\n", __func__); */ - - if ((padapter->bSurpriseRemoved == true) || (padapter->bDriverStopped == true)) - { - /* DBG_8723A("%s bSurpriseRemoved:%d, bDriverStopped:%d\n", __func__, padapter->bSurpriseRemoved, padapter->bDriverStopped); */ - return; - } - schedule_work(&pLed->BlinkWorkItem); -} - -/* */ -/* Description: */ -/* Callback function of LED BlinkWorkItem. */ -/* We dispatch acture LED blink action according to LedStrategy. */ -/* */ -void BlinkWorkItemCallback23a(struct work_struct *work) -{ - struct led_8723a *pLed = container_of(work, struct led_8723a, BlinkWorkItem); - - BlinkHandler23a(pLed); -} - -/* */ -/* Description: */ -/* Reset status of led_8723a object. */ -/* */ -void ResetLedStatus23a(struct led_8723a *pLed) -{ - - pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ - pLed->bLedOn = false; /* true if LED is ON, false if LED is OFF. */ - - pLed->bLedBlinkInProgress = false; /* true if it is blinking, false o.w.. */ - pLed->bLedWPSBlinkInProgress = false; - - pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */ - pLed->BlinkingLedState = LED_UNKNOWN; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */ - - pLed->bLedNoLinkBlinkInProgress = false; - pLed->bLedLinkBlinkInProgress = false; - pLed->bLedStartToLinkBlinkInProgress = false; - pLed->bLedScanBlinkInProgress = false; -} - - /* */ -/* Description: */ -/* Initialize an led_8723a object. */ -/* */ -void -InitLed871x23a(struct rtw_adapter *padapter, struct led_8723a *pLed, enum led_pin_8723a LedPin) -{ - pLed->padapter = padapter; - pLed->LedPin = LedPin; - - ResetLedStatus23a(pLed); - - setup_timer(&pLed->BlinkTimer, BlinkTimerCallback, (unsigned long)pLed); - - INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback23a); -} - -/* */ -/* Description: */ -/* DeInitialize an led_8723a object. */ -/* */ -void -DeInitLed871x23a(struct led_8723a *pLed) -{ - cancel_work_sync(&pLed->BlinkWorkItem); - del_timer_sync(&pLed->BlinkTimer); - ResetLedStatus23a(pLed); -} - -/* Description: */ -/* Implementation of LED blinking behavior. */ -/* It toggle off LED and schedule corresponding timer if necessary. */ - -static void SwLedBlink(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - /* Determine if we shall change LED state again. */ - pLed->BlinkTimes--; - switch (pLed->CurrLedState) { - - case LED_BLINK_NORMAL: - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - case LED_BLINK_StartToBlink: - if (check_fwstate(pmlmepriv, _FW_LINKED) && - check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - bStopBlinking = true; - if (check_fwstate(pmlmepriv, _FW_LINKED) && - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) - bStopBlinking = true; - else if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - case LED_BLINK_WPS: - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - default: - bStopBlinking = true; - break; - } - - if (bStopBlinking) { - if ((check_fwstate(pmlmepriv, _FW_LINKED)) && !pLed->bLedOn) - SwLedOn23a(padapter, pLed); - else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) - SwLedOff23a(padapter, pLed); - - pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = false; - } else { - /* Assign LED state to toggle. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - /* Schedule a timer to toggle LED state. */ - switch (pLed->CurrLedState) { - case LED_BLINK_NORMAL: - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL)); - break; - case LED_BLINK_SLOWLY: - case LED_BLINK_StartToBlink: - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL)); - break; - case LED_BLINK_WPS: - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_LONG_INTERVAL)); - break; - default: - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL)); - break; - } - } -} - -static void SwLedBlink1(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long delay = 0; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - ResetLedStatus23a(pLed); - return; - } - switch (pLed->CurrLedState) { - case LED_BLINK_SLOWLY: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - break; - case LED_BLINK_NORMAL: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_LINK_INTERVAL_ALPHA; - break; - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_LINK_INTERVAL_ALPHA; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_LINK_INTERVAL_ALPHA; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = false; - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - break; - case LED_BLINK_WPS: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - break; - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) - bStopBlinking = false; - else - bStopBlinking = true; - if (bStopBlinking) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_LINK_INTERVAL_ALPHA; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - - pLed->bLedWPSBlinkInProgress = false; - } else { - pLed->BlinkingLedState = RTW_LED_OFF; - delay = LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA; - } - break; - default: - break; - } - if (delay) - mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(delay)); -} - -static void SwLedBlink2(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("stop scan blink CurrLedState %d\n", - pLed->CurrLedState)); - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("stop scan blink CurrLedState %d\n", - pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("stop CurrLedState %d\n", pLed->CurrLedState)); - - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("stop CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA)); - } - } - break; - default: - break; - } -} - -static void SwLedBlink3(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - if (pLed->CurrLedState != LED_BLINK_WPS_STOP) - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - bStopBlinking = true; - } - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff23a(padapter, pLed); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - SwLedOn23a(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff23a(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - } - } - break; - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - bStopBlinking = true; - } - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff23a(padapter, pLed); - } else if (check_fwstate(pmlmepriv, - _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - - if (!pLed->bLedOn) - SwLedOn23a(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedOn) - SwLedOff23a(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA)); - } - } - break; - - case LED_BLINK_WPS: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - break; - - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - pLed->BlinkingLedState = RTW_LED_OFF; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA)); - bStopBlinking = false; - } else { - bStopBlinking = true; - } - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff23a(padapter, pLed); - } - else - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedWPSBlinkInProgress = false; - } - break; - - default: - break; - } -} - -static void SwLedBlink4(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &padapter->ledpriv; - struct led_8723a *pLed1 = &ledpriv->SwLed1; - u8 bStopBlinking = false; - unsigned long delay = 0; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) - { - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - SwLedOff23a(padapter, pLed1); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SLOWLY: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - break; - - case LED_BLINK_StartToBlink: - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - delay = LED_BLINK_SLOWLY_INTERVAL; - } else { - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NORMAL_INTERVAL; - } - break; - - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - bStopBlinking = false; - } - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff23a(padapter, pLed); - } else { - pLed->bLedNoLinkBlinkInProgress = false; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - } - break; - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - bStopBlinking = true; - } - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff23a(padapter, pLed); - } else { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - } - break; - - case LED_BLINK_WPS: - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - delay = LED_BLINK_SLOWLY_INTERVAL; - } else { - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NORMAL_INTERVAL; - } - break; - - case LED_BLINK_WPS_STOP: /* WPS authentication fail */ - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - delay = LED_BLINK_NORMAL_INTERVAL; - break; - - case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - if (pLed->bLedOn) { - pLed->BlinkTimes = 1; - } else { - bStopBlinking = true; - } - } - - if (bStopBlinking) { - pLed->BlinkTimes = 10; - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_LINK_INTERVAL_ALPHA; - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - delay = LED_BLINK_NORMAL_INTERVAL; - } - break; - - default: - break; - } - if (delay) - mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(delay)); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); -} - -static void SwLedBlink5(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - u8 bStopBlinking = false; - unsigned long delay = 0; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - bStopBlinking = true; - } - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff23a(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - } - break; - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - bStopBlinking = true; - } - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff23a(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff23a(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - } - break; - - default: - break; - } - - if (delay) - mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(delay)); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); -} - -static void SwLedBlink6(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff23a(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); -} - -/* ALPHA, added by chiyoko, 20090106 */ -static void -SwLedControlMode1(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct led_8723a *pLed = &ledpriv->SwLed0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - long delay = -1; - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (pLed->bLedNoLinkBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - } - break; - - case LED_CTL_LINK: - if (pLed->bLedLinkBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_LINK_INTERVAL_ALPHA; - } - break; - - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic && - check_fwstate(pmlmepriv, _FW_LINKED)) - ; - else if (pLed->bLedScanBlinkInProgress == false) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - break; - - case LED_CTL_STOP_WPS: - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - } else { - pLed->bLedWPSBlinkInProgress = true; - } - - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - delay = LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA; - } else { - pLed->BlinkingLedState = RTW_LED_ON; - delay = 0; - } - break; - - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_NO_LINK_INTERVAL_ALPHA; - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - - SwLedOff23a(padapter, pLed); - break; - - default: - break; - - } - - if (delay != -1) - mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(delay)); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ -static void -SwLedControlMode2(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct led_8723a *pLed = &ledpriv->SwLed0; - long delay = -1; - - switch (LedAction) { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) - ; - else if (pLed->bLedScanBlinkInProgress == false) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false && - check_fwstate(pmlmepriv, _FW_LINKED)) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - break; - case LED_CTL_LINK: - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - - delay = 0; - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - delay = 0; - } - break; - case LED_CTL_STOP_WPS: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - delay = 0; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - break; - case LED_CTL_STOP_WPS_FAIL: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff23a(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - delay = 0; - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - break; - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - delay = 0; - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - delay = 0; - break; - default: - break; - - } - - if (delay != -1) - mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(delay)); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); -} - - /* COREGA, added by chiyoko, 20090316 */ -static void -SwLedControlMode3(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct led_8723a *pLed = &ledpriv->SwLed0; - long delay = -1; - - switch (LedAction) { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) - ; - else if (pLed->bLedScanBlinkInProgress == false) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false && - check_fwstate(pmlmepriv, _FW_LINKED)) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_FASTER_INTERVAL_ALPHA; - } - break; - - case LED_CTL_LINK: - if (IS_LED_WPS_BLINKING(pLed)) - return; - - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - - delay = 0; - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - delay = LED_BLINK_SCAN_INTERVAL_ALPHA; - } - break; - - case LED_CTL_STOP_WPS: - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } else { - pLed->bLedWPSBlinkInProgress = true; - } - - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - delay = LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA; - } else { - pLed->BlinkingLedState = RTW_LED_ON; - delay = 0; - } - - break; - - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - delay = 0; - break; - - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - delay = 0; - } - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - delay = 0; - break; - - default: - break; - - } - - if (delay != -1) - mod_timer(&pLed->BlinkTimer, jiffies + msecs_to_jiffies(delay)); - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); -} - - /* Edimax-Belkin, added by chiyoko, 20090413 */ -static void -SwLedControlMode4(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct led_8723a *pLed = &ledpriv->SwLed0; - struct led_8723a *pLed1 = &ledpriv->SwLed1; - - switch (LedAction) { - case LED_CTL_START_TO_LINK: - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - del_timer_sync(&pLed1->BlinkTimer); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - mod_timer(&pLed->BlinkTimer, jiffies); - } - - if (pLed->bLedStartToLinkBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - - pLed->bLedStartToLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_StartToBlink; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL)); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL)); - } - } - break; - - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - /* LED1 settings */ - if (LedAction == LED_CTL_LINK) { - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - del_timer_sync(&pLed1->BlinkTimer); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - mod_timer(&pLed->BlinkTimer, jiffies); - } - } - - if (pLed->bLedNoLinkBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - } - break; - - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic && - check_fwstate(pmlmepriv, _FW_LINKED)) - ; - else if (pLed->bLedScanBlinkInProgress == false) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) { - return; - } - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA)); - } - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - del_timer_sync(&pLed1->BlinkTimer); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - mod_timer(&pLed->BlinkTimer, jiffies); - } - - if (pLed->bLedWPSBlinkInProgress == false) { - if (pLed->bLedNoLinkBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL)); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL)); - } - } - break; - - case LED_CTL_STOP_WPS: /* WPS connect success */ - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - break; - - case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - del_timer_sync(&pLed1->BlinkTimer); - else - pLed1->bLedWPSBlinkInProgress = true; - - pLed1->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed1->bLedOn) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL)); - - break; - - case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - del_timer_sync(&pLed1->BlinkTimer); - else - pLed1->bLedWPSBlinkInProgress = true; - - pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; - pLed1->BlinkTimes = 10; - if (pLed1->bLedOn) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL)); - - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedStartToLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedStartToLinkBlinkInProgress = false; - } - - if (pLed1->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed1->BlinkTimer); - pLed1->bLedWPSBlinkInProgress = false; - } - - pLed1->BlinkingLedState = LED_UNKNOWN; - SwLedOff23a(padapter, pLed); - SwLedOff23a(padapter, pLed1); - break; - - default: - break; - - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - /* Sercomm-Belkin, added by chiyoko, 20090415 */ -static void -SwLedControlMode5(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct led_8723a *pLed = &ledpriv->SwLed0; - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_NO_LINK: - case LED_CTL_LINK: /* solid blue */ - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - - mod_timer(&pLed->BlinkTimer, jiffies); - break; - - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic && - check_fwstate(pmlmepriv, _FW_LINKED)) - ; - else if (pLed->bLedScanBlinkInProgress == false) { - if (pLed->bLedBlinkInProgress == true) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress == false) { - if (pLed->CurrLedState == LED_BLINK_SCAN) { - return; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA)); - } - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - - SwLedOff23a(padapter, pLed); - break; - - default: - break; - - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - /* WNC-Corega, added by chiyoko, 20090902 */ -static void SwLedControlMode6(struct rtw_adapter *padapter, - enum led_ctl_mode LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct led_8723a *pLed0 = &ledpriv->SwLed0; - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - del_timer_sync(&pLed0->BlinkTimer); - pLed0->CurrLedState = RTW_LED_ON; - pLed0->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed0->BlinkTimer, jiffies); - break; - case LED_CTL_POWER_OFF: - SwLedOff23a(padapter, pLed0); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); -} - -/* */ -/* Description: */ -/* Handler function of LED Blinking. */ -/* We dispatch acture LED blink action according to LedStrategy. */ -/* */ -void BlinkHandler23a(struct led_8723a *pLed) -{ - struct rtw_adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &padapter->ledpriv; - - /* DBG_8723A("%s (%s:%d)\n", __func__, current->comm, current->pid); */ - - if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) - return; - - switch (ledpriv->LedStrategy) { - case SW_LED_MODE0: - SwLedBlink(pLed); - break; - case SW_LED_MODE1: - SwLedBlink1(pLed); - break; - case SW_LED_MODE2: - SwLedBlink2(pLed); - break; - case SW_LED_MODE3: - SwLedBlink3(pLed); - break; - case SW_LED_MODE4: - SwLedBlink4(pLed); - break; - case SW_LED_MODE5: - SwLedBlink5(pLed); - break; - case SW_LED_MODE6: - SwLedBlink6(pLed); - break; - default: - break; - } -} - -void -LedControl871x23a(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) { - struct led_priv *ledpriv = &padapter->ledpriv; - - if ((padapter->bSurpriseRemoved == true) || - (padapter->bDriverStopped == true) || - (padapter->hw_init_completed == false)) { - return; - } - - if (ledpriv->bRegUseLed == false) - return; - - /* if (!priv->up) */ - /* return; */ - - /* if (priv->bInHctTest) */ - /* return; */ - - if ((padapter->pwrctrlpriv.rf_pwrstate != rf_on && - padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) && - (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || - LedAction == LED_CTL_SITE_SURVEY || - LedAction == LED_CTL_LINK || - LedAction == LED_CTL_NO_LINK || - LedAction == LED_CTL_POWER_ON)) { - return; - } - - switch (ledpriv->LedStrategy) { - case SW_LED_MODE0: - break; - case SW_LED_MODE1: - SwLedControlMode1(padapter, LedAction); - break; - case SW_LED_MODE2: - SwLedControlMode2(padapter, LedAction); - break; - case SW_LED_MODE3: - SwLedControlMode3(padapter, LedAction); - break; - case SW_LED_MODE4: - SwLedControlMode4(padapter, LedAction); - break; - case SW_LED_MODE5: - SwLedControlMode5(padapter, LedAction); - break; - case SW_LED_MODE6: - SwLedControlMode6(padapter, LedAction); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("LedStrategy:%d, LedAction %d\n", ledpriv->LedStrategy, LedAction)); -} diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 85d1eca5af8b..95bed7a98003 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -815,8 +815,6 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter) if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_LINK); - rtw_cfg80211_indicate_connect(padapter); netif_carrier_on(padapter->pnetdev); @@ -861,10 +859,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) _clr_fwstate_(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_clear_scan_deny(padapter); - } rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 9d6539325839..8dd35133be94 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1495,7 +1495,6 @@ static int validate_recv_frame(struct rtw_adapter *adapter, retval = _FAIL; /* only data frame return _SUCCESS */ break; case IEEE80211_FTYPE_DATA: - rtw_led_control(adapter, LED_CTL_RX); pattrib->qos = (subtype & IEEE80211_STYPE_QOS_DATA) ? 1 : 0; retval = validate_recv_data_frame(adapter, precv_frame); if (retval == _FAIL) { @@ -2206,8 +2205,6 @@ static int recv_func_posthandle(struct rtw_adapter *padapter, struct recv_priv *precvpriv = &padapter->recvpriv; /* DATA FRAME */ - rtw_led_control(padapter, LED_CTL_RX); - prframe = decryptor(padapter, prframe); if (prframe == NULL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 1f4ebb36f653..c79d5b900594 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1901,8 +1901,6 @@ int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb) } pxmitframe->pkt = skb; - rtw_led_control(padapter, LED_CTL_TX); - do_queue_select(padapter, &pxmitframe->attrib); #ifdef CONFIG_8723AU_AP_MODE diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_led.c b/drivers/staging/rtl8723au/hal/rtl8723au_led.c deleted file mode 100644 index b946636af9b3..000000000000 --- a/drivers/staging/rtl8723au/hal/rtl8723au_led.c +++ /dev/null @@ -1,124 +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. - * - ******************************************************************************/ - -#include "drv_types.h" -#include "rtl8723a_hal.h" -#include "rtl8723a_led.h" -#include "usb_ops_linux.h" - -/* */ -/* LED object. */ -/* */ - -/* */ -/* Prototype of protected function. */ -/* */ - -/* */ -/* LED_819xUsb routines. */ -/* */ - -/* Description: */ -/* Turn on LED according to LedPin specified. */ -void SwLedOn23a(struct rtw_adapter *padapter, struct led_8723a *pLed) -{ - u8 LedCfg = 0; - - if ((padapter->bSurpriseRemoved == true) || (padapter->bDriverStopped == true)) - return; - switch (pLed->LedPin) { - case LED_PIN_GPIO0: - break; - case LED_PIN_LED0: - /* SW control led0 on. */ - rtl8723au_write8(padapter, REG_LEDCFG0, - (LedCfg&0xf0)|BIT(5)|BIT(6)); - break; - case LED_PIN_LED1: - /* SW control led1 on. */ - rtl8723au_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(6)); - break; - case LED_PIN_LED2: - LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2); - /* SW control led1 on. */ - rtl8723au_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(5)); - break; - default: - break; - } - pLed->bLedOn = true; -} - -/* Description: */ -/* Turn off LED according to LedPin specified. */ -void SwLedOff23a(struct rtw_adapter *padapter, struct led_8723a *pLed) -{ - u8 LedCfg = 0; - /* struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); */ - - if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) - goto exit; - - switch (pLed->LedPin) { - case LED_PIN_GPIO0: - break; - case LED_PIN_LED0: - /* SW control led0 on. */ - rtl8723au_write8(padapter, REG_LEDCFG0, - (LedCfg&0xf0)|BIT(5)|BIT(6)); - break; - case LED_PIN_LED1: - /* SW control led1 on. */ - rtl8723au_write8(padapter, REG_LEDCFG1, - (LedCfg&0x00)|BIT(5)|BIT(6)); - break; - case LED_PIN_LED2: - LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2); - /* SW control led1 on. */ - rtl8723au_write8(padapter, REG_LEDCFG2, - (LedCfg&0x80)|BIT(3)|BIT(5)); - break; - default: - break; - } -exit: - pLed->bLedOn = false; -} - -/* Interface to manipulate LED objects. */ - -/* Description: */ -/* Initialize all LED_871x objects. */ -void -rtl8723au_InitSwLeds(struct rtw_adapter *padapter) -{ - struct led_priv *pledpriv = &padapter->ledpriv; - - pledpriv->LedControlHandler = LedControl871x23a; - /* 8723as-vau wifi used led2 */ - InitLed871x23a(padapter, &pledpriv->SwLed0, LED_PIN_LED2); - -/* InitLed871x23a(padapter,&pledpriv->SwLed1, LED_PIN_LED2); */ -} - -/* Description: */ -/* DeInitialize all LED_819xUsb objects. */ -void -rtl8723au_DeInitSwLeds(struct rtw_adapter *padapter) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - - DeInitLed871x23a(&ledpriv->SwLed0); -} diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 1c7ce85e7838..ead676f8b684 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -444,14 +443,6 @@ static void _InitEDCA(struct rtw_adapter *Adapter) static void _InitHWLed(struct rtw_adapter *Adapter) { - struct led_priv *pledpriv = &Adapter->ledpriv; - - if (pledpriv->LedStrategy != HW_LED) - return; - -/* HW led control */ -/* to do .... */ -/* must consider cases of antenna diversity/ commbo card/solo card/mini card */ } static void _InitRDGSetting(struct rtw_adapter *Adapter) @@ -1209,14 +1200,6 @@ static void _ReadBoardType(struct rtw_adapter *Adapter, u8 *PROMContent, pHalData->ExternalPA = 1; } -static void _ReadLEDSetting(struct rtw_adapter *Adapter, u8 *PROMContent, - bool AutoloadFail) -{ - struct led_priv *pledpriv = &Adapter->ledpriv; - - pledpriv->LedStrategy = HW_LED; -} - static void Hal_EfuseParseMACAddr_8723AU(struct rtw_adapter *padapter, u8 *hwinfo, bool AutoLoadFail) { @@ -1263,7 +1246,6 @@ static void readAdapterInfo(struct rtw_adapter *padapter) pEEPROM->bautoload_fail_flag); Hal_EfuseParseThermalMeter_8723A(padapter, hwinfo, pEEPROM->bautoload_fail_flag); - _ReadLEDSetting(padapter, hwinfo, pEEPROM->bautoload_fail_flag); /* _ReadRFSetting(Adapter, PROMContent, pEEPROM->bautoload_fail_flag); */ /* _ReadPSSetting(Adapter, PROMContent, pEEPROM->bautoload_fail_flag); */ Hal_EfuseParseAntennaDiversity(padapter, hwinfo, diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 9870f87bdc70..e83463aeb9b1 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -51,7 +51,6 @@ enum _NIC_VERSION { #include #include #include -#include #include #include @@ -228,7 +227,6 @@ struct rtw_adapter { struct registry_priv registrypriv; struct pwrctrl_priv pwrctrlpriv; struct eeprom_priv eeprompriv; - struct led_priv ledpriv; u32 setband; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_led.h b/drivers/staging/rtl8723au/include/rtl8723a_led.h deleted file mode 100644 index 1623d186feb4..000000000000 --- a/drivers/staging/rtl8723au/include/rtl8723a_led.h +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - ******************************************************************************/ -#ifndef __RTL8723A_LED_H__ -#define __RTL8723A_LED_H__ - -#include -#include - - -/* */ -/* Interface to manipulate LED objects. */ -/* */ -void rtl8723au_InitSwLeds(struct rtw_adapter *padapter); -void rtl8723au_DeInitSwLeds(struct rtw_adapter *padapter); -void SwLedOn23a(struct rtw_adapter *padapter, struct led_8723a * pLed); -void SwLedOff23a(struct rtw_adapter *padapter, struct led_8723a * pLed); - -#endif diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 8ffe5def3d4d..71044107d13b 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -17,7 +17,6 @@ #include #include -#include #define C2H_MEM_SZ (16*1024) diff --git a/drivers/staging/rtl8723au/include/rtw_led.h b/drivers/staging/rtl8723au/include/rtw_led.h deleted file mode 100644 index c071da587efd..000000000000 --- a/drivers/staging/rtl8723au/include/rtw_led.h +++ /dev/null @@ -1,181 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - ******************************************************************************/ -#ifndef __RTW_LED_H_ -#define __RTW_LED_H_ - -#include -#include - -#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) - -#define LED_BLINK_NORMAL_INTERVAL 100 -#define LED_BLINK_SLOWLY_INTERVAL 200 -#define LED_BLINK_LONG_INTERVAL 400 - -#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000 -#define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ -#define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ -#define LED_BLINK_FASTER_INTERVAL_ALPHA 50 -#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 - -#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100 -#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000 - -#define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000 -#define LED_BLINK_NORMAL_INTERVAL_PORNET 100 - -#define LED_BLINK_FAST_INTERVAL_BITLAND 30 - -/* 060403, rcnjko: Customized for AzWave. */ -#define LED_CM2_BLINK_ON_INTERVAL 250 -#define LED_CM2_BLINK_OFF_INTERVAL 4750 - -#define LED_CM8_BLINK_INTERVAL 500 /* for QMI */ -#define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */ - -/* 080124, lanhsin: Customized for RunTop */ -#define LED_RunTop_BLINK_INTERVAL 300 - -/* 060421, rcnjko: Customized for Sercomm Printer Server case. */ -#define LED_CM3_BLINK_INTERVAL 1500 - -enum led_ctl_mode { - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7, - LED_CTL_START_TO_LINK = 8, - LED_CTL_START_WPS = 9, - LED_CTL_STOP_WPS = 10, - LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */ - LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */ - LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */ - LED_CTL_CONNECTION_NO_TRANSFER = 14, -}; - -enum led_state_872x { - LED_UNKNOWN = 0, - RTW_LED_ON = 1, - RTW_LED_OFF = 2, - LED_BLINK_NORMAL = 3, - LED_BLINK_SLOWLY = 4, - LED_BLINK_POWER_ON = 5, - LED_BLINK_SCAN = 6, /* LED is blinking during scanning period, the # of times to blink is depend on time for scanning. */ - LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */ - LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer Server case */ - LED_BLINK_TXRX = 9, - LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */ - LED_BLINK_WPS_STOP = 11, /* for ALPHA */ - LED_BLINK_WPS_STOP_OVERLAP = 12, /* for BELKIN */ - LED_BLINK_RUNTOP = 13, /* Customized for RunTop */ - LED_BLINK_CAMEO = 14, - LED_BLINK_XAVI = 15, - LED_BLINK_ALWAYS_ON = 16, -}; - -enum led_pin_8723a { - LED_PIN_NULL = 0, - LED_PIN_LED0 = 1, - LED_PIN_LED1 = 2, - LED_PIN_LED2 = 3, - LED_PIN_GPIO0 = 4, -}; - -struct led_8723a { - struct rtw_adapter *padapter; - - enum led_pin_8723a LedPin; /* Identify how to implement this SW led. */ - enum led_state_872x CurrLedState; /* Current LED state. */ - enum led_state_872x BlinkingLedState; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */ - - u8 bLedOn; /* true if LED is ON, false if LED is OFF. */ - - u8 bLedBlinkInProgress; /* true if it is blinking, false o.w.. */ - - u8 bLedWPSBlinkInProgress; - - u32 BlinkTimes; /* Number of times to toggle led state for blinking. */ - - struct timer_list BlinkTimer; /* Timer object for led blinking. */ - - u8 bSWLedCtrl; - - /* ALPHA, added by chiyoko, 20090106 */ - u8 bLedNoLinkBlinkInProgress; - u8 bLedLinkBlinkInProgress; - u8 bLedStartToLinkBlinkInProgress; - u8 bLedScanBlinkInProgress; - - struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to manipulate H/W to blink LED. */ -}; - -#define IS_LED_WPS_BLINKING(_LED_871x) (((struct led_8723a *)_LED_871x)->CurrLedState==LED_BLINK_WPS \ - || ((struct led_8723a *)_LED_871x)->CurrLedState==LED_BLINK_WPS_STOP \ - || ((struct led_8723a *)_LED_871x)->bLedWPSBlinkInProgress) - -#define IS_LED_BLINKING(_LED_871x) (((struct led_8723a *)_LED_871x)->bLedWPSBlinkInProgress \ - ||((struct led_8723a *)_LED_871x)->bLedScanBlinkInProgress) - -/* */ -/* LED customization. */ -/* */ - -enum led_strategy_8723a { - SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option. */ - SW_LED_MODE1= 1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */ - SW_LED_MODE2 = 2, /* SW control 1 LED via GPIO0, customized for AzWave 8187 minicard. */ - SW_LED_MODE3 = 3, /* SW control 1 LED via GPIO0, customized for Sercomm Printer Server case. */ - SW_LED_MODE4 = 4, /* for Edimax / Belkin */ - SW_LED_MODE5 = 5, /* for Sercomm / Belkin */ - SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */ - HW_LED = 50, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes, see MAC.CONFIG1 for details.) */ - LED_ST_NONE = 99, -}; - -void LedControl871x23a(struct rtw_adapter *padapter, enum led_ctl_mode LedAction); - -struct led_priv{ - /* add for led controll */ - struct led_8723a SwLed0; - struct led_8723a SwLed1; - enum led_strategy_8723a LedStrategy; - u8 bRegUseLed; - void (*LedControlHandler)(struct rtw_adapter *padapter, enum led_ctl_mode LedAction); - /* add for led controll */ -}; - -#define rtw_led_control(adapter, LedAction) - -void BlinkWorkItemCallback23a(struct work_struct *work); - -void ResetLedStatus23a(struct led_8723a *pLed); - -void -InitLed871x23a( - struct rtw_adapter *padapter, - struct led_8723a *pLed, - enum led_pin_8723a LedPin -); - -void -DeInitLed871x23a(struct led_8723a *pLed); - -/* hal... */ -void BlinkHandler23a(struct led_8723a *pLed); - -#endif /* __RTW_LED_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index d00100356630..9966d16342b3 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -542,9 +542,6 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("%s:cancel dynamic_chk_timer!\n", __func__)); - RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("%s:cancel DeInitSwLeds!\n", __func__)); - del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer); del_timer_sync(&padapter->mlmepriv.set_scan_deny_timer); @@ -681,8 +678,6 @@ int netdev_open23a(struct net_device *pnetdev) rtw_cfg80211_init_wiphy(padapter); - rtw_led_control(padapter, LED_CTL_NO_LINK); - padapter->bup = true; } padapter->net_closed = false; @@ -764,8 +759,6 @@ int rtw_ips_pwr_up23a(struct rtw_adapter *padapter) result = ips_netdrv_open(padapter); - rtw_led_control(padapter, LED_CTL_NO_LINK); - DBG_8723A("<=== rtw_ips_pwr_up23a.............. in %dms\n", jiffies_to_msecs(jiffies - start_time)); return result; @@ -780,8 +773,6 @@ void rtw_ips_pwr_down23a(struct rtw_adapter *padapter) padapter->bCardDisableWOHSM = true; padapter->net_closed = true; - rtw_led_control(padapter, LED_CTL_POWER_OFF); - rtw_ips_dev_unload23a(padapter); padapter->bCardDisableWOHSM = false; DBG_8723A("<=== rtw_ips_pwr_down23a..................... in %dms\n", @@ -840,8 +831,6 @@ static int netdev_close(struct net_device *pnetdev) rtw_free_assoc_resources23a(padapter, 1); /* s2-4. */ rtw_free_network_queue23a(padapter); - /* Close LED */ - rtw_led_control(padapter, LED_CTL_POWER_OFF); } rtw_scan_abort23a(padapter); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 08424d478039..926129e5f0ae 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -307,8 +307,6 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, _FW_LINKED)) { _clr_fwstate_(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_os_indicate_disconnect23a(padapter); /* donnot enqueue cmd */ -- cgit v1.2.3-59-g8ed1b From af13ccf79924fcd4f478b2cbe4bc10baa7c2f31b Mon Sep 17 00:00:00 2001 From: Sanjeev Sharma Date: Tue, 11 Nov 2014 13:24:43 +0530 Subject: staging:rtl8723au: core: Added missing space reported by checkpatch. This is a patch to the rtw_cmd.c file that fixes following Error. ERROR: spaces required around that '>' (ctx:WxV) Signed-off-by: Sanjeev Sharma Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 77d43a5960a1..afb237bf6287 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -954,7 +954,7 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) /* check traffic for powersaving. */ if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || - pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod >2) + pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) bEnterPS = false; else bEnterPS = true; @@ -1148,7 +1148,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) cnt++; - if (cnt>10) + if (cnt > 10) break; val = rtl8723a_chk_hi_queue_empty(padapter); -- cgit v1.2.3-59-g8ed1b From 6b1b4cad86780a716b505988d0b857ce29be4ad7 Mon Sep 17 00:00:00 2001 From: Sanjeev Sharma Date: Tue, 11 Nov 2014 15:28:14 +0530 Subject: staging:rtl8723au: core: Fix checkpatch warning This is a patch to the rtw_cmd.c file that fixes following Warning by introducing temporary structure. WARNING: line over 80 characters Signed-off-by: Sanjeev Sharma Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index afb237bf6287..60e0ded8ae02 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -916,34 +916,34 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) u8 bHigherBusyTxTraffic = false; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int BusyThreshold = 100; + struct rt_link_detect *ldi = &pmlmepriv->LinkDetectInfo; + /* */ /* Determine if our traffic is busy now */ /* */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { if (rtl8723a_BT_coexist(padapter)) BusyThreshold = 50; - else if (pmlmepriv->LinkDetectInfo.bBusyTraffic) + else if (ldi->bBusyTraffic) BusyThreshold = 75; /* if we raise bBusyTraffic in last watchdog, using lower threshold. */ - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) { + if (ldi->NumRxOkInPeriod > BusyThreshold || + ldi->NumTxOkInPeriod > BusyThreshold) { bBusyTraffic = true; - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) + if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod) bRxBusyTraffic = true; else bTxBusyTraffic = true; } /* Higher Tx/Rx data. */ - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) { + if (ldi->NumRxOkInPeriod > 4000 || + ldi->NumTxOkInPeriod > 4000) { bHigherBusyTraffic = true; - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) + if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod) bHigherBusyRxTraffic = true; else bHigherBusyTxTraffic = true; @@ -952,9 +952,9 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) if (!rtl8723a_BT_coexist(padapter) || !rtl8723a_BT_using_antenna_1(padapter)) { /* check traffic for powersaving. */ - if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || - pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) + if (((ldi->NumRxUnicastOkInPeriod + + ldi->NumTxOkInPeriod) > 8) || + ldi->NumRxUnicastOkInPeriod > 2) bEnterPS = false; else bEnterPS = true; @@ -968,15 +968,15 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) } else LPS_Leave23a(padapter); - pmlmepriv->LinkDetectInfo.NumRxOkInPeriod = 0; - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod = 0; - pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - pmlmepriv->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - pmlmepriv->LinkDetectInfo.bTxBusyTraffic = bTxBusyTraffic; - pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic; - pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; - pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; - pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic; + ldi->NumRxOkInPeriod = 0; + ldi->NumTxOkInPeriod = 0; + ldi->NumRxUnicastOkInPeriod = 0; + ldi->bBusyTraffic = bBusyTraffic; + ldi->bTxBusyTraffic = bTxBusyTraffic; + ldi->bRxBusyTraffic = bRxBusyTraffic; + ldi->bHigherBusyTraffic = bHigherBusyTraffic; + ldi->bHigherBusyRxTraffic = bHigherBusyRxTraffic; + ldi->bHigherBusyTxTraffic = bHigherBusyTxTraffic; } static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) -- cgit v1.2.3-59-g8ed1b From 0431f080c52348c0ba1e0d9f55d12df06dc980a8 Mon Sep 17 00:00:00 2001 From: Aleh Suprunovich Date: Mon, 17 Nov 2014 13:22:41 +0300 Subject: staging: rtl8723au: fix sparse warning drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:747:1: warning: symbol 'rtl8723a_EfusePgPacketRead' was not declared. Should it be static? Function 'rtl8723a_EfusePgPacketRead' seems to be unused in current staging code. Before, it was available as 'static s32 Hal_EfusePgPacketRead', but code that was using it removed, in the same commit as rename and signature change to 'bool rtl8723a_EfusePgPacketRead' has taken place. Signed-off-by: Aleh Suprunovich Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 78 ----------------------- 1 file changed, 78 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 5c143fc8be76..044807cf5457 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -743,84 +743,6 @@ u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) return retU2; } -bool -rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) -{ - u8 efuse_data, word_cnts = 0; - u16 efuse_addr = 0; - u8 hoffset = 0, hworden = 0; - u8 i; - u8 max_section = 0; - s32 ret; - - if (data == NULL) - return false; - - EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, - &max_section); - if (offset > max_section) { - DBG_8723A("%s: Packet offset(%d) is illegal(>%d)!\n", - __func__, offset, max_section); - return false; - } - - memset(data, 0xFF, PGPKT_DATA_SIZE); - ret = true; - - /* */ - /* Efuse has been pre-programmed dummy 5Bytes at the - end of Efuse by CP. */ - /* Skip dummy parts to prevent unexpected data read from Efuse. */ - /* By pass right now. 2009.02.19. */ - /* */ - while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { - if (efuse_OneByteRead23a(padapter, efuse_addr++, &efuse_data) == - _FAIL) { - ret = false; - break; - } - - if (efuse_data == 0xFF) - break; - - if (EXT_HEADER(efuse_data)) { - hoffset = GET_HDR_OFFSET_2_0(efuse_data); - efuse_OneByteRead23a(padapter, efuse_addr++, &efuse_data); - if (ALL_WORDS_DISABLED(efuse_data)) { - DBG_8723A("%s: Error!! All words disabled!\n", - __func__); - continue; - } - - hoffset |= ((efuse_data & 0xF0) >> 1); - hworden = efuse_data & 0x0F; - } else { - hoffset = (efuse_data >> 4) & 0x0F; - hworden = efuse_data & 0x0F; - } - - if (hoffset == offset) { - for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { - /* Check word enable condition in the section */ - if (!(hworden & (0x01 << i))) { - ReadEFuseByte23a(padapter, efuse_addr++, - &efuse_data); - data[i * 2] = efuse_data; - - ReadEFuseByte23a(padapter, efuse_addr++, - &efuse_data); - data[(i * 2) + 1] = efuse_data; - } - } - } else { - word_cnts = Efuse_CalculateWordCnts23a(hworden); - efuse_addr += word_cnts * 2; - } - } - - return ret; -} - void rtl8723a_read_chip_version(struct rtw_adapter *padapter) { u32 value32; -- cgit v1.2.3-59-g8ed1b From 8488d6eca9d3bfd10420d37fccf45b98cdd867ac Mon Sep 17 00:00:00 2001 From: "Tobenna P. Igwe" Date: Tue, 18 Nov 2014 01:45:41 +0000 Subject: staging:rtl8723au: Fix sparse warning cast to restricted __le16 This patch fixes the following sparse warning: drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c:343:36: warning: cast to restricted __le16 by using the le16_to_cpus function. Signed-off-by: Tobenna P. Igwe Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index d80ea4ee39e9..78665eec3c1d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -340,7 +340,7 @@ static u8 bthci_GetAssocInfo(struct rtw_adapter *padapter, u8 EntryNum) tempBuf, TotalLen-BaseMemoryShift); pAmpAsoc = (struct amp_assoc_structure *)tempBuf; - pAmpAsoc->Length = le16_to_cpu(pAmpAsoc->Length); + le16_to_cpus(&pAmpAsoc->Length); BaseMemoryShift += 3 + pAmpAsoc->Length; RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("TypeID = 0x%x, ", pAmpAsoc->TypeID)); -- cgit v1.2.3-59-g8ed1b From ce6bed69e3256217fc7773a889c7a925bf07d69e Mon Sep 17 00:00:00 2001 From: Kinka Huang Date: Thu, 20 Nov 2014 00:27:02 +0800 Subject: staging:rtl8723au: fix sparse warning: incorrect type in assignment Signed-off-by: Kinka Huang Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 95bed7a98003..734972cae87c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2153,9 +2153,9 @@ bool rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); - ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | + ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40; + IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40); GetHalDefVar8192CUsb(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); -- cgit v1.2.3-59-g8ed1b From 902f3bb1ef1471076a6529e27531f78d1541fbcd Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:48 +0100 Subject: staging: lustre: ldlm: Add missing newlines after declarations checkpatch.pl complains about a number of missing newlines after declarations. This patch gets rid of these warnings. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/interval_tree.c | 5 +++++ drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 4 +++- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 4 ++++ drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 +++ drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 ++ drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 8 ++++++++ drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 ++ 9 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index a3d7a7292417..eab2bd60241b 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -73,6 +73,7 @@ static inline int extent_compare(struct interval_node_extent *e1, struct interval_node_extent *e2) { int rc; + if (e1->start == e2->start) { if (e1->end < e2->end) rc = -1; @@ -321,6 +322,7 @@ static void interval_insert_color(struct interval_node *node, /* Parent is RED, so gparent must not be NULL */ if (node_is_left_child(parent)) { struct interval_node *uncle; + uncle = gparent->in_right; if (uncle && node_is_red(uncle)) { uncle->in_color = INTERVAL_BLACK; @@ -340,6 +342,7 @@ static void interval_insert_color(struct interval_node *node, __rotate_right(gparent, root); } else { struct interval_node *uncle; + uncle = gparent->in_left; if (uncle && node_is_red(uncle)) { uncle->in_color = INTERVAL_BLACK; @@ -427,6 +430,7 @@ static void interval_erase_color(struct interval_node *node, } else { if (node_is_black_or_0(tmp->in_right)) { struct interval_node *o_left; + o_left = tmp->in_left; if (o_left) o_left->in_color = INTERVAL_BLACK; @@ -458,6 +462,7 @@ static void interval_erase_color(struct interval_node *node, } else { if (node_is_black_or_0(tmp->in_left)) { struct interval_node *o_right; + o_right = tmp->in_right; if (o_right) o_right->in_color = INTERVAL_BLACK; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 0c09b611f4a6..a89eebaedabf 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -182,7 +182,9 @@ void ldlm_extent_add_lock(struct ldlm_resource *res, root = &res->lr_itree[idx].lit_root; found = interval_insert(&node->li_node, root); if (found) { /* The policy group found. */ - struct ldlm_interval *tmp = ldlm_interval_detach(lock); + struct ldlm_interval *tmp; + + tmp = ldlm_interval_detach(lock); LASSERT(tmp != NULL); ldlm_interval_free(tmp); ldlm_interval_attach(to_ldlm_interval(found), lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index e00478b9b50b..efb36354150f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -291,6 +291,7 @@ reprocess: } } else { int reprocess_failed = 0; + lockmode_verify(mode); /* This loop determines if there are existing locks diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 06cf6d282e65..b3009cc1ad9c 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -214,6 +214,7 @@ static inline struct ldlm_extent * ldlm_interval_extent(struct ldlm_interval *node) { struct ldlm_lock *lock; + LASSERT(!list_empty(&node->li_group)); lock = list_entry(node->li_group.next, struct ldlm_lock, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 2c4af89eee7e..c0e54898a2e1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -226,6 +226,7 @@ EXPORT_SYMBOL(ldlm_lock_put); int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock) { int rc = 0; + if (!list_empty(&lock->l_lru)) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); @@ -858,6 +859,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); + LASSERTF(lock != NULL, "Non-existing lock: %#llx\n", lockh->cookie); ldlm_lock_decref_internal(lock, mode); LDLM_LOCK_PUT(lock); @@ -1286,6 +1288,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, __u64 wait_flags = LDLM_FL_LVB_READY | LDLM_FL_DESTROYED | LDLM_FL_FAIL_NOTIFIED; struct l_wait_info lwi; + if (lock->l_completion_ast) { int err = lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC, @@ -2219,6 +2222,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, nid = libcfs_nid2str(exp->exp_connection->c_peer.nid); } else if (exp && exp->exp_obd != NULL) { struct obd_import *imp = exp->exp_obd->u.cli.cl_import; + nid = libcfs_nid2str(imp->imp_connection->c_peer.nid); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 5fb9d842f7b9..870dac1de484 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -190,6 +190,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_BL_CB_RACE)) { int to = cfs_time_seconds(1); + while (to > 0) { set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(to); @@ -884,6 +885,7 @@ void ldlm_put_ref(void) mutex_lock(&ldlm_ref_mutex); if (ldlm_refcount == 1) { int rc = ldlm_cleanup(); + if (rc) CERROR("ldlm_cleanup failed: %d\n", rc); else @@ -966,6 +968,7 @@ static cfs_hash_ops_t ldlm_export_lock_ops = { int ldlm_init_export(struct obd_export *exp) { int rc; + exp->exp_lock_hash = cfs_hash_create(obd_uuid2str(&exp->exp_client_uuid), HASH_EXP_LOCK_CUR_BITS, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 0e1ab06d2543..b0f06d8228e1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -943,6 +943,7 @@ EXPORT_SYMBOL(ldlm_pool_del); __u64 ldlm_pool_get_slv(struct ldlm_pool *pl) { __u64 slv; + spin_lock(&pl->pl_lock); slv = pl->pl_server_lock_volume; spin_unlock(&pl->pl_lock); @@ -971,6 +972,7 @@ EXPORT_SYMBOL(ldlm_pool_set_slv); __u64 ldlm_pool_get_clv(struct ldlm_pool *pl) { __u64 slv; + spin_lock(&pl->pl_lock); slv = pl->pl_client_lock_volume; spin_unlock(&pl->pl_lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 95e71a0922f3..292ac7a2d02a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -135,6 +135,7 @@ EXPORT_SYMBOL(ldlm_expired_completion_wait); int ldlm_get_enq_timeout(struct ldlm_lock *lock) { int timeout = at_get(ldlm_lock_to_ns_at(lock)); + if (AT_OFF) return obd_timeout / 2; /* Since these are non-updating timeouts, we should be conservative. @@ -601,6 +602,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, * again. */ if ((*flags) & LDLM_FL_LOCK_CHANGED) { int newmode = reply->lock_desc.l_req_mode; + LASSERT(!is_replay); if (newmode && newmode != lock->l_req_mode) { LDLM_DEBUG(lock, "server returned different mode %s", @@ -669,6 +671,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, rc = ldlm_lock_enqueue(ns, &lock, NULL, flags); if (lock->l_completion_ast != NULL) { int err = lock->l_completion_ast(lock, *flags, NULL); + if (!rc) rc = err; if (rc) @@ -718,6 +721,7 @@ static inline int ldlm_capsule_handles_avail(struct req_capsule *pill, int off) { int size = req_capsule_msg_size(pill, loc); + return ldlm_req_handles_avail(size, off); } @@ -726,6 +730,7 @@ static inline int ldlm_format_handles_avail(struct obd_import *imp, enum req_location loc, int off) { int size = req_capsule_fmt_size(imp->imp_msg_magic, fmt, loc); + return ldlm_req_handles_avail(size, off); } @@ -1407,6 +1412,7 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, { ldlm_policy_res_t result = LDLM_POLICY_CANCEL_LOCK; ldlm_cancel_for_recovery cb = ns->ns_cancel_for_recovery; + lock_res_and_lock(lock); /* don't check added & count since we want to process all locks @@ -1721,6 +1727,7 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, int flags) { int added; + added = ldlm_prepare_lru_list(ns, cancels, count, max, flags); if (added <= 0) return added; @@ -2005,6 +2012,7 @@ struct iter_helper_data { static int ldlm_iter_helper(struct ldlm_lock *lock, void *closure) { struct iter_helper_data *helper = closure; + return helper->iter(lock, helper->closure); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 397adbe3ce0e..0fdbb9caa46e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -804,6 +804,7 @@ static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force) if (atomic_read(&ns->ns_bref) > 0) { struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc; + CDEBUG(D_DLMTRACE, "dlm namespace %s free waiting on refcount %d\n", ldlm_ns_name(ns), atomic_read(&ns->ns_bref)); @@ -1332,6 +1333,7 @@ void ldlm_dump_all_namespaces(ldlm_side_t client, int level) list_for_each(tmp, ldlm_namespace_list(client)) { struct ldlm_namespace *ns; + ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain); ldlm_namespace_dump(level, ns); } -- cgit v1.2.3-59-g8ed1b From e7ddc48c10826cdb44d414c1211ca22b4d2fff1b Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:49 +0100 Subject: staging: lustre: ldlm: Fix overlong lines checkpatch complains about a number of lines which are over the 80 character line limit. This patch changes most of them to comply, the few remaining lines with warnings are not changed for readability reasons. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 6 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 6 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 8 +++-- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 36 +++++++++++++--------- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 11 ++++--- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 6 ++-- 8 files changed, 49 insertions(+), 30 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index efb36354150f..a4c252febfe4 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -260,7 +260,8 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, int splitted = 0; const struct ldlm_callback_suite null_cbs = { NULL }; - CDEBUG(D_DLMTRACE, "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", + CDEBUG(D_DLMTRACE, + "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", *flags, new->l_policy_data.l_flock.owner, new->l_policy_data.l_flock.pid, mode, req->l_policy_data.l_flock.start, @@ -497,7 +498,8 @@ reprocess: new->l_policy_data.l_flock.end + 1; new2->l_conn_export = lock->l_conn_export; if (lock->l_export != NULL) { - new2->l_export = class_export_lock_get(lock->l_export, new2); + new2->l_export = class_export_lock_get(lock->l_export, + new2); if (new2->l_export->exp_lock_hash && hlist_unhashed(&new2->l_exp_hash)) cfs_hash_add(new2->l_export->exp_lock_hash, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index b3009cc1ad9c..6c6c57ca91de 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -91,7 +91,8 @@ static inline int ldlm_ns_empty(struct ldlm_namespace *ns) } void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *, ldlm_side_t); -void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *, ldlm_side_t); +void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *, + ldlm_side_t); struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t); /* ldlm_request.c */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 249f3116d74a..c5c86e73ca52 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -603,7 +603,8 @@ int client_disconnect_export(struct obd_export *exp) /* obd_force == local only */ ldlm_cli_cancel_unused(obd->obd_namespace, NULL, obd->obd_force ? LCF_LOCAL : 0, NULL); - ldlm_namespace_free_prior(obd->obd_namespace, imp, obd->obd_force); + ldlm_namespace_free_prior(obd->obd_namespace, imp, + obd->obd_force); } /* There's no need to hold sem while disconnecting an import, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index c0e54898a2e1..f987a4021ebf 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1342,7 +1342,8 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } else if (!(flags & LDLM_FL_TEST_LOCK)) {/*less verbose for test-only*/ LDLM_DEBUG_NOLOCK("not matched ns %p type %u mode %u res %llu/%llu (%llu %llu)", - ns, type, mode, res_id->name[0], res_id->name[1], + ns, type, mode, res_id->name[0], + res_id->name[1], (type == LDLM_PLAIN || type == LDLM_IBITS) ? res_id->name[2] :policy->l_extent.start, (type == LDLM_PLAIN || type == LDLM_IBITS) ? @@ -1455,7 +1456,8 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, memcpy(data, lvb, size); } else { - LDLM_ERROR(lock, "Replied unexpected lquota LVB size %d", + LDLM_ERROR(lock, + "Replied unexpected lquota LVB size %d", size); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 870dac1de484..4afc15e0199d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -158,13 +158,15 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns, unlock_res_and_lock(lock); if (do_ast) { - CDEBUG(D_DLMTRACE, "Lock %p already unused, calling callback (%p)\n", - lock, lock->l_blocking_ast); + CDEBUG(D_DLMTRACE, + "Lock %p already unused, calling callback (%p)\n", lock, + lock->l_blocking_ast); if (lock->l_blocking_ast != NULL) lock->l_blocking_ast(lock, ld, lock->l_ast_data, LDLM_CB_BLOCKING); } else { - CDEBUG(D_DLMTRACE, "Lock %p is referenced, will be cancelled later\n", + CDEBUG(D_DLMTRACE, + "Lock %p is referenced, will be cancelled later\n", lock); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index b0f06d8228e1..c8c7aee4ed5e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -54,10 +54,10 @@ * calculated as the number of locks in LRU * lock live time in seconds. If * CLV > SLV - lock is canceled. * - * Client has LVF, that is, lock volume factor which regulates how much sensitive - * client should be about last SLV from server. The higher LVF is the more locks - * will be canceled on client. Default value for it is 1. Setting LVF to 2 means - * that client will cancel locks 2 times faster. + * Client has LVF, that is, lock volume factor which regulates how much + * sensitive client should be about last SLV from server. The higher LVF is the + * more locks will be canceled on client. Default value for it is 1. Setting LVF + * to 2 means that client will cancel locks 2 times faster. * * Locks on a client will be canceled more intensively in these cases: * (1) if SLV is smaller, that is, load is higher on the server; @@ -70,11 +70,12 @@ * if flow is getting thinner, more and more particles become outside of it and * as particles are locks, they should be canceled. * - * General idea of this belongs to Vitaly Fertman (vitaly@clusterfs.com). Andreas - * Dilger (adilger@clusterfs.com) proposed few nice ideas like using LVF and many - * cleanups. Flow definition to allow more easy understanding of the logic belongs - * to Nikita Danilov (nikita@clusterfs.com) as well as many cleanups and fixes. - * And design and implementation are done by Yury Umanets (umka@clusterfs.com). + * General idea of this belongs to Vitaly Fertman (vitaly@clusterfs.com). + * Andreas Dilger (adilger@clusterfs.com) proposed few nice ideas like using + * LVF and many cleanups. Flow definition to allow more easy understanding of + * the logic belongs to Nikita Danilov (nikita@clusterfs.com) as well as many + * cleanups and fixes. And design and implementation are done by Yury Umanets + * (umka@clusterfs.com). * * Glossary for terms used: * @@ -696,8 +697,9 @@ LPROC_SEQ_FOPS_RO(lprocfs_grant_plan); LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int); LDLM_POOL_PROC_WRITER(recalc_period, int); -static ssize_t lprocfs_recalc_period_seq_write(struct file *file, const char *buf, - size_t len, loff_t *off) +static ssize_t lprocfs_recalc_period_seq_write(struct file *file, + const char *buf, size_t len, + loff_t *off) { struct seq_file *seq = file->private_data; @@ -1134,23 +1136,27 @@ static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, gfp_t gfp_mask) return (client == LDLM_NAMESPACE_SERVER) ? SHRINK_STOP : freed; } -static unsigned long ldlm_pools_srv_count(struct shrinker *s, struct shrink_control *sc) +static unsigned long ldlm_pools_srv_count(struct shrinker *s, + struct shrink_control *sc) { return ldlm_pools_count(LDLM_NAMESPACE_SERVER, sc->gfp_mask); } -static unsigned long ldlm_pools_srv_scan(struct shrinker *s, struct shrink_control *sc) +static unsigned long ldlm_pools_srv_scan(struct shrinker *s, + struct shrink_control *sc) { return ldlm_pools_scan(LDLM_NAMESPACE_SERVER, sc->nr_to_scan, sc->gfp_mask); } -static unsigned long ldlm_pools_cli_count(struct shrinker *s, struct shrink_control *sc) +static unsigned long ldlm_pools_cli_count(struct shrinker *s, + struct shrink_control *sc) { return ldlm_pools_count(LDLM_NAMESPACE_CLIENT, sc->gfp_mask); } -static unsigned long ldlm_pools_cli_scan(struct shrinker *s, struct shrink_control *sc) +static unsigned long ldlm_pools_cli_scan(struct shrinker *s, + struct shrink_control *sc) { return ldlm_pools_scan(LDLM_NAMESPACE_CLIENT, sc->nr_to_scan, sc->gfp_mask); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 292ac7a2d02a..5478e4d8e257 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1275,7 +1275,8 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) * server-side namespace is not possible. */ if (lustre_msg_get_slv(req->rq_repmsg) == 0 || lustre_msg_get_limit(req->rq_repmsg) == 0) { - DEBUG_REQ(D_HA, req, "Zero SLV or Limit found (SLV: %llu, Limit: %u)", + DEBUG_REQ(D_HA, req, + "Zero SLV or Limit found (SLV: %llu, Limit: %u)", lustre_msg_get_slv(req->rq_repmsg), lustre_msg_get_limit(req->rq_repmsg)); return 0; @@ -1591,8 +1592,9 @@ ldlm_cancel_lru_policy(struct ldlm_namespace *ns, int flags) * sending any RPCs or waiting for any * outstanding RPC to complete. */ -static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *cancels, - int count, int max, int flags) +static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, + struct list_head *cancels, int count, int max, + int flags) { ldlm_cancel_lru_policy_t pf; struct ldlm_lock *lock, *next; @@ -1916,7 +1918,8 @@ struct ldlm_cli_cancel_arg { void *lc_opaque; }; -static int ldlm_cli_hash_cancel_unused(struct cfs_hash *hs, struct cfs_hash_bd *bd, +static int ldlm_cli_hash_cancel_unused(struct cfs_hash *hs, + struct cfs_hash_bd *bd, struct hlist_node *hnode, void *arg) { struct ldlm_resource *res = cfs_hash_object(hs, hnode); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 0fdbb9caa46e..fb8dd680ced1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -454,7 +454,8 @@ static void *ldlm_res_hop_object(struct hlist_node *hnode) return hlist_entry(hnode, struct ldlm_resource, lr_hash); } -static void ldlm_res_hop_get_locked(struct cfs_hash *hs, struct hlist_node *hnode) +static void ldlm_res_hop_get_locked(struct cfs_hash *hs, + struct hlist_node *hnode) { struct ldlm_resource *res; @@ -462,7 +463,8 @@ static void ldlm_res_hop_get_locked(struct cfs_hash *hs, struct hlist_node *hnod ldlm_resource_getref(res); } -static void ldlm_res_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) +static void ldlm_res_hop_put_locked(struct cfs_hash *hs, + struct hlist_node *hnode) { struct ldlm_resource *res; -- cgit v1.2.3-59-g8ed1b From 43ee4160bb1dba58e62a2e45c05c046b952e44cc Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:50 +0100 Subject: staging: lustre: ldlm: Fix warning about missing spaces checkpatch.pl complains about a number of places where spaces were missing. This patch fixes all of these errors. For better readability, the warning of hitting the 80 character per line limit in line 1349 introduced by this change is ignored deliberately. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 4 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 3 ++- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index f987a4021ebf..7674be484d40 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -576,7 +576,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, /* It's unlikely but possible that someone marked the lock as * destroyed after we did handle2object on it */ - if (flags == 0 && ((lock->l_flags & LDLM_FL_DESTROYED)== 0)) { + if (flags == 0 && ((lock->l_flags & LDLM_FL_DESTROYED) == 0)) { lu_ref_add(&lock->l_reference, "handle", current); return lock; } @@ -1345,7 +1345,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, ns, type, mode, res_id->name[0], res_id->name[1], (type == LDLM_PLAIN || type == LDLM_IBITS) ? - res_id->name[2] :policy->l_extent.start, + res_id->name[2] : policy->l_extent.start, (type == LDLM_PLAIN || type == LDLM_IBITS) ? res_id->name[3] : policy->l_extent.end); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 5478e4d8e257..c117ff530029 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -2082,7 +2082,8 @@ static int ldlm_chain_lock_for_replay(struct ldlm_lock *lock, void *closure) /* we use l_pending_chain here, because it's unused on clients. */ LASSERTF(list_empty(&lock->l_pending_chain), "lock %p next %p prev %p\n", - lock, &lock->l_pending_chain.next,&lock->l_pending_chain.prev); + lock, &lock->l_pending_chain.next, + &lock->l_pending_chain.prev); /* bug 9573: don't replay locks left after eviction, or * bug 17614: locks being actively cancelled. Get a reference * on a lock so that it does not disappear under us (e.g. due to cancel) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index fb8dd680ced1..80b2e91735e5 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -93,7 +93,7 @@ int ldlm_proc_setup(void) &ldlm_dump_granted_max }, { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops, &ldlm_cancel_unused_locks_before_replay }, - { NULL }}; + { NULL } }; LASSERT(ldlm_ns_proc_dir == NULL); ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME, @@ -385,8 +385,8 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) #undef MAX_STRING_SIZE #else /* CONFIG_PROC_FS */ -#define ldlm_namespace_proc_unregister(ns) ({;}) -#define ldlm_namespace_proc_register(ns) ({0;}) +#define ldlm_namespace_proc_unregister(ns) ({; }) +#define ldlm_namespace_proc_register(ns) ({0; }) #endif /* CONFIG_PROC_FS */ @@ -578,7 +578,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, return NULL; } - for (idx = 0;;idx++) { + for (idx = 0;; idx++) { nsd = &ldlm_ns_hash_defs[idx]; if (nsd->nsd_type == LDLM_NS_TYPE_UNKNOWN) { CERROR("Unknown type %d for ns %s\n", ns_type, name); -- cgit v1.2.3-59-g8ed1b From 0e1bbbb0302014bb77f58880a25ac554c085345c Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:51 +0100 Subject: staging: lustre: ldlm: Fix indentation errors for switch-case checkpatch complains about two indentation errors where the case statements are on a higher indentation level than the corresponding switch statement. This patch removes these errors. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 36 +++++++++++------------ drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 14 ++++----- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 7674be484d40..d36f865c8aa2 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1823,24 +1823,24 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, arg->list = rpc_list; switch (ast_type) { - case LDLM_WORK_BL_AST: - arg->type = LDLM_BL_CALLBACK; - work_ast_lock = ldlm_work_bl_ast_lock; - break; - case LDLM_WORK_CP_AST: - arg->type = LDLM_CP_CALLBACK; - work_ast_lock = ldlm_work_cp_ast_lock; - break; - case LDLM_WORK_REVOKE_AST: - arg->type = LDLM_BL_CALLBACK; - work_ast_lock = ldlm_work_revoke_ast_lock; - break; - case LDLM_WORK_GL_AST: - arg->type = LDLM_GL_CALLBACK; - work_ast_lock = ldlm_work_gl_ast_lock; - break; - default: - LBUG(); + case LDLM_WORK_BL_AST: + arg->type = LDLM_BL_CALLBACK; + work_ast_lock = ldlm_work_bl_ast_lock; + break; + case LDLM_WORK_CP_AST: + arg->type = LDLM_CP_CALLBACK; + work_ast_lock = ldlm_work_cp_ast_lock; + break; + case LDLM_WORK_REVOKE_AST: + arg->type = LDLM_BL_CALLBACK; + work_ast_lock = ldlm_work_revoke_ast_lock; + break; + case LDLM_WORK_GL_AST: + arg->type = LDLM_GL_CALLBACK; + work_ast_lock = ldlm_work_gl_ast_lock; + break; + default: + LBUG(); } /* We create a ptlrpc request set with flow control extension. diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index c117ff530029..03523b083b51 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1419,14 +1419,14 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, /* don't check added & count since we want to process all locks * from unused list */ switch (lock->l_resource->lr_type) { - case LDLM_EXTENT: - case LDLM_IBITS: - if (cb && cb(lock)) - break; - default: - result = LDLM_POLICY_SKIP_LOCK; - lock->l_flags |= LDLM_FL_SKIPPED; + case LDLM_EXTENT: + case LDLM_IBITS: + if (cb && cb(lock)) break; + default: + result = LDLM_POLICY_SKIP_LOCK; + lock->l_flags |= LDLM_FL_SKIPPED; + break; } unlock_res_and_lock(lock); -- cgit v1.2.3-59-g8ed1b From 9844f9c9b4c29e457dea363c01f632228ebb27d8 Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:52 +0100 Subject: staging: lustre: ldlm: Fix initialization of static variables checkpatch complains about static variables being initialized to 0 which is unnecessary. This patch removes the initialization. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 4afc15e0199d..b95f73cb5548 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -724,7 +724,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp) { struct ldlm_bl_work_item *blwi = NULL; - static unsigned int num_bl = 0; + static unsigned int num_bl; spin_lock(&blp->blp_lock); /* process a request from the blp_list at least every blp_num_threads */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 03523b083b51..a9a04ded91ef 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -95,7 +95,7 @@ int ldlm_expired_completion_wait(void *data) struct obd_device *obd; if (lock->l_conn_export == NULL) { - static unsigned long next_dump = 0, last_dump = 0; + static unsigned long next_dump, last_dump; LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", " CFS_DURATION_T"s ago)\n", -- cgit v1.2.3-59-g8ed1b From fd0c587aa91d202b22184d96daa1edeeebcde718 Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:53 +0100 Subject: staging: lustre: ldlm: Fix warning about unneeded return statement checkpatch complains about an unneeded return statement in the function search_granted_lock(), which is removed by this patch. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index d36f865c8aa2..8191005464b1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -982,7 +982,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = queue->prev; prev->mode_link = &req->l_sl_mode; prev->policy_link = &req->l_sl_policy; - return; } /** -- cgit v1.2.3-59-g8ed1b From b0e47b96e313aa6c855843b506626b3fbeb3bcc7 Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:54 +0100 Subject: staging: lustre: ldlm: Remove unnecessary line continuations checkpatch finds two unnecessary line continuations in ldlm_lockd.c which are removed by this patch. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index b95f73cb5548..98fbd3f7e751 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -1051,7 +1051,7 @@ static int ldlm_setup(void) .so_req_handler = ldlm_callback_handler, }, }; - ldlm_state->ldlm_cb_service = \ + ldlm_state->ldlm_cb_service = ptlrpc_register_service(&conf, ldlm_svc_proc_dir); if (IS_ERR(ldlm_state->ldlm_cb_service)) { CERROR("failed to start service\n"); @@ -1079,7 +1079,7 @@ static int ldlm_setup(void) blp->blp_min_threads = LDLM_NTHRS_INIT; blp->blp_max_threads = LDLM_NTHRS_MAX; } else { - blp->blp_min_threads = blp->blp_max_threads = \ + blp->blp_min_threads = blp->blp_max_threads = min_t(int, LDLM_NTHRS_MAX, max_t(int, LDLM_NTHRS_INIT, ldlm_num_threads)); } -- cgit v1.2.3-59-g8ed1b From 8d2ff65da8cf1c84a1bc676e9ecb870120f369fa Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:55 +0100 Subject: staging: lustre: ldlm: Remove unnecessary braces at ifs checkpatch complains about three places where braces are not necessary. This patch removes the braces. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 8 +++----- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index c8c7aee4ed5e..55503e461dc9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -271,11 +271,10 @@ static void ldlm_pool_recalc_slv(struct ldlm_pool *pl) slv = slv * slv_factor; slv = dru(slv, LDLM_POOL_SLV_SHIFT, round_up); - if (slv > ldlm_pool_slv_max(limit)) { + if (slv > ldlm_pool_slv_max(limit)) slv = ldlm_pool_slv_max(limit); - } else if (slv < ldlm_pool_slv_min(limit)) { + else if (slv < ldlm_pool_slv_min(limit)) slv = ldlm_pool_slv_min(limit); - } pl->pl_server_lock_volume = slv; } @@ -1388,9 +1387,8 @@ static int ldlm_pools_thread_start(void) static void ldlm_pools_thread_stop(void) { - if (ldlm_pools_thread == NULL) { + if (ldlm_pools_thread == NULL) return; - } thread_set_flags(ldlm_pools_thread, SVC_STOPPING); wake_up(&ldlm_pools_thread->t_ctl_waitq); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index a9a04ded91ef..287da325d928 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -245,9 +245,8 @@ noreproc: obd = class_exp2obd(lock->l_conn_export); /* if this is a local lock, then there is no import */ - if (obd != NULL) { + if (obd != NULL) imp = obd->u.cli.cl_import; - } /* Wait a long time for enqueue - server may have to callback a lock from another client. Server will evict the other client if it -- cgit v1.2.3-59-g8ed1b From 4d089bb4e703367030c910ccb4d10e06dc395344 Mon Sep 17 00:00:00 2001 From: Andreas Ruprecht Date: Sun, 23 Nov 2014 14:37:56 +0100 Subject: staging: lustre: ldlm: Remove space before braces for defined() check checkpatch complains about two places where a space is prohibited before the braces for in "#if defined()" check. This patch removes these warnings. Signed-off-by: Andreas Ruprecht Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 55503e461dc9..4c838f615a64 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -636,7 +636,7 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit) } EXPORT_SYMBOL(ldlm_pool_setup); -#if defined (CONFIG_PROC_FS) +#if defined(CONFIG_PROC_FS) static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) { int granted, grant_rate, cancel_rate, grant_step; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 80b2e91735e5..1f150e46f50e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -71,7 +71,7 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay; * DDOS. */ unsigned int ldlm_dump_granted_max = 256; -#if defined (CONFIG_PROC_FS) +#if defined(CONFIG_PROC_FS) static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer, size_t count, loff_t *off) { -- cgit v1.2.3-59-g8ed1b From 3008dd9d9bcca3196659667648994793acea7cb9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:00 +0000 Subject: staging: vt6655: CARDvUpdateBasicTopRate use basic_rates to find top rate basic_rates should now be used to find it. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index aaa72891fc51..d7b023b57b12 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -843,7 +843,7 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) /* Determines the highest basic rate. */ for (ii = RATE_54M; ii >= RATE_6M; ii--) { - if ((pDevice->wBasicRate) & ((unsigned short)(1<basic_rates) & ((u32)(1 << ii))) { byTopOFDM = ii; break; } @@ -851,7 +851,7 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) pDevice->byTopOFDMBasicRate = byTopOFDM; for (ii = RATE_11M;; ii--) { - if ((pDevice->wBasicRate) & ((unsigned short)(1<basic_rates) & ((u32)(1 << ii))) { byTopCCK = ii; break; } -- cgit v1.2.3-59-g8ed1b From b930eb56e381b11fbf93c4c25fc441eddc22b1cb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:01 +0000 Subject: staging: vt6655: dead code remove CARDbAddBasicRate we nonlonger set rates in the driver Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 12 ------------ drivers/staging/vt6655/card.h | 1 - 2 files changed, 13 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index d7b023b57b12..7b2596960dc4 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -861,18 +861,6 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) pDevice->byTopCCKBasicRate = byTopCCK; } -bool CARDbAddBasicRate(struct vnt_private *pDevice, unsigned short wRateIdx) -{ - unsigned short wRate = (unsigned short)(1<wBasicRate |= wRate; - - /* Determines the highest basic rate. */ - CARDvUpdateBasicTopRate((void *)pDevice); - - return true; -} - bool CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) { int ii; diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index f12afefd7fd8..2449f3cb5696 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -76,7 +76,6 @@ struct vnt_private; void CARDvSetRSPINF(struct vnt_private *, CARD_PHY_TYPE ePHYType); void vUpdateIFS(struct vnt_private *); void CARDvUpdateBasicTopRate(struct vnt_private *); -bool CARDbAddBasicRate(struct vnt_private *, unsigned short wRateIdx); bool CARDbIsOFDMinBasicRate(struct vnt_private *); void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode); bool CARDbSoftwareReset(struct vnt_private *); -- cgit v1.2.3-59-g8ed1b From a558e3dcc38e7bb85ee052cd7c7ed44e6b40c85a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:02 +0000 Subject: staging: vt6655: CARDbSetPhyParameter change CARD_PHY_TYPE to bb_type using u8 for bb_type Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 8 ++++---- drivers/staging/vt6655/card.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 7b2596960dc4..6a1efd152e36 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -204,7 +204,7 @@ s_vCalculateOFDMRParameter( * * Return Value: None. */ -bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, +bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type, unsigned short wCapInfo, unsigned char byERPField, void *pvSupportRateIEs, void *pvExtSupportRateIEs) { @@ -216,7 +216,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, int i; /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ - if (ePHYType == PHY_TYPE_11A) { + if (bb_type == BB_TYPE_11A) { if (pDevice->byRFType == RF_AIROHA7230) { /* AL7230 use single PAPE and connect to PAPE_2.4G */ MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); @@ -243,7 +243,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, bySIFS = C_SIFS_A; byDIFS = C_SIFS_A + 2*C_SLOT_SHORT; byCWMaxMin = 0xA4; - } else if (ePHYType == PHY_TYPE_11B) { + } else if (bb_type == BB_TYPE_11B) { MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B); if (pDevice->byRFType == RF_AIROHA7230) { pDevice->abyBBVGA[0] = 0x1C; @@ -344,7 +344,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType, pDevice->byPacketType = CARDbyGetPktType(pDevice); - CARDvSetRSPINF(pDevice, ePHYType); + CARDvSetRSPINF(pDevice, bb_type); return true; } diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 2449f3cb5696..9d19f9761c59 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -89,7 +89,7 @@ void CARDvSafeResetTx(struct vnt_private *); void CARDvSafeResetRx(struct vnt_private *); bool CARDbRadioPowerOff(struct vnt_private *); bool CARDbRadioPowerOn(struct vnt_private *); -bool CARDbSetPhyParameter(struct vnt_private *, CARD_PHY_TYPE ePHYType, +bool CARDbSetPhyParameter(struct vnt_private *, u8, unsigned short wCapInfo, unsigned char byERPField, void *pvSupportRateIEs, void *pvExtSupportRateIEs); bool CARDbUpdateTSF(struct vnt_private *, unsigned char byRxRate, -- cgit v1.2.3-59-g8ed1b From 6e1d14a56baa886dc9c52190112967a9e8a9e386 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:03 +0000 Subject: staging: vt6655: CARDvSetRSPINF us bb_type for CARD_PHY_TYPE Using u8 for bb_type Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 20 ++++++++++---------- drivers/staging/vt6655/card.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 6a1efd152e36..24ba9d40a7ac 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -669,7 +669,7 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, * * Return Value: None. */ -void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType) +void CARDvSetRSPINF(struct vnt_private *pDevice, u8 bb_type) { union vnt_phy_field_swap phy; unsigned char byTxRate, byRsvTime; /* For OFDM */ @@ -716,55 +716,55 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, CARD_PHY_TYPE ePHYType) /* RSPINF_a_6 */ s_vCalculateOFDMRParameter(RATE_6M, - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_9 */ s_vCalculateOFDMRParameter(RATE_9M, - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_12 */ s_vCalculateOFDMRParameter(RATE_12M, - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_18 */ s_vCalculateOFDMRParameter(RATE_18M, - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_24 */ s_vCalculateOFDMRParameter(RATE_24M, - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_36 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_36M), - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_48 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_48M), - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_54 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_72 */ s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), - ePHYType, + bb_type, &byTxRate, &byRsvTime); VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 9d19f9761c59..306f7b7a828a 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -73,7 +73,7 @@ typedef enum _CARD_STATUS_TYPE { struct vnt_private; -void CARDvSetRSPINF(struct vnt_private *, CARD_PHY_TYPE ePHYType); +void CARDvSetRSPINF(struct vnt_private *, u8); void vUpdateIFS(struct vnt_private *); void CARDvUpdateBasicTopRate(struct vnt_private *); bool CARDbIsOFDMinBasicRate(struct vnt_private *); -- cgit v1.2.3-59-g8ed1b From d1ab52011c67d1e85955dbe73e329d56a7d8bc30 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:04 +0000 Subject: staging: vt6655: s_vCalculateOFDMRParameter use bb_type for CARD_PHY_TYPE using u8 for bb_type and replacing PHY_TYPE_11A with BB_TYPE_11A Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 24ba9d40a7ac..e6e5f63627af 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -78,7 +78,7 @@ static void s_vCalculateOFDMRParameter( unsigned char byRate, - CARD_PHY_TYPE ePHYType, + u8 bb_type, unsigned char *pbyTxRate, unsigned char *pbyRsvTime ); @@ -102,14 +102,14 @@ static void s_vCalculateOFDMRParameter( unsigned char byRate, - CARD_PHY_TYPE ePHYType, + u8 bb_type, unsigned char *pbyTxRate, unsigned char *pbyRsvTime ) { switch (byRate) { case RATE_6M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9B; *pbyRsvTime = 44; } else { @@ -119,7 +119,7 @@ s_vCalculateOFDMRParameter( break; case RATE_9M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9F; *pbyRsvTime = 36; } else { @@ -129,7 +129,7 @@ s_vCalculateOFDMRParameter( break; case RATE_12M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9A; *pbyRsvTime = 32; } else { @@ -139,7 +139,7 @@ s_vCalculateOFDMRParameter( break; case RATE_18M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9E; *pbyRsvTime = 28; } else { @@ -149,7 +149,7 @@ s_vCalculateOFDMRParameter( break; case RATE_36M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9D; *pbyRsvTime = 24; } else { @@ -159,7 +159,7 @@ s_vCalculateOFDMRParameter( break; case RATE_48M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x98; *pbyRsvTime = 24; } else { @@ -169,7 +169,7 @@ s_vCalculateOFDMRParameter( break; case RATE_54M: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x9C; *pbyRsvTime = 24; } else { @@ -180,7 +180,7 @@ s_vCalculateOFDMRParameter( case RATE_24M: default: - if (ePHYType == PHY_TYPE_11A) { /* 5GHZ */ + if (bb_type == BB_TYPE_11A) { /* 5GHZ */ *pbyTxRate = 0x99; *pbyRsvTime = 28; } else { -- cgit v1.2.3-59-g8ed1b From b40d821dcc12dfac61a4ce021e074bcb0f8b8c84 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:05 +0000 Subject: staging: vt6655: dead code remove typedef enum _CARD_PHY_TYPE Removing unused eCurrentPHYType Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.h | 7 ------- drivers/staging/vt6655/device.h | 1 - 2 files changed, 8 deletions(-) diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 306f7b7a828a..30f34720947a 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -51,13 +51,6 @@ #define CB_MAX_CHANNEL_5G 42 #define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G) -typedef enum _CARD_PHY_TYPE { - PHY_TYPE_11A = 0, - PHY_TYPE_11B, - PHY_TYPE_11G, - PHY_TYPE_AUTO -} CARD_PHY_TYPE, *PCARD_PHY_TYPE; - typedef enum _CARD_PKT_TYPE { PKT_TYPE_802_11_BCN, PKT_TYPE_802_11_MNG, diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 1393210771de..dab07e1224f2 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -320,7 +320,6 @@ struct vnt_private { unsigned char byEIFS; unsigned char bySlot; unsigned char byCWMaxMin; - CARD_PHY_TYPE eCurrentPHYType; VIA_BB_TYPE byBBType; /* 0:11A, 1:11B, 2:11G */ VIA_PKT_TYPE byPacketType; /* -- cgit v1.2.3-59-g8ed1b From bfb6c8637640cd6d2fb3f06d056769654c2f7e86 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:06 +0000 Subject: staging: vt6655: CARDbSetPhyParameter remove unused parameters wCapInfo byERPField, *pvSupportRateIEs *pvExtSupportRateIEs Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 4 +--- drivers/staging/vt6655/card.h | 4 +--- drivers/staging/vt6655/device_main.c | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index e6e5f63627af..532c3c825031 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -204,9 +204,7 @@ s_vCalculateOFDMRParameter( * * Return Value: None. */ -bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type, - unsigned short wCapInfo, unsigned char byERPField, - void *pvSupportRateIEs, void *pvExtSupportRateIEs) +bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) { unsigned char byCWMaxMin = 0; unsigned char bySlot = 0; diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 30f34720947a..605d8a82f3f5 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -82,9 +82,7 @@ void CARDvSafeResetTx(struct vnt_private *); void CARDvSafeResetRx(struct vnt_private *); bool CARDbRadioPowerOff(struct vnt_private *); bool CARDbRadioPowerOn(struct vnt_private *); -bool CARDbSetPhyParameter(struct vnt_private *, u8, - unsigned short wCapInfo, unsigned char byERPField, - void *pvSupportRateIEs, void *pvExtSupportRateIEs); +bool CARDbSetPhyParameter(struct vnt_private *, u8); bool CARDbUpdateTSF(struct vnt_private *, unsigned char byRxRate, u64 qwBSSTimestamp, u64 qwLocalTSF); bool CARDbSetBeaconPeriod(struct vnt_private *, unsigned short wBeaconInterval); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 397f13f10c1a..22a55f4a9962 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1425,8 +1425,7 @@ static int vnt_config(struct ieee80211_hw *hw, u32 changed) if (priv->byBBType != bb_type) { priv->byBBType = bb_type; - CARDbSetPhyParameter(priv, - priv->byBBType, 0, 0, NULL, NULL); + CARDbSetPhyParameter(priv, priv->byBBType); } } @@ -1487,7 +1486,7 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, priv->bShortSlotTime = false; vUpdateIFS(priv); - CARDbSetPhyParameter(priv, priv->byBBType, 0, 0, NULL, NULL); + CARDbSetPhyParameter(priv, priv->byBBType); BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]); } -- cgit v1.2.3-59-g8ed1b From ff8d9f0806c8db8a3920752f4ca38f6688d0f87c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:07 +0000 Subject: staging: vt6655: replace typedef enum _VIA_BB_TYPE with macros Replacing type with u8 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index dab07e1224f2..3742d8d6764a 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -148,12 +148,9 @@ #define NUM 64 /* 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; +#define BB_TYPE_11A 0 +#define BB_TYPE_11B 1 +#define BB_TYPE_11G 2 /* 0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) */ typedef enum _VIA_PKT_TYPE @@ -321,7 +318,7 @@ struct vnt_private { unsigned char bySlot; unsigned char byCWMaxMin; - VIA_BB_TYPE byBBType; /* 0:11A, 1:11B, 2:11G */ + u8 byBBType; /* 0:11A, 1:11B, 2:11G */ VIA_PKT_TYPE byPacketType; /* * 0:11a,1:11b,2:11gb (only CCK * in BasicRate), 3:11ga (OFDM in -- cgit v1.2.3-59-g8ed1b From bf8918de79b98f647bb2927b5935de09ed091b12 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:08 +0000 Subject: staging: vt6655: change typedef enum _VIA_PKT_TYPE to macro Replacing for u8 type and removing cast for byBBType. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 23 ++++++++++------------- drivers/staging/vt6655/device_main.c | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 3742d8d6764a..55aa48b63b12 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -152,14 +152,11 @@ #define BB_TYPE_11B 1 #define BB_TYPE_11G 2 -/* 0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) */ -typedef enum _VIA_PKT_TYPE -{ - PK_TYPE_11A = 0, - PK_TYPE_11B, - PK_TYPE_11GB, - PK_TYPE_11GA -} VIA_PKT_TYPE, *PVIA_PKT_TYPE; +/* 0:11a, 1:11b, 2:11gb (only CCK in BasicRate), 3:11ga (OFDM in BasicRate) */ +#define PK_TYPE_11A 0 +#define PK_TYPE_11B 1 +#define PK_TYPE_11GB 2 +#define PK_TYPE_11GA 3 typedef struct __chip_info_tbl { CHIP_TYPE chip_id; @@ -319,11 +316,11 @@ struct vnt_private { unsigned char byCWMaxMin; u8 byBBType; /* 0:11A, 1:11B, 2:11G */ - VIA_PKT_TYPE byPacketType; /* - * 0:11a,1:11b,2:11gb (only CCK - * in BasicRate), 3:11ga (OFDM in - * Basic Rate) - */ + u8 byPacketType; /* + * 0:11a,1:11b,2:11gb (only CCK + * in BasicRate), 3:11ga (OFDM in + * Basic Rate) + */ unsigned short wBasicRate; unsigned char byACKRate; unsigned char byTopOFDMBasicRate; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 22a55f4a9962..2e3178429437 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -226,7 +226,7 @@ device_set_options(struct vnt_private *pDevice) pDevice->byLongRetryLimit = pDevice->sOpts.long_retry; pDevice->bDiversityRegCtlON = (pDevice->sOpts.flags & DEVICE_FLAGS_DiversityANT) ? 1 : 0; pDevice->byBBType = pDevice->sOpts.bbp_type; - pDevice->byPacketType = (VIA_PKT_TYPE)pDevice->byBBType; + pDevice->byPacketType = pDevice->byBBType; pDevice->byAutoFBCtrl = AUTO_FB_0; pDevice->bUpdateBBVGA = true; pDevice->byPreambleType = 0; -- cgit v1.2.3-59-g8ed1b From c397d46fbe4610a88c1e868d6f9ae93b52f70228 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 7 Nov 2014 19:06:09 +0000 Subject: staging: vt6655: always keep abyCurrentNetAddr aligned to 2 Because the driver now uses ether_addr_copy the alignment of this variable must be maintained at 2. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 55aa48b63b12..83efbfb57c79 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -283,7 +283,7 @@ struct vnt_private { bool bZoneRegExist; unsigned char byOriginalZonetype; - unsigned char abyCurrentNetAddr[ETH_ALEN]; + unsigned char abyCurrentNetAddr[ETH_ALEN]; __aligned(2) bool bLinkPass; /* link status: OK or fail */ /* Adapter statistics */ -- cgit v1.2.3-59-g8ed1b From 6d35b1fcaa403aedc37e0ff17baf8c4f2ae07ed8 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:08 +0000 Subject: staging: vt6655: card Remove function vUpdateIFS vUpdateIFS does the same operations of CARDbSetPhyParameter there is not need to call this function. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 65 ------------------------------------ drivers/staging/vt6655/card.h | 1 - drivers/staging/vt6655/device_main.c | 1 - 3 files changed, 67 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 532c3c825031..a93ca160dda7 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -21,7 +21,6 @@ * Functions: * s_vSafeResetTx - Rest Tx * CARDvSetRSPINF - Set RSPINF - * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS * CARDvUpdateBasicTopRate - Update BasicTopRate * CARDbAddBasicRate - Add to BasicRateSet * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet @@ -770,70 +769,6 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, u8 bb_type) MACvSelectPage0(pDevice->PortOffset); } -/* - * Description: Update IFS - * - * Parameters: - * In: - * pDevice - The adapter to be set - * Out: - * none - * - * Return Value: None. - */ -void vUpdateIFS(struct vnt_private *pDevice) -{ - /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ - - unsigned char byMaxMin = 0; - - if (pDevice->byPacketType == PK_TYPE_11A) { /*0000 0000 0000 0000,11a*/ - pDevice->uSlot = C_SLOT_SHORT; - pDevice->uSIFS = C_SIFS_A; - pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT; - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } else if (pDevice->byPacketType == PK_TYPE_11B) { - /* 0000 0001 0000 0000,11b */ - pDevice->uSlot = C_SLOT_LONG; - pDevice->uSIFS = C_SIFS_BG; - pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG; - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ - pDevice->uSIFS = C_SIFS_BG; - if (pDevice->bShortSlotTime) - pDevice->uSlot = C_SLOT_SHORT; - else - pDevice->uSlot = C_SLOT_LONG; - - pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; - if (pDevice->wBasicRate & 0x0150) { - /* 0000 0001 0101 0000,24M,12M,6M */ - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } else { - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - } - - pDevice->uCwMax = C_CWMAX; - pDevice->uEIFS = C_EIFS; - if (pDevice->byRFType == RF_RFMD2959) { - /* bcs TX_PE will reserve 3 us */ - VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (unsigned char)(pDevice->uSIFS - 3)); - VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (unsigned char)(pDevice->uDIFS - 3)); - } else { - VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (unsigned char)pDevice->uSIFS); - VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (unsigned char)pDevice->uDIFS); - } - VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (unsigned char)pDevice->uEIFS); - VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (unsigned char)pDevice->uSlot); - byMaxMin |= 0xA0; /* 1010 1111,C_CWMAX = 1023 */ - VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (unsigned char)byMaxMin); -} - void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) { unsigned char byTopOFDM = RATE_24M, byTopCCK = RATE_1M; diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 605d8a82f3f5..2e567104ded4 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -67,7 +67,6 @@ typedef enum _CARD_STATUS_TYPE { struct vnt_private; void CARDvSetRSPINF(struct vnt_private *, u8); -void vUpdateIFS(struct vnt_private *); void CARDvUpdateBasicTopRate(struct vnt_private *); bool CARDbIsOFDMinBasicRate(struct vnt_private *); void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 2e3178429437..13923326a34a 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1485,7 +1485,6 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, else priv->bShortSlotTime = false; - vUpdateIFS(priv); CARDbSetPhyParameter(priv, priv->byBBType); BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]); } -- cgit v1.2.3-59-g8ed1b From 738487ffc53d9f3e9a2564551fc877f9d377d11f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:09 +0000 Subject: staging: vt6655: card.c move __iomem into functions. Removing dereferencing from callers Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 18 ++++++++++++------ drivers/staging/vt6655/card.h | 8 ++++---- drivers/staging/vt6655/device_main.c | 7 +++---- drivers/staging/vt6655/rxtx.c | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index a93ca160dda7..a0796405c308 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -394,7 +394,7 @@ bool CARDbSetBeaconPeriod(struct vnt_private *pDevice, { u64 qwNextTBTT = 0; - CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); /* Get Local TSF counter */ + CARDbGetCurrentTSF(pDevice, &qwNextTBTT); /* Get Local TSF counter */ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); @@ -828,8 +828,10 @@ unsigned char CARDbyGetPktType(struct vnt_private *pDevice) * * Return Value: none */ -void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode) +void CARDvSetLoopbackMode(struct vnt_private *priv, unsigned short wLoopbackMode) { + void __iomem *dwIoBase = priv->PortOffset; + switch (wLoopbackMode) { case CARD_LB_NONE: case CARD_LB_MAC: @@ -905,8 +907,9 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) * * Return Value: true if success; otherwise false */ -bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF) +bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) { + void __iomem *dwIoBase = priv->PortOffset; unsigned short ww; unsigned char byData; @@ -964,11 +967,12 @@ u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval) * * Return Value: none */ -void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval) +void CARDvSetFirstNextTBTT(struct vnt_private *priv, unsigned short wBeaconInterval) { + void __iomem *dwIoBase = priv->PortOffset; u64 qwNextTBTT = 0; - CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); /* Get Local TSF counter */ + CARDbGetCurrentTSF(priv, &qwNextTBTT); /* Get Local TSF counter */ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); /* Set NextTBTT */ @@ -991,8 +995,10 @@ void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterva * * Return Value: none */ -void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeaconInterval) +void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 qwTSF, unsigned short wBeaconInterval) { + void __iomem *dwIoBase = priv->PortOffset; + qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); /* Set NextTBTT */ VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwTSF); diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 2e567104ded4..2dfc41952271 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -69,11 +69,11 @@ struct vnt_private; void CARDvSetRSPINF(struct vnt_private *, u8); void CARDvUpdateBasicTopRate(struct vnt_private *); bool CARDbIsOFDMinBasicRate(struct vnt_private *); -void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode); +void CARDvSetLoopbackMode(struct vnt_private *, unsigned short wLoopbackMode); bool CARDbSoftwareReset(struct vnt_private *); -void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval); -void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeaconInterval); -bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF); +void CARDvSetFirstNextTBTT(struct vnt_private *, unsigned short wBeaconInterval); +void CARDvUpdateNextTBTT(struct vnt_private *, u64 qwTSF, unsigned short wBeaconInterval); +bool CARDbGetCurrentTSF(struct vnt_private *, u64 *pqwCurrTSF); u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval); u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2); unsigned char CARDbyGetPktType(struct vnt_private *); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 13923326a34a..83e4162c0094 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1513,8 +1513,7 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, CARDbSetBeaconPeriod(priv, conf->beacon_int); - CARDvSetFirstNextTBTT(priv->PortOffset, - conf->beacon_int); + CARDvSetFirstNextTBTT(priv, conf->beacon_int); } else { VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); @@ -1633,7 +1632,7 @@ static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct vnt_private *priv = hw->priv; u64 tsf; - CARDbGetCurrentTSF(priv->PortOffset, &tsf); + CARDbGetCurrentTSF(priv, &tsf); return tsf; } @@ -1643,7 +1642,7 @@ static void vnt_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, { struct vnt_private *priv = hw->priv; - CARDvUpdateNextTBTT(priv->PortOffset, tsf, vif->bss_conf.beacon_int); + CARDvUpdateNextTBTT(priv, tsf, vif->bss_conf.beacon_int); } static void vnt_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index f4da7e76f658..4189405bb238 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1521,7 +1521,7 @@ int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif, VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); - CARDvSetFirstNextTBTT(priv->PortOffset, conf->beacon_int); + CARDvSetFirstNextTBTT(priv, conf->beacon_int); CARDbSetBeaconPeriod(priv, conf->beacon_int); -- cgit v1.2.3-59-g8ed1b From 817c985ba185ffc75db1d27856fc0344c8429053 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:10 +0000 Subject: staging: vt6655: rf remove __iomem *dwIoBase from functions replacing with vnt_private and removing dereferencing from callers Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 8 +++++--- drivers/staging/vt6655/rf.c | 25 ++++++++++++++++--------- drivers/staging/vt6655/rf.h | 6 +++--- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index cc1bc94ceaa3..c8f739dd346e 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -188,14 +188,16 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) /* TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput */ if (pDevice->byRFType == RF_AIROHA7230) - RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (unsigned char)uConnectionChannel); + RFbAL7230SelectChannelPostProcess(pDevice, pDevice->byCurrentCh, + (unsigned char)uConnectionChannel); pDevice->byCurrentCh = (unsigned char)uConnectionChannel; - bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (unsigned char)uConnectionChannel); + bResult &= RFbSelectChannel(pDevice, pDevice->byRFType, + (unsigned char)uConnectionChannel); /* Init Synthesizer Table */ if (pDevice->bEnablePSMode) - RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel); + RFvWriteWakeProgSyn(pDevice, pDevice->byRFType, uConnectionChannel); BBvSoftwareReset(pDevice); diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 2b1e7a09360e..da2c5e65bbe9 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -468,8 +468,9 @@ static bool s_bAL7230Init(struct vnt_private *priv) } // Need to Pull PLLON low when writing channel registers through 3-wire interface -static bool s_bAL7230SelectChannel(void __iomem *dwIoBase, unsigned char byChannel) +static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byChannel) { + void __iomem *dwIoBase = priv->PortOffset; bool bResult; bResult = true; @@ -627,8 +628,9 @@ bool IFRFbWriteEmbedded(void __iomem *dwIoBase, unsigned long dwData) * Return Value: true if succeeded; false if failed. * */ -static bool RFbAL2230Init(void __iomem *dwIoBase) +static bool RFbAL2230Init(struct vnt_private *priv) { + void __iomem *dwIoBase = priv->PortOffset; int ii; bool bResult; @@ -674,8 +676,9 @@ static bool RFbAL2230Init(void __iomem *dwIoBase) return bResult; } -static bool RFbAL2230SelectChannel(void __iomem *dwIoBase, unsigned char byChannel) +static bool RFbAL2230SelectChannel(struct vnt_private *priv, unsigned char byChannel) { + void __iomem *dwIoBase = priv->PortOffset; bool bResult; bResult = true; @@ -756,7 +759,7 @@ bool RFbInit( case RF_AIROHA: case RF_AL2230S: pDevice->byMaxPwrLevel = AL2230_PWR_IDX_LEN; - bResult = RFbAL2230Init(pDevice->PortOffset); + bResult = RFbAL2230Init(pDevice); break; case RF_AIROHA7230: pDevice->byMaxPwrLevel = AL7230_PWR_IDX_LEN; @@ -785,18 +788,18 @@ bool RFbInit( * Return Value: true if succeeded; false if failed. * */ -bool RFbSelectChannel(void __iomem *dwIoBase, unsigned char byRFType, unsigned char byChannel) +bool RFbSelectChannel(struct vnt_private *priv, unsigned char byRFType, unsigned char byChannel) { bool bResult = true; switch (byRFType) { case RF_AIROHA: case RF_AL2230S: - bResult = RFbAL2230SelectChannel(dwIoBase, byChannel); + bResult = RFbAL2230SelectChannel(priv, byChannel); break; //{{ RobertYu: 20050104 case RF_AIROHA7230: - bResult = s_bAL7230SelectChannel(dwIoBase, byChannel); + bResult = s_bAL7230SelectChannel(priv, byChannel); break; //}} RobertYu case RF_NOTHING: @@ -821,8 +824,9 @@ bool RFbSelectChannel(void __iomem *dwIoBase, unsigned char byRFType, unsigned c * Return Value: None. * */ -bool RFvWriteWakeProgSyn(void __iomem *dwIoBase, unsigned char byRFType, unsigned int uChannel) +bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, unsigned int uChannel) { + void __iomem *dwIoBase = priv->PortOffset; int ii; unsigned char byInitCount = 0; unsigned char bySleepCount = 0; @@ -1071,8 +1075,11 @@ RFvRSSITodBm( // Post processing for the 11b/g and 11a. // for save time on changing Reg2,3,5,7,10,12,15 -bool RFbAL7230SelectChannelPostProcess(void __iomem *dwIoBase, unsigned char byOldChannel, unsigned char byNewChannel) +bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, + unsigned char byOldChannel, + unsigned char byNewChannel) { + void __iomem *dwIoBase = priv->PortOffset; bool bResult; bResult = true; diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index e8a7372e5483..98c2326dcd48 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -74,11 +74,11 @@ /*--------------------- Export Functions --------------------------*/ bool IFRFbWriteEmbedded(void __iomem *dwIoBase, unsigned long dwData); -bool RFbSelectChannel(void __iomem *dwIoBase, unsigned char byRFType, unsigned char byChannel); +bool RFbSelectChannel(struct vnt_private *, unsigned char byRFType, unsigned char byChannel); bool RFbInit( struct vnt_private * ); -bool RFvWriteWakeProgSyn(void __iomem *dwIoBase, unsigned char byRFType, unsigned int uChannel); +bool RFvWriteWakeProgSyn(struct vnt_private *, unsigned char byRFType, unsigned int uChannel); bool RFbSetPower(struct vnt_private *, unsigned int uRATE, unsigned int uCH); bool RFbRawSetPower( struct vnt_private *, @@ -94,7 +94,7 @@ RFvRSSITodBm( ); //{{ RobertYu: 20050104 -bool RFbAL7230SelectChannelPostProcess(void __iomem *dwIoBase, unsigned char byOldChannel, unsigned char byNewChannel); +bool RFbAL7230SelectChannelPostProcess(struct vnt_private *, unsigned char byOldChannel, unsigned char byNewChannel); //}} RobertYu #endif // __RF_H__ -- cgit v1.2.3-59-g8ed1b From b310a0cdc2be93584c28681edf4ae66e3ebe0f64 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:11 +0000 Subject: staging: vt6655: IFRFbWriteEmbedded replace __iomem with vnt_private Fixing callers to vnt_private Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rf.c | 85 +++++++++++++++++++++++---------------------- drivers/staging/vt6655/rf.h | 2 +- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index da2c5e65bbe9..3b7ad493cd1b 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -440,18 +440,21 @@ static bool s_bAL7230Init(struct vnt_private *priv) BBvPowerSaveModeOFF(priv); /* RobertYu:20050106, have DC value for Calibration */ for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[ii]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[ii]); // PLL On MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); //Calibration MACvTimer0MicroSDelay(dwIoBase, 150);//150us - bResult &= IFRFbWriteEmbedded(dwIoBase, (0x9ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); //TXDCOC:active, RCK:disable + /* TXDCOC:active, RCK:disable */ + bResult &= IFRFbWriteEmbedded(priv, (0x9ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); MACvTimer0MicroSDelay(dwIoBase, 30);//30us - bResult &= IFRFbWriteEmbedded(dwIoBase, (0x3ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); //TXDCOC:disable, RCK:active + /* TXDCOC:disable, RCK:active */ + bResult &= IFRFbWriteEmbedded(priv, (0x3ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); MACvTimer0MicroSDelay(dwIoBase, 30);//30us - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[CB_AL7230_INIT_SEQ-1]); //TXDCOC:disable, RCK:disable + /* TXDCOC:disable, RCK:disable */ + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[CB_AL7230_INIT_SEQ-1]); MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 | SOFTPWRCTL_SWPE2 | @@ -478,9 +481,9 @@ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byCha // PLLON Off MACvWordRegBitsOff(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230ChannelTable0[byChannel - 1]); //Reg0 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230ChannelTable1[byChannel - 1]); //Reg1 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230ChannelTable2[byChannel - 1]); //Reg4 + bResult &= IFRFbWriteEmbedded(priv, dwAL7230ChannelTable0[byChannel - 1]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230ChannelTable1[byChannel - 1]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230ChannelTable2[byChannel - 1]); // PLLOn On MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); @@ -569,8 +572,9 @@ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byCha * Return Value: true if succeeded; false if failed. * */ -bool IFRFbWriteEmbedded(void __iomem *dwIoBase, unsigned long dwData) +bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData) { + void __iomem *dwIoBase = priv->PortOffset; unsigned short ww; unsigned long dwValue; @@ -648,10 +652,10 @@ static bool RFbAL2230Init(struct vnt_private *priv) //patch abnormal AL2230 frequency output //2008-8-21 chester - IFRFbWriteEmbedded(dwIoBase, (0x07168700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); + IFRFbWriteEmbedded(priv, (0x07168700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++) - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL2230InitTable[ii]); + bResult &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[ii]); //2008-8-21 chester MACvTimer0MicroSDelay(dwIoBase, 30); //delay 30 us @@ -659,11 +663,11 @@ static bool RFbAL2230Init(struct vnt_private *priv) MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); MACvTimer0MicroSDelay(dwIoBase, 150);//150us - bResult &= IFRFbWriteEmbedded(dwIoBase, (0x00d80f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); + bResult &= IFRFbWriteEmbedded(priv, (0x00d80f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); MACvTimer0MicroSDelay(dwIoBase, 30);//30us - bResult &= IFRFbWriteEmbedded(dwIoBase, (0x00780f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); + bResult &= IFRFbWriteEmbedded(priv, (0x00780f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); MACvTimer0MicroSDelay(dwIoBase, 30);//30us - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL2230InitTable[CB_AL2230_INIT_SEQ-1]); + bResult &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[CB_AL2230_INIT_SEQ-1]); MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 | SOFTPWRCTL_SWPE2 | @@ -683,8 +687,8 @@ static bool RFbAL2230SelectChannel(struct vnt_private *priv, unsigned char byCha bResult = true; - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL2230ChannelTable0[byChannel - 1]); - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL2230ChannelTable1[byChannel - 1]); + bResult &= IFRFbWriteEmbedded(priv, dwAL2230ChannelTable0[byChannel - 1]); + bResult &= IFRFbWriteEmbedded(priv, dwAL2230ChannelTable1[byChannel - 1]); // Set Channel[7] = 0 to tell H/W channel is changing now. VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel & 0x7F)); @@ -996,22 +1000,22 @@ bool RFbRawSetPower( switch (pDevice->byRFType) { case RF_AIROHA: - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, dwAL2230PowerTable[byPwr]); + bResult &= IFRFbWriteEmbedded(pDevice, dwAL2230PowerTable[byPwr]); if (uRATE <= RATE_11M) - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(pDevice, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); else - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(pDevice, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); break; case RF_AL2230S: - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, dwAL2230PowerTable[byPwr]); + bResult &= IFRFbWriteEmbedded(pDevice, dwAL2230PowerTable[byPwr]); if (uRATE <= RATE_11M) { - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(pDevice, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(pDevice, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); } else { - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(pDevice, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(pDevice, 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); } break; @@ -1021,7 +1025,7 @@ bool RFbRawSetPower( dwMax7230Pwr = 0x080C0B00 | ((byPwr) << 12) | (BY_AL7230_REG_LEN << 3) | IFREGCTL_REGW; - bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, dwMax7230Pwr); + bResult &= IFRFbWriteEmbedded(pDevice, dwMax7230Pwr); break; default: @@ -1079,7 +1083,6 @@ bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, unsigned char byOldChannel, unsigned char byNewChannel) { - void __iomem *dwIoBase = priv->PortOffset; bool bResult; bResult = true; @@ -1088,23 +1091,23 @@ bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, // Channel Index 1~14 if ((byOldChannel <= CB_MAX_CHANNEL_24G) && (byNewChannel > CB_MAX_CHANNEL_24G)) { - // Change from 2.4G to 5G - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[2]); //Reg2 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[3]); //Reg3 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[5]); //Reg5 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[7]); //Reg7 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[10]);//Reg10 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[12]);//Reg12 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTableAMode[15]);//Reg15 + /* Change from 2.4G to 5G [Reg] */ + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[2]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[3]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[5]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[7]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[10]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[12]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[15]); } else if ((byOldChannel > CB_MAX_CHANNEL_24G) && (byNewChannel <= CB_MAX_CHANNEL_24G)) { - // change from 5G to 2.4G - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[2]); //Reg2 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[3]); //Reg3 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[5]); //Reg5 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[7]); //Reg7 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[10]);//Reg10 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[12]);//Reg12 - bResult &= IFRFbWriteEmbedded(dwIoBase, dwAL7230InitTable[15]);//Reg15 + /* Change from 5G to 2.4G [Reg] */ + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[2]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[3]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[5]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[7]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[10]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[12]); + bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[15]); } return bResult; diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index 98c2326dcd48..8a6e2cfedaa5 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -73,7 +73,7 @@ /*--------------------- Export Functions --------------------------*/ -bool IFRFbWriteEmbedded(void __iomem *dwIoBase, unsigned long dwData); +bool IFRFbWriteEmbedded(struct vnt_private *, unsigned long dwData); bool RFbSelectChannel(struct vnt_private *, unsigned char byRFType, unsigned char byChannel); bool RFbInit( struct vnt_private * -- cgit v1.2.3-59-g8ed1b From ac3e134af262a74c4c9b0857cd6b4e1cbcddc783 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:12 +0000 Subject: staging: vt6655: rf.c camel calse vnt_private rename pDevice to priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rf.c | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 3b7ad493cd1b..798dfb77608a 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -754,20 +754,20 @@ static bool RFbAL2230SelectChannel(struct vnt_private *priv, unsigned char byCha * */ bool RFbInit( - struct vnt_private *pDevice + struct vnt_private *priv ) { bool bResult = true; - switch (pDevice->byRFType) { + switch (priv->byRFType) { case RF_AIROHA: case RF_AL2230S: - pDevice->byMaxPwrLevel = AL2230_PWR_IDX_LEN; - bResult = RFbAL2230Init(pDevice); + priv->byMaxPwrLevel = AL2230_PWR_IDX_LEN; + bResult = RFbAL2230Init(priv); break; case RF_AIROHA7230: - pDevice->byMaxPwrLevel = AL7230_PWR_IDX_LEN; - bResult = s_bAL7230Init(pDevice); + priv->byMaxPwrLevel = AL7230_PWR_IDX_LEN; + bResult = s_bAL7230Init(priv); break; case RF_NOTHING: bResult = true; @@ -906,7 +906,7 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, unsig * */ bool RFbSetPower( - struct vnt_private *pDevice, + struct vnt_private *priv, unsigned int uRATE, unsigned int uCH ) @@ -916,7 +916,7 @@ bool RFbSetPower( unsigned char byDec = 0; unsigned char byPwrdBm = 0; - if (pDevice->dwDiagRefCount != 0) + if (priv->dwDiagRefCount != 0) return true; if ((uCH < 1) || (uCH > CB_MAX_CHANNEL)) @@ -927,22 +927,22 @@ bool RFbSetPower( case RATE_2M: case RATE_5M: case RATE_11M: - byPwr = pDevice->abyCCKPwrTbl[uCH]; - byPwrdBm = pDevice->abyCCKDefaultPwr[uCH]; + byPwr = priv->abyCCKPwrTbl[uCH]; + byPwrdBm = priv->abyCCKDefaultPwr[uCH]; break; case RATE_6M: case RATE_9M: case RATE_18M: - byPwr = pDevice->abyOFDMPwrTbl[uCH]; - if (pDevice->byRFType == RF_UW2452) + byPwr = priv->abyOFDMPwrTbl[uCH]; + if (priv->byRFType == RF_UW2452) byDec = byPwr + 14; else byDec = byPwr + 10; - if (byDec >= pDevice->byMaxPwrLevel) - byDec = pDevice->byMaxPwrLevel-1; + if (byDec >= priv->byMaxPwrLevel) + byDec = priv->byMaxPwrLevel-1; - if (pDevice->byRFType == RF_UW2452) { + if (priv->byRFType == RF_UW2452) { byPwrdBm = byDec - byPwr; byPwrdBm /= 3; } else { @@ -950,24 +950,24 @@ bool RFbSetPower( byPwrdBm >>= 1; } - byPwrdBm += pDevice->abyOFDMDefaultPwr[uCH]; + byPwrdBm += priv->abyOFDMDefaultPwr[uCH]; byPwr = byDec; break; case RATE_24M: case RATE_36M: case RATE_48M: case RATE_54M: - byPwr = pDevice->abyOFDMPwrTbl[uCH]; - byPwrdBm = pDevice->abyOFDMDefaultPwr[uCH]; + byPwr = priv->abyOFDMPwrTbl[uCH]; + byPwrdBm = priv->abyOFDMDefaultPwr[uCH]; break; } - if (pDevice->byCurPwr == byPwr) + if (priv->byCurPwr == byPwr) return true; - bResult = RFbRawSetPower(pDevice, byPwr, uRATE); + bResult = RFbRawSetPower(priv, byPwr, uRATE); if (bResult) - pDevice->byCurPwr = byPwr; + priv->byCurPwr = byPwr; return bResult; } @@ -987,7 +987,7 @@ bool RFbSetPower( */ bool RFbRawSetPower( - struct vnt_private *pDevice, + struct vnt_private *priv, unsigned char byPwr, unsigned int uRATE ) @@ -995,27 +995,27 @@ bool RFbRawSetPower( bool bResult = true; unsigned long dwMax7230Pwr = 0; - if (byPwr >= pDevice->byMaxPwrLevel) + if (byPwr >= priv->byMaxPwrLevel) return false; - switch (pDevice->byRFType) { + switch (priv->byRFType) { case RF_AIROHA: - bResult &= IFRFbWriteEmbedded(pDevice, dwAL2230PowerTable[byPwr]); + bResult &= IFRFbWriteEmbedded(priv, dwAL2230PowerTable[byPwr]); if (uRATE <= RATE_11M) - bResult &= IFRFbWriteEmbedded(pDevice, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(priv, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); else - bResult &= IFRFbWriteEmbedded(pDevice, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(priv, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); break; case RF_AL2230S: - bResult &= IFRFbWriteEmbedded(pDevice, dwAL2230PowerTable[byPwr]); + bResult &= IFRFbWriteEmbedded(priv, dwAL2230PowerTable[byPwr]); if (uRATE <= RATE_11M) { - bResult &= IFRFbWriteEmbedded(pDevice, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); - bResult &= IFRFbWriteEmbedded(pDevice, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(priv, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(priv, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); } else { - bResult &= IFRFbWriteEmbedded(pDevice, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); - bResult &= IFRFbWriteEmbedded(pDevice, 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(priv, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); + bResult &= IFRFbWriteEmbedded(priv, 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); } break; @@ -1025,7 +1025,7 @@ bool RFbRawSetPower( dwMax7230Pwr = 0x080C0B00 | ((byPwr) << 12) | (BY_AL7230_REG_LEN << 3) | IFREGCTL_REGW; - bResult &= IFRFbWriteEmbedded(pDevice, dwMax7230Pwr); + bResult &= IFRFbWriteEmbedded(priv, dwMax7230Pwr); break; default: @@ -1041,7 +1041,7 @@ bool RFbRawSetPower( * * Parameters: * In: - * pDevice - The adapter to be translated + * priv - The adapter to be translated * byCurrRSSI - RSSI to be translated * Out: * pdwdbm - Translated dbm number @@ -1051,7 +1051,7 @@ bool RFbRawSetPower( -*/ void RFvRSSITodBm( - struct vnt_private *pDevice, + struct vnt_private *priv, unsigned char byCurrRSSI, long *pldBm ) @@ -1061,7 +1061,7 @@ RFvRSSITodBm( long a = 0; unsigned char abyAIROHARF[4] = {0, 18, 0, 40}; - switch (pDevice->byRFType) { + switch (priv->byRFType) { case RF_AIROHA: case RF_AL2230S: case RF_AIROHA7230: //RobertYu: 20040104 -- cgit v1.2.3-59-g8ed1b From 0a5ea1e3527d440afdc336308bbef366094f3b31 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:13 +0000 Subject: staging: vt6655: rf.c: Remove author comments Moving names to file header comment Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rf.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 798dfb77608a..87d97da3d9e1 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -29,6 +29,8 @@ * IFRFbWriteEmbedded - Embedded write RF register via MAC * * Revision History: + * RobertYu 2005 + * chester 2008 * */ @@ -172,7 +174,6 @@ static unsigned long dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = { 0x0407F900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW }; -//{{ RobertYu:20050104 // 40MHz reference frequency // Need to Pull PLLON(PE3) low when writing channel registers through 3-wire. static const unsigned long dwAL7230InitTable[CB_AL7230_INIT_SEQ] = { @@ -408,7 +409,6 @@ static const unsigned long dwAL7230ChannelTable2[CB_MAX_CHANNEL] = { 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55) 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // channel = 165, Tf = 5825MHz (56) }; -//}} RobertYu /*--------------------- Static Functions --------------------------*/ @@ -511,7 +511,6 @@ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byCha * */ -//{{ RobertYu: 20041210 /* * Description: UW2452 IFRF chip init function * @@ -525,9 +524,6 @@ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byCha * */ -//}} RobertYu -//////////////////////////////////////////////////////////////////////////////// - /* * Description: VT3226 IFRF chip init function * @@ -645,18 +641,15 @@ static bool RFbAL2230Init(struct vnt_private *priv) MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPECTI | SOFTPWRCTL_TXPEINV)); -//2008-8-21 chester // PLL Off MACvWordRegBitsOff(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); //patch abnormal AL2230 frequency output -//2008-8-21 chester IFRFbWriteEmbedded(priv, (0x07168700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++) bResult &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[ii]); -//2008-8-21 chester MACvTimer0MicroSDelay(dwIoBase, 30); //delay 30 us // PLL On @@ -856,7 +849,6 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, unsig MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230ChannelTable1[uChannel-1]); break; - //{{ RobertYu: 20050104 // Need to check, PLLON need to be low for channel setting case RF_AIROHA7230: byInitCount = CB_AL7230_INIT_SEQ + 3; // Init Reg + Channel Reg (3) @@ -878,7 +870,6 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, unsig ii++; MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230ChannelTable2[uChannel-1]); break; - //}} RobertYu case RF_NOTHING: return true; @@ -1064,7 +1055,7 @@ RFvRSSITodBm( switch (priv->byRFType) { case RF_AIROHA: case RF_AL2230S: - case RF_AIROHA7230: //RobertYu: 20040104 + case RF_AIROHA7230: a = abyAIROHARF[byIdx]; break; default: @@ -1074,9 +1065,6 @@ RFvRSSITodBm( *pldBm = -1 * (a + b * 2); } -//////////////////////////////////////////////////////////////////////////////// -//{{ RobertYu: 20050104 - // Post processing for the 11b/g and 11a. // for save time on changing Reg2,3,5,7,10,12,15 bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, @@ -1112,6 +1100,3 @@ bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, return bResult; } - -//}} RobertYu -//////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3-59-g8ed1b From 7eb1570ff7ea285df555055e0544e702d079b425 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:14 +0000 Subject: staging: vt6655: rf.c Removed unneeded comments Type and function that are not present comments Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rf.c | 134 -------------------------------------------- 1 file changed, 134 deletions(-) diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 87d97da3d9e1..0b16ebfc3f8e 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -39,8 +39,6 @@ #include "rf.h" #include "baseband.h" -/*--------------------- Static Definitions -------------------------*/ - #define BY_AL2230_REG_LEN 23 //24bit #define CB_AL2230_INIT_SEQ 15 #define SWITCH_CHANNEL_DELAY_AL2230 200 //us @@ -51,10 +49,6 @@ #define SWITCH_CHANNEL_DELAY_AL7230 200 //us #define AL7230_PWR_IDX_LEN 64 -/*--------------------- Static Classes ----------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - static const unsigned long dwAL2230InitTable[CB_AL2230_INIT_SEQ] = { 0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // 0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // @@ -410,8 +404,6 @@ static const unsigned long dwAL7230ChannelTable2[CB_MAX_CHANNEL] = { 0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW // channel = 165, Tf = 5825MHz (56) }; -/*--------------------- Static Functions --------------------------*/ - /* * Description: AIROHA IFRF chip init function * @@ -497,64 +489,6 @@ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byCha return bResult; } -/* - * Description: Select channel with UW2452 chip - * - * Parameters: - * In: - * dwIoBase - I/O base address - * uChannel - Channel number - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/* - * Description: UW2452 IFRF chip init function - * - * Parameters: - * In: - * dwIoBase - I/O base address - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/* - * Description: VT3226 IFRF chip init function - * - * Parameters: - * In: - * dwIoBase - I/O base address - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/* - * Description: Select channel with VT3226 chip - * - * Parameters: - * In: - * dwIoBase - I/O base address - * uChannel - Channel number - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ - /* * Description: Write to IF/RF, by embedded programming * @@ -589,33 +523,6 @@ bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData) return true; } -/* - * Description: RFMD RF2959 IFRF chip init function - * - * Parameters: - * In: - * dwIoBase - I/O base address - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/* - * Description: Select channel with RFMD 2959 chip - * - * Parameters: - * In: - * dwIoBase - I/O base address - * uChannel - Channel number - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - /* * Description: AIROHA IFRF chip init function * @@ -692,47 +599,6 @@ static bool RFbAL2230SelectChannel(struct vnt_private *priv, unsigned char byCha return bResult; } -/* - * Description: UW2451 IFRF chip init function - * - * Parameters: - * In: - * dwIoBase - I/O base address - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/* - * Description: Select channel with UW2451 chip - * - * Parameters: - * In: - * dwIoBase - I/O base address - * uChannel - Channel number - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - -/* - * Description: Set sleep mode to UW2451 chip - * - * Parameters: - * In: - * dwIoBase - I/O base address - * uChannel - Channel number - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ - /* * Description: RF init function * -- cgit v1.2.3-59-g8ed1b From 74ed42c73d7b3819d2c80164840aa8f00be3975d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 12 Nov 2014 21:11:15 +0000 Subject: staging: vt6655: rf.c clean up function comments Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rf.c | 59 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 0b16ebfc3f8e..32ef99341e20 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -424,7 +424,7 @@ static bool s_bAL7230Init(struct vnt_private *priv) bResult = true; - //3-wire control for normal mode + /* 3-wire control for normal mode */ VNSvOutPortB(dwIoBase + MAC_REG_SOFTPWRCTL, 0); MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPECTI | @@ -434,10 +434,10 @@ static bool s_bAL7230Init(struct vnt_private *priv) for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[ii]); - // PLL On + /* PLL On */ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); - //Calibration + /* Calibration */ MACvTimer0MicroSDelay(dwIoBase, 150);//150us /* TXDCOC:active, RCK:disable */ bResult &= IFRFbWriteEmbedded(priv, (0x9ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW)); @@ -455,14 +455,15 @@ static bool s_bAL7230Init(struct vnt_private *priv) BBvPowerSaveModeON(priv); /* RobertYu:20050106 */ - // PE1: TX_ON, PE2: RX_ON, PE3: PLLON - //3-wire control for power saving mode + /* PE1: TX_ON, PE2: RX_ON, PE3: PLLON */ + /* 3-wire control for power saving mode */ VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); //1100 0000 return bResult; } -// Need to Pull PLLON low when writing channel registers through 3-wire interface +/* Need to Pull PLLON low when writing channel registers through + * 3-wire interface */ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byChannel) { void __iomem *dwIoBase = priv->PortOffset; @@ -470,20 +471,20 @@ static bool s_bAL7230SelectChannel(struct vnt_private *priv, unsigned char byCha bResult = true; - // PLLON Off + /* PLLON Off */ MACvWordRegBitsOff(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); bResult &= IFRFbWriteEmbedded(priv, dwAL7230ChannelTable0[byChannel - 1]); bResult &= IFRFbWriteEmbedded(priv, dwAL7230ChannelTable1[byChannel - 1]); bResult &= IFRFbWriteEmbedded(priv, dwAL7230ChannelTable2[byChannel - 1]); - // PLLOn On + /* PLLOn On */ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); - // Set Channel[7] = 0 to tell H/W channel is changing now. + /* Set Channel[7] = 0 to tell H/W channel is changing now. */ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel & 0x7F)); MACvTimer0MicroSDelay(dwIoBase, SWITCH_CHANNEL_DELAY_AL7230); - // Set Channel[7] = 1 to tell H/W channel change is done. + /* Set Channel[7] = 1 to tell H/W channel change is done. */ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel | 0x80)); return bResult; @@ -510,7 +511,7 @@ bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData) VNSvOutPortD(dwIoBase + MAC_REG_IFREGCTL, dwData); - // W_MAX_TIMEOUT is the timeout period + /* W_MAX_TIMEOUT is the timeout period */ for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { VNSvInPortD(dwIoBase + MAC_REG_IFREGCTL, &dwValue); if (dwValue & IFREGCTL_DONE) @@ -543,23 +544,22 @@ static bool RFbAL2230Init(struct vnt_private *priv) bResult = true; - //3-wire control for normal mode + /* 3-wire control for normal mode */ VNSvOutPortB(dwIoBase + MAC_REG_SOFTPWRCTL, 0); MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPECTI | SOFTPWRCTL_TXPEINV)); - // PLL Off - + /* PLL Off */ MACvWordRegBitsOff(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); - //patch abnormal AL2230 frequency output + /* patch abnormal AL2230 frequency output */ IFRFbWriteEmbedded(priv, (0x07168700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW)); for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++) bResult &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[ii]); MACvTimer0MicroSDelay(dwIoBase, 30); //delay 30 us - // PLL On + /* PLL On */ MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); MACvTimer0MicroSDelay(dwIoBase, 150);//150us @@ -574,7 +574,7 @@ static bool RFbAL2230Init(struct vnt_private *priv) SOFTPWRCTL_SWPECTI | SOFTPWRCTL_TXPEINV)); - //3-wire control for power saving mode + /* 3-wire control for power saving mode */ VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); //1100 0000 return bResult; @@ -590,10 +590,10 @@ static bool RFbAL2230SelectChannel(struct vnt_private *priv, unsigned char byCha bResult &= IFRFbWriteEmbedded(priv, dwAL2230ChannelTable0[byChannel - 1]); bResult &= IFRFbWriteEmbedded(priv, dwAL2230ChannelTable1[byChannel - 1]); - // Set Channel[7] = 0 to tell H/W channel is changing now. + /* Set Channel[7] = 0 to tell H/W channel is changing now. */ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel & 0x7F)); MACvTimer0MicroSDelay(dwIoBase, SWITCH_CHANNEL_DELAY_AL2230); - // Set Channel[7] = 1 to tell H/W channel change is done. + /* Set Channel[7] = 1 to tell H/W channel change is done. */ VNSvOutPortB(dwIoBase + MAC_REG_CHANNEL, (byChannel | 0x80)); return bResult; @@ -702,7 +702,8 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, unsig if (uChannel > CB_MAX_CHANNEL_24G) return false; - byInitCount = CB_AL2230_INIT_SEQ + 2; // Init Reg + Channel Reg (2) + /* Init Reg + Channel Reg (2) */ + byInitCount = CB_AL2230_INIT_SEQ + 2; bySleepCount = 0; if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) return false; @@ -715,9 +716,10 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, unsig MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230ChannelTable1[uChannel-1]); break; - // Need to check, PLLON need to be low for channel setting + /* Need to check, PLLON need to be low for channel setting */ case RF_AIROHA7230: - byInitCount = CB_AL7230_INIT_SEQ + 3; // Init Reg + Channel Reg (3) + /* Init Reg + Channel Reg (3) */ + byInitCount = CB_AL7230_INIT_SEQ + 3; bySleepCount = 0; if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) return false; @@ -878,7 +880,8 @@ bool RFbRawSetPower( break; case RF_AIROHA7230: - // 0x080F1B00 for 3 wire control TxGain(D10) and 0x31 as TX Gain value + /* 0x080F1B00 for 3 wire control TxGain(D10) + * and 0x31 as TX Gain value */ dwMax7230Pwr = 0x080C0B00 | ((byPwr) << 12) | (BY_AL7230_REG_LEN << 3) | IFREGCTL_REGW; @@ -931,8 +934,8 @@ RFvRSSITodBm( *pldBm = -1 * (a + b * 2); } -// Post processing for the 11b/g and 11a. -// for save time on changing Reg2,3,5,7,10,12,15 +/* Post processing for the 11b/g and 11a. + * for save time on changing Reg2,3,5,7,10,12,15 */ bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, unsigned char byOldChannel, unsigned char byNewChannel) @@ -941,9 +944,9 @@ bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, bResult = true; - // if change between 11 b/g and 11a need to update the following register - // Channel Index 1~14 - + /* if change between 11 b/g and 11a need to update the following + * register + * Channel Index 1~14 */ if ((byOldChannel <= CB_MAX_CHANNEL_24G) && (byNewChannel > CB_MAX_CHANNEL_24G)) { /* Change from 2.4G to 5G [Reg] */ bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTableAMode[2]); -- cgit v1.2.3-59-g8ed1b From 698f140d67e0a92b6d4606c67fdf42b3853c34b6 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sun, 23 Nov 2014 18:48:15 +0100 Subject: staging: android: ion: Deletion of unnecessary checks before two function calls The functions ion_heap_destroy() and vfree() perform also input parameter validation. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 6 ++---- drivers/staging/android/ion/ion_dummy_driver.c | 6 ++---- drivers/staging/android/ion/tegra/tegra_ion.c | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 8724ef89ce94..296d347660fc 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -263,8 +263,7 @@ err: heap->ops->unmap_dma(heap, buffer); heap->ops->free(buffer); err1: - if (buffer->pages) - vfree(buffer->pages); + vfree(buffer->pages); err2: kfree(buffer); return ERR_PTR(ret); @@ -276,8 +275,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer) buffer->heap->ops->unmap_kernel(buffer->heap, buffer); buffer->heap->ops->unmap_dma(buffer->heap, buffer); buffer->heap->ops->free(buffer); - if (buffer->pages) - vfree(buffer->pages); + vfree(buffer->pages); kfree(buffer); } diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c index f3ea1c31e533..5678870bff48 100644 --- a/drivers/staging/android/ion/ion_dummy_driver.c +++ b/drivers/staging/android/ion/ion_dummy_driver.c @@ -112,10 +112,8 @@ static int __init ion_dummy_init(void) } return 0; err: - for (i = 0; i < dummy_ion_pdata.nr; i++) { - if (heaps[i]) - ion_heap_destroy(heaps[i]); - } + for (i = 0; i < dummy_ion_pdata.nr; ++i) + ion_heap_destroy(heaps[i]); kfree(heaps); if (carveout_ptr) { diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c index 11c7cceb3c7d..5b8ef0e66010 100644 --- a/drivers/staging/android/ion/tegra/tegra_ion.c +++ b/drivers/staging/android/ion/tegra/tegra_ion.c @@ -54,10 +54,8 @@ static int tegra_ion_probe(struct platform_device *pdev) platform_set_drvdata(pdev, idev); return 0; err: - for (i = 0; i < num_heaps; i++) { - if (heaps[i]) - ion_heap_destroy(heaps[i]); - } + for (i = 0; i < num_heaps; ++i) + ion_heap_destroy(heaps[i]); return err; } -- cgit v1.2.3-59-g8ed1b From 030739f52e0ac1a5c12b04d0ee414f612a9c8729 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 7 Nov 2014 22:44:58 +0200 Subject: staging: octeon-ethernet: drop multiple NAPI instances Octeon Ethernet driver is currently trying to wake up multiple CPU cores for parallel NAPI processing when needed, to cope with the fact that all network interfaces are handled through the same receive queue processed by a single core/interrupt (see http://marc.info/?l=linux-kernel&m=137209784914565&w=2). This partially overlaps with generic RPS functionality. Commit a6a39a7fcff5 ("staging: octeon-ethernet: disable load balance for receiving packet when CONFIG_RPS is enabled") already disabled this when RPS is enabled. Let's delete this code altogether as it has issues like packet reordering and potential problems with CPU offlining/onlining. Tested on EdgeRouter Lite. Signed-off-by: Aaro Koskinen Acked-By: David Daney Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rx.c | 109 +++---------------------------- drivers/staging/octeon/ethernet.c | 6 -- drivers/staging/octeon/octeon-ethernet.h | 1 - 3 files changed, 10 insertions(+), 106 deletions(-) diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 44e372f09683..1789a1221007 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -61,66 +61,7 @@ #include -struct cvm_napi_wrapper { - struct napi_struct napi; -} ____cacheline_aligned_in_smp; - -static struct cvm_napi_wrapper cvm_oct_napi[NR_CPUS] __cacheline_aligned_in_smp; - -struct cvm_oct_core_state { - int baseline_cores; - /* - * The number of additional cores that could be processing - * input packets. - */ - atomic_t available_cores; - cpumask_t cpu_state; -} ____cacheline_aligned_in_smp; - -static struct cvm_oct_core_state core_state __cacheline_aligned_in_smp; - -static int cvm_irq_cpu; - -static void cvm_oct_enable_napi(void *_) -{ - int cpu = smp_processor_id(); - napi_schedule(&cvm_oct_napi[cpu].napi); -} - -static void cvm_oct_enable_one_cpu(void) -{ - int v; - int cpu; - - /* Check to see if more CPUs are available for receive processing... */ - v = atomic_sub_if_positive(1, &core_state.available_cores); - if (v < 0) - return; - - /* ... if a CPU is available, Turn on NAPI polling for that CPU. */ - for_each_online_cpu(cpu) { - if (!cpu_test_and_set(cpu, core_state.cpu_state)) { - v = smp_call_function_single(cpu, cvm_oct_enable_napi, - NULL, 0); - if (v) - panic("Can't enable NAPI."); - break; - } - } -} - -static void cvm_oct_no_more_work(void) -{ - int cpu = smp_processor_id(); - - if (cpu == cvm_irq_cpu) { - enable_irq(OCTEON_IRQ_WORKQ0 + pow_receive_group); - return; - } - - cpu_clear(cpu, core_state.cpu_state); - atomic_add(1, &core_state.available_cores); -} +static struct napi_struct cvm_oct_napi; /** * cvm_oct_do_interrupt - interrupt handler. @@ -132,8 +73,7 @@ static irqreturn_t cvm_oct_do_interrupt(int cpl, void *dev_id) { /* Disable the IRQ and start napi_poll. */ disable_irq_nosync(OCTEON_IRQ_WORKQ0 + pow_receive_group); - cvm_irq_cpu = smp_processor_id(); - cvm_oct_enable_napi(NULL); + napi_schedule(&cvm_oct_napi); return IRQ_HANDLED; } @@ -285,23 +225,6 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) cvmx_pow_work_request_async_nocheck(CVMX_SCR_SCRATCH, CVMX_POW_NO_WAIT); did_work_request = 1; } - -#ifndef CONFIG_RPS - if (rx_count == 0) { - /* - * First time through, see if there is enough - * work waiting to merit waking another - * CPU. - */ - union cvmx_pow_wq_int_cntx counts; - int backlog; - int cores_in_use = core_state.baseline_cores - atomic_read(&core_state.available_cores); - counts.u64 = cvmx_read_csr(CVMX_POW_WQ_INT_CNTX(pow_receive_group)); - backlog = counts.s.iq_cnt + counts.s.ds_cnt; - if (backlog > budget * cores_in_use && napi != NULL) - cvm_oct_enable_one_cpu(); - } -#endif rx_count++; skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1; @@ -478,7 +401,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) if (rx_count < budget && napi != NULL) { /* No more work */ napi_complete(napi); - cvm_oct_no_more_work(); + enable_irq(OCTEON_IRQ_WORKQ0 + pow_receive_group); } return rx_count; } @@ -513,18 +436,10 @@ void cvm_oct_rx_initialize(void) if (NULL == dev_for_napi) panic("No net_devices were allocated."); - if (max_rx_cpus >= 1 && max_rx_cpus < num_online_cpus()) - atomic_set(&core_state.available_cores, max_rx_cpus); - else - atomic_set(&core_state.available_cores, num_online_cpus()); - core_state.baseline_cores = atomic_read(&core_state.available_cores); - - core_state.cpu_state = CPU_MASK_NONE; - for_each_possible_cpu(i) { - netif_napi_add(dev_for_napi, &cvm_oct_napi[i].napi, - cvm_oct_napi_poll, rx_napi_weight); - napi_enable(&cvm_oct_napi[i].napi); - } + netif_napi_add(dev_for_napi, &cvm_oct_napi, cvm_oct_napi_poll, + rx_napi_weight); + napi_enable(&cvm_oct_napi); + /* Register an IRQ handler to receive POW interrupts */ i = request_irq(OCTEON_IRQ_WORKQ0 + pow_receive_group, cvm_oct_do_interrupt, 0, "Ethernet", cvm_oct_device); @@ -545,15 +460,11 @@ void cvm_oct_rx_initialize(void) int_pc.s.pc_thr = 5; cvmx_write_csr(CVMX_POW_WQ_INT_PC, int_pc.u64); - - /* Scheduld NAPI now. This will indirectly enable interrupts. */ - cvm_oct_enable_one_cpu(); + /* Schedule NAPI now. This will indirectly enable the interrupt. */ + napi_schedule(&cvm_oct_napi); } void cvm_oct_rx_shutdown(void) { - int i; - /* Shutdown all of the NAPIs */ - for_each_possible_cpu(i) - netif_napi_del(&cvm_oct_napi[i].napi); + netif_napi_del(&cvm_oct_napi); } diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 47d4277dc1ab..ed1bdeaa00ac 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -98,12 +98,6 @@ MODULE_PARM_DESC(pow_send_list, "\n" "\t\"eth2,spi3,spi7\" would cause these three devices to transmit\n" "\tusing the pow_send_group."); -int max_rx_cpus = -1; -module_param(max_rx_cpus, int, 0444); -MODULE_PARM_DESC(max_rx_cpus, "\n" - "\t\tThe maximum number of CPUs to use for packet reception.\n" - "\t\tUse -1 to use all available CPUs."); - int rx_napi_weight = 32; module_param(rx_napi_weight, int, 0444); MODULE_PARM_DESC(rx_napi_weight, "The NAPI WEIGHT parameter."); diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index d0e321119914..f48dc766fada 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -99,7 +99,6 @@ extern struct workqueue_struct *cvm_oct_poll_queue; extern atomic_t cvm_oct_poll_queue_stopping; extern u64 cvm_oct_tx_poll_interval; -extern int max_rx_cpus; extern int rx_napi_weight; #endif -- cgit v1.2.3-59-g8ed1b From 2e6ac45c4af7dfc2225985bdc5ec0514f6d8d29b Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 7 Nov 2014 23:43:33 +0200 Subject: staging: octeon-usb: move helper functions Move helper functions to make them visible to all functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 4337a2fe282e..57ae66b8fd7b 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -456,6 +456,16 @@ struct octeon_temp_buffer { u8 data[0]; }; +static inline struct octeon_hcd *cvmx_usb_to_octeon(struct cvmx_usb_state *p) +{ + return container_of(p, struct octeon_hcd, usb); +} + +static inline struct usb_hcd *octeon_to_hcd(struct octeon_hcd *p) +{ + return container_of((void *)p, struct usb_hcd, hcd_priv); +} + /** * octeon_alloc_temp_buffer - allocate a temporary buffer for USB transfer * (if needed) @@ -2112,16 +2122,6 @@ done: union cvmx_usbcx_gintmsk, sofmsk, need_sof); } -static inline struct octeon_hcd *cvmx_usb_to_octeon(struct cvmx_usb_state *p) -{ - return container_of(p, struct octeon_hcd, usb); -} - -static inline struct usb_hcd *octeon_to_hcd(struct octeon_hcd *p) -{ - return container_of((void *)p, struct usb_hcd, hcd_priv); -} - static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, enum cvmx_usb_complete status, struct cvmx_usb_pipe *pipe, -- cgit v1.2.3-59-g8ed1b From ba0b8e420a7c9527d3f3a7276d48885e9e975fa7 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Fri, 7 Nov 2014 23:43:34 +0200 Subject: staging: octeon-usb: eliminate cvmx_dprintf() usage Eliminate cvmx_dprintf() usage and use dev_err() instead. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 57ae66b8fd7b..fbca966ba72e 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1512,6 +1512,9 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, int channel, struct cvmx_usb_pipe *pipe) { + struct octeon_hcd *priv = cvmx_usb_to_octeon(usb); + struct usb_hcd *hcd = octeon_to_hcd(priv); + struct device *dev = hcd->self.controller; struct cvmx_usb_transaction *transaction = list_first_entry(&pipe->transactions, typeof(*transaction), node); @@ -1528,7 +1531,7 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, switch (transaction->stage) { case CVMX_USB_STAGE_NON_CONTROL: case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: - cvmx_dprintf("%s: ERROR - Non control stage\n", __func__); + dev_err(dev, "%s: ERROR - Non control stage\n", __func__); break; case CVMX_USB_STAGE_SETUP: usbc_hctsiz.s.pid = 3; /* Setup */ @@ -2585,6 +2588,9 @@ static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb) */ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) { + struct octeon_hcd *priv = cvmx_usb_to_octeon(usb); + struct usb_hcd *hcd = octeon_to_hcd(priv); + struct device *dev = hcd->self.controller; union cvmx_usbcx_hcintx usbc_hcint; union cvmx_usbcx_hctsizx usbc_hctsiz; union cvmx_usbcx_hccharx usbc_hcchar; @@ -2642,8 +2648,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * Channel halt isn't needed. */ } else { - cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", - usb->index, channel); + dev_err(dev, "USB%d: Channel %d interrupt without halt\n", + usb->index, channel); return 0; } } -- cgit v1.2.3-59-g8ed1b From fe4d7e2cc9eaf5d3b3885bdbd24080881270557c Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Wed, 12 Nov 2014 02:08:06 +0100 Subject: staging: panel: Reorder initial DEFAULT_* defines Change the order of the initial DEFAULT_* defines so that it matches the Kconfig order. Signed-off-by: Mariusz Gorski Acked-By: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index d30ccb594785..530f7e185231 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -302,14 +302,15 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; /* * Construct custom config from the kernel's configuration */ -#define DEFAULT_PROFILE PANEL_PROFILE_LARGE #define DEFAULT_PARPORT 0 -#define DEFAULT_LCD LCD_TYPE_OLD +#define DEFAULT_PROFILE PANEL_PROFILE_LARGE #define DEFAULT_KEYPAD KEYPAD_TYPE_OLD +#define DEFAULT_LCD LCD_TYPE_OLD +#define DEFAULT_LCD_HEIGHT 2 #define DEFAULT_LCD_WIDTH 40 #define DEFAULT_LCD_BWIDTH 40 #define DEFAULT_LCD_HWIDTH 64 -#define DEFAULT_LCD_HEIGHT 2 +#define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL #define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL #define DEFAULT_LCD_PIN_E PIN_AUTOLF @@ -318,7 +319,6 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #define DEFAULT_LCD_PIN_SCL PIN_STROBE #define DEFAULT_LCD_PIN_SDA PIN_D0 #define DEFAULT_LCD_PIN_BL PIN_NOT_SET -#define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL #ifdef CONFIG_PANEL_PROFILE #undef DEFAULT_PROFILE -- cgit v1.2.3-59-g8ed1b From 1e13e8aa1f88c4ac29f4fde4bfcc39c636e83015 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Wed, 12 Nov 2014 02:08:07 +0100 Subject: staging: panel: Reorder DEFAULT_* values redefines Change the order of the DEFAULT_* values redefines so that it matches the Kconfig order. Signed-off-by: Mariusz Gorski Acked-By: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 530f7e185231..4434c1d948d2 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -320,16 +320,16 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #define DEFAULT_LCD_PIN_SDA PIN_D0 #define DEFAULT_LCD_PIN_BL PIN_NOT_SET -#ifdef CONFIG_PANEL_PROFILE -#undef DEFAULT_PROFILE -#define DEFAULT_PROFILE CONFIG_PANEL_PROFILE -#endif - #ifdef CONFIG_PANEL_PARPORT #undef DEFAULT_PARPORT #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT #endif +#ifdef CONFIG_PANEL_PROFILE +#undef DEFAULT_PROFILE +#define DEFAULT_PROFILE CONFIG_PANEL_PROFILE +#endif + #if DEFAULT_PROFILE == 0 /* custom */ #ifdef CONFIG_PANEL_KEYPAD #undef DEFAULT_KEYPAD @@ -341,6 +341,11 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #define DEFAULT_LCD CONFIG_PANEL_LCD #endif +#ifdef CONFIG_PANEL_LCD_HEIGHT +#undef DEFAULT_LCD_HEIGHT +#define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT +#endif + #ifdef CONFIG_PANEL_LCD_WIDTH #undef DEFAULT_LCD_WIDTH #define DEFAULT_LCD_WIDTH CONFIG_PANEL_LCD_WIDTH @@ -356,9 +361,9 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #define DEFAULT_LCD_HWIDTH CONFIG_PANEL_LCD_HWIDTH #endif -#ifdef CONFIG_PANEL_LCD_HEIGHT -#undef DEFAULT_LCD_HEIGHT -#define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT +#ifdef CONFIG_PANEL_LCD_CHARSET +#undef DEFAULT_LCD_CHARSET +#define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET #endif #ifdef CONFIG_PANEL_LCD_PROTO @@ -396,11 +401,6 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #define DEFAULT_LCD_PIN_BL CONFIG_PANEL_LCD_PIN_BL #endif -#ifdef CONFIG_PANEL_LCD_CHARSET -#undef DEFAULT_LCD_CHARSET -#define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET -#endif - #endif /* DEFAULT_PROFILE == 0 */ /* global variables */ -- cgit v1.2.3-59-g8ed1b From 98e0e762ea757b91669b01b5c9fa7bdb939e4d1c Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Wed, 12 Nov 2014 02:08:08 +0100 Subject: staging: panel: Reorder module parameter declarations Change the order of the module parameter declarations so that it matches the Kconfig order. Signed-off-by: Mariusz Gorski Acked-By: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 73 ++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 4434c1d948d2..05b0d1e9d2b7 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -433,6 +433,22 @@ static int parport = -1; module_param(parport, int, 0000); MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)"); +static int profile = DEFAULT_PROFILE; +module_param(profile, int, 0000); +MODULE_PARM_DESC(profile, + "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; " + "4=16x2 nexcom; default=40x2, old kp"); + +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"); + +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"); + static int lcd_height = -1; module_param(lcd_height, int, 0000); MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD"); @@ -449,39 +465,15 @@ static int lcd_hwidth = -1; /* hardware buffer width (usually 64) */ module_param(lcd_hwidth, int, 0000); MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)"); -static int lcd_enabled = -1; -module_param(lcd_enabled, int, 0000); -MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); - -static int keypad_enabled = -1; -module_param(keypad_enabled, int, 0000); -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"); +static int lcd_charset = -1; +module_param(lcd_charset, int, 0000); +MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); 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"); -static int lcd_charset = -1; -module_param(lcd_charset, int, 0000); -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"); - -static int profile = DEFAULT_PROFILE; -module_param(profile, int, 0000); -MODULE_PARM_DESC(profile, - "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; " - "4=16x2 nexcom; default=40x2, old kp"); - /* * These are the parallel port pins the LCD control signals are connected to. * Set this to 0 if the signal is not used. Set it to its opposite value @@ -506,20 +498,31 @@ 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)"); -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)"); +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)"); 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)"); -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)"); +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)"); + +/* Deprecated module parameters - consider not using them anymore */ + +static int lcd_enabled = -1; +module_param(lcd_enabled, int, 0000); +MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); + +static int keypad_enabled = -1; +module_param(keypad_enabled, int, 0000); +MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); + static const unsigned char *lcd_char_conv; -- cgit v1.2.3-59-g8ed1b From 98fac3d3dbf467542e49b44fdf8809c62ba5f44e Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Wed, 12 Nov 2014 02:08:09 +0100 Subject: staging: panel: Use better names for two defined values Give DEFAULT_KEYPAD and DEFAULT_LCD defines better names, so that their meaning is emphasized. Signed-off-by: Mariusz Gorski Acked-By: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 05b0d1e9d2b7..c6eeddfb398f 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -304,8 +304,8 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; */ #define DEFAULT_PARPORT 0 #define DEFAULT_PROFILE PANEL_PROFILE_LARGE -#define DEFAULT_KEYPAD KEYPAD_TYPE_OLD -#define DEFAULT_LCD LCD_TYPE_OLD +#define DEFAULT_KEYPAD_TYPE KEYPAD_TYPE_OLD +#define DEFAULT_LCD_TYPE LCD_TYPE_OLD #define DEFAULT_LCD_HEIGHT 2 #define DEFAULT_LCD_WIDTH 40 #define DEFAULT_LCD_BWIDTH 40 @@ -332,13 +332,13 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #if DEFAULT_PROFILE == 0 /* custom */ #ifdef CONFIG_PANEL_KEYPAD -#undef DEFAULT_KEYPAD -#define DEFAULT_KEYPAD CONFIG_PANEL_KEYPAD +#undef DEFAULT_KEYPAD_TYPE +#define DEFAULT_KEYPAD_TYPE CONFIG_PANEL_KEYPAD #endif #ifdef CONFIG_PANEL_LCD -#undef DEFAULT_LCD -#define DEFAULT_LCD CONFIG_PANEL_LCD +#undef DEFAULT_LCD_TYPE +#define DEFAULT_LCD_TYPE CONFIG_PANEL_LCD #endif #ifdef CONFIG_PANEL_LCD_HEIGHT @@ -2239,9 +2239,9 @@ static int panel_init(void) case PANEL_PROFILE_CUSTOM: /* custom profile */ if (keypad_type < 0) - keypad_type = DEFAULT_KEYPAD; + keypad_type = DEFAULT_KEYPAD_TYPE; if (lcd_type < 0) - lcd_type = DEFAULT_LCD; + lcd_type = DEFAULT_LCD_TYPE; break; case PANEL_PROFILE_OLD: /* 8 bits, 2*16, old keypad */ -- cgit v1.2.3-59-g8ed1b From c1e433accdb6b6a10c7be4376a0f6ec4205a51e9 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Tue, 11 Nov 2014 15:40:23 +0800 Subject: staging: fwserial: remove multiple blank lines This patch fixes the multiple blank lines issue complained by checkpatch.pl by removing useless blank lines. Signed-off-by: Le Tan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index af0c3878358c..73deae3cd9eb 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -278,7 +278,6 @@ static void fwtty_send_txn_async(struct fwtty_peer *peer, len, fwtty_common_callback, txn); } - static void __fwtty_restart_tx(struct fwtty_port *port) { int len, avail; @@ -508,7 +507,6 @@ static void fwtty_do_hangup(struct work_struct *work) tty_kref_put(tty); } - static void fwtty_emit_breaks(struct work_struct *work) { struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); @@ -1622,7 +1620,6 @@ static inline int mgmt_pkt_expected_len(__be16 code) case FWSC_VIRT_CABLE_PLUG_RSP: /* | FWSC_RSP_OK */ return sizeof(pkt.hdr) + sizeof(pkt.plug_rsp); - case FWSC_VIRT_CABLE_UNPLUG: case FWSC_VIRT_CABLE_UNPLUG_RSP: case FWSC_VIRT_CABLE_PLUG_RSP | FWSC_RSP_NACK: -- cgit v1.2.3-59-g8ed1b From 968bf0cf0c18523b491a030bd56fab4c1e1640bb Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 25 Nov 2014 16:51:08 +0100 Subject: staging: ozwpan: Deletion of unnecessary checks before the function call "oz_free_urb_link" The oz_free_urb_link() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 27217d75f155..057632c3f1cc 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -354,8 +354,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, } spin_lock(&g_tasklet_lock); spin_unlock_irqrestore(&g_tasklet_lock, irq_state); - if (cancel_urbl) - oz_free_urb_link(cancel_urbl); + oz_free_urb_link(cancel_urbl); } /* @@ -523,8 +522,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, } } spin_unlock_bh(&port->ozhcd->hcd_lock); - if (urbl) - oz_free_urb_link(urbl); + oz_free_urb_link(urbl); return urbl ? 0 : -EIDRM; } -- cgit v1.2.3-59-g8ed1b From 16ceb7283987d8d7cad260bacf49f4197c625504 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Mon, 24 Nov 2014 22:58:48 +0100 Subject: staging: olpc_dcon: Deletion of a check before backlight_device_unregister() The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index eb83b28b8cd1..6a9a8815477c 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -682,8 +682,7 @@ static int dcon_remove(struct i2c_client *client) free_irq(DCON_IRQ, dcon); - if (dcon->bl_dev) - backlight_device_unregister(dcon->bl_dev); + backlight_device_unregister(dcon->bl_dev); if (dcon_device != NULL) platform_device_unregister(dcon_device); -- cgit v1.2.3-59-g8ed1b From d268b50eb21d06cffe949ed3c1c05f1bf9939916 Mon Sep 17 00:00:00 2001 From: Anjana Sasindran Date: Fri, 21 Nov 2014 00:27:50 +0530 Subject: Drivers:staging:dgap: Added a blank line after declaration This patch fixes the checkpatch.pl warning: WARNING:Missing a blank line after declaration Signed-off-by: Anjana Sasindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index f38354f04d50..bdb5317e3d9d 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -4414,6 +4414,7 @@ static struct board_t *find_board_by_major(unsigned int major) for (i = 0; i < MAXBOARDS; i++) { struct board_t *brd = dgap_board[i]; + if (!brd) return NULL; if (major == brd->serial_driver->major || -- cgit v1.2.3-59-g8ed1b From e3c2b451b42e143f265e40cafa4e08d051123436 Mon Sep 17 00:00:00 2001 From: Aede Symen Hoekstra Date: Sun, 16 Nov 2014 16:48:49 +0100 Subject: staging: wlan-ng: prism2fw: fixed code style issue Fixed checkpatch.pl warning message: line over 80 characters Signed-off-by: Aede Symen Hoekstra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index e907380f9163..9408644cc8b8 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -238,7 +238,8 @@ static int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev) * 0 - success * ~0 - failure ----------------------------------------------------------------*/ -static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) +static int prism2_fwapply(const struct ihex_binrec *rfptr, + wlandevice_t *wlandev) { signed int result = 0; struct p80211msg_dot11req_mibget getmsg; -- cgit v1.2.3-59-g8ed1b From 876e20d333c07b51b6452dbbd7f02c624b65e250 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Sun, 23 Nov 2014 22:12:20 -0500 Subject: staging: rtl8192e: add missing tasklet_kill on remove path The powersave tasklet is created in rtllib_softmac_init and it is not removed while unloading the module. Cc: Larry Finger Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index e970db474470..d992a754e72d 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3168,6 +3168,7 @@ void rtllib_softmac_free(struct rtllib_device *ieee) cancel_delayed_work(&ieee->associate_retry_wq); destroy_workqueue(ieee->wq); up(&ieee->wx_sem); + tasklet_kill(&ieee->ps_task); } /******************************************************** -- cgit v1.2.3-59-g8ed1b From 31d4cf12944ea7e578e4cef9b742da504dfbd444 Mon Sep 17 00:00:00 2001 From: Krzysztof Konopko Date: Mon, 10 Nov 2014 18:54:22 +0000 Subject: rtl8188eu: Simplify rtw_endofpktfile() in xmit_linux.c scripts/checkpatch.pl reports a coding style problem in xmit_linux.c WARNING:BRACES: braces {} are not necessary for single statement blocks #61852: FILE: rtl8188eu/os_dep/xmit_linux.c:70: This patch removes unnecessary braces and simplifies the function to a single return statement. Signed-off-by: Krzysztof Konopko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index d5e41a52a0eb..5acf9a9dddeb 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -66,13 +66,7 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) int rtw_endofpktfile(struct pkt_file *pfile) { - - if (pfile->pkt_len == 0) { - return true; - } - - - return false; + return pfile->pkt_len == 0; } int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) -- cgit v1.2.3-59-g8ed1b From 79a8641d9f104b1cb089eb734373612e369f8fe8 Mon Sep 17 00:00:00 2001 From: Krzysztof Konopko Date: Fri, 7 Nov 2014 00:24:26 +0100 Subject: rtl8188eu: Fix FSF_MAILING_ADDRESS in rtw_led.* rtw_led.* files include Free Software Foundation's mailing address in the sample GPL notice. This is not desired and picked when running scripts/checkpatch.pl. Signed-off-by: Krzysztof Konopko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 4 ---- drivers/staging/rtl8188eu/include/rtw_led.h | 4 ---- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 2aa62517e4a2..c6e83796c800 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -11,10 +11,6 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * * ******************************************************************************/ diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index dec8dbc483b4..c49a9a1e7ece 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -11,10 +11,6 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * * ******************************************************************************/ #ifndef __RTW_LED_H_ -- cgit v1.2.3-59-g8ed1b From f4a52b40dee4fcacf6b7c34483cd0a0133df4436 Mon Sep 17 00:00:00 2001 From: Krzysztof Konopko Date: Fri, 7 Nov 2014 00:24:27 +0100 Subject: rtl8188eu: Fix a typo in rtw_led.* A rather obvious typo in one of the identifier has been found. This patch fixes the typo and ensures any lines changed do not exceed 80 characters as indicated by scripts/checkpatch.pl Signed-off-by: Krzysztof Konopko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 6 ++++-- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index c6e83796c800..1b8264b978da 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -224,7 +224,8 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->bLedWPSBlinkInProgress = false; } else { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + _set_timer(&(pLed->BlinkTimer), + LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA); } break; default: @@ -388,7 +389,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = LED_BLINK_WPS_STOP; if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + _set_timer(&(pLed->BlinkTimer), + LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA); } else { pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), 0); diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index c49a9a1e7ece..23f0cfe312f3 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -23,7 +23,7 @@ #define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ #define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ #define LED_BLINK_FASTER_INTERVAL_ALPHA 50 -#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 +#define LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA 5000 enum LED_CTL_MODE { LED_CTL_POWER_ON, -- cgit v1.2.3-59-g8ed1b From aff24b999554d048d3105fefdd0bd89dbfc312af Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:07 -0700 Subject: staging: comedi: addi_apci_1564: board does not use an AMCC PCI controller According to ADDI-DATA, the APCI-1564 board has a FPGA with a PCI core, it does not use an AMCC PCI controller chip. Remove the amcc_s5933.h include as well as the read of the AMCC_OP_REG_INTCSR register. That offset would actually read APCI1564_WDOG_STATUS_REG register in the FPGA which has nothing to do with the interrupt status. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index aa908a4a24cf..cf14b0a923d4 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -28,7 +28,6 @@ #include "../comedidev.h" #include "comedi_fc.h" -#include "amcc_s5933.h" #include "addi_watchdog.h" struct apci1564_private { @@ -80,11 +79,6 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) unsigned int ctrl; unsigned int chan; - /* check interrupt is from this device */ - if ((inl(devpriv->amcc_iobase + AMCC_OP_REG_INTCSR) & - INTCSR_INTR_ASSERTED) == 0) - return IRQ_NONE; - status = inl(devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); if (status & APCI1564_DI_INT_ENABLE) { /* disable the interrupt */ -- cgit v1.2.3-59-g8ed1b From 950a6f8714fd73d4348036413f21e056de4b10bd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:08 -0700 Subject: staging: comedi: addi_apci_1564: use correct I/O base for APCI1564_DI_INT_STATUS_REG The APCI1564_DI_INT_STATUS_REG is located in the PCI BAR 0 I/O space. That base address is stored in devpriv->amcc_iobase. Use that to correctly read the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index cf14b0a923d4..467e27838b56 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -85,8 +85,8 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) outl(status & APCI1564_DI_INT_DISABLE, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); - s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG) - & 0xffff; + s->state = inl(devpriv->amcc_iobase + + APCI1564_DI_INT_STATUS_REG) & 0xffff; comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); -- cgit v1.2.3-59-g8ed1b From 63f9c51a5273daf5619ef0eae23d9f6317e01bcd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:09 -0700 Subject: staging: comedi: addi_apci_1564: store PCI BAR 1 base address in private data According to ADDI-DATA, only the PLD Revision 2.x versions of the APCI-1564 have the 3 counters. The base address for these counters is found in PCI BAR 1. For aesthetics, save this base address in the private data. The dev->iobase can then be used for the main registers of the board. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 57 ++++++++++------------ drivers/staging/comedi/drivers/addi_apci_1564.c | 25 +++++----- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index ad9949c39eae..37733ae2e918 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -47,7 +47,7 @@ #define APCI1564_TIMER_WARN_TIMEBASE_REG 0x64 /* - * dev->iobase Register Map + * devpriv->counters Register Map */ #define APCI1564_COUNTER_REG(x) (0x00 + ((x) * 0x20)) #define APCI1564_COUNTER_RELOAD_REG(x) (0x04 + ((x) * 0x20)) @@ -93,12 +93,12 @@ static int apci1564_timer_config(struct comedi_device *dev, outl(0x0, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); outl(0x0, devpriv->amcc_iobase + APCI1564_DO_IRQ_REG); outl(0x0, devpriv->amcc_iobase + APCI1564_WDOG_IRQ_REG); - outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(0)); - outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(1)); - outl(0x0, dev->iobase + - APCI1564_COUNTER_IRQ_REG(2)); + outl(0x0, + devpriv->counters + APCI1564_COUNTER_IRQ_REG(0)); + outl(0x0, + devpriv->counters + APCI1564_COUNTER_IRQ_REG(1)); + outl(0x0, + devpriv->counters + APCI1564_COUNTER_IRQ_REG(2)); } else { /* disable Timer interrupt */ outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); @@ -118,16 +118,16 @@ static int apci1564_timer_config(struct comedi_device *dev, devpriv->timer_select_mode = ADDIDATA_COUNTER; /* First Stop The Counter */ - ul_Command1 = inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + ul_Command1 = inl(devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; /* Stop The Timer */ - outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ul_Command1, + devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); /* Set the reload value */ - outl(data[3], dev->iobase + - APCI1564_COUNTER_RELOAD_REG(chan)); + outl(data[3], + devpriv->counters + APCI1564_COUNTER_RELOAD_REG(chan)); /* Set the mode : */ /* - Disable the hardware */ @@ -140,18 +140,18 @@ static int apci1564_timer_config(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (unsigned int) ((unsigned int) data[4] << 16UL); - outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ul_Command1, + devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); /* Enable or Disable Interrupt */ ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1); - outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ul_Command1, + devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); /* Set the Up/Down selection */ ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18); - outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ul_Command1, + devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -188,9 +188,8 @@ static int apci1564_timer_write(struct comedi_device *dev, outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); } } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { - ul_Command1 = - inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + ul_Command1 = inl(devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); if (data[1] == 1) { /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; @@ -202,8 +201,8 @@ static int apci1564_timer_write(struct comedi_device *dev, /* Clears the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; } - outl(ul_Command1, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ul_Command1, + devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -230,12 +229,10 @@ static int apci1564_timer_read(struct comedi_device *dev, data[1] = inl(devpriv->amcc_iobase + APCI1564_TIMER_REG); } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { /* Read the Counter Actual Value. */ - data[0] = - inl(dev->iobase + - APCI1564_COUNTER_REG(chan)); - ul_Command1 = - inl(dev->iobase + - APCI1564_COUNTER_STATUS_REG(chan)); + data[0] = inl(devpriv->counters + + APCI1564_COUNTER_REG(chan)); + ul_Command1 = inl(devpriv->counters + + APCI1564_COUNTER_STATUS_REG(chan)); /* Get the software trigger status */ data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 467e27838b56..ecdbc880a31a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -31,6 +31,7 @@ #include "addi_watchdog.h" struct apci1564_private { + unsigned long counters; /* base address of 32-bit counters */ unsigned int amcc_iobase; /* base of AMCC I/O registers */ unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ @@ -63,9 +64,9 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_RELOAD_REG); /* Reset the counter registers */ - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(0)); - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(1)); - outl(0x0, dev->iobase + APCI1564_COUNTER_CTRL_REG(2)); + outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0)); + outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(1)); + outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(2)); return 0; } @@ -108,20 +109,21 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } for (chan = 0; chan < 4; chan++) { - status = inl(dev->iobase + APCI1564_COUNTER_IRQ_REG(chan)); + status = inl(devpriv->counters + + APCI1564_COUNTER_IRQ_REG(chan)); if (status & 0x01) { /* Disable Counter Interrupt */ - ctrl = inl(dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); - outl(0x0, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + ctrl = inl(devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); + outl(0x0, devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_current, 0); /* Enable Counter Interrupt */ - outl(ctrl, dev->iobase + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); } } @@ -369,8 +371,9 @@ static int apci1564_auto_attach(struct comedi_device *dev, if (ret) return ret; - dev->iobase = pci_resource_start(pcidev, 1); + /* PLD Revision 2.x I/O Mapping */ devpriv->amcc_iobase = pci_resource_start(pcidev, 0); + devpriv->counters = pci_resource_start(pcidev, 1); apci1564_reset(dev); -- cgit v1.2.3-59-g8ed1b From 4484a23907724ad524d41e11dafa2a6be993420a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:10 -0700 Subject: staging: comedi: addi_apci_1564: use dev->iobase for main registers According to ADDI-DATA, the PLD Revision 2.x versions of the APCI-1564 use PCI BAR 0 for the main registers of the board. Remove the 'amcc_iobase' member of the private data and use the dev->iobase to store the base address of PCI BAR 1. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 36 +++++----- drivers/staging/comedi/drivers/addi_apci_1564.c | 79 ++++++++++------------ 2 files changed, 53 insertions(+), 62 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 37733ae2e918..c65dc1230a75 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -18,7 +18,7 @@ #define ADDIDATA_WATCHDOG 2 /* - * devpriv->amcc_iobase Register Map + * dev->iobase Register Map */ #define APCI1564_DI_REG 0x04 #define APCI1564_DI_INT_MODE1_REG 0x08 @@ -81,18 +81,18 @@ static int apci1564_timer_config(struct comedi_device *dev, devpriv->tsk_current = current; if (data[0] == ADDIDATA_TIMER) { /* First Stop The Timer */ - ul_Command1 = inl(devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; /* Stop The Timer */ - outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); devpriv->timer_select_mode = ADDIDATA_TIMER; if (data[1] == 1) { /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ - outl(0x02, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DO_IRQ_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_WDOG_IRQ_REG); + outl(0x02, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); + outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); + outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); outl(0x0, devpriv->counters + APCI1564_COUNTER_IRQ_REG(0)); outl(0x0, @@ -101,19 +101,19 @@ static int apci1564_timer_config(struct comedi_device *dev, devpriv->counters + APCI1564_COUNTER_IRQ_REG(2)); } else { /* disable Timer interrupt */ - outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG); } /* Loading Timebase */ - outl(data[2], devpriv->amcc_iobase + APCI1564_TIMER_TIMEBASE_REG); + outl(data[2], dev->iobase + APCI1564_TIMER_TIMEBASE_REG); /* Loading the Reload value */ - outl(data[3], devpriv->amcc_iobase + APCI1564_TIMER_RELOAD_REG); + outl(data[3], dev->iobase + APCI1564_TIMER_RELOAD_REG); - ul_Command1 = inl(devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; /* mode 2 */ - outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); } else if (data[0] == ADDIDATA_COUNTER) { devpriv->timer_select_mode = ADDIDATA_COUNTER; @@ -175,17 +175,17 @@ static int apci1564_timer_write(struct comedi_device *dev, if (devpriv->timer_select_mode == ADDIDATA_TIMER) { if (data[1] == 1) { - ul_Command1 = inl(devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; /* Enable the Timer */ - outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); } else if (data[1] == 0) { /* Stop The Timer */ - ul_Command1 = inl(devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); } } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { ul_Command1 = inl(devpriv->counters + @@ -223,10 +223,10 @@ static int apci1564_timer_read(struct comedi_device *dev, if (devpriv->timer_select_mode == ADDIDATA_TIMER) { /* Stores the status of the Timer */ - data[0] = inl(devpriv->amcc_iobase + APCI1564_TIMER_STATUS_REG) & 0x1; + data[0] = inl(dev->iobase + APCI1564_TIMER_STATUS_REG) & 0x1; /* Stores the Actual value of the Timer */ - data[1] = inl(devpriv->amcc_iobase + APCI1564_TIMER_REG); + data[1] = inl(dev->iobase + APCI1564_TIMER_REG); } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { /* Read the Counter Actual Value. */ data[0] = inl(devpriv->counters + diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index ecdbc880a31a..4252054e86ea 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -32,7 +32,6 @@ struct apci1564_private { unsigned long counters; /* base address of 32-bit counters */ - unsigned int amcc_iobase; /* base of AMCC I/O registers */ unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ @@ -47,21 +46,21 @@ static int apci1564_reset(struct comedi_device *dev) struct apci1564_private *devpriv = dev->private; /* Disable the input interrupts and reset status register */ - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); - inl(devpriv->amcc_iobase + APCI1564_DI_INT_STATUS_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_INT_MODE1_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_INT_MODE2_REG); + outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); + inl(dev->iobase + APCI1564_DI_INT_STATUS_REG); + outl(0x0, dev->iobase + APCI1564_DI_INT_MODE1_REG); + outl(0x0, dev->iobase + APCI1564_DI_INT_MODE2_REG); /* Reset the output channels and disable interrupts */ - outl(0x0, devpriv->amcc_iobase + APCI1564_DO_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DO_INT_CTRL_REG); + outl(0x0, dev->iobase + APCI1564_DO_REG); + outl(0x0, dev->iobase + APCI1564_DO_INT_CTRL_REG); /* Reset the watchdog registers */ - addi_watchdog_reset(devpriv->amcc_iobase + APCI1564_WDOG_REG); + addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG); /* Reset the timer registers */ - outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_RELOAD_REG); + outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(0x0, dev->iobase + APCI1564_TIMER_RELOAD_REG); /* Reset the counter registers */ outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0)); @@ -80,32 +79,32 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) unsigned int ctrl; unsigned int chan; - status = inl(devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); + status = inl(dev->iobase + APCI1564_DI_IRQ_REG); if (status & APCI1564_DI_INT_ENABLE) { /* disable the interrupt */ outl(status & APCI1564_DI_INT_DISABLE, - devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); + dev->iobase + APCI1564_DI_IRQ_REG); - s->state = inl(devpriv->amcc_iobase + - APCI1564_DI_INT_STATUS_REG) & 0xffff; + s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG) & + 0xffff; comedi_buf_write_samples(s, &s->state, 1); comedi_handle_events(dev, s); /* enable the interrupt */ - outl(status, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); + outl(status, dev->iobase + APCI1564_DI_IRQ_REG); } - status = inl(devpriv->amcc_iobase + APCI1564_TIMER_IRQ_REG); + status = inl(dev->iobase + APCI1564_TIMER_IRQ_REG); if (status & 0x01) { /* Disable Timer Interrupt */ - ctrl = inl(devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + ctrl = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_current, 0); /* Enable Timer Interrupt */ - outl(ctrl, devpriv->amcc_iobase + APCI1564_TIMER_CTRL_REG); + outl(ctrl, dev->iobase + APCI1564_TIMER_CTRL_REG); } for (chan = 0; chan < 4; chan++) { @@ -135,9 +134,7 @@ static int apci1564_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct apci1564_private *devpriv = dev->private; - - data[1] = inl(devpriv->amcc_iobase + APCI1564_DI_REG); + data[1] = inl(dev->iobase + APCI1564_DI_REG); return insn->n; } @@ -147,12 +144,10 @@ static int apci1564_do_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct apci1564_private *devpriv = dev->private; - - s->state = inl(devpriv->amcc_iobase + APCI1564_DO_REG); + s->state = inl(dev->iobase + APCI1564_DO_REG); if (comedi_dio_update_state(s, data)) - outl(s->state, devpriv->amcc_iobase + APCI1564_DO_REG); + outl(s->state, dev->iobase + APCI1564_DO_REG); data[1] = s->state; @@ -164,9 +159,7 @@ static int apci1564_diag_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct apci1564_private *devpriv = dev->private; - - data[1] = inl(devpriv->amcc_iobase + APCI1564_DO_INT_STATUS_REG) & 3; + data[1] = inl(dev->iobase + APCI1564_DO_INT_STATUS_REG) & 3; return insn->n; } @@ -220,10 +213,10 @@ static int apci1564_cos_insn_config(struct comedi_device *dev, devpriv->ctrl = 0; devpriv->mode1 = 0; devpriv->mode2 = 0; - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); - inl(devpriv->amcc_iobase + APCI1564_DI_INT_STATUS_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_INT_MODE1_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_INT_MODE2_REG); + outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); + inl(dev->iobase + APCI1564_DI_INT_STATUS_REG); + outl(0x0, dev->iobase + APCI1564_DI_INT_MODE1_REG); + outl(0x0, dev->iobase + APCI1564_DI_INT_MODE2_REG); break; case COMEDI_DIGITAL_TRIG_ENABLE_EDGES: if (devpriv->ctrl != (APCI1564_DI_INT_ENABLE | @@ -335,9 +328,9 @@ static int apci1564_cos_cmd(struct comedi_device *dev, return -EINVAL; } - outl(devpriv->mode1, devpriv->amcc_iobase + APCI1564_DI_INT_MODE1_REG); - outl(devpriv->mode2, devpriv->amcc_iobase + APCI1564_DI_INT_MODE2_REG); - outl(devpriv->ctrl, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); + outl(devpriv->mode1, dev->iobase + APCI1564_DI_INT_MODE1_REG); + outl(devpriv->mode2, dev->iobase + APCI1564_DI_INT_MODE2_REG); + outl(devpriv->ctrl, dev->iobase + APCI1564_DI_IRQ_REG); return 0; } @@ -345,12 +338,10 @@ static int apci1564_cos_cmd(struct comedi_device *dev, static int apci1564_cos_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct apci1564_private *devpriv = dev->private; - - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_IRQ_REG); - inl(devpriv->amcc_iobase + APCI1564_DI_INT_STATUS_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_INT_MODE1_REG); - outl(0x0, devpriv->amcc_iobase + APCI1564_DI_INT_MODE2_REG); + outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); + inl(dev->iobase + APCI1564_DI_INT_STATUS_REG); + outl(0x0, dev->iobase + APCI1564_DI_INT_MODE1_REG); + outl(0x0, dev->iobase + APCI1564_DI_INT_MODE2_REG); return 0; } @@ -372,7 +363,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, return ret; /* PLD Revision 2.x I/O Mapping */ - devpriv->amcc_iobase = pci_resource_start(pcidev, 0); + dev->iobase = pci_resource_start(pcidev, 0); devpriv->counters = pci_resource_start(pcidev, 1); apci1564_reset(dev); @@ -438,7 +429,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Initialize the watchdog subdevice */ s = &dev->subdevices[4]; - ret = addi_watchdog_init(s, devpriv->amcc_iobase + APCI1564_WDOG_REG); + ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_REG); if (ret) return ret; -- cgit v1.2.3-59-g8ed1b From 951fd40b28444e273404c2fb0b28d8e3cf5660b2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:11 -0700 Subject: staging: comedi: addi_apci_1564: detect PLD revision for I/O mapping The APCI-1564 has different I/O mapping depending on if the PLD revision is Rev 1.0 or Rev 2.x. The revision can be determined by reading the EEPROM register at offset 0x00 of PCI BAR 0 and checking the value of bits 7 to 4. Add this check to apci1564_auto_attach(). Currently this driver is coded to work with the Rev 2.x I/O mapping. For now, fail the attach if a Rev 1.0 PLD is detected. Document the I/O mapping for both revisions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 54 +++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 4252054e86ea..f75803a39449 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -30,7 +30,44 @@ #include "comedi_fc.h" #include "addi_watchdog.h" +/* + * PCI BAR 0 + * + * PLD Revision 1.0 I/O Mapping + * 0x00 93C76 EEPROM + * 0x04 - 0x18 Timer 12-Bit + * + * PLD Revision 2.x I/O Mapping + * 0x00 93C76 EEPROM + * 0x04 - 0x14 Digital Input + * 0x18 - 0x25 Digital Output + * 0x28 - 0x44 Watchdog 8-Bit + * 0x48 - 0x64 Timer 12-Bit + */ +#define APCI1564_EEPROM_REG 0x00 +#define APCI1564_EEPROM_VCC_STATUS (1 << 8) +#define APCI1564_EEPROM_TO_REV(x) (((x) >> 4) & 0xf) +#define APCI1564_EEPROM_DI (1 << 3) +#define APCI1564_EEPROM_DO (1 << 2) +#define APCI1564_EEPROM_CS (1 << 1) +#define APCI1564_EEPROM_CLK (1 << 0) + +/* + * PCI BAR 1 + * + * PLD Revision 1.0 I/O Mapping + * 0x00 - 0x10 Digital Input + * 0x14 - 0x20 Digital Output + * 0x24 - 0x3c Watchdog 8-Bit + * + * PLD Revision 2.x I/O Mapping + * 0x00 Counter_0 + * 0x20 Counter_1 + * 0x30 Counter_3 + */ + struct apci1564_private { + unsigned long eeprom; /* base address of EEPROM register */ unsigned long counters; /* base address of 32-bit counters */ unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ @@ -352,6 +389,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct apci1564_private *devpriv; struct comedi_subdevice *s; + unsigned int val; int ret; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); @@ -362,9 +400,19 @@ static int apci1564_auto_attach(struct comedi_device *dev, if (ret) return ret; - /* PLD Revision 2.x I/O Mapping */ - dev->iobase = pci_resource_start(pcidev, 0); - devpriv->counters = pci_resource_start(pcidev, 1); + /* read the EEPROM register and check the I/O map revision */ + devpriv->eeprom = pci_resource_start(pcidev, 0); + val = inl(devpriv->eeprom + APCI1564_EEPROM_REG); + if (APCI1564_EEPROM_TO_REV(val) == 0) { + /* PLD Revision 1.0 I/O Mapping */ + dev_err(dev->class_dev, + "PLD Revision 1.0 detected, not yet supported\n"); + return -ENXIO; + } else { + /* PLD Revision 2.x I/O Mapping */ + dev->iobase = devpriv->eeprom; + devpriv->counters = pci_resource_start(pcidev, 1); + } apci1564_reset(dev); -- cgit v1.2.3-59-g8ed1b From 37436196525239c61816a5b9e009a7aeab11ad2c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:12 -0700 Subject: staging: comedi: addi_apci_1564: fix dev->iobase for all PLD revisions The APCI-1564 has different I/O mapping depending on if the PLD revision is Rev 1.0 or Rev 2.x. Fix the main register defines so they will work for all PLD revisions and initialie the dev->iobase appropriately. Move the register defines to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 29 ----------------- drivers/staging/comedi/drivers/addi_apci_1564.c | 38 +++++++++++++++++++++- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index c65dc1230a75..1c313bca5806 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -17,35 +17,6 @@ #define ADDIDATA_COUNTER 1 #define ADDIDATA_WATCHDOG 2 -/* - * dev->iobase Register Map - */ -#define APCI1564_DI_REG 0x04 -#define APCI1564_DI_INT_MODE1_REG 0x08 -#define APCI1564_DI_INT_MODE2_REG 0x0c -#define APCI1564_DI_INT_STATUS_REG 0x10 -#define APCI1564_DI_IRQ_REG 0x14 -#define APCI1564_DO_REG 0x18 -#define APCI1564_DO_INT_CTRL_REG 0x1c -#define APCI1564_DO_INT_STATUS_REG 0x20 -#define APCI1564_DO_IRQ_REG 0x24 -#define APCI1564_WDOG_REG 0x28 -#define APCI1564_WDOG_RELOAD_REG 0x2c -#define APCI1564_WDOG_TIMEBASE_REG 0x30 -#define APCI1564_WDOG_CTRL_REG 0x34 -#define APCI1564_WDOG_STATUS_REG 0x38 -#define APCI1564_WDOG_IRQ_REG 0x3c -#define APCI1564_WDOG_WARN_TIMEVAL_REG 0x40 -#define APCI1564_WDOG_WARN_TIMEBASE_REG 0x44 -#define APCI1564_TIMER_REG 0x48 -#define APCI1564_TIMER_RELOAD_REG 0x4c -#define APCI1564_TIMER_TIMEBASE_REG 0x50 -#define APCI1564_TIMER_CTRL_REG 0x54 -#define APCI1564_TIMER_STATUS_REG 0x58 -#define APCI1564_TIMER_IRQ_REG 0x5c -#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x60 -#define APCI1564_TIMER_WARN_TIMEBASE_REG 0x64 - /* * devpriv->counters Register Map */ diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index f75803a39449..0fa7f72da10e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -51,6 +51,7 @@ #define APCI1564_EEPROM_DO (1 << 2) #define APCI1564_EEPROM_CS (1 << 1) #define APCI1564_EEPROM_CLK (1 << 0) +#define APCI1564_REV2_MAIN_IOBASE 0x04 /* * PCI BAR 1 @@ -65,6 +66,39 @@ * 0x20 Counter_1 * 0x30 Counter_3 */ +#define APCI1564_REV1_MAIN_IOBASE 0x00 + +/* + * dev->iobase Register Map + * PLD Revision 1.0 - PCI BAR 1 + 0x00 + * PLD Revision 2.x - PCI BAR 0 + 0x04 + */ +#define APCI1564_DI_REG 0x00 +#define APCI1564_DI_INT_MODE1_REG 0x04 +#define APCI1564_DI_INT_MODE2_REG 0x08 +#define APCI1564_DI_INT_STATUS_REG 0x0c +#define APCI1564_DI_IRQ_REG 0x10 +#define APCI1564_DO_REG 0x14 +#define APCI1564_DO_INT_CTRL_REG 0x18 +#define APCI1564_DO_INT_STATUS_REG 0x1c +#define APCI1564_DO_IRQ_REG 0x20 +#define APCI1564_WDOG_REG 0x24 +#define APCI1564_WDOG_RELOAD_REG 0x28 +#define APCI1564_WDOG_TIMEBASE_REG 0x2c +#define APCI1564_WDOG_CTRL_REG 0x30 +#define APCI1564_WDOG_STATUS_REG 0x34 +#define APCI1564_WDOG_IRQ_REG 0x38 +#define APCI1564_WDOG_WARN_TIMEVAL_REG 0x3c +#define APCI1564_WDOG_WARN_TIMEBASE_REG 0x40 +#define APCI1564_TIMER_REG 0x44 +#define APCI1564_TIMER_RELOAD_REG 0x48 +#define APCI1564_TIMER_TIMEBASE_REG 0x4c +#define APCI1564_TIMER_CTRL_REG 0x50 +#define APCI1564_TIMER_STATUS_REG 0x54 +#define APCI1564_TIMER_IRQ_REG 0x58 +#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x5c /* Rev 2.x only */ +#define APCI1564_TIMER_WARN_TIMEBASE_REG 0x60 /* Rev 2.x only */ + struct apci1564_private { unsigned long eeprom; /* base address of EEPROM register */ @@ -405,12 +439,14 @@ static int apci1564_auto_attach(struct comedi_device *dev, val = inl(devpriv->eeprom + APCI1564_EEPROM_REG); if (APCI1564_EEPROM_TO_REV(val) == 0) { /* PLD Revision 1.0 I/O Mapping */ + dev->iobase = pci_resource_start(pcidev, 1) + + APCI1564_REV1_MAIN_IOBASE; dev_err(dev->class_dev, "PLD Revision 1.0 detected, not yet supported\n"); return -ENXIO; } else { /* PLD Revision 2.x I/O Mapping */ - dev->iobase = devpriv->eeprom; + dev->iobase = devpriv->eeprom + APCI1564_REV2_MAIN_IOBASE; devpriv->counters = pci_resource_start(pcidev, 1); } -- cgit v1.2.3-59-g8ed1b From 6cf8ea2ebfb4421927cd7f1c66247d6980b5ac4c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:13 -0700 Subject: staging: comedi: addi_apci_1564: fix timer iobase for all PLD revisions The APCI-1564 has different I/O mapping depending on if the PLD revision is Rev 1.0 or Rev 2.x. Add a member, 'timer', to the private data for the base address of the 12-bit timer. Fix the register defines so they will work for all PLD revisions and initialize the devpriv->timer appropriately. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 32 ++++++++++-------- drivers/staging/comedi/drivers/addi_apci_1564.c | 38 ++++++++++++++-------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 1c313bca5806..b689303cbf0c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -52,15 +52,15 @@ static int apci1564_timer_config(struct comedi_device *dev, devpriv->tsk_current = current; if (data[0] == ADDIDATA_TIMER) { /* First Stop The Timer */ - ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; /* Stop The Timer */ - outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, devpriv->timer + APCI1564_TIMER_CTRL_REG); devpriv->timer_select_mode = ADDIDATA_TIMER; if (data[1] == 1) { /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ - outl(0x02, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(0x02, devpriv->timer + APCI1564_TIMER_CTRL_REG); outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); @@ -72,19 +72,19 @@ static int apci1564_timer_config(struct comedi_device *dev, devpriv->counters + APCI1564_COUNTER_IRQ_REG(2)); } else { /* disable Timer interrupt */ - outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); } /* Loading Timebase */ - outl(data[2], dev->iobase + APCI1564_TIMER_TIMEBASE_REG); + outl(data[2], devpriv->timer + APCI1564_TIMER_TIMEBASE_REG); /* Loading the Reload value */ - outl(data[3], dev->iobase + APCI1564_TIMER_RELOAD_REG); + outl(data[3], devpriv->timer + APCI1564_TIMER_RELOAD_REG); - ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; /* mode 2 */ - outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, devpriv->timer + APCI1564_TIMER_CTRL_REG); } else if (data[0] == ADDIDATA_COUNTER) { devpriv->timer_select_mode = ADDIDATA_COUNTER; @@ -146,17 +146,21 @@ static int apci1564_timer_write(struct comedi_device *dev, if (devpriv->timer_select_mode == ADDIDATA_TIMER) { if (data[1] == 1) { - ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(devpriv->timer + + APCI1564_TIMER_CTRL_REG); ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; /* Enable the Timer */ - outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, + devpriv->timer + APCI1564_TIMER_CTRL_REG); } else if (data[1] == 0) { /* Stop The Timer */ - ul_Command1 = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); + ul_Command1 = inl(devpriv->timer + + APCI1564_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(ul_Command1, + devpriv->timer + APCI1564_TIMER_CTRL_REG); } } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { ul_Command1 = inl(devpriv->counters + @@ -194,10 +198,10 @@ static int apci1564_timer_read(struct comedi_device *dev, if (devpriv->timer_select_mode == ADDIDATA_TIMER) { /* Stores the status of the Timer */ - data[0] = inl(dev->iobase + APCI1564_TIMER_STATUS_REG) & 0x1; + data[0] = inl(devpriv->timer + APCI1564_TIMER_STATUS_REG) & 0x1; /* Stores the Actual value of the Timer */ - data[1] = inl(dev->iobase + APCI1564_TIMER_REG); + data[1] = inl(devpriv->timer + APCI1564_TIMER_REG); } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { /* Read the Counter Actual Value. */ data[0] = inl(devpriv->counters + diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 0fa7f72da10e..b74e6c62eb24 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -51,7 +51,9 @@ #define APCI1564_EEPROM_DO (1 << 2) #define APCI1564_EEPROM_CS (1 << 1) #define APCI1564_EEPROM_CLK (1 << 0) +#define APCI1564_REV1_TIMER_IOBASE 0x04 #define APCI1564_REV2_MAIN_IOBASE 0x04 +#define APCI1564_REV2_TIMER_IOBASE 0x48 /* * PCI BAR 1 @@ -90,18 +92,24 @@ #define APCI1564_WDOG_IRQ_REG 0x38 #define APCI1564_WDOG_WARN_TIMEVAL_REG 0x3c #define APCI1564_WDOG_WARN_TIMEBASE_REG 0x40 -#define APCI1564_TIMER_REG 0x44 -#define APCI1564_TIMER_RELOAD_REG 0x48 -#define APCI1564_TIMER_TIMEBASE_REG 0x4c -#define APCI1564_TIMER_CTRL_REG 0x50 -#define APCI1564_TIMER_STATUS_REG 0x54 -#define APCI1564_TIMER_IRQ_REG 0x58 -#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x5c /* Rev 2.x only */ -#define APCI1564_TIMER_WARN_TIMEBASE_REG 0x60 /* Rev 2.x only */ +/* + * devpriv->timer Register Map + * PLD Revision 1.0 - PCI BAR 0 + 0x04 + * PLD Revision 2.x - PCI BAR 0 + 0x48 + */ +#define APCI1564_TIMER_REG 0x00 +#define APCI1564_TIMER_RELOAD_REG 0x04 +#define APCI1564_TIMER_TIMEBASE_REG 0x08 +#define APCI1564_TIMER_CTRL_REG 0x0c +#define APCI1564_TIMER_STATUS_REG 0x10 +#define APCI1564_TIMER_IRQ_REG 0x14 +#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x18 /* Rev 2.x only */ +#define APCI1564_TIMER_WARN_TIMEBASE_REG 0x1c /* Rev 2.x only */ struct apci1564_private { unsigned long eeprom; /* base address of EEPROM register */ + unsigned long timer; /* base address of 12-bit timer */ unsigned long counters; /* base address of 32-bit counters */ unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ @@ -130,8 +138,8 @@ static int apci1564_reset(struct comedi_device *dev) addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG); /* Reset the timer registers */ - outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG); - outl(0x0, dev->iobase + APCI1564_TIMER_RELOAD_REG); + outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(0x0, devpriv->timer + APCI1564_TIMER_RELOAD_REG); /* Reset the counter registers */ outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0)); @@ -165,17 +173,17 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) outl(status, dev->iobase + APCI1564_DI_IRQ_REG); } - status = inl(dev->iobase + APCI1564_TIMER_IRQ_REG); + status = inl(devpriv->timer + APCI1564_TIMER_IRQ_REG); if (status & 0x01) { /* Disable Timer Interrupt */ - ctrl = inl(dev->iobase + APCI1564_TIMER_CTRL_REG); - outl(0x0, dev->iobase + APCI1564_TIMER_CTRL_REG); + ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_current, 0); /* Enable Timer Interrupt */ - outl(ctrl, dev->iobase + APCI1564_TIMER_CTRL_REG); + outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); } for (chan = 0; chan < 4; chan++) { @@ -441,12 +449,14 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* PLD Revision 1.0 I/O Mapping */ dev->iobase = pci_resource_start(pcidev, 1) + APCI1564_REV1_MAIN_IOBASE; + devpriv->timer = devpriv->eeprom + APCI1564_REV1_TIMER_IOBASE; dev_err(dev->class_dev, "PLD Revision 1.0 detected, not yet supported\n"); return -ENXIO; } else { /* PLD Revision 2.x I/O Mapping */ dev->iobase = devpriv->eeprom + APCI1564_REV2_MAIN_IOBASE; + devpriv->timer = devpriv->eeprom + APCI1564_REV2_TIMER_IOBASE; devpriv->counters = pci_resource_start(pcidev, 1); } -- cgit v1.2.3-59-g8ed1b From 3a2cf2f971b7128b1daff50abbd88c766b458544 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:14 -0700 Subject: staging: comedi: addi_apci_1564: fix counter code in main driver source The Rev 1.0 APCI-1564 boards do not have counters. Fix the code in the main driver source so that the I/O accesses to the counters do not happen if the devpriv->counters member is not initialized. This does not fix the code in hwdrv_apci1564.c. That code violates the comedi API and is currently broken. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 44 ++++++++++++++----------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index b74e6c62eb24..3fb9cc06973d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -141,10 +141,12 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); outl(0x0, devpriv->timer + APCI1564_TIMER_RELOAD_REG); - /* Reset the counter registers */ - outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0)); - outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(1)); - outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(2)); + if (devpriv->counters) { + /* Reset the counter registers */ + outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0)); + outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(1)); + outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(2)); + } return 0; } @@ -186,22 +188,24 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); } - for (chan = 0; chan < 4; chan++) { - status = inl(devpriv->counters + - APCI1564_COUNTER_IRQ_REG(chan)); - if (status & 0x01) { - /* Disable Counter Interrupt */ - ctrl = inl(devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); - outl(0x0, devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_current, 0); - - /* Enable Counter Interrupt */ - outl(ctrl, devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); + if (devpriv->counters) { + for (chan = 0; chan < 4; chan++) { + status = inl(devpriv->counters + + APCI1564_COUNTER_IRQ_REG(chan)); + if (status & 0x01) { + /* Disable Counter Interrupt */ + ctrl = inl(devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); + outl(0x0, devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); + + /* Send a signal to from kernel to user space */ + send_sig(SIGIO, devpriv->tsk_current, 0); + + /* Enable Counter Interrupt */ + outl(ctrl, devpriv->counters + + APCI1564_COUNTER_CTRL_REG(chan)); + } } } -- cgit v1.2.3-59-g8ed1b From 1a69a887d69250778e5493fcebc6e95d1c625d20 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:15 -0700 Subject: staging: comedi: addi_apci_1564: move counter register defines to driver Move the defines for the counter registers from the included source file to the main driver source file. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 12 ------------ drivers/staging/comedi/drivers/addi_apci_1564.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index b689303cbf0c..af37df713a37 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -17,18 +17,6 @@ #define ADDIDATA_COUNTER 1 #define ADDIDATA_WATCHDOG 2 -/* - * devpriv->counters Register Map - */ -#define APCI1564_COUNTER_REG(x) (0x00 + ((x) * 0x20)) -#define APCI1564_COUNTER_RELOAD_REG(x) (0x04 + ((x) * 0x20)) -#define APCI1564_COUNTER_TIMEBASE_REG(x) (0x08 + ((x) * 0x20)) -#define APCI1564_COUNTER_CTRL_REG(x) (0x0c + ((x) * 0x20)) -#define APCI1564_COUNTER_STATUS_REG(x) (0x10 + ((x) * 0x20)) -#define APCI1564_COUNTER_IRQ_REG(x) (0x14 + ((x) * 0x20)) -#define APCI1564_COUNTER_WARN_TIMEVAL_REG(x) (0x18 + ((x) * 0x20)) -#define APCI1564_COUNTER_WARN_TIMEBASE_REG(x) (0x1c + ((x) * 0x20)) - /* * Configures The Timer or Counter * diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 3fb9cc06973d..958eb7d29be2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -107,6 +107,19 @@ #define APCI1564_TIMER_WARN_TIMEVAL_REG 0x18 /* Rev 2.x only */ #define APCI1564_TIMER_WARN_TIMEBASE_REG 0x1c /* Rev 2.x only */ +/* + * devpriv->counters Register Map + * PLD Revision 2.x - PCI BAR 1 + 0x00 + */ +#define APCI1564_COUNTER_REG(x) (0x00 + ((x) * 0x20)) +#define APCI1564_COUNTER_RELOAD_REG(x) (0x04 + ((x) * 0x20)) +#define APCI1564_COUNTER_TIMEBASE_REG(x) (0x08 + ((x) * 0x20)) +#define APCI1564_COUNTER_CTRL_REG(x) (0x0c + ((x) * 0x20)) +#define APCI1564_COUNTER_STATUS_REG(x) (0x10 + ((x) * 0x20)) +#define APCI1564_COUNTER_IRQ_REG(x) (0x14 + ((x) * 0x20)) +#define APCI1564_COUNTER_WARN_TIMEVAL_REG(x) (0x18 + ((x) * 0x20)) +#define APCI1564_COUNTER_WARN_TIMEBASE_REG(x) (0x1c + ((x) * 0x20)) + struct apci1564_private { unsigned long eeprom; /* base address of EEPROM register */ unsigned long timer; /* base address of 12-bit timer */ -- cgit v1.2.3-59-g8ed1b From 0658d6de9c9750201a5728f25dd3037a73941077 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:16 -0700 Subject: staging: comedi: addi_apci_1564: split timer and counter subdevices The timer subdevice is currently broken in this driver. The Rev 1.0 and 2.x versions of the board both have a 12-bit timer. But only the Rev 2.x boards have the 3 32-bit counters. Split the current timer subdevice into two separate subdevices: 1) A single channel 12-bit timer subdevice 2) A three channel 32-bit counter subdevice This represents the hardware correctly and the counters can be disabled on the Rev 1.0 boards. Split up the current (*insn_config), (*insn_write), and (*insn_read) so they only deal with the hardware associated with the subdevice. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 312 ++++++++++----------- drivers/staging/comedi/drivers/addi_apci_1564.c | 36 ++- 2 files changed, 174 insertions(+), 174 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index af37df713a37..23bc8de3a80a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -17,199 +17,185 @@ #define ADDIDATA_COUNTER 1 #define ADDIDATA_WATCHDOG 2 -/* - * Configures The Timer or Counter - * - * data[0] Configure as: 0 = Timer, 1 = Counter - * data[1] 1 = Enable Interrupt, 0 = Disable Interrupt - * data[2] Time Unit - * data[3] Reload Value - * data[4] Timer Mode - * data[5] Timer Counter Watchdog Number - * data[6] Counter Direction - */ -static int apci1564_timer_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int apci1564_timer_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int ul_Command1 = 0; + unsigned int ctrl; devpriv->tsk_current = current; - if (data[0] == ADDIDATA_TIMER) { - /* First Stop The Timer */ - ul_Command1 = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); - ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - /* Stop The Timer */ - outl(ul_Command1, devpriv->timer + APCI1564_TIMER_CTRL_REG); - - devpriv->timer_select_mode = ADDIDATA_TIMER; - if (data[1] == 1) { - /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */ - outl(0x02, devpriv->timer + APCI1564_TIMER_CTRL_REG); - outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); - outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); - outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); + + /* First Stop The Timer */ + ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + ctrl &= 0xfffff9fe; + /* Stop The Timer */ + outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + + if (data[1] == 1) { + /* Enable timer int & disable all the other int sources */ + outl(0x02, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); + outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); + outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); + if (devpriv->counters) { outl(0x0, devpriv->counters + APCI1564_COUNTER_IRQ_REG(0)); outl(0x0, devpriv->counters + APCI1564_COUNTER_IRQ_REG(1)); outl(0x0, devpriv->counters + APCI1564_COUNTER_IRQ_REG(2)); - } else { - /* disable Timer interrupt */ - outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); } - - /* Loading Timebase */ - outl(data[2], devpriv->timer + APCI1564_TIMER_TIMEBASE_REG); - - /* Loading the Reload value */ - outl(data[3], devpriv->timer + APCI1564_TIMER_RELOAD_REG); - - ul_Command1 = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); - ul_Command1 = (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL; - /* mode 2 */ - outl(ul_Command1, devpriv->timer + APCI1564_TIMER_CTRL_REG); - } else if (data[0] == ADDIDATA_COUNTER) { - devpriv->timer_select_mode = ADDIDATA_COUNTER; - - /* First Stop The Counter */ - ul_Command1 = inl(devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); - ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - /* Stop The Timer */ - outl(ul_Command1, - devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); - - /* Set the reload value */ - outl(data[3], - devpriv->counters + APCI1564_COUNTER_RELOAD_REG(chan)); - - /* Set the mode : */ - /* - Disable the hardware */ - /* - Disable the counter mode */ - /* - Disable the warning */ - /* - Disable the reset */ - /* - Disable the timer mode */ - /* - Enable the counter mode */ - - ul_Command1 = - (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | - (unsigned int) ((unsigned int) data[4] << 16UL); - outl(ul_Command1, - devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); - - /* Enable or Disable Interrupt */ - ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1); - outl(ul_Command1, - devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); - - /* Set the Up/Down selection */ - ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18); - outl(ul_Command1, - devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); } else { - dev_err(dev->class_dev, "Invalid subdevice.\n"); + /* disable Timer interrupt */ + outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); } + + /* Loading Timebase */ + outl(data[2], devpriv->timer + APCI1564_TIMER_TIMEBASE_REG); + + /* Loading the Reload value */ + outl(data[3], devpriv->timer + APCI1564_TIMER_RELOAD_REG); + + ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + ctrl &= 0xfff719e2; + ctrl |= (2 << 13) | 0x10; + /* mode 2 */ + outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + return insn->n; } -/* - * Start / Stop The Selected Timer or Counter - * - * data[0] Configure as: 0 = Timer, 1 = Counter - * data[1] 0 = Stop, 1 = Start, 2 = Trigger Clear (Only Counter) - */ -static int apci1564_timer_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int apci1564_timer_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int ul_Command1 = 0; - - if (devpriv->timer_select_mode == ADDIDATA_TIMER) { - if (data[1] == 1) { - ul_Command1 = inl(devpriv->timer + - APCI1564_TIMER_CTRL_REG); - ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - - /* Enable the Timer */ - outl(ul_Command1, - devpriv->timer + APCI1564_TIMER_CTRL_REG); - } else if (data[1] == 0) { - /* Stop The Timer */ - - ul_Command1 = inl(devpriv->timer + - APCI1564_TIMER_CTRL_REG); - ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; - outl(ul_Command1, - devpriv->timer + APCI1564_TIMER_CTRL_REG); - } - } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { - ul_Command1 = inl(devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); - if (data[1] == 1) { - /* Start the Counter subdevice */ - ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; - } else if (data[1] == 0) { - /* Stops the Counter subdevice */ - ul_Command1 = 0; - - } else if (data[1] == 2) { - /* Clears the Counter subdevice */ - ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; - } - outl(ul_Command1, - devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); - } else { - dev_err(dev->class_dev, "Invalid subdevice.\n"); + unsigned int ctrl; + + ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + switch (data[1]) { + case 0: /* Stop The Timer */ + ctrl &= 0xfffff9fe; + break; + case 1: /* Enable the Timer */ + ctrl &= 0xfffff9ff; + ctrl |= 0x1; + break; } + outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + return insn->n; } -/* - * Read The Selected Timer or Counter - */ -static int apci1564_timer_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int apci1564_timer_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int ul_Command1 = 0; - if (devpriv->timer_select_mode == ADDIDATA_TIMER) { - /* Stores the status of the Timer */ - data[0] = inl(devpriv->timer + APCI1564_TIMER_STATUS_REG) & 0x1; + /* Stores the status of the Timer */ + data[0] = inl(devpriv->timer + APCI1564_TIMER_STATUS_REG) & 0x1; - /* Stores the Actual value of the Timer */ - data[1] = inl(devpriv->timer + APCI1564_TIMER_REG); - } else if (devpriv->timer_select_mode == ADDIDATA_COUNTER) { - /* Read the Counter Actual Value. */ - data[0] = inl(devpriv->counters + - APCI1564_COUNTER_REG(chan)); - ul_Command1 = inl(devpriv->counters + - APCI1564_COUNTER_STATUS_REG(chan)); + /* Stores the Actual value of the Timer */ + data[1] = inl(devpriv->timer + APCI1564_TIMER_REG); - /* Get the software trigger status */ - data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); + return insn->n; +} - /* Get the hardware trigger status */ - data[2] = (unsigned char) ((ul_Command1 >> 2) & 1); +static int apci1564_counter_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int ctrl; - /* Get the software clear status */ - data[3] = (unsigned char) ((ul_Command1 >> 3) & 1); + devpriv->tsk_current = current; - /* Get the overflow status */ - data[4] = (unsigned char) ((ul_Command1 >> 0) & 1); - } else { - dev_err(dev->class_dev, "Invalid subdevice.\n"); + /* First Stop The Counter */ + ctrl = inl(devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + ctrl &= 0xfffff9fe; + /* Stop The Timer */ + outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + + /* Set the reload value */ + outl(data[3], devpriv->counters + APCI1564_COUNTER_RELOAD_REG(chan)); + + /* Set the mode : */ + /* - Disable the hardware */ + /* - Disable the counter mode */ + /* - Disable the warning */ + /* - Disable the reset */ + /* - Disable the timer mode */ + /* - Enable the counter mode */ + + ctrl &= 0xfffc19e2; + ctrl |= 0x80000 | (data[4] << 16); + outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + + /* Enable or Disable Interrupt */ + ctrl &= 0xfffff9fd; + ctrl |= (data[1] << 1); + outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + + /* Set the Up/Down selection */ + ctrl &= 0xfffbf9ff; + ctrl |= (data[6] << 18); + outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + + return insn->n; +} + +static int apci1564_counter_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int ctrl; + + ctrl = inl(devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + switch (data[1]) { + case 0: /* Stops the Counter subdevice */ + ctrl = 0; + break; + case 1: /* Start the Counter subdevice */ + ctrl &= 0xfffff9ff; + ctrl |= 0x1; + break; + case 2: /* Clears the Counter subdevice */ + ctrl &= 0xfffff9ff; + ctrl |= 0x400; + break; } + outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + + return insn->n; +} + +static int apci1564_counter_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int status; + + /* Read the Counter Actual Value. */ + data[0] = inl(devpriv->counters + APCI1564_COUNTER_REG(chan)); + + status = inl(devpriv->counters + APCI1564_COUNTER_STATUS_REG(chan)); + data[1] = (status >> 1) & 1; /* software trigger status */ + data[2] = (status >> 2) & 1; /* hardware trigger status */ + data[3] = (status >> 3) & 1; /* software clear status */ + data[4] = (status >> 0) & 1; /* overflow status */ + return insn->n; } diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 958eb7d29be2..359880d422f2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -127,7 +127,6 @@ struct apci1564_private { unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ - unsigned char timer_select_mode; struct task_struct *tsk_current; }; @@ -486,7 +485,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->irq = pcidev->irq; } - ret = comedi_alloc_subdevices(dev, 6); + ret = comedi_alloc_subdevices(dev, 7); if (ret) return ret; @@ -527,25 +526,40 @@ static int apci1564_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise Timer Subdevice Structures */ + /* Timer subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 3; - s->maxdata = 0; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->n_chan = 1; + s->maxdata = 0x0fff; s->range_table = &range_digital; - s->insn_write = apci1564_timer_write; - s->insn_read = apci1564_timer_read; - s->insn_config = apci1564_timer_config; + s->insn_config = apci1564_timer_insn_config; + s->insn_write = apci1564_timer_insn_write; + s->insn_read = apci1564_timer_insn_read; - /* Initialize the watchdog subdevice */ + /* Counter subdevice */ s = &dev->subdevices[4]; + if (devpriv->counters) { + s->type = COMEDI_SUBD_COUNTER; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE | SDF_LSAMPL; + s->n_chan = 3; + s->maxdata = 0xffffffff; + s->range_table = &range_digital; + s->insn_config = apci1564_counter_insn_config; + s->insn_write = apci1564_counter_insn_write; + s->insn_read = apci1564_counter_insn_read; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Initialize the watchdog subdevice */ + s = &dev->subdevices[5]; ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_REG); if (ret) return ret; /* Initialize the diagnostic status subdevice */ - s = &dev->subdevices[5]; + s = &dev->subdevices[6]; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; s->n_chan = 2; -- cgit v1.2.3-59-g8ed1b From 1b4bcf1fedbe7dcd98d9d35dfc947f033a398c4d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:17 -0700 Subject: staging: comedi: addi_tcw.h: provide generic defines for the ADDI-DATA TCW The TCW (timer/counter/watchdog) devices in the various ADDI-DATA drivers use a common register map definition. Provide a common generic define for these registers so they don't have to be replicated in each driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_tcw.h | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 drivers/staging/comedi/drivers/addi_tcw.h diff --git a/drivers/staging/comedi/drivers/addi_tcw.h b/drivers/staging/comedi/drivers/addi_tcw.h new file mode 100644 index 000000000000..8794d4cbbfb0 --- /dev/null +++ b/drivers/staging/comedi/drivers/addi_tcw.h @@ -0,0 +1,56 @@ +#ifndef _ADDI_TCW_H +#define _ADDI_TCW_H + +/* + * Following are the generic definitions for the ADDI-DATA timer/counter/ + * watchdog (TCW) registers and bits. Some of the registers are not used + * depending on the use of the TCW. + */ + +#define ADDI_TCW_VAL_REG 0x00 + +#define ADDI_TCW_SYNC_REG 0x00 +#define ADDI_TCW_SYNC_CTR_TRIG (1 << 8) +#define ADDI_TCW_SYNC_CTR_DIS (1 << 7) +#define ADDI_TCW_SYNC_CTR_ENA (1 << 6) +#define ADDI_TCW_SYNC_TIMER_TRIG (1 << 5) +#define ADDI_TCW_SYNC_TIMER_DIS (1 << 4) +#define ADDI_TCW_SYNC_TIMER_ENA (1 << 3) +#define ADDI_TCW_SYNC_WDOG_TRIG (1 << 2) +#define ADDI_TCW_SYNC_WDOG_DIS (1 << 1) +#define ADDI_TCW_SYNC_WDOG_ENA (1 << 0) + +#define ADDI_TCW_RELOAD_REG 0x04 + +#define ADDI_TCW_TIMEBASE_REG 0x08 + +#define ADDI_TCW_CTRL_REG 0x0c +#define ADDI_TCW_CTRL_EXT_CLK_STATUS (1 << 21) +#define ADDI_TCW_CTRL_CASCADE (1 << 20) +#define ADDI_TCW_CTRL_CNTR_ENA (1 << 19) +#define ADDI_TCW_CTRL_CNT_UP (1 << 18) +#define ADDI_TCW_CTRL_EXT_CLK(x) ((x) << 16) +#define ADDI_TCW_CTRL_OUT(x) ((x) << 11) +#define ADDI_TCW_CTRL_GATE (1 << 10) +#define ADDI_TCW_CTRL_TRIG (1 << 9) +#define ADDI_TCW_CTRL_EXT_GATE(x) ((x) << 7) +#define ADDI_TCW_CTRL_EXT_TRIG(x) ((x) << 5) +#define ADDI_TCW_CTRL_TIMER_ENA (1 << 4) +#define ADDI_TCW_CTRL_RESET_ENA (1 << 3) +#define ADDI_TCW_CTRL_WARN_ENA (1 << 2) +#define ADDI_TCW_CTRL_IRQ_ENA (1 << 1) +#define ADDI_TCW_CTRL_ENA (1 << 0) + +#define ADDI_TCW_STATUS_REG 0x10 +#define ADDI_TCW_STATUS_SOFT_CLR (1 << 3) +#define ADDI_TCW_STATUS_SOFT_TRIG (1 << 1) +#define ADDI_TCW_STATUS_OVERFLOW (1 << 0) + +#define ADDI_TCW_IRQ_REG 0x14 +#define ADDI_TCW_IRQ (1 << 0) + +#define ADDI_TCW_WARN_TIMEVAL_REG 0x18 + +#define ADDI_TCW_WARN_TIMEBASE_REG 0x1c + +#endif -- cgit v1.2.3-59-g8ed1b From e23337dcbb539420f35b0c7569ab123068e742fc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:18 -0700 Subject: staging: comedi: addi_apci_1564: use addi_tcw.h defines for timer Use the generic TCW (timer/counter/watchdog) defines for the 12-bit timer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 24 +++++++++++----------- drivers/staging/comedi/drivers/addi_apci_1564.c | 23 ++++++++------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 23bc8de3a80a..2f403e55a22c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -28,14 +28,14 @@ static int apci1564_timer_insn_config(struct comedi_device *dev, devpriv->tsk_current = current; /* First Stop The Timer */ - ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); ctrl &= 0xfffff9fe; /* Stop The Timer */ - outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); if (data[1] == 1) { /* Enable timer int & disable all the other int sources */ - outl(0x02, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(0x02, devpriv->timer + ADDI_TCW_CTRL_REG); outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); @@ -49,20 +49,20 @@ static int apci1564_timer_insn_config(struct comedi_device *dev, } } else { /* disable Timer interrupt */ - outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); } /* Loading Timebase */ - outl(data[2], devpriv->timer + APCI1564_TIMER_TIMEBASE_REG); + outl(data[2], devpriv->timer + ADDI_TCW_TIMEBASE_REG); /* Loading the Reload value */ - outl(data[3], devpriv->timer + APCI1564_TIMER_RELOAD_REG); + outl(data[3], devpriv->timer + ADDI_TCW_RELOAD_REG); - ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); ctrl &= 0xfff719e2; ctrl |= (2 << 13) | 0x10; /* mode 2 */ - outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); return insn->n; } @@ -75,7 +75,7 @@ static int apci1564_timer_insn_write(struct comedi_device *dev, struct apci1564_private *devpriv = dev->private; unsigned int ctrl; - ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); + ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); switch (data[1]) { case 0: /* Stop The Timer */ ctrl &= 0xfffff9fe; @@ -85,7 +85,7 @@ static int apci1564_timer_insn_write(struct comedi_device *dev, ctrl |= 0x1; break; } - outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); return insn->n; } @@ -98,10 +98,10 @@ static int apci1564_timer_insn_read(struct comedi_device *dev, struct apci1564_private *devpriv = dev->private; /* Stores the status of the Timer */ - data[0] = inl(devpriv->timer + APCI1564_TIMER_STATUS_REG) & 0x1; + data[0] = inl(devpriv->timer + ADDI_TCW_STATUS_REG) & 0x1; /* Stores the Actual value of the Timer */ - data[1] = inl(devpriv->timer + APCI1564_TIMER_REG); + data[1] = inl(devpriv->timer + ADDI_TCW_VAL_REG); return insn->n; } diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 359880d422f2..d47904ee98de 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -28,6 +28,7 @@ #include "../comedidev.h" #include "comedi_fc.h" +#include "addi_tcw.h" #include "addi_watchdog.h" /* @@ -94,18 +95,10 @@ #define APCI1564_WDOG_WARN_TIMEBASE_REG 0x40 /* - * devpriv->timer Register Map + * devpriv->timer Register Map (see addi_tcw.h for register/bit defines) * PLD Revision 1.0 - PCI BAR 0 + 0x04 * PLD Revision 2.x - PCI BAR 0 + 0x48 */ -#define APCI1564_TIMER_REG 0x00 -#define APCI1564_TIMER_RELOAD_REG 0x04 -#define APCI1564_TIMER_TIMEBASE_REG 0x08 -#define APCI1564_TIMER_CTRL_REG 0x0c -#define APCI1564_TIMER_STATUS_REG 0x10 -#define APCI1564_TIMER_IRQ_REG 0x14 -#define APCI1564_TIMER_WARN_TIMEVAL_REG 0x18 /* Rev 2.x only */ -#define APCI1564_TIMER_WARN_TIMEBASE_REG 0x1c /* Rev 2.x only */ /* * devpriv->counters Register Map @@ -150,8 +143,8 @@ static int apci1564_reset(struct comedi_device *dev) addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG); /* Reset the timer registers */ - outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->timer + APCI1564_TIMER_RELOAD_REG); + outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); + outl(0x0, devpriv->timer + ADDI_TCW_RELOAD_REG); if (devpriv->counters) { /* Reset the counter registers */ @@ -187,17 +180,17 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) outl(status, dev->iobase + APCI1564_DI_IRQ_REG); } - status = inl(devpriv->timer + APCI1564_TIMER_IRQ_REG); + status = inl(devpriv->timer + ADDI_TCW_IRQ_REG); if (status & 0x01) { /* Disable Timer Interrupt */ - ctrl = inl(devpriv->timer + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG); + ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); + outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_current, 0); /* Enable Timer Interrupt */ - outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG); + outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); } if (devpriv->counters) { -- cgit v1.2.3-59-g8ed1b From 7d6156ed3be0fe9484f36004e81aab0b0eca69b5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:19 -0700 Subject: staging: comedi: addi_apci_1564: use addi_tcw.h defines for counters Use the generic TCW (timer/counter/watchdog) defines for the 32-bit counters. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 35 ++++++++++++---------- drivers/staging/comedi/drivers/addi_apci_1564.c | 35 ++++++++++------------ 2 files changed, 34 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 2f403e55a22c..fa99c8ca4f95 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -40,12 +40,12 @@ static int apci1564_timer_insn_config(struct comedi_device *dev, outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); if (devpriv->counters) { - outl(0x0, - devpriv->counters + APCI1564_COUNTER_IRQ_REG(0)); - outl(0x0, - devpriv->counters + APCI1564_COUNTER_IRQ_REG(1)); - outl(0x0, - devpriv->counters + APCI1564_COUNTER_IRQ_REG(2)); + unsigned long iobase; + + iobase = devpriv->counters + ADDI_TCW_IRQ_REG; + outl(0x0, iobase + APCI1564_COUNTER(0)); + outl(0x0, iobase + APCI1564_COUNTER(1)); + outl(0x0, iobase + APCI1564_COUNTER(2)); } } else { /* disable Timer interrupt */ @@ -113,18 +113,19 @@ static int apci1564_counter_insn_config(struct comedi_device *dev, { struct apci1564_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); unsigned int ctrl; devpriv->tsk_current = current; /* First Stop The Counter */ - ctrl = inl(devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + ctrl = inl(iobase + ADDI_TCW_CTRL_REG); ctrl &= 0xfffff9fe; /* Stop The Timer */ - outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, iobase + ADDI_TCW_CTRL_REG); /* Set the reload value */ - outl(data[3], devpriv->counters + APCI1564_COUNTER_RELOAD_REG(chan)); + outl(data[3], iobase + ADDI_TCW_RELOAD_REG); /* Set the mode : */ /* - Disable the hardware */ @@ -136,17 +137,17 @@ static int apci1564_counter_insn_config(struct comedi_device *dev, ctrl &= 0xfffc19e2; ctrl |= 0x80000 | (data[4] << 16); - outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, iobase + ADDI_TCW_CTRL_REG); /* Enable or Disable Interrupt */ ctrl &= 0xfffff9fd; ctrl |= (data[1] << 1); - outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, iobase + ADDI_TCW_CTRL_REG); /* Set the Up/Down selection */ ctrl &= 0xfffbf9ff; ctrl |= (data[6] << 18); - outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, iobase + ADDI_TCW_CTRL_REG); return insn->n; } @@ -158,9 +159,10 @@ static int apci1564_counter_insn_write(struct comedi_device *dev, { struct apci1564_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); unsigned int ctrl; - ctrl = inl(devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + ctrl = inl(iobase + ADDI_TCW_CTRL_REG); switch (data[1]) { case 0: /* Stops the Counter subdevice */ ctrl = 0; @@ -174,7 +176,7 @@ static int apci1564_counter_insn_write(struct comedi_device *dev, ctrl |= 0x400; break; } - outl(ctrl, devpriv->counters + APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, iobase + ADDI_TCW_CTRL_REG); return insn->n; } @@ -186,12 +188,13 @@ static int apci1564_counter_insn_read(struct comedi_device *dev, { struct apci1564_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); unsigned int status; /* Read the Counter Actual Value. */ - data[0] = inl(devpriv->counters + APCI1564_COUNTER_REG(chan)); + data[0] = inl(iobase + ADDI_TCW_VAL_REG); - status = inl(devpriv->counters + APCI1564_COUNTER_STATUS_REG(chan)); + status = inl(iobase + ADDI_TCW_STATUS_REG); data[1] = (status >> 1) & 1; /* software trigger status */ data[2] = (status >> 2) & 1; /* hardware trigger status */ data[3] = (status >> 3) & 1; /* software clear status */ diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index d47904ee98de..18f38f00fb12 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -101,17 +101,10 @@ */ /* - * devpriv->counters Register Map + * devpriv->counters Register Map (see addi_tcw.h for register/bit defines) * PLD Revision 2.x - PCI BAR 1 + 0x00 */ -#define APCI1564_COUNTER_REG(x) (0x00 + ((x) * 0x20)) -#define APCI1564_COUNTER_RELOAD_REG(x) (0x04 + ((x) * 0x20)) -#define APCI1564_COUNTER_TIMEBASE_REG(x) (0x08 + ((x) * 0x20)) -#define APCI1564_COUNTER_CTRL_REG(x) (0x0c + ((x) * 0x20)) -#define APCI1564_COUNTER_STATUS_REG(x) (0x10 + ((x) * 0x20)) -#define APCI1564_COUNTER_IRQ_REG(x) (0x14 + ((x) * 0x20)) -#define APCI1564_COUNTER_WARN_TIMEVAL_REG(x) (0x18 + ((x) * 0x20)) -#define APCI1564_COUNTER_WARN_TIMEBASE_REG(x) (0x1c + ((x) * 0x20)) +#define APCI1564_COUNTER(x) ((x) * 0x20) struct apci1564_private { unsigned long eeprom; /* base address of EEPROM register */ @@ -147,10 +140,12 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, devpriv->timer + ADDI_TCW_RELOAD_REG); if (devpriv->counters) { + unsigned long iobase = devpriv->counters + ADDI_TCW_CTRL_REG; + /* Reset the counter registers */ - outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0)); - outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(1)); - outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(2)); + outl(0x0, iobase + APCI1564_COUNTER(0)); + outl(0x0, iobase + APCI1564_COUNTER(1)); + outl(0x0, iobase + APCI1564_COUNTER(2)); } return 0; @@ -195,21 +190,21 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) if (devpriv->counters) { for (chan = 0; chan < 4; chan++) { - status = inl(devpriv->counters + - APCI1564_COUNTER_IRQ_REG(chan)); + unsigned long iobase; + + iobase = devpriv->counters + APCI1564_COUNTER(chan); + + status = inl(iobase + ADDI_TCW_IRQ_REG); if (status & 0x01) { /* Disable Counter Interrupt */ - ctrl = inl(devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); - outl(0x0, devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); + ctrl = inl(iobase + ADDI_TCW_CTRL_REG); + outl(0x0, iobase + ADDI_TCW_CTRL_REG); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_current, 0); /* Enable Counter Interrupt */ - outl(ctrl, devpriv->counters + - APCI1564_COUNTER_CTRL_REG(chan)); + outl(ctrl, iobase + ADDI_TCW_CTRL_REG); } } } -- cgit v1.2.3-59-g8ed1b From e8dbe0c4c2566c4db885c24dbc1f603d9c703b41 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:20 -0700 Subject: staging: comedi: addi_apci_1564: enable support for PLD Rev 1.0 I/O mapping Remove the error return in the (*auto_attach) and allow the driver to attach to APC-1564 boards that use the PLD Rev 1.0 I/O mapping. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 18f38f00fb12..6872b69da5db 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -454,9 +454,6 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->iobase = pci_resource_start(pcidev, 1) + APCI1564_REV1_MAIN_IOBASE; devpriv->timer = devpriv->eeprom + APCI1564_REV1_TIMER_IOBASE; - dev_err(dev->class_dev, - "PLD Revision 1.0 detected, not yet supported\n"); - return -ENXIO; } else { /* PLD Revision 2.x I/O Mapping */ dev->iobase = devpriv->eeprom + APCI1564_REV2_MAIN_IOBASE; -- cgit v1.2.3-59-g8ed1b From a3e0316c1648825dcadb4f779cba14b9ddc00a71 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 16:20:21 -0700 Subject: staging: comedi: addi_watchdog: use addi_tcw.h defines for watchdog Use the generic TCW (timer/counter/watchdog) defines for the 8-bit watchdog. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_watchdog.c | 30 ++++++++------------------ 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/staging/comedi/drivers/addi_watchdog.c index 0af141ab39fc..c5b082d4e51e 100644 --- a/drivers/staging/comedi/drivers/addi_watchdog.c +++ b/drivers/staging/comedi/drivers/addi_watchdog.c @@ -20,21 +20,9 @@ #include #include "../comedidev.h" +#include "addi_tcw.h" #include "addi_watchdog.h" -/* - * Register offsets/defines for the addi-data watchdog - */ -#define ADDI_WDOG_REG 0x00 -#define ADDI_WDOG_RELOAD_REG 0x04 -#define ADDI_WDOG_TIMEBASE 0x08 -#define ADDI_WDOG_CTRL_REG 0x0c -#define ADDI_WDOG_CTRL_ENABLE (1 << 0) -#define ADDI_WDOG_CTRL_SW_TRIG (1 << 9) -#define ADDI_WDOG_STATUS_REG 0x10 -#define ADDI_WDOG_STATUS_ENABLED (1 << 0) -#define ADDI_WDOG_STATUS_SW_TRIG (1 << 1) - struct addi_watchdog_private { unsigned long iobase; unsigned int wdog_ctrl; @@ -60,9 +48,9 @@ static int addi_watchdog_insn_config(struct comedi_device *dev, switch (data[0]) { case INSN_CONFIG_ARM: - spriv->wdog_ctrl = ADDI_WDOG_CTRL_ENABLE; + spriv->wdog_ctrl = ADDI_TCW_CTRL_ENA; reload = data[1] & s->maxdata; - outl(reload, spriv->iobase + ADDI_WDOG_RELOAD_REG); + outl(reload, spriv->iobase + ADDI_TCW_RELOAD_REG); /* Time base is 20ms, let the user know the timeout */ dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n", @@ -75,7 +63,7 @@ static int addi_watchdog_insn_config(struct comedi_device *dev, return -EINVAL; } - outl(spriv->wdog_ctrl, spriv->iobase + ADDI_WDOG_CTRL_REG); + outl(spriv->wdog_ctrl, spriv->iobase + ADDI_TCW_CTRL_REG); return insn->n; } @@ -89,7 +77,7 @@ static int addi_watchdog_insn_read(struct comedi_device *dev, int i; for (i = 0; i < insn->n; i++) - data[i] = inl(spriv->iobase + ADDI_WDOG_STATUS_REG); + data[i] = inl(spriv->iobase + ADDI_TCW_STATUS_REG); return insn->n; } @@ -109,8 +97,8 @@ static int addi_watchdog_insn_write(struct comedi_device *dev, /* "ping" the watchdog */ for (i = 0; i < insn->n; i++) { - outl(spriv->wdog_ctrl | ADDI_WDOG_CTRL_SW_TRIG, - spriv->iobase + ADDI_WDOG_CTRL_REG); + outl(spriv->wdog_ctrl | ADDI_TCW_CTRL_TRIG, + spriv->iobase + ADDI_TCW_CTRL_REG); } return insn->n; @@ -118,8 +106,8 @@ static int addi_watchdog_insn_write(struct comedi_device *dev, void addi_watchdog_reset(unsigned long iobase) { - outl(0x0, iobase + ADDI_WDOG_CTRL_REG); - outl(0x0, iobase + ADDI_WDOG_RELOAD_REG); + outl(0x0, iobase + ADDI_TCW_CTRL_REG); + outl(0x0, iobase + ADDI_TCW_RELOAD_REG); } EXPORT_SYMBOL_GPL(addi_watchdog_reset); -- cgit v1.2.3-59-g8ed1b From 6250d982ee02ba44c230b7fb6f17432732a7a0fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 17:57:54 -0700 Subject: staging: comedi: adl_pci9118: use comedi_async 'scans_done' to detect EOA The comedi core now counts the number of samples added to the async buffer and detects the end-of-scan and increments the comedi_async 'scans_done' counter. Remove the private data member 'ai_act_scan' and use the 'scans_done' member to detect the end-of-acquisition. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 2aef881b6ee4..971235402289 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -221,7 +221,6 @@ struct pci9118_private { unsigned char int_ctrl; unsigned char ai_cfg; unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */ - unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_n_realscanlen; /* * what we must transfer for one * outgoing scan include front/back adds @@ -477,13 +476,7 @@ static void move_block_from_dma(struct comedi_device *dev, unsigned short *dma_buffer, unsigned int num_samples) { - struct pci9118_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples); - devpriv->ai_act_scan += - (s->async->cur_chan + num_samples) / cmd->scan_end_arg; - comedi_buf_write_samples(s, dma_buffer, num_samples); } @@ -571,7 +564,6 @@ static int pci9118_ai_cancel(struct comedi_device *dev, devpriv->ai_do = 0; devpriv->usedma = 0; - devpriv->ai_act_scan = 0; devpriv->ai_act_dmapos = 0; s->async->inttrig = NULL; devpriv->ai_neverending = 0; @@ -612,13 +604,9 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, comedi_buf_write_samples(s, &sampl, 1); - if (s->async->cur_chan == 0) { - devpriv->ai_act_scan++; - if (!devpriv->ai_neverending) { - /* all data sampled? */ - if (devpriv->ai_act_scan >= cmd->stop_arg) - s->async->events |= COMEDI_CB_EOA; - } + if (!devpriv->ai_neverending) { + if (s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; } } @@ -651,8 +639,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, } if (!devpriv->ai_neverending) { - /* all data sampled? */ - if (devpriv->ai_act_scan >= cmd->stop_arg) + if (s->async->scans_done >= cmd->stop_arg) s->async->events |= COMEDI_CB_EOA; } @@ -1114,7 +1101,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) inl(dev->iobase + PCI9118_AI_STATUS_REG); inl(dev->iobase + PCI9118_INT_CTRL_REG); - devpriv->ai_act_scan = 0; devpriv->ai_act_dmapos = 0; if (devpriv->usedma) { -- cgit v1.2.3-59-g8ed1b From e57bfa673c3056747f8014b956e6fbed02f917d5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 17:57:55 -0700 Subject: staging: comedi: adl_pci9118: absorb move_block_from_dma() Absorb this simple helper function into interrupt_pci9118_ai_dma(). Remove the unnecessary local variables 'sampls' and 'm'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 971235402289..b527748658f0 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -471,15 +471,6 @@ static unsigned int defragment_dma_buffer(struct comedi_device *dev, return j; } -static void move_block_from_dma(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned short *dma_buffer, - unsigned int num_samples) -{ - num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples); - comedi_buf_write_samples(s, dma_buffer, num_samples); -} - static void pci9118_exttrg_enable(struct comedi_device *dev, bool enable) { struct pci9118_private *devpriv = dev->private; @@ -616,9 +607,10 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct pci9118_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; struct pci9118_dmabuf *dmabuf = &devpriv->dmabuf[devpriv->dma_actbuf]; - unsigned int next_dma_buf, samplesinbuf, sampls, m; + unsigned int nsamples; + unsigned int next_dma_buf; - samplesinbuf = dmabuf->use_size >> 1; /* number of received samples */ + nsamples = dmabuf->use_size >> 1; /* number of received samples */ if (devpriv->dma_doublebuf) { /* * switch DMA buffers if is used @@ -630,12 +622,10 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, interrupt_pci9118_ai_mode4_switch(dev, next_dma_buf); } - if (samplesinbuf) { - /* how many samples is to end of buffer */ - m = s->async->prealloc_bufsz >> 1; - sampls = m; - move_block_from_dma(dev, s, dmabuf->virt, samplesinbuf); - m = m - sampls; /* m=how many samples was transferred */ + if (nsamples) { + nsamples = defragment_dma_buffer(dev, s, dmabuf->virt, + nsamples); + comedi_buf_write_samples(s, dmabuf->virt, nsamples); } if (!devpriv->ai_neverending) { -- cgit v1.2.3-59-g8ed1b From f6266a41d820feaa7b7febe122b285e336e40bfd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 17:57:56 -0700 Subject: staging: comedi: adl_pci9118: use comedi_bytes_to_samples() Remove the assumption of the sample size by using the comedi_bytes_to_samples() helper function to convert the number of bytes to the number of samples. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index b527748658f0..498e0c7775e5 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -607,11 +607,9 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct pci9118_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; struct pci9118_dmabuf *dmabuf = &devpriv->dmabuf[devpriv->dma_actbuf]; - unsigned int nsamples; + unsigned int nsamples = comedi_bytes_to_samples(s, dmabuf->use_size); unsigned int next_dma_buf; - nsamples = dmabuf->use_size >> 1; /* number of received samples */ - if (devpriv->dma_doublebuf) { /* * switch DMA buffers if is used * double buffering -- cgit v1.2.3-59-g8ed1b From b6bc224f33b2d2f537f6605f88542ac16dfbc192 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 10 Nov 2014 17:28:23 -0700 Subject: staging: comedi: adl_pci9111: use comedi_async 'scans_done' to detect EOA The comedi core now counts the number of samples added to the async buffer and detects the end-of-scan and increments the comedi_async 'scans_done' counter. Remove the private data member 'stop_counter' and use the 'scans_done' member to detect the end-of-acquisition. This fixes a possible interger overflow when calculating the value of the 'stop_counter' and removes the need to accumulate the 'total' number of samples added to the async buffer in pci9111_handle_fifo_half_full(). Signed-off-by: H Hartley Sweeten Reviewed-by: 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 47934c938a4b..539eb94cfe8d 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -133,8 +133,6 @@ static const struct comedi_lrange pci9111_ai_range = { struct pci9111_private_data { unsigned long lcr_io_base; - int stop_counter; - unsigned int scan_delay; unsigned int chunk_counter; unsigned int chunk_num_samples; @@ -404,12 +402,6 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, outb(CR_RANGE(cmd->chanlist[0]) & PCI9111_AI_RANGE_MASK, dev->iobase + PCI9111_AI_RANGE_STAT_REG); - /* Set counter */ - if (cmd->stop_src == TRIG_COUNT) - dev_private->stop_counter = cmd->stop_arg * cmd->chanlist_len; - else /* TRIG_NONE */ - dev_private->stop_counter = 0; - /* Set timer pacer */ dev_private->scan_delay = 0; if (cmd->convert_src == TRIG_TIMER) { @@ -435,7 +427,6 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, } outb(trig, dev->iobase + PCI9111_AI_TRIG_CTRL_REG); - dev_private->stop_counter *= (1 + dev_private->scan_delay); dev_private->chunk_counter = 0; dev_private->chunk_num_samples = cmd->chanlist_len * (1 + dev_private->scan_delay); @@ -464,21 +455,14 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, { struct pci9111_private_data *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int total = 0; unsigned int samples; - if (cmd->stop_src == TRIG_COUNT && - PCI9111_FIFO_HALF_SIZE > devpriv->stop_counter) - samples = devpriv->stop_counter; - else - samples = PCI9111_FIFO_HALF_SIZE; - + samples = comedi_nsamples_left(s, PCI9111_FIFO_HALF_SIZE); insw(dev->iobase + PCI9111_AI_FIFO_REG, devpriv->ai_bounce_buffer, samples); if (devpriv->scan_delay < 1) { - total = comedi_buf_write_samples(s, devpriv->ai_bounce_buffer, - samples); + comedi_buf_write_samples(s, devpriv->ai_bounce_buffer, samples); } else { unsigned int pos = 0; unsigned int to_read; @@ -491,7 +475,7 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, if (to_read > samples - pos) to_read = samples - pos; - total += comedi_buf_write_samples(s, + comedi_buf_write_samples(s, devpriv->ai_bounce_buffer + pos, to_read); } else { @@ -500,8 +484,6 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, if (to_read > samples - pos) to_read = samples - pos; - - total += comedi_samples_to_bytes(s, to_read); } pos += to_read; @@ -512,8 +494,6 @@ static void pci9111_handle_fifo_half_full(struct comedi_device *dev, devpriv->chunk_counter = 0; } } - - devpriv->stop_counter -= comedi_bytes_to_samples(s, total); } static irqreturn_t pci9111_interrupt(int irq, void *p_device) @@ -570,7 +550,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) pci9111_handle_fifo_half_full(dev, s); } - if (cmd->stop_src == TRIG_COUNT && dev_private->stop_counter == 0) + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) async->events |= COMEDI_CB_EOA; outb(0, dev->iobase + PCI9111_INT_CLR_REG); -- cgit v1.2.3-59-g8ed1b From 4d9b0714a29a4d56bb7345a58737438c89fa250b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:17 -0700 Subject: staging: comedi: dmm32at: make AI (*cancel) actually cancel async command Currently the AI (*cancel) changes a private data member to cause the interrupt handler to cancel the async command after the next interrupt. Move the code that disables the interrupt and terminates the acquisition from the interrunt handler into dmm32at_ai_cancel() so that the async command is terminated instantly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index fc2c0db73999..d73ba5b2f749 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -468,9 +468,8 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct dmm32at_private *devpriv = dev->private; - - devpriv->ai_scans_left = 1; + /* disable further interrupts and clocks */ + outb(0x0, dev->iobase + DMM32AT_INTCLOCK); return 0; } @@ -507,8 +506,6 @@ static irqreturn_t dmm32at_isr(int irq, void *d) if (devpriv->ai_scans_left != 0xffffffff) { /* TRIG_COUNT */ devpriv->ai_scans_left--; if (devpriv->ai_scans_left == 0) { - /* disable further interrupts and clocks */ - outb(0x0, dev->iobase + DMM32AT_INTCLOCK); /* set the buffer to be flushed with an EOF */ s->async->events |= COMEDI_CB_EOA; } -- cgit v1.2.3-59-g8ed1b From 933fca13a0b81aa247e0b428f0b873f9b8a5137e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:18 -0700 Subject: staging: comedi: dmm32at: use comedi_async 'scans_done' to detect EOA Remove the private data member 'ai_scans_left' and use the comedi_async 'scans_done' to detect the end-of-acquisition. This also removes the artifical max limit on the cmd->stop_arg. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index d73ba5b2f749..fce3b855fdbd 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -153,7 +153,6 @@ static const struct comedi_lrange dmm32at_aoranges = { struct dmm32at_private { int data; int ai_inuse; - unsigned int ai_scans_left; unsigned char dio_config; }; @@ -330,13 +329,10 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, 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, 0xfffffff0); + if (cmd->stop_src == TRIG_COUNT) err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); - } else { - /* TRIG_NONE */ + else /* TRIG_NONE */ err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); - } if (err) return 3; @@ -405,7 +401,6 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) 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 range; unsigned char chanlo, chanhi; @@ -437,13 +432,6 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* reset the interrupt just in case */ outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL); - if (cmd->stop_src == TRIG_COUNT) - devpriv->ai_scans_left = cmd->stop_arg; - else { /* TRIG_NONE */ - devpriv->ai_scans_left = 0xffffffff; /* indicates TRIG_NONE to - * isr */ - } - /* * wait for circuit to settle * we don't have the 'insn' here but it's not needed @@ -452,7 +440,7 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (ret) return ret; - if (devpriv->ai_scans_left > 1) { + if (cmd->stop_src == TRIG_NONE || cmd->stop_arg > 1) { /* start the clock and enable the interrupts */ dmm32at_setaitimer(dev, cmd->scan_begin_arg); } else { @@ -476,7 +464,6 @@ static int dmm32at_ai_cancel(struct comedi_device *dev, static irqreturn_t dmm32at_isr(int irq, void *d) { struct comedi_device *dev = d; - struct dmm32at_private *devpriv = dev->private; unsigned char intstat; unsigned int samp; unsigned short msb, lsb; @@ -503,14 +490,10 @@ static irqreturn_t dmm32at_isr(int irq, void *d) comedi_buf_write_samples(s, &samp, 1); } - if (devpriv->ai_scans_left != 0xffffffff) { /* TRIG_COUNT */ - devpriv->ai_scans_left--; - if (devpriv->ai_scans_left == 0) { - /* set the buffer to be flushed with an EOF */ - s->async->events |= COMEDI_CB_EOA; - } + if (cmd->stop_src == TRIG_COUNT && + s->async->scans_done >= cmd->stop_arg) + s->async->events |= COMEDI_CB_EOA; - } comedi_handle_events(dev, s); } -- cgit v1.2.3-59-g8ed1b From 0c0eadadcbe6ed9596568696f9c5b157707a7c8f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:19 -0700 Subject: staging: comedi: dmm32at: introduce dmm32_ai_get_sample() Introduce a helper function to read the two's complement analog input sample from the hardware and munge it to the offset binary (unsigned) format that comedi expects. Use the comedi_offset_munge() helper to munge the data. Use the new helper in the analog input (*insn_read) and in the interrupt handler for the async command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 40 +++++++++++++------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index fce3b855fdbd..b90f61965396 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -156,6 +156,18 @@ struct dmm32at_private { unsigned char dio_config; }; +static unsigned int dmm32at_ai_get_sample(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned int val; + + val = inb(dev->iobase + DMM32AT_AILSB); + val |= (inb(dev->iobase + DMM32AT_AIMSB) << 8); + + /* munge two's complement value to offset binary */ + return comedi_offset_munge(s, val); +} + static int dmm32at_ai_status(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -174,8 +186,6 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { int n; - unsigned int d; - unsigned short msb, lsb; unsigned char chan; int range; int ret; @@ -210,19 +220,7 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev, if (ret) return ret; - /* read data */ - lsb = inb(dev->iobase + DMM32AT_AILSB); - msb = inb(dev->iobase + DMM32AT_AIMSB); - - /* invert sign bit to make range unsigned, this is an - idiosyncrasy of the diamond board, it return - conversions as a signed value, i.e. -32768 to - 32767, flipping the bit and interpreting it as - signed gives you a range of 0 to 65535 which is - used by comedi */ - d = ((msb ^ 0x0080) << 8) + lsb; - - data[n] = d; + data[n] = dmm32at_ai_get_sample(dev, s); } /* return the number of samples read/written */ @@ -465,8 +463,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d) { struct comedi_device *dev = d; unsigned char intstat; - unsigned int samp; - unsigned short msb, lsb; + unsigned int val; int i; if (!dev->attached) { @@ -481,13 +478,8 @@ static irqreturn_t dmm32at_isr(int irq, void *d) struct comedi_cmd *cmd = &s->async->cmd; for (i = 0; i < cmd->chanlist_len; i++) { - /* read data */ - lsb = inb(dev->iobase + DMM32AT_AILSB); - msb = inb(dev->iobase + DMM32AT_AIMSB); - - /* invert sign bit to make range unsigned */ - samp = ((msb ^ 0x0080) << 8) + lsb; - comedi_buf_write_samples(s, &samp, 1); + val = dmm32at_ai_get_sample(dev, s); + comedi_buf_write_samples(s, &val, 1); } if (cmd->stop_src == TRIG_COUNT && -- cgit v1.2.3-59-g8ed1b From 01b7ecdd9529fd5722b9b18424f510cc34cc8e85 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:20 -0700 Subject: staging: comedi: dmm32at: tidy up dmm32at_ai_rinsn() For aesthetics, rename this function to dmm32at_ai_insn_read(). Get the 'chan' and 'range' from the chanspec when declaring the local variables. Remove the unecessary masking of the 'chan'. Remove some unnecessary comments. Change the final return to 'insn->n' to clarify the return value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 33 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index b90f61965396..b21d08df4555 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -181,27 +181,22 @@ static int dmm32at_ai_status(struct comedi_device *dev, return -EBUSY; } -static int dmm32at_ai_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int dmm32at_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - int n; - unsigned char chan; - int range; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); int ret; - - /* get the channel and range number */ - - chan = CR_CHAN(insn->chanspec) & (s->n_chan - 1); - range = CR_RANGE(insn->chanspec); + int i; /* zero scan and fifo control and reset fifo */ outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL); - /* write the ai channel range regs */ + /* set the channel and range */ outb(chan, dev->iobase + DMM32AT_AILOW); outb(chan, dev->iobase + DMM32AT_AIHIGH); - /* set the range bits */ outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); /* wait for circuit to settle */ @@ -209,22 +204,18 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev, if (ret) return ret; - /* convert n samples */ - for (n = 0; n < insn->n; n++) { - /* trigger conversion */ + for (i = 0; i < insn->n; i++) { outb(0xff, dev->iobase + DMM32AT_CONV); - /* wait for conversion to end */ ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, DMM32AT_AISTAT); if (ret) return ret; - data[n] = dmm32at_ai_get_sample(dev, s); + data[i] = dmm32at_ai_get_sample(dev, s); } - /* return the number of samples read/written */ - return n; + return insn->n; } static int dmm32at_ns_to_timer(unsigned int *ns, unsigned int flags) @@ -693,7 +684,7 @@ static int dmm32at_attach(struct comedi_device *dev, s->n_chan = 32; s->maxdata = 0xffff; s->range_table = &dmm32at_airanges; - s->insn_read = dmm32at_ai_rinsn; + s->insn_read = dmm32at_ai_insn_read; if (dev->irq) { dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; -- cgit v1.2.3-59-g8ed1b From 593ea59de723e32dd584ceb57efcdb96a5bca975 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:21 -0700 Subject: staging: comedi: dmm32at: introduce dmm32at_reset() For aesthetics, factor the board reset and detection code out of the (*attach) function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 64 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index b21d08df4555..301bbb69698a 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -610,21 +610,12 @@ static int dmm32at_dio_insn_config(struct comedi_device *dev, return insn->n; } -static int dmm32at_attach(struct comedi_device *dev, - struct comedi_devconfig *it) +/* Make sure the board is there and put it to a known state */ +static int dmm32at_reset(struct comedi_device *dev) { - struct dmm32at_private *devpriv; - int ret; - struct comedi_subdevice *s; + struct dmm32at_private *devpriv = dev->private; unsigned char aihi, ailo, fifostat, aistat, intstat, airback; - ret = comedi_request_region(dev, it->options[0], 0x10); - if (ret) - return ret; - - /* the following just makes sure the board is there and gets - it to a known state */ - /* reset the board */ outb(DMM32AT_RESET, dev->iobase + DMM32AT_CNTRL); @@ -655,10 +646,40 @@ static int dmm32at_attach(struct comedi_device *dev, intstat = inb(dev->iobase + DMM32AT_INTCLOCK); airback = inb(dev->iobase + DMM32AT_AIRBACK); - if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) || - (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) { - dev_err(dev->class_dev, "board detection failed\n"); + if (ailo != 0x00 || aihi != 0x1f || fifostat != 0x80 || + aistat != 0x60 || intstat != 0x00 || airback != 0x0c) return -EIO; + + /* get access to the DIO regs */ + outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL); + /* set the DIO's to the defualt input setting */ + devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB | + DMM32AT_DIRCL | DMM32AT_DIRCH | + DMM32AT_DIENABLE; + outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); + + return 0; +} + +static int dmm32at_attach(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + struct dmm32at_private *devpriv; + struct comedi_subdevice *s; + int 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; + + ret = dmm32at_reset(dev); + if (ret) { + dev_err(dev->class_dev, "board detection failed\n"); + return ret; } if (it->options[1]) { @@ -668,10 +689,6 @@ static int dmm32at_attach(struct comedi_device *dev, dev->irq = it->options[1]; } - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; @@ -710,15 +727,6 @@ static int dmm32at_attach(struct comedi_device *dev, s = &dev->subdevices[2]; /* digital i/o subdevice */ - - /* get access to the DIO regs */ - outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL); - /* set the DIO's to the defualt input setting */ - devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB | - DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE; - outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); - - /* set up the subdevice */ s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 24; -- cgit v1.2.3-59-g8ed1b From 646b55ee6418dd5f20eadc3cd6a4e04f4e1fa1a5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:22 -0700 Subject: staging: comedi: dmm32at: tidy up subdevice initialization For aesthetics, add some whitespace to the subdevice initialization. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 58 +++++++++++++++----------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 301bbb69698a..5e8a8db12972 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -693,48 +693,46 @@ static int dmm32at_attach(struct comedi_device *dev, if (ret) return ret; + /* Analog Input subdevice */ s = &dev->subdevices[0]; - /* analog input subdevice */ - s->type = COMEDI_SUBD_AI; - /* we support single-ended (ground) and differential */ - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF; - s->n_chan = 32; - s->maxdata = 0xffff; - s->range_table = &dmm32at_airanges; - s->insn_read = dmm32at_ai_insn_read; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF; + s->n_chan = 32; + s->maxdata = 0xffff; + s->range_table = &dmm32at_airanges; + s->insn_read = dmm32at_ai_insn_read; if (dev->irq) { dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = 32; - s->do_cmd = dmm32at_ai_cmd; - s->do_cmdtest = dmm32at_ai_cmdtest; - s->cancel = dmm32at_ai_cancel; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = s->n_chan; + s->do_cmd = dmm32at_ai_cmd; + s->do_cmdtest = dmm32at_ai_cmdtest; + s->cancel = dmm32at_ai_cancel; } + /* Analog Output subdevice */ s = &dev->subdevices[1]; - /* analog output subdevice */ - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 4; - s->maxdata = 0x0fff; - s->range_table = &dmm32at_aoranges; - s->insn_write = dmm32at_ao_insn_write; - s->insn_read = comedi_readback_insn_read; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 4; + s->maxdata = 0x0fff; + s->range_table = &dmm32at_aoranges; + s->insn_write = dmm32at_ao_insn_write; + s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) return ret; + /* Digital I/O subdevice */ s = &dev->subdevices[2]; - /* digital i/o subdevice */ - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 24; - s->maxdata = 1; - s->state = 0; - s->range_table = &range_digital; - s->insn_bits = dmm32at_dio_insn_bits; - s->insn_config = dmm32at_dio_insn_config; + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 24; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = dmm32at_dio_insn_bits; + s->insn_config = dmm32at_dio_insn_config; return 0; } -- cgit v1.2.3-59-g8ed1b From e5d44e8c8b0ea90627c41d1e350f6d01ee5f4a2a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:23 -0700 Subject: staging: comedi: dmm32at: tidy up cmd->scan_begin_{src, arg} validation This driver only supports a single scan_begin_src, TRIG_TIMER. Tidy up the (*do_cmdtest) validation of the cmd->scan_begin_{src,arg}. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 36 ++++++++------------------------ 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 5e8a8db12972..9a46a669179e 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -261,8 +261,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, /* 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->scan_begin_src, TRIG_TIMER); err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER /*| TRIG_EXT */); err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); @@ -273,7 +272,6 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, /* 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); @@ -286,20 +284,8 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); -#define MAX_SCAN_SPEED 1000000 /* in nanoseconds */ -#define MIN_SCAN_SPEED 1000000000 /* in nanoseconds */ - - if (cmd->scan_begin_src == TRIG_TIMER) { - err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, - MAX_SCAN_SPEED); - err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, - MIN_SCAN_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); - } + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 1000000); + err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 1000000000); if (cmd->convert_src == TRIG_TIMER) { if (cmd->convert_arg >= 17500) @@ -328,21 +314,17 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - if (cmd->scan_begin_src == TRIG_TIMER) { - arg = cmd->scan_begin_arg; - dmm32at_ns_to_timer(&arg, cmd->flags); - err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); - } + arg = cmd->scan_begin_arg; + dmm32at_ns_to_timer(&arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); + if (cmd->convert_src == TRIG_TIMER) { arg = cmd->convert_arg; dmm32at_ns_to_timer(&arg, cmd->flags); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); - if (cmd->scan_begin_src == TRIG_TIMER) { - arg = cmd->convert_arg * cmd->scan_end_arg; - err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, - arg); - } + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3-59-g8ed1b From 85b0e7668a8d187c2bd59f5f60338168513e5602 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:24 -0700 Subject: staging: comedi: dmm32at: tidy up cmd->convert_{src, arg} validation This driver only supports a single convert_src, TRIG_TIMER. Tidy up the (*do_cmdtest) validation of the cmd->convert_{src,arg}. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 40 +++++++++++--------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 9a46a669179e..637b6651e559 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -262,8 +262,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER); - err |= cfc_check_trigger_src(&cmd->convert_src, - TRIG_TIMER /*| TRIG_EXT */); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER); err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); @@ -272,7 +271,6 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, /* Step 2a : make sure trigger sources are unique */ - err |= cfc_check_trigger_is_unique(cmd->convert_src); err |= cfc_check_trigger_is_unique(cmd->stop_src); /* Step 2b : and mutually compatible */ @@ -287,20 +285,14 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 1000000); err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 1000000000); - if (cmd->convert_src == TRIG_TIMER) { - if (cmd->convert_arg >= 17500) - cmd->convert_arg = 20000; - else if (cmd->convert_arg >= 12500) - cmd->convert_arg = 15000; - else if (cmd->convert_arg >= 7500) - cmd->convert_arg = 10000; - else - cmd->convert_arg = 5000; - } else { - /* external trigger */ - /* see above */ - err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 9); - } + if (cmd->convert_arg >= 17500) + cmd->convert_arg = 20000; + else if (cmd->convert_arg >= 12500) + cmd->convert_arg = 15000; + else if (cmd->convert_arg >= 7500) + cmd->convert_arg = 10000; + else + cmd->convert_arg = 5000; err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); @@ -314,18 +306,12 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - arg = cmd->scan_begin_arg; + arg = cmd->convert_arg; dmm32at_ns_to_timer(&arg, cmd->flags); - err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); - if (cmd->convert_src == TRIG_TIMER) { - arg = cmd->convert_arg; - dmm32at_ns_to_timer(&arg, cmd->flags); - err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); - - arg = cmd->convert_arg * cmd->scan_end_arg; - err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg); - } + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg); if (err) return 4; -- cgit v1.2.3-59-g8ed1b From ec1b2320009bc2a9893c7a6eef32fdced0b4455d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:25 -0700 Subject: staging: comedi: dmm32at: remove dmm32at_ns_to_timer() This function is not necessary. It simply returns the 'ns' value that was passed to it. Remove it as well as the unnecessary Step 4 check of the cmd->convert_arg. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 637b6651e559..297338f4f46b 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -218,12 +218,6 @@ static int dmm32at_ai_insn_read(struct comedi_device *dev, return insn->n; } -static int dmm32at_ns_to_timer(unsigned int *ns, unsigned int flags) -{ - /* trivial timer */ - return *ns; -} - static int dmm32at_ai_check_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -304,11 +298,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, if (err) return 3; - /* step 4: fix up any arguments */ - - arg = cmd->convert_arg; - dmm32at_ns_to_timer(&arg, cmd->flags); - err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + /* Step 4: fix up any arguments */ arg = cmd->convert_arg * cmd->scan_end_arg; err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg); -- cgit v1.2.3-59-g8ed1b From 2dd9681196c56a7ae48ec99522acc23843844bee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:26 -0700 Subject: staging: comedi: dmm32at: remove unused members of the private data The 'data' and 'ai_inuse' members in the private data are not used in the driver. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 297338f4f46b..6413f60c6f6b 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -151,8 +151,6 @@ static const struct comedi_lrange dmm32at_aoranges = { }; struct dmm32at_private { - int data; - int ai_inuse; unsigned char dio_config; }; -- cgit v1.2.3-59-g8ed1b From c5f1b1e5529ef46769615ac8f4e38d0830b5a9c0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:27 -0700 Subject: staging: comedi: dmm32at: introduce dmm32at_ai_set_chanspec() Introduce a helper function to set the analog input channel scan and range control registers. Use the new helper in the analog input (*insn_read) and (*do_cmd) functions. The extra sanity checks in the (*do_cmd) are not necessary. The cmd->chanlist will always be valid and the (*do_cmdtest) validates the channel list in Step 5. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 53 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 6413f60c6f6b..dc222d13e318 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -154,6 +154,24 @@ struct dmm32at_private { unsigned char dio_config; }; +static void dmm32at_ai_set_chanspec(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chanspec, int nchan) +{ + unsigned int chan = CR_CHAN(chanspec); + unsigned int range = CR_RANGE(chanspec); + unsigned int last_chan = (chan + nchan - 1) % s->n_chan; + + outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL); + + if (nchan > 1) + outb(DMM32AT_SCANENABLE, dev->iobase + DMM32AT_FIFOCNTRL); + + outb(chan, dev->iobase + DMM32AT_AILOW); + outb(last_chan, dev->iobase + DMM32AT_AIHIGH); + outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); +} + static unsigned int dmm32at_ai_get_sample(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -184,18 +202,10 @@ static int dmm32at_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int range = CR_RANGE(insn->chanspec); int ret; int i; - /* zero scan and fifo control and reset fifo */ - outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL); - - /* set the channel and range */ - outb(chan, dev->iobase + DMM32AT_AILOW); - outb(chan, dev->iobase + DMM32AT_AIHIGH); - outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); + dmm32at_ai_set_chanspec(dev, s, insn->chanspec, 1); /* wait for circuit to settle */ ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, DMM32AT_AIRBACK); @@ -347,32 +357,9 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; - int range; - unsigned char chanlo, chanhi; int ret; - if (!cmd->chanlist) - return -EINVAL; - - /* get the channel list and range */ - chanlo = CR_CHAN(cmd->chanlist[0]) & (s->n_chan - 1); - chanhi = chanlo + cmd->chanlist_len - 1; - if (chanhi >= s->n_chan) - return -EINVAL; - range = CR_RANGE(cmd->chanlist[0]); - - /* reset fifo */ - outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL); - - /* set scan enable */ - outb(DMM32AT_SCANENABLE, dev->iobase + DMM32AT_FIFOCNTRL); - - /* write the ai channel range regs */ - outb(chanlo, dev->iobase + DMM32AT_AILOW); - outb(chanhi, dev->iobase + DMM32AT_AIHIGH); - - /* set the range bits */ - outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); + dmm32at_ai_set_chanspec(dev, s, cmd->chanlist[0], cmd->chanlist_len); /* reset the interrupt just in case */ outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL); -- cgit v1.2.3-59-g8ed1b From 387ca51f7c403b342a9e382ac15c6df461ea2190 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:28 -0700 Subject: staging: comedi: dmm32at: use 8255 module for Digital I/O subdevice The Dimond-MM-32-AT board uses an internal 82C55-type digital I/O circuit to provide the 24 digital I/O lines. The only quirk is the need to set the page selection bits in the control register to select page 1 addresses. Instead of duplicating the 8255 code, provide an (*io) callback and use the 8255 module to support this subdevice. This also removes the need for the private data in this driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/dmm32at.c | 123 +++---------------------------- 2 files changed, 13 insertions(+), 111 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index cf52577349a7..a8201fe87512 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -384,6 +384,7 @@ config COMEDI_DT282X config COMEDI_DMM32AT tristate "Diamond Systems MM-32-AT PC/104 board support" + select COMEDI_8255 ---help--- Enable support for Diamond Systems MM-32-AT PC/104 boards diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index dc222d13e318..df0a47fe0d11 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -37,6 +37,7 @@ Configuration Options: #include #include "../comedidev.h" +#include "8255.h" #include "comedi_fc.h" /* Board register addresses */ @@ -69,10 +70,7 @@ Configuration Options: #define DMM32AT_CLK2 0x0e #define DMM32AT_CLKCT 0x0f -#define DMM32AT_DIOA 0x0c -#define DMM32AT_DIOB 0x0d -#define DMM32AT_DIOC 0x0e -#define DMM32AT_DIOCONF 0x0f +#define DMM32AT_8255_IOBASE 0x0c /* Page 1 registers */ /* Board register values. */ @@ -113,13 +111,6 @@ Configuration Options: #define DMM32AT_CLKCT1 0x56 /* mode3 counter 1 - write low byte only */ #define DMM32AT_CLKCT2 0xb6 /* mode3 counter 2 - write high and low byte */ -/* DMM32AT_DIOCONF 0x0f */ -#define DMM32AT_DIENABLE 0x80 -#define DMM32AT_DIRA 0x10 -#define DMM32AT_DIRB 0x02 -#define DMM32AT_DIRCL 0x01 -#define DMM32AT_DIRCH 0x08 - /* board AI ranges in comedi structure */ static const struct comedi_lrange dmm32at_airanges = { 4, { @@ -150,10 +141,6 @@ static const struct comedi_lrange dmm32at_aoranges = { } }; -struct dmm32at_private { - unsigned char dio_config; -}; - static void dmm32at_ai_set_chanspec(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int chanspec, int nchan) @@ -472,91 +459,22 @@ static int dmm32at_ao_insn_write(struct comedi_device *dev, return insn->n; } -static int dmm32at_dio_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct dmm32at_private *devpriv = dev->private; - unsigned int mask; - unsigned int val; - - mask = comedi_dio_update_state(s, data); - if (mask) { - /* get access to the DIO regs */ - outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL); - - /* if either part of dio is set for output */ - if (((devpriv->dio_config & DMM32AT_DIRCL) == 0) || - ((devpriv->dio_config & DMM32AT_DIRCH) == 0)) { - val = (s->state & 0x00ff0000) >> 16; - outb(val, dev->iobase + DMM32AT_DIOC); - } - if ((devpriv->dio_config & DMM32AT_DIRB) == 0) { - val = (s->state & 0x0000ff00) >> 8; - outb(val, dev->iobase + DMM32AT_DIOB); - } - if ((devpriv->dio_config & DMM32AT_DIRA) == 0) { - val = (s->state & 0x000000ff); - outb(val, dev->iobase + DMM32AT_DIOA); - } - } - - val = inb(dev->iobase + DMM32AT_DIOA); - val |= inb(dev->iobase + DMM32AT_DIOB) << 8; - val |= inb(dev->iobase + DMM32AT_DIOC) << 16; - s->state = val; - - data[1] = val; - - return insn->n; -} - -static int dmm32at_dio_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int dmm32at_8255_io(struct comedi_device *dev, + int dir, int port, int data, unsigned long regbase) { - struct dmm32at_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - unsigned char chanbit; - int ret; - - if (chan < 8) { - mask = 0x0000ff; - chanbit = DMM32AT_DIRA; - } else if (chan < 16) { - mask = 0x00ff00; - chanbit = DMM32AT_DIRB; - } else if (chan < 20) { - mask = 0x0f0000; - chanbit = DMM32AT_DIRCL; - } else { - mask = 0xf00000; - chanbit = DMM32AT_DIRCH; - } - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - - if (data[0] == INSN_CONFIG_DIO_OUTPUT) - devpriv->dio_config &= ~chanbit; - else - devpriv->dio_config |= chanbit; /* get access to the DIO regs */ outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL); - /* set the DIO's to the new configuration setting */ - outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); - return insn->n; + if (dir) { + outb(data, dev->iobase + regbase + port); + return 0; + } + return inb(dev->iobase + regbase + port); } /* Make sure the board is there and put it to a known state */ static int dmm32at_reset(struct comedi_device *dev) { - struct dmm32at_private *devpriv = dev->private; unsigned char aihi, ailo, fifostat, aistat, intstat, airback; /* reset the board */ @@ -593,28 +511,15 @@ static int dmm32at_reset(struct comedi_device *dev) aistat != 0x60 || intstat != 0x00 || airback != 0x0c) return -EIO; - /* get access to the DIO regs */ - outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL); - /* set the DIO's to the defualt input setting */ - devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB | - DMM32AT_DIRCL | DMM32AT_DIRCH | - DMM32AT_DIENABLE; - outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); - return 0; } static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - struct dmm32at_private *devpriv; struct comedi_subdevice *s; int 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; @@ -669,13 +574,9 @@ static int dmm32at_attach(struct comedi_device *dev, /* Digital I/O subdevice */ s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 24; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = dmm32at_dio_insn_bits; - s->insn_config = dmm32at_dio_insn_config; + ret = subdev_8255_init(dev, s, dmm32at_8255_io, DMM32AT_8255_IOBASE); + if (ret) + return ret; return 0; } -- cgit v1.2.3-59-g8ed1b From 32b994eaeed6300ad36b94ae089021bfdf84dc7f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:29 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_CONV For aesthetics, rename this define used for the Start A/D Conversion register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index df0a47fe0d11..ee6e510fef97 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -41,7 +41,7 @@ Configuration Options: #include "comedi_fc.h" /* Board register addresses */ -#define DMM32AT_CONV 0x00 +#define DMM32AT_AI_START_CONV_REG 0x00 #define DMM32AT_AILSB 0x00 #define DMM32AT_AUXDOUT 0x01 #define DMM32AT_AIMSB 0x01 @@ -200,7 +200,7 @@ static int dmm32at_ai_insn_read(struct comedi_device *dev, return ret; for (i = 0; i < insn->n; i++) { - outb(0xff, dev->iobase + DMM32AT_CONV); + outb(0xff, dev->iobase + DMM32AT_AI_START_CONV_REG); ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, DMM32AT_AISTAT); @@ -365,7 +365,7 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } else { /* start the interrups and initiate a single scan */ outb(DMM32AT_ADINT, dev->iobase + DMM32AT_INTCLOCK); - outb(0xff, dev->iobase + DMM32AT_CONV); + outb(0xff, dev->iobase + DMM32AT_AI_START_CONV_REG); } return 0; -- cgit v1.2.3-59-g8ed1b From 3f4beddff34832fa38c574c55d1fc60c286cb894 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:30 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_AI[LM]SB For aesthetics, rename these defines used for the A/D LSB/MSB registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index ee6e510fef97..e3981115c7b7 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -42,9 +42,9 @@ Configuration Options: /* Board register addresses */ #define DMM32AT_AI_START_CONV_REG 0x00 -#define DMM32AT_AILSB 0x00 +#define DMM32AT_AI_LSB_REG 0x00 #define DMM32AT_AUXDOUT 0x01 -#define DMM32AT_AIMSB 0x01 +#define DMM32AT_AI_MSB_REG 0x01 #define DMM32AT_AILOW 0x02 #define DMM32AT_AIHIGH 0x03 @@ -164,8 +164,8 @@ static unsigned int dmm32at_ai_get_sample(struct comedi_device *dev, { unsigned int val; - val = inb(dev->iobase + DMM32AT_AILSB); - val |= (inb(dev->iobase + DMM32AT_AIMSB) << 8); + val = inb(dev->iobase + DMM32AT_AI_LSB_REG); + val |= (inb(dev->iobase + DMM32AT_AI_MSB_REG) << 8); /* munge two's complement value to offset binary */ return comedi_offset_munge(s, val); -- cgit v1.2.3-59-g8ed1b From 02a173eefbdc987e4729abe22399587a78828da6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:31 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_AUXDOUT For aesthetics, rename this define used for the Auxillary Digital Output register. This register is currently not used in the driver. Document the bits of the register for completeness. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index e3981115c7b7..2e5d5a43b1b6 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -43,7 +43,10 @@ Configuration Options: /* Board register addresses */ #define DMM32AT_AI_START_CONV_REG 0x00 #define DMM32AT_AI_LSB_REG 0x00 -#define DMM32AT_AUXDOUT 0x01 +#define DMM32AT_AUX_DOUT_REG 0x01 +#define DMM32AT_AUX_DOUT2 (1 << 2) /* J3.42 - OUT2 (OUT2EN) */ +#define DMM32AT_AUX_DOUT1 (1 << 1) /* J3.43 */ +#define DMM32AT_AUX_DOUT0 (1 << 0) /* J3.44 - OUT0 (OUT0EN) */ #define DMM32AT_AI_MSB_REG 0x01 #define DMM32AT_AILOW 0x02 #define DMM32AT_AIHIGH 0x03 -- cgit v1.2.3-59-g8ed1b From d443fae2341abddf04676deed0b8b3112eb17636 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:32 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_AI{LOW,HIGH} For aesthetics, rename these defines used for the A/D Low/High Channel registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 2e5d5a43b1b6..f0519bc0cd9e 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -48,8 +48,8 @@ Configuration Options: #define DMM32AT_AUX_DOUT1 (1 << 1) /* J3.43 */ #define DMM32AT_AUX_DOUT0 (1 << 0) /* J3.44 - OUT0 (OUT0EN) */ #define DMM32AT_AI_MSB_REG 0x01 -#define DMM32AT_AILOW 0x02 -#define DMM32AT_AIHIGH 0x03 +#define DMM32AT_AI_LO_CHAN_REG 0x02 +#define DMM32AT_AI_HI_CHAN_REG 0x03 #define DMM32AT_DACSTAT 0x04 #define DMM32AT_DACLSB_REG 0x04 @@ -157,8 +157,8 @@ static void dmm32at_ai_set_chanspec(struct comedi_device *dev, if (nchan > 1) outb(DMM32AT_SCANENABLE, dev->iobase + DMM32AT_FIFOCNTRL); - outb(chan, dev->iobase + DMM32AT_AILOW); - outb(last_chan, dev->iobase + DMM32AT_AIHIGH); + outb(chan, dev->iobase + DMM32AT_AI_LO_CHAN_REG); + outb(last_chan, dev->iobase + DMM32AT_AI_HI_CHAN_REG); outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); } @@ -493,8 +493,8 @@ static int dmm32at_reset(struct comedi_device *dev) outb(0x0, dev->iobase + DMM32AT_INTCLOCK); /* write a test channel range, the high 3 bits should drop */ - outb(0x80, dev->iobase + DMM32AT_AILOW); - outb(0xff, dev->iobase + DMM32AT_AIHIGH); + outb(0x80, dev->iobase + DMM32AT_AI_LO_CHAN_REG); + outb(0xff, dev->iobase + DMM32AT_AI_HI_CHAN_REG); /* set the range at 10v unipolar */ outb(DMM32AT_RANGE_U10, dev->iobase + DMM32AT_AICONF); @@ -503,8 +503,8 @@ static int dmm32at_reset(struct comedi_device *dev) udelay(100); /* read back the values */ - ailo = inb(dev->iobase + DMM32AT_AILOW); - aihi = inb(dev->iobase + DMM32AT_AIHIGH); + ailo = inb(dev->iobase + DMM32AT_AI_LO_CHAN_REG); + aihi = inb(dev->iobase + DMM32AT_AI_HI_CHAN_REG); fifostat = inb(dev->iobase + DMM32AT_FIFOSTAT); aistat = inb(dev->iobase + DMM32AT_AISTAT); intstat = inb(dev->iobase + DMM32AT_INTCLOCK); -- cgit v1.2.3-59-g8ed1b From 0db01ed89ee9a5474a6bbf55bda75baddf94b623 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:33 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_DAC[LM]SB For aesthetics, rename these defines used for the D/A LSB/MSB registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index f0519bc0cd9e..39f416c3c402 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -50,10 +50,9 @@ Configuration Options: #define DMM32AT_AI_MSB_REG 0x01 #define DMM32AT_AI_LO_CHAN_REG 0x02 #define DMM32AT_AI_HI_CHAN_REG 0x03 - #define DMM32AT_DACSTAT 0x04 -#define DMM32AT_DACLSB_REG 0x04 -#define DMM32AT_DACMSB_REG 0x05 +#define DMM32AT_AO_LSB_REG 0x04 +#define DMM32AT_AO_MSB_REG 0x05 #define DMM32AT_DACMSB_CHAN(x) ((x) << 6) #define DMM32AT_FIFOCNTRL 0x07 @@ -444,9 +443,9 @@ static int dmm32at_ao_insn_write(struct comedi_device *dev, int ret; /* write LSB then MSB + chan to load DAC */ - outb(val & 0xff, dev->iobase + DMM32AT_DACLSB_REG); + outb(val & 0xff, dev->iobase + DMM32AT_AO_LSB_REG); outb((val >> 8) | DMM32AT_DACMSB_CHAN(chan), - dev->iobase + DMM32AT_DACMSB_REG); + dev->iobase + DMM32AT_AO_MSB_REG); /* wait for circuit to settle */ ret = comedi_timeout(dev, s, insn, dmm32at_ao_eoc, 0); @@ -454,7 +453,7 @@ static int dmm32at_ao_insn_write(struct comedi_device *dev, return ret; /* dummy read to update DAC */ - inb(dev->iobase + DMM32AT_DACMSB_REG); + inb(dev->iobase + DMM32AT_AO_MSB_REG); s->readback[chan] = val; } -- cgit v1.2.3-59-g8ed1b From 668a02d1c8bc6c635e6ce215f1c8c6bed3e0dc07 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:34 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_DACSTAT For aesthetics, rename this define used for the Status / Auxillary Digital Inputs register. Document the bits in the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 39f416c3c402..2bfa21bb03e7 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -50,7 +50,13 @@ Configuration Options: #define DMM32AT_AI_MSB_REG 0x01 #define DMM32AT_AI_LO_CHAN_REG 0x02 #define DMM32AT_AI_HI_CHAN_REG 0x03 -#define DMM32AT_DACSTAT 0x04 +#define DMM32AT_AUX_DI_REG 0x04 +#define DMM32AT_AUX_DI_DACBUSY (1 << 7) +#define DMM32AT_AUX_DI_CALBUSY (1 << 6) +#define DMM32AT_AUX_DI3 (1 << 3) /* J3.45 - ADCLK (CLKSEL) */ +#define DMM32AT_AUX_DI2 (1 << 2) /* J3.46 - GATE12 (GT12EN) */ +#define DMM32AT_AUX_DI1 (1 << 1) /* J3.47 - GATE0 (GT0EN) */ +#define DMM32AT_AUX_DI0 (1 << 0) /* J3.48 - CLK0 (SRC0) */ #define DMM32AT_AO_LSB_REG 0x04 #define DMM32AT_AO_MSB_REG 0x05 #define DMM32AT_DACMSB_CHAN(x) ((x) << 6) @@ -76,9 +82,6 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_DACSTAT 0x04 */ -#define DMM32AT_DACBUSY 0x80 - /* DMM32AT_FIFOCNTRL 0x07 */ #define DMM32AT_FIFORESET 0x02 #define DMM32AT_SCANENABLE 0x04 @@ -424,8 +427,8 @@ static int dmm32at_ao_eoc(struct comedi_device *dev, { unsigned char status; - status = inb(dev->iobase + DMM32AT_DACSTAT); - if ((status & DMM32AT_DACBUSY) == 0) + status = inb(dev->iobase + DMM32AT_AUX_DI_REG); + if ((status & DMM32AT_AUX_DI_DACBUSY) == 0) return 0; return -EBUSY; } -- cgit v1.2.3-59-g8ed1b From e46f7651d0e34ac4fbc208bb70c7d6d6166742f3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:35 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_DACMSB_CHAN For aesthetics, rename this define used to set the DACH[10] bits in the DAC MSB register to select the D/A channel. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 2bfa21bb03e7..8585069bc8fe 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -59,7 +59,7 @@ Configuration Options: #define DMM32AT_AUX_DI0 (1 << 0) /* J3.48 - CLK0 (SRC0) */ #define DMM32AT_AO_LSB_REG 0x04 #define DMM32AT_AO_MSB_REG 0x05 -#define DMM32AT_DACMSB_CHAN(x) ((x) << 6) +#define DMM32AT_AO_MSB_DACH(x) ((x) << 6) #define DMM32AT_FIFOCNTRL 0x07 #define DMM32AT_FIFOSTAT 0x07 @@ -447,7 +447,7 @@ static int dmm32at_ao_insn_write(struct comedi_device *dev, /* write LSB then MSB + chan to load DAC */ outb(val & 0xff, dev->iobase + DMM32AT_AO_LSB_REG); - outb((val >> 8) | DMM32AT_DACMSB_CHAN(chan), + outb((val >> 8) | DMM32AT_AO_MSB_DACH(chan), dev->iobase + DMM32AT_AO_MSB_REG); /* wait for circuit to settle */ -- cgit v1.2.3-59-g8ed1b From d18f166773c77a8bc4bd14652b0c915d1195f80e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:36 -0700 Subject: staging: comedi: dmm32at: define the FIFO Depth register This driver currently does not use the FIFO. For completeness, define the offset to the FIFO Depth register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 8585069bc8fe..463a62b843bc 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -60,6 +60,7 @@ Configuration Options: #define DMM32AT_AO_LSB_REG 0x04 #define DMM32AT_AO_MSB_REG 0x05 #define DMM32AT_AO_MSB_DACH(x) ((x) << 6) +#define DMM32AT_FIFO_DEPTH_REG 0x06 #define DMM32AT_FIFOCNTRL 0x07 #define DMM32AT_FIFOSTAT 0x07 -- cgit v1.2.3-59-g8ed1b From b8c17c479ae429e2e696f219781e6ad8799a04f2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:37 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_FIFOCNTRL For aesthetics, rename this define used for the FIFO Control register. Also, rename the defines used for the bits of this register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 463a62b843bc..a58d51d1f533 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -61,8 +61,10 @@ Configuration Options: #define DMM32AT_AO_MSB_REG 0x05 #define DMM32AT_AO_MSB_DACH(x) ((x) << 6) #define DMM32AT_FIFO_DEPTH_REG 0x06 - -#define DMM32AT_FIFOCNTRL 0x07 +#define DMM32AT_FIFO_CTRL_REG 0x07 +#define DMM32AT_FIFO_CTRL_FIFOEN (1 << 3) +#define DMM32AT_FIFO_CTRL_SCANEN (1 << 2) +#define DMM32AT_FIFO_CTRL_FIFORST (1 << 1) #define DMM32AT_FIFOSTAT 0x07 #define DMM32AT_CNTRL 0x08 @@ -83,10 +85,6 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_FIFOCNTRL 0x07 */ -#define DMM32AT_FIFORESET 0x02 -#define DMM32AT_SCANENABLE 0x04 - /* DMM32AT_CNTRL 0x08 */ #define DMM32AT_RESET 0x20 #define DMM32AT_INTRESET 0x08 @@ -155,10 +153,11 @@ static void dmm32at_ai_set_chanspec(struct comedi_device *dev, unsigned int range = CR_RANGE(chanspec); unsigned int last_chan = (chan + nchan - 1) % s->n_chan; - outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL); + outb(DMM32AT_FIFO_CTRL_FIFORST, dev->iobase + DMM32AT_FIFO_CTRL_REG); if (nchan > 1) - outb(DMM32AT_SCANENABLE, dev->iobase + DMM32AT_FIFOCNTRL); + outb(DMM32AT_FIFO_CTRL_SCANEN, + dev->iobase + DMM32AT_FIFO_CTRL_REG); outb(chan, dev->iobase + DMM32AT_AI_LO_CHAN_REG); outb(last_chan, dev->iobase + DMM32AT_AI_HI_CHAN_REG); @@ -490,7 +489,7 @@ static int dmm32at_reset(struct comedi_device *dev) udelay(1000); /* zero scan and fifo control */ - outb(0x0, dev->iobase + DMM32AT_FIFOCNTRL); + outb(0x0, dev->iobase + DMM32AT_FIFO_CTRL_REG); /* zero interrupt and clock control */ outb(0x0, dev->iobase + DMM32AT_INTCLOCK); -- cgit v1.2.3-59-g8ed1b From 7586f90784be0e7153f6ec4de8317168874c4a6e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:38 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_FIFOSTAT For aesthetics, rename this define used for the FIFO Status register. Define the bits of the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index a58d51d1f533..c7f9602ce6e3 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -65,7 +65,14 @@ Configuration Options: #define DMM32AT_FIFO_CTRL_FIFOEN (1 << 3) #define DMM32AT_FIFO_CTRL_SCANEN (1 << 2) #define DMM32AT_FIFO_CTRL_FIFORST (1 << 1) -#define DMM32AT_FIFOSTAT 0x07 +#define DMM32AT_FIFO_STATUS_REG 0x07 +#define DMM32AT_FIFO_STATUS_EF (1 << 7) +#define DMM32AT_FIFO_STATUS_HF (1 << 6) +#define DMM32AT_FIFO_STATUS_FF (1 << 5) +#define DMM32AT_FIFO_STATUS_OVF (1 << 4) +#define DMM32AT_FIFO_STATUS_FIFOEN (1 << 3) +#define DMM32AT_FIFO_STATUS_SCANEN (1 << 2) +#define DMM32AT_FIFO_STATUS_PAGE_MASK (3 << 0) #define DMM32AT_CNTRL 0x08 #define DMM32AT_AISTAT 0x08 @@ -507,12 +514,13 @@ static int dmm32at_reset(struct comedi_device *dev) /* read back the values */ ailo = inb(dev->iobase + DMM32AT_AI_LO_CHAN_REG); aihi = inb(dev->iobase + DMM32AT_AI_HI_CHAN_REG); - fifostat = inb(dev->iobase + DMM32AT_FIFOSTAT); + fifostat = inb(dev->iobase + DMM32AT_FIFO_STATUS_REG); aistat = inb(dev->iobase + DMM32AT_AISTAT); intstat = inb(dev->iobase + DMM32AT_INTCLOCK); airback = inb(dev->iobase + DMM32AT_AIRBACK); - if (ailo != 0x00 || aihi != 0x1f || fifostat != 0x80 || + if (ailo != 0x00 || aihi != 0x1f || + fifostat != DMM32AT_FIFO_STATUS_EF || aistat != 0x60 || intstat != 0x00 || airback != 0x0c) return -EIO; -- cgit v1.2.3-59-g8ed1b From d900a48841091e07d34d26a7cb7b29ce0447752c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:39 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_CNTRL For aesthetics, rename this define used for the Miscellaneous Control register. Also, rename the defines for the bits of the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index c7f9602ce6e3..4ebbd98e333d 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -73,8 +73,13 @@ Configuration Options: #define DMM32AT_FIFO_STATUS_FIFOEN (1 << 3) #define DMM32AT_FIFO_STATUS_SCANEN (1 << 2) #define DMM32AT_FIFO_STATUS_PAGE_MASK (3 << 0) - -#define DMM32AT_CNTRL 0x08 +#define DMM32AT_CTRL_REG 0x08 +#define DMM32AT_CTRL_RESETA (1 << 5) +#define DMM32AT_CTRL_RESETD (1 << 4) +#define DMM32AT_CTRL_INTRST (1 << 3) +#define DMM32AT_CTRL_PAGE_8254 (0 << 0) +#define DMM32AT_CTRL_PAGE_8255 (1 << 0) +#define DMM32AT_CTRL_PAGE_CALIB (3 << 0) #define DMM32AT_AISTAT 0x08 #define DMM32AT_INTCLOCK 0x09 @@ -92,12 +97,6 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_CNTRL 0x08 */ -#define DMM32AT_RESET 0x20 -#define DMM32AT_INTRESET 0x08 -#define DMM32AT_CLKACC 0x00 -#define DMM32AT_DIOACC 0x01 - /* DMM32AT_AISTAT 0x08 */ #define DMM32AT_STATUS 0x80 @@ -338,7 +337,7 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) outb(0, dev->iobase + DMM32AT_CNTRDIO); /* get access to the clock regs */ - outb(DMM32AT_CLKACC, dev->iobase + DMM32AT_CNTRL); + outb(DMM32AT_CTRL_PAGE_8254, dev->iobase + DMM32AT_CTRL_REG); /* write the counter 1 control word and low byte to counter */ outb(DMM32AT_CLKCT1, dev->iobase + DMM32AT_CLKCT); @@ -361,7 +360,7 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) dmm32at_ai_set_chanspec(dev, s, cmd->chanlist[0], cmd->chanlist_len); /* reset the interrupt just in case */ - outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL); + outb(DMM32AT_CTRL_INTRST, dev->iobase + DMM32AT_CTRL_REG); /* * wait for circuit to settle @@ -423,7 +422,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d) } /* reset the interrupt */ - outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL); + outb(DMM32AT_CTRL_INTRST, dev->iobase + DMM32AT_CTRL_REG); return IRQ_HANDLED; } @@ -475,7 +474,7 @@ static int dmm32at_8255_io(struct comedi_device *dev, int dir, int port, int data, unsigned long regbase) { /* get access to the DIO regs */ - outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL); + outb(DMM32AT_CTRL_PAGE_8255, dev->iobase + DMM32AT_CTRL_REG); if (dir) { outb(data, dev->iobase + regbase + port); @@ -490,7 +489,7 @@ static int dmm32at_reset(struct comedi_device *dev) unsigned char aihi, ailo, fifostat, aistat, intstat, airback; /* reset the board */ - outb(DMM32AT_RESET, dev->iobase + DMM32AT_CNTRL); + outb(DMM32AT_CTRL_RESETA, dev->iobase + DMM32AT_CTRL_REG); /* allow a millisecond to reset */ udelay(1000); -- cgit v1.2.3-59-g8ed1b From 4b82531e27c017d3e1a231fa9f87c5dd1bcda6fc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:40 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_AISTAT For aesthetics, rename this define used for the A/D Status register. Also, rename the defines for the bits of the register. The probe code in dmm32at_reset() checks this register to make sure the S/D1 and S/D0 bits are set. This check actually verifies that the board is configured (with jumpers on the board) with all the Analog Input channels operating in single-ended mode. Add a comment about this. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 4ebbd98e333d..3f36f0ebf3a9 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -80,7 +80,11 @@ Configuration Options: #define DMM32AT_CTRL_PAGE_8254 (0 << 0) #define DMM32AT_CTRL_PAGE_8255 (1 << 0) #define DMM32AT_CTRL_PAGE_CALIB (3 << 0) -#define DMM32AT_AISTAT 0x08 +#define DMM32AT_AI_STATUS_REG 0x08 +#define DMM32AT_AI_STATUS_STS (1 << 7) +#define DMM32AT_AI_STATUS_SD1 (1 << 6) +#define DMM32AT_AI_STATUS_SD0 (1 << 5) +#define DMM32AT_AI_STATUS_ADCH_MASK (0x1f << 0) #define DMM32AT_INTCLOCK 0x09 @@ -97,9 +101,6 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_AISTAT 0x08 */ -#define DMM32AT_STATUS 0x80 - /* DMM32AT_INTCLOCK 0x09 */ #define DMM32AT_ADINT 0x80 #define DMM32AT_CLKSEL 0x03 @@ -190,7 +191,7 @@ static int dmm32at_ai_status(struct comedi_device *dev, unsigned char status; status = inb(dev->iobase + context); - if ((status & DMM32AT_STATUS) == 0) + if ((status & DMM32AT_AI_STATUS_STS) == 0) return 0; return -EBUSY; } @@ -214,7 +215,7 @@ static int dmm32at_ai_insn_read(struct comedi_device *dev, outb(0xff, dev->iobase + DMM32AT_AI_START_CONV_REG); ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, - DMM32AT_AISTAT); + DMM32AT_AI_STATUS_REG); if (ret) return ret; @@ -514,13 +515,19 @@ static int dmm32at_reset(struct comedi_device *dev) ailo = inb(dev->iobase + DMM32AT_AI_LO_CHAN_REG); aihi = inb(dev->iobase + DMM32AT_AI_HI_CHAN_REG); fifostat = inb(dev->iobase + DMM32AT_FIFO_STATUS_REG); - aistat = inb(dev->iobase + DMM32AT_AISTAT); + aistat = inb(dev->iobase + DMM32AT_AI_STATUS_REG); intstat = inb(dev->iobase + DMM32AT_INTCLOCK); airback = inb(dev->iobase + DMM32AT_AIRBACK); + /* + * NOTE: The (DMM32AT_AI_STATUS_SD1 | DMM32AT_AI_STATUS_SD0) + * test makes this driver only work if the board is configured + * with all A/D channels set for single-ended operation. + */ if (ailo != 0x00 || aihi != 0x1f || fifostat != DMM32AT_FIFO_STATUS_EF || - aistat != 0x60 || intstat != 0x00 || airback != 0x0c) + aistat != (DMM32AT_AI_STATUS_SD1 | DMM32AT_AI_STATUS_SD0) || + intstat != 0x00 || airback != 0x0c) return -EIO; return 0; -- cgit v1.2.3-59-g8ed1b From 990c96d15efa77585e9e47ad57702cf65362ada6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:41 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_INTCLOCK For aesthetics, rename this define used for the Interrupt and A/D Clock Control and Status register. Also, rename the defines for the bits of the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 3f36f0ebf3a9..9058e327f0a1 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -85,8 +85,12 @@ Configuration Options: #define DMM32AT_AI_STATUS_SD1 (1 << 6) #define DMM32AT_AI_STATUS_SD0 (1 << 5) #define DMM32AT_AI_STATUS_ADCH_MASK (0x1f << 0) - -#define DMM32AT_INTCLOCK 0x09 +#define DMM32AT_INTCLK_REG 0x09 +#define DMM32AT_INTCLK_ADINT (1 << 7) +#define DMM32AT_INTCLK_DINT (1 << 6) +#define DMM32AT_INTCLK_TINT (1 << 5) +#define DMM32AT_INTCLK_CLKEN (1 << 1) /* 1=see below 0=software */ +#define DMM32AT_INTCLK_CLKSEL (1 << 0) /* 1=OUT2 0=EXTCLK */ #define DMM32AT_CNTRDIO 0x0a @@ -101,10 +105,6 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_INTCLOCK 0x09 */ -#define DMM32AT_ADINT 0x80 -#define DMM32AT_CLKSEL 0x03 - /* DMM32AT_CNTRDIO 0x0a */ #define DMM32AT_FREQ12 0x80 @@ -350,7 +350,9 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) outb(hi2, dev->iobase + DMM32AT_CLK2); /* enable the ai conversion interrupt and the clock to start scans */ - outb(DMM32AT_ADINT | DMM32AT_CLKSEL, dev->iobase + DMM32AT_INTCLOCK); + outb(DMM32AT_INTCLK_ADINT | + DMM32AT_INTCLK_CLKEN | DMM32AT_INTCLK_CLKSEL, + dev->iobase + DMM32AT_INTCLK_REG); } static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) @@ -376,7 +378,7 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) dmm32at_setaitimer(dev, cmd->scan_begin_arg); } else { /* start the interrups and initiate a single scan */ - outb(DMM32AT_ADINT, dev->iobase + DMM32AT_INTCLOCK); + outb(DMM32AT_INTCLK_ADINT, dev->iobase + DMM32AT_INTCLK_REG); outb(0xff, dev->iobase + DMM32AT_AI_START_CONV_REG); } @@ -388,7 +390,7 @@ static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { /* disable further interrupts and clocks */ - outb(0x0, dev->iobase + DMM32AT_INTCLOCK); + outb(0x0, dev->iobase + DMM32AT_INTCLK_REG); return 0; } @@ -404,9 +406,9 @@ static irqreturn_t dmm32at_isr(int irq, void *d) return IRQ_HANDLED; } - intstat = inb(dev->iobase + DMM32AT_INTCLOCK); + intstat = inb(dev->iobase + DMM32AT_INTCLK_REG); - if (intstat & DMM32AT_ADINT) { + if (intstat & DMM32AT_INTCLK_ADINT) { struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; @@ -499,7 +501,7 @@ static int dmm32at_reset(struct comedi_device *dev) outb(0x0, dev->iobase + DMM32AT_FIFO_CTRL_REG); /* zero interrupt and clock control */ - outb(0x0, dev->iobase + DMM32AT_INTCLOCK); + outb(0x0, dev->iobase + DMM32AT_INTCLK_REG); /* write a test channel range, the high 3 bits should drop */ outb(0x80, dev->iobase + DMM32AT_AI_LO_CHAN_REG); @@ -516,7 +518,7 @@ static int dmm32at_reset(struct comedi_device *dev) aihi = inb(dev->iobase + DMM32AT_AI_HI_CHAN_REG); fifostat = inb(dev->iobase + DMM32AT_FIFO_STATUS_REG); aistat = inb(dev->iobase + DMM32AT_AI_STATUS_REG); - intstat = inb(dev->iobase + DMM32AT_INTCLOCK); + intstat = inb(dev->iobase + DMM32AT_INTCLK_REG); airback = inb(dev->iobase + DMM32AT_AIRBACK); /* -- cgit v1.2.3-59-g8ed1b From bbf0a305fe861ffc7628a12d6c0ccda8b8d0d163 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:42 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_CNTRDIO For aesthetics, rename this define used for the Counter and Digital I/O Configuration register. Define the bits of the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 9058e327f0a1..b2da8193a383 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -91,8 +91,14 @@ Configuration Options: #define DMM32AT_INTCLK_TINT (1 << 5) #define DMM32AT_INTCLK_CLKEN (1 << 1) /* 1=see below 0=software */ #define DMM32AT_INTCLK_CLKSEL (1 << 0) /* 1=OUT2 0=EXTCLK */ - -#define DMM32AT_CNTRDIO 0x0a +#define DMM32AT_CTRDIO_CFG_REG 0x0a +#define DMM32AT_CTRDIO_CFG_FREQ12 (1 << 7) /* CLK12 1=100KHz 0=10MHz */ +#define DMM32AT_CTRDIO_CFG_FREQ0 (1 << 6) /* CLK0 1=10KHz 0=10MHz */ +#define DMM32AT_CTRDIO_CFG_OUT2EN (1 << 5) /* J3.42 1=OUT2 is DOUT2 */ +#define DMM32AT_CTRDIO_CFG_OUT0EN (1 << 4) /* J3,44 1=OUT0 is DOUT0 */ +#define DMM32AT_CTRDIO_CFG_GT0EN (1 << 2) /* J3.47 1=DIN1 is GATE0 */ +#define DMM32AT_CTRDIO_CFG_SRC0 (1 << 1) /* CLK0 is 0=FREQ0 1=J3.48 */ +#define DMM32AT_CTRDIO_CFG_GT12EN (1 << 0) /* J3.46 1=DIN2 is GATE12 */ #define DMM32AT_AICONF 0x0b #define DMM32AT_AIRBACK 0x0b @@ -105,9 +111,6 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_CNTRDIO 0x0a */ -#define DMM32AT_FREQ12 0x80 - /* DMM32AT_AICONF 0x0b */ #define DMM32AT_RANGE_U10 0x0c #define DMM32AT_RANGE_U5 0x0d @@ -334,8 +337,8 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) hi2 = (both2 & 0xff00) >> 8; lo2 = both2 & 0x00ff; - /* set the counter frequency to 10mhz */ - outb(0, dev->iobase + DMM32AT_CNTRDIO); + /* set counter clocks to 10MHz, disable all aux dio */ + outb(0, dev->iobase + DMM32AT_CTRDIO_CFG_REG); /* get access to the clock regs */ outb(DMM32AT_CTRL_PAGE_8254, dev->iobase + DMM32AT_CTRL_REG); -- cgit v1.2.3-59-g8ed1b From 06d0ac3664cb92045d48220d7eef9da6ab6c1671 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:43 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_AICONF For aesthetics, rename this define used for the Analog Configuration register. Define the bits of the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index b2da8193a383..ff88810c622d 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -99,8 +99,15 @@ Configuration Options: #define DMM32AT_CTRDIO_CFG_GT0EN (1 << 2) /* J3.47 1=DIN1 is GATE0 */ #define DMM32AT_CTRDIO_CFG_SRC0 (1 << 1) /* CLK0 is 0=FREQ0 1=J3.48 */ #define DMM32AT_CTRDIO_CFG_GT12EN (1 << 0) /* J3.46 1=DIN2 is GATE12 */ +#define DMM32AT_AI_CFG_REG 0x0b +#define DMM32AT_AI_CFG_SCINT_20US (0 << 4) +#define DMM32AT_AI_CFG_SCINT_15US (1 << 4) +#define DMM32AT_AI_CFG_SCINT_10US (2 << 4) +#define DMM32AT_AI_CFG_SCINT_5US (3 << 4) +#define DMM32AT_AI_CFG_RANGE (1 << 3) /* 0=5V 1=10V */ +#define DMM32AT_AI_CFG_ADBU (1 << 2) /* 0=bipolar 1=unipolar */ +#define DMM32AT_AI_CFG_GAIN(x) ((x) << 0) -#define DMM32AT_AICONF 0x0b #define DMM32AT_AIRBACK 0x0b #define DMM32AT_CLK1 0x0d @@ -111,15 +118,11 @@ Configuration Options: /* Board register values. */ -/* DMM32AT_AICONF 0x0b */ +/* DMM32AT_AI_CFG_REG 0x0b */ #define DMM32AT_RANGE_U10 0x0c #define DMM32AT_RANGE_U5 0x0d #define DMM32AT_RANGE_B10 0x08 #define DMM32AT_RANGE_B5 0x00 -#define DMM32AT_SCINT_20 0x00 -#define DMM32AT_SCINT_15 0x10 -#define DMM32AT_SCINT_10 0x20 -#define DMM32AT_SCINT_5 0x30 /* DMM32AT_CLKCT 0x0f */ #define DMM32AT_CLKCT1 0x56 /* mode3 counter 1 - write low byte only */ @@ -171,7 +174,7 @@ static void dmm32at_ai_set_chanspec(struct comedi_device *dev, outb(chan, dev->iobase + DMM32AT_AI_LO_CHAN_REG); outb(last_chan, dev->iobase + DMM32AT_AI_HI_CHAN_REG); - outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF); + outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AI_CFG_REG); } static unsigned int dmm32at_ai_get_sample(struct comedi_device *dev, @@ -511,7 +514,7 @@ static int dmm32at_reset(struct comedi_device *dev) outb(0xff, dev->iobase + DMM32AT_AI_HI_CHAN_REG); /* set the range at 10v unipolar */ - outb(DMM32AT_RANGE_U10, dev->iobase + DMM32AT_AICONF); + outb(DMM32AT_RANGE_U10, dev->iobase + DMM32AT_AI_CFG_REG); /* should take 10 us to settle, here's a hundred */ udelay(100); -- cgit v1.2.3-59-g8ed1b From fc7e1c08846100cbd5bbeeb0ee18349c229d27a5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:44 -0700 Subject: staging: comedi: dmm32at: rename DMM32AT_AIRBACK For aesthetics, rename this define used for the Analog I/O Readback register. Define the bits of the register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index ff88810c622d..87ed1b3e3c62 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -107,8 +107,11 @@ Configuration Options: #define DMM32AT_AI_CFG_RANGE (1 << 3) /* 0=5V 1=10V */ #define DMM32AT_AI_CFG_ADBU (1 << 2) /* 0=bipolar 1=unipolar */ #define DMM32AT_AI_CFG_GAIN(x) ((x) << 0) - -#define DMM32AT_AIRBACK 0x0b +#define DMM32AT_AI_READBACK_REG 0x0b +#define DMM32AT_AI_READBACK_WAIT (1 << 7) /* DMM32AT_AI_STATUS_STS */ +#define DMM32AT_AI_READBACK_RANGE (1 << 3) +#define DMM32AT_AI_READBACK_ADBU (1 << 2) +#define DMM32AT_AI_READBACK_GAIN_MASK (3 << 0) #define DMM32AT_CLK1 0x0d #define DMM32AT_CLK2 0x0e @@ -213,7 +216,8 @@ static int dmm32at_ai_insn_read(struct comedi_device *dev, dmm32at_ai_set_chanspec(dev, s, insn->chanspec, 1); /* wait for circuit to settle */ - ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, DMM32AT_AIRBACK); + ret = comedi_timeout(dev, s, insn, dmm32at_ai_status, + DMM32AT_AI_READBACK_REG); if (ret) return ret; @@ -375,7 +379,8 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * 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); + ret = comedi_timeout(dev, s, NULL, dmm32at_ai_status, + DMM32AT_AI_READBACK_REG); if (ret) return ret; @@ -525,7 +530,7 @@ static int dmm32at_reset(struct comedi_device *dev) fifostat = inb(dev->iobase + DMM32AT_FIFO_STATUS_REG); aistat = inb(dev->iobase + DMM32AT_AI_STATUS_REG); intstat = inb(dev->iobase + DMM32AT_INTCLK_REG); - airback = inb(dev->iobase + DMM32AT_AIRBACK); + airback = inb(dev->iobase + DMM32AT_AI_READBACK_REG); /* * NOTE: The (DMM32AT_AI_STATUS_SD1 | DMM32AT_AI_STATUS_SD0) -- cgit v1.2.3-59-g8ed1b From a26f3d3274deacfa2f190a21f7c5de9492ecb28a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:45 -0700 Subject: staging: comedi: dmm32at: tidy up multi-line comments Reformat the multi-line comments for follow the CodingStyle. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 65 +++++++++++++++++--------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 87ed1b3e3c62..738c205365ea 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -1,36 +1,39 @@ /* - comedi/drivers/dmm32at.c - Diamond Systems mm32at code for a Comedi driver - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. -*/ + * dmm32at.c + * Diamond Systems Diamond-MM-32-AT Comedi driver + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + /* -Driver: dmm32at -Description: Diamond Systems mm32at driver. -Devices: -Author: Perry J. Piplani -Updated: Fri Jun 4 09:13:24 CDT 2004 -Status: experimental - -This driver is for the Diamond Systems MM-32-AT board -http://www.diamondsystems.com/products/diamondmm32at It is being used -on serveral projects inside NASA, without problems so far. For analog -input commands, TRIG_EXT is not yet supported at all.. - -Configuration Options: - comedi_config /dev/comedi0 dmm32at baseaddr,irq -*/ + * Driver: dmm32at + * Description: Diamond Systems Diamond-MM-32-AT + * Devices: (Diamond Systems) Diamond-MM-32-AT [dmm32at] + * Author: Perry J. Piplani + * Updated: Fri Jun 4 09:13:24 CDT 2004 + * Status: experimental + * + * Configuration Options: + * comedi_config /dev/comedi0 dmm32at baseaddr,irq + * + * This driver is for the Diamond Systems MM-32-AT board + * http://www.diamondsystems.com/products/diamondmm32at + * + * It is being used on serveral projects inside NASA, without + * problems so far. For analog input commands, TRIG_EXT is not + * yet supported. + */ #include #include -- cgit v1.2.3-59-g8ed1b From 921890b0d674cece0a9becf8f38a14deaef6d3d2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 11 Nov 2014 16:55:46 -0700 Subject: staging: comedi: dmm32at: update the MODULE_DESCRIPTION Change the MODULE_DESCRIPTION to something more useful than the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 738c205365ea..09732262aff4 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -625,5 +625,5 @@ static struct comedi_driver dmm32at_driver = { module_comedi_driver(dmm32at_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi: Diamond Systems Diamond-MM-32-AT"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From af57d89e162a18676cb87825e193125e40f4c34b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 12 Nov 2014 16:00:48 +0000 Subject: staging: comedi: fix scan_end_arg == chanlist_len assumption Some comedi drivers allow the `scan_end_arg` value of an asynchronous command to be a multiple (> 1) of the `chanlist_len` although most require them to be the same value. `comedi_bytes_per_scan()` is incorrectly using `chanlist_len` as the length of the scan. Change it to use `scan_end_arg`. `comedi_nsamples_left()` is incorrectly using `cur_chan` as the current sample position in the scan (it is actually the current position in the channel list). Change it to use the actual sample position in the scan. (Unfortunately we only have the current scan position in bytes currently, so convert that to a sample position.) Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 82ac84504589..e516ed907f7e 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -317,10 +317,10 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) case COMEDI_SUBD_DO: case COMEDI_SUBD_DIO: bits_per_sample = 8 * comedi_bytes_per_sample(s); - num_samples = DIV_ROUND_UP(cmd->chanlist_len, bits_per_sample); + num_samples = DIV_ROUND_UP(cmd->scan_end_arg, bits_per_sample); break; default: - num_samples = cmd->chanlist_len; + num_samples = cmd->scan_end_arg; break; } return comedi_samples_to_bytes(s, num_samples); @@ -384,11 +384,13 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s, /* +1 to force comedi_nscans_left() to return the scans left */ unsigned int nscans = (nsamples / cmd->scan_end_arg) + 1; unsigned int scans_left = comedi_nscans_left(s, nscans); + unsigned int scan_pos = + comedi_bytes_to_samples(s, async->scan_progress); unsigned long long samples_left = 0; if (scans_left) { samples_left = ((unsigned long long)scans_left * - cmd->scan_end_arg) - async->cur_chan; + cmd->scan_end_arg) - scan_pos; } if (samples_left < nsamples) -- cgit v1.2.3-59-g8ed1b From 594e400a2c3a64d7c3ba8ad7b0196c887a354100 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 13 Nov 2014 11:41:01 -0700 Subject: staging: comedi: das6402: add basic (*do_cmdtest) for AI async commands Currently the async command support in this driver consists of just the stubbed in functions. Flesh out the (*do_cmdtest) function for basic support of timed analog input acquisitions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 105 ++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index f3909f3f755e..29270bdfd2a6 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -35,6 +35,7 @@ #include #include "../comedidev.h" +#include "comedi_fc.h" #include "8253.h" /* @@ -207,11 +208,113 @@ static int das6402_ai_cmd(struct comedi_device *dev, return -EINVAL; } +static int das6402_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + unsigned int aref0 = CR_AREF(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + unsigned int aref = CR_AREF(cmd->chanlist[i]); + + if (chan != chan0 + i) { + dev_dbg(dev->class_dev, + "chanlist must be consecutive\n"); + return -EINVAL; + } + + if (range != range0) { + dev_dbg(dev->class_dev, + "chanlist must have the same range\n"); + return -EINVAL; + } + + if (aref != aref0) { + dev_dbg(dev->class_dev, + "chanlist must have the same reference\n"); + return -EINVAL; + } + + if (aref0 == AREF_DIFF && chan > (s->n_chan / 2)) { + dev_dbg(dev->class_dev, + "chanlist differential channel to large\n"); + return -EINVAL; + } + } + return 0; +} + static int das6402_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - return -EINVAL; + struct das6402_private *devpriv = dev->private; + int err = 0; + unsigned int arg; + + /* 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_FOLLOW); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER); + 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->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); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); + err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + + if (cmd->stop_src == TRIG_COUNT) + err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); + 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->convert_src == TRIG_TIMER) { + arg = cmd->convert_arg; + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, + &devpriv->divider1, + &devpriv->divider2, + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + } + + if (err) + return 4; + + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= das6402_ai_check_chanlist(dev, s, cmd); + + if (err) + return 5; + + return 0; } static int das6402_ai_cancel(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From 3e0a738099b20bfca8198503193fcebf4235fd62 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 13 Nov 2014 11:41:02 -0700 Subject: staging: comedi: das6402: introduce das6402_ai_set_mode() Introduce a helper function to set the analog input acquisition mode. This will be needed when the (*do_cmd) function is completed to support async commands. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 29270bdfd2a6..562d6ab90b76 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -202,6 +202,23 @@ static irqreturn_t das6402_interrupt(int irq, void *d) return IRQ_HANDLED; } +static void das6402_ai_set_mode(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chanspec, + unsigned int mode) +{ + unsigned int range = CR_RANGE(chanspec); + unsigned int aref = CR_AREF(chanspec); + + mode |= DAS6402_MODE_RANGE(range); + if (aref == AREF_GROUND) + mode |= DAS6402_MODE_SE; + if (comedi_range_is_unipolar(s, range)) + mode |= DAS6402_MODE_UNI; + + das6402_set_mode(dev, mode); +} + static int das6402_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -349,26 +366,18 @@ static int das6402_ai_insn_read(struct comedi_device *dev, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int range = CR_RANGE(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec); unsigned int val; int ret; int i; - val = DAS6402_MODE_RANGE(range) | DAS6402_MODE_POLLED; - if (aref == AREF_DIFF) { - if (chan > s->n_chan / 2) - return -EINVAL; - } else { - val |= DAS6402_MODE_SE; - } - if (comedi_range_is_unipolar(s, range)) - val |= DAS6402_MODE_UNI; + if (aref == AREF_DIFF && chan > (s->n_chan / 2)) + return -EINVAL; /* enable software conversion trigger */ outb(DAS6402_CTRL_SOFT_TRIG, dev->iobase + DAS6402_CTRL_REG); - das6402_set_mode(dev, val); + das6402_ai_set_mode(dev, s, insn->chanspec, DAS6402_MODE_POLLED); /* load the mux for single channel conversion */ outw(DAS6402_AI_MUX_HI(chan) | DAS6402_AI_MUX_LO(chan), -- cgit v1.2.3-59-g8ed1b From d1d24cb65ee3605cc348a16eb9fd833c60c07ff7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 13 Nov 2014 11:41:03 -0700 Subject: staging: comedi: das6402: read analog input samples in interrupt handler Currently the interrupt handler just clears the interrupt. Add the code necessary to read the analog input samples when running an async command. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 42 ++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 562d6ab90b76..047e9737d1fb 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -193,12 +193,46 @@ static void das6402_enable_counter(struct comedi_device *dev, bool load) } } +static unsigned int das6402_ai_read_sample(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned int val; + + val = inw(dev->iobase + DAS6402_AI_DATA_REG); + if (s->maxdata == 0x0fff) + val >>= 4; + return val; +} + static irqreturn_t das6402_interrupt(int irq, void *d) { struct comedi_device *dev = d; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + unsigned int status; + + status = inb(dev->iobase + DAS6402_STATUS_REG); + if ((status & DAS6402_STATUS_INT) == 0) + return IRQ_NONE; + + if (status & DAS6402_STATUS_FFULL) { + async->events |= COMEDI_CB_OVERFLOW; + } else if (status & DAS6402_STATUS_FFNE) { + unsigned int val; + + val = das6402_ai_read_sample(dev, s); + comedi_buf_write_samples(s, &val, 1); + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; + } das6402_clear_all_interrupts(dev); + comedi_handle_events(dev, s); + return IRQ_HANDLED; } @@ -367,7 +401,6 @@ static int das6402_ai_insn_read(struct comedi_device *dev, { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec); - unsigned int val; int ret; int i; @@ -391,12 +424,7 @@ static int das6402_ai_insn_read(struct comedi_device *dev, if (ret) break; - val = inw(dev->iobase + DAS6402_AI_DATA_REG); - - if (s->maxdata == 0x0fff) - val >>= 4; - - data[i] = val; + data[i] = das6402_ai_read_sample(dev, s); } das6402_ai_clear_eoc(dev); -- cgit v1.2.3-59-g8ed1b From 1fe6a03ac8ddbf0fa93fe4aa6d728cdb6c056a1c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 13 Nov 2014 11:41:04 -0700 Subject: staging: comedi: das6402: add (*do_cmd) for AI async commands Flesh out the (*do_cmd) function to support timed analog input acquisitions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 047e9737d1fb..780f4f646ea0 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -256,7 +256,25 @@ static void das6402_ai_set_mode(struct comedi_device *dev, static int das6402_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - return -EINVAL; + struct das6402_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int chan_lo = CR_CHAN(cmd->chanlist[0]); + unsigned int chan_hi = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]); + + das6402_ai_set_mode(dev, s, cmd->chanlist[0], DAS6402_MODE_FIFONEPTY); + + /* load the mux for chanlist conversion */ + outw(DAS6402_AI_MUX_HI(chan_hi) | DAS6402_AI_MUX_LO(chan_lo), + dev->iobase + DAS6402_AI_MUX_REG); + + das6402_enable_counter(dev, true); + + /* enable interrupt and pacer trigger */ + outb(DAS6402_CTRL_INTE | + DAS6402_CTRL_IRQ(devpriv->irq) | + DAS6402_CTRL_PACER_TRIG, dev->iobase + DAS6402_CTRL_REG); + + return 0; } static int das6402_ai_check_chanlist(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From 864b52c4aeeba328660574d847190dda76d13519 Mon Sep 17 00:00:00 2001 From: Marcus Hufvudsson Date: Sat, 15 Nov 2014 16:55:20 +0100 Subject: staging: comedi: me4000: Fixed code style issue Fixed checkpatch.pl error message. Space prohibited before that ',' Signed-off-by: Marcus Hufvudsson Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index ae6ac49e730e..fc6741919a48 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -416,7 +416,7 @@ static void me4000_reset(struct comedi_device *dev) val |= PLX9052_CNTRL_PCI_RESET; outl(val, info->plx_regbase + PLX9052_CNTRL); val &= ~PLX9052_CNTRL_PCI_RESET; - outl(val , info->plx_regbase + PLX9052_CNTRL); + outl(val, info->plx_regbase + PLX9052_CNTRL); /* 0x8000 to the DACs means an output voltage of 0V */ for (chan = 0; chan < 4; chan++) -- cgit v1.2.3-59-g8ed1b From 388674e0a92f2bf4ce6ddd3758b0cef906b55ce4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:44 -0700 Subject: staging: comedi: adv_pci1724: use subdevice readback for 'ao_value' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only analog output subdevice. Remove the then unused 'ao_value' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 29 +++++----------------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 2697758b1ed9..7bbd36ae0791 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -127,7 +127,6 @@ static const struct comedi_lrange ao_ranges_1724 = { /* this structure is for data unique to this hardware driver. */ struct adv_pci1724_private { - int ao_value[NUM_AO_CHANNELS]; int offset_value[NUM_AO_CHANNELS]; int gain_value[NUM_AO_CHANNELS]; }; @@ -170,7 +169,6 @@ static int set_dac(struct comedi_device *dev, unsigned mode, unsigned channel, static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct adv_pci1724_private *devpriv = dev->private; int channel = CR_CHAN(insn->chanspec); int retval; int i; @@ -182,27 +180,8 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, retval = set_dac(dev, DAC_NORMAL_MODE, channel, data[i]); if (retval < 0) return retval; - devpriv->ao_value[channel] = data[i]; - } - return insn->n; -} - -static int ao_readback_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct adv_pci1724_private *devpriv = dev->private; - int channel = CR_CHAN(insn->chanspec); - int i; - - if (devpriv->ao_value[channel] < 0) { - dev_err(dev->class_dev, - "Cannot read back channels which have not yet been written to\n"); - return -EIO; + s->readback[channel] = data[i]; } - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_value[channel]; - return insn->n; } @@ -306,9 +285,12 @@ static int setup_subdevices(struct comedi_device *dev) s->n_chan = NUM_AO_CHANNELS; s->maxdata = 0x3fff; s->range_table = &ao_ranges_1724; - s->insn_read = ao_readback_insn; s->insn_write = ao_winsn; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + /* offset calibration */ s = &dev->subdevices[1]; s->type = COMEDI_SUBD_CALIB; @@ -346,7 +328,6 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, /* init software copies of output values to indicate we don't know * what the output value is since it has never been written. */ for (i = 0; i < NUM_AO_CHANNELS; ++i) { - devpriv->ao_value[i] = -1; devpriv->offset_value[i] = -1; devpriv->gain_value[i] = -1; } -- cgit v1.2.3-59-g8ed1b From 38020b55e7ced8398378b9023e41e9e1470b64cc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:45 -0700 Subject: staging: comedi: adv_pci1724: use subdevice readback for 'offset_value' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only offset calib subdevice. Remove the then unused 'offset_value' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 31 ++++++---------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 7bbd36ae0791..4aa1631de547 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -127,7 +127,6 @@ static const struct comedi_lrange ao_ranges_1724 = { /* this structure is for data unique to this hardware driver. */ struct adv_pci1724_private { - int offset_value[NUM_AO_CHANNELS]; int gain_value[NUM_AO_CHANNELS]; }; @@ -189,7 +188,6 @@ static int offset_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct adv_pci1724_private *devpriv = dev->private; int channel = CR_CHAN(insn->chanspec); int retval; int i; @@ -201,27 +199,8 @@ static int offset_write_insn(struct comedi_device *dev, retval = set_dac(dev, DAC_OFFSET_MODE, channel, data[i]); if (retval < 0) return retval; - devpriv->offset_value[channel] = data[i]; - } - - return insn->n; -} - -static int offset_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct adv_pci1724_private *devpriv = dev->private; - unsigned int channel = CR_CHAN(insn->chanspec); - int i; - - if (devpriv->offset_value[channel] < 0) { - dev_err(dev->class_dev, - "Cannot read back channels which have not yet been written to\n"); - return -EIO; + s->readback[channel] = data[i]; } - for (i = 0; i < insn->n; i++) - data[i] = devpriv->offset_value[channel]; return insn->n; } @@ -296,9 +275,12 @@ static int setup_subdevices(struct comedi_device *dev) s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = NUM_AO_CHANNELS; - s->insn_read = offset_read_insn; - s->insn_write = offset_write_insn; s->maxdata = 0x3fff; + s->insn_write = offset_write_insn; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; /* gain calibration */ s = &dev->subdevices[2]; @@ -328,7 +310,6 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, /* init software copies of output values to indicate we don't know * what the output value is since it has never been written. */ for (i = 0; i < NUM_AO_CHANNELS; ++i) { - devpriv->offset_value[i] = -1; devpriv->gain_value[i] = -1; } -- cgit v1.2.3-59-g8ed1b From 5081162d6c6b93ace4039da13571149268ba74ba Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:46 -0700 Subject: staging: comedi: adv_pci1724: use subdevice readback for 'gain_value' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only gain calib subdevice. Remove the then unused 'gain_value' member from the private data. The private data is now unnecessary. Remove it and the allocation. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 46 ++++------------------------ 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 4aa1631de547..735522876c80 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -125,11 +125,6 @@ static const struct comedi_lrange ao_ranges_1724 = { } }; -/* this structure is for data unique to this hardware driver. */ -struct adv_pci1724_private { - int gain_value[NUM_AO_CHANNELS]; -}; - static int wait_for_dac_idle(struct comedi_device *dev) { static const int timeout = 10000; @@ -209,7 +204,6 @@ static int gain_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct adv_pci1724_private *devpriv = dev->private; int channel = CR_CHAN(insn->chanspec); int retval; int i; @@ -221,27 +215,8 @@ static int gain_write_insn(struct comedi_device *dev, retval = set_dac(dev, DAC_GAIN_MODE, channel, data[i]); if (retval < 0) return retval; - devpriv->gain_value[channel] = data[i]; - } - - return insn->n; -} - -static int gain_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, - unsigned int *data) -{ - struct adv_pci1724_private *devpriv = dev->private; - unsigned int channel = CR_CHAN(insn->chanspec); - int i; - - if (devpriv->gain_value[channel] < 0) { - dev_err(dev->class_dev, - "Cannot read back channels which have not yet been written to\n"); - return -EIO; + s->readback[channel] = data[i]; } - for (i = 0; i < insn->n; i++) - data[i] = devpriv->gain_value[channel]; return insn->n; } @@ -287,9 +262,12 @@ static int setup_subdevices(struct comedi_device *dev) s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = NUM_AO_CHANNELS; - s->insn_read = gain_read_insn; - s->insn_write = gain_write_insn; s->maxdata = 0x3fff; + s->insn_write = gain_write_insn; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; return 0; } @@ -298,21 +276,9 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, unsigned long context_unused) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct adv_pci1724_private *devpriv; - int i; int retval; unsigned int board_id; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - - /* init software copies of output values to indicate we don't know - * what the output value is since it has never been written. */ - for (i = 0; i < NUM_AO_CHANNELS; ++i) { - devpriv->gain_value[i] = -1; - } - retval = comedi_pci_enable(dev); if (retval) return retval; -- cgit v1.2.3-59-g8ed1b From 21cdf8f43b85a9e6c9905dbeb401e4a4d1c8a6c3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:47 -0700 Subject: staging: comedi: adv_pci1724: remove NUM_AO_CHANNELS define This define is now only used to set each of the subdevice 'n_chan'. For clarity, remove the define and open code the values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 735522876c80..db5f6eb7acc4 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -60,8 +60,6 @@ supported PCI devices are configured as comedi devices automatically. #define PCI_VENDOR_ID_ADVANTECH 0x13fe -#define NUM_AO_CHANNELS 32 - /* register offsets */ enum board_registers { DAC_CONTROL_REG = 0x0, @@ -236,7 +234,7 @@ static int setup_subdevices(struct comedi_device *dev) s = &dev->subdevices[0]; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; - s->n_chan = NUM_AO_CHANNELS; + s->n_chan = 32; s->maxdata = 0x3fff; s->range_table = &ao_ranges_1724; s->insn_write = ao_winsn; @@ -249,7 +247,7 @@ static int setup_subdevices(struct comedi_device *dev) s = &dev->subdevices[1]; s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; - s->n_chan = NUM_AO_CHANNELS; + s->n_chan = 32; s->maxdata = 0x3fff; s->insn_write = offset_write_insn; @@ -261,7 +259,7 @@ static int setup_subdevices(struct comedi_device *dev) s = &dev->subdevices[2]; s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; - s->n_chan = NUM_AO_CHANNELS; + s->n_chan = 32; s->maxdata = 0x3fff; s->insn_write = gain_write_insn; -- cgit v1.2.3-59-g8ed1b From dcbd4ed87cc82398238eb870008a338b4faec76f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:48 -0700 Subject: staging: comedi: adv_pci1724: introduce adv_pci1724_insn_write() The analog output, offset calib, and gain calib subdevices all use similar (*insn_write) functions. The onyl difference is the 'mode' that is passed to the set_dac() helper. Introduce a new (*insn_write) function that can be used by all the subdevices. Use the s->private member to pass the 'mode' needed by set_dac(). Remove the subdevice specific (*insn_write) functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 68 ++++++++-------------------- 1 file changed, 18 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index db5f6eb7acc4..cc70ed84cfee 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -158,62 +158,27 @@ static int set_dac(struct comedi_device *dev, unsigned mode, unsigned channel, return 0; } -static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int adv_pci1724_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - int channel = CR_CHAN(insn->chanspec); - int retval; - int i; - - /* turn off synchronous mode */ - outl(0, dev->iobase + SYNC_OUTPUT_REG); - - for (i = 0; i < insn->n; ++i) { - retval = set_dac(dev, DAC_NORMAL_MODE, channel, data[i]); - if (retval < 0) - return retval; - s->readback[channel] = data[i]; - } - return insn->n; -} - -static int offset_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - int channel = CR_CHAN(insn->chanspec); - int retval; + unsigned long mode = (unsigned long)s->private; + unsigned int chan = CR_CHAN(insn->chanspec); + int ret; int i; /* turn off synchronous mode */ outl(0, dev->iobase + SYNC_OUTPUT_REG); for (i = 0; i < insn->n; ++i) { - retval = set_dac(dev, DAC_OFFSET_MODE, channel, data[i]); - if (retval < 0) - return retval; - s->readback[channel] = data[i]; - } - - return insn->n; -} - -static int gain_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - int channel = CR_CHAN(insn->chanspec); - int retval; - int i; + unsigned int val = data[i]; - /* turn off synchronous mode */ - outl(0, dev->iobase + SYNC_OUTPUT_REG); + ret = set_dac(dev, mode, chan, val); + if (ret < 0) + return ret; - for (i = 0; i < insn->n; ++i) { - retval = set_dac(dev, DAC_GAIN_MODE, channel, data[i]); - if (retval < 0) - return retval; - s->readback[channel] = data[i]; + s->readback[chan] = val; } return insn->n; @@ -237,7 +202,8 @@ static int setup_subdevices(struct comedi_device *dev) s->n_chan = 32; s->maxdata = 0x3fff; s->range_table = &ao_ranges_1724; - s->insn_write = ao_winsn; + s->insn_write = adv_pci1724_insn_write; + s->private = (void *)DAC_NORMAL_MODE; ret = comedi_alloc_subdev_readback(s); if (ret) @@ -249,7 +215,8 @@ static int setup_subdevices(struct comedi_device *dev) s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = 32; s->maxdata = 0x3fff; - s->insn_write = offset_write_insn; + s->insn_write = adv_pci1724_insn_write; + s->private = (void *)DAC_OFFSET_MODE; ret = comedi_alloc_subdev_readback(s); if (ret) @@ -261,7 +228,8 @@ static int setup_subdevices(struct comedi_device *dev) s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = 32; s->maxdata = 0x3fff; - s->insn_write = gain_write_insn; + s->insn_write = adv_pci1724_insn_write; + s->private = (void *)DAC_GAIN_MODE; ret = comedi_alloc_subdev_readback(s); if (ret) -- cgit v1.2.3-59-g8ed1b From e25e22b01203f6588b0124cc2d3d45756d6de59f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:49 -0700 Subject: staging: comedi: adv_pci1724: use comedi_timeout() to wait for DAC idle state Use the comedi_timeout() helper to wait for the DAC to be idle before writing to it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 33 +++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index cc70ed84cfee..c19d35908e6c 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -53,7 +53,6 @@ supported PCI devices are configured as comedi devices automatically. */ #include -#include #include #include "../comedidev.h" @@ -123,34 +122,24 @@ static const struct comedi_lrange ao_ranges_1724 = { } }; -static int wait_for_dac_idle(struct comedi_device *dev) +static int adv_pci1724_dac_idle(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) { - static const int timeout = 10000; - int i; + unsigned int status; - for (i = 0; i < timeout; ++i) { - if ((inl(dev->iobase + SYNC_OUTPUT_REG) & DAC_BUSY) == 0) - break; - udelay(1); - } - if (i == timeout) { - dev_err(dev->class_dev, - "Timed out waiting for dac to become idle\n"); - return -EIO; - } - return 0; + status = inl(dev->iobase + SYNC_OUTPUT_REG); + if ((status & DAC_BUSY) == 0) + return 0; + return -EBUSY; } static int set_dac(struct comedi_device *dev, unsigned mode, unsigned channel, unsigned data) { - int retval; unsigned control_bits; - retval = wait_for_dac_idle(dev); - if (retval < 0) - return retval; - control_bits = mode; control_bits |= dac_channel_and_group_select_bits(channel); control_bits |= dac_data_bits(data); @@ -174,6 +163,10 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; ++i) { unsigned int val = data[i]; + ret = comedi_timeout(dev, s, insn, adv_pci1724_dac_idle, 0); + if (ret) + return ret; + ret = set_dac(dev, mode, chan, val); if (ret < 0) return ret; -- cgit v1.2.3-59-g8ed1b From 77aa39330aa1085b1cd877a0211cefc69b34d339 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:50 -0700 Subject: staging: comedi: adv_pci1724: absorb set_dac() Absorb this simple function into adv_pci1724_insn_write(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index c19d35908e6c..26341358458f 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -135,18 +135,6 @@ static int adv_pci1724_dac_idle(struct comedi_device *dev, return -EBUSY; } -static int set_dac(struct comedi_device *dev, unsigned mode, unsigned channel, - unsigned data) -{ - unsigned control_bits; - - control_bits = mode; - control_bits |= dac_channel_and_group_select_bits(channel); - control_bits |= dac_data_bits(data); - outl(control_bits, dev->iobase + DAC_CONTROL_REG); - return 0; -} - static int adv_pci1724_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -162,14 +150,16 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; ++i) { unsigned int val = data[i]; + unsigned int ctrl; ret = comedi_timeout(dev, s, insn, adv_pci1724_dac_idle, 0); if (ret) return ret; - ret = set_dac(dev, mode, chan, val); - if (ret < 0) - return ret; + ctrl = mode; + ctrl |= dac_channel_and_group_select_bits(chan); + ctrl |= dac_data_bits(val); + outl(ctrl, dev->iobase + DAC_CONTROL_REG); s->readback[chan] = val; } -- cgit v1.2.3-59-g8ed1b From 7b13c4633cd96f449f1cc3a5dddb8fd435a5352d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:51 -0700 Subject: staging: comedi: adv_pci1724: remove PCI_VENDOR_ID_ADVANTECH define This define is already in pci_ids.h. Remove the duplicate in this driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 26341358458f..b7c20c93081b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -57,8 +57,6 @@ supported PCI devices are configured as comedi devices automatically. #include "../comedidev.h" -#define PCI_VENDOR_ID_ADVANTECH 0x13fe - /* register offsets */ enum board_registers { DAC_CONTROL_REG = 0x0, -- cgit v1.2.3-59-g8ed1b From c2edc021633490b6491de4ec6cbaa369f956bb36 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:52 -0700 Subject: staging: comedi: adv_pci1724: tidy up the register I/O map For aesthetics, convert the enum board_registers into defines and rename them so they have namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index b7c20c93081b..1d4b8cd423aa 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -57,14 +57,14 @@ supported PCI devices are configured as comedi devices automatically. #include "../comedidev.h" -/* register offsets */ -enum board_registers { - DAC_CONTROL_REG = 0x0, - SYNC_OUTPUT_REG = 0x4, - EEPROM_CONTROL_REG = 0x8, - SYNC_OUTPUT_TRIGGER_REG = 0xc, - BOARD_ID_REG = 0x10 -}; +/* + * PCI bar 2 Register I/O map (dev->iobase) + */ +#define PCI1724_DAC_CTRL_REG 0x00 +#define PCI1724_SYNC_OUTPUT_REG 0x04 +#define PCI1724_EEPROM_CTRL_REG 0x08 +#define PCI1724_SYNC_OUTPUT_TRIG_REG 0x0c +#define PCI1724_BOARD_ID_REG 0x10 /* bit definitions for registers */ enum dac_control_contents { @@ -127,7 +127,7 @@ static int adv_pci1724_dac_idle(struct comedi_device *dev, { unsigned int status; - status = inl(dev->iobase + SYNC_OUTPUT_REG); + status = inl(dev->iobase + PCI1724_SYNC_OUTPUT_REG); if ((status & DAC_BUSY) == 0) return 0; return -EBUSY; @@ -144,7 +144,7 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, int i; /* turn off synchronous mode */ - outl(0, dev->iobase + SYNC_OUTPUT_REG); + outl(0, dev->iobase + PCI1724_SYNC_OUTPUT_REG); for (i = 0; i < insn->n; ++i) { unsigned int val = data[i]; @@ -157,7 +157,7 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, ctrl = mode; ctrl |= dac_channel_and_group_select_bits(chan); ctrl |= dac_data_bits(val); - outl(ctrl, dev->iobase + DAC_CONTROL_REG); + outl(ctrl, dev->iobase + PCI1724_DAC_CTRL_REG); s->readback[chan] = val; } @@ -231,7 +231,7 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, return retval; dev->iobase = pci_resource_start(pcidev, 2); - board_id = inl(dev->iobase + BOARD_ID_REG) & BOARD_ID_MASK; + board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG) & BOARD_ID_MASK; dev_info(dev->class_dev, "board id: %d\n", board_id); retval = setup_subdevices(dev); -- cgit v1.2.3-59-g8ed1b From 83d94bcc8e524c5dfe9443007600dfdecd81a5d9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:53 -0700 Subject: staging: comedi: adv_pci1724: define the dac control register bits Define the bits for the DAC control register and remove the enum along with the helper functions. Simplify adv_pci1724_insn_write() a bit. The 'ctrl' bits are based on the 'chan' and 'mode' and do not need to be recalculated for each 'val'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 55 ++++++++-------------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 1d4b8cd423aa..91e57c8fd3bb 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -61,43 +61,18 @@ supported PCI devices are configured as comedi devices automatically. * PCI bar 2 Register I/O map (dev->iobase) */ #define PCI1724_DAC_CTRL_REG 0x00 +#define PCI1724_DAC_CTRL_GX(x) (1 << (20 + ((x) / 8))) +#define PCI1724_DAC_CTRL_CX(x) (((x) % 8) << 16) +#define PCI1724_DAC_CTRL_MODE_GAIN (1 << 14) +#define PCI1724_DAC_CTRL_MODE_OFFSET (2 << 14) +#define PCI1724_DAC_CTRL_MODE_NORMAL (3 << 14) +#define PCI1724_DAC_CTRL_MODE_MASK (3 << 14) +#define PCI1724_DAC_CTRL_DATA(x) (((x) & 0x3fff) << 0) #define PCI1724_SYNC_OUTPUT_REG 0x04 #define PCI1724_EEPROM_CTRL_REG 0x08 #define PCI1724_SYNC_OUTPUT_TRIG_REG 0x0c #define PCI1724_BOARD_ID_REG 0x10 -/* bit definitions for registers */ -enum dac_control_contents { - DAC_DATA_MASK = 0x3fff, - DAC_DESTINATION_MASK = 0xc000, - DAC_NORMAL_MODE = 0xc000, - DAC_OFFSET_MODE = 0x8000, - DAC_GAIN_MODE = 0x4000, - DAC_CHANNEL_SELECT_MASK = 0xf0000, - DAC_GROUP_SELECT_MASK = 0xf00000 -}; - -static uint32_t dac_data_bits(uint16_t dac_data) -{ - return dac_data & DAC_DATA_MASK; -} - -static uint32_t dac_channel_select_bits(unsigned channel) -{ - return (channel << 16) & DAC_CHANNEL_SELECT_MASK; -} - -static uint32_t dac_group_select_bits(unsigned group) -{ - return (1 << (20 + group)) & DAC_GROUP_SELECT_MASK; -} - -static uint32_t dac_channel_and_group_select_bits(unsigned comedi_channel) -{ - return dac_channel_select_bits(comedi_channel % 8) | - dac_group_select_bits(comedi_channel / 8); -} - enum sync_output_contents { SYNC_MODE = 0x1, DAC_BUSY = 0x2, /* dac state machine is not ready */ @@ -140,24 +115,24 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, { unsigned long mode = (unsigned long)s->private; unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int ctrl; int ret; int i; + ctrl = PCI1724_DAC_CTRL_GX(chan) | PCI1724_DAC_CTRL_CX(chan) | mode; + /* turn off synchronous mode */ outl(0, dev->iobase + PCI1724_SYNC_OUTPUT_REG); for (i = 0; i < insn->n; ++i) { unsigned int val = data[i]; - unsigned int ctrl; ret = comedi_timeout(dev, s, insn, adv_pci1724_dac_idle, 0); if (ret) return ret; - ctrl = mode; - ctrl |= dac_channel_and_group_select_bits(chan); - ctrl |= dac_data_bits(val); - outl(ctrl, dev->iobase + PCI1724_DAC_CTRL_REG); + outl(ctrl | PCI1724_DAC_CTRL_DATA(val), + dev->iobase + PCI1724_DAC_CTRL_REG); s->readback[chan] = val; } @@ -184,7 +159,7 @@ static int setup_subdevices(struct comedi_device *dev) s->maxdata = 0x3fff; s->range_table = &ao_ranges_1724; s->insn_write = adv_pci1724_insn_write; - s->private = (void *)DAC_NORMAL_MODE; + s->private = (void *)PCI1724_DAC_CTRL_MODE_NORMAL; ret = comedi_alloc_subdev_readback(s); if (ret) @@ -197,7 +172,7 @@ static int setup_subdevices(struct comedi_device *dev) s->n_chan = 32; s->maxdata = 0x3fff; s->insn_write = adv_pci1724_insn_write; - s->private = (void *)DAC_OFFSET_MODE; + s->private = (void *)PCI1724_DAC_CTRL_MODE_OFFSET; ret = comedi_alloc_subdev_readback(s); if (ret) @@ -210,7 +185,7 @@ static int setup_subdevices(struct comedi_device *dev) s->n_chan = 32; s->maxdata = 0x3fff; s->insn_write = adv_pci1724_insn_write; - s->private = (void *)DAC_GAIN_MODE; + s->private = (void *)PCI1724_DAC_CTRL_MODE_GAIN; ret = comedi_alloc_subdev_readback(s); if (ret) -- cgit v1.2.3-59-g8ed1b From 14356535fbf9d4be3c94f6afa6e46768f0e07197 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:54 -0700 Subject: staging: comedi: adv_pci1724: define the sync output control/status reg Define the bits for the synchronous output control/status register and remove the enum. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 91e57c8fd3bb..f4c42eb031fc 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -68,16 +68,13 @@ supported PCI devices are configured as comedi devices automatically. #define PCI1724_DAC_CTRL_MODE_NORMAL (3 << 14) #define PCI1724_DAC_CTRL_MODE_MASK (3 << 14) #define PCI1724_DAC_CTRL_DATA(x) (((x) & 0x3fff) << 0) -#define PCI1724_SYNC_OUTPUT_REG 0x04 +#define PCI1724_SYNC_CTRL_REG 0x04 +#define PCI1724_SYNC_CTRL_DACSTAT (1 << 1) +#define PCI1724_SYNC_CTRL_SYN (1 << 0) #define PCI1724_EEPROM_CTRL_REG 0x08 #define PCI1724_SYNC_OUTPUT_TRIG_REG 0x0c #define PCI1724_BOARD_ID_REG 0x10 -enum sync_output_contents { - SYNC_MODE = 0x1, - DAC_BUSY = 0x2, /* dac state machine is not ready */ -}; - enum sync_output_trigger_contents { SYNC_TRIGGER_BITS = 0x0 /* any value works */ }; @@ -102,8 +99,8 @@ static int adv_pci1724_dac_idle(struct comedi_device *dev, { unsigned int status; - status = inl(dev->iobase + PCI1724_SYNC_OUTPUT_REG); - if ((status & DAC_BUSY) == 0) + status = inl(dev->iobase + PCI1724_SYNC_CTRL_REG); + if ((status & PCI1724_SYNC_CTRL_DACSTAT) == 0) return 0; return -EBUSY; } @@ -122,7 +119,7 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, ctrl = PCI1724_DAC_CTRL_GX(chan) | PCI1724_DAC_CTRL_CX(chan) | mode; /* turn off synchronous mode */ - outl(0, dev->iobase + PCI1724_SYNC_OUTPUT_REG); + outl(0, dev->iobase + PCI1724_SYNC_CTRL_REG); for (i = 0; i < insn->n; ++i) { unsigned int val = data[i]; -- cgit v1.2.3-59-g8ed1b From 80b00a5842e2523a66c501c2858bd464cc9d0a06 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:55 -0700 Subject: staging: comedi: adv_pci1724: remove enum sync_output_trigger_contents This enum is not used in the driver. Remove it. For aesthetics, rename the register define and move the comment that any value will trigger the sync output. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index f4c42eb031fc..f8198efb1a09 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -72,13 +72,9 @@ supported PCI devices are configured as comedi devices automatically. #define PCI1724_SYNC_CTRL_DACSTAT (1 << 1) #define PCI1724_SYNC_CTRL_SYN (1 << 0) #define PCI1724_EEPROM_CTRL_REG 0x08 -#define PCI1724_SYNC_OUTPUT_TRIG_REG 0x0c +#define PCI1724_SYNC_TRIG_REG 0x0c /* any value works */ #define PCI1724_BOARD_ID_REG 0x10 -enum sync_output_trigger_contents { - SYNC_TRIGGER_BITS = 0x0 /* any value works */ -}; - enum board_id_contents { BOARD_ID_MASK = 0xf }; -- cgit v1.2.3-59-g8ed1b From 70adf763bae7bde3edf2faf69df3a8c56dbba685 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:56 -0700 Subject: staging: comedi: adv_pci1724: define the board id register bits For aesthetics, remove the enum and define the bits for this register. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index f8198efb1a09..2df765f43f4e 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -74,10 +74,7 @@ supported PCI devices are configured as comedi devices automatically. #define PCI1724_EEPROM_CTRL_REG 0x08 #define PCI1724_SYNC_TRIG_REG 0x0c /* any value works */ #define PCI1724_BOARD_ID_REG 0x10 - -enum board_id_contents { - BOARD_ID_MASK = 0xf -}; +#define PCI1724_BOARD_ID_MASK (0xf << 0) static const struct comedi_lrange ao_ranges_1724 = { 4, { @@ -199,8 +196,9 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, return retval; dev->iobase = pci_resource_start(pcidev, 2); - board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG) & BOARD_ID_MASK; - dev_info(dev->class_dev, "board id: %d\n", board_id); + board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG); + dev_info(dev->class_dev, "board id: %d\n", + board_id & PCI1724_BOARD_ID_MASK); retval = setup_subdevices(dev); if (retval < 0) -- cgit v1.2.3-59-g8ed1b From 27de4358f950ac5fb4797c8f92265c61291a8895 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:57 -0700 Subject: staging: comedi: adv_pci1724: absorb setup_subdevices() For aesthetics, absorb this function into the (*auto_attach). Add some whitespace to the subdevice init. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 83 ++++++++++++---------------- 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 2df765f43f4e..fdcf3ab7af5f 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -130,80 +130,67 @@ static int adv_pci1724_insn_write(struct comedi_device *dev, return insn->n; } -/* Allocate and initialize the subdevice structures. - */ -static int setup_subdevices(struct comedi_device *dev) +static int adv_pci1724_auto_attach(struct comedi_device *dev, + unsigned long context_unused) { + struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct comedi_subdevice *s; + unsigned int board_id; int ret; + ret = comedi_pci_enable(dev); + if (ret) + return ret; + + dev->iobase = pci_resource_start(pcidev, 2); + board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG); + dev_info(dev->class_dev, "board id: %d\n", + board_id & PCI1724_BOARD_ID_MASK); + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; - /* analog output subdevice */ + /* Analog Output subdevice */ s = &dev->subdevices[0]; - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; - s->n_chan = 32; - s->maxdata = 0x3fff; - s->range_table = &ao_ranges_1724; - s->insn_write = adv_pci1724_insn_write; - s->private = (void *)PCI1724_DAC_CTRL_MODE_NORMAL; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; + s->n_chan = 32; + s->maxdata = 0x3fff; + s->range_table = &ao_ranges_1724; + s->insn_write = adv_pci1724_insn_write; + s->private = (void *)PCI1724_DAC_CTRL_MODE_NORMAL; ret = comedi_alloc_subdev_readback(s); if (ret) return ret; - /* offset calibration */ + /* Offset Calibration subdevice */ s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_CALIB; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; - s->n_chan = 32; - s->maxdata = 0x3fff; - s->insn_write = adv_pci1724_insn_write; - s->private = (void *)PCI1724_DAC_CTRL_MODE_OFFSET; + s->type = COMEDI_SUBD_CALIB; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; + s->n_chan = 32; + s->maxdata = 0x3fff; + s->insn_write = adv_pci1724_insn_write; + s->private = (void *)PCI1724_DAC_CTRL_MODE_OFFSET; ret = comedi_alloc_subdev_readback(s); if (ret) return ret; - /* gain calibration */ + /* Gain Calibration subdevice */ s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_CALIB; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; - s->n_chan = 32; - s->maxdata = 0x3fff; - s->insn_write = adv_pci1724_insn_write; - s->private = (void *)PCI1724_DAC_CTRL_MODE_GAIN; + s->type = COMEDI_SUBD_CALIB; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; + s->n_chan = 32; + s->maxdata = 0x3fff; + s->insn_write = adv_pci1724_insn_write; + s->private = (void *)PCI1724_DAC_CTRL_MODE_GAIN; ret = comedi_alloc_subdev_readback(s); if (ret) return ret; - return 0; -} - -static int adv_pci1724_auto_attach(struct comedi_device *dev, - unsigned long context_unused) -{ - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - int retval; - unsigned int board_id; - - retval = comedi_pci_enable(dev); - if (retval) - return retval; - - dev->iobase = pci_resource_start(pcidev, 2); - board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG); - dev_info(dev->class_dev, "board id: %d\n", - board_id & PCI1724_BOARD_ID_MASK); - - retval = setup_subdevices(dev); - if (retval < 0) - return retval; - dev_info(dev->class_dev, "%s (pci %s) attached, board id: %u\n", dev->board_name, pci_name(pcidev), board_id); return 0; -- cgit v1.2.3-59-g8ed1b From bbef9b17ebcf2b5f95ce7365f1f8d4d2bdc14431 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:58 -0700 Subject: staging: comedi: adv_pci1724: remove unnecessary dev_info() Remove the unnecessary noise at the end of the (*auto_attach). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index fdcf3ab7af5f..b5b54b90d2ae 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -191,8 +191,6 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, if (ret) return ret; - dev_info(dev->class_dev, "%s (pci %s) attached, board id: %u\n", - dev->board_name, pci_name(pcidev), board_id); return 0; } -- cgit v1.2.3-59-g8ed1b From 4360bb2f14cf7345e7b32bff07cbf1e192f3ccc4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:10:59 -0700 Subject: staging: comedi: adv_pci1724: tidy up the pci_driver declaration For aesthetics, add some whitespace to the pci_driver declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index b5b54b90d2ae..4570e1864474 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -215,12 +215,11 @@ static const struct pci_device_id adv_pci1724_pci_table[] = { MODULE_DEVICE_TABLE(pci, adv_pci1724_pci_table); static struct pci_driver adv_pci1724_pci_driver = { - .name = "adv_pci1724", - .id_table = adv_pci1724_pci_table, - .probe = adv_pci1724_pci_probe, - .remove = comedi_pci_auto_unconfig, + .name = "adv_pci1724", + .id_table = adv_pci1724_pci_table, + .probe = adv_pci1724_pci_probe, + .remove = comedi_pci_auto_unconfig, }; - module_comedi_pci_driver(adv_pci1724_driver, adv_pci1724_pci_driver); MODULE_AUTHOR("Frank Mori Hess "); -- cgit v1.2.3-59-g8ed1b From 35581695d0decf72be05a7962b41794131b117a6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:11:00 -0700 Subject: staging: comedi: adv_pci1724: tidy up the comedi_driver declaration For aesthetics, add some whitespace to the comedi_driver declaration. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 4570e1864474..6c5396c24646 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -195,10 +195,10 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, } static struct comedi_driver adv_pci1724_driver = { - .driver_name = "adv_pci1724", - .module = THIS_MODULE, - .auto_attach = adv_pci1724_auto_attach, - .detach = comedi_pci_detach, + .driver_name = "adv_pci1724", + .module = THIS_MODULE, + .auto_attach = adv_pci1724_auto_attach, + .detach = comedi_pci_detach, }; static int adv_pci1724_pci_probe(struct pci_dev *dev, -- cgit v1.2.3-59-g8ed1b From bd6e4a4141008d179882ff97561d25d1f080f442 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:11:01 -0700 Subject: staging: comedi: adv_pci1724: tidy up multi-line comments Tidy up the multi-line comments to follow the CodingStyle. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 94 +++++++++++++--------------- 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 6c5396c24646..1201733fc9b0 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -1,56 +1,50 @@ /* - comedi/drivers/adv_pci1724.c - This is a driver for the Advantech PCI-1724U card. - - Author: Frank Mori Hess - Copyright (C) 2013 GnuBIO Inc - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1997-8 David A. Schleef - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. -*/ + * adv_pci1724.c + * Comedi driver for the Advantech PCI-1724U card. + * + * Author: Frank Mori Hess + * Copyright (C) 2013 GnuBIO Inc + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1997-8 David A. Schleef + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ /* - -Driver: adv_1724 -Description: Advantech PCI-1724U -Author: Frank Mori Hess -Status: works -Updated: 2013-02-09 -Devices: [Advantech] PCI-1724U (adv_pci1724) - -Subdevice 0 is the analog output. -Subdevice 1 is the offset calibration for the analog output. -Subdevice 2 is the gain calibration for the analog output. - -The calibration offset and gains have quite a large effect -on the analog output, so it is possible to adjust the analog output to -have an output range significantly different from the board's -nominal output ranges. For a calibrated +/- 10V range, the analog -output's offset will be set somewhere near mid-range (0x2000) and its -gain will be near maximum (0x3fff). - -There is really no difference between the board's documented 0-20mA -versus 4-20mA output ranges. To pick one or the other is simply a matter -of adjusting the offset and gain calibration until the board outputs in -the desired range. - -Configuration options: - None - -Manual configuration of comedi devices is not supported by this driver; -supported PCI devices are configured as comedi devices automatically. - -*/ + * Driver: adv_pci1724 + * Description: Advantech PCI-1724U + * Devices: (Advantech) PCI-1724U [adv_pci1724] + * Author: Frank Mori Hess + * Updated: 2013-02-09 + * Status: works + * + * Configuration Options: not applicable, uses comedi PCI auto config + * + * Subdevice 0 is the analog output. + * Subdevice 1 is the offset calibration for the analog output. + * Subdevice 2 is the gain calibration for the analog output. + * + * The calibration offset and gains have quite a large effect on the + * analog output, so it is possible to adjust the analog output to + * have an output range significantly different from the board's + * nominal output ranges. For a calibrated +/-10V range, the analog + * output's offset will be set somewhere near mid-range (0x2000) and + * its gain will be near maximum (0x3fff). + * + * There is really no difference between the board's documented 0-20mA + * versus 4-20mA output ranges. To pick one or the other is simply a + * matter of adjusting the offset and gain calibration until the board + * outputs in the desired range. + */ #include #include -- cgit v1.2.3-59-g8ed1b From 474bfe5ff961831b83e08092fd3e093bd3a1418c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:11:02 -0700 Subject: staging: comedi: adv_pci1724: rename ao_ranges_1724 For aesthetics, rename the analog output comedi_lrange table so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 1201733fc9b0..a8d28403262e 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -70,7 +70,7 @@ #define PCI1724_BOARD_ID_REG 0x10 #define PCI1724_BOARD_ID_MASK (0xf << 0) -static const struct comedi_lrange ao_ranges_1724 = { +static const struct comedi_lrange adv_pci1724_ao_ranges = { 4, { BIP_RANGE(10), RANGE_mA(0, 20), @@ -151,7 +151,7 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; s->n_chan = 32; s->maxdata = 0x3fff; - s->range_table = &ao_ranges_1724; + s->range_table = &adv_pci1724_ao_ranges; s->insn_write = adv_pci1724_insn_write; s->private = (void *)PCI1724_DAC_CTRL_MODE_NORMAL; -- cgit v1.2.3-59-g8ed1b From aa11672ef43c05d4ff5580ad41ceae9867e5430d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 10:19:10 -0700 Subject: staging: comedi: drivers: have core hook up default (*insn_read) for readback Most of the comedi drivers that provide readback for write only subdevices now use the comedi core comedi_alloc_subdev_readback() helper to allocate the subdevice 'reaback' member instead of using some member in their private data. These drivers also hook up the (*insn_read) callback to the comedi_readback_insn_read() helper to provide the readback. Have the core automatically hook up the (*insn_read) callback after allocating the memory if the driver has not already hooked it up to a private function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_3120.c | 1 - drivers/staging/comedi/drivers/addi_apci_3501.c | 1 - drivers/staging/comedi/drivers/addi_apci_3xxx.c | 1 - drivers/staging/comedi/drivers/adl_pci6208.c | 1 - drivers/staging/comedi/drivers/adl_pci9111.c | 1 - drivers/staging/comedi/drivers/adl_pci9118.c | 1 - drivers/staging/comedi/drivers/aio_aio12_8.c | 1 - drivers/staging/comedi/drivers/amplc_pci224.c | 1 - drivers/staging/comedi/drivers/amplc_pci230.c | 1 - drivers/staging/comedi/drivers/cb_das16_cs.c | 1 - drivers/staging/comedi/drivers/cb_pcidas.c | 1 - drivers/staging/comedi/drivers/cb_pcidas64.c | 1 - drivers/staging/comedi/drivers/cb_pcimdas.c | 1 - drivers/staging/comedi/drivers/dac02.c | 1 - drivers/staging/comedi/drivers/daqboard2000.c | 1 - drivers/staging/comedi/drivers/das08.c | 1 - drivers/staging/comedi/drivers/das16.c | 1 - drivers/staging/comedi/drivers/dmm32at.c | 1 - drivers/staging/comedi/drivers/dt2801.c | 1 - drivers/staging/comedi/drivers/dt2811.c | 1 - drivers/staging/comedi/drivers/dt282x.c | 1 - drivers/staging/comedi/drivers/dt3000.c | 1 - drivers/staging/comedi/drivers/fl512.c | 1 - drivers/staging/comedi/drivers/icp_multi.c | 1 - drivers/staging/comedi/drivers/ii_pci20kc.c | 1 - drivers/staging/comedi/drivers/me4000.c | 1 - drivers/staging/comedi/drivers/me_daq.c | 1 - drivers/staging/comedi/drivers/mf6x4.c | 1 - drivers/staging/comedi/drivers/multiq3.c | 1 - drivers/staging/comedi/drivers/ni_670x.c | 1 - drivers/staging/comedi/drivers/ni_at_ao.c | 1 - drivers/staging/comedi/drivers/ni_atmio16d.c | 1 - drivers/staging/comedi/drivers/ni_mio_common.c | 1 - drivers/staging/comedi/drivers/pcl711.c | 1 - drivers/staging/comedi/drivers/pcl726.c | 1 - drivers/staging/comedi/drivers/pcl812.c | 1 - drivers/staging/comedi/drivers/pcl818.c | 1 - drivers/staging/comedi/drivers/pcmmio.c | 1 - drivers/staging/comedi/drivers/quatech_daqp_cs.c | 1 - drivers/staging/comedi/drivers/rtd520.c | 1 - drivers/staging/comedi/drivers/rti800.c | 1 - drivers/staging/comedi/drivers/rti802.c | 1 - drivers/staging/comedi/drivers/s526.c | 1 - drivers/staging/comedi/drivers/s626.c | 1 - 45 files changed, 4 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index e516ed907f7e..61802d7947ae 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -109,6 +109,10 @@ int comedi_alloc_subdev_readback(struct comedi_subdevice *s) s->readback = kcalloc(s->n_chan, sizeof(*s->readback), GFP_KERNEL); if (!s->readback) return -ENOMEM; + + if (!s->insn_read) + s->insn_read = comedi_readback_insn_read; + return 0; } EXPORT_SYMBOL_GPL(comedi_alloc_subdev_readback); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index e9816e7a235d..c65f9407fd06 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1051,7 +1051,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, s->maxdata = 0x3fff; s->range_table = &range_bipolar10; s->insn_write = apci3120_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 79245236be78..a726efcea6a5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -362,7 +362,6 @@ static int apci3501_auto_attach(struct comedi_device *dev, s->maxdata = 0x3fff; s->range_table = &apci3501_ao_range; s->insn_write = apci3501_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 630d778df2c5..c173810a3b5b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -854,7 +854,6 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &apci3xxx_ao_range; s->insn_write = apci3xxx_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 0ad46fe492c9..528f15c25dae 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -169,7 +169,6 @@ static int pci6208_auto_attach(struct comedi_device *dev, s->maxdata = 0xffff; s->range_table = &range_bipolar10; s->insn_write = pci6208_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 539eb94cfe8d..47f6c0e9f014 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -731,7 +731,6 @@ static int pci9111_auto_attach(struct comedi_device *dev, s->len_chanlist = 1; s->range_table = &range_bipolar10; s->insn_write = pci9111_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 498e0c7775e5..5e0ff9db6a47 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1588,7 +1588,6 @@ static int pci9118_common_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &range_bipolar10; s->insn_write = pci9118_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 538277a691b2..fbc3e5aa94cb 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -212,7 +212,6 @@ static int aio_aio12_8_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &range_aio_aio12_8; s->insn_write = aio_aio12_8_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index a896f0192fbd..924c8298c7a0 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -1075,7 +1075,6 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model) s->maxdata = (1 << thisboard->ao_bits) - 1; s->range_table = thisboard->ao_range; s->insn_write = pci224_ao_insn_write; - s->insn_read = comedi_readback_insn_read; s->len_chanlist = s->n_chan; dev->write_subdev = s; s->do_cmd = pci224_ao_cmd; diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index fb0b70fdce7d..49806a5e514c 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2511,7 +2511,6 @@ static int pci230_auto_attach(struct comedi_device *dev, s->maxdata = (1 << thisboard->ao_bits) - 1; s->range_table = &pci230_ao_range; s->insn_write = pci230_ao_insn_write; - s->insn_read = comedi_readback_insn_read; s->len_chanlist = 2; if (dev->irq) { dev->write_subdev = s; diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index f88880aea6da..0a48d2a961d5 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -305,7 +305,6 @@ static int das16cs_auto_attach(struct comedi_device *dev, s->maxdata = 0xffff; s->range_table = &range_bipolar10; s->insn_write = &das16cs_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 10c67fec75a0..35c63059df4b 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1478,7 +1478,6 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->range_table = &cb_pcidas_ao_ranges; /* default to no fifo (*insn_write) */ s->insn_write = cb_pcidas_ao_nofifo_winsn; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 05da5b33834a..4762e6a5f1b9 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3786,7 +3786,6 @@ static int setup_subdevices(struct comedi_device *dev) s->maxdata = (1 << thisboard->ao_bits) - 1; s->range_table = thisboard->ao_range_table; s->insn_write = ao_winsn; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 73e5c96ff249..70dd2c9eecdb 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -226,7 +226,6 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, /* ranges are hardware settable, but not software readable. */ s->range_table = &range_unknown; s->insn_write = cb_pcimdas_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/dac02.c b/drivers/staging/comedi/drivers/dac02.c index 34cbe83f0ce7..beb36c8dd00a 100644 --- a/drivers/staging/comedi/drivers/dac02.c +++ b/drivers/staging/comedi/drivers/dac02.c @@ -129,7 +129,6 @@ static int dac02_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0x0fff; s->range_table = &das02_ao_ranges; s->insn_write = dac02_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index e5b5a8133b34..96697fbb5239 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -707,7 +707,6 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, s->n_chan = 2; s->maxdata = 0xffff; s->insn_write = daqboard2000_ao_insn_write; - s->insn_read = comedi_readback_insn_read; s->range_table = &range_bipolar10; result = comedi_alloc_subdev_readback(s); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index cdf71f9f199c..20a9f0eb72b5 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -474,7 +474,6 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->maxdata = (1 << thisboard->ao_nbits) - 1; s->range_table = &range_bipolar5; s->insn_write = das08_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 8de27053666f..2436057304a3 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1175,7 +1175,6 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0x0fff; s->range_table = devpriv->user_ao_range_table; s->insn_write = das16_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 09732262aff4..6df298a99cc6 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -601,7 +601,6 @@ static int dmm32at_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &dmm32at_aoranges; s->insn_write = dmm32at_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index e97386343a0e..b96e60ffad73 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -597,7 +597,6 @@ havetype: devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]); devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]); s->insn_write = dt2801_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 1736e397ad2c..d660f277487e 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -418,7 +418,6 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->range_type_list[0] = dac_range_types[devpriv->dac_range[0]]; devpriv->range_type_list[1] = dac_range_types[devpriv->dac_range[1]]; s->insn_write = dt2811_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 674e03eb1601..2be98bb9a809 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -1231,7 +1231,6 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* ranges are per-channel, set by jumpers on the board */ s->range_table = &dt282x_ao_range; s->insn_write = dt282x_ao_insn_write; - s->insn_read = comedi_readback_insn_read; if (dev->irq) { dev->write_subdev = s; s->subdev_flags |= SDF_CMD_WRITE; diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index c2058ba39fa1..1d9a7a63e06f 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -697,7 +697,6 @@ static int dt3000_auto_attach(struct comedi_device *dev, s->len_chanlist = 1; s->range_table = &range_bipolar10; s->insn_write = dt3k_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 5a1e3c8fc01c..e1f493241cd6 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -135,7 +135,6 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0x0fff; s->range_table = &range_fl512; s->insn_write = fl512_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index fbbcab20a48b..1ea168620103 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -495,7 +495,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev, s->len_chanlist = 4; s->range_table = &range_analog; s->insn_write = icp_multi_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index cc5fd75b8bc0..1085d66935fe 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -392,7 +392,6 @@ static int ii20k_init_module(struct comedi_device *dev, s->maxdata = 0xffff; s->range_table = &ii20k_ao_ranges; s->insn_write = ii20k_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index fc6741919a48..915685c1c85c 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1426,7 +1426,6 @@ static int me4000_auto_attach(struct comedi_device *dev, s->maxdata = 0xFFFF; /* 16 bit DAC */ s->range_table = &range_bipolar10; s->insn_write = me4000_ao_insn_write; - s->insn_read = comedi_readback_insn_read; result = comedi_alloc_subdev_readback(s); if (result) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 9dec9c175877..b5278c11e622 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -517,7 +517,6 @@ static int me_auto_attach(struct comedi_device *dev, s->len_chanlist = 4; s->range_table = &me_ao_range; s->insn_write = me_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/mf6x4.c b/drivers/staging/comedi/drivers/mf6x4.c index c8d3a22c5896..af21bc180c46 100644 --- a/drivers/staging/comedi/drivers/mf6x4.c +++ b/drivers/staging/comedi/drivers/mf6x4.c @@ -259,7 +259,6 @@ static int mf6x4_auto_attach(struct comedi_device *dev, unsigned long context) s->maxdata = 0x3fff; /* 14 bits DAC */ s->range_table = &range_bipolar10; s->insn_write = mf6x4_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index f710c8e81320..8471219210b6 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -238,7 +238,6 @@ static int multiq3_attach(struct comedi_device *dev, s->maxdata = 0xfff; s->range_table = &range_bipolar5; s->insn_write = multiq3_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 54721deb80cc..c42a81c0bfa1 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -228,7 +228,6 @@ static int ni_670x_auto_attach(struct comedi_device *dev, s->range_table = &range_bipolar10; } s->insn_write = ni_670x_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 3e1ce5866147..5fb40cd13b4d 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -344,7 +344,6 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0x0fff; s->range_table = it->options[3] ? &range_unipolar10 : &range_bipolar10; s->insn_write = atao_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index d0ac49eaab06..c484c89c94b5 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -692,7 +692,6 @@ static int atmio16d_attach(struct comedi_device *dev, break; } s->insn_write = atmio16d_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 97869ce463b7..353c17bb4325 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -5441,7 +5441,6 @@ static int ni_E_init(struct comedi_device *dev, s->range_table = board->ao_range_table; s->insn_config = ni_ao_insn_config; s->insn_write = ni_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 93fa4b8ddf15..938aebc8e0ea 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -497,7 +497,6 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0xfff; s->range_table = &range_bipolar5; s->insn_write = pcl711_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index a1ac567fb192..86f713fdf1d0 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -376,7 +376,6 @@ static int pcl726_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table_list = devpriv->rangelist; s->insn_write = pcl726_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index c3499aa47dee..ac243ca5e0f8 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1324,7 +1324,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) break; } s->insn_write = pcl812_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index f1e0f36424e9..8edea35532a9 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -1158,7 +1158,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->range_table = &range_unknown; } s->insn_write = pcl818_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 985fabd879aa..f0059e935da0 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -732,7 +732,6 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0xffff; s->range_table = &pcmmio_ao_ranges; s->insn_write = pcmmio_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index f77485b28fe2..96098110b0b3 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -740,7 +740,6 @@ static int daqp_auto_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &range_bipolar5; s->insn_write = daqp_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index fb71fd60bc4e..581aa58d9c0a 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1263,7 +1263,6 @@ static int rtd_auto_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &rtd_ao_range; s->insn_write = rtd_ao_winsn; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index e3d9f44cefb9..67b4b378bd01 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -313,7 +313,6 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it) ? rti800_ao_ranges[it->options[7]] : &range_unknown; s->insn_write = rti800_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index c81b01c40f12..96c3974207ae 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -100,7 +100,6 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0xfff; s->n_chan = 8; s->insn_write = rti802_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 75872c6aec2a..6f3e8a08e75c 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -583,7 +583,6 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 0xffff; s->range_table = &range_bipolar10; s->insn_write = s526_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index fc7d8a572bf3..14932c5f3798 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2801,7 +2801,6 @@ static int s626_auto_attach(struct comedi_device *dev, s->maxdata = 0x3fff; s->range_table = &range_bipolar10; s->insn_write = s626_ao_insn_write; - s->insn_read = comedi_readback_insn_read; ret = comedi_alloc_subdev_readback(s); if (ret) -- cgit v1.2.3-59-g8ed1b From 37318bdb14aba8145644c7ca4b76b1ba3efbdcae Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:19 -0700 Subject: staging: comedi: cb_pcidas64: use subdevice readback for 'caldac_state' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only calibration subdevice. Remove the then unused 'caldac_state' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 30 ++++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 4762e6a5f1b9..c641778f3464 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1107,7 +1107,6 @@ struct pcidas64_private { unsigned int ext_trig_falling; /* states of various devices stored to enable read-back */ unsigned int ad8402_state[2]; - unsigned int caldac_state[8]; short ai_cmd_running; unsigned int ai_fifo_segment_length; struct ext_clock_info ext_clock; @@ -3550,9 +3549,6 @@ static void caldac_write(struct comedi_device *dev, unsigned int channel, unsigned int value) { const struct pcidas64_board *thisboard = dev->board_ptr; - struct pcidas64_private *devpriv = dev->private; - - devpriv->caldac_state[channel] = value; switch (thisboard->layout) { case LAYOUT_60XX: @@ -3571,27 +3567,15 @@ static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct pcidas64_private *devpriv = dev->private; int channel = CR_CHAN(insn->chanspec); /* return immediately if setting hasn't changed, since * programming these things is slow */ - if (devpriv->caldac_state[channel] == data[0]) + if (s->readback[channel] == data[0]) return 1; caldac_write(dev, channel, data[0]); - - return 1; -} - -static int calib_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, - unsigned int *data) -{ - struct pcidas64_private *devpriv = dev->private; - unsigned int channel = CR_CHAN(insn->chanspec); - - data[0] = devpriv->caldac_state[channel]; + s->readback[channel] = data[0]; return 1; } @@ -3864,10 +3848,16 @@ static int setup_subdevices(struct comedi_device *dev) s->maxdata = 0xfff; else s->maxdata = 0xff; - s->insn_read = calib_read_insn; s->insn_write = calib_write_insn; - for (i = 0; i < s->n_chan; i++) + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + + for (i = 0; i < s->n_chan; i++) { caldac_write(dev, i, s->maxdata / 2); + s->readback[i] = s->maxdata / 2; + } /* 2 channel ad8402 potentiometer */ s = &dev->subdevices[7]; -- cgit v1.2.3-59-g8ed1b From 5e2de5e7f9f31db55399e2b4ad3b612dadaf7ebe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:20 -0700 Subject: staging: comedi: cb_pcidas64: fix calib_write_insn() The comedi core expects the (*insn_write) functions to write 'insn->n' values to the hardware and return the number of values written. Currently this function only writes the first value. For this subdevice it only makes sense to write the final data value. Fix the function to work like the core expects. For aesthetics, rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index c641778f3464..17c98a59b44f 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3563,21 +3563,27 @@ static void caldac_write(struct comedi_device *dev, unsigned int channel, } } -static int calib_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int cb_pcidas64_calib_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - int channel = CR_CHAN(insn->chanspec); + unsigned int chan = CR_CHAN(insn->chanspec); - /* return immediately if setting hasn't changed, since - * programming these things is slow */ - if (s->readback[channel] == data[0]) - return 1; + /* + * Programming the calib device is slow. Only write the + * last data value if the value has changed. + */ + if (insn->n) { + unsigned int val = data[insn->n - 1]; - caldac_write(dev, channel, data[0]); - s->readback[channel] = data[0]; + if (s->readback[chan] != val) { + caldac_write(dev, chan, val); + s->readback[chan] = val; + } + } - return 1; + return insn->n; } static void ad8402_write(struct comedi_device *dev, unsigned int channel, @@ -3848,7 +3854,7 @@ static int setup_subdevices(struct comedi_device *dev) s->maxdata = 0xfff; else s->maxdata = 0xff; - s->insn_write = calib_write_insn; + s->insn_write = cb_pcidas64_calib_insn_write; ret = comedi_alloc_subdev_readback(s); if (ret) -- cgit v1.2.3-59-g8ed1b From fe1184e49a8a4d9a32eef0d5e166dd9eec76b565 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:21 -0700 Subject: staging: comedi: cb_pcidas64: use subdevice readback for 'ad8402_state' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only calibration subdevice. Remove the then unused 'ad8402_state' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 33 ++++++++++------------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 17c98a59b44f..d80f34d35ee3 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1105,8 +1105,6 @@ struct pcidas64_private { uint8_t i2c_cal_range_bits; /* configure digital triggers to trigger on falling edge */ unsigned int ext_trig_falling; - /* states of various devices stored to enable read-back */ - unsigned int ad8402_state[2]; short ai_cmd_running; unsigned int ai_fifo_segment_length; struct ext_clock_info ext_clock; @@ -3595,8 +3593,6 @@ static void ad8402_write(struct comedi_device *dev, unsigned int channel, unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff); static const int ad8402_udelay = 1; - devpriv->ad8402_state[channel] = value; - register_bits = SELECT_8402_64XX_BIT; udelay(ad8402_udelay); writew(register_bits, devpriv->main_iobase + CALIBRATION_REG); @@ -3622,33 +3618,20 @@ static int ad8402_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct pcidas64_private *devpriv = dev->private; int channel = CR_CHAN(insn->chanspec); /* return immediately if setting hasn't changed, since * programming these things is slow */ - if (devpriv->ad8402_state[channel] == data[0]) + if (s->readback[channel] == data[0]) return 1; - devpriv->ad8402_state[channel] = data[0]; + s->readback[channel] = data[0]; ad8402_write(dev, channel, data[0]); return 1; } -static int ad8402_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct pcidas64_private *devpriv = dev->private; - unsigned int channel = CR_CHAN(insn->chanspec); - - data[0] = devpriv->ad8402_state[channel]; - - return 1; -} - static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) { struct pcidas64_private *devpriv = dev->private; @@ -3871,11 +3854,17 @@ static int setup_subdevices(struct comedi_device *dev) s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = 2; - s->insn_read = ad8402_read_insn; - s->insn_write = ad8402_write_insn; s->maxdata = 0xff; - for (i = 0; i < s->n_chan; i++) + s->insn_write = ad8402_write_insn; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + + for (i = 0; i < s->n_chan; i++) { ad8402_write(dev, i, s->maxdata / 2); + s->readback[i] = s->maxdata / 2; + } } else s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From dc658fdc8a807c5b5a405277685f35e53673729c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:22 -0700 Subject: staging: comedi: cb_pcidas64: fix ad8402_write_insn() The comedi core expects the (*insn_write) functions to write 'insn->n' values to the hardware and return the number of values written. Currently this function only writes the first value. For this subdevice it only makes sense to write the final data value. Fix the function to work like the core expects. For aesthetics, rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index d80f34d35ee3..eddb7ace43df 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3614,22 +3614,27 @@ static void ad8402_write(struct comedi_device *dev, unsigned int channel, } /* for pci-das6402/16, channel 0 is analog input gain and channel 1 is offset */ -static int ad8402_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int cb_pcidas64_ad8402_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - int channel = CR_CHAN(insn->chanspec); - - /* return immediately if setting hasn't changed, since - * programming these things is slow */ - if (s->readback[channel] == data[0]) - return 1; + unsigned int chan = CR_CHAN(insn->chanspec); - s->readback[channel] = data[0]; + /* + * Programming the calib device is slow. Only write the + * last data value if the value has changed. + */ + if (insn->n) { + unsigned int val = data[insn->n - 1]; - ad8402_write(dev, channel, data[0]); + if (s->readback[chan] != val) { + ad8402_write(dev, chan, val); + s->readback[chan] = val; + } + } - return 1; + return insn->n; } static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) @@ -3855,7 +3860,7 @@ static int setup_subdevices(struct comedi_device *dev) s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = 2; s->maxdata = 0xff; - s->insn_write = ad8402_write_insn; + s->insn_write = cb_pcidas64_ad8402_insn_write; ret = comedi_alloc_subdev_readback(s); if (ret) -- cgit v1.2.3-59-g8ed1b From 06b66dc22b83fd3d9e4de42011dc5de04a226971 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:23 -0700 Subject: staging: comedi: cb_pcidas: remove unnecessary check in caldac_8800_write() The 'address' passed to this function is actually the comedi channel. This value will always be less than the subdevice n_chan (which is 8). Remove the unnecessary sanity check in caldac_8800_write(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 35c63059df4b..1296ccd8a798 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -596,16 +596,10 @@ static int caldac_8800_write(struct comedi_device *dev, unsigned int address, uint8_t value) { struct cb_pcidas_private *devpriv = dev->private; - static const int num_caldac_channels = 8; static const int bitstream_length = 11; unsigned int bitstream = ((address & 0x7) << 8) | value; static const int caldac_8800_udelay = 1; - if (address >= num_caldac_channels) { - dev_err(dev->class_dev, "illegal caldac channel\n"); - return -1; - } - if (value == devpriv->caldac_value[address]) return 1; -- cgit v1.2.3-59-g8ed1b From f52e5e44a9eedc1649bf65f28d6ad69a46c54f10 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:24 -0700 Subject: staging: comedi: cb_pcidas: fix caldac_write_insn() The comedi core expects the (*insn_write) functions to write 'insn->n' values to the hardware and return the number of values written. Currently this function only writes the first value. For this subdevice it only makes sense to write the final data value. Fix the function to work like the core expects. For aesthetics, rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 40 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 1296ccd8a798..d33b37c83ee8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -592,19 +592,14 @@ static void write_calibration_bitstream(struct comedi_device *dev, } } -static int caldac_8800_write(struct comedi_device *dev, unsigned int address, - uint8_t value) +static void caldac_8800_write(struct comedi_device *dev, + unsigned int chan, uint8_t val) { struct cb_pcidas_private *devpriv = dev->private; static const int bitstream_length = 11; - unsigned int bitstream = ((address & 0x7) << 8) | value; + unsigned int bitstream = ((chan & 0x7) << 8) | val; static const int caldac_8800_udelay = 1; - if (value == devpriv->caldac_value[address]) - return 1; - - devpriv->caldac_value[address] = value; - write_calibration_bitstream(dev, cal_enable_bits(dev), bitstream, bitstream_length); @@ -613,17 +608,26 @@ static int caldac_8800_write(struct comedi_device *dev, unsigned int address, devpriv->control_status + CALIBRATION_REG); udelay(caldac_8800_udelay); outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG); - - return 1; } -static int caldac_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int cb_pcidas_caldac_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - const unsigned int channel = CR_CHAN(insn->chanspec); + struct cb_pcidas_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + + if (insn->n) { + unsigned int val = data[insn->n - 1]; + + if (devpriv->caldac_value[chan] != val) { + caldac_8800_write(dev, chan, val); + devpriv->caldac_value[chan] = val; + } + } - return caldac_8800_write(dev, channel, data[0]); + return insn->n; } static int caldac_read_insn(struct comedi_device *dev, @@ -1511,9 +1515,11 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->n_chan = NUM_CHANNELS_8800; s->maxdata = 0xff; s->insn_read = caldac_read_insn; - s->insn_write = caldac_write_insn; - for (i = 0; i < s->n_chan; i++) + s->insn_write = cb_pcidas_caldac_insn_write; + for (i = 0; i < s->n_chan; i++) { caldac_8800_write(dev, i, s->maxdata / 2); + devpriv->caldac_value[i] = s->maxdata / 2; + } /* trim potentiometer */ s = &dev->subdevices[5]; -- cgit v1.2.3-59-g8ed1b From 3f5ced0d0241d64b43c33402e714198824d5b0de Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:25 -0700 Subject: staging: comedi: cb_pcidas: use subdevice readback for 'caldac_value' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only caldac subdevice. Remove the then unused 'caldac_value' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index d33b37c83ee8..f92ad26d38ff 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -356,7 +356,6 @@ struct cb_pcidas_private { /* divisors of master clock for analog output pacing */ unsigned int ao_divisor1; unsigned int ao_divisor2; - unsigned int caldac_value[NUM_CHANNELS_8800]; unsigned int trimpot_value[NUM_CHANNELS_8402]; unsigned int dac08_value; unsigned int calibration_source; @@ -615,32 +614,20 @@ static int cb_pcidas_caldac_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct cb_pcidas_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); if (insn->n) { unsigned int val = data[insn->n - 1]; - if (devpriv->caldac_value[chan] != val) { + if (s->readback[chan] != val) { caldac_8800_write(dev, chan, val); - devpriv->caldac_value[chan] = val; + s->readback[chan] = val; } } return insn->n; } -static int caldac_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct cb_pcidas_private *devpriv = dev->private; - - data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)]; - - return 1; -} - /* 1602/16 pregain offset */ static void dac08_write(struct comedi_device *dev, unsigned int value) { @@ -1514,11 +1501,15 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = NUM_CHANNELS_8800; s->maxdata = 0xff; - s->insn_read = caldac_read_insn; s->insn_write = cb_pcidas_caldac_insn_write; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + for (i = 0; i < s->n_chan; i++) { caldac_8800_write(dev, i, s->maxdata / 2); - devpriv->caldac_value[i] = s->maxdata / 2; + s->readback[i] = s->maxdata / 2; } /* trim potentiometer */ -- cgit v1.2.3-59-g8ed1b From 7a82a2c4e4aa0cdace951cf35c266d02fb96039f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:26 -0700 Subject: staging: comedi: cb_pcidas: fix trimpot_write_insn() The comedi core expects the (*insn_write) functions to write 'insn->n' values to the hardware and return the number of values written. Currently this function only writes the first value. For this subdevice it only makes sense to write the final data value. Fix the function to work like the core expects. For aesthetics, rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 44 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index f92ad26d38ff..d5edb5f31ef6 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -721,38 +721,42 @@ static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel, return 0; } -static int cb_pcidas_trimpot_write(struct comedi_device *dev, - unsigned int channel, unsigned int value) +static void cb_pcidas_trimpot_write(struct comedi_device *dev, + unsigned int chan, unsigned int val) { const struct cb_pcidas_board *thisboard = dev->board_ptr; - struct cb_pcidas_private *devpriv = dev->private; - - if (devpriv->trimpot_value[channel] == value) - return 1; - devpriv->trimpot_value[channel] = value; switch (thisboard->trimpot) { case AD7376: - trimpot_7376_write(dev, value); + trimpot_7376_write(dev, val); break; case AD8402: - trimpot_8402_write(dev, channel, value); + trimpot_8402_write(dev, chan, val); break; default: dev_err(dev->class_dev, "driver bug?\n"); - return -1; + break; } - - return 1; } -static int trimpot_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int cb_pcidas_trimpot_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - unsigned int channel = CR_CHAN(insn->chanspec); + struct cb_pcidas_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + + if (insn->n) { + unsigned int val = data[insn->n - 1]; + + if (devpriv->trimpot_value[chan] != val) { + cb_pcidas_trimpot_write(dev, chan, val); + devpriv->trimpot_value[chan] = val; + } + } - return cb_pcidas_trimpot_write(dev, channel, data[0]); + return insn->n; } static int trimpot_read_insn(struct comedi_device *dev, @@ -1524,9 +1528,11 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->maxdata = 0xff; } s->insn_read = trimpot_read_insn; - s->insn_write = trimpot_write_insn; - for (i = 0; i < s->n_chan; i++) + s->insn_write = cb_pcidas_trimpot_insn_write; + for (i = 0; i < s->n_chan; i++) { cb_pcidas_trimpot_write(dev, i, s->maxdata / 2); + devpriv->trimpot_value[i] = s->maxdata / 2; + } /* dac08 caldac */ s = &dev->subdevices[6]; -- cgit v1.2.3-59-g8ed1b From a1c76758987eac334a7dffcb0b50e597da4ded77 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:27 -0700 Subject: staging: comedi: cb_pcidas: use subdevice readback for 'trimpot_value' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only trimpot calib subdevice. Remove the then unused 'trimpot_value' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index d5edb5f31ef6..86e3d200bb21 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -356,7 +356,6 @@ struct cb_pcidas_private { /* divisors of master clock for analog output pacing */ unsigned int ao_divisor1; unsigned int ao_divisor2; - unsigned int trimpot_value[NUM_CHANNELS_8402]; unsigned int dac08_value; unsigned int calibration_source; }; @@ -744,33 +743,20 @@ static int cb_pcidas_trimpot_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct cb_pcidas_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); if (insn->n) { unsigned int val = data[insn->n - 1]; - if (devpriv->trimpot_value[chan] != val) { + if (s->readback[chan] != val) { cb_pcidas_trimpot_write(dev, chan, val); - devpriv->trimpot_value[chan] = val; + s->readback[chan] = val; } } return insn->n; } -static int trimpot_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct cb_pcidas_private *devpriv = dev->private; - unsigned int channel = CR_CHAN(insn->chanspec); - - data[0] = devpriv->trimpot_value[channel]; - - return 1; -} - static int cb_pcidas_ai_check_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -1527,11 +1513,15 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->n_chan = NUM_CHANNELS_8402; s->maxdata = 0xff; } - s->insn_read = trimpot_read_insn; s->insn_write = cb_pcidas_trimpot_insn_write; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + for (i = 0; i < s->n_chan; i++) { cb_pcidas_trimpot_write(dev, i, s->maxdata / 2); - devpriv->trimpot_value[i] = s->maxdata / 2; + s->readback[i] = s->maxdata / 2; } /* dac08 caldac */ -- cgit v1.2.3-59-g8ed1b From 9c034da124d08237fe973ca0073f5f70297b20fb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:28 -0700 Subject: staging: comedi: cb_pcidas: tidy up dac08_write_insn() For consistency with the other calib subdevices, refactor this (*insn_write) function so that it only writes the final data value to the hardware., For aesthetics, rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 48 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 86e3d200bb21..04b6d39d1051 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -631,34 +631,35 @@ static int cb_pcidas_caldac_insn_write(struct comedi_device *dev, static void dac08_write(struct comedi_device *dev, unsigned int value) { struct cb_pcidas_private *devpriv = dev->private; - unsigned long cal_reg; - if (devpriv->dac08_value != value) { - devpriv->dac08_value = value; + value &= 0xff; + value |= cal_enable_bits(dev); - cal_reg = devpriv->control_status + CALIBRATION_REG; - - value &= 0xff; - value |= cal_enable_bits(dev); - - /* latch the new value into the caldac */ - outw(value, cal_reg); - udelay(1); - outw(value | SELECT_DAC08_BIT, cal_reg); - udelay(1); - outw(value, cal_reg); - udelay(1); - } + /* latch the new value into the caldac */ + outw(value, devpriv->control_status + CALIBRATION_REG); + udelay(1); + outw(value | SELECT_DAC08_BIT, + devpriv->control_status + CALIBRATION_REG); + udelay(1); + outw(value, devpriv->control_status + CALIBRATION_REG); + udelay(1); } -static int dac08_write_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int cb_pcidas_dac08_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - int i; + struct cb_pcidas_private *devpriv = dev->private; + + if (insn->n) { + unsigned int val = data[insn->n - 1]; - for (i = 0; i < insn->n; i++) - dac08_write(dev, data[i]); + if (devpriv->dac08_value != val) { + dac08_write(dev, val); + devpriv->dac08_value = val; + } + } return insn->n; } @@ -1531,9 +1532,10 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = NUM_CHANNELS_DAC08; s->insn_read = dac08_read_insn; - s->insn_write = dac08_write_insn; + s->insn_write = cb_pcidas_dac08_insn_write; s->maxdata = 0xff; dac08_write(dev, s->maxdata / 2); + devpriv->dac08_value = s->maxdata / 2; } else s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From e42151f945f7b45e6a1634fc3b665b36f5e42a03 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:29 -0700 Subject: staging: comedi: cb_pcidas: use subdevice readback for 'dac08_value' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only dac08 calib subdevice. Remove the then unused 'dac08_value' member from the private data. The dac08 calib subdevice only has one channel. For consistency in the driver, modify the subdevice init so that a loop is used to initialize the channels and readback values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 32 ++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 04b6d39d1051..669b1703eb99 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -356,7 +356,6 @@ struct cb_pcidas_private { /* divisors of master clock for analog output pacing */ unsigned int ao_divisor1; unsigned int ao_divisor2; - unsigned int dac08_value; unsigned int calibration_source; }; @@ -650,31 +649,20 @@ static int cb_pcidas_dac08_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct cb_pcidas_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); if (insn->n) { unsigned int val = data[insn->n - 1]; - if (devpriv->dac08_value != val) { + if (s->readback[chan] != val) { dac08_write(dev, val); - devpriv->dac08_value = val; + s->readback[chan] = val; } } return insn->n; } -static int dac08_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, - unsigned int *data) -{ - struct cb_pcidas_private *devpriv = dev->private; - - data[0] = devpriv->dac08_value; - - return 1; -} - static int trimpot_7376_write(struct comedi_device *dev, uint8_t value) { struct cb_pcidas_private *devpriv = dev->private; @@ -1531,11 +1519,17 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_CALIB; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = NUM_CHANNELS_DAC08; - s->insn_read = dac08_read_insn; - s->insn_write = cb_pcidas_dac08_insn_write; s->maxdata = 0xff; - dac08_write(dev, s->maxdata / 2); - devpriv->dac08_value = s->maxdata / 2; + s->insn_write = cb_pcidas_dac08_insn_write; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + + for (i = 0; i < s->n_chan; i++) { + dac08_write(dev, s->maxdata / 2); + s->readback[i] = s->maxdata / 2; + } } else s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From f8990d088c226b58c26a918c7de03006a3b1ab3c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:30 -0700 Subject: staging: comedi: ni_at_ao: use subdevice readback for 'caldac' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only caldac subdevice. Remove the then unused 'caldac' member from the private data. Tidy up atao_calib_insn_write(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_ao.c | 55 ++++++++++++------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 5fb40cd13b4d..05370a4a74a5 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -244,47 +244,31 @@ static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct atao_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int bitstring; - unsigned int val; - int bit; - if (insn->n == 0) - return 0; + if (insn->n) { + unsigned int val = data[insn->n - 1]; + unsigned int bitstring = ((chan & 0x7) << 8) | val; + unsigned int bits; + int bit; - devpriv->caldac[chan] = data[insn->n - 1] & s->maxdata; + /* write the channel and last data value to the caldac */ + /* clock the bitstring to the caldac; MSB -> LSB */ + for (bit = 1 << 10; bit; bit >>= 1) { + bits = (bit & bitstring) ? ATAO_CFG2_SDATA : 0; - /* write the channel and last data value to the caldac */ - bitstring = ((chan & 0x7) << 8) | devpriv->caldac[chan]; + outw(bits, dev->iobase + ATAO_CFG2_REG); + outw(bits | ATAO_CFG2_SCLK, + dev->iobase + ATAO_CFG2_REG); + } - /* clock the bitstring to the caldac; MSB -> LSB */ - for (bit = 1 << 10; bit; bit >>= 1) { - val = (bit & bitstring) ? ATAO_CFG2_SDATA : 0; + /* strobe the caldac to load the value */ + outw(ATAO_CFG2_CALLD(chan), dev->iobase + ATAO_CFG2_REG); + outw(ATAO_CFG2_CALLD_NOP, dev->iobase + ATAO_CFG2_REG); - outw(val, dev->iobase + ATAO_CFG2_REG); - outw(val | ATAO_CFG2_SCLK, dev->iobase + ATAO_CFG2_REG); + s->readback[chan] = val; } - /* strobe the caldac to load the value */ - outw(ATAO_CFG2_CALLD(chan), dev->iobase + ATAO_CFG2_REG); - outw(ATAO_CFG2_CALLD_NOP, dev->iobase + ATAO_CFG2_REG); - - return insn->n; -} - -static int atao_calib_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct atao_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->caldac[chan]; - return insn->n; } @@ -365,9 +349,12 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_WRITABLE | SDF_INTERNAL; s->n_chan = (board->n_ao_chans * 2) + 1; s->maxdata = 0xff; - s->insn_read = atao_calib_insn_read; s->insn_write = atao_calib_insn_write; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + /* EEPROM subdevice */ s = &dev->subdevices[3]; s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From 332f46e4be24f252fdc719abd52f3ac711c0aab4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:31 -0700 Subject: staging: comedi: ni_labpc_common: move calib readback value check/save to (*insn_write) Move the check/save of the calib subdevice value to the (*insn_write) function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_common.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 685220369c32..4abca1d1db72 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -1150,10 +1150,6 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel, { struct labpc_private *devpriv = dev->private; - if (value == devpriv->caldac[channel]) - return; - devpriv->caldac[channel] = value; - /* clear caldac load bit and make sure we don't write to eeprom */ devpriv->cmd5 &= ~(CMD5_CALDACLD | CMD5_EEPROMCS | CMD5_WRTPRT); udelay(1); @@ -1178,14 +1174,21 @@ static int labpc_calib_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { + struct labpc_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); /* * Only write the last data value to the caldac. Preceding * data would be overwritten anyway. */ - if (insn->n > 0) - write_caldac(dev, chan, data[insn->n - 1]); + if (insn->n > 0) { + unsigned int val = data[insn->n - 1]; + + if (devpriv->caldac[chan] != val) { + write_caldac(dev, chan, val); + devpriv->caldac[chan] = val; + } + } return insn->n; } @@ -1345,8 +1348,10 @@ int labpc_common_attach(struct comedi_device *dev, s->insn_read = labpc_calib_insn_read; s->insn_write = labpc_calib_insn_write; - for (i = 0; i < s->n_chan; i++) + for (i = 0; i < s->n_chan; i++) { write_caldac(dev, i, s->maxdata / 2); + devpriv->caldac[i] = s->maxdata / 2; + } } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From 1e3d3a4d1bba9b7de7f18212954740624cd0448e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:32 -0700 Subject: staging: comedi: ni_labpc_common: use subdevice readback for 'caldac' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only caldac subdevice. Remove the then unused 'caldac' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.h | 2 -- drivers/staging/comedi/drivers/ni_labpc_common.c | 27 ++++++------------------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index f6e5cd15a409..3261e226cc3d 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -72,8 +72,6 @@ struct labpc_private { enum transfer_type current_transfer; /* stores contents of board's eeprom */ unsigned int eeprom_data[EEPROM_SIZE]; - /* stores settings of calibration dacs */ - unsigned int caldac[16]; /* * function pointers so we can use inb/outb or readb/writeb as * appropriate diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 4abca1d1db72..548d3df08525 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -1174,7 +1174,6 @@ static int labpc_calib_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct labpc_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); /* @@ -1184,30 +1183,15 @@ static int labpc_calib_insn_write(struct comedi_device *dev, if (insn->n > 0) { unsigned int val = data[insn->n - 1]; - if (devpriv->caldac[chan] != val) { + if (s->readback[chan] != val) { write_caldac(dev, chan, val); - devpriv->caldac[chan] = val; + s->readback[chan] = val; } } return insn->n; } -static int labpc_calib_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct labpc_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->caldac[chan]; - - return insn->n; -} - static int labpc_eeprom_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -1345,12 +1329,15 @@ int labpc_common_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = 16; s->maxdata = 0xff; - s->insn_read = labpc_calib_insn_read; s->insn_write = labpc_calib_insn_write; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + for (i = 0; i < s->n_chan; i++) { write_caldac(dev, i, s->maxdata / 2); - devpriv->caldac[i] = s->maxdata / 2; + s->readback[i] = s->maxdata / 2; } } else { s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From 8e06519b27921fb06bcb719d78df4a80a60ea8ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:33 -0700 Subject: staging: comedi: ni_labpc_common: introduce labpc_ao_write() Introduce a helper function to write a value to a given DAC channel. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_common.c | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 548d3df08525..354c33e6f21c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -918,6 +918,18 @@ static irqreturn_t labpc_interrupt(int irq, void *d) return IRQ_HANDLED; } +static void labpc_ao_write(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chan, unsigned int val) +{ + struct labpc_private *devpriv = dev->private; + + devpriv->write_byte(dev, val & 0xff, DAC_LSB_REG(chan)); + devpriv->write_byte(dev, (val >> 8) & 0xff, DAC_MSB_REG(chan)); + + devpriv->ao_value[chan] = val; +} + static int labpc_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -927,7 +939,6 @@ static int labpc_ao_insn_write(struct comedi_device *dev, struct labpc_private *devpriv = dev->private; int channel, range; unsigned long flags; - int lsb, msb; channel = CR_CHAN(insn->chanspec); @@ -950,13 +961,7 @@ static int labpc_ao_insn_write(struct comedi_device *dev, devpriv->write_byte(dev, devpriv->cmd6, CMD6_REG); } /* send data */ - lsb = data[0] & 0xff; - msb = (data[0] >> 8) & 0xff; - devpriv->write_byte(dev, lsb, DAC_LSB_REG(channel)); - devpriv->write_byte(dev, msb, DAC_MSB_REG(channel)); - - /* remember value for readback */ - devpriv->ao_value[channel] = data[0]; + labpc_ao_write(dev, s, channel, data[0]); return 1; } @@ -1300,15 +1305,8 @@ int labpc_common_attach(struct comedi_device *dev, s->insn_write = labpc_ao_insn_write; /* initialize analog outputs to a known value */ - for (i = 0; i < s->n_chan; i++) { - short lsb, msb; - - devpriv->ao_value[i] = s->maxdata / 2; - lsb = devpriv->ao_value[i] & 0xff; - msb = (devpriv->ao_value[i] >> 8) & 0xff; - devpriv->write_byte(dev, lsb, DAC_LSB_REG(i)); - devpriv->write_byte(dev, msb, DAC_MSB_REG(i)); - } + for (i = 0; i < s->n_chan; i++) + labpc_ao_write(dev, s, i, s->maxdata / 2); } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From c82f0e6b364890df25f2d9cd05dd4103dcc02d15 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:34 -0700 Subject: staging: comedi: ni_labpc_common: use subdevice readback for analog outputs Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the analog output subdevice. Remove the then unused 'ao_value' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.h | 2 -- drivers/staging/comedi/drivers/ni_labpc_common.c | 19 +++++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index 3261e226cc3d..e6a95f94774c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -37,8 +37,6 @@ struct labpc_boardinfo { struct labpc_private { /* number of data points left to be taken */ unsigned long long count; - /* software copy of analog output values */ - unsigned int ao_value[NUM_AO_CHAN]; /* software copys of bits written to command registers */ unsigned int cmd1; unsigned int cmd2; diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 354c33e6f21c..a6c63b511a66 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -927,7 +927,7 @@ static void labpc_ao_write(struct comedi_device *dev, devpriv->write_byte(dev, val & 0xff, DAC_LSB_REG(chan)); devpriv->write_byte(dev, (val >> 8) & 0xff, DAC_MSB_REG(chan)); - devpriv->ao_value[chan] = val; + s->readback[chan] = val; } static int labpc_ao_insn_write(struct comedi_device *dev, @@ -966,18 +966,6 @@ static int labpc_ao_insn_write(struct comedi_device *dev, return 1; } -static int labpc_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct labpc_private *devpriv = dev->private; - - data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; - - return 1; -} - /* lowlevel write to eeprom/dac */ static void labpc_serial_out(struct comedi_device *dev, unsigned int value, unsigned int value_width) @@ -1301,9 +1289,12 @@ int labpc_common_attach(struct comedi_device *dev, s->n_chan = NUM_AO_CHAN; s->maxdata = 0x0fff; s->range_table = &range_labpc_ao; - s->insn_read = labpc_ao_insn_read; s->insn_write = labpc_ao_insn_write; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + /* initialize analog outputs to a known value */ for (i = 0; i < s->n_chan; i++) labpc_ao_write(dev, s, i, s->maxdata / 2); -- cgit v1.2.3-59-g8ed1b From 45c311c4384c4e50881b18928edf5d0d2ea0b640 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:35 -0700 Subject: staging: comedi: ni_labpc_common: use subdevice readback for eeprom Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the eeprom subdevice. Remove the then unused 'eeprom_data' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.h | 2 -- drivers/staging/comedi/drivers/ni_labpc_common.c | 30 ++++++++---------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index e6a95f94774c..ac2c01f9dfdc 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -68,8 +68,6 @@ struct labpc_private { unsigned int dma_transfer_size; /* we are using dma/fifo-half-full/etc. */ enum transfer_type current_transfer; - /* stores contents of board's eeprom */ - unsigned int eeprom_data[EEPROM_SIZE]; /* * function pointers so we can use inb/outb or readb/writeb as * appropriate diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index a6c63b511a66..9d26aced0021 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -1099,8 +1099,6 @@ static int labpc_eeprom_write(struct comedi_device *dev, dev_err(dev->class_dev, "eeprom write timed out\n"); return -ETIME; } - /* update software copy of eeprom */ - devpriv->eeprom_data[address] = value; /* enable read/write to eeprom */ devpriv->cmd5 &= ~CMD5_EEPROMCS; @@ -1202,25 +1200,14 @@ static int labpc_eeprom_insn_write(struct comedi_device *dev, * data would be overwritten anyway. */ if (insn->n > 0) { - ret = labpc_eeprom_write(dev, chan, data[insn->n - 1]); + unsigned int val = data[insn->n - 1]; + + ret = labpc_eeprom_write(dev, chan, val); if (ret) return ret; - } - - return insn->n; -} -static int labpc_eeprom_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct labpc_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->eeprom_data[chan]; + s->readback[chan] = val; + } return insn->n; } @@ -1339,11 +1326,14 @@ int labpc_common_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = EEPROM_SIZE; s->maxdata = 0xff; - s->insn_read = labpc_eeprom_insn_read; s->insn_write = labpc_eeprom_insn_write; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + for (i = 0; i < s->n_chan; i++) - devpriv->eeprom_data[i] = labpc_eeprom_read(dev, i); + s->readback[i] = labpc_eeprom_read(dev, i); } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From 5f86288fc54865164e0439ea5d8b64d4ec1ad40e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 20 Nov 2014 15:07:36 -0700 Subject: staging: comedi: ni_labpc_common: use comedi_timeout() when writing to eeprom Use the comedi_timeout() helper to wait for the eeprom to be ready to accept writes and remove the timeout loop in labpc_eeprom_write(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_common.c | 37 ++++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 9d26aced0021..d89d5852aeea 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -1078,27 +1078,13 @@ static unsigned int labpc_eeprom_read_status(struct comedi_device *dev) return value; } -static int labpc_eeprom_write(struct comedi_device *dev, - unsigned int address, unsigned int value) +static void labpc_eeprom_write(struct comedi_device *dev, + unsigned int address, unsigned int value) { struct labpc_private *devpriv = dev->private; const int write_enable_instruction = 0x6; const int write_instruction = 0x2; const int write_length = 8; /* 8 bit write lengths to eeprom */ - const int write_in_progress_bit = 0x1; - const int timeout = 10000; - int i; - - /* make sure there isn't already a write in progress */ - for (i = 0; i < timeout; i++) { - if ((labpc_eeprom_read_status(dev) & write_in_progress_bit) == - 0) - break; - } - if (i == timeout) { - dev_err(dev->class_dev, "eeprom write timed out\n"); - return -ETIME; - } /* enable read/write to eeprom */ devpriv->cmd5 &= ~CMD5_EEPROMCS; @@ -1131,8 +1117,6 @@ static int labpc_eeprom_write(struct comedi_device *dev, devpriv->cmd5 &= ~(CMD5_EEPROMCS | CMD5_WRTPRT); udelay(1); devpriv->write_byte(dev, devpriv->cmd5, CMD5_REG); - - return 0; } /* writes to 8 bit calibration dacs */ @@ -1183,6 +1167,20 @@ static int labpc_calib_insn_write(struct comedi_device *dev, return insn->n; } +static int labpc_eeprom_ready(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned int status; + + /* make sure there isn't already a write in progress */ + status = labpc_eeprom_read_status(dev); + if ((status & 0x1) == 0) + return 0; + return -EBUSY; +} + static int labpc_eeprom_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -1202,10 +1200,11 @@ static int labpc_eeprom_insn_write(struct comedi_device *dev, if (insn->n > 0) { unsigned int val = data[insn->n - 1]; - ret = labpc_eeprom_write(dev, chan, val); + ret = comedi_timeout(dev, s, insn, labpc_eeprom_ready, 0); if (ret) return ret; + labpc_eeprom_write(dev, chan, val); s->readback[chan] = val; } -- cgit v1.2.3-59-g8ed1b From 01601aaf9f23bf2e1ed41a06f37e7d990f64806a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:27 -0700 Subject: staging: comedi: adv_pci1723: tidy up register map For aesthetics, rename the defines used for the register map offsets and remove the unnecessary comments. Add the bit defines for the registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 117 +++++++++++---------------- 1 file changed, 48 insertions(+), 69 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 1b54716994c5..51349893fb95 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -48,60 +48,42 @@ TODO: #include "../comedidev.h" -/* all the registers for the pci1723 board */ -#define PCI1723_DA(N) ((N)<<1) /* W: D/A register N (0 to 7) */ - -#define PCI1723_SYN_SET 0x12 /* synchronized set register */ -#define PCI1723_ALL_CHNNELE_SYN_STROBE 0x12 - /* synchronized status register */ - -#define PCI1723_RANGE_CALIBRATION_MODE 0x14 - /* range and calibration mode */ -#define PCI1723_RANGE_CALIBRATION_STATUS 0x14 - /* range and calibration status */ - -#define PCI1723_CONTROL_CMD_CALIBRATION_FUN 0x16 - /* - * SADC control command for - * calibration function - */ -#define PCI1723_STATUS_CMD_CALIBRATION_FUN 0x16 - /* - * SADC control status for - * calibration function - */ - -#define PCI1723_CALIBRATION_PARA_STROBE 0x18 - /* Calibration parameter strobe */ - -#define PCI1723_DIGITAL_IO_PORT_SET 0x1A /* Digital I/O port setting */ -#define PCI1723_DIGITAL_IO_PORT_MODE 0x1A /* Digital I/O port mode */ - -#define PCI1723_WRITE_DIGITAL_OUTPUT_CMD 0x1C - /* Write digital output command */ -#define PCI1723_READ_DIGITAL_INPUT_DATA 0x1C /* Read digital input data */ - -#define PCI1723_WRITE_CAL_CMD 0x1E /* Write calibration command */ -#define PCI1723_READ_CAL_STATUS 0x1E /* Read calibration status */ - -#define PCI1723_SYN_STROBE 0x20 /* Synchronized strobe */ - -#define PCI1723_RESET_ALL_CHN_STROBE 0x22 - /* Reset all D/A channels strobe */ - -#define PCI1723_RESET_CAL_CONTROL_STROBE 0x24 - /* - * Reset the calibration - * controller strobe - */ - -#define PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE 0x26 - /* - * Change D/A channels output - * type strobe - */ - -#define PCI1723_SELECT_CALIBRATION 0x28 /* Select the calibration Ref_V */ +/* + * PCI Bar 2 I/O Register map (dev->iobase) + */ +#define PCI1723_AO_REG(x) (0x00 + ((x) * 2)) +#define PCI1723_BOARD_ID_REG 0x10 +#define PCI1723_BOARD_ID_MASK (0xf << 0) +#define PCI1723_SYNC_CTRL_REG 0x12 +#define PCI1723_SYNC_CTRL_ASYNC (0 << 0) +#define PCI1723_SYNC_CTRL_SYNC (1 << 0) +#define PCI1723_CTRL_REG 0x14 +#define PCI1723_CTRL_BUSY (1 << 15) +#define PCI1723_CTRL_INIT (1 << 14) +#define PCI1723_CTRL_SELF (1 << 8) +#define PCI1723_CTRL_IDX(x) (((x) & 0x3) << 6) +#define PCI1723_CTRL_RANGE(x) (((x) & 0x3) << 4) +#define PCI1723_CTRL_GAIN (0 << 3) +#define PCI1723_CTRL_OFFSET (1 << 3) +#define PCI1723_CTRL_CHAN(x) (((x) & 0x7) << 0) +#define PCI1723_CALIB_CTRL_REG 0x16 +#define PCI1723_CALIB_CTRL_CS (1 << 2) +#define PCI1723_CALIB_CTRL_DAT (1 << 1) +#define PCI1723_CALIB_CTRL_CLK (1 << 0) +#define PCI1723_CALIB_STROBE_REG 0x18 +#define PCI1723_DIO_CTRL_REG 0x1a +#define PCI1723_DIO_CTRL_HDIO (1 << 1) +#define PCI1723_DIO_CTRL_LDIO (1 << 0) +#define PCI1723_DIO_DATA_REG 0x1c +#define PCI1723_CALIB_DATA_REG 0x1e +#define PCI1723_SYNC_STROBE_REG 0x20 +#define PCI1723_RESET_AO_STROBE_REG 0x22 +#define PCI1723_RESET_CALIB_STROBE_REG 0x24 +#define PCI1723_RANGE_STROBE_REG 0x26 +#define PCI1723_VREF_REG 0x28 +#define PCI1723_VREF_NEG10V (0 << 0) +#define PCI1723_VREF_0V (1 << 0) +#define PCI1723_VREF_POS10V (3 << 0) struct pci1723_private { unsigned char da_range[8]; /* D/A output range for each channel */ @@ -116,25 +98,22 @@ static int pci1723_reset(struct comedi_device *dev) struct pci1723_private *devpriv = dev->private; int i; - outw(0x01, dev->iobase + PCI1723_SYN_SET); - /* set synchronous output mode */ + outw(PCI1723_SYNC_CTRL_SYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); for (i = 0; i < 8; i++) { /* set all outputs to 0V */ devpriv->ao_data[i] = 0x8000; - outw(devpriv->ao_data[i], dev->iobase + PCI1723_DA(i)); + outw(devpriv->ao_data[i], dev->iobase + PCI1723_AO_REG(i)); /* set all ranges to +/- 10V */ devpriv->da_range[i] = 0; outw(((devpriv->da_range[i] << 4) | i), - PCI1723_RANGE_CALIBRATION_MODE); + PCI1723_CTRL_REG); } - outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); - /* update ranges */ - outw(0, dev->iobase + PCI1723_SYN_STROBE); /* update outputs */ + outw(0, dev->iobase + PCI1723_RANGE_STROBE_REG); + outw(0, dev->iobase + PCI1723_SYNC_STROBE_REG); - /* set asynchronous output mode */ - outw(0, dev->iobase + PCI1723_SYN_SET); + outw(PCI1723_SYNC_CTRL_ASYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); return 0; } @@ -166,7 +145,7 @@ static int pci1723_ao_write_winsn(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { devpriv->ao_data[chan] = data[n]; - outw(data[n], dev->iobase + PCI1723_DA(chan)); + outw(data[n], dev->iobase + PCI1723_AO_REG(chan)); } return n; @@ -199,7 +178,7 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, mode |= 0x0001; /* low byte input */ if (!(s->io_bits & 0xff00)) mode |= 0x0002; /* high byte input */ - outw(mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); + outw(mode, dev->iobase + PCI1723_DIO_CTRL_REG); return insn->n; } @@ -210,9 +189,9 @@ static int pci1723_dio_insn_bits(struct comedi_device *dev, unsigned int *data) { if (comedi_dio_update_state(s, data)) - outw(s->state, dev->iobase + PCI1723_WRITE_DIGITAL_OUTPUT_CMD); + outw(s->state, dev->iobase + PCI1723_DIO_DATA_REG); - data[1] = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA); + data[1] = inw(dev->iobase + PCI1723_DIO_DATA_REG); return insn->n; } @@ -260,7 +239,7 @@ static int pci1723_auto_attach(struct comedi_device *dev, s->insn_bits = pci1723_dio_insn_bits; /* read DIO config */ - switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE) & 0x03) { + switch (inw(dev->iobase + PCI1723_DIO_CTRL_REG) & 0x03) { case 0x00: /* low byte output, high byte output */ s->io_bits = 0xFFFF; break; @@ -275,7 +254,7 @@ static int pci1723_auto_attach(struct comedi_device *dev, break; } /* read DIO port state */ - s->state = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA); + s->state = inw(dev->iobase + PCI1723_DIO_DATA_REG); pci1723_reset(dev); -- cgit v1.2.3-59-g8ed1b From 24001039a4618e80cdf44a2b2970001dd8e63029 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:28 -0700 Subject: staging: comedi: adv_pci1723: remove private data 'da_range' This member of the private data is initialized to 0 by pci1723_reset() and is not used any where else in the driver. Remove it. Use the register map defines to set the range for each output channel. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 51349893fb95..87f78367fe95 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -86,7 +86,6 @@ TODO: #define PCI1723_VREF_POS10V (3 << 0) struct pci1723_private { - unsigned char da_range[8]; /* D/A output range for each channel */ unsigned short ao_data[8]; /* data output buffer */ }; @@ -105,8 +104,7 @@ static int pci1723_reset(struct comedi_device *dev) devpriv->ao_data[i] = 0x8000; outw(devpriv->ao_data[i], dev->iobase + PCI1723_AO_REG(i)); /* set all ranges to +/- 10V */ - devpriv->da_range[i] = 0; - outw(((devpriv->da_range[i] << 4) | i), + outw(PCI1723_CTRL_RANGE(0) | PCI1723_CTRL_CHAN(i), PCI1723_CTRL_REG); } -- cgit v1.2.3-59-g8ed1b From b5ed2b28433e9b8826a30fbc942bc2309dca7031 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:29 -0700 Subject: staging: comedi: adv_pci1723: remove board reset during (*detach) The pci1723_reset() function simply resets all the analog output channels to 0V and a +/-10V range. This really isn't necessary when detaching the driver. Remove the board reset and just use comedi_pci_detach() directly for the (*detach). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 87f78367fe95..1b59eb2ff4e9 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -259,18 +259,11 @@ static int pci1723_auto_attach(struct comedi_device *dev, return 0; } -static void pci1723_detach(struct comedi_device *dev) -{ - if (dev->iobase) - pci1723_reset(dev); - comedi_pci_detach(dev); -} - static struct comedi_driver adv_pci1723_driver = { .driver_name = "adv_pci1723", .module = THIS_MODULE, .auto_attach = pci1723_auto_attach, - .detach = pci1723_detach, + .detach = comedi_pci_detach, }; static int adv_pci1723_pci_probe(struct pci_dev *dev, -- cgit v1.2.3-59-g8ed1b From 5317f9a6299cefbf8eadea7d8a0355c0ec9cc2b0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:30 -0700 Subject: staging: comedi: adv_pci1723: absorb pci1723_reset() This function is only called by the (*auto_attach) to reset all the analog output channels. For aesthetics, absorb the function. Fix the range programming for each channel. According to the users manual the "range strobe" register needs to be written after setting the "DAC range control" register in order to load the range setting. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 45 ++++++++++------------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 1b59eb2ff4e9..098c69cfbaee 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -89,33 +89,6 @@ struct pci1723_private { unsigned short ao_data[8]; /* data output buffer */ }; -/* - * The pci1723 card reset; - */ -static int pci1723_reset(struct comedi_device *dev) -{ - struct pci1723_private *devpriv = dev->private; - int i; - - outw(PCI1723_SYNC_CTRL_SYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); - - for (i = 0; i < 8; i++) { - /* set all outputs to 0V */ - devpriv->ao_data[i] = 0x8000; - outw(devpriv->ao_data[i], dev->iobase + PCI1723_AO_REG(i)); - /* set all ranges to +/- 10V */ - outw(PCI1723_CTRL_RANGE(0) | PCI1723_CTRL_CHAN(i), - PCI1723_CTRL_REG); - } - - outw(0, dev->iobase + PCI1723_RANGE_STROBE_REG); - outw(0, dev->iobase + PCI1723_SYNC_STROBE_REG); - - outw(PCI1723_SYNC_CTRL_ASYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); - - return 0; -} - static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -201,6 +174,7 @@ static int pci1723_auto_attach(struct comedi_device *dev, struct pci1723_private *devpriv; struct comedi_subdevice *s; int ret; + int i; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) @@ -226,6 +200,21 @@ static int pci1723_auto_attach(struct comedi_device *dev, s->insn_write = pci1723_ao_write_winsn; s->insn_read = pci1723_insn_read_ao; + /* synchronously reset all analog outputs to 0V, +/-10V range */ + outw(PCI1723_SYNC_CTRL_SYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); + for (i = 0; i < s->n_chan; i++) { + outw(PCI1723_CTRL_RANGE(0) | PCI1723_CTRL_CHAN(i), + PCI1723_CTRL_REG); + outw(0, dev->iobase + PCI1723_RANGE_STROBE_REG); + + devpriv->ao_data[i] = 0x8000; + outw(devpriv->ao_data[i], dev->iobase + PCI1723_AO_REG(i)); + } + outw(0, dev->iobase + PCI1723_SYNC_STROBE_REG); + + /* disable syncronous control */ + outw(PCI1723_SYNC_CTRL_ASYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); + s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; @@ -254,8 +243,6 @@ static int pci1723_auto_attach(struct comedi_device *dev, /* read DIO port state */ s->state = inw(dev->iobase + PCI1723_DIO_DATA_REG); - pci1723_reset(dev); - return 0; } -- cgit v1.2.3-59-g8ed1b From c8a14b924c15de655ae504f6a5cc2f698c2c4e13 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:31 -0700 Subject: staging: comedi: adv_pci1723: use comedi_subdevice readback for 'ao_data' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only analog output subdevice. Remove the then unused 'ao_data' member from the private data. The private data is now unnecessary. Remove it and the allocation. For aesthetics, rename the (*insn_write) function and tidy it up a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 57 +++++++++------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 098c69cfbaee..a03f4bc7f4fb 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -85,41 +85,22 @@ TODO: #define PCI1723_VREF_0V (1 << 0) #define PCI1723_VREF_POS10V (3 << 0) -struct pci1723_private { - unsigned short ao_data[8]; /* data output buffer */ -}; - -static int pci1723_insn_read_ao(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct pci1723_private *devpriv = dev->private; - int n, chan; - - chan = CR_CHAN(insn->chanspec); - for (n = 0; n < insn->n; n++) - data[n] = devpriv->ao_data[chan]; - - return n; -} - -/* - analog data output; -*/ -static int pci1723_ao_write_winsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int pci1723_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct pci1723_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - int n; + int i; - for (n = 0; n < insn->n; n++) { - devpriv->ao_data[chan] = data[n]; - outw(data[n], dev->iobase + PCI1723_AO_REG(chan)); + for (i = 0; i < insn->n; i++) { + unsigned int val = data[i]; + + outw(val, dev->iobase + PCI1723_AO_REG(chan)); + s->readback[chan] = val; } - return n; + return insn->n; } /* @@ -171,15 +152,10 @@ static int pci1723_auto_attach(struct comedi_device *dev, unsigned long context_unused) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct pci1723_private *devpriv; struct comedi_subdevice *s; int ret; int i; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - ret = comedi_pci_enable(dev); if (ret) return ret; @@ -197,8 +173,11 @@ static int pci1723_auto_attach(struct comedi_device *dev, s->maxdata = 0xffff; s->len_chanlist = 8; s->range_table = &range_bipolar10; - s->insn_write = pci1723_ao_write_winsn; - s->insn_read = pci1723_insn_read_ao; + s->insn_write = pci1723_ao_insn_write; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; /* synchronously reset all analog outputs to 0V, +/-10V range */ outw(PCI1723_SYNC_CTRL_SYNC, dev->iobase + PCI1723_SYNC_CTRL_REG); @@ -207,8 +186,8 @@ static int pci1723_auto_attach(struct comedi_device *dev, PCI1723_CTRL_REG); outw(0, dev->iobase + PCI1723_RANGE_STROBE_REG); - devpriv->ao_data[i] = 0x8000; - outw(devpriv->ao_data[i], dev->iobase + PCI1723_AO_REG(i)); + outw(0x8000, dev->iobase + PCI1723_AO_REG(i)); + s->readback[i] = 0x8000; } outw(0, dev->iobase + PCI1723_SYNC_STROBE_REG); -- cgit v1.2.3-59-g8ed1b From 0f35abd5edaea253ab73e77c26d3393f589f4ae1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:32 -0700 Subject: staging: comedi: adv_pci1723: tidy up pci1723_dio_insn_config() For aesthetics, tidy this function up and use the register defines to remove the magic numbers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index a03f4bc7f4fb..53f2b2158594 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -103,33 +103,24 @@ static int pci1723_ao_insn_write(struct comedi_device *dev, return insn->n; } -/* - digital i/o config/query -*/ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - unsigned short mode; + unsigned int mask = (chan < 8) ? 0x00ff : 0xff00; + unsigned short mode = 0x0000; /* assume output */ int ret; - if (chan < 8) - mask = 0x00ff; - else - mask = 0xff00; - ret = comedi_dio_insn_config(dev, s, insn, data, mask); if (ret) return ret; - /* update hardware DIO mode */ - mode = 0x0000; /* assume output */ if (!(s->io_bits & 0x00ff)) - mode |= 0x0001; /* low byte input */ + mode |= PCI1723_DIO_CTRL_LDIO; /* low byte input */ if (!(s->io_bits & 0xff00)) - mode |= 0x0002; /* high byte input */ + mode |= PCI1723_DIO_CTRL_HDIO; /* high byte input */ outw(mode, dev->iobase + PCI1723_DIO_CTRL_REG); return insn->n; -- cgit v1.2.3-59-g8ed1b From 348aeaa712e315b6ced688e4d7152136479b047d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:33 -0700 Subject: staging: comedi: adv_pci1723: tidy up DIO io_bits initialization Tidy up the code that determines the initial io_bits (direction) of the digital I/O subdevice and remove the magic numbers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 53f2b2158594..01e90d946860 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -144,6 +144,7 @@ static int pci1723_auto_attach(struct comedi_device *dev, { struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct comedi_subdevice *s; + unsigned int val; int ret; int i; @@ -195,22 +196,12 @@ static int pci1723_auto_attach(struct comedi_device *dev, s->insn_config = pci1723_dio_insn_config; s->insn_bits = pci1723_dio_insn_bits; - /* read DIO config */ - switch (inw(dev->iobase + PCI1723_DIO_CTRL_REG) & 0x03) { - case 0x00: /* low byte output, high byte output */ - s->io_bits = 0xFFFF; - break; - case 0x01: /* low byte input, high byte output */ - s->io_bits = 0xFF00; - break; - case 0x02: /* low byte output, high byte input */ - s->io_bits = 0x00FF; - break; - case 0x03: /* low byte input, high byte input */ - s->io_bits = 0x0000; - break; - } - /* read DIO port state */ + /* get initial DIO direction and state */ + val = inw(dev->iobase + PCI1723_DIO_CTRL_REG); + if (!(val & PCI1723_DIO_CTRL_LDIO)) + s->io_bits |= 0x00ff; /* low byte output */ + if (!(val & PCI1723_DIO_CTRL_HDIO)) + s->io_bits |= 0xff00; /* high byte output */ s->state = inw(dev->iobase + PCI1723_DIO_DATA_REG); return 0; -- cgit v1.2.3-59-g8ed1b From 817c5ac2dc41f6371bbc343bdf236c8993d53c28 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:34 -0700 Subject: staging: comedi: adv_pci1723: remove subdevice 'len_chanlist' initialization The subdevice 'len_chanlist' is only used by subdevices that support async commands. Remove the unnecessary initializations in this driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 01e90d946860..9c9a0d332e5f 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -140,7 +140,7 @@ static int pci1723_dio_insn_bits(struct comedi_device *dev, } static int pci1723_auto_attach(struct comedi_device *dev, - unsigned long context_unused) + unsigned long context_unused) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct comedi_subdevice *s; @@ -163,7 +163,6 @@ static int pci1723_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; s->maxdata = 0xffff; - s->len_chanlist = 8; s->range_table = &range_bipolar10; s->insn_write = pci1723_ao_insn_write; @@ -191,7 +190,6 @@ static int pci1723_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 16; s->maxdata = 1; - s->len_chanlist = 16; s->range_table = &range_digital; s->insn_config = pci1723_dio_insn_config; s->insn_bits = pci1723_dio_insn_bits; -- cgit v1.2.3-59-g8ed1b From e5092d796913ad28d528b571f646143ffe1d5dcc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:35 -0700 Subject: staging: comedi: adv_pci1723: update the MODULE_DESCRIPTION Update the MODULE_DESCRIPTION to something more useful than the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 9c9a0d332e5f..937980aaf68b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -234,5 +234,5 @@ static struct pci_driver adv_pci1723_pci_driver = { module_comedi_pci_driver(adv_pci1723_driver, adv_pci1723_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Advantech PCI-1723 Comedi driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From c3a132c75d8a978f46adbabe74ce470384de0a90 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:36 -0700 Subject: staging: comedi: adv_pci1723: tidy up multi-line comments Tidy up the multi-line comments to follow the CodingStyle. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 79 +++++++++++++--------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 937980aaf68b..bd86a7137a06 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -1,47 +1,44 @@ /* - comedi/drivers/pci1723.c - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + * adv_pci1723.c + * Comedi driver for the Advantech PCI-1723 card. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. -*/ /* -Driver: adv_pci1723 -Description: Advantech PCI-1723 -Author: yonggang , Ian Abbott -Devices: [Advantech] PCI-1723 (adv_pci1723) -Updated: Mon, 14 Apr 2008 15:12:56 +0100 -Status: works - -Configuration Options: - [0] - PCI bus of device (optional) - [1] - PCI slot of device (optional) - - If bus/slot is not specified, the first supported - PCI device found will be used. - -Subdevice 0 is 8-channel AO, 16-bit, range +/- 10 V. - -Subdevice 1 is 16-channel DIO. The channels are configurable as input or -output in 2 groups (0 to 7, 8 to 15). Configuring any channel implicitly -configures all channels in the same group. - -TODO: - -1. Add the two milliamp ranges to the AO subdevice (0 to 20 mA, 4 to 20 mA). -2. Read the initial ranges and values of the AO subdevice at start-up instead - of reinitializing them. -3. Implement calibration. -*/ + * Driver: adv_pci1723 + * Description: Advantech PCI-1723 + * Author: yonggang , Ian Abbott + * Devices: (Advantech) PCI-1723 [adv_pci1723] + * Updated: Mon, 14 Apr 2008 15:12:56 +0100 + * Status: works + * + * Configuration Options: not applicable, uses comedi PCI auto config + * + * Subdevice 0 is 8-channel AO, 16-bit, range +/- 10 V. + * + * Subdevice 1 is 16-channel DIO. The channels are configurable as + * input or output in 2 groups (0 to 7, 8 to 15). Configuring any + * channel implicitly configures all channels in the same group. + * + * TODO: + * 1. Add the two milliamp ranges to the AO subdevice (0 to 20 mA, + * 4 to 20 mA). + * 2. Read the initial ranges and values of the AO subdevice at + * start-up instead of reinitializing them. + * 3. Implement calibration. + */ #include #include -- cgit v1.2.3-59-g8ed1b From 14ec0838665367b169804a822a65015a1b486986 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 21 Nov 2014 14:22:37 -0700 Subject: staging: comedi: adv_pci1723: remove comedi_device 'write_subdev' init The comedi_device 'write_subdev' should only be initialized if the subdevice supports async commands. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1723.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index bd86a7137a06..65f854e1eb66 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -155,7 +155,6 @@ static int pci1723_auto_attach(struct comedi_device *dev, return ret; s = &dev->subdevices[0]; - dev->write_subdev = s; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 8; -- cgit v1.2.3-59-g8ed1b From fe2a7c05756c5a368843e8233d1c1f3fbf028511 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 27 Nov 2014 07:10:20 -0800 Subject: Revert "staging: unisys: fix CamelCase macro names in controlframework.h" This reverts commit 75185f57f110a7c48d9d33a585320c93334adf0c because it modified the .gitignore file in the root of the tree, without saying it did so, which isn't acceptable. Reported-by: Stephen Rothwell Cc: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .gitignore | 4 ---- .../staging/unisys/common-spar/include/channels/controlframework.h | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6bfac06d79ca..e213b27f3921 100644 --- a/.gitignore +++ b/.gitignore @@ -96,7 +96,3 @@ x509.genkey # Kconfig presets all.config - -#eclipse files -.project -.cproject diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index 7f1adf64b173..80e2df139ea3 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -28,14 +28,14 @@ #include #include "channel.h" -#define ULTRA_MEMORY_COUNT_KI 1024 +#define ULTRA_MEMORY_COUNT_Ki 1024 /* Scale order 0 is one 32-bit (4-byte) word (in 64 or 128-bit * architecture potentially 64 or 128-bit word) */ #define ULTRA_MEMORY_PAGE_WORD 4 /* Define Ki scale page to be traditional 4KB page */ -#define ULTRA_MEMORY_PAGE_KI (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_KI) +#define ULTRA_MEMORY_PAGE_Ki (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_Ki) struct spar_segment_state { u16 enabled:1; /* Bit 0: May enter other states */ u16 active:1; /* Bit 1: Assigned to active partition */ -- cgit v1.2.3-59-g8ed1b From aa9d9be96d33d97488e1bdf13a144931a3fce08e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 27 Nov 2014 08:13:24 -0800 Subject: staging: unisys: remove pointless macros These macros aren't used anywhere, so just remove them. Cc: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/controlframework.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index 80e2df139ea3..33d9caf337c8 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -28,14 +28,6 @@ #include #include "channel.h" -#define ULTRA_MEMORY_COUNT_Ki 1024 - -/* Scale order 0 is one 32-bit (4-byte) word (in 64 or 128-bit - * architecture potentially 64 or 128-bit word) */ -#define ULTRA_MEMORY_PAGE_WORD 4 - -/* Define Ki scale page to be traditional 4KB page */ -#define ULTRA_MEMORY_PAGE_Ki (ULTRA_MEMORY_PAGE_WORD * ULTRA_MEMORY_COUNT_Ki) struct spar_segment_state { u16 enabled:1; /* Bit 0: May enter other states */ u16 active:1; /* Bit 1: Assigned to active partition */ -- cgit v1.2.3-59-g8ed1b From 8b21696c51b05fbe0175cc3c22f3aaf1408cc18c Mon Sep 17 00:00:00 2001 From: Anjana Sasindran Date: Fri, 28 Nov 2014 22:09:09 +0530 Subject: staging:drivers:staging:rtl8188eu:hal:rtl8188e_hal_init.c: Added a blank line after declaration This patch fix a checkpatch.pl warning WARNING:Missing blank line after declaration Signed-off-by: Anjana Sasindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 68db5c99696f..7d460eaafa35 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -182,6 +182,7 @@ static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable case HAL_ODM_STA_INFO: { struct sta_info *psta = pValue1; + if (bSet) { DBG_88E("### Set STA_(%d) info\n", psta->mac_id); ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); -- cgit v1.2.3-59-g8ed1b From 6179ed592b5e4c797d7c9668fe81356ebbeab423 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 1 Dec 2014 15:20:58 -0500 Subject: staging: rtl8188eu: usb_dvobj_init(): A NULL pointer check for usb_host_endpoints makes no sense struct usb_host_interface points to an array of struct usb_host_endpoints - it makes no sense to do a NULL pointer check for each pointer. Signed-off-by: Jes Sorensen Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 33 +++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index d3cbcc4a405c..bee39c2278f1 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -63,7 +63,6 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_config_descriptor *pconf_desc; struct usb_host_interface *phost_iface; struct usb_interface_descriptor *piface_desc; - struct usb_host_endpoint *phost_endp; struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; @@ -92,24 +91,22 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { int ep_num; - phost_endp = phost_iface->endpoint + i; - - if (phost_endp) { - pendp_desc = &phost_endp->desc; - ep_num = usb_endpoint_num(pendp_desc); - - if (usb_endpoint_is_bulk_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_int_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_bulk_out(pendp_desc)) { - pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; - pdvobjpriv->RtNumOutPipes++; - } - pdvobjpriv->ep_num[i] = ep_num; + pendp_desc = &phost_iface->endpoint[i].desc; + + ep_num = usb_endpoint_num(pendp_desc); + + if (usb_endpoint_is_bulk_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_int_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = + ep_num; + pdvobjpriv->RtNumOutPipes++; } + pdvobjpriv->ep_num[i] = ep_num; } if (pusbd->speed == USB_SPEED_HIGH) -- cgit v1.2.3-59-g8ed1b From 99eff12f8a28762ac5d96158f0e344d64f978d28 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Tue, 2 Dec 2014 23:33:29 +0100 Subject: staging: rtl8188eu: hal: hal_intf.c: Cleaning up functions that are not used anywhere Removes some functions that are not used anywhere. rtw_hal_interrupt_handler() rtw_hal_sreset_get_wifi_status() This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 16 ---------------- drivers/staging/rtl8188eu/include/hal_intf.h | 3 --- 2 files changed, 19 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index 538a0f65d09c..4bdbed28774e 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -275,13 +275,6 @@ void rtw_hal_write_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, bitmask, data); } -s32 rtw_hal_interrupt_handler(struct adapter *adapt) -{ - if (adapt->HalFunc.interrupt_handler) - return adapt->HalFunc.interrupt_handler(adapt); - return _FAIL; -} - void rtw_hal_set_bwmode(struct adapter *adapt, enum ht_channel_width bandwidth, u8 offset) { @@ -329,15 +322,6 @@ void rtw_hal_sreset_init(struct adapter *adapt) adapt->HalFunc.sreset_init_value(adapt); } -u8 rtw_hal_sreset_get_wifi_status(struct adapter *adapt) -{ - u8 status = 0; - - if (adapt->HalFunc.sreset_get_wifi_status) - status = adapt->HalFunc.sreset_get_wifi_status(adapt); - return status; -} - void rtw_hal_notch_filter(struct adapter *adapter, bool enable) { if (adapter->HalFunc.hal_notch_filter) diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 9191993dd3f5..3b476d80f64d 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -304,8 +304,6 @@ void rtw_hal_write_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -s32 rtw_hal_interrupt_handler(struct adapter *padapter); - void rtw_hal_set_bwmode(struct adapter *padapter, enum ht_channel_width Bandwidth, u8 Offset); void rtw_hal_set_chan(struct adapter *padapter, u8 channel); @@ -317,7 +315,6 @@ void rtw_hal_antdiv_rssi_compared(struct adapter *padapter, struct wlan_bssid_ex *src); void rtw_hal_sreset_init(struct adapter *padapter); -u8 rtw_hal_sreset_get_wifi_status(struct adapter *padapter); void rtw_hal_notch_filter(struct adapter *adapter, bool enable); void rtw_hal_reset_security_engine(struct adapter *adapter); -- cgit v1.2.3-59-g8ed1b From ac33c20dadf927b7fc96292810007633805a6fe2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 27 Nov 2014 11:37:17 +0000 Subject: staging: comedi: adl_pci9118: simplify interrupt_pci9118_ai_dma() a bit Eliminate the `next_dma_buf` variable in `interrupt_pci9118_ai_dma()`. It holds the next value of `devpriv->dma_actbuf` when double buffering is used, but we can just set that to the next value directly at the point where the buffers are switched as the old value is not used anywhere else. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 5e0ff9db6a47..aecfae891628 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -608,16 +608,15 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; struct pci9118_dmabuf *dmabuf = &devpriv->dmabuf[devpriv->dma_actbuf]; unsigned int nsamples = comedi_bytes_to_samples(s, dmabuf->use_size); - unsigned int next_dma_buf; - if (devpriv->dma_doublebuf) { /* - * switch DMA buffers if is used - * double buffering - */ - next_dma_buf = 1 - devpriv->dma_actbuf; - pci9118_amcc_setup_dma(dev, next_dma_buf); - if (devpriv->ai_do == 4) - interrupt_pci9118_ai_mode4_switch(dev, next_dma_buf); + /* switch DMA buffers and restart DMA if double buffering */ + if (devpriv->dma_doublebuf) { + devpriv->dma_actbuf = 1 - devpriv->dma_actbuf; + pci9118_amcc_setup_dma(dev, devpriv->dma_actbuf); + if (devpriv->ai_do == 4) { + interrupt_pci9118_ai_mode4_switch(dev, + devpriv->dma_actbuf); + } } if (nsamples) { @@ -631,11 +630,8 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, s->async->events |= COMEDI_CB_EOA; } - if (devpriv->dma_doublebuf) { - /* switch dma buffers */ - devpriv->dma_actbuf = 1 - devpriv->dma_actbuf; - } else { - /* restart DMA if is not used double buffering */ + /* restart DMA if not double buffering */ + if (!devpriv->dma_doublebuf) { pci9118_amcc_setup_dma(dev, 0); if (devpriv->ai_do == 4) interrupt_pci9118_ai_mode4_switch(dev, 0); -- cgit v1.2.3-59-g8ed1b From bb4a51a1b5d5acde77f814689aa467304bd942fb Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 27 Nov 2014 11:37:18 +0000 Subject: staging: comedi: adl_pci9118: try and avoid unnecessary DMA restart `interrupt_pci9118_ai_dma()` is called on interrupt to transfer data from DMA buffers into the comedi async data buffer. Currently it always restarts DMA. If double buffering, it restarts DMA on the next DMA buffer before processing the current DMA buffer, otherwise it restarts DMA on the same DMA buffer after it has been processed. For single buffering we can avoid restarting the DMA transfer by checking the async event flags after the current buffer has been processed, which is easy. For double buffering, we need to know how many valid samples there are in the current buffer before it has been processed and determine whether there is enough to complete the acquisition. Call new function `valid_samples_in_act_dma_buf()` to determine the number of valid samples in the current DMA buffer, and compare that with the result of `comedi_nsamples_left()` to determine if DMA needs to be restarted. (`comedi_nsamples_left()` needs an upper bound to clamp to, so use the number of valid samples in the DMA buffer plus one for our test.) It is still possible for DMA to be restarted unnecessarily in the double buffer case if a `COMEDI_CB_OVERFLOW` event occurs while copying to the comedi async buffer, but it doesn't really matter. The ongoing DMA operation will get disabled when the subdevice's `cancel()` handler is called when the events are handled later in the interrupt service routine (as it does currently). Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 78 +++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index aecfae891628..c0ea7335ed38 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -446,6 +446,62 @@ static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev, outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG); } +static unsigned int valid_samples_in_act_dma_buf(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int n_raw_samples) +{ + struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int start_pos = devpriv->ai_add_front; + unsigned int stop_pos = start_pos + cmd->chanlist_len; + unsigned int span_len = stop_pos + devpriv->ai_add_back; + unsigned int dma_pos = devpriv->ai_act_dmapos; + unsigned int whole_spans, n_samples, x; + + if (span_len == cmd->chanlist_len) + return n_raw_samples; /* use all samples */ + + /* + * Not all samples are to be used. Buffer contents consist of a + * possibly non-whole number of spans and a region of each span + * is to be used. + * + * Account for samples in whole number of spans. + */ + whole_spans = n_raw_samples / span_len; + n_samples = whole_spans * cmd->chanlist_len; + n_raw_samples -= whole_spans * span_len; + + /* + * Deal with remaining samples which could overlap up to two spans. + */ + while (n_raw_samples) { + if (dma_pos < start_pos) { + /* Skip samples before start position. */ + x = start_pos - dma_pos; + if (x > n_raw_samples) + x = n_raw_samples; + dma_pos += x; + n_raw_samples -= x; + if (!n_raw_samples) + break; + } + if (dma_pos < stop_pos) { + /* Include samples before stop position. */ + x = stop_pos - dma_pos; + if (x > n_raw_samples) + x = n_raw_samples; + n_samples += x; + dma_pos += x; + n_raw_samples -= x; + } + /* Advance to next span. */ + start_pos += span_len; + stop_pos += span_len; + } + return n_samples; +} + static unsigned int defragment_dma_buffer(struct comedi_device *dev, struct comedi_subdevice *s, unsigned short *dma_buffer, @@ -607,10 +663,16 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct pci9118_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; struct pci9118_dmabuf *dmabuf = &devpriv->dmabuf[devpriv->dma_actbuf]; - unsigned int nsamples = comedi_bytes_to_samples(s, dmabuf->use_size); + unsigned int n_all = comedi_bytes_to_samples(s, dmabuf->use_size); + unsigned int n_valid; + bool more_dma; + + /* determine whether more DMA buffers to do after this one */ + n_valid = valid_samples_in_act_dma_buf(dev, s, n_all); + more_dma = n_valid < comedi_nsamples_left(s, n_valid + 1); /* switch DMA buffers and restart DMA if double buffering */ - if (devpriv->dma_doublebuf) { + if (more_dma && devpriv->dma_doublebuf) { devpriv->dma_actbuf = 1 - devpriv->dma_actbuf; pci9118_amcc_setup_dma(dev, devpriv->dma_actbuf); if (devpriv->ai_do == 4) { @@ -619,10 +681,9 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, } } - if (nsamples) { - nsamples = defragment_dma_buffer(dev, s, dmabuf->virt, - nsamples); - comedi_buf_write_samples(s, dmabuf->virt, nsamples); + if (n_all) { + n_valid = defragment_dma_buffer(dev, s, dmabuf->virt, n_all); + comedi_buf_write_samples(s, dmabuf->virt, n_valid); } if (!devpriv->ai_neverending) { @@ -630,8 +691,11 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, s->async->events |= COMEDI_CB_EOA; } + if (s->async->events & COMEDI_CB_CANCEL_MASK) + more_dma = false; + /* restart DMA if not double buffering */ - if (!devpriv->dma_doublebuf) { + if (more_dma && !devpriv->dma_doublebuf) { pci9118_amcc_setup_dma(dev, 0); if (devpriv->ai_do == 4) interrupt_pci9118_ai_mode4_switch(dev, 0); -- cgit v1.2.3-59-g8ed1b From e87f65b238a6c1e76776469d92190f6c46c5817f Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 27 Nov 2014 11:37:19 +0000 Subject: staging: comedi: adl_pci9118: eliminate DMA buffer defragmentation step The DMA operations used by the driver may have been set up to acquire data from unwanted channels in addition to the wanted channels. Currently, `interrupt_pci9118_ai_dma()` calls `defragment_dma_buffer()` to move all the wanted data to the start of the DMA buffer and then calls `comedi_buf_write_samples()` to copy it all to the comedi async buffer. Those two functions used to be called from `move_block_from_dma()` which was absorbed into `interrupt_pci9118_ai_dma()`. Reinstate `move_block_from_dma()` but rewrite it to copy data directly from the wanted fragments of the DMA buffer to the comedi async buffer without defragmenting the buffer first. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 67 +++++++++++++++++++--------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index c0ea7335ed38..26603582e71a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -502,29 +502,56 @@ static unsigned int valid_samples_in_act_dma_buf(struct comedi_device *dev, return n_samples; } -static unsigned int defragment_dma_buffer(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned short *dma_buffer, - unsigned int num_samples) +static void move_block_from_dma(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned short *dma_buffer, + unsigned int n_raw_samples) { struct pci9118_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int i = 0, j = 0; - unsigned int start_pos = devpriv->ai_add_front, - stop_pos = devpriv->ai_add_front + cmd->chanlist_len; - unsigned int raw_scanlen = devpriv->ai_add_front + cmd->chanlist_len + - devpriv->ai_add_back; + unsigned int start_pos = devpriv->ai_add_front; + unsigned int stop_pos = start_pos + cmd->chanlist_len; + unsigned int span_len = stop_pos + devpriv->ai_add_back; + unsigned int dma_pos = devpriv->ai_act_dmapos; + unsigned int x; - for (i = 0; i < num_samples; i++) { - if (devpriv->ai_act_dmapos >= start_pos && - devpriv->ai_act_dmapos < stop_pos) { - dma_buffer[j++] = dma_buffer[i]; + if (span_len == cmd->chanlist_len) { + /* All samples are to be copied. */ + comedi_buf_write_samples(s, dma_buffer, n_raw_samples); + dma_pos += n_raw_samples; + } else { + /* + * Not all samples are to be copied. Buffer contents consist + * of a possibly non-whole number of spans and a region of + * each span is to be copied. + */ + while (n_raw_samples) { + if (dma_pos < start_pos) { + /* Skip samples before start position. */ + x = start_pos - dma_pos; + if (x > n_raw_samples) + x = n_raw_samples; + dma_pos += x; + n_raw_samples -= x; + if (!n_raw_samples) + break; + } + if (dma_pos < stop_pos) { + /* Copy samples before stop position. */ + x = stop_pos - dma_pos; + if (x > n_raw_samples) + x = n_raw_samples; + comedi_buf_write_samples(s, dma_buffer, x); + dma_pos += x; + n_raw_samples -= x; + } + /* Advance to next span. */ + start_pos += span_len; + stop_pos += span_len; } - devpriv->ai_act_dmapos++; - devpriv->ai_act_dmapos %= raw_scanlen; } - - return j; + /* Update position in span for next time. */ + devpriv->ai_act_dmapos = dma_pos % span_len; } static void pci9118_exttrg_enable(struct comedi_device *dev, bool enable) @@ -681,10 +708,8 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, } } - if (n_all) { - n_valid = defragment_dma_buffer(dev, s, dmabuf->virt, n_all); - comedi_buf_write_samples(s, dmabuf->virt, n_valid); - } + if (n_all) + move_block_from_dma(dev, s, dmabuf->virt, n_all); if (!devpriv->ai_neverending) { if (s->async->scans_done >= cmd->stop_arg) -- cgit v1.2.3-59-g8ed1b From f884625f82ea883859391cd99deb1a222799b706 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Fri, 28 Nov 2014 14:34:29 +0100 Subject: staging: octeon: Fix checkpatch 80 character limit warnings Fixing 80 character limit warnings in octeon/ethernet-rx.c Signed-off-by: Luis de Bethencourt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rx.c | 49 ++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 1789a1221007..fcbe836aa997 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -126,13 +126,15 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work) if (*ptr == 0xd5) { /* - printk_ratelimited("Port %d received 0xd5 preamble\n", work->ipprt); + printk_ratelimited("Port %d received 0xd5 preamble\n", + work->ipprt); */ work->packet_ptr.s.addr += i + 1; work->len -= i + 5; } else if ((*ptr & 0xf) == 0xd) { /* - printk_ratelimited("Port %d received 0x?d preamble\n", work->ipprt); + printk_ratelimited("Port %d received 0x?d preamble\n", + work->ipprt); */ work->packet_ptr.s.addr += i; work->len -= i + 4; @@ -218,11 +220,13 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) cvmx_write_csr(CVMX_POW_WQ_INT, wq_int.u64); break; } - pskb = (struct sk_buff **)(cvm_oct_get_buffer_ptr(work->packet_ptr) - sizeof(void *)); + pskb = (struct sk_buff **)(cvm_oct_get_buffer_ptr(work->packet_ptr) - + sizeof(void *)); prefetch(pskb); if (USE_ASYNC_IOBDMA && rx_count < (budget - 1)) { - cvmx_pow_work_request_async_nocheck(CVMX_SCR_SCRATCH, CVMX_POW_NO_WAIT); + cvmx_pow_work_request_async_nocheck(CVMX_SCR_SCRATCH, + CVMX_POW_NO_WAIT); did_work_request = 1; } rx_count++; @@ -247,7 +251,8 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) * buffer. */ if (likely(skb_in_hw)) { - skb->data = skb->head + work->packet_ptr.s.addr - cvmx_ptr_to_phys(skb->head); + skb->data = skb->head + work->packet_ptr.s.addr - + cvmx_ptr_to_phys(skb->head); prefetch(skb->data); skb->len = work->len; skb_set_tail_pointer(skb, skb->len); @@ -284,7 +289,8 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) /* No packet buffers to free */ } else { int segments = work->word2.s.bufs; - union cvmx_buf_ptr segment_ptr = work->packet_ptr; + union cvmx_buf_ptr segment_ptr = + work->packet_ptr; int len = work->len; while (segments--) { @@ -300,8 +306,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) * one: int segment_size = * segment_ptr.s.size; */ - int segment_size = CVMX_FPA_PACKET_POOL_SIZE - - (segment_ptr.s.addr - (((segment_ptr.s.addr >> 7) - segment_ptr.s.back) << 7)); + int segment_size = + CVMX_FPA_PACKET_POOL_SIZE - + (segment_ptr.s.addr - + (((segment_ptr.s.addr >> 7) - + segment_ptr.s.back) << 7)); /* * Don't copy more than what * is left in the packet. @@ -332,8 +341,10 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) skb->protocol = eth_type_trans(skb, dev); skb->dev = dev; - if (unlikely(work->word2.s.not_IP || work->word2.s.IP_exc || - work->word2.s.L4_error || !work->word2.s.tcp_or_udp)) + if (unlikely(work->word2.s.not_IP || + work->word2.s.IP_exc || + work->word2.s.L4_error || + !work->word2.s.tcp_or_udp)) skb->ip_summed = CHECKSUM_NONE; else skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -341,11 +352,15 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) /* Increment RX stats for virtual ports */ if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) { #ifdef CONFIG_64BIT - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets); - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes); + atomic64_add(1, + (atomic64_t *)&priv->stats.rx_packets); + atomic64_add(skb->len, + (atomic64_t *)&priv->stats.rx_bytes); #else - atomic_add(1, (atomic_t *)&priv->stats.rx_packets); - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes); + atomic_add(1, + (atomic_t *)&priv->stats.rx_packets); + atomic_add(skb->len, + (atomic_t *)&priv->stats.rx_bytes); #endif } netif_receive_skb(skb); @@ -356,9 +371,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget) dev->name); */ #ifdef CONFIG_64BIT - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped); + atomic64_add(1, + (atomic64_t *)&priv->stats.rx_dropped); #else - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped); + atomic_add(1, + (atomic_t *)&priv->stats.rx_dropped); #endif dev_kfree_skb_irq(skb); } -- cgit v1.2.3-59-g8ed1b From 59a66a24e2e0658cabbabe5b5426ef4aafe87b12 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:45 +0100 Subject: staging: panel: Set default parport module param value Set default parport module param value to DEFAULT_PARPORT so that a if-block can be avoided. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index c6eeddfb398f..3dd318af1595 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -429,7 +429,7 @@ static struct timer_list scan_timer; MODULE_DESCRIPTION("Generic parallel port LCD/Keypad driver"); -static int parport = -1; +static int parport = DEFAULT_PARPORT; module_param(parport, int, 0000); MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)"); @@ -2231,9 +2231,6 @@ static int panel_init(void) if (lcd_type < 0) lcd_type = lcd_enabled; - if (parport < 0) - parport = DEFAULT_PARPORT; - /* take care of an eventual profile */ switch (profile) { case PANEL_PROFILE_CUSTOM: -- cgit v1.2.3-59-g8ed1b From d9114767d1d19a77ebfbab6764281abf84df7862 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:46 +0100 Subject: staging: panel: Call init function directly Remove useless function and let the kernel call the actual init function directly. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 3dd318af1595..0d3f09e7ee4a 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2222,7 +2222,7 @@ static struct parport_driver panel_driver = { }; /* init function */ -static int panel_init(void) +static int __init panel_init_module(void) { /* for backwards compatibility */ if (keypad_type < 0) @@ -2334,11 +2334,6 @@ static int panel_init(void) return 0; } -static int __init panel_init_module(void) -{ - return panel_init(); -} - static void __exit panel_cleanup_module(void) { unregister_reboot_notifier(&panel_notifier); -- cgit v1.2.3-59-g8ed1b From 36277d4ad01a6cb3c9e4b762f412cb45c29aa1ae Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:47 +0100 Subject: staging: panel: Remove magic numbers Get rid of magic numbers indicating that the value of a module param is not set. Use a defined value instead. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 0d3f09e7ee4a..1b4a2111769d 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -133,6 +133,8 @@ #define LCD_ESCAPE_LEN 24 /* max chars for LCD escape command */ #define LCD_ESCAPE_CHAR 27 /* use char 27 for escape command */ +#define NOT_SET -1 + /* macros to simplify use of the parallel port */ #define r_ctr(x) (parport_read_control((x)->port)) #define r_dtr(x) (parport_read_data((x)->port)) @@ -439,37 +441,37 @@ MODULE_PARM_DESC(profile, "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; " "4=16x2 nexcom; default=40x2, old kp"); -static int keypad_type = -1; +static int keypad_type = NOT_SET; 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"); -static int lcd_type = -1; +static int lcd_type = NOT_SET; 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"); -static int lcd_height = -1; +static int lcd_height = NOT_SET; module_param(lcd_height, int, 0000); MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD"); -static int lcd_width = -1; +static int lcd_width = NOT_SET; module_param(lcd_width, int, 0000); MODULE_PARM_DESC(lcd_width, "Number of columns on the LCD"); -static int lcd_bwidth = -1; /* internal buffer width (usually 40) */ +static int lcd_bwidth = NOT_SET; /* internal buffer width (usually 40) */ module_param(lcd_bwidth, int, 0000); MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)"); -static int lcd_hwidth = -1; /* hardware buffer width (usually 64) */ +static int lcd_hwidth = NOT_SET; /* hardware buffer width (usually 64) */ module_param(lcd_hwidth, int, 0000); MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)"); -static int lcd_charset = -1; +static int lcd_charset = NOT_SET; module_param(lcd_charset, int, 0000); MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); -static int lcd_proto = -1; +static int lcd_proto = NOT_SET; module_param(lcd_proto, int, 0000); MODULE_PARM_DESC(lcd_proto, "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface"); @@ -515,11 +517,11 @@ MODULE_PARM_DESC(lcd_bl_pin, /* Deprecated module parameters - consider not using them anymore */ -static int lcd_enabled = -1; +static int lcd_enabled = NOT_SET; module_param(lcd_enabled, int, 0000); MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); -static int keypad_enabled = -1; +static int keypad_enabled = NOT_SET; module_param(keypad_enabled, int, 0000); MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); -- cgit v1.2.3-59-g8ed1b From 2d35bcf66c61d696d9784fbf42a64daa9df0b068 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:48 +0100 Subject: staging: panel: Use defined value or checking module params state Avoid magic number and use a comparison with a defined value instead that checks whether module param has been set by the user to some value at loading time. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 86 +++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 1b4a2111769d..52889905c924 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1411,29 +1411,29 @@ static void lcd_init(void) switch (lcd_type) { case LCD_TYPE_OLD: /* parallel mode, 8 bits */ - if (lcd_proto < 0) + if (lcd_proto == NOT_SET) lcd_proto = LCD_PROTO_PARALLEL; - if (lcd_charset < 0) + if (lcd_charset == NOT_SET) lcd_charset = LCD_CHARSET_NORMAL; if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_STROBE; if (lcd_rs_pin == PIN_NOT_SET) lcd_rs_pin = PIN_AUTOLF; - if (lcd_width < 0) + if (lcd_width == NOT_SET) lcd_width = 40; - if (lcd_bwidth < 0) + if (lcd_bwidth == NOT_SET) lcd_bwidth = 40; - if (lcd_hwidth < 0) + if (lcd_hwidth == NOT_SET) lcd_hwidth = 64; - if (lcd_height < 0) + if (lcd_height == NOT_SET) lcd_height = 2; break; case LCD_TYPE_KS0074: /* serial mode, ks0074 */ - if (lcd_proto < 0) + if (lcd_proto == NOT_SET) lcd_proto = LCD_PROTO_SERIAL; - if (lcd_charset < 0) + if (lcd_charset == NOT_SET) lcd_charset = LCD_CHARSET_KS0074; if (lcd_bl_pin == PIN_NOT_SET) lcd_bl_pin = PIN_AUTOLF; @@ -1442,20 +1442,20 @@ static void lcd_init(void) if (lcd_da_pin == PIN_NOT_SET) lcd_da_pin = PIN_D0; - if (lcd_width < 0) + if (lcd_width == NOT_SET) lcd_width = 16; - if (lcd_bwidth < 0) + if (lcd_bwidth == NOT_SET) lcd_bwidth = 40; - if (lcd_hwidth < 0) + if (lcd_hwidth == NOT_SET) lcd_hwidth = 16; - if (lcd_height < 0) + if (lcd_height == NOT_SET) lcd_height = 2; break; case LCD_TYPE_NEXCOM: /* parallel mode, 8 bits, generic */ - if (lcd_proto < 0) + if (lcd_proto == NOT_SET) lcd_proto = LCD_PROTO_PARALLEL; - if (lcd_charset < 0) + if (lcd_charset == NOT_SET) lcd_charset = LCD_CHARSET_NORMAL; if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_AUTOLF; @@ -1464,42 +1464,42 @@ static void lcd_init(void) if (lcd_rw_pin == PIN_NOT_SET) lcd_rw_pin = PIN_INITP; - if (lcd_width < 0) + if (lcd_width == NOT_SET) lcd_width = 16; - if (lcd_bwidth < 0) + if (lcd_bwidth == NOT_SET) lcd_bwidth = 40; - if (lcd_hwidth < 0) + if (lcd_hwidth == NOT_SET) lcd_hwidth = 64; - if (lcd_height < 0) + if (lcd_height == NOT_SET) lcd_height = 2; break; case LCD_TYPE_CUSTOM: /* customer-defined */ - if (lcd_proto < 0) + if (lcd_proto == NOT_SET) lcd_proto = DEFAULT_LCD_PROTO; - if (lcd_charset < 0) + if (lcd_charset == NOT_SET) lcd_charset = DEFAULT_LCD_CHARSET; /* default geometry will be set later */ break; case LCD_TYPE_HANTRONIX: /* parallel mode, 8 bits, hantronix-like */ default: - if (lcd_proto < 0) + if (lcd_proto == NOT_SET) lcd_proto = LCD_PROTO_PARALLEL; - if (lcd_charset < 0) + if (lcd_charset == NOT_SET) lcd_charset = LCD_CHARSET_NORMAL; if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_STROBE; if (lcd_rs_pin == PIN_NOT_SET) lcd_rs_pin = PIN_SELECP; - if (lcd_width < 0) + if (lcd_width == NOT_SET) lcd_width = 16; - if (lcd_bwidth < 0) + if (lcd_bwidth == NOT_SET) lcd_bwidth = 40; - if (lcd_hwidth < 0) + if (lcd_hwidth == NOT_SET) lcd_hwidth = 64; - if (lcd_height < 0) + if (lcd_height == NOT_SET) lcd_height = 2; break; } @@ -1557,7 +1557,7 @@ static void lcd_init(void) if (lcd_da_pin == PIN_NOT_SET) lcd_da_pin = PIN_NONE; - if (lcd_charset < 0) + if (lcd_charset == NOT_SET) lcd_charset = DEFAULT_LCD_CHARSET; if (lcd_charset == LCD_CHARSET_KS0074) @@ -2227,58 +2227,58 @@ static struct parport_driver panel_driver = { static int __init panel_init_module(void) { /* for backwards compatibility */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = keypad_enabled; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = lcd_enabled; /* take care of an eventual profile */ switch (profile) { case PANEL_PROFILE_CUSTOM: /* custom profile */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = DEFAULT_KEYPAD_TYPE; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = DEFAULT_LCD_TYPE; break; case PANEL_PROFILE_OLD: /* 8 bits, 2*16, old keypad */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = KEYPAD_TYPE_OLD; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = LCD_TYPE_OLD; - if (lcd_width < 0) + if (lcd_width == NOT_SET) lcd_width = 16; - if (lcd_hwidth < 0) + if (lcd_hwidth == NOT_SET) lcd_hwidth = 16; break; case PANEL_PROFILE_NEW: /* serial, 2*16, new keypad */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = KEYPAD_TYPE_NEW; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = LCD_TYPE_KS0074; break; case PANEL_PROFILE_HANTRONIX: /* 8 bits, 2*16 hantronix-like, no keypad */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = KEYPAD_TYPE_NONE; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = LCD_TYPE_HANTRONIX; break; case PANEL_PROFILE_NEXCOM: /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = KEYPAD_TYPE_NEXCOM; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = LCD_TYPE_NEXCOM; break; case PANEL_PROFILE_LARGE: /* 8 bits, 2*40, old keypad */ - if (keypad_type < 0) + if (keypad_type == NOT_SET) keypad_type = KEYPAD_TYPE_OLD; - if (lcd_type < 0) + if (lcd_type == NOT_SET) lcd_type = LCD_TYPE_OLD; break; } -- cgit v1.2.3-59-g8ed1b From a8b2580b736746a4f978dfebf25be7f3f457bdd8 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:49 +0100 Subject: staging: panel: Start making module params read-only Start decoupling module params from the actual device state, both for lcd and keypad, by keeping the params read-only and moving the device state to related structs. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 52889905c924..7e5bb53c4a8a 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -212,6 +212,10 @@ static pmask_t phys_prev; static char inputs_stable; /* these variables are specific to the keypad */ +static struct { + bool enabled; +} keypad; + static char keypad_buffer[KEYPAD_BUFFER]; static int keypad_buflen; static int keypad_start; @@ -219,6 +223,9 @@ static char keypressed; static wait_queue_head_t keypad_read_wait; /* lcd-specific variables */ +static struct { + bool enabled; +} lcd; /* contains the LCD config state */ static unsigned long int lcd_flags; @@ -1393,7 +1400,7 @@ static void panel_lcd_print(const char *s) const char *tmp = s; int count = strlen(s); - if (lcd_enabled && lcd_initialized) { + if (lcd.enabled && lcd_initialized) { for (; count-- > 0; tmp++) { if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) /* let's be a little nice with other processes @@ -1923,7 +1930,7 @@ static void panel_process_inputs(void) static void panel_scan_timer(void) { - if (keypad_enabled && keypad_initialized) { + if (keypad.enabled && keypad_initialized) { if (spin_trylock_irq(&pprt_lock)) { phys_scan_contacts(); @@ -1935,7 +1942,7 @@ static void panel_scan_timer(void) panel_process_inputs(); } - if (lcd_enabled && lcd_initialized) { + if (lcd.enabled && lcd_initialized) { if (keypressed) { if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0)) lcd_backlight(1); @@ -2114,7 +2121,7 @@ static void keypad_init(void) static int panel_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { - if (lcd_enabled && lcd_initialized) { + if (lcd.enabled && lcd_initialized) { switch (code) { case SYS_DOWN: panel_lcd_print @@ -2170,13 +2177,13 @@ static void panel_attach(struct parport *port) /* must init LCD first, just in case an IRQ from the keypad is * generated at keypad init */ - if (lcd_enabled) { + if (lcd.enabled) { lcd_init(); if (misc_register(&lcd_dev)) goto err_unreg_device; } - if (keypad_enabled) { + if (keypad.enabled) { keypad_init(); if (misc_register(&keypad_dev)) goto err_lcd_unreg; @@ -2184,7 +2191,7 @@ static void panel_attach(struct parport *port) return; err_lcd_unreg: - if (lcd_enabled) + if (lcd.enabled) misc_deregister(&lcd_dev); err_unreg_device: parport_unregister_device(pprt); @@ -2202,12 +2209,12 @@ static void panel_detach(struct parport *port) return; } - if (keypad_enabled && keypad_initialized) { + if (keypad.enabled && keypad_initialized) { misc_deregister(&keypad_dev); keypad_initialized = 0; } - if (lcd_enabled && lcd_initialized) { + if (lcd.enabled && lcd_initialized) { misc_deregister(&lcd_dev); lcd_initialized = 0; } @@ -2283,8 +2290,8 @@ static int __init panel_init_module(void) break; } - lcd_enabled = (lcd_type > 0); - keypad_enabled = (keypad_type > 0); + lcd.enabled = (lcd_type > 0); + keypad.enabled = (keypad_type > 0); switch (keypad_type) { case KEYPAD_TYPE_OLD: @@ -2309,7 +2316,7 @@ static int __init panel_init_module(void) return -EIO; } - if (!lcd_enabled && !keypad_enabled) { + if (!lcd.enabled && !keypad.enabled) { /* no device enabled, let's release the parport */ if (pprt) { parport_release(pprt); @@ -2344,12 +2351,12 @@ static void __exit panel_cleanup_module(void) del_timer_sync(&scan_timer); if (pprt != NULL) { - if (keypad_enabled) { + if (keypad.enabled) { misc_deregister(&keypad_dev); keypad_initialized = 0; } - if (lcd_enabled) { + if (lcd.enabled) { panel_lcd_print("\x0cLCD driver " PANEL_VERSION "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-"); misc_deregister(&lcd_dev); -- cgit v1.2.3-59-g8ed1b From 87b8e0c88195cfc98c15e717af87034efba533f6 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:50 +0100 Subject: staging: panel: Make two more module params read-only Make keypad_type and lcd_type module params read-only. This step also starts making it more clear what is the precedence of device params coming from different sources (device profile, runtime module param values etc). Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 71 ++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 7e5bb53c4a8a..5868a2813b30 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -227,6 +227,9 @@ static struct { bool enabled; } lcd; +/* Needed only for init */ +static int selected_lcd_type = NOT_SET; + /* contains the LCD config state */ static unsigned long int lcd_flags; /* contains the LCD X offset */ @@ -1415,7 +1418,7 @@ static void panel_lcd_print(const char *s) /* initialize the LCD driver */ static void lcd_init(void) { - switch (lcd_type) { + switch (selected_lcd_type) { case LCD_TYPE_OLD: /* parallel mode, 8 bits */ if (lcd_proto == NOT_SET) @@ -2233,28 +2236,21 @@ static struct parport_driver panel_driver = { /* init function */ static int __init panel_init_module(void) { - /* for backwards compatibility */ - if (keypad_type == NOT_SET) - keypad_type = keypad_enabled; - - if (lcd_type == NOT_SET) - lcd_type = lcd_enabled; + int selected_keypad_type = NOT_SET; /* take care of an eventual profile */ switch (profile) { case PANEL_PROFILE_CUSTOM: /* custom profile */ - if (keypad_type == NOT_SET) - keypad_type = DEFAULT_KEYPAD_TYPE; - if (lcd_type == NOT_SET) - lcd_type = DEFAULT_LCD_TYPE; + selected_keypad_type = DEFAULT_KEYPAD_TYPE; + selected_lcd_type = DEFAULT_LCD_TYPE; break; case PANEL_PROFILE_OLD: /* 8 bits, 2*16, old keypad */ - if (keypad_type == NOT_SET) - keypad_type = KEYPAD_TYPE_OLD; - if (lcd_type == NOT_SET) - lcd_type = LCD_TYPE_OLD; + selected_keypad_type = KEYPAD_TYPE_OLD; + selected_lcd_type = LCD_TYPE_OLD; + + /* TODO: This two are a little hacky, sort it out later */ if (lcd_width == NOT_SET) lcd_width = 16; if (lcd_hwidth == NOT_SET) @@ -2262,38 +2258,45 @@ static int __init panel_init_module(void) break; case PANEL_PROFILE_NEW: /* serial, 2*16, new keypad */ - if (keypad_type == NOT_SET) - keypad_type = KEYPAD_TYPE_NEW; - if (lcd_type == NOT_SET) - lcd_type = LCD_TYPE_KS0074; + selected_keypad_type = KEYPAD_TYPE_NEW; + selected_lcd_type = LCD_TYPE_KS0074; break; case PANEL_PROFILE_HANTRONIX: /* 8 bits, 2*16 hantronix-like, no keypad */ - if (keypad_type == NOT_SET) - keypad_type = KEYPAD_TYPE_NONE; - if (lcd_type == NOT_SET) - lcd_type = LCD_TYPE_HANTRONIX; + selected_keypad_type = KEYPAD_TYPE_NONE; + selected_lcd_type = LCD_TYPE_HANTRONIX; break; case PANEL_PROFILE_NEXCOM: /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */ - if (keypad_type == NOT_SET) - keypad_type = KEYPAD_TYPE_NEXCOM; - if (lcd_type == NOT_SET) - lcd_type = LCD_TYPE_NEXCOM; + selected_keypad_type = KEYPAD_TYPE_NEXCOM; + selected_lcd_type = LCD_TYPE_NEXCOM; break; case PANEL_PROFILE_LARGE: /* 8 bits, 2*40, old keypad */ - if (keypad_type == NOT_SET) - keypad_type = KEYPAD_TYPE_OLD; - if (lcd_type == NOT_SET) - lcd_type = LCD_TYPE_OLD; + selected_keypad_type = KEYPAD_TYPE_OLD; + selected_lcd_type = LCD_TYPE_OLD; break; } - lcd.enabled = (lcd_type > 0); - keypad.enabled = (keypad_type > 0); + /* + * Overwrite selection with module param values (both keypad and lcd), + * where the deprecated params have lower prio. + */ + if (keypad_enabled > -1) + selected_keypad_type = keypad_enabled; + if (keypad_type > -1) + selected_keypad_type = keypad_type; + + keypad.enabled = (selected_keypad_type > 0); + + if (lcd_enabled > -1) + selected_lcd_type = lcd_enabled; + if (lcd_type > -1) + selected_lcd_type = lcd_type; + + lcd.enabled = (selected_lcd_type > 0); - switch (keypad_type) { + switch (selected_keypad_type) { case KEYPAD_TYPE_OLD: keypad_profile = old_keypad_profile; break; -- cgit v1.2.3-59-g8ed1b From 8037e2a3c00dca47ce08fca477394a6c7d82f992 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:51 +0100 Subject: staging: panel: Refactor LCD init code Rework lcd_init method to make it a little bit more clear about the precedence of the params, move LCD geometry and pins layout to the LCD struct and thus make the LCD-related module params effectively read-only. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 304 ++++++++++++++++++++++-------------------- 1 file changed, 163 insertions(+), 141 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 5868a2813b30..0bdb4470a4a8 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -225,6 +225,21 @@ static wait_queue_head_t keypad_read_wait; /* lcd-specific variables */ static struct { bool enabled; + int height; + int width; + int bwidth; + int hwidth; + int charset; + int proto; + /* TODO: use union here? */ + struct { + int e; + int rs; + int rw; + int cl; + int da; + int bl; + } pins; } lcd; /* Needed only for init */ @@ -766,7 +781,7 @@ static void lcd_send_serial(int byte) /* turn the backlight on or off */ static void lcd_backlight(int on) { - if (lcd_bl_pin == PIN_NONE) + if (lcd.pins.bl == PIN_NONE) return; /* The backlight is activated by setting the AUTOFEED line to +5V */ @@ -865,23 +880,23 @@ static void lcd_write_data_tilcd(int data) static void lcd_gotoxy(void) { lcd_write_cmd(0x80 /* set DDRAM address */ - | (lcd_addr_y ? lcd_hwidth : 0) + | (lcd_addr_y ? lcd.hwidth : 0) /* we force the cursor to stay at the end of the line if it wants to go farther */ - | ((lcd_addr_x < lcd_bwidth) ? lcd_addr_x & - (lcd_hwidth - 1) : lcd_bwidth - 1)); + | ((lcd_addr_x < lcd.bwidth) ? lcd_addr_x & + (lcd.hwidth - 1) : lcd.bwidth - 1)); } static void lcd_print(char c) { - if (lcd_addr_x < lcd_bwidth) { + if (lcd_addr_x < lcd.bwidth) { if (lcd_char_conv != NULL) c = lcd_char_conv[(unsigned char)c]; lcd_write_data(c); lcd_addr_x++; } /* prevents the cursor from wrapping onto the next line */ - if (lcd_addr_x == lcd_bwidth) + if (lcd_addr_x == lcd.bwidth) lcd_gotoxy(); } @@ -895,7 +910,7 @@ static void lcd_clear_fast_s(void) lcd_gotoxy(); spin_lock_irq(&pprt_lock); - for (pos = 0; pos < lcd_height * lcd_hwidth; pos++) { + for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) { lcd_send_serial(0x5F); /* R/W=W, RS=1 */ lcd_send_serial(' ' & 0x0F); lcd_send_serial((' ' >> 4) & 0x0F); @@ -918,7 +933,7 @@ static void lcd_clear_fast_p8(void) lcd_gotoxy(); spin_lock_irq(&pprt_lock); - for (pos = 0; pos < lcd_height * lcd_hwidth; pos++) { + for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) { /* present the data to the data port */ w_dtr(pprt, ' '); @@ -956,7 +971,7 @@ static void lcd_clear_fast_tilcd(void) lcd_gotoxy(); spin_lock_irq(&pprt_lock); - for (pos = 0; pos < lcd_height * lcd_hwidth; pos++) { + for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) { /* present the data to the data port */ w_dtr(pprt, ' '); udelay(60); @@ -981,7 +996,7 @@ static void lcd_clear_display(void) static void lcd_init_display(void) { - lcd_flags = ((lcd_height > 1) ? LCD_FLAG_N : 0) + lcd_flags = ((lcd.height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | LCD_FLAG_C | LCD_FLAG_B; long_sleep(20); /* wait 20 ms after power-up for the paranoid */ @@ -1095,17 +1110,17 @@ static inline int handle_lcd_special_code(void) case 'l': /* Shift Cursor Left */ if (lcd_addr_x > 0) { /* back one char if not at end of line */ - if (lcd_addr_x < lcd_bwidth) + if (lcd_addr_x < lcd.bwidth) lcd_write_cmd(0x10); lcd_addr_x--; } processed = 1; break; case 'r': /* shift cursor right */ - if (lcd_addr_x < lcd_width) { + if (lcd_addr_x < lcd.width) { /* allow the cursor to pass the end of the line */ if (lcd_addr_x < - (lcd_bwidth - 1)) + (lcd.bwidth - 1)) lcd_write_cmd(0x14); lcd_addr_x++; } @@ -1124,7 +1139,7 @@ static inline int handle_lcd_special_code(void) case 'k': { /* kill end of line */ int x; - for (x = lcd_addr_x; x < lcd_bwidth; x++) + for (x = lcd_addr_x; x < lcd.bwidth; x++) lcd_write_data(' '); /* restore cursor position */ @@ -1272,7 +1287,7 @@ static void lcd_write_char(char c) if (lcd_addr_x > 0) { /* check if we're not at the end of the line */ - if (lcd_addr_x < lcd_bwidth) + if (lcd_addr_x < lcd.bwidth) /* back one char */ lcd_write_cmd(0x10); lcd_addr_x--; @@ -1289,10 +1304,10 @@ static void lcd_write_char(char c) case '\n': /* flush the remainder of the current line and go to the beginning of the next line */ - for (; lcd_addr_x < lcd_bwidth; lcd_addr_x++) + for (; lcd_addr_x < lcd.bwidth; lcd_addr_x++) lcd_write_data(' '); lcd_addr_x = 0; - lcd_addr_y = (lcd_addr_y + 1) % lcd_height; + lcd_addr_y = (lcd_addr_y + 1) % lcd.height; lcd_gotoxy(); break; case '\r': @@ -1421,174 +1436,164 @@ static void lcd_init(void) switch (selected_lcd_type) { case LCD_TYPE_OLD: /* parallel mode, 8 bits */ - if (lcd_proto == NOT_SET) - lcd_proto = LCD_PROTO_PARALLEL; - if (lcd_charset == NOT_SET) - lcd_charset = LCD_CHARSET_NORMAL; - if (lcd_e_pin == PIN_NOT_SET) - lcd_e_pin = PIN_STROBE; - if (lcd_rs_pin == PIN_NOT_SET) - lcd_rs_pin = PIN_AUTOLF; - - if (lcd_width == NOT_SET) - lcd_width = 40; - if (lcd_bwidth == NOT_SET) - lcd_bwidth = 40; - if (lcd_hwidth == NOT_SET) - lcd_hwidth = 64; - if (lcd_height == NOT_SET) - lcd_height = 2; + lcd.proto = LCD_PROTO_PARALLEL; + lcd.charset = LCD_CHARSET_NORMAL; + lcd.pins.e = PIN_STROBE; + lcd.pins.rs = PIN_AUTOLF; + + lcd.width = 40; + lcd.bwidth = 40; + lcd.hwidth = 64; + lcd.height = 2; break; case LCD_TYPE_KS0074: /* serial mode, ks0074 */ - if (lcd_proto == NOT_SET) - lcd_proto = LCD_PROTO_SERIAL; - if (lcd_charset == NOT_SET) - lcd_charset = LCD_CHARSET_KS0074; - if (lcd_bl_pin == PIN_NOT_SET) - lcd_bl_pin = PIN_AUTOLF; - if (lcd_cl_pin == PIN_NOT_SET) - lcd_cl_pin = PIN_STROBE; - if (lcd_da_pin == PIN_NOT_SET) - lcd_da_pin = PIN_D0; - - if (lcd_width == NOT_SET) - lcd_width = 16; - if (lcd_bwidth == NOT_SET) - lcd_bwidth = 40; - if (lcd_hwidth == NOT_SET) - lcd_hwidth = 16; - if (lcd_height == NOT_SET) - lcd_height = 2; + lcd.proto = LCD_PROTO_SERIAL; + lcd.charset = LCD_CHARSET_KS0074; + lcd.pins.bl = PIN_AUTOLF; + lcd.pins.cl = PIN_STROBE; + lcd.pins.da = PIN_D0; + + lcd.width = 16; + lcd.bwidth = 40; + lcd.hwidth = 16; + lcd.height = 2; break; case LCD_TYPE_NEXCOM: /* parallel mode, 8 bits, generic */ - if (lcd_proto == NOT_SET) - lcd_proto = LCD_PROTO_PARALLEL; - if (lcd_charset == NOT_SET) - lcd_charset = LCD_CHARSET_NORMAL; - if (lcd_e_pin == PIN_NOT_SET) - lcd_e_pin = PIN_AUTOLF; - if (lcd_rs_pin == PIN_NOT_SET) - lcd_rs_pin = PIN_SELECP; - if (lcd_rw_pin == PIN_NOT_SET) - lcd_rw_pin = PIN_INITP; - - if (lcd_width == NOT_SET) - lcd_width = 16; - if (lcd_bwidth == NOT_SET) - lcd_bwidth = 40; - if (lcd_hwidth == NOT_SET) - lcd_hwidth = 64; - if (lcd_height == NOT_SET) - lcd_height = 2; + lcd.proto = LCD_PROTO_PARALLEL; + lcd.charset = LCD_CHARSET_NORMAL; + lcd.pins.e = PIN_AUTOLF; + lcd.pins.rs = PIN_SELECP; + lcd.pins.rw = PIN_INITP; + + lcd.width = 16; + lcd.bwidth = 40; + lcd.hwidth = 64; + lcd.height = 2; break; case LCD_TYPE_CUSTOM: /* customer-defined */ - if (lcd_proto == NOT_SET) - lcd_proto = DEFAULT_LCD_PROTO; - if (lcd_charset == NOT_SET) - lcd_charset = DEFAULT_LCD_CHARSET; + lcd.proto = DEFAULT_LCD_PROTO; + lcd.charset = DEFAULT_LCD_CHARSET; /* default geometry will be set later */ break; case LCD_TYPE_HANTRONIX: /* parallel mode, 8 bits, hantronix-like */ default: - if (lcd_proto == NOT_SET) - lcd_proto = LCD_PROTO_PARALLEL; - if (lcd_charset == NOT_SET) - lcd_charset = LCD_CHARSET_NORMAL; - if (lcd_e_pin == PIN_NOT_SET) - lcd_e_pin = PIN_STROBE; - if (lcd_rs_pin == PIN_NOT_SET) - lcd_rs_pin = PIN_SELECP; - - if (lcd_width == NOT_SET) - lcd_width = 16; - if (lcd_bwidth == NOT_SET) - lcd_bwidth = 40; - if (lcd_hwidth == NOT_SET) - lcd_hwidth = 64; - if (lcd_height == NOT_SET) - lcd_height = 2; + lcd.proto = LCD_PROTO_PARALLEL; + lcd.charset = LCD_CHARSET_NORMAL; + lcd.pins.e = PIN_STROBE; + lcd.pins.rs = PIN_SELECP; + + lcd.width = 16; + lcd.bwidth = 40; + lcd.hwidth = 64; + lcd.height = 2; break; } + /* Overwrite with module params set on loading */ + if (lcd_height > -1) + lcd.height = lcd_height; + if (lcd_width > -1) + lcd.width = lcd_width; + if (lcd_bwidth > -1) + lcd.bwidth = lcd_bwidth; + if (lcd_hwidth > -1) + lcd.hwidth = lcd_hwidth; + if (lcd_charset > -1) + lcd.charset = lcd_charset; + if (lcd_proto > -1) + lcd.proto = lcd_proto; + if (lcd_e_pin != PIN_NOT_SET) + lcd.pins.e = lcd_e_pin; + if (lcd_rs_pin != PIN_NOT_SET) + lcd.pins.rs = lcd_rs_pin; + if (lcd_rw_pin != PIN_NOT_SET) + lcd.pins.rw = lcd_rw_pin; + if (lcd_cl_pin != PIN_NOT_SET) + lcd.pins.cl = lcd_cl_pin; + if (lcd_da_pin != PIN_NOT_SET) + lcd.pins.da = lcd_da_pin; + if (lcd_bl_pin != PIN_NOT_SET) + lcd.pins.bl = lcd_bl_pin; + /* this is used to catch wrong and default values */ - if (lcd_width <= 0) - lcd_width = DEFAULT_LCD_WIDTH; - if (lcd_bwidth <= 0) - lcd_bwidth = DEFAULT_LCD_BWIDTH; - if (lcd_hwidth <= 0) - lcd_hwidth = DEFAULT_LCD_HWIDTH; - if (lcd_height <= 0) - lcd_height = DEFAULT_LCD_HEIGHT; - - if (lcd_proto == LCD_PROTO_SERIAL) { /* SERIAL */ + if (lcd.width <= 0) + lcd.width = DEFAULT_LCD_WIDTH; + if (lcd.bwidth <= 0) + lcd.bwidth = DEFAULT_LCD_BWIDTH; + if (lcd.hwidth <= 0) + lcd.hwidth = DEFAULT_LCD_HWIDTH; + if (lcd.height <= 0) + lcd.height = DEFAULT_LCD_HEIGHT; + + if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */ lcd_write_cmd = lcd_write_cmd_s; lcd_write_data = lcd_write_data_s; lcd_clear_fast = lcd_clear_fast_s; - if (lcd_cl_pin == PIN_NOT_SET) - lcd_cl_pin = DEFAULT_LCD_PIN_SCL; - if (lcd_da_pin == PIN_NOT_SET) - lcd_da_pin = DEFAULT_LCD_PIN_SDA; + if (lcd.pins.cl == PIN_NOT_SET) + lcd.pins.cl = DEFAULT_LCD_PIN_SCL; + if (lcd.pins.da == PIN_NOT_SET) + lcd.pins.da = DEFAULT_LCD_PIN_SDA; - } else if (lcd_proto == LCD_PROTO_PARALLEL) { /* PARALLEL */ + } else if (lcd.proto == LCD_PROTO_PARALLEL) { /* PARALLEL */ lcd_write_cmd = lcd_write_cmd_p8; lcd_write_data = lcd_write_data_p8; lcd_clear_fast = lcd_clear_fast_p8; - if (lcd_e_pin == PIN_NOT_SET) - lcd_e_pin = DEFAULT_LCD_PIN_E; - if (lcd_rs_pin == PIN_NOT_SET) - lcd_rs_pin = DEFAULT_LCD_PIN_RS; - if (lcd_rw_pin == PIN_NOT_SET) - lcd_rw_pin = DEFAULT_LCD_PIN_RW; + if (lcd.pins.e == PIN_NOT_SET) + lcd.pins.e = DEFAULT_LCD_PIN_E; + if (lcd.pins.rs == PIN_NOT_SET) + lcd.pins.rs = DEFAULT_LCD_PIN_RS; + if (lcd.pins.rw == PIN_NOT_SET) + lcd.pins.rw = DEFAULT_LCD_PIN_RW; } else { lcd_write_cmd = lcd_write_cmd_tilcd; lcd_write_data = lcd_write_data_tilcd; lcd_clear_fast = lcd_clear_fast_tilcd; } - if (lcd_bl_pin == PIN_NOT_SET) - lcd_bl_pin = DEFAULT_LCD_PIN_BL; - - if (lcd_e_pin == PIN_NOT_SET) - lcd_e_pin = PIN_NONE; - if (lcd_rs_pin == PIN_NOT_SET) - lcd_rs_pin = PIN_NONE; - if (lcd_rw_pin == PIN_NOT_SET) - lcd_rw_pin = PIN_NONE; - if (lcd_bl_pin == PIN_NOT_SET) - lcd_bl_pin = PIN_NONE; - if (lcd_cl_pin == PIN_NOT_SET) - lcd_cl_pin = PIN_NONE; - if (lcd_da_pin == PIN_NOT_SET) - lcd_da_pin = PIN_NONE; - - if (lcd_charset == NOT_SET) - lcd_charset = DEFAULT_LCD_CHARSET; - - if (lcd_charset == LCD_CHARSET_KS0074) + if (lcd.pins.bl == PIN_NOT_SET) + lcd.pins.bl = DEFAULT_LCD_PIN_BL; + + if (lcd.pins.e == PIN_NOT_SET) + lcd.pins.e = PIN_NONE; + if (lcd.pins.rs == PIN_NOT_SET) + lcd.pins.rs = PIN_NONE; + if (lcd.pins.rw == PIN_NOT_SET) + lcd.pins.rw = PIN_NONE; + if (lcd.pins.bl == PIN_NOT_SET) + lcd.pins.bl = PIN_NONE; + if (lcd.pins.cl == PIN_NOT_SET) + lcd.pins.cl = PIN_NONE; + if (lcd.pins.da == PIN_NOT_SET) + lcd.pins.da = PIN_NONE; + + if (lcd.charset == NOT_SET) + lcd.charset = DEFAULT_LCD_CHARSET; + + if (lcd.charset == LCD_CHARSET_KS0074) lcd_char_conv = lcd_char_conv_ks0074; else lcd_char_conv = NULL; - if (lcd_bl_pin != PIN_NONE) + if (lcd.pins.bl != PIN_NONE) init_scan_timer(); - pin_to_bits(lcd_e_pin, lcd_bits[LCD_PORT_D][LCD_BIT_E], + pin_to_bits(lcd.pins.e, lcd_bits[LCD_PORT_D][LCD_BIT_E], lcd_bits[LCD_PORT_C][LCD_BIT_E]); - pin_to_bits(lcd_rs_pin, lcd_bits[LCD_PORT_D][LCD_BIT_RS], + pin_to_bits(lcd.pins.rs, lcd_bits[LCD_PORT_D][LCD_BIT_RS], lcd_bits[LCD_PORT_C][LCD_BIT_RS]); - pin_to_bits(lcd_rw_pin, lcd_bits[LCD_PORT_D][LCD_BIT_RW], + pin_to_bits(lcd.pins.rw, lcd_bits[LCD_PORT_D][LCD_BIT_RW], lcd_bits[LCD_PORT_C][LCD_BIT_RW]); - pin_to_bits(lcd_bl_pin, lcd_bits[LCD_PORT_D][LCD_BIT_BL], + pin_to_bits(lcd.pins.bl, lcd_bits[LCD_PORT_D][LCD_BIT_BL], lcd_bits[LCD_PORT_C][LCD_BIT_BL]); - pin_to_bits(lcd_cl_pin, lcd_bits[LCD_PORT_D][LCD_BIT_CL], + pin_to_bits(lcd.pins.cl, lcd_bits[LCD_PORT_D][LCD_BIT_CL], lcd_bits[LCD_PORT_C][LCD_BIT_CL]); - pin_to_bits(lcd_da_pin, lcd_bits[LCD_PORT_D][LCD_BIT_DA], + pin_to_bits(lcd.pins.da, lcd_bits[LCD_PORT_D][LCD_BIT_DA], lcd_bits[LCD_PORT_C][LCD_BIT_DA]); /* before this line, we must NOT send anything to the display. @@ -2278,6 +2283,23 @@ static int __init panel_init_module(void) break; } + /* + * Init lcd struct with load-time values to preserve exact current + * functionality (at least for now). + */ + lcd.height = lcd_height; + lcd.width = lcd_width; + lcd.bwidth = lcd_bwidth; + lcd.hwidth = lcd_hwidth; + lcd.charset = lcd_charset; + lcd.proto = lcd_proto; + lcd.pins.e = lcd_e_pin; + lcd.pins.rs = lcd_rs_pin; + lcd.pins.rw = lcd_rw_pin; + lcd.pins.cl = lcd_cl_pin; + lcd.pins.da = lcd_da_pin; + lcd.pins.bl = lcd_bl_pin; + /* * Overwrite selection with module param values (both keypad and lcd), * where the deprecated params have lower prio. -- cgit v1.2.3-59-g8ed1b From 1a4b2e3e6c65655cf1319de5f486c062cd5379da Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:52 +0100 Subject: staging: panel: Remove more magic number comparison Use a defined value instead of magic number comparison for checking whether a module param value has been set. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 0bdb4470a4a8..19f6767731e9 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1494,17 +1494,17 @@ static void lcd_init(void) } /* Overwrite with module params set on loading */ - if (lcd_height > -1) + if (lcd_height != NOT_SET) lcd.height = lcd_height; - if (lcd_width > -1) + if (lcd_width != NOT_SET) lcd.width = lcd_width; - if (lcd_bwidth > -1) + if (lcd_bwidth != NOT_SET) lcd.bwidth = lcd_bwidth; - if (lcd_hwidth > -1) + if (lcd_hwidth != NOT_SET) lcd.hwidth = lcd_hwidth; - if (lcd_charset > -1) + if (lcd_charset != NOT_SET) lcd.charset = lcd_charset; - if (lcd_proto > -1) + if (lcd_proto != NOT_SET) lcd.proto = lcd_proto; if (lcd_e_pin != PIN_NOT_SET) lcd.pins.e = lcd_e_pin; @@ -2304,16 +2304,16 @@ static int __init panel_init_module(void) * Overwrite selection with module param values (both keypad and lcd), * where the deprecated params have lower prio. */ - if (keypad_enabled > -1) + if (keypad_enabled != NOT_SET) selected_keypad_type = keypad_enabled; - if (keypad_type > -1) + if (keypad_type != NOT_SET) selected_keypad_type = keypad_type; keypad.enabled = (selected_keypad_type > 0); - if (lcd_enabled > -1) + if (lcd_enabled != NOT_SET) selected_lcd_type = lcd_enabled; - if (lcd_type > -1) + if (lcd_type != NOT_SET) selected_lcd_type = lcd_type; lcd.enabled = (selected_lcd_type > 0); -- cgit v1.2.3-59-g8ed1b From 6d8b588c32243a3b6dc63b0153a30f7c17bb2689 Mon Sep 17 00:00:00 2001 From: Mariusz Gorski Date: Thu, 27 Nov 2014 22:36:53 +0100 Subject: staging: panel: Move LCD-related state into struct lcd Move more or less all LCD-related state into struct lcd in order to get better cohesion; use bool instead of int where it makes sense. Signed-off-by: Mariusz Gorski Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 255 ++++++++++++++++++++++-------------------- 1 file changed, 134 insertions(+), 121 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 19f6767731e9..98325b7b4462 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -225,12 +225,20 @@ static wait_queue_head_t keypad_read_wait; /* lcd-specific variables */ static struct { bool enabled; + bool initialized; + bool must_clear; + + /* TODO: use bool here? */ + char left_shift; + int height; int width; int bwidth; int hwidth; int charset; int proto; + int light_tempo; + /* TODO: use union here? */ struct { int e; @@ -240,22 +248,26 @@ static struct { int da; int bl; } pins; + + /* contains the LCD config state */ + unsigned long int flags; + + /* Contains the LCD X and Y offset */ + struct { + unsigned long int x; + unsigned long int y; + } addr; + + /* Current escape sequence and it's length or -1 if outside */ + struct { + char buf[LCD_ESCAPE_LEN + 1]; + int len; + } esc_seq; } lcd; /* Needed only for init */ static int selected_lcd_type = NOT_SET; -/* contains the LCD config state */ -static unsigned long int lcd_flags; -/* contains the LCD X offset */ -static unsigned long int lcd_addr_x; -/* contains the LCD Y offset */ -static unsigned long int lcd_addr_y; -/* current escape sequence, 0 terminated */ -static char lcd_escape[LCD_ESCAPE_LEN + 1]; -/* not in escape state. >=0 = escape cmd len */ -static int lcd_escape_len = -1; - /* * Bit masks to convert LCD signals to parallel port outputs. * _d_ are values for data port, _c_ are for control port. @@ -438,13 +450,8 @@ static atomic_t keypad_available = ATOMIC_INIT(1); static struct pardevice *pprt; -static int lcd_initialized; static int keypad_initialized; -static int light_tempo; - -static char lcd_must_clear; -static char lcd_left_shift; static char init_in_progress; static void (*lcd_write_cmd)(int); @@ -880,23 +887,23 @@ static void lcd_write_data_tilcd(int data) static void lcd_gotoxy(void) { lcd_write_cmd(0x80 /* set DDRAM address */ - | (lcd_addr_y ? lcd.hwidth : 0) + | (lcd.addr.y ? lcd.hwidth : 0) /* we force the cursor to stay at the end of the line if it wants to go farther */ - | ((lcd_addr_x < lcd.bwidth) ? lcd_addr_x & + | ((lcd.addr.x < lcd.bwidth) ? lcd.addr.x & (lcd.hwidth - 1) : lcd.bwidth - 1)); } static void lcd_print(char c) { - if (lcd_addr_x < lcd.bwidth) { + if (lcd.addr.x < lcd.bwidth) { if (lcd_char_conv != NULL) c = lcd_char_conv[(unsigned char)c]; lcd_write_data(c); - lcd_addr_x++; + lcd.addr.x++; } /* prevents the cursor from wrapping onto the next line */ - if (lcd_addr_x == lcd.bwidth) + if (lcd.addr.x == lcd.bwidth) lcd_gotoxy(); } @@ -905,8 +912,8 @@ static void lcd_clear_fast_s(void) { int pos; - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); spin_lock_irq(&pprt_lock); @@ -918,8 +925,8 @@ static void lcd_clear_fast_s(void) } spin_unlock_irq(&pprt_lock); - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); } @@ -928,8 +935,8 @@ static void lcd_clear_fast_p8(void) { int pos; - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); spin_lock_irq(&pprt_lock); @@ -956,8 +963,8 @@ static void lcd_clear_fast_p8(void) } spin_unlock_irq(&pprt_lock); - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); } @@ -966,8 +973,8 @@ static void lcd_clear_fast_tilcd(void) { int pos; - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); spin_lock_irq(&pprt_lock); @@ -979,8 +986,8 @@ static void lcd_clear_fast_tilcd(void) spin_unlock_irq(&pprt_lock); - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); } @@ -988,15 +995,15 @@ static void lcd_clear_fast_tilcd(void) static void lcd_clear_display(void) { lcd_write_cmd(0x01); /* clear display */ - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; /* we must wait a few milliseconds (15) */ long_sleep(15); } static void lcd_init_display(void) { - lcd_flags = ((lcd.height > 1) ? LCD_FLAG_N : 0) + lcd.flags = ((lcd.height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | LCD_FLAG_C | LCD_FLAG_B; long_sleep(20); /* wait 20 ms after power-up for the paranoid */ @@ -1009,8 +1016,8 @@ static void lcd_init_display(void) long_sleep(10); lcd_write_cmd(0x30 /* set font height and lines number */ - | ((lcd_flags & LCD_FLAG_F) ? 4 : 0) - | ((lcd_flags & LCD_FLAG_N) ? 8 : 0) + | ((lcd.flags & LCD_FLAG_F) ? 4 : 0) + | ((lcd.flags & LCD_FLAG_N) ? 8 : 0) ); long_sleep(10); @@ -1018,12 +1025,12 @@ static void lcd_init_display(void) long_sleep(10); lcd_write_cmd(0x08 /* set display mode */ - | ((lcd_flags & LCD_FLAG_D) ? 4 : 0) - | ((lcd_flags & LCD_FLAG_C) ? 2 : 0) - | ((lcd_flags & LCD_FLAG_B) ? 1 : 0) + | ((lcd.flags & LCD_FLAG_D) ? 4 : 0) + | ((lcd.flags & LCD_FLAG_C) ? 2 : 0) + | ((lcd.flags & LCD_FLAG_B) ? 1 : 0) ); - lcd_backlight((lcd_flags & LCD_FLAG_L) ? 1 : 0); + lcd_backlight((lcd.flags & LCD_FLAG_L) ? 1 : 0); long_sleep(10); @@ -1046,100 +1053,101 @@ static inline int handle_lcd_special_code(void) int processed = 0; - char *esc = lcd_escape + 2; - int oldflags = lcd_flags; + char *esc = lcd.esc_seq.buf + 2; + int oldflags = lcd.flags; /* check for display mode flags */ switch (*esc) { case 'D': /* Display ON */ - lcd_flags |= LCD_FLAG_D; + lcd.flags |= LCD_FLAG_D; processed = 1; break; case 'd': /* Display OFF */ - lcd_flags &= ~LCD_FLAG_D; + lcd.flags &= ~LCD_FLAG_D; processed = 1; break; case 'C': /* Cursor ON */ - lcd_flags |= LCD_FLAG_C; + lcd.flags |= LCD_FLAG_C; processed = 1; break; case 'c': /* Cursor OFF */ - lcd_flags &= ~LCD_FLAG_C; + lcd.flags &= ~LCD_FLAG_C; processed = 1; break; case 'B': /* Blink ON */ - lcd_flags |= LCD_FLAG_B; + lcd.flags |= LCD_FLAG_B; processed = 1; break; case 'b': /* Blink OFF */ - lcd_flags &= ~LCD_FLAG_B; + lcd.flags &= ~LCD_FLAG_B; processed = 1; break; case '+': /* Back light ON */ - lcd_flags |= LCD_FLAG_L; + lcd.flags |= LCD_FLAG_L; processed = 1; break; case '-': /* Back light OFF */ - lcd_flags &= ~LCD_FLAG_L; + lcd.flags &= ~LCD_FLAG_L; processed = 1; break; case '*': /* flash back light using the keypad timer */ if (scan_timer.function != NULL) { - if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0)) + if (lcd.light_tempo == 0 + && ((lcd.flags & LCD_FLAG_L) == 0)) lcd_backlight(1); - light_tempo = FLASH_LIGHT_TEMPO; + lcd.light_tempo = FLASH_LIGHT_TEMPO; } processed = 1; break; case 'f': /* Small Font */ - lcd_flags &= ~LCD_FLAG_F; + lcd.flags &= ~LCD_FLAG_F; processed = 1; break; case 'F': /* Large Font */ - lcd_flags |= LCD_FLAG_F; + lcd.flags |= LCD_FLAG_F; processed = 1; break; case 'n': /* One Line */ - lcd_flags &= ~LCD_FLAG_N; + lcd.flags &= ~LCD_FLAG_N; processed = 1; break; case 'N': /* Two Lines */ - lcd_flags |= LCD_FLAG_N; + lcd.flags |= LCD_FLAG_N; break; case 'l': /* Shift Cursor Left */ - if (lcd_addr_x > 0) { + if (lcd.addr.x > 0) { /* back one char if not at end of line */ - if (lcd_addr_x < lcd.bwidth) + if (lcd.addr.x < lcd.bwidth) lcd_write_cmd(0x10); - lcd_addr_x--; + lcd.addr.x--; } processed = 1; break; case 'r': /* shift cursor right */ - if (lcd_addr_x < lcd.width) { + if (lcd.addr.x < lcd.width) { /* allow the cursor to pass the end of the line */ - if (lcd_addr_x < + if (lcd.addr.x < (lcd.bwidth - 1)) lcd_write_cmd(0x14); - lcd_addr_x++; + lcd.addr.x++; } processed = 1; break; case 'L': /* shift display left */ - lcd_left_shift++; + lcd.left_shift++; lcd_write_cmd(0x18); processed = 1; break; case 'R': /* shift display right */ - lcd_left_shift--; + lcd.left_shift--; lcd_write_cmd(0x1C); processed = 1; break; case 'k': { /* kill end of line */ int x; - for (x = lcd_addr_x; x < lcd.bwidth; x++) + for (x = lcd.addr.x; x < lcd.bwidth; x++) lcd_write_data(' '); /* restore cursor position */ @@ -1149,7 +1157,7 @@ static inline int handle_lcd_special_code(void) } case 'I': /* reinitialize display */ lcd_init_display(); - lcd_left_shift = 0; + lcd.left_shift = 0; processed = 1; break; case 'G': { @@ -1220,11 +1228,11 @@ static inline int handle_lcd_special_code(void) while (*esc) { if (*esc == 'x') { esc++; - if (kstrtoul(esc, 10, &lcd_addr_x) < 0) + if (kstrtoul(esc, 10, &lcd.addr.x) < 0) break; } else if (*esc == 'y') { esc++; - if (kstrtoul(esc, 10, &lcd_addr_y) < 0) + if (kstrtoul(esc, 10, &lcd.addr.y) < 0) break; } else { break; @@ -1237,25 +1245,25 @@ static inline int handle_lcd_special_code(void) } /* Check whether one flag was changed */ - if (oldflags != lcd_flags) { + if (oldflags != lcd.flags) { /* check whether one of B,C,D flags were changed */ - if ((oldflags ^ lcd_flags) & + if ((oldflags ^ lcd.flags) & (LCD_FLAG_B | LCD_FLAG_C | LCD_FLAG_D)) /* set display mode */ lcd_write_cmd(0x08 - | ((lcd_flags & LCD_FLAG_D) ? 4 : 0) - | ((lcd_flags & LCD_FLAG_C) ? 2 : 0) - | ((lcd_flags & LCD_FLAG_B) ? 1 : 0)); + | ((lcd.flags & LCD_FLAG_D) ? 4 : 0) + | ((lcd.flags & LCD_FLAG_C) ? 2 : 0) + | ((lcd.flags & LCD_FLAG_B) ? 1 : 0)); /* check whether one of F,N flags was changed */ - else if ((oldflags ^ lcd_flags) & (LCD_FLAG_F | LCD_FLAG_N)) + else if ((oldflags ^ lcd.flags) & (LCD_FLAG_F | LCD_FLAG_N)) lcd_write_cmd(0x30 - | ((lcd_flags & LCD_FLAG_F) ? 4 : 0) - | ((lcd_flags & LCD_FLAG_N) ? 8 : 0)); + | ((lcd.flags & LCD_FLAG_F) ? 4 : 0) + | ((lcd.flags & LCD_FLAG_N) ? 8 : 0)); /* check whether L flag was changed */ - else if ((oldflags ^ lcd_flags) & (LCD_FLAG_L)) { - if (lcd_flags & (LCD_FLAG_L)) + else if ((oldflags ^ lcd.flags) & (LCD_FLAG_L)) { + if (lcd.flags & (LCD_FLAG_L)) lcd_backlight(1); - else if (light_tempo == 0) + else if (lcd.light_tempo == 0) /* switch off the light only when the tempo lighting is gone */ lcd_backlight(0); @@ -1268,29 +1276,29 @@ static inline int handle_lcd_special_code(void) static void lcd_write_char(char c) { /* first, we'll test if we're in escape mode */ - if ((c != '\n') && lcd_escape_len >= 0) { + if ((c != '\n') && lcd.esc_seq.len >= 0) { /* yes, let's add this char to the buffer */ - lcd_escape[lcd_escape_len++] = c; - lcd_escape[lcd_escape_len] = 0; + lcd.esc_seq.buf[lcd.esc_seq.len++] = c; + lcd.esc_seq.buf[lcd.esc_seq.len] = 0; } else { /* aborts any previous escape sequence */ - lcd_escape_len = -1; + lcd.esc_seq.len = -1; switch (c) { case LCD_ESCAPE_CHAR: /* start of an escape sequence */ - lcd_escape_len = 0; - lcd_escape[lcd_escape_len] = 0; + lcd.esc_seq.len = 0; + lcd.esc_seq.buf[lcd.esc_seq.len] = 0; break; case '\b': /* go back one char and clear it */ - if (lcd_addr_x > 0) { + if (lcd.addr.x > 0) { /* check if we're not at the end of the line */ - if (lcd_addr_x < lcd.bwidth) + if (lcd.addr.x < lcd.bwidth) /* back one char */ lcd_write_cmd(0x10); - lcd_addr_x--; + lcd.addr.x--; } /* replace with a space */ lcd_write_data(' '); @@ -1304,15 +1312,15 @@ static void lcd_write_char(char c) case '\n': /* flush the remainder of the current line and go to the beginning of the next line */ - for (; lcd_addr_x < lcd.bwidth; lcd_addr_x++) + for (; lcd.addr.x < lcd.bwidth; lcd.addr.x++) lcd_write_data(' '); - lcd_addr_x = 0; - lcd_addr_y = (lcd_addr_y + 1) % lcd.height; + lcd.addr.x = 0; + lcd.addr.y = (lcd.addr.y + 1) % lcd.height; lcd_gotoxy(); break; case '\r': /* go to the beginning of the same line */ - lcd_addr_x = 0; + lcd.addr.x = 0; lcd_gotoxy(); break; case '\t': @@ -1328,32 +1336,32 @@ static void lcd_write_char(char c) /* now we'll see if we're in an escape mode and if the current escape sequence can be understood. */ - if (lcd_escape_len >= 2) { + if (lcd.esc_seq.len >= 2) { int processed = 0; - if (!strcmp(lcd_escape, "[2J")) { + if (!strcmp(lcd.esc_seq.buf, "[2J")) { /* clear the display */ lcd_clear_fast(); processed = 1; - } else if (!strcmp(lcd_escape, "[H")) { + } else if (!strcmp(lcd.esc_seq.buf, "[H")) { /* cursor to home */ - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; lcd_gotoxy(); processed = 1; } /* codes starting with ^[[L */ - else if ((lcd_escape_len >= 3) && - (lcd_escape[0] == '[') && - (lcd_escape[1] == 'L')) { + else if ((lcd.esc_seq.len >= 3) && + (lcd.esc_seq.buf[0] == '[') && + (lcd.esc_seq.buf[1] == 'L')) { processed = handle_lcd_special_code(); } /* LCD special escape codes */ /* flush the escape sequence if it's been processed or if it is getting too long. */ - if (processed || (lcd_escape_len >= LCD_ESCAPE_LEN)) - lcd_escape_len = -1; + if (processed || (lcd.esc_seq.len >= LCD_ESCAPE_LEN)) + lcd.esc_seq.len = -1; } /* escape codes */ } @@ -1386,9 +1394,9 @@ static int lcd_open(struct inode *inode, struct file *file) if (file->f_mode & FMODE_READ) /* device is write-only */ return -EPERM; - if (lcd_must_clear) { + if (lcd.must_clear) { lcd_clear_display(); - lcd_must_clear = 0; + lcd.must_clear = false; } return nonseekable_open(inode, file); } @@ -1418,7 +1426,7 @@ static void panel_lcd_print(const char *s) const char *tmp = s; int count = strlen(s); - if (lcd.enabled && lcd_initialized) { + if (lcd.enabled && lcd.initialized) { for (; count-- > 0; tmp++) { if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) /* let's be a little nice with other processes @@ -1599,7 +1607,7 @@ static void lcd_init(void) /* before this line, we must NOT send anything to the display. * Since lcd_init_display() needs to write data, we have to * enable mark the LCD initialized just before. */ - lcd_initialized = 1; + lcd.initialized = true; lcd_init_display(); /* display a short message */ @@ -1611,10 +1619,10 @@ static void lcd_init(void) panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE "\nPanel-" PANEL_VERSION); #endif - lcd_addr_x = 0; - lcd_addr_y = 0; + lcd.addr.x = 0; + lcd.addr.y = 0; /* clear the display on the next device opening */ - lcd_must_clear = 1; + lcd.must_clear = true; lcd_gotoxy(); } @@ -1950,14 +1958,16 @@ static void panel_scan_timer(void) panel_process_inputs(); } - if (lcd.enabled && lcd_initialized) { + if (lcd.enabled && lcd.initialized) { if (keypressed) { - if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0)) + if (lcd.light_tempo == 0 + && ((lcd.flags & LCD_FLAG_L) == 0)) lcd_backlight(1); - light_tempo = FLASH_LIGHT_TEMPO; - } else if (light_tempo > 0) { - light_tempo--; - if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0)) + lcd.light_tempo = FLASH_LIGHT_TEMPO; + } else if (lcd.light_tempo > 0) { + lcd.light_tempo--; + if (lcd.light_tempo == 0 + && ((lcd.flags & LCD_FLAG_L) == 0)) lcd_backlight(0); } } @@ -2129,7 +2139,7 @@ static void keypad_init(void) static int panel_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { - if (lcd.enabled && lcd_initialized) { + if (lcd.enabled && lcd.initialized) { switch (code) { case SYS_DOWN: panel_lcd_print @@ -2222,9 +2232,9 @@ static void panel_detach(struct parport *port) keypad_initialized = 0; } - if (lcd.enabled && lcd_initialized) { + if (lcd.enabled && lcd.initialized) { misc_deregister(&lcd_dev); - lcd_initialized = 0; + lcd.initialized = false; } parport_release(pprt); @@ -2300,6 +2310,9 @@ static int __init panel_init_module(void) lcd.pins.da = lcd_da_pin; lcd.pins.bl = lcd_bl_pin; + /* Leave it for now, just in case */ + lcd.esc_seq.len = -1; + /* * Overwrite selection with module param values (both keypad and lcd), * where the deprecated params have lower prio. @@ -2385,7 +2398,7 @@ static void __exit panel_cleanup_module(void) panel_lcd_print("\x0cLCD driver " PANEL_VERSION "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-"); misc_deregister(&lcd_dev); - lcd_initialized = 0; + lcd.initialized = false; } /* TODO: free all input signals */ -- cgit v1.2.3-59-g8ed1b From da4f18ed3b4bf9ff204391a7895b26095426ddd1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 29 Nov 2014 00:01:58 +0000 Subject: staging: vt6655: remove duplicate MACvSetPacketFilter Packet filtering is already done in vnt_configure. A call to MACvSetPacketFilter is not necessary in MACvInitialize as this will be done by vnt_configure when interface is up. Also remove macros associated with this function. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 66 -------------------------------------------- drivers/staging/vt6655/mac.h | 13 --------- 2 files changed, 79 deletions(-) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index af966065a243..8f0d652fea7c 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -33,7 +33,6 @@ * MACvGetShortRetryLimit - Get 802.11 Short Retry limit * MACvSetLongRetryLimit - Set 802.11 Long Retry limit * MACvSetLoopbackMode - Set MAC Loopback Mode - * MACvSetPacketFilter - Set MAC Address Filter * MACvSaveContext - Save Context of MAC Registers * MACvRestoreContext - Restore Context of MAC Registers * MACbSoftwareReset - Software Reset MAC @@ -213,66 +212,6 @@ void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode) VNSvOutPortB(dwIoBase + MAC_REG_TEST, byOrgValue); } -/* - * Description: - * Set MAC Address filter - * - * Parameters: - * In: - * dwIoBase - Base Address for MAC - * wFilterType - Filter Type - * Out: - * none - * - * Return Value: none - * - */ -void MACvSetPacketFilter(void __iomem *dwIoBase, unsigned short wFilterType) -{ - unsigned char byOldRCR; - unsigned char byNewRCR = 0; - - // if only in DIRECTED mode, multicast-address will set to zero, - // but if other mode exist (e.g. PROMISCUOUS), multicast-address - // will be open - if (wFilterType & PKT_TYPE_DIRECTED) { - // set multicast address to accept none - MACvSelectPage1(dwIoBase); - VNSvOutPortD(dwIoBase + MAC_REG_MAR0, 0L); - VNSvOutPortD(dwIoBase + MAC_REG_MAR0 + sizeof(unsigned long), 0L); - MACvSelectPage0(dwIoBase); - } - - if (wFilterType & (PKT_TYPE_PROMISCUOUS | PKT_TYPE_ALL_MULTICAST)) { - // set multicast address to accept all - MACvSelectPage1(dwIoBase); - VNSvOutPortD(dwIoBase + MAC_REG_MAR0, 0xFFFFFFFFL); - VNSvOutPortD(dwIoBase + MAC_REG_MAR0 + sizeof(unsigned long), 0xFFFFFFFFL); - MACvSelectPage0(dwIoBase); - } - - if (wFilterType & PKT_TYPE_PROMISCUOUS) { - byNewRCR |= (RCR_RXALLTYPE | RCR_UNICAST | RCR_MULTICAST | RCR_BROADCAST); - - byNewRCR &= ~RCR_BSSID; - } - - if (wFilterType & (PKT_TYPE_ALL_MULTICAST | PKT_TYPE_MULTICAST)) - byNewRCR |= RCR_MULTICAST; - - if (wFilterType & PKT_TYPE_BROADCAST) - byNewRCR |= RCR_BROADCAST; - - if (wFilterType & PKT_TYPE_ERROR_CRC) - byNewRCR |= RCR_ERRCRC; - - VNSvInPortB(dwIoBase + MAC_REG_RCR, &byOldRCR); - if (byNewRCR != byOldRCR) { - // Modify the Receive Command Register - VNSvOutPortB(dwIoBase + MAC_REG_RCR, byNewRCR); - } -} - /* * Description: * Save MAC registers to context buffer @@ -629,11 +568,6 @@ void MACvInitialize(void __iomem *dwIoBase) VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); // enable TSF counter VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); - - // set packet filter - // receive directed and broadcast address - - MACvSetPacketFilter(dwIoBase, PKT_TYPE_DIRECTED | PKT_TYPE_BROADCAST); } /* diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 7d39a7ffba4c..e1e7e10435f6 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -574,17 +574,6 @@ #define MAC_LB_INTERNAL 0x01 // #define MAC_LB_NONE 0x00 // -// Ethernet address filter type -#define PKT_TYPE_NONE 0x00 // turn off receiver -#define PKT_TYPE_ALL_MULTICAST 0x80 -#define PKT_TYPE_PROMISCUOUS 0x40 -#define PKT_TYPE_DIRECTED 0x20 // obsolete, directed address is always accepted -#define PKT_TYPE_BROADCAST 0x10 -#define PKT_TYPE_MULTICAST 0x08 -#define PKT_TYPE_ERROR_WPA 0x04 -#define PKT_TYPE_ERROR_CRC 0x02 -#define PKT_TYPE_BSSID 0x01 - #define Default_BI 0x200 // MiscFIFO Offset @@ -976,8 +965,6 @@ void MACvGetLongRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit) void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode); -void MACvSetPacketFilter(void __iomem *dwIoBase, unsigned short wFilterType); - void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf); void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf); -- cgit v1.2.3-59-g8ed1b From 950701a127caca1d5c1ebf5649cd7c1ddf4b06b9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 29 Nov 2014 00:01:59 +0000 Subject: staging: vt6655: srom remove dead functions Remove these unused functions SROMbWriteEmbedded SROMvRegBitsOn SROMvRegBitsOff SROMbIsRegBitsOn SROMbIsRegBitsOff SROMvWriteAllContents SROMvWriteEtherAddress SROMvReadSubSysVenId SROMbAutoLoad Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/srom.c | 251 ------------------------------------------ drivers/staging/vt6655/srom.h | 13 --- 2 files changed, 264 deletions(-) diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index 1ac60fb4490f..9ec49e653b61 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -106,144 +106,6 @@ unsigned char SROMbyReadEmbedded(void __iomem *dwIoBase, unsigned char byContntO return byData; } -/* - * Description: Write a byte to EEPROM, by MAC I2C - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byContntOffset - address of EEPROM - * wData - data to write - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ -bool SROMbWriteEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byData) -{ - unsigned short wDelay, wNoACK; - unsigned char byWait; - - unsigned char byOrg; - - VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - /* turn off hardware retry for getting NACK */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); - for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { - VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); - VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); - VNSvOutPortB(dwIoBase + MAC_REG_I2MDOPT, byData); - - /* issue write command */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMW); - /* wait DONE be set */ - for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { - VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); - if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) - break; - PCAvDelayByIO(CB_DELAY_LOOP_WAIT); - } - - if ((wDelay < W_MAX_TIMEOUT) && - (!(byWait & I2MCSR_NACK))) { - break; - } - } - if (wNoACK == W_MAX_I2CRETRY) { - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - return false; - } - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - return true; -} - -/* - * Description: Turn bits on in eeprom - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byContntOffset - address of EEPROM - * byBits - bits to turn on - * Out: - * none - * - * Return Value: none - * - */ -void SROMvRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits) -{ - unsigned char byOrgData; - - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - SROMbWriteEmbedded(dwIoBase, byContntOffset, (unsigned char)(byOrgData | byBits)); -} - -/* - * Description: Turn bits off in eeprom - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byContntOffset - address of EEPROM - * byBits - bits to turn off - * Out: - * none - * - */ -void SROMvRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits) -{ - unsigned char byOrgData; - - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - SROMbWriteEmbedded(dwIoBase, byContntOffset, (unsigned char)(byOrgData & (~byBits))); -} - -/* - * Description: Test if bits on in eeprom - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byContntOffset - address of EEPROM - * byTestBits - bits to test - * Out: - * none - * - * Return Value: true if all test bits on; otherwise false - * - */ -bool SROMbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits) -{ - unsigned char byOrgData; - - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - return (byOrgData & byTestBits) == byTestBits; -} - -/* - * Description: Test if bits off in eeprom - * - * Parameters: - * In: - * dwIoBase - I/O base address - * byContntOffset - address of EEPROM - * byTestBits - bits to test - * Out: - * none - * - * Return Value: true if all test bits off; otherwise false - * - */ -bool SROMbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits) -{ - unsigned char byOrgData; - - byOrgData = SROMbyReadEmbedded(dwIoBase, byContntOffset); - return !(byOrgData & byTestBits); -} - /* * Description: Read all contents of eeprom to buffer * @@ -267,30 +129,6 @@ void SROMvReadAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs) } } -/* - * Description: Write all contents of buffer to eeprom - * - * Parameters: - * In: - * dwIoBase - I/O base address - * pbyEepromRegs - EEPROM content Buffer - * Out: - * none - * - * Return Value: none - * - */ -void SROMvWriteAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs) -{ - int ii; - - /* ii = Rom Address */ - for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { - SROMbWriteEmbedded(dwIoBase, (unsigned char)ii, *pbyEepromRegs); - pbyEepromRegs++; - } -} - /* * Description: Read Ethernet Address from eeprom to buffer * @@ -313,92 +151,3 @@ void SROMvReadEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddres pbyEtherAddress++; } } - -/* - * Description: Write Ethernet Address from buffer to eeprom - * - * Parameters: - * In: - * dwIoBase - I/O base address - * pbyEtherAddress - Ethernet Address buffer - * Out: - * none - * - * Return Value: none - * - */ -void SROMvWriteEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress) -{ - unsigned char ii; - - /* ii = Rom Address */ - for (ii = 0; ii < ETH_ALEN; ii++) { - SROMbWriteEmbedded(dwIoBase, ii, *pbyEtherAddress); - pbyEtherAddress++; - } -} - -/* - * Description: Read Sub_VID and Sub_SysId from eeprom to buffer - * - * Parameters: - * In: - * dwIoBase - I/O base address - * Out: - * pdwSubSysVenId - Sub_VID and Sub_SysId read - * - * Return Value: none - * - */ -void SROMvReadSubSysVenId(void __iomem *dwIoBase, unsigned long *pdwSubSysVenId) -{ - unsigned char *pbyData; - - pbyData = (unsigned char *)pdwSubSysVenId; - /* sub vendor */ - *pbyData = SROMbyReadEmbedded(dwIoBase, 6); - *(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7); - /* sub system */ - *(pbyData+2) = SROMbyReadEmbedded(dwIoBase, 8); - *(pbyData+3) = SROMbyReadEmbedded(dwIoBase, 9); -} - -/* - * Description: Auto Load EEPROM to MAC register - * - * Parameters: - * In: - * dwIoBase - I/O base address - * Out: - * none - * - * Return Value: true if success; otherwise false - * - */ -bool SROMbAutoLoad(void __iomem *dwIoBase) -{ - unsigned char byWait; - int ii; - - unsigned char byOrg; - - VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - /* turn on hardware retry */ - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg | I2MCFG_NORETRY)); - - MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD); - - /* ii = Rom Address */ - for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { - MACvTimer0MicroSDelay(dwIoBase, CB_EEPROM_READBYTE_WAIT); - VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); - if (!(byWait & I2MCSR_AUTOLD)) - break; - } - - VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, byOrg); - - if (ii == EEP_MAX_CONTEXT_SIZE) - return false; - return true; -} diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index 9f309c401770..cab638be3302 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -132,22 +132,9 @@ typedef struct tagSSromReg { /*--------------------- Export Functions --------------------------*/ unsigned char SROMbyReadEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset); -bool SROMbWriteEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byData); - -void SROMvRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits); -void SROMvRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits); - -bool SROMbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits); -bool SROMbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits); void SROMvReadAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs); -void SROMvWriteAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs); void SROMvReadEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress); -void SROMvWriteEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress); - -void SROMvReadSubSysVenId(void __iomem *dwIoBase, unsigned long *pdwSubSysVenId); - -bool SROMbAutoLoad(void __iomem *dwIoBase); #endif // __EEPROM_H__ -- cgit v1.2.3-59-g8ed1b From 4a7f0cff0592d9aaea8b211fc1cab6d8e8404c82 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 29 Nov 2014 00:02:00 +0000 Subject: staging: vt6655: remove unused typedef struct tagSSromReg Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/srom.h | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index cab638be3302..7d3e3ef9f17f 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -89,40 +89,6 @@ /*--------------------- Export Types ------------------------------*/ -// AT24C02 eeprom contents -// 2048 bits = 256 bytes = 128 words -// -typedef struct tagSSromReg { - unsigned char abyPAR[6]; // 0x00 (unsigned short) - - unsigned short wSUB_VID; // 0x03 (unsigned short) - unsigned short wSUB_SID; - - unsigned char byBCFG0; // 0x05 (unsigned short) - unsigned char byBCFG1; - - unsigned char byFCR0; // 0x06 (unsigned short) - unsigned char byFCR1; - unsigned char byPMC0; // 0x07 (unsigned short) - unsigned char byPMC1; - unsigned char byMAXLAT; // 0x08 (unsigned short) - unsigned char byMINGNT; - unsigned char byCFG0; // 0x09 (unsigned short) - unsigned char byCFG1; - unsigned short wCISPTR; // 0x0A (unsigned short) - unsigned short wRsv0; // 0x0B (unsigned short) - unsigned short wRsv1; // 0x0C (unsigned short) - unsigned char byBBPAIR; // 0x0D (unsigned short) - unsigned char byRFTYPE; - unsigned char byMinChannel; // 0x0E (unsigned short) - unsigned char byMaxChannel; - unsigned char bySignature; // 0x0F (unsigned short) - unsigned char byCheckSum; - - unsigned char abyReserved0[96]; // 0x10 (unsigned short) - unsigned char abyCIS[128]; // 0x80 (unsigned short) -} SSromReg, *PSSromReg; - /*--------------------- Export Macros ------------------------------*/ /*--------------------- Export Classes ----------------------------*/ -- cgit v1.2.3-59-g8ed1b From 4b71166d786cb38974b4e0d2021446e128a17cd1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 29 Nov 2014 00:02:01 +0000 Subject: staging: vt6655: s_cbFillTxBufHead remove unused parameter *puMACfragNum *puMACfragNum was part of old legacy functions. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 4189405bb238..f1dacf9e9c46 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -131,8 +131,7 @@ static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, - unsigned char *pPacket, unsigned int uNodeIndex, - unsigned int *puMACfragNum); + unsigned char *pPacket, unsigned int uNodeIndex); static __le16 @@ -1033,8 +1032,7 @@ static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, - unsigned char *pPacket, unsigned int is_pspoll, - unsigned int *puMACfragNum) + unsigned char *pPacket, unsigned int is_pspoll) { PDEVICE_TD_INFO td_info = pHeadTD->pTDInfo; struct sk_buff *skb = td_info->skb; @@ -1214,8 +1212,6 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - *puMACfragNum = uMACfragNum; - return cbHeaderLength; } @@ -1297,7 +1293,6 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, struct ieee80211_hdr *hdr; struct vnt_tx_fifo_head *tx_buffer_head = (struct vnt_tx_fifo_head *)td_info->buf; - u32 frag; u16 tx_body_size = skb->len, current_rate; u8 pkt_type; bool is_pspoll = false; @@ -1405,7 +1400,7 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, skb->len, dma_idx, head_td, (u8 *)skb->data, - is_pspoll, &frag); + is_pspoll); if (info->control.hw_key) { tx_key = info->control.hw_key; -- cgit v1.2.3-59-g8ed1b From 154bb8bd43cfe4d714c39e09b820427612f40bde Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 29 Nov 2014 00:02:02 +0000 Subject: staging: vt6655: s_cbFillTxBufHead remove parameter *pPacket skb->data is available locally so use that instead. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index f1dacf9e9c46..9d169166fe2b 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -131,7 +131,7 @@ static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, - unsigned char *pPacket, unsigned int uNodeIndex); + unsigned int uNodeIndex); static __le16 @@ -1032,7 +1032,7 @@ static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, - unsigned char *pPacket, unsigned int is_pspoll) + unsigned int is_pspoll) { PDEVICE_TD_INFO td_info = pHeadTD->pTDInfo; struct sk_buff *skb = td_info->skb; @@ -1200,7 +1200,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, uLength = cbHeaderLength + uPadding; /* Copy the Packet into a tx Buffer */ - memcpy((pbyBuffer + uLength), pPacket, cbFrameBodySize); + memcpy((pbyBuffer + uLength), skb->data, cbFrameBodySize); ptdCurr = (PSTxDesc)pHeadTD; @@ -1399,8 +1399,7 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG); s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, skb->len, - dma_idx, head_td, (u8 *)skb->data, - is_pspoll); + dma_idx, head_td, is_pspoll); if (info->control.hw_key) { tx_key = info->control.hw_key; -- cgit v1.2.3-59-g8ed1b From 19f3ed3f1eaae4732f6c0baea8ebc6ebb1a4489d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 29 Nov 2014 00:02:03 +0000 Subject: staging: vt6655: s_cbFillTxBufHead remove parameter cbFrameBodySize skb->len is available locally use that instead. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 9d169166fe2b..61c39dd7ad01 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -129,7 +129,7 @@ s_vGenerateTxParameter( static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, - unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, + unsigned char *pbyTxBufferAddr, unsigned int uDMAIdx, PSTxDesc pHeadTD, unsigned int uNodeIndex); @@ -1030,7 +1030,7 @@ s_vGenerateTxParameter( static unsigned int s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, - unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, + unsigned char *pbyTxBufferAddr, unsigned int uDMAIdx, PSTxDesc pHeadTD, unsigned int is_pspoll) { @@ -1195,12 +1195,12 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, hdr->duration_id = uDuration; - cbReqCount = cbHeaderLength + uPadding + cbFrameBodySize; + cbReqCount = cbHeaderLength + uPadding + skb->len; pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; uLength = cbHeaderLength + uPadding; /* Copy the Packet into a tx Buffer */ - memcpy((pbyBuffer + uLength), skb->data, cbFrameBodySize); + memcpy((pbyBuffer + uLength), skb->data, skb->len); ptdCurr = (PSTxDesc)pHeadTD; @@ -1398,7 +1398,7 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG); - s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, skb->len, + s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, dma_idx, head_td, is_pspoll); if (info->control.hw_key) { -- cgit v1.2.3-59-g8ed1b From 2af7f0b6113435f04ddbda44f7036488dfabb98a Mon Sep 17 00:00:00 2001 From: Anjana Sasindran Date: Sat, 29 Nov 2014 20:38:45 +0530 Subject: staging:ft1000_pcmcia:Added a blank line after declaration This patch fix the checkpatch.pl warning WARNING: Missing a blank line after declaration Signed-off-by: Anjana Sasindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 11dbe369e18b..d5475b7270a8 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -2042,6 +2042,7 @@ static void ft1000_get_drvinfo(struct net_device *dev, static u32 ft1000_get_link(struct net_device *dev) { struct ft1000_info *info; + info = netdev_priv(dev); return info->mediastate; } -- cgit v1.2.3-59-g8ed1b From 707ce72f9769061fb2828fab46706b6716186447 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:52 -0500 Subject: staging: rtl8723au: recv_priv.is_signal_dbg is never set Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 104 ++++++++++++--------------- drivers/staging/rtl8723au/include/rtw_recv.h | 2 - 2 files changed, 46 insertions(+), 60 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 8dd35133be94..5b15c4ae0f31 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -2314,66 +2314,54 @@ void rtw_signal_stat_timer_hdl23a(unsigned long data) u8 _alpha = 3; /* this value is based on converging_constant = 5000 */ /* and sampling_interval = 1000 */ - if (adapter->recvpriv.is_signal_dbg) { - /* update the user specific value, signal_strength_dbg, */ - /* to signal_strength, rssi */ - adapter->recvpriv.signal_strength = - adapter->recvpriv.signal_strength_dbg; - adapter->recvpriv.rssi = - (s8)translate_percentage_to_dbm((u8)adapter->recvpriv.signal_strength_dbg); - } else { - if (recvpriv->signal_strength_data.update_req == 0) { - /* update_req is clear, means we got rx */ - avg_signal_strength = - recvpriv->signal_strength_data.avg_val; - num_signal_strength = - recvpriv->signal_strength_data.total_num; - /* after avg_vals are acquired, we can re-stat */ - /* the signal values */ - recvpriv->signal_strength_data.update_req = 1; - } + if (recvpriv->signal_strength_data.update_req == 0) { + /* update_req is clear, means we got rx */ + avg_signal_strength = recvpriv->signal_strength_data.avg_val; + num_signal_strength = recvpriv->signal_strength_data.total_num; + /* after avg_vals are acquired, we can re-stat */ + /* the signal values */ + recvpriv->signal_strength_data.update_req = 1; + } + + if (recvpriv->signal_qual_data.update_req == 0) { + /* update_req is clear, means we got rx */ + avg_signal_qual = recvpriv->signal_qual_data.avg_val; + num_signal_qual = recvpriv->signal_qual_data.total_num; + /* after avg_vals are acquired, we can re-stat */ + /*the signal values */ + recvpriv->signal_qual_data.update_req = 1; + } + + /* update value of signal_strength, rssi, signal_qual */ + if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) { + tmp_s = (avg_signal_strength + (_alpha - 1) * + recvpriv->signal_strength); + if (tmp_s %_alpha) + tmp_s = tmp_s / _alpha + 1; + else + tmp_s = tmp_s / _alpha; + if (tmp_s > 100) + tmp_s = 100; - if (recvpriv->signal_qual_data.update_req == 0) { - /* update_req is clear, means we got rx */ - avg_signal_qual = recvpriv->signal_qual_data.avg_val; - num_signal_qual = recvpriv->signal_qual_data.total_num; - /* after avg_vals are acquired, we can re-stat */ - /*the signal values */ - recvpriv->signal_qual_data.update_req = 1; - } + tmp_q = avg_signal_qual + (_alpha - 1) * recvpriv->signal_qual; + if (tmp_q %_alpha) + tmp_q = tmp_q / _alpha + 1; + else + tmp_q = tmp_q / _alpha; + if (tmp_q > 100) + tmp_q = 100; - /* update value of signal_strength, rssi, signal_qual */ - if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) { - tmp_s = (avg_signal_strength + (_alpha - 1) * - recvpriv->signal_strength); - if (tmp_s %_alpha) - tmp_s = tmp_s / _alpha + 1; - else - tmp_s = tmp_s / _alpha; - if (tmp_s > 100) - tmp_s = 100; - - tmp_q = (avg_signal_qual + (_alpha - 1) * - recvpriv->signal_qual); - if (tmp_q %_alpha) - tmp_q = tmp_q / _alpha + 1; - else - tmp_q = tmp_q / _alpha; - if (tmp_q > 100) - tmp_q = 100; - - recvpriv->signal_strength = tmp_s; - recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s); - recvpriv->signal_qual = tmp_q; - - DBG_8723A("%s signal_strength:%3u, rssi:%3d, " - "signal_qual:%3u, num_signal_strength:%u, " - "num_signal_qual:%u\n", - __func__, recvpriv->signal_strength, - recvpriv->rssi, recvpriv->signal_qual, - num_signal_strength, num_signal_qual - ); - } + recvpriv->signal_strength = tmp_s; + recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s); + recvpriv->signal_qual = tmp_q; + + DBG_8723A("%s signal_strength:%3u, rssi:%3d, " + "signal_qual:%3u, num_signal_strength:%u, " + "num_signal_qual:%u\n", + __func__, recvpriv->signal_strength, + recvpriv->rssi, recvpriv->signal_qual, + num_signal_strength, num_signal_qual); } + rtw_set_signal_stat_timer(recvpriv); } diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index f846bb5e7ab7..79656ee423b4 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -200,8 +200,6 @@ struct recv_priv { u8 *precv_buf; /* For display the phy informatiom */ - u8 is_signal_dbg; /* for debug */ - u8 signal_strength_dbg; /* for debug */ s8 rssi; s8 rxpwdb; u8 signal_strength; -- cgit v1.2.3-59-g8ed1b From f7bf8c243da20b2b303794fc80a0e2a66d966823 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:53 -0500 Subject: staging: rtl8723au: recv_priv->rssi is not used for anything Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 ++---- drivers/staging/rtl8723au/core/rtw_recv.c | 10 ++++------ drivers/staging/rtl8723au/include/rtw_recv.h | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 734972cae87c..7299ef0a2e54 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1022,11 +1022,9 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter, * the ptarget_wlan->network.Rssi is raw data, we use * ptarget_wlan->network.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm( - ptarget_wlan->network.SignalStrength); - DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n", + DBG_8723A("%s signal_strength:%3u, signal_qual:%3u\n", __func__, padapter->recvpriv.signal_strength, - padapter->recvpriv.rssi, padapter->recvpriv.signal_qual); + padapter->recvpriv.signal_qual); rtw_set_signal_stat_timer(&padapter->recvpriv); /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 5b15c4ae0f31..559dddee2648 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -2352,15 +2352,13 @@ void rtw_signal_stat_timer_hdl23a(unsigned long data) tmp_q = 100; recvpriv->signal_strength = tmp_s; - recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s); recvpriv->signal_qual = tmp_q; - DBG_8723A("%s signal_strength:%3u, rssi:%3d, " - "signal_qual:%3u, num_signal_strength:%u, " - "num_signal_qual:%u\n", + DBG_8723A("%s signal_strength:%3u, signal_qual:%3u, " + "num_signal_strength:%u, num_signal_qual:%u\n", __func__, recvpriv->signal_strength, - recvpriv->rssi, recvpriv->signal_qual, - num_signal_strength, num_signal_qual); + recvpriv->signal_qual, num_signal_strength, + num_signal_qual); } rtw_set_signal_stat_timer(recvpriv); diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index 79656ee423b4..dc784be3ddd9 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -200,7 +200,6 @@ struct recv_priv { u8 *precv_buf; /* For display the phy informatiom */ - s8 rssi; s8 rxpwdb; u8 signal_strength; u8 signal_qual; -- cgit v1.2.3-59-g8ed1b From 7114ca14fcd97c04980811fa2aa40d5f7f061c40 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:54 -0500 Subject: staging: rtl8723au: Fold ODM_PhyStatusQuery23a_92CSeries() into ODM_PhyStatusQuery23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm_HWConfig.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm_HWConfig.c b/drivers/staging/rtl8723au/hal/odm_HWConfig.c index 29d844d66cae..fb3cc872f205 100644 --- a/drivers/staging/rtl8723au/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723au/hal/odm_HWConfig.c @@ -391,20 +391,11 @@ static void odm_Process_RSSIForDM(struct dm_odm_t *pDM_Odm, } } -/* Endianness before calling this API */ -static void ODM_PhyStatusQuery23a_92CSeries(struct dm_odm_t *pDM_Odm, - struct phy_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_packet_info *pPktinfo) +void ODM_PhyStatusQuery23a(struct dm_odm_t *pDM_Odm, struct phy_info *pPhyInfo, + u8 *pPhyStatus, struct odm_packet_info *pPktinfo) { odm_RxPhyStatus92CSeries_Parsing(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); odm_Process_RSSIForDM(pDM_Odm, pPhyInfo, pPktinfo); } - -void ODM_PhyStatusQuery23a(struct dm_odm_t *pDM_Odm, struct phy_info *pPhyInfo, - u8 *pPhyStatus, struct odm_packet_info *pPktinfo) -{ - ODM_PhyStatusQuery23a_92CSeries(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); -} -- cgit v1.2.3-59-g8ed1b From d3220b71185e4792ac40086ed357d8cb3f6cc3e7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:55 -0500 Subject: staging: rtl8732au: Partial clean up of rtl8723a_rf6052.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c | 229 +++++++++++++----------- 1 file changed, 123 insertions(+), 106 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c index 2dc0886e5f90..1aad4384471c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c @@ -42,21 +42,6 @@ #include #include -/*---------------------------Define Local Constant---------------------------*/ -/* Define local structure for debug!!!!! */ -struct rf_shadow_compare_map { - /* Shadow register value */ - u32 Value; - /* Compare or not flag */ - u8 Compare; - /* Record If it had ever modified unpredicted */ - u8 ErrorOrNot; - /* Recorver Flag */ - u8 Recorver; - /* */ - u8 Driver_Write; -}; - /*----------------------------------------------------------------------------- * Function: PHY_RF6052SetBandwidth() * @@ -71,20 +56,23 @@ struct rf_shadow_compare_map { * * Note: For RF type 0222D *---------------------------------------------------------------------------*/ -void rtl8723a_phy_rf6052set_bw( - struct rtw_adapter *Adapter, - enum ht_channel_width Bandwidth) /* 20M or 40M */ +void rtl8723a_phy_rf6052set_bw(struct rtw_adapter *Adapter, + enum ht_channel_width Bandwidth) /* 20M or 40M */ { - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); switch (Bandwidth) { case HT_CHANNEL_WIDTH_20: - pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | 0x0400); - PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + pHalData->RfRegChnlVal[0] = + (pHalData->RfRegChnlVal[0] & 0xfffff3ff) | 0x0400; + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, + pHalData->RfRegChnlVal[0]); break; case HT_CHANNEL_WIDTH_40: - pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff)); - PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + pHalData->RfRegChnlVal[0] = + (pHalData->RfRegChnlVal[0] & 0xfffff3ff); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, + pHalData->RfRegChnlVal[0]); break; default: break; @@ -108,7 +96,8 @@ void rtl8723a_phy_rf6052set_bw( * *---------------------------------------------------------------------------*/ -void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter, u8 *pPowerlevel) +void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter, + u8 *pPowerlevel) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; @@ -118,7 +107,8 @@ void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter, u8 *pPowerleve u8 idx1, idx2; u8 *ptr; - /* According to SD3 eechou's suggestion, we need to disable turbo scan for RU. */ + /* According to SD3 eechou's suggestion, we need to disable + turbo scan for RU. */ /* Otherwise, external PA will be broken if power index > 0x20. */ if (pHalData->EEPROMRegulatory != 0 || pHalData->ExternalPA) TurboScanOff = true; @@ -131,29 +121,37 @@ void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter, u8 *pPowerleve if (TurboScanOff) { for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - TxAGC[idx1] = - pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | - (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); - /* 2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */ + TxAGC[idx1] = pPowerlevel[idx1] | + (pPowerlevel[idx1] << 8) | + (pPowerlevel[idx1] << 16) | + (pPowerlevel[idx1] << 24); + /* 2010/10/18 MH For external PA module. + We need to limit power index to be less + than 0x20. */ if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA) TxAGC[idx1] = 0x20; } } } else { -/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ -/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ -/* In the future, two mechanism shall be separated from each other and maintained independantly. Thanks for Lanhsin's reminder. */ +/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx + * power. It shall be determined by power training mechanism. */ +/* Currently, we cannot fully disable driver dynamic tx power + * mechanism because it is referenced by BT coexist mechanism. */ +/* In the future, two mechanism shall be separated from each other + * and maintained independantly. Thanks for Lanhsin's reminder. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { TxAGC[RF_PATH_A] = 0x10101010; TxAGC[RF_PATH_B] = 0x10101010; - } else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) { + } else if (pdmpriv->DynamicTxHighPowerLvl == + TxHighPwrLevel_Level2) { TxAGC[RF_PATH_A] = 0x00000000; TxAGC[RF_PATH_B] = 0x00000000; } else { for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - TxAGC[idx1] = - pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | - (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + TxAGC[idx1] = pPowerlevel[idx1] | + (pPowerlevel[idx1] << 8) | + (pPowerlevel[idx1] << 16) | + (pPowerlevel[idx1] << 24); } if (pHalData->EEPROMRegulatory == 0) { @@ -178,29 +176,24 @@ void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter, u8 *pPowerleve } /* rf-A cck tx power */ - tmpval = TxAGC[RF_PATH_A]&0xff; + tmpval = TxAGC[RF_PATH_A] & 0xff; PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); - tmpval = TxAGC[RF_PATH_A]>>8; + tmpval = TxAGC[RF_PATH_A] >> 8; PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); /* rf-B cck tx power */ - tmpval = TxAGC[RF_PATH_B]>>24; + tmpval = TxAGC[RF_PATH_B] >> 24; PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); - tmpval = TxAGC[RF_PATH_B]&0x00ffffff; + tmpval = TxAGC[RF_PATH_B] & 0x00ffffff; PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); } /* PHY_RF6052SetCckTxPower */ /* powerbase0 for OFDM rates */ /* powerbase1 for HT MCS rates */ -static void getPowerBase( - struct rtw_adapter *Adapter, - u8 *pPowerLevel, - u8 Channel, - u32 *OfdmBase, - u32 *MCSBase - ) +static void getPowerBase(struct rtw_adapter *Adapter, u8 *pPowerLevel, + u8 Channel, u32 *OfdmBase, u32 *MCSBase) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); u32 powerBase0, powerBase1; u8 Legacy_pwrdiff = 0; s8 HT20_pwrdiff = 0; @@ -211,8 +204,9 @@ static void getPowerBase( Legacy_pwrdiff = pHalData->TxPwrLegacyHtDiff[i][Channel-1]; powerBase0 = powerlevel[i] + Legacy_pwrdiff; - powerBase0 = (powerBase0<<24) | (powerBase0<<16) | (powerBase0<<8) | powerBase0; - *(OfdmBase+i) = powerBase0; + powerBase0 = powerBase0 << 24 | powerBase0 << 16 | + powerBase0 << 8 | powerBase0; + *(OfdmBase + i) = powerBase0; } for (i = 0; i < 2; i++) { @@ -222,36 +216,35 @@ static void getPowerBase( powerlevel[i] += HT20_pwrdiff; } powerBase1 = powerlevel[i]; - powerBase1 = (powerBase1<<24) | (powerBase1<<16) | (powerBase1<<8) | powerBase1; - *(MCSBase+i) = powerBase1; + powerBase1 = powerBase1 << 24 | powerBase1 << 16 | + powerBase1 << 8 | powerBase1; + *(MCSBase + i) = powerBase1; } } -static void getTxPowerWriteValByRegulatory( - struct rtw_adapter *Adapter, - u8 Channel, - u8 index, - u32 *powerBase0, - u32 *powerBase1, - u32 *pOutWriteVal - ) +static void +getTxPowerWriteValByRegulatory(struct rtw_adapter *Adapter, u8 Channel, + u8 index, u32 *powerBase0, u32 *powerBase1, + u32 *pOutWriteVal) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; - u8 i, chnlGroup = 0, pwr_diff_limit[4]; - u32 writeVal, customer_limit, rf; + u8 i, chnlGroup = 0, pwr_diff_limit[4]; + u32 writeVal, customer_limit, rf; /* Index 0 & 1 = legacy OFDM, 2-5 = HT_MCS rate */ for (rf = 0; rf < 2; rf++) { switch (pHalData->EEPROMRegulatory) { case 0: /* Realtek better performance */ - /* increase power diff defined by Realtek for large power */ + /* increase power diff defined by Realtek for + * large power */ chnlGroup = 0; writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)] + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); break; case 1: /* Realtek regulatory */ - /* increase power diff defined by Realtek for regulatory */ + /* increase power diff defined by Realtek for + * regulatory */ if (pHalData->pwrGroupCnt == 1) chnlGroup = 0; if (pHalData->pwrGroupCnt >= 3) { @@ -262,17 +255,20 @@ static void getTxPowerWriteValByRegulatory( else if (Channel > 9) chnlGroup = 2; - if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + if (pHalData->CurrentChannelBW == + HT_CHANNEL_WIDTH_20) chnlGroup++; else chnlGroup += 4; } writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf?8:0)] + - ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + ((index < 2) ? powerBase0[rf] : + powerBase1[rf]); break; case 2: /* Better regulatory */ - /* don't increase any power diff */ - writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + /* don't increase any power diff */ + writeVal = ((index < 2) ? powerBase0[rf] : + powerBase1[rf]); break; case 3: /* Customer defined power diff. */ chnlGroup = 0; @@ -299,28 +295,34 @@ static void getTxPowerWriteValByRegulatory( break; } -/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ -/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ -/* In the future, two mechanism shall be separated from each other and maintained independantly. Thanks for Lanhsin's reminder. */ +/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. + It shall be determined by power training mechanism. */ +/* Currently, we cannot fully disable driver dynamic tx power mechanism + because it is referenced by BT coexist mechanism. */ +/* In the future, two mechanism shall be separated from each other and + maintained independantly. Thanks for Lanhsin's reminder. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) writeVal = 0x14141414; - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) + else if (pdmpriv->DynamicTxHighPowerLvl == + TxHighPwrLevel_Level2) writeVal = 0x00000000; - /* 20100628 Joseph: High power mode for BT-Coexist mechanism. */ - /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */ + /* 20100628 Joseph: High power mode for BT-Coexist mechanism. */ + /* This mechanism is only applied when + Driver-Highpower-Mechanism is OFF. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1) writeVal = writeVal - 0x06060606; else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2) writeVal = writeVal; - *(pOutWriteVal+rf) = writeVal; + *(pOutWriteVal + rf) = writeVal; } } -static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue) +static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, + u32 *pValue) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); u16 RegOffset_A[6] = { rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24, rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04, @@ -338,12 +340,13 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue for (rf = 0; rf < 2; rf++) { writeVal = pValue[rf]; for (i = 0; i < 4; i++) { - pwr_val[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8)); - if (pwr_val[i] > RF6052_MAX_TX_PWR) + pwr_val[i] = (u8)((writeVal & + (0x7f << (i * 8))) >> (i * 8)); + if (pwr_val[i] > RF6052_MAX_TX_PWR) pwr_val[i] = RF6052_MAX_TX_PWR; } - writeVal = (pwr_val[3]<<24) | (pwr_val[2]<<16) | - (pwr_val[1]<<8) | pwr_val[0]; + writeVal = pwr_val[3] << 24 | pwr_val[2] << 16 | + pwr_val[1] << 8 | pwr_val[0]; if (rf == 0) RegOffset = RegOffset_A[index]; @@ -352,7 +355,8 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue PHY_SetBBReg(Adapter, RegOffset, bMaskDWord, writeVal); - /* 201005115 Joseph: Set Tx Power diff for Tx power training mechanism. */ + /* 201005115 Joseph: Set Tx Power diff for Tx power + training mechanism. */ if (((pHalData->rf_type == RF_2T2R) && (RegOffset == rTxAGC_A_Mcs15_Mcs12 || RegOffset == rTxAGC_B_Mcs15_Mcs12)) || @@ -360,15 +364,19 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue (RegOffset == rTxAGC_A_Mcs07_Mcs04 || RegOffset == rTxAGC_B_Mcs07_Mcs04))) { writeVal = pwr_val[3]; - if (RegOffset == rTxAGC_A_Mcs15_Mcs12 || RegOffset == rTxAGC_A_Mcs07_Mcs04) + if (RegOffset == rTxAGC_A_Mcs15_Mcs12 || + RegOffset == rTxAGC_A_Mcs07_Mcs04) RegOffset = 0xc90; - if (RegOffset == rTxAGC_B_Mcs15_Mcs12 || RegOffset == rTxAGC_B_Mcs07_Mcs04) + if (RegOffset == rTxAGC_B_Mcs15_Mcs12 || + RegOffset == rTxAGC_B_Mcs07_Mcs04) RegOffset = 0xc98; for (i = 0; i < 3; i++) { if (i != 2) - writeVal = (writeVal > 8) ? (writeVal-8) : 0; + writeVal = (writeVal > 8) ? + (writeVal - 8) : 0; else - writeVal = (writeVal > 6) ? (writeVal-6) : 0; + writeVal = (writeVal > 6) ? + (writeVal - 6) : 0; rtl8723au_write8(Adapter, RegOffset + i, (u8)writeVal); } @@ -379,8 +387,9 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue * Function: PHY_RF6052SetOFDMTxPower * * Overview: For legacy and HY OFDM, we must read EEPROM TX power index for - * different channel and read original value in TX power register area from - * 0xe00. We increase offset and original value to be correct tx pwr. + * different channel and read original value in TX power + * register area from 0xe00. We increase offset and + * original value to be correct tx pwr. * * Input: NONE * @@ -389,20 +398,23 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue * Return: NONE * * Revised History: - * When Who Remark - * 11/05/2008 MHC Simulate 8192 series method. - * 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to - * A/B pwr difference or legacy/HT pwr diff. - * 2. We concern with path B legacy/HT OFDM difference. - * 01/22/2009 MHC Support new EPRO format from SD3. + * When Remark + * 11/05/2008 MHC Simulate 8192 series method. + * 01/06/2009 MHC 1. Prevent Path B tx power overflow or + * underflow dure to A/B pwr difference or + * legacy/HT pwr diff. + * 2. We concern with path B legacy/HT OFDM difference. + * 01/22/2009 MHC Support new EPRO format from SD3. * *---------------------------------------------------------------------------*/ -void rtl8723a_PHY_RF6052SetOFDMTxPower(struct rtw_adapter *Adapter, u8 *pPowerLevel, u8 Channel) +void rtl8723a_PHY_RF6052SetOFDMTxPower(struct rtw_adapter *Adapter, + u8 *pPowerLevel, u8 Channel) { u32 writeVal[2], powerBase0[2], powerBase1[2]; u8 index = 0; - getPowerBase(Adapter, pPowerLevel, Channel, &powerBase0[0], &powerBase1[0]); + getPowerBase(Adapter, pPowerLevel, Channel, + &powerBase0[0], &powerBase1[0]); for (index = 0; index < 6; index++) { getTxPowerWriteValByRegulatory(Adapter, Channel, index, @@ -416,7 +428,7 @@ static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter) { u32 u4RegValue = 0; u8 eRFPath; - struct bb_reg_define *pPhyReg; + struct bb_reg_define *pPhyReg; int rtStatus = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); @@ -430,15 +442,17 @@ static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter) /*----Store original RFENV control type----*/ switch (eRFPath) { case RF_PATH_A: - u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, + bRFSI_RFENV); break; case RF_PATH_B: - u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, + bRFSI_RFENV << 16); break; } /*----Set RF_ENV enable----*/ - PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); + PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1); udelay(1);/* PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ @@ -446,10 +460,12 @@ static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter) udelay(1);/* PlatformStallExecution(1); */ /* Set bit number of Address and Data for RF register */ - PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, + 0x0); /* Set 1 to 4 bits for 8255 */ udelay(1);/* PlatformStallExecution(1); */ - PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, + 0x0); /* Set 0 to 12 bits for 8255 */ udelay(1);/* PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ @@ -464,15 +480,16 @@ static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter) /*----Restore RFENV control type----*/; switch (eRFPath) { case RF_PATH_A: - PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, + bRFSI_RFENV, u4RegValue); break; case RF_PATH_B: - PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, + bRFSI_RFENV << 16, u4RegValue); break; } if (rtStatus != _SUCCESS) { - /* RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); */ goto phy_RF6052_Config_ParaFile_Fail; } } -- cgit v1.2.3-59-g8ed1b From 116bf14907dfb75b69350e7351dbd739caa70e2d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:56 -0500 Subject: staging: rtl8723au: Fold rtw_ack_tx_done23a() into rtw23a_sctx_done_err() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 1 - drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 15 +++++++++++ drivers/staging/rtl8723au/hal/rtl8723a_xmit.c | 31 ----------------------- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 5 ++-- 5 files changed, 18 insertions(+), 35 deletions(-) delete mode 100644 drivers/staging/rtl8723au/hal/rtl8723a_xmit.c diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index b184108680eb..3e8989018a88 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -32,7 +32,6 @@ r8723au-y := \ hal/rtl8723a_rf6052.o \ hal/rtl8723a_rxdesc.o \ hal/rtl8723a_sreset.o \ - hal/rtl8723a_xmit.o \ hal/rtl8723au_recv.o \ hal/rtl8723au_xmit.o \ hal/usb_halinit.o \ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 044807cf5457..01f1b79c165e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1048,6 +1048,21 @@ exit: return ret; } +void handle_txrpt_ccx_8723a(struct rtw_adapter *adapter, void *buf) +{ + struct txrpt_ccx_8723a *txrpt_ccx = buf; + struct submit_ctx *pack_tx_ops = &adapter->xmitpriv.ack_tx_ops; + + if (txrpt_ccx->int_ccx && adapter->xmitpriv.ack_tx) { + if (txrpt_ccx->pkt_ok) + rtw23a_sctx_done_err(&pack_tx_ops, + RTW_SCTX_DONE_SUCCESS); + else + rtw23a_sctx_done_err(&pack_tx_ops, + RTW_SCTX_DONE_CCX_PKT_FAIL); + } +} + void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) { u8 val; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723a_xmit.c deleted file mode 100644 index 6ea2f9efef64..000000000000 --- a/drivers/staging/rtl8723au/hal/rtl8723a_xmit.c +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - ******************************************************************************/ -#define _RTL8723A_XMIT_C_ - -#include -#include -#include - -void handle_txrpt_ccx_8723a(struct rtw_adapter *adapter, void *buf) -{ - struct txrpt_ccx_8723a *txrpt_ccx = buf; - - if (txrpt_ccx->int_ccx) { - if (txrpt_ccx->pkt_ok) - rtw_ack_tx_done23a(&adapter->xmitpriv, RTW_SCTX_DONE_SUCCESS); - else - rtw_ack_tx_done23a(&adapter->xmitpriv, RTW_SCTX_DONE_CCX_PKT_FAIL); - } -} diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 87097c459137..d047d753957e 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -379,7 +379,6 @@ void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, u8 qos_acm23a(u8 acm_mask, u8 priority); u32 rtw_get_ff_hwaddr23a(struct xmit_frame *pxmitframe); int rtw_ack_tx_wait23a(struct xmit_priv *pxmitpriv, u32 timeout_ms); -void rtw_ack_tx_done23a(struct xmit_priv *pxmitpriv, int status); /* include after declaring struct xmit_buf, in order to avoid warning */ #include diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 926129e5f0ae..92ab66747704 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -242,6 +242,7 @@ void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter) static void rtw_dev_unload(struct rtw_adapter *padapter) { + struct submit_ctx *pack_tx_ops = &padapter->xmitpriv.ack_tx_ops; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n")); if (padapter->bup) { @@ -249,8 +250,8 @@ static void rtw_dev_unload(struct rtw_adapter *padapter) padapter->bDriverStopped = true; if (padapter->xmitpriv.ack_tx) - rtw_ack_tx_done23a(&padapter->xmitpriv, - RTW_SCTX_DONE_DRV_STOP); + rtw23a_sctx_done_err(&pack_tx_ops, + RTW_SCTX_DONE_DRV_STOP); /* s3. */ rtl8723a_usb_intf_stop(padapter); -- cgit v1.2.3-59-g8ed1b From 01ffd629b91c25002c30f13d2fdb7a1668aecfe9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:57 -0500 Subject: staging: rtl8723au: Eliminate do_queue_select() functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 14 +------------- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 14 +------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c79d5b900594..00a04af66ff5 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1858,18 +1858,6 @@ u32 rtw_get_ff_hwaddr23a(struct xmit_frame *pxmitframe) return addr; } -static void do_queue_select(struct rtw_adapter *padapter, struct pkt_attrib *pattrib) -{ - u8 qsel; - - qsel = pattrib->priority; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - ("### do_queue_select priority =%d , qsel = %d\n", - pattrib->priority, qsel)); - - pattrib->qsel = qsel; -} - /* * The main transmit(tx) entry * @@ -1901,7 +1889,7 @@ int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb) } pxmitframe->pkt = skb; - do_queue_select(padapter, &pxmitframe->attrib); + pxmitframe->attrib.qsel = pxmitframe->attrib.priority; #ifdef CONFIG_8723AU_AP_MODE spin_lock_bh(&pxmitpriv->lock); diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index 9cdd9e5d9f76..6070510bb470 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -21,18 +21,6 @@ /* include */ #include -static void do_queue_select(struct rtw_adapter *padapter, struct pkt_attrib *pattrib) -{ - u8 qsel; - - qsel = pattrib->priority; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - ("### do_queue_select priority =%d , qsel = %d\n", - pattrib->priority, qsel)); - - pattrib->qsel = qsel; -} - static int urb_zero_packet_chk(struct rtw_adapter *padapter, int sz) { int blnSetTxDescOffset; @@ -441,7 +429,7 @@ bool rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct pkt_attrib *pattrib = &pxmitframe->attrib; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - do_queue_select(padapter, pattrib); + pattrib->qsel = pattrib->priority; spin_lock_bh(&pxmitpriv->lock); #ifdef CONFIG_8723AU_AP_MODE -- cgit v1.2.3-59-g8ed1b From 6a8f6189979fcc6eca18da270fcbd984d6713254 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:58 -0500 Subject: staging: rtl8723au: Remove unused rtw_sctx_done23a() function Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 5 ----- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 00a04af66ff5..7a5e6bf0d1ae 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -2362,11 +2362,6 @@ void rtw23a_sctx_done_err(struct submit_ctx **sctx, int status) } } -void rtw_sctx_done23a(struct submit_ctx **sctx) -{ - rtw23a_sctx_done_err(sctx, RTW_SCTX_DONE_SUCCESS); -} - int rtw_ack_tx_wait23a(struct xmit_priv *pxmitpriv, u32 timeout_ms) { struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index d047d753957e..2b7d6d08238b 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -196,7 +196,6 @@ enum { void rtw_sctx_init23a(struct submit_ctx *sctx, int timeout_ms); int rtw_sctx_wait23a(struct submit_ctx *sctx); void rtw23a_sctx_done_err(struct submit_ctx **sctx, int status); -void rtw_sctx_done23a(struct submit_ctx **sctx); struct xmit_buf { struct list_head list, list2; -- cgit v1.2.3-59-g8ed1b From ec28fb8948dc2d25fcece4c89c2329a8f1503778 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:04:59 -0500 Subject: staging: rtl8723au: Remove write only struct hal_data_8723a.interfaceIndex Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 -- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 3 --- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index ead676f8b684..027b42a9087e 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -84,8 +84,6 @@ void rtl8723au_chip_configure(struct rtw_adapter *padapter) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); - pHalData->interfaceIndex = pdvobjpriv->InterfaceNumber; - rtl8723au_set_queue_pipe_mapping(padapter, pdvobjpriv->RtNumInPipes, pdvobjpriv->RtNumOutPipes); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 72af134f74fd..5a70f2fd3ead 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -372,9 +372,6 @@ struct hal_data_8723a { /* 2010/08/09 MH Add CU power down mode. */ u8 pwrdown; - /* Add for dual MAC 0--Mac0 1--Mac1 */ - u32 interfaceIndex; - u8 OutEpQueueSel; u8 OutEpNumber; -- cgit v1.2.3-59-g8ed1b From 4a293154a940da8d8bd1cea2485b1c7620620a6e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:00 -0500 Subject: staging: rtl8723au: Fold rtl8723au_set_queue_pipe_mapping into rtl8723au_chip_configure() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 27 ++++++++------------------- drivers/staging/rtl8723au/include/usb_ops.h | 2 +- drivers/staging/rtl8723au/os_dep/usb_intf.c | 3 ++- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 027b42a9087e..b8d5040798f4 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -60,33 +60,22 @@ _ConfigChipOutEP(struct rtw_adapter *pAdapter, u8 NumOutPipe) (u32)NumOutPipe, (u32)pHalData->OutEpNumber)); */ } -static bool rtl8723au_set_queue_pipe_mapping(struct rtw_adapter *pAdapter, - u8 NumInPipe, u8 NumOutPipe) +bool rtl8723au_chip_configure(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(pAdapter); - bool result = false; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + u8 NumInPipe = pdvobjpriv->RtNumInPipes; + u8 NumOutPipe = pdvobjpriv->RtNumOutPipes; - _ConfigChipOutEP(pAdapter, NumOutPipe); + _ConfigChipOutEP(padapter, NumOutPipe); /* Normal chip with one IN and one OUT doesn't have interrupt IN EP. */ if (pHalData->OutEpNumber == 1) { if (NumInPipe != 1) - return result; + return false; } - result = Hal_MappingOutPipe23a(pAdapter, NumOutPipe); - - return result; -} - -void rtl8723au_chip_configure(struct rtw_adapter *padapter) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); - - rtl8723au_set_queue_pipe_mapping(padapter, - pdvobjpriv->RtNumInPipes, - pdvobjpriv->RtNumOutPipes); + return Hal_MappingOutPipe23a(padapter, NumOutPipe); } static int _InitPowerOn(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index ade8bc71572a..ff11e13b24a8 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -63,6 +63,6 @@ static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj) atomic_set(&dvobj->continual_urb_error, 0); } -void rtl8723au_chip_configure(struct rtw_adapter *padapter); +bool rtl8723au_chip_configure(struct rtw_adapter *padapter); #endif /* __USB_OPS_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 92ab66747704..373a617ace54 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -530,7 +530,8 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, rtl8723a_read_chip_version(padapter); /* step usb endpoint mapping */ - rtl8723au_chip_configure(padapter); + if (!rtl8723au_chip_configure(padapter)) + goto free_hal_data; /* step read efuse/eeprom data and get mac_addr */ rtl8723a_read_adapter_info(padapter); -- cgit v1.2.3-59-g8ed1b From a1cfeeb22b55f5539c7b83e49b2bce1706e7f205 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:01 -0500 Subject: staging: rtl8723au: _InitPowerOn(): Don't zero init variables unnecessarily Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index b8d5040798f4..3b09dc2d5bbc 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -80,9 +80,8 @@ bool rtl8723au_chip_configure(struct rtw_adapter *padapter) static int _InitPowerOn(struct rtw_adapter *padapter) { - int status = _SUCCESS; - u16 value16 = 0; - u8 value8 = 0; + u16 value16; + u8 value8; /* RSV_CTRL 0x1C[7:0] = 0x00 unlock ISO/CLK/Power control register */ @@ -109,7 +108,7 @@ static int _InitPowerOn(struct rtw_adapter *padapter) /* for Efuse PG, suggest by Jackie 2011.11.23 */ PHY_SetBBReg(padapter, REG_EFUSE_CTRL, BIT(28)|BIT(29)|BIT(30), 0x06); - return status; + return _SUCCESS; } /* Shall USB interface init this? */ -- cgit v1.2.3-59-g8ed1b From bacdcb85c91ab4ddfc1b1e5e5bcd14138c18422e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:02 -0500 Subject: staging: rtl8723au: Fold _InitNormalChipQueuePriority() into _InitQueuePriority() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 3b09dc2d5bbc..4cc0a0f9f316 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -298,7 +298,7 @@ static void _InitNormalChipThreeOutEpPriority(struct rtw_adapter *Adapter) _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); } -static void _InitNormalChipQueuePriority(struct rtw_adapter *Adapter) +static void _InitQueuePriority(struct rtw_adapter *Adapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); @@ -318,11 +318,6 @@ static void _InitNormalChipQueuePriority(struct rtw_adapter *Adapter) } } -static void _InitQueuePriority(struct rtw_adapter *Adapter) -{ - _InitNormalChipQueuePriority(Adapter); -} - static void _InitTransferPageSize(struct rtw_adapter *Adapter) { /* Tx page size is always 128. */ -- cgit v1.2.3-59-g8ed1b From 2098778f562123c09cace4a15cd08f0cc26f0e48 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:03 -0500 Subject: staging: rtl8723au: Remove no-op _InitHWLed() function Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 4cc0a0f9f316..762c51427958 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -422,10 +422,6 @@ static void _InitEDCA(struct rtw_adapter *Adapter) rtl8723au_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); } -static void _InitHWLed(struct rtw_adapter *Adapter) -{ -} - static void _InitRDGSetting(struct rtw_adapter *Adapter) { rtl8723au_write8(Adapter, REG_RD_CTRL, 0xFF); @@ -666,8 +662,6 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter) _InitRetryFunction(Adapter); rtl8723a_InitBeaconParameters(Adapter); - _InitHWLed(Adapter); - _BBTurnOnBlock(Adapter); /* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */ -- cgit v1.2.3-59-g8ed1b From 6e1c29fd9e10af8aff4f9fe628e1ca9d337e90a9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:04 -0500 Subject: staging: rtl8723au: Do not write garbage to REG_SPS0_CTRL Use a separate variable to hold the value of REG_SPS0_CTRL to avoid it getting clobbered and writing out garbage to it, for the case of eRFPowerState == rf_sleep/rf_off && bRegSSPwrLvl == 1. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 762c51427958..6c6601332035 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -776,9 +776,11 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, int bRegSSPwrLvl) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - u8 value8; + u8 value8, sps0; u8 bytetmp; + sps0 = rtl8723au_read8(Adapter, REG_SPS0_CTRL); + switch (eRFPowerState) { case rf_on: if (bRegSSPwrLvl == 1) { @@ -788,8 +790,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ rtl8723au_write8(Adapter, REG_SPS0_CTRL, - rtl8723au_read8(Adapter, REG_SPS0_CTRL) | - BIT(0) | BIT(3)); + sps0 | BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ /* RF */ @@ -832,8 +833,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ rtl8723au_write8(Adapter, REG_SPS0_CTRL, - rtl8723au_read8(Adapter, REG_SPS0_CTRL) | - BIT(0) | BIT(3)); + sps0 | BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ /* RF */ @@ -882,11 +882,10 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, break; case rf_sleep: case rf_off: - value8 = rtl8723au_read8(Adapter, REG_SPS0_CTRL); if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)) - value8 &= ~BIT(0); + sps0 &= ~BIT(0); else - value8 &= ~(BIT(0) | BIT(3)); + sps0 &= ~(BIT(0) | BIT(3)); if (bRegSSPwrLvl == 1) { RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL1\n")); /* Disable RF and BB only for SelectSuspend. */ @@ -936,7 +935,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, bRFRegOffsetMask, 0); /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ - rtl8723au_write8(Adapter, REG_SPS0_CTRL, value8); + rtl8723au_write8(Adapter, REG_SPS0_CTRL, sps0); } else { /* Level 2 or others. */ RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL2\n")); { @@ -1009,7 +1008,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, bRFRegOffsetMask, 0); /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ - rtl8723au_write8(Adapter, REG_SPS0_CTRL, value8); + rtl8723au_write8(Adapter, REG_SPS0_CTRL, sps0); /* 2010/10/13 MH/Isaachsu exchange sequence. */ /* h. AFE_PLL_CTRL 0x28[7:0] = 0x80 -- cgit v1.2.3-59-g8ed1b From 0e316c225100e68e082f57bf1959382f2e345648 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:05 -0500 Subject: staging: rtl8723au: Fold _ps_open_RF23a() into rtl8723au_hal_init() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 6c6601332035..cd3f8ba16804 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -25,6 +25,10 @@ #include +static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, + enum rt_rf_power_state eRFPowerState, + int bRegSSPwrLvl); + static void _ConfigChipOutEP(struct rtw_adapter *pAdapter, u8 NumOutPipe) { @@ -495,8 +499,6 @@ enum rt_rf_power_state RfOnOffDetect23a(struct rtw_adapter *pAdapter) return rfpowerstate; } -void _ps_open_RF23a(struct rtw_adapter *padapter); - int rtl8723au_hal_init(struct rtw_adapter *Adapter) { u8 val8 = 0; @@ -511,7 +513,9 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter) Adapter->hw_init_completed = false; if (Adapter->pwrctrlpriv.bkeepfwalive) { - _ps_open_RF23a(Adapter); + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 + needs to be verified */ + phy_SsPwrSwitch92CU(Adapter, rf_on, 1); if (pHalData->bIQKInitialized) { rtl8723a_phy_iq_calibrate(Adapter, true); @@ -1027,12 +1031,6 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, } /* phy_PowerSwitch92CU */ -void _ps_open_RF23a(struct rtw_adapter *padapter) -{ - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - phy_SsPwrSwitch92CU(padapter, rf_on, 1); -} - static void CardDisableRTL8723U(struct rtw_adapter *Adapter) { u8 u1bTmp; -- cgit v1.2.3-59-g8ed1b From b024793188002b9eed452b5f6a04d45003ed5772 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:06 -0500 Subject: staging: rtl8723au: phy_SsPwrSwitch92CU() was never called with bRegSSPwrLvl != 1 Get rid of the alternate code paths since these weren't used and have never been tested according to the in-code comments. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 322 ++++++++-------------------- 1 file changed, 84 insertions(+), 238 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index cd3f8ba16804..4cfa2f765c9f 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -26,8 +26,7 @@ #include static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, - enum rt_rf_power_state eRFPowerState, - int bRegSSPwrLvl); + enum rt_rf_power_state eRFPowerState); static void _ConfigChipOutEP(struct rtw_adapter *pAdapter, u8 NumOutPipe) @@ -513,9 +512,7 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter) Adapter->hw_init_completed = false; if (Adapter->pwrctrlpriv.bkeepfwalive) { - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 - needs to be verified */ - phy_SsPwrSwitch92CU(Adapter, rf_on, 1); + phy_SsPwrSwitch92CU(Adapter, rf_on); if (pHalData->bIQKInitialized) { rtl8723a_phy_iq_calibrate(Adapter, true); @@ -776,112 +773,50 @@ exit: } static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, - enum rt_rf_power_state eRFPowerState, - int bRegSSPwrLvl) + enum rt_rf_power_state eRFPowerState) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - u8 value8, sps0; - u8 bytetmp; + u8 sps0; sps0 = rtl8723au_read8(Adapter, REG_SPS0_CTRL); switch (eRFPowerState) { case rf_on: - if (bRegSSPwrLvl == 1) { - /* 1. Enable MAC Clock. Can not be enabled now. */ - /* WriteXBYTE(REG_SYS_CLKR+1, - ReadXBYTE(REG_SYS_CLKR+1) | BIT(3)); */ - - /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ - rtl8723au_write8(Adapter, REG_SPS0_CTRL, - sps0 | BIT(0) | BIT(3)); - - /* 3. restore BB, AFE control register. */ - /* RF */ - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x380038, 1); - else - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x38, 1); - PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 1); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 0); - - /* AFE */ - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, - 0x63DB25A0); - else if (pHalData->rf_type == RF_1T1R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, - 0x631B25A0); - - /* 4. issue 3-wire command that RF set to Rx idle - mode. This is used to re-write the RX idle mode. */ - /* We can only prvide a usual value instead and then - HW will modify the value by itself. */ - PHY_SetRFReg(Adapter, RF_PATH_A, 0, - bRFRegOffsetMask, 0x32D95); - if (pHalData->rf_type == RF_2T2R) { - PHY_SetRFReg(Adapter, RF_PATH_B, 0, - bRFRegOffsetMask, 0x32D95); - } - } else { /* Level 2 or others. */ - /* h. AFE_PLL_CTRL 0x28[7:0] = 0x80 - disable AFE PLL */ - rtl8723au_write8(Adapter, REG_AFE_PLL_CTRL, 0x81); - - /* i. AFE_XTAL_CTRL 0x24[15:0] = 0x880F - gated AFE DIG_CLOCK */ - rtl8723au_write16(Adapter, REG_AFE_XTAL_CTRL, 0x800F); - mdelay(1); - - /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ - rtl8723au_write8(Adapter, REG_SPS0_CTRL, - sps0 | BIT(0) | BIT(3)); - - /* 3. restore BB, AFE control register. */ - /* RF */ - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x380038, 1); - else - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x38, 1); - PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 1); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 0); - - /* AFE */ - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, - bMaskDWord, 0x63DB25A0); - else if (pHalData->rf_type == RF_1T1R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, - bMaskDWord, 0x631B25A0); - - /* 4. issue 3-wire command that RF set to Rx idle - mode. This is used to re-write the RX idle mode. */ - /* We can only prvide a usual value instead and - then HW will modify the value by itself. */ - PHY_SetRFReg(Adapter, RF_PATH_A, 0, + /* 1. Enable MAC Clock. Can not be enabled now. */ + /* WriteXBYTE(REG_SYS_CLKR+1, + ReadXBYTE(REG_SYS_CLKR+1) | BIT(3)); */ + + /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ + rtl8723au_write8(Adapter, REG_SPS0_CTRL, + sps0 | BIT(0) | BIT(3)); + + /* 3. restore BB, AFE control register. */ + /* RF */ + if (pHalData->rf_type == RF_2T2R) + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, + 0x380038, 1); + else + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, + 0x38, 1); + PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 1); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 0); + + /* AFE */ + if (pHalData->rf_type == RF_2T2R) + PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, + 0x63DB25A0); + else if (pHalData->rf_type == RF_1T1R) + PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, + 0x631B25A0); + + /* 4. issue 3-wire command that RF set to Rx idle + mode. This is used to re-write the RX idle mode. */ + /* We can only prvide a usual value instead and then + HW will modify the value by itself. */ + PHY_SetRFReg(Adapter, RF_PATH_A, 0, bRFRegOffsetMask, 0x32D95); + if (pHalData->rf_type == RF_2T2R) { + PHY_SetRFReg(Adapter, RF_PATH_B, 0, bRFRegOffsetMask, 0x32D95); - if (pHalData->rf_type == RF_2T2R) { - PHY_SetRFReg(Adapter, RF_PATH_B, 0, - bRFRegOffsetMask, 0x32D95); - } - - /* 5. gated MAC Clock */ - bytetmp = rtl8723au_read8(Adapter, REG_APSD_CTRL); - rtl8723au_write8(Adapter, REG_APSD_CTRL, - bytetmp & ~BIT(6)); - - mdelay(10); - - /* Set BB reset at first */ - /* 0x16 */ - rtl8723au_write8(Adapter, REG_SYS_FUNC_EN, 0x17); - - /* Enable TX */ - rtl8723au_write8(Adapter, REG_TXPAUSE, 0x0); } break; case rf_sleep: @@ -890,146 +825,57 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, sps0 &= ~BIT(0); else sps0 &= ~(BIT(0) | BIT(3)); - if (bRegSSPwrLvl == 1) { - RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL1\n")); - /* Disable RF and BB only for SelectSuspend. */ - - /* 1. Set BB/RF to shutdown. */ - /* (1) Reg878[5:3]= 0 RF rx_code for - preamble power saving */ - /* (2)Reg878[21:19]= 0 Turn off RF-B */ - /* (3) RegC04[7:4]= 0 Turn off all paths - for packet detection */ - /* (4) Reg800[1] = 1 enable preamble power - saving */ - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF0] = - PHY_QueryBBReg(Adapter, rFPGA0_XAB_RFParameter, - bMaskDWord); - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF1] = - PHY_QueryBBReg(Adapter, rOFDM0_TRxPathEnable, - bMaskDWord); - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF2] = - PHY_QueryBBReg(Adapter, rFPGA0_RFMOD, - bMaskDWord); - if (pHalData->rf_type == RF_2T2R) { - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x380038, 0); - } else if (pHalData->rf_type == RF_1T1R) { - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x38, 0); - } - PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 0); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 1); - - /* 2 .AFE control register to power down. bit[30:22] */ - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_AFE0] = - PHY_QueryBBReg(Adapter, rRx_Wait_CCA, - bMaskDWord); - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, - 0x00DB25A0); - else if (pHalData->rf_type == RF_1T1R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, - 0x001B25A0); - - /* 3. issue 3-wire command that RF set to power down.*/ - PHY_SetRFReg(Adapter, RF_PATH_A, 0, bRFRegOffsetMask, 0); - if (pHalData->rf_type == RF_2T2R) - PHY_SetRFReg(Adapter, RF_PATH_B, 0, - bRFRegOffsetMask, 0); - - /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ - rtl8723au_write8(Adapter, REG_SPS0_CTRL, sps0); - } else { /* Level 2 or others. */ - RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL2\n")); - { - u8 eRFPath = RF_PATH_A, value8 = 0; - rtl8723au_write8(Adapter, REG_TXPAUSE, 0xFF); - PHY_SetRFReg(Adapter, - (enum RF_RADIO_PATH)eRFPath, - 0x0, bMaskByte0, 0x0); - value8 |= APSDOFF; - /* 0x40 */ - rtl8723au_write8(Adapter, REG_APSD_CTRL, - value8); - - /* After switch APSD, we need to delay - for stability */ - mdelay(10); - - /* Set BB reset at first */ - value8 = 0; - value8 |= (FEN_USBD | FEN_USBA | - FEN_BB_GLB_RSTn); - /* 0x16 */ - rtl8723au_write8(Adapter, REG_SYS_FUNC_EN, - value8); - } - - /* Disable RF and BB only for SelectSuspend. */ - - /* 1. Set BB/RF to shutdown. */ - /* (1) Reg878[5:3]= 0 RF rx_code for - preamble power saving */ - /* (2)Reg878[21:19]= 0 Turn off RF-B */ - /* (3) RegC04[7:4]= 0 Turn off all paths for - packet detection */ - /* (4) Reg800[1] = 1 enable preamble power - saving */ - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF0] = - PHY_QueryBBReg(Adapter, rFPGA0_XAB_RFParameter, - bMaskDWord); - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF1] = - PHY_QueryBBReg(Adapter, rOFDM0_TRxPathEnable, - bMaskDWord); - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF2] = - PHY_QueryBBReg(Adapter, rFPGA0_RFMOD, - bMaskDWord); - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x380038, 0); - else if (pHalData->rf_type == RF_1T1R) - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, - 0x38, 0); - PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 0); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 1); - - /* 2 .AFE control register to power down. bit[30:22] */ - Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_AFE0] = - PHY_QueryBBReg(Adapter, rRx_Wait_CCA, - bMaskDWord); - if (pHalData->rf_type == RF_2T2R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, - 0x00DB25A0); - else if (pHalData->rf_type == RF_1T1R) - PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, - 0x001B25A0); - - /* 3. issue 3-wire command that RF set to power down. */ - PHY_SetRFReg(Adapter, RF_PATH_A, 0, bRFRegOffsetMask, 0); - if (pHalData->rf_type == RF_2T2R) - PHY_SetRFReg(Adapter, RF_PATH_B, 0, - bRFRegOffsetMask, 0); - - /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ - rtl8723au_write8(Adapter, REG_SPS0_CTRL, sps0); - - /* 2010/10/13 MH/Isaachsu exchange sequence. */ - /* h. AFE_PLL_CTRL 0x28[7:0] = 0x80 - disable AFE PLL */ - rtl8723au_write8(Adapter, REG_AFE_PLL_CTRL, 0x80); - mdelay(1); - - /* i. AFE_XTAL_CTRL 0x24[15:0] = 0x880F - gated AFE DIG_CLOCK */ - rtl8723au_write16(Adapter, REG_AFE_XTAL_CTRL, 0xA80F); + + RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL1\n")); + /* Disable RF and BB only for SelectSuspend. */ + + /* 1. Set BB/RF to shutdown. */ + /* (1) Reg878[5:3]= 0 RF rx_code for + preamble power saving */ + /* (2)Reg878[21:19]= 0 Turn off RF-B */ + /* (3) RegC04[7:4]= 0 Turn off all paths + for packet detection */ + /* (4) Reg800[1] = 1 enable preamble power saving */ + Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF0] = + PHY_QueryBBReg(Adapter, rFPGA0_XAB_RFParameter, + bMaskDWord); + Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF1] = + PHY_QueryBBReg(Adapter, rOFDM0_TRxPathEnable, + bMaskDWord); + Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF2] = + PHY_QueryBBReg(Adapter, rFPGA0_RFMOD, bMaskDWord); + if (pHalData->rf_type == RF_2T2R) { + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, + 0x380038, 0); + } else if (pHalData->rf_type == RF_1T1R) { + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, 0x38, 0); } + PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 0); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 1); + + /* 2 .AFE control register to power down. bit[30:22] */ + Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_AFE0] = + PHY_QueryBBReg(Adapter, rRx_Wait_CCA, bMaskDWord); + if (pHalData->rf_type == RF_2T2R) + PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, + 0x00DB25A0); + else if (pHalData->rf_type == RF_1T1R) + PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord, + 0x001B25A0); + + /* 3. issue 3-wire command that RF set to power down.*/ + PHY_SetRFReg(Adapter, RF_PATH_A, 0, bRFRegOffsetMask, 0); + if (pHalData->rf_type == RF_2T2R) + PHY_SetRFReg(Adapter, RF_PATH_B, 0, + bRFRegOffsetMask, 0); + + /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ + rtl8723au_write8(Adapter, REG_SPS0_CTRL, sps0); break; default: break; } - -} /* phy_PowerSwitch92CU */ +} static void CardDisableRTL8723U(struct rtw_adapter *Adapter) { -- cgit v1.2.3-59-g8ed1b From 4405ef40f2c2f5fbd266dcf117f7747b63cdef08 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:07 -0500 Subject: staging: rtl8723au: Use a local variable to state if MAC was already powered on Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 15 ++++++++------- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 -- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 4cfa2f765c9f..c23bd48f11e1 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -500,12 +500,13 @@ enum rt_rf_power_state RfOnOffDetect23a(struct rtw_adapter *pAdapter) int rtl8723au_hal_init(struct rtw_adapter *Adapter) { - u8 val8 = 0; - u32 boundary; - int status = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u8 val8 = 0; + u32 boundary; + int status = _SUCCESS; + bool mac_on; unsigned long init_start_time = jiffies; @@ -535,9 +536,9 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter) /* 0x100 value of first mac is 0xEA while 0x100 value of secondary is 0x00 */ if (val8 == 0xEA) { - pHalData->bMACFuncEnable = false; + mac_on = false; } else { - pHalData->bMACFuncEnable = true; + mac_on = true; RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("%s: MAC has already power on\n", __func__)); } @@ -556,7 +557,7 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter) boundary = WMM_NORMAL_TX_PAGE_BOUNDARY; } - if (!pHalData->bMACFuncEnable) { + if (!mac_on) { status = InitLLTTable23a(Adapter, boundary); if (status == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, @@ -642,7 +643,7 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter) pHalData->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum RF_RADIO_PATH)0, RF_CHNLBW, bRFRegOffsetMask); pHalData->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum RF_RADIO_PATH)1, RF_CHNLBW, bRFRegOffsetMask); - if (!pHalData->bMACFuncEnable) { + if (!mac_on) { _InitQueueReservedPage(Adapter); _InitTxBufferBoundary(Adapter); } diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 5a70f2fd3ead..49f745345376 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -402,8 +402,6 @@ struct hal_data_8723a { * 2011/02/23 MH Add for 8723 mylti function definition. The define should be moved to an */ /* independent file in the future. */ - bool bMACFuncEnable; - /* Interrupt related register information. */ u32 IntArray[2]; u32 IntrMask[2]; -- cgit v1.2.3-59-g8ed1b From b1f43bd3e0e8a27a6610542698a82c0784729d24 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:08 -0500 Subject: staging: rtl8723au: rtl8723au_read_port() addr argument wasn't used Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 3 +-- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 19 ++++++++----------- drivers/staging/rtl8723au/include/rtl8723a_recv.h | 1 - drivers/staging/rtl8723au/include/usb_ops_linux.h | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index c23bd48f11e1..b1daf7b1a504 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -952,8 +952,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (rtl8723au_read_port(Adapter, RECV_BULK_IN_ADDR, 0, - precvbuf) == _FAIL) { + if (rtl8723au_read_port(Adapter, 0, precvbuf) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index c1b04c13c392..6a23b931443d 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -545,8 +545,7 @@ static void usb_read_port_complete(struct urb *purb) ("usb_read_port_complete: (purb->actual_" "length > MAX_RECVBUF_SZ) || (purb->actual_" "length < RXDESC_SIZE)\n")); - rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, - precvbuf); + rtl8723au_read_port(padapter, 0, precvbuf); DBG_8723A("%s()-%d: RX Warning!\n", __func__, __LINE__); } else { @@ -561,8 +560,7 @@ static void usb_read_port_complete(struct urb *purb) tasklet_schedule(&precvpriv->recv_tasklet); precvbuf->pskb = NULL; - rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, - precvbuf); + rtl8723au_read_port(padapter, 0, precvbuf); } } else { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, @@ -596,8 +594,7 @@ static void usb_read_port_complete(struct urb *purb) break; case -EPROTO: case -EOVERFLOW: - rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, - precvbuf); + rtl8723au_read_port(padapter, 0, precvbuf); break; case -EINPROGRESS: DBG_8723A("ERROR: URB IS IN PROGRESS!\n"); @@ -608,18 +605,18 @@ static void usb_read_port_complete(struct urb *purb) } } -int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, +int rtl8723au_read_port(struct rtw_adapter *adapter, u32 cnt, struct recv_buf *precvbuf) { + struct urb *purb; + struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); + struct recv_priv *precvpriv = &adapter->recvpriv; + struct usb_device *pusbd = pdvobj->pusbdev; int err; unsigned int pipe; unsigned long tmpaddr; unsigned long alignment; int ret = _SUCCESS; - struct urb *purb; - struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); - struct recv_priv *precvpriv = &adapter->recvpriv; - struct usb_device *pusbd = pdvobj->pusbdev; if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, diff --git a/drivers/staging/rtl8723au/include/rtl8723a_recv.h b/drivers/staging/rtl8723au/include/rtl8723a_recv.h index 0109052a4fbb..cff9b4b111d0 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_recv.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_recv.h @@ -28,7 +28,6 @@ #define MAX_RECVBUF_SZ 15360 /* 15k < 16k */ -#define RECV_BULK_IN_ADDR 0x80 #define RECV_INT_IN_ADDR 0x81 #define PHY_RSSI_SLID_WIN_MAX 100 diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index bf68bbb41f9c..0494087cff5a 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -21,7 +21,7 @@ #define MAX_USBCTRL_VENDORREQ_TIMES 10 -int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, +int rtl8723au_read_port(struct rtw_adapter *adapter, u32 cnt, struct recv_buf *precvbuf); void rtl8723au_read_port_cancel(struct rtw_adapter *padapter); int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, -- cgit v1.2.3-59-g8ed1b From c6419a6d79eb176d053f66ebc14d745531b2ece8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:09 -0500 Subject: staging: rtl8723au: rtl8723au_read_interrupt() addr argument wasn't used Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 4 ++-- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 2 +- drivers/staging/rtl8723au/include/rtl8723a_recv.h | 2 -- drivers/staging/rtl8723au/include/usb_ops_linux.h | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index b1daf7b1a504..2c2d6b542e65 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -960,9 +960,9 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) } precvbuf++; } - if (rtl8723au_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) { + if (rtl8723au_read_interrupt(Adapter) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, - ("usb_rx_init: usb_read_interrupt error\n")); + ("%s: usb_read_interrupt error\n", __func__)); status = _FAIL; } pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR); diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 6a23b931443d..a6d16adce107 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -317,7 +317,7 @@ urb_submit: } } -int rtl8723au_read_interrupt(struct rtw_adapter *adapter, u32 addr) +int rtl8723au_read_interrupt(struct rtw_adapter *adapter) { int err; unsigned int pipe; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_recv.h b/drivers/staging/rtl8723au/include/rtl8723a_recv.h index cff9b4b111d0..0177bbc1c1cf 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_recv.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_recv.h @@ -28,8 +28,6 @@ #define MAX_RECVBUF_SZ 15360 /* 15k < 16k */ -#define RECV_INT_IN_ADDR 0x81 - #define PHY_RSSI_SLID_WIN_MAX 100 #define PHY_LINKQUALITY_SLID_WIN_MAX 20 diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 0494087cff5a..af2f14b8b360 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -27,7 +27,7 @@ void rtl8723au_read_port_cancel(struct rtw_adapter *padapter); int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct xmit_buf *pxmitbuf); void rtl8723au_write_port_cancel(struct rtw_adapter *padapter); -int rtl8723au_read_interrupt(struct rtw_adapter *adapter, u32 addr); +int rtl8723au_read_interrupt(struct rtw_adapter *adapter); u8 rtl8723au_read8(struct rtw_adapter *padapter, u16 addr); u16 rtl8723au_read16(struct rtw_adapter *padapter, u16 addr); -- cgit v1.2.3-59-g8ed1b From 525bb5e73447ba6c7742f5f6b9005dcadb28b4d9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:10 -0500 Subject: staging: rtl8723au: Remove unused slimcombo debug flag Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 11 ----------- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 4 ---- 2 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 2c2d6b542e65..b15edc920b78 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1107,13 +1107,6 @@ static void _ReadRFType(struct rtw_adapter *Adapter) pHalData->rf_chip = RF_6052; } -static void _ReadSilmComboMode(struct rtw_adapter *Adapter) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - - pHalData->SlimComboDbg = false; /* Default is not debug mode. */ -} - /* */ /* Description: */ /* We should set Efuse cell selection to WiFi cell in default. */ @@ -1146,10 +1139,6 @@ void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter) _ReadRFType(Adapter);/* rf_chip -> _InitRFType() */ _ReadPROMContent(Adapter); - /* 2010/10/25 MH THe function must be called after - borad_type & IC-Version recognize. */ - _ReadSilmComboMode(Adapter); - /* MSG_8723A("%s()(done), rf_chip = 0x%x, rf_type = 0x%x\n", __func__, pHalData->rf_chip, pHalData->rf_type); */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 49f745345376..e14633678b52 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -375,10 +375,6 @@ struct hal_data_8723a { u8 OutEpQueueSel; u8 OutEpNumber; - /* 2010/11/22 MH Add for slim combo debug mode selective. */ - /* This is used for fix the drawback of CU TSMC-A/UMC-A cut. HW auto suspend ability. Close BT clock. */ - bool SlimComboDbg; - /* */ /* Add For EEPROM Efuse switch and Efuse Shadow map Setting */ /* */ -- cgit v1.2.3-59-g8ed1b From 36318bdc0b077a56034707efc50b7143e1326f41 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:11 -0500 Subject: staging: rtl8723au: rtl8723a_update_ramask(): Fix up some bad formatting Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index b15edc920b78..febe5cedef8f 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1202,17 +1202,17 @@ int GetHalDefVar8192CUsb(struct rtw_adapter *Adapter, void rtl8723a_update_ramask(struct rtw_adapter *padapter, u32 mac_id, u8 rssi_level) { - u8 init_rate = 0; - u8 networkType, raid; - u32 mask, rate_bitmap; - u8 shortGIrate = false; - int supportRateNum = 0; struct sta_info *psta; - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; + struct FW_Sta_Info *fw_sta; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + u8 init_rate, networkType, raid; + u32 mask, rate_bitmap; + u8 shortGIrate = false; + int supportRateNum; if (mac_id >= NUM_STA) /* CAM_SIZE */ return; @@ -1241,8 +1241,8 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, break; case 1:/* for broadcast/multicast */ - supportRateNum = rtw_get_rateset_len23a( - pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + fw_sta = &pmlmeinfo->FW_sta_info[mac_id]; + supportRateNum = rtw_get_rateset_len23a(fw_sta->SupportedRates); if (pmlmeext->cur_wireless_mode & WIRELESS_11B) networkType = WIRELESS_11B; else @@ -1254,16 +1254,16 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, break; default: /* for each sta in IBSS */ - supportRateNum = rtw_get_rateset_len23a( - pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + fw_sta = &pmlmeinfo->FW_sta_info[mac_id]; + supportRateNum = rtw_get_rateset_len23a(fw_sta->SupportedRates); networkType = judge_network_type23a(padapter, - pmlmeinfo->FW_sta_info[mac_id].SupportedRates, - supportRateNum) & 0xf; + fw_sta->SupportedRates, + supportRateNum) & 0xf; /* pmlmeext->cur_wireless_mode = networkType; */ raid = networktype_to_raid23a(networkType); mask = update_supported_rate23a(cur_network->SupportedRates, - supportRateNum); + supportRateNum); /* todo: support HT in IBSS */ break; @@ -1277,15 +1277,14 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, __func__, mac_id, networkType, mask, rssi_level, rate_bitmap); mask &= rate_bitmap; - mask |= ((raid<<28)&0xf0000000); + mask |= ((raid << 28) & 0xf0000000); - init_rate = get_highest_rate_idx23a(mask)&0x3f; + init_rate = get_highest_rate_idx23a(mask) & 0x3f; if (pHalData->fw_ractrl == true) { u8 arg = 0; - /* arg = (cam_idx-4)&0x1f;MACID */ - arg = mac_id&0x1f;/* MACID */ + arg = mac_id & 0x1f;/* MACID */ arg |= BIT(7); @@ -1300,7 +1299,7 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, if (shortGIrate == true) init_rate |= BIT(6); - rtl8723au_write8(padapter, (REG_INIDATA_RATE_SEL+mac_id), + rtl8723au_write8(padapter, (REG_INIDATA_RATE_SEL + mac_id), init_rate); } -- cgit v1.2.3-59-g8ed1b From 7b78bdc5f89b1bf59df0d7b0360d49bc1d3dff94 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:12 -0500 Subject: staging: rtl8723au: Fold _BlockWrite() into _PageWrite() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 01f1b79c165e..267a80b50630 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -47,29 +47,19 @@ static void _FWDownloadEnable(struct rtw_adapter *padapter, bool enable) } } -static int _BlockWrite(struct rtw_adapter *padapter, void *buffer, u32 buffSize) -{ - int ret; - - if (buffSize > MAX_PAGE_SIZE) - return _FAIL; - - ret = rtl8723au_writeN(padapter, FW_8723A_START_ADDRESS, - buffSize, buffer); - - return ret; -} - static int _PageWrite(struct rtw_adapter *padapter, u32 page, void *buffer, u32 size) { u8 value8; u8 u8Page = (u8) (page & 0x07); + if (size > MAX_PAGE_SIZE) + return _FAIL; + value8 = (rtl8723au_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page; rtl8723au_write8(padapter, REG_MCUFWDL + 2, value8); - return _BlockWrite(padapter, buffer, size); + return rtl8723au_writeN(padapter, FW_8723A_START_ADDRESS, size, buffer); } static int _WriteFW(struct rtw_adapter *padapter, void *buffer, u32 size) -- cgit v1.2.3-59-g8ed1b From b1e111d56b2a3e604b2ffb32322bb5d1a6b9635b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:13 -0500 Subject: staging: rtl8723au: _DisableRFAFEAndResetBB8192C(): Use correct enum value Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 267a80b50630..d2b4fb01d7f3 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1253,11 +1253,11 @@ c. APSD_CTRL 0x600[7:0] = 0x40 d. SYS_FUNC_EN 0x02[7:0] = 0x16 reset BB state machine e. SYS_FUNC_EN 0x02[7:0] = 0x14 reset BB state machine ***************************************/ - u8 eRFPath = 0, value8 = 0; + u8 value8 = 0; rtl8723au_write8(padapter, REG_TXPAUSE, 0xFF); - PHY_SetRFReg(padapter, (enum RF_RADIO_PATH) eRFPath, 0x0, bMaskByte0, 0x0); + PHY_SetRFReg(padapter, RF_PATH_A, 0x0, bMaskByte0, 0x0); value8 |= APSDOFF; rtl8723au_write8(padapter, REG_APSD_CTRL, value8); /* 0x40 */ -- cgit v1.2.3-59-g8ed1b From aba3eb10963857e68d9c1cbc0e6c641263a06cb1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:14 -0500 Subject: staging: rtl8723au: _DisableRFAFEAndResetBB8192C(): Reduce code obfuscation Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d2b4fb01d7f3..3aa20f68e9d5 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1253,18 +1253,17 @@ c. APSD_CTRL 0x600[7:0] = 0x40 d. SYS_FUNC_EN 0x02[7:0] = 0x16 reset BB state machine e. SYS_FUNC_EN 0x02[7:0] = 0x14 reset BB state machine ***************************************/ - u8 value8 = 0; + u8 value8; rtl8723au_write8(padapter, REG_TXPAUSE, 0xFF); PHY_SetRFReg(padapter, RF_PATH_A, 0x0, bMaskByte0, 0x0); - value8 |= APSDOFF; + value8 = APSDOFF; rtl8723au_write8(padapter, REG_APSD_CTRL, value8); /* 0x40 */ /* Set BB reset at first */ - value8 = 0; - value8 |= (FEN_USBD | FEN_USBA | FEN_BB_GLB_RSTn); + value8 = FEN_USBD | FEN_USBA | FEN_BB_GLB_RSTn; rtl8723au_write8(padapter, REG_SYS_FUNC_EN, value8); /* 0x16 */ /* Set global reset. */ -- cgit v1.2.3-59-g8ed1b From 38f36d81465b33383b595ba23ef95985d0306aa7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:15 -0500 Subject: staging: rtl8723au: Remove unnecessary wrapper _DisableRFAFEAndResetBB() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 3aa20f68e9d5..5d2e77422e08 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1276,11 +1276,6 @@ e. SYS_FUNC_EN 0x02[7:0] = 0x14 reset BB state machine /* RT_TRACE(COMP_INIT, DBG_LOUD, ("======> RF off and reset BB.\n")); */ } -static void _DisableRFAFEAndResetBB(struct rtw_adapter *padapter) -{ - _DisableRFAFEAndResetBB8192C(padapter); -} - static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, bool bWithoutHWSM) { @@ -1452,7 +1447,7 @@ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) return _SUCCESS; } /* RF Off Sequence ==== */ - _DisableRFAFEAndResetBB(padapter); + _DisableRFAFEAndResetBB8192C(padapter); /* ==== Reset digital sequence ====== */ _ResetDigitalProcedure1(padapter, false); @@ -1477,7 +1472,7 @@ int CardDisableWithoutHWSM(struct rtw_adapter *padapter) } /* RF Off Sequence ==== */ - _DisableRFAFEAndResetBB(padapter); + _DisableRFAFEAndResetBB8192C(padapter); /* ==== Reset digital sequence ====== */ _ResetDigitalProcedure1(padapter, true); -- cgit v1.2.3-59-g8ed1b From 31b7e846bd22866f8465c27168f574add4d98a93 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:16 -0500 Subject: staging: rtl8723au: _ResetDigitalProcedure1_92C() reduce code obfuscation Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 62 +++++++++++------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 5d2e77422e08..222dcd17ff56 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1289,18 +1289,18 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, i. SYS_FUNC_EN 0x02[10]= 1 enable MCU register, (8051 enable) ******************************/ - u16 valu16 = 0; + u16 valu16; rtl8723au_write8(padapter, REG_MCUFWDL, 0); valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); /* reset MCU , 8051 */ rtl8723au_write16(padapter, REG_SYS_FUNC_EN, - valu16 & (~FEN_CPUEN)); + valu16 & ~FEN_CPUEN); valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN) & 0x0FFF; /* reset MAC */ rtl8723au_write16(padapter, REG_SYS_FUNC_EN, - valu16 | (FEN_HWPDN | FEN_ELDR)); + valu16 | FEN_HWPDN | FEN_ELDR); valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); /* enable MCU , 8051 */ @@ -1308,43 +1308,41 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, valu16 | FEN_CPUEN); } else { u8 retry_cnts = 0; + u8 val8; + + val8 = rtl8723au_read8(padapter, REG_MCUFWDL); /* 2010/08/12 MH For USB SS, we can not stop 8051 when we are trying to enter IPS/HW&SW radio off. For S3/S4/S5/Disable, we can stop 8051 because */ /* we will init FW when power on again. */ /* If we want to SS mode, we can not reset 8051. */ - if (rtl8723au_read8(padapter, REG_MCUFWDL) & BIT(1)) { + if ((val8 & BIT(1)) && padapter->bFWReady) { /* IF fw in RAM code, do reset */ - if (padapter->bFWReady) { - /* 2010/08/25 MH Accordign to RD alfred's - suggestion, we need to disable other */ - /* HRCV INT to influence 8051 reset. */ - rtl8723au_write8(padapter, REG_FWIMR, 0x20); - /* 2011/02/15 MH According to Alex's - suggestion, close mask to prevent - incorrect FW write operation. */ - rtl8723au_write8(padapter, REG_FTIMR, 0x00); - rtl8723au_write8(padapter, REG_FSIMR, 0x00); - - /* 8051 reset by self */ - rtl8723au_write8(padapter, REG_HMETFR + 3, - 0x20); - - while ((retry_cnts++ < 100) && - (FEN_CPUEN & - rtl8723au_read16(padapter, - REG_SYS_FUNC_EN))) { - udelay(50); /* us */ - } + /* 2010/08/25 MH Accordign to RD alfred's + suggestion, we need to disable other */ + /* HRCV INT to influence 8051 reset. */ + rtl8723au_write8(padapter, REG_FWIMR, 0x20); + /* 2011/02/15 MH According to Alex's + suggestion, close mask to prevent + incorrect FW write operation. */ + rtl8723au_write8(padapter, REG_FTIMR, 0x00); + rtl8723au_write8(padapter, REG_FSIMR, 0x00); + + /* 8051 reset by self */ + rtl8723au_write8(padapter, REG_HMETFR + 3, 0x20); + + while ((retry_cnts++ < 100) && + (rtl8723au_read16(padapter, REG_SYS_FUNC_EN) & + FEN_CPUEN)) { + udelay(50); /* us */ + } - if (retry_cnts >= 100) { - /* Reset MAC and Enable 8051 */ - rtl8723au_write8(padapter, - REG_SYS_FUNC_EN + 1, - 0x50); - mdelay(10); - } + if (retry_cnts >= 100) { + /* Reset MAC and Enable 8051 */ + rtl8723au_write8(padapter, + REG_SYS_FUNC_EN + 1, 0x50); + mdelay(10); } } /* Reset MAC and Enable 8051 */ -- cgit v1.2.3-59-g8ed1b From 441272e71d872d3d910cdddd08104a5f216b8ce0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:17 -0500 Subject: staging: rtl8723au: Remove unnecessary wrapper _ResetDigitalProcedure1() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 222dcd17ff56..b2048b60484c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1369,12 +1369,6 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, } } -static void _ResetDigitalProcedure1(struct rtw_adapter *padapter, - bool bWithoutHWSM) -{ - _ResetDigitalProcedure1_92C(padapter, bWithoutHWSM); -} - static void _ResetDigitalProcedure2(struct rtw_adapter *padapter) { /***************************** @@ -1448,7 +1442,7 @@ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) _DisableRFAFEAndResetBB8192C(padapter); /* ==== Reset digital sequence ====== */ - _ResetDigitalProcedure1(padapter, false); + _ResetDigitalProcedure1_92C(padapter, false); /* ==== Pull GPIO PIN to balance level and LED control ====== */ _DisableGPIO(padapter); @@ -1473,7 +1467,7 @@ int CardDisableWithoutHWSM(struct rtw_adapter *padapter) _DisableRFAFEAndResetBB8192C(padapter); /* ==== Reset digital sequence ====== */ - _ResetDigitalProcedure1(padapter, true); + _ResetDigitalProcedure1_92C(padapter, true); /* ==== Pull GPIO PIN to balance level and LED control ====== */ _DisableGPIO(padapter); -- cgit v1.2.3-59-g8ed1b From cffca68d7b2f1b3e6a07e521983d6484be56debf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:18 -0500 Subject: staging: rtl8723au: _DisableAnalog(): Avoid zero-init variables unnecessarily Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index b2048b60484c..2e1d194f600c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1385,8 +1385,8 @@ m. SYS_ISO_CTRL 0x01[7:0] = 0x83 isolated ELDR to PON static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - u16 value16 = 0; - u8 value8 = 0; + u16 value16; + u8 value8; if (bWithoutHWSM) { /***************************** @@ -1400,7 +1400,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) /* rtl8723au_write8(padapter, REG_LDOV12D_CTRL, 0x54); */ value8 = rtl8723au_read8(padapter, REG_LDOV12D_CTRL); - value8 &= (~LDV12_EN); + value8 &= ~LDV12_EN; rtl8723au_write8(padapter, REG_LDOV12D_CTRL, value8); /* RT_TRACE(COMP_INIT, DBG_LOUD, (" REG_LDOV12D_CTRL Reg0x21:0x%02x.\n", value8)); */ @@ -1422,9 +1422,9 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) use HW to shut down 8051 automatically. */ /* Becasue suspend operatione need the asistance of 8051 to wait for 3ms. */ - value16 |= (APDM_HOST | AFSM_HSUS | PFM_ALDN); + value16 = APDM_HOST | AFSM_HSUS | PFM_ALDN; } else { - value16 |= (APDM_HOST | AFSM_HSUS | PFM_ALDN); + value16 = APDM_HOST | AFSM_HSUS | PFM_ALDN; } rtl8723au_write16(padapter, REG_APS_FSMCO, value16); /* 0x4802 */ -- cgit v1.2.3-59-g8ed1b From 315f9a2fe237c81535695005592eb7c586f3181e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 30 Nov 2014 16:05:19 -0500 Subject: staging: rtl8723au: Hal_InitPGData() avoid unnecessary typecasts Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 2e1d194f600c..a5eadd4e2580 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1487,22 +1487,20 @@ void Hal_InitPGData(struct rtw_adapter *padapter, u8 *PROMContent) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - if (false == pEEPROM->bautoload_fail_flag) { /* autoload OK. */ + if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */ if (!pEEPROM->EepromOrEfuse) { /* Read EFUSE real map to shadow. */ EFUSE_ShadowMapUpdate23a(padapter, EFUSE_WIFI); - memcpy((void *)PROMContent, - (void *)pEEPROM->efuse_eeprom_data, + memcpy(PROMContent, pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE); } - } else { /* autoload fail */ + } else { RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); -/* pHalData->AutoloadFailFlag = true; */ /* update to default value 0xFF */ - if (false == pEEPROM->EepromOrEfuse) + if (!pEEPROM->EepromOrEfuse) EFUSE_ShadowMapUpdate23a(padapter, EFUSE_WIFI); - memcpy((void *)PROMContent, (void *)pEEPROM->efuse_eeprom_data, + memcpy(PROMContent, pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE); } } -- cgit v1.2.3-59-g8ed1b From 5f18611038f9c9d503318490069b730c942523f8 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Sat, 29 Nov 2014 17:48:34 -0500 Subject: staging: clocking-wizard: check for a valid clk_name pointer The clk_name gets the return value from kasprintf (part of which does the allocation of the returned buffer). So check the return pointer before using it for clk_register_fixed_factor. Signed-off-by: Devendra Naga Reviewed-by: Soren Brinkmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c index 7202d8e889aa..0a3a8fe67fb5 100644 --- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c +++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c @@ -221,6 +221,11 @@ static int clk_wzrd_probe(struct platform_device *pdev) reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) & WZRD_DIVCLK_DIVIDE_MASK) >> WZRD_DIVCLK_DIVIDE_SHIFT; clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev)); + if (!clk_name) { + ret = -ENOMEM; + goto err_rm_int_clk; + } + clk_wzrd->clks_internal[wzrd_clk_mul_div] = clk_register_fixed_factor( &pdev->dev, clk_name, __clk_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]), -- cgit v1.2.3-59-g8ed1b From e66f7a27521119ccd76e91ebf5f8084c51285581 Mon Sep 17 00:00:00 2001 From: Athira Sharikkal Date: Sun, 30 Nov 2014 14:16:05 +0530 Subject: Drivers:staging:clocking-wizard: Added a newline Fixed checkpatch warning: Missing a newline after declarations Signed-off-by: Athira Sharikkal Acked-by: Soren Brinkmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c index 0a3a8fe67fb5..471d0877f382 100644 --- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c +++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c @@ -253,6 +253,7 @@ static int clk_wzrd_probe(struct platform_device *pdev) clkout_name, clk_name, 0, 1, reg); if (IS_ERR(clk_wzrd->clkout[i])) { int j; + for (j = i + 1; j < WZRD_NUM_OUTPUTS; j++) clk_unregister(clk_wzrd->clkout[j]); dev_err(&pdev->dev, -- cgit v1.2.3-59-g8ed1b From 73df998683eaddffca8c29ea74a339abac68e939 Mon Sep 17 00:00:00 2001 From: Athira Lekshmi Date: Fri, 28 Nov 2014 18:26:13 +0530 Subject: Drivers:staging:rtl8192e: Fixed checkpatch warning Fixed checkpatch warning: WARNING: space prohibited before semicolon Signed-off-by: Athira Lekshmi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index ca76ad013f5f..cf11b042b93a 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -2687,7 +2687,7 @@ void rtllib_rx_mgt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *stats) { - struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; + struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data; if ((WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) != RTLLIB_STYPE_PROBE_RESP) && -- cgit v1.2.3-59-g8ed1b From 3ec16e93d84333c52527042ea5f5911bc8c2591e Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Wed, 3 Dec 2014 06:29:12 +0800 Subject: drivers: staging: rtl8192e: Include "asm/unaligned.h" instead of "access_ok.h" in "rtl819x_BAProc.c" "asm/unaligned.h" is more generic than "access_ok.h", and it may include "access_ok.h", so need use it instead of "access_ok.h". During building, "rtllib.h" has already include "asm/unaligned.h", so will cause building issue. The related error (with allmodconfig under parisc): CC [M] drivers/staging/rtl8192e/rtl819x_BAProc.o In file included from ./arch/parisc/include/asm/unaligned.h:4:0, from include/linux/ieee80211.h:22, from include/net/lib80211.h:31, from drivers/staging/rtl8192e/rtllib.h:45, from drivers/staging/rtl8192e/rtl819x_BAProc.c:20: include/linux/unaligned/be_struct.h:6:19: error: redefinition of 'get_unaligned_be16' static inline u16 get_unaligned_be16(const void *p) ^ In file included from drivers/staging/rtl8192e/rtl819x_BAProc.c:19:0: include/linux/unaligned/access_ok.h:22:19: note: previous definition of 'get_unaligned_be16' was here static inline u16 get_unaligned_be16(const void *p) ^ ... For independent from other include files, still suggest it includes "asm/unaligned.h" too. And also include "asm/byteorder.h" since it is the first include file". Signed-off-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 66ea79198892..0415e02b4eff 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -16,7 +16,8 @@ * Contact Information: * wlanfae ******************************************************************************/ -#include +#include +#include #include "rtllib.h" #include "rtl819x_BA.h" -- cgit v1.2.3-59-g8ed1b From 0a005d59c04551bfdcc53b2a71473d603d62d066 Mon Sep 17 00:00:00 2001 From: Geoff Darst Date: Sat, 29 Nov 2014 13:17:22 -0700 Subject: staging: ft1000 : replace __attribute ((__packed__) with __packed Replace two instances of __attribute ((__packed__) with __packed macro to address the warning found by the checkpatch.pl tool. Signed-off-by: Geoff Darst Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c index 115005061765..06b0e9cfb9b1 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c @@ -101,7 +101,7 @@ struct dsp_file_hdr { u32 version_data_offset; /* Offset were scrambled version data begins. */ u32 version_data_size; /* Size, in words, of scrambled version data. */ u32 nDspImages; /* Number of DSP images in file. */ -} __attribute__ ((packed)); +} __packed; struct dsp_image_info { u32 coff_date; /* Date/time when DSP Coff image was built. */ @@ -112,7 +112,7 @@ struct dsp_image_info { u32 version; /* Embedded version # of DSP code. */ unsigned short checksum; /* Dsp File checksum */ unsigned short pad1; -} __attribute__ ((packed)); +} __packed; void card_bootload(struct net_device *dev) { -- cgit v1.2.3-59-g8ed1b From bd0f483c873725148c8a54f58f174507a74c4815 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 30 Nov 2014 19:14:14 +0100 Subject: staging: unisys: remove unneeded structure Delete a local structure that is only used to be initialized by memset. A semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ identifier x,i; @@ { ... when any -struct i x; <+... when != x - memset(&x,...); ...+> } // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/visorchipset_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index c8f7beaac87a..7e6be32cf7bb 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1940,7 +1940,6 @@ static HOSTADDRESS controlvm_get_channel_address(void) static void controlvm_periodic_work(struct work_struct *work) { - struct visorchipset_channel_info chanInfo; struct controlvm_message inmsg; BOOL gotACommand = FALSE; BOOL handle_command_failed = FALSE; @@ -1955,8 +1954,6 @@ controlvm_periodic_work(struct work_struct *work) if (visorchipset_clientregwait && !clientregistered) goto Away; - memset(&chanInfo, 0, sizeof(struct visorchipset_channel_info)); - Poll_Count++; if (Poll_Count >= 250) ; /* keep going */ -- cgit v1.2.3-59-g8ed1b From d10dc6b3bb4dbf5626dcb7e28d75f590132f413e Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 2 Dec 2014 16:20:14 +0530 Subject: staging: unisys: remove duplicate header these header files were included multiple times Signed-off-by: Sudip Mukherjee Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/timskmod.h | 1 - drivers/staging/unisys/uislib/uisutils.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index de11f440e1e3..cff7983dab85 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index a8466e30c22a..4a5b86773927 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -25,9 +25,7 @@ #include "uisutils.h" #include "version.h" #include "vbushelper.h" -#include #include -#include #ifdef CONFIG_HIGHMEM #include #endif -- cgit v1.2.3-59-g8ed1b From 60ebee3bcf804a15229d71ac571c05f9f5e9e818 Mon Sep 17 00:00:00 2001 From: Janet Liu Date: Sun, 30 Nov 2014 18:08:10 +0800 Subject: staging: lustre: fixed sparse warnings related to static declarations drivers/staging/lustre/lustre/mdc/mdc_request.c:63:5: warning: symbol 'mdc_unpack_capa' was not declared. Should it be static? drivers/staging/lustre/lustre/mdc/mdc_request.c:150:5: warning: symbol 'mdc_getstatus' was not declared. Should it be static? drivers/staging/lustre/lustre/mdc/mdc_request.c:217:5: warning: symbol 'mdc_getattr' was not declared. Should it be static? drivers/staging/lustre/lustre/mdc/mdc_request.c:261:5: warning: symbol 'mdc_getattr_name' was not declared. Should it be static? drivers/staging/lustre/lustre/mdc/mdc_request.c:444:5: warning: symbol 'mdc_setxattr' was not declared. Should it be static? drivers/staging/lustre/lustre/mdc/mdc_request.c:455:5: warning: symbol 'mdc_getxattr' was not declared. Should it be static? Signed-off-by: Janet Liu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_request.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 14e1ba1675f6..3b0f245a8780 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -60,7 +60,7 @@ struct mdc_renew_capa_args { static int mdc_cleanup(struct obd_device *obd); -int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, +static int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, const struct req_msg_field *field, struct obd_capa **oc) { struct lustre_capa *capa; @@ -147,7 +147,7 @@ out: } /* This should be mdc_get_info("rootfid") */ -int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid, +static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid, struct obd_capa **pc) { return send_getstatus(class_exp2cliimp(exp), rootfid, pc, @@ -214,7 +214,7 @@ static int mdc_getattr_common(struct obd_export *exp, return 0; } -int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, +static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { struct ptlrpc_request *req; @@ -258,7 +258,7 @@ int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, return rc; } -int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, +static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { struct ptlrpc_request *req; @@ -441,7 +441,7 @@ static int mdc_xattr_common(struct obd_export *exp, return rc; } -int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid, +static int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, u64 valid, const char *xattr_name, const char *input, int input_size, int output_size, int flags, __u32 suppgid, struct ptlrpc_request **request) @@ -452,7 +452,7 @@ int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid, suppgid, request); } -int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid, +static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, u64 valid, const char *xattr_name, const char *input, int input_size, int output_size, int flags, struct ptlrpc_request **request) -- cgit v1.2.3-59-g8ed1b From 450b31a9d0a601c78995ea0f9cefd07b05a8dc34 Mon Sep 17 00:00:00 2001 From: Vincenzo Scotti Date: Mon, 1 Dec 2014 00:10:26 +0100 Subject: staging: lustre: fix sparse warnings: static function declaration Signed-off-by: Vincenzo Scotti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 252f3e13d04a..dc5ceb55d001 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -1999,7 +1999,7 @@ static void *__req_capsule_get(struct req_capsule *pill, /** * Dump a request and/or reply */ -void __req_capsule_dump(struct req_capsule *pill, enum req_location loc) +static void __req_capsule_dump(struct req_capsule *pill, enum req_location loc) { const struct req_format *fmt; const struct req_msg_field *field; -- cgit v1.2.3-59-g8ed1b From 13cb076d3057e0c4b26acb0ee5e5d6ea9b5131c0 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 2 Dec 2014 11:40:33 +0100 Subject: lustre: Deletion of unnecessary checks before three function calls The functions free_ll_remote_perm(), free_rmtperm_hash() and iput() test whether their argument is NULL and then return immediately. Thus the test around their calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/remote_perm.c | 5 ++--- drivers/staging/lustre/lustre/llite/statahead.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index c05a9126cfe3..a58182600dae 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -194,7 +194,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) if (!lli->lli_remote_perms) lli->lli_remote_perms = perm_hash; - else if (perm_hash) + else free_rmtperm_hash(perm_hash); head = lli->lli_remote_perms + remote_perm_hashfunc(perm->rp_uid); @@ -209,8 +209,7 @@ again: continue; if (tmp->lrp_fsgid != perm->rp_fsgid) continue; - if (lrp) - free_ll_remote_perm(lrp); + free_ll_remote_perm(lrp); lrp = tmp; break; } diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index c4bd09edb0ce..db2bb44cdce5 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -334,8 +334,7 @@ static void ll_sa_entry_put(struct ll_statahead_info *sai, LASSERT(ll_sa_entry_unhashed(entry)); ll_sa_entry_cleanup(sai, entry); - if (entry->se_inode) - iput(entry->se_inode); + iput(entry->se_inode); OBD_FREE(entry, entry->se_size); atomic_dec(&sai->sai_cache_count); -- cgit v1.2.3-59-g8ed1b From 5b53672bbc410e20cda96d045a3372d6212fc3bc Mon Sep 17 00:00:00 2001 From: Anjana Sasindran Date: Sun, 30 Nov 2014 23:03:37 +0530 Subject: staging: rtl8723au: hal: Removed the extra semicolon This patch fix the checkpatch.pl warning: WARNING: Statement terminations use 1 semicolon Signed-off-by: Anjana Sasindran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 78665eec3c1d..86a83975f4f0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -10639,7 +10639,7 @@ void BTDM_BBBackOffLevel(struct rtw_adapter *padapter, u8 type) void BTDM_FWCoexAllOff(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); RTPRINT(FBT, BT_TRACE, ("BTDM_FWCoexAllOff()\n")); if (pHalData->bt_coexist.bFWCoexistAllOff) @@ -10653,7 +10653,7 @@ void BTDM_FWCoexAllOff(struct rtw_adapter *padapter) void BTDM_SWCoexAllOff(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); RTPRINT(FBT, BT_TRACE, ("BTDM_SWCoexAllOff()\n")); if (pHalData->bt_coexist.bSWCoexistAllOff) @@ -10666,7 +10666,7 @@ void BTDM_SWCoexAllOff(struct rtw_adapter *padapter) void BTDM_HWCoexAllOff(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); RTPRINT(FBT, BT_TRACE, ("BTDM_HWCoexAllOff()\n")); if (pHalData->bt_coexist.bHWCoexistAllOff) -- cgit v1.2.3-59-g8ed1b From 6c410db7c4305da28107f8b2b650ffe7d010aed1 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sun, 30 Nov 2014 23:05:56 -0600 Subject: staging: comedi: change some printk calls to pr_err There are a handful of calls to printk in ni_stc.h without specified log levels, as well as one in ni_mio_common.c. This patch converts these calls to pr_err() instead, so that they are now explicitly log level ERR. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 353c17bb4325..11e70173712d 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3945,7 +3945,7 @@ static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg) stc_register = Interrupt_B_Enable_Register; break; default: - printk("%s: unhandled register 0x%x in switch.\n", + pr_err("%s: unhandled register 0x%x in switch.\n", __func__, reg); BUG(); return 0; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 131e9049f21b..bd69c3f0acdc 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -334,7 +334,7 @@ static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries) max_channel = 6; } if (channel > max_channel) { - printk("%s: bug, invalid RTSI_channel=%i\n", __func__, channel); + pr_err("%s: bug, invalid RTSI_channel=%i\n", __func__, channel); return 0; } return 1 << (base_bit_shift + channel); @@ -1090,7 +1090,7 @@ static inline int M_Offset_Static_AI_Control(int i) 0x263, }; if (((unsigned)i) >= ARRAY_SIZE(offset)) { - printk("%s: invalid channel=%i\n", __func__, i); + pr_err("%s: invalid channel=%i\n", __func__, i); return offset[0]; } return offset[i]; @@ -1105,7 +1105,7 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel) 0x267 }; if (((unsigned)channel) >= ARRAY_SIZE(offset)) { - printk("%s: invalid channel=%i\n", __func__, channel); + pr_err("%s: invalid channel=%i\n", __func__, channel); return offset[0]; } return offset[channel]; @@ -1114,7 +1114,7 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel) static inline unsigned M_Offset_PFI_Output_Select(unsigned n) { if (n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS) { - printk("%s: invalid pfi output select register=%i\n", + pr_err("%s: invalid pfi output select register=%i\n", __func__, n); return M_Offset_PFI_Output_Select_1; } @@ -1171,7 +1171,7 @@ static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned RTSI_channel) { if (RTSI_channel > 7) { - printk("%s: bug, invalid RTSI_channel=%i\n", __func__, + pr_err("%s: bug, invalid RTSI_channel=%i\n", __func__, RTSI_channel); return 0; } @@ -1192,7 +1192,7 @@ static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor) { static const unsigned max_divisor = 0x10; if (divisor < 1 || divisor > max_divisor) { - printk("%s: bug, invalid divisor=%i\n", __func__, divisor); + pr_err("%s: bug, invalid divisor=%i\n", __func__, divisor); return 0; } return (divisor & 0xf) << 8; @@ -1202,7 +1202,7 @@ static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier) { static const unsigned max_multiplier = 0x100; if (multiplier < 1 || multiplier > max_multiplier) { - printk("%s: bug, invalid multiplier=%i\n", __func__, + pr_err("%s: bug, invalid multiplier=%i\n", __func__, multiplier); return 0; } -- cgit v1.2.3-59-g8ed1b From 68de8d673494578372d6886aefa12feb8be14b51 Mon Sep 17 00:00:00 2001 From: Mike Krinkin Date: Tue, 2 Dec 2014 14:37:45 +0300 Subject: staging: rtl8712: remove unnecessary else after return Fixes checkpatch warning: WARNING: else is not generally useful after a break or return Signed-off-by: Mike Krinkin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 27f38acc2d62..cd8b444b255b 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -522,11 +522,10 @@ int r8712_recv_indicatepkts_in_order(struct _adapter *padapter, if (bforced == true) { if (list_empty(phead)) return true; - else { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); - pattrib = &prframe->u.hdr.attrib; - preorder_ctrl->indicate_seq = pattrib->seq_num; - } + + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + pattrib = &prframe->u.hdr.attrib; + preorder_ctrl->indicate_seq = pattrib->seq_num; } /* Prepare indication list and indication. * Check if there is any packet need indicate. */ -- cgit v1.2.3-59-g8ed1b From 17d2c6439be65777245914be354c5a97c76ad246 Mon Sep 17 00:00:00 2001 From: Sean Cleator Date: Tue, 2 Dec 2014 23:45:00 +0000 Subject: Staging: slicoss: Fix long line issues in slicoss.c A patch to the slicoss.c file to fix some of the long line issues found by the checkpath.pl tool Signed-off-by: Sean Cleator Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index cff7cbea526b..42d62ef56cb8 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -498,12 +498,14 @@ static int slic_card_download(struct adapter *adapter) slic_reg32_write(&slic_regs->slic_wcs, baseaddress + codeaddr, FLUSH); /* Write out instruction to low addr */ - slic_reg32_write(&slic_regs->slic_wcs, instruction, FLUSH); + slic_reg32_write(&slic_regs->slic_wcs, + instruction, FLUSH); instruction = *(u32 *)(fw->data + index); index += 4; /* Write out instruction to high addr */ - slic_reg32_write(&slic_regs->slic_wcs, instruction, FLUSH); + slic_reg32_write(&slic_regs->slic_wcs, + instruction, FLUSH); instruction = *(u32 *)(fw->data + index); index += 4; } @@ -1532,14 +1534,18 @@ retry_rcvqfill: dev_err(dev, "%s: LOW 32bits PHYSICAL ADDRESS == 0\n", __func__); dev_err(dev, "skb[%p] PROBLEM\n", skb); - dev_err(dev, " skbdata[%p]\n", skb->data); + dev_err(dev, " skbdata[%p]\n", + skb->data); dev_err(dev, " skblen[%x]\n", skb->len); dev_err(dev, " paddr[%p]\n", paddr); dev_err(dev, " paddrl[%x]\n", paddrl); dev_err(dev, " paddrh[%x]\n", paddrh); - dev_err(dev, " rcvq->head[%p]\n", rcvq->head); - dev_err(dev, " rcvq->tail[%p]\n", rcvq->tail); - dev_err(dev, " rcvq->count[%x]\n", rcvq->count); + dev_err(dev, " rcvq->head[%p]\n", + rcvq->head); + dev_err(dev, " rcvq->tail[%p]\n", + rcvq->tail); + dev_err(dev, " rcvq->count[%x]\n", + rcvq->count); dev_err(dev, "SKIP THIS SKB!!!!!!!!\n"); goto retry_rcvqfill; } @@ -1548,14 +1554,18 @@ retry_rcvqfill: dev_err(dev, "%s: LOW 32bits PHYSICAL ADDRESS == 0\n", __func__); dev_err(dev, "skb[%p] PROBLEM\n", skb); - dev_err(dev, " skbdata[%p]\n", skb->data); + dev_err(dev, " skbdata[%p]\n", + skb->data); dev_err(dev, " skblen[%x]\n", skb->len); dev_err(dev, " paddr[%p]\n", paddr); dev_err(dev, " paddrl[%x]\n", paddrl); dev_err(dev, " paddrh[%x]\n", paddrh); - dev_err(dev, " rcvq->head[%p]\n", rcvq->head); - dev_err(dev, " rcvq->tail[%p]\n", rcvq->tail); - dev_err(dev, " rcvq->count[%x]\n", rcvq->count); + dev_err(dev, " rcvq->head[%p]\n", + rcvq->head); + dev_err(dev, " rcvq->tail[%p]\n", + rcvq->tail); + dev_err(dev, " rcvq->count[%x]\n", + rcvq->count); dev_err(dev, "GIVE TO CARD ANYWAY\n"); } #endif @@ -1884,7 +1894,8 @@ static void slic_xmit_fail(struct adapter *adapter, break; case XMIT_FAIL_HOSTCMD_FAIL: dev_err(&adapter->netdev->dev, - "xmit_start skb[%p] type[%x] No host commands available\n", skb, skb->pkt_type); + "xmit_start skb[%p] type[%x] No host commands available\n", + skb, skb->pkt_type); break; } } @@ -2096,7 +2107,8 @@ static void slic_interrupt_card_up(u32 isr, struct adapter *adapter, } } else if (isr & ISR_XDROP) { dev_err(&dev->dev, - "isr & ISR_ERR [%x] ISR_XDROP\n", isr); + "isr & ISR_ERR [%x] ISR_XDROP\n", + isr); } else { dev_err(&dev->dev, "isr & ISR_ERR [%x]\n", @@ -2340,7 +2352,8 @@ static int slic_if_init(struct adapter *adapter) SLIC_GET_ADDR_LOW(&pshmem->isr), FLUSH); #else slic_reg32_write(&slic_regs->slic_addr_upper, 0, DONT_FLUSH); - slic_reg32_write(&slic_regs->slic_isp, (u32)&pshmem->isr, FLUSH); + slic_reg32_write(&slic_regs->slic_isp, (u32)&pshmem->isr, + FLUSH); #endif spin_unlock_irqrestore(&adapter->bit64reglock.lock, adapter->bit64reglock.flags); -- cgit v1.2.3-59-g8ed1b